intent-engine 0.11.1

A command-line database service for tracking strategic intent, tasks, and events
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# Dashboard API Reference

**Version**: 0.5.0 (Phase 1 MVP)
**Base URL**: `http://localhost:<PORT>/api` or `http://<your-ip>:<PORT>/api`

⚠️ **Security Notice**: The Dashboard API is accessible from your local network without authentication. Only use on trusted networks.

---

## Overview

The Intent-Engine Dashboard provides a RESTful API for managing tasks and events. All endpoints return JSON responses with a consistent structure.

**Network Access**:
- Local: `http://localhost:11391/api` (default port)
- Network: `http://<your-machine-ip>:11391/api` (e.g., from Windows host when running in WSL)

### Response Format

**Success Response**:
```json
{
  "data": <result_object_or_array>
}
```

**Error Response**:
```json
{
  "code": "ERROR_CODE",
  "message": "Human-readable error message",
  "details": {} // Optional
}
```

### HTTP Status Codes

- `200 OK` - Success
- `201 Created` - Resource created
- `204 No Content` - Success with no body
- `400 Bad Request` - Invalid request
- `404 Not Found` - Resource not found
- `500 Internal Server Error` - Server error

---

## Endpoints

### Health & Info

#### GET /api/health

Health check endpoint.

**Response**:
```json
{
  "status": "healthy",
  "service": "intent-engine-dashboard",
  "version": "0.5.0"
}
```

#### GET /api/info

Get project information.

**Response**:
```json
{
  "name": "my-project",
  "path": "/path/to/project",
  "database": "/path/to/.intent-engine/intents.db",
  "port": 11391
}
```

---

### Tasks

#### GET /api/tasks

List all tasks with optional filtering.

**Query Parameters**:
- `status` (optional): Filter by status (`todo`, `doing`, `done`)
- `parent` (optional): Filter by parent ID or `"null"` for top-level tasks

**Example**:
```bash
GET /api/tasks?status=todo
GET /api/tasks?parent=null
GET /api/tasks?parent=42
```

**Response**:
```json
{
  "data": [
    {
      "id": 1,
      "name": "Task name",
      "spec": "Task specification (Markdown)",
      "status": "todo",
      "priority": 0,
      "parent_id": null,
      "first_todo_at": "2025-11-16T12:00:00Z",
      "first_doing_at": null,
      "first_done_at": null
    }
  ]
}
```

#### GET /api/tasks/:id

Get a single task by ID.

**Parameters**:
- `:id` - Task ID (integer)

**Response**:
```json
{
  "data": {
    "id": 42,
    "name": "Implement authentication",
    "spec": "# Authentication Implementation\n\n...",
    "status": "doing",
    "priority": 1,
    "parent_id": null,
    "first_todo_at": "2025-11-16T12:00:00Z",
    "first_doing_at": "2025-11-16T13:00:00Z",
    "first_done_at": null
  }
}
```

**Errors**:
- `404` - Task not found

#### POST /api/tasks

Create a new task.

**Request Body**:
```json
{
  "name": "Task name (required)",
  "spec": "Specification in Markdown (optional)",
  "priority": 1,  // 1=critical, 2=high, 3=medium, 4=low (optional)
  "parent_id": 42 // Parent task ID (optional)
}
```

**Response**: `201 Created`
```json
{
  "data": {
    "id": 100,
    "name": "Task name",
    ...
  }
}
```

#### PATCH /api/tasks/:id

Update a task.

**Request Body** (all fields optional):
```json
{
  "name": "New name",
  "spec": "Updated specification",
  "priority": 2,
  "status": "doing" // "todo", "doing", "done"
}
```

**Response**: `200 OK`
```json
{
  "data": {
    "id": 42,
    "name": "New name",
    ...
  }
}
```

**Errors**:
- `404` - Task not found

#### DELETE /api/tasks/:id

Delete a task.

**Response**: `204 No Content`

**Errors**:
- `404` - Task not found
- `400` - Task has subtasks (cannot delete)

---

### Task Operations

#### POST /api/tasks/:id/start

Start a task (set as current focus).

**Response**: `200 OK`
```json
{
  "data": {
    "id": 42,
    "status": "doing",
    ...
  }
}
```

**Errors**:
- `404` - Task not found
- `400` - Task has unmet dependencies

#### POST /api/tasks/done

Complete the currently focused task.

**Note**: This is a global operation with **no ID parameter**.

**Response**: `200 OK`
```json
{
  "data": {
    "id": 42,
    "status": "done",
    ...
  }
}
```

**Errors**:
- `400` - No current task
- `400` - Task has incomplete subtasks

#### POST /api/tasks/:id/switch

Switch focus to a different task.

**Response**: `200 OK`
```json
{
  "data": {
    "id": 50,
    "status": "doing",
    ...
  }
}
```

**Errors**:
- `404` - Task not found

#### POST /api/tasks/:id/spawn-subtask

Create a subtask of the **current task** and switch focus to it.

**Note**: The `:id` parameter is **ignored**. The current task is used as parent.

**Request Body**:
```json
{
  "name": "Subtask name (required)",
  "spec": "Specification (optional)"
}
```

**Response**: `201 Created`
```json
{
  "data": {
    "parent_task": { ... },
    "subtask": {
      "id": 101,
      "parent_id": 42,
      "name": "Subtask name",
      ...
    }
  }
}
```

**Errors**:
- `400` - No current task

---

### Events

#### GET /api/tasks/:id/events

List events for a task.

**Query Parameters**:
- `event_type` (optional): Filter by type (`decision`, `blocker`, `milestone`, `note`)
- `since` (optional): Time filter (`1d`, `7d`, `24h`, etc.)
- `limit` (optional): Maximum number of events (integer)

**Example**:
```bash
GET /api/tasks/42/events?event_type=decision
GET /api/tasks/42/events?since=7d&limit=10
```

**Response**:
```json
{
  "data": [
    {
      "id": 1,
      "task_id": 42,
      "log_type": "decision",
      "discussion_data": "Chose approach A because...",
      "timestamp": "2025-11-16T14:00:00Z"
    }
  ]
}
```

#### POST /api/tasks/:id/events

Add an event to a task.

**Request Body**:
```json
{
  "type": "decision",  // "decision", "blocker", "milestone", "note"
  "data": "Event content in Markdown"
}
```

**Response**: `201 Created`
```json
{
  "data": {
    "id": 10,
    "task_id": 42,
    "log_type": "decision",
    "discussion_data": "Event content...",
    "timestamp": "2025-11-16T14:30:00Z"
  }
}
```

**Errors**:
- `400` - Invalid event type

---

### Global Operations

#### GET /api/current-task

Get the currently focused task.

**Response**:
```json
{
  "data": {
    "current_task_id": 42,
    "task": {
      "id": 42,
      "name": "Current task",
      ...
    }
  }
}
```

**If no current task**:
```json
{
  "data": null,
  "message": "No current task"
}
```

#### GET /api/pick-next

Get the recommended next task based on priority and focus.

**Response**:
```json
{
  "data": {
    "task": {
      "id": 50,
      "name": "Next recommended task",
      ...
    },
    "reason": "Depth-first: subtask of current task"
  }
}
```

**If no tasks available**:
```json
{
  "data": {
    "task": null,
    "reason": "No tasks available"
  }
}
```

#### GET /api/search

Unified search across tasks and events.

**Query Parameters**:
- `query` (required): Search query (supports FTS5 syntax)
- `include_tasks` (optional): Include tasks in results (default: `true`)
- `include_events` (optional): Include events in results (default: `true`)
- `limit` (optional): Maximum results (default: 20)

**Example**:
```bash
GET /api/search?query=authentication
GET /api/search?query=JWT AND token&include_events=false
```

**Response**:
```json
{
  "data": [
    {
      "result_type": "task",
      "task": { ... },
      "match_field": "name",
      "match_snippet": "...authentication..."
    },
    {
      "result_type": "event",
      "event": { ... },
      "task_chain": [{ "id": 42, "name": "Parent" }],
      "match_snippet": "...JWT token..."
    }
  ]
}
```

---

## Error Codes

### Task Errors

- `TASK_NOT_FOUND` (404) - Task with given ID does not exist
- `NO_CURRENT_TASK` (400) - No task is currently focused
- `TASK_HAS_SUBTASKS` (400) - Cannot delete/complete task with incomplete subtasks
- `TASK_BLOCKED` (400) - Task has unmet dependencies

### Request Errors

- `INVALID_REQUEST` (400) - Malformed request or invalid parameters
- `INVALID_EVENT_TYPE` (400) - Event type must be decision/blocker/milestone/note

### Server Errors

- `DATABASE_ERROR` (500) - Database operation failed
- `INTERNAL_ERROR` (500) - Unexpected server error

---

## Authentication

**Phase 1**: No authentication required.

⚠️ **Security Warning**: Dashboard binds to `0.0.0.0` (accessible from local network). Only use on trusted networks.

**Current Binding**: All network interfaces (`0.0.0.0`) for development convenience (e.g., WSL access from Windows host)

**Future**: Phase 2+ will add authentication (API keys, JWT).

---

## Rate Limiting

**Phase 1**: No rate limiting.

**Future**: Phase 2+ will add rate limiting for production use.

---

## CORS

CORS is enabled for all origins in Phase 1 (development mode).

Allowed methods: `GET`, `POST`, `PATCH`, `DELETE`
Allowed headers: All

---

## Example Workflows

### Create and Complete a Task

```bash
# 1. Create task
curl -X POST http://127.0.0.1:11391/api/tasks \
  -H "Content-Type: application/json" \
  -d '{"name": "Fix bug #123", "priority": 1}'

# Response: {"data": {"id": 100, ...}}

# 2. Start task
curl -X POST http://127.0.0.1:11391/api/tasks/100/start

# 3. Add a decision event
curl -X POST http://127.0.0.1:11391/api/tasks/100/events \
  -H "Content-Type: application/json" \
  -d '{"type": "decision", "data": "Fixed by reverting commit abc123"}'

# 4. Complete task
curl -X POST http://127.0.0.1:11391/api/tasks/done

# Response: {"data": {"id": 100, "status": "done", ...}}
```

### Search and Update

```bash
# 1. Search for tasks
curl "http://127.0.0.1:11391/api/search?query=authentication"

# 2. Update a task
curl -X PATCH http://127.0.0.1:11391/api/tasks/42 \
  -H "Content-Type: application/json" \
  -d '{"priority": 1, "spec": "Updated specification"}'
```

---

## Notes

- All timestamps are in ISO 8601 format (UTC)
- Markdown content is stored as-is; rendering happens client-side
- Task IDs are auto-incremented integers
- Priority: 1 (highest) to 4 (lowest), 0 = default

---

**Last Updated**: 2025-11-16
**Version**: 0.5.0