sqlew 2.1.4 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +891 -605
- package/README.md +302 -690
- package/assets/kanban-style.png +0 -0
- package/assets/schema.sql +531 -402
- package/dist/database.d.ts +9 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +33 -34
- package/dist/database.js.map +1 -1
- package/dist/index.js +1024 -213
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-task-tables.d.ts +47 -0
- package/dist/migrations/add-task-tables.d.ts.map +1 -0
- package/dist/migrations/add-task-tables.js +285 -0
- package/dist/migrations/add-task-tables.js.map +1 -0
- package/dist/migrations/index.d.ts +96 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +239 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts +61 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.js +442 -0
- package/dist/migrations/migrate-decisions-to-tasks.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -3
- package/dist/schema.js.map +1 -1
- package/dist/tools/constraints.d.ts +4 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +6 -27
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts +17 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +195 -190
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +113 -166
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +2 -9
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +67 -126
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/tasks.d.ts +90 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +732 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/utils.d.ts +8 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +50 -21
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/batch.d.ts +69 -0
- package/dist/utils/batch.d.ts.map +1 -0
- package/dist/utils/batch.js +148 -0
- package/dist/utils/batch.js.map +1 -0
- package/dist/utils/query-builder.d.ts +68 -0
- package/dist/utils/query-builder.d.ts.map +1 -0
- package/dist/utils/query-builder.js +116 -0
- package/dist/utils/query-builder.js.map +1 -0
- package/dist/utils/task-stale-detection.d.ts +28 -0
- package/dist/utils/task-stale-detection.d.ts.map +1 -0
- package/dist/utils/task-stale-detection.js +92 -0
- package/dist/utils/task-stale-detection.js.map +1 -0
- package/dist/utils/validators.d.ts +57 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +117 -0
- package/dist/utils/validators.js.map +1 -0
- package/docs/AI_AGENT_GUIDE.md +1471 -648
- package/{ARCHITECTURE.md → docs/ARCHITECTURE.md} +636 -636
- package/docs/BEST_PRACTICES.md +481 -0
- package/docs/DECISION_TO_TASK_MIGRATION_GUIDE.md +457 -0
- package/docs/MIGRATION_CHAIN.md +280 -0
- package/{MIGRATION_v2.md → docs/MIGRATION_v2.md} +538 -538
- package/docs/SHARED_CONCEPTS.md +339 -0
- package/docs/TASK_ACTIONS.md +854 -0
- package/docs/TASK_LINKING.md +729 -0
- package/docs/TASK_MIGRATION.md +701 -0
- package/docs/TASK_OVERVIEW.md +363 -0
- package/docs/TASK_SYSTEM.md +1244 -0
- package/docs/TOOL_REFERENCE.md +471 -0
- package/docs/TOOL_SELECTION.md +279 -0
- package/docs/WORKFLOWS.md +602 -0
- package/docs/refactoring-summary-2025-10-17.md +365 -0
- package/docs/requirement-2025-10-17.md +508 -0
- package/package.json +64 -64
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
# Task System Overview - Kanban Task Watcher
|
|
2
|
+
|
|
3
|
+
**Version:** 3.0.0
|
|
4
|
+
**Last Updated:** 2025-10-17
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
1. [Overview](#overview)
|
|
9
|
+
2. [Core Concepts](#core-concepts)
|
|
10
|
+
3. [Status Definitions](#status-definitions)
|
|
11
|
+
4. [State Machine Transitions](#state-machine-transitions)
|
|
12
|
+
5. [Auto-Stale Detection](#auto-stale-detection)
|
|
13
|
+
6. [Priority System](#priority-system)
|
|
14
|
+
7. [Quick Start](#quick-start)
|
|
15
|
+
8. [Related Documentation](#related-documentation)
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
The Kanban Task Watcher is an AI-optimized task management system designed to solve token waste from misuse of the `decision` tool for task/todo tracking.
|
|
20
|
+
|
|
21
|
+
### Problem Statement
|
|
22
|
+
|
|
23
|
+
Real-world usage analysis revealed:
|
|
24
|
+
- **204 task-like decisions** in 3-day production usage
|
|
25
|
+
- **~825 tokens** to query 10 task-like decisions (332 bytes/decision average)
|
|
26
|
+
- **No lifecycle management:** Tasks stuck in "in_progress" after interrupts or usage limits
|
|
27
|
+
- **Inefficient queries:** Full text content loaded even for simple list operations
|
|
28
|
+
|
|
29
|
+
### Solution
|
|
30
|
+
|
|
31
|
+
Dedicated Kanban task system with:
|
|
32
|
+
- **70% token reduction** via metadata-only list queries
|
|
33
|
+
- **Auto-stale detection** to handle interrupted sessions
|
|
34
|
+
- **Status validation** with enforced state machine transitions
|
|
35
|
+
- **Linking system** to connect tasks with decisions, constraints, files
|
|
36
|
+
- **Flat hierarchy** for AI simplicity (no subtasks)
|
|
37
|
+
|
|
38
|
+
## Core Concepts
|
|
39
|
+
|
|
40
|
+
### Task Structure
|
|
41
|
+
|
|
42
|
+
Every task has:
|
|
43
|
+
- **Identity:** `task_id`, `title`
|
|
44
|
+
- **Status:** Lifecycle stage (todo → in_progress → done → archived)
|
|
45
|
+
- **Metadata:** `priority`, `assignee`, `tags`, `layer`
|
|
46
|
+
- **Content:** Optional `description` (stored separately for token efficiency)
|
|
47
|
+
- **Links:** Connections to decisions, constraints, files
|
|
48
|
+
- **Timestamps:** `created_ts`, `updated_ts`
|
|
49
|
+
|
|
50
|
+
### Token Efficiency Strategy
|
|
51
|
+
|
|
52
|
+
**Metadata-Only Queries:**
|
|
53
|
+
- **`list` action:** Returns metadata only (~100 bytes/task)
|
|
54
|
+
- **`get` action:** Returns full details with description (~332 bytes/task)
|
|
55
|
+
- **70% reduction** compared to decision-based task tracking
|
|
56
|
+
|
|
57
|
+
**Comparison Table:**
|
|
58
|
+
|
|
59
|
+
| Query Type | Bytes/Task | 10 Tasks | Use Case |
|
|
60
|
+
|------------|-----------|----------|----------|
|
|
61
|
+
| `list` (metadata only) | ~100 | ~1,000 | Browse, filter, status check |
|
|
62
|
+
| `get` (full details) | ~332 | ~3,320 | Read description, view links |
|
|
63
|
+
| Old `decision` method | ~332 | ~3,320 | What AIs were doing before v3.0 |
|
|
64
|
+
|
|
65
|
+
### Flat Hierarchy
|
|
66
|
+
|
|
67
|
+
**Design Decision:** No subtasks
|
|
68
|
+
- Simpler for AI agents to manage
|
|
69
|
+
- Clearer status tracking
|
|
70
|
+
- Easier to query and filter
|
|
71
|
+
- Use tags/links for relationships instead
|
|
72
|
+
|
|
73
|
+
## Status Definitions
|
|
74
|
+
|
|
75
|
+
| Status | ID | Description | Use Case |
|
|
76
|
+
|--------|----|-----------|----|
|
|
77
|
+
| `todo` | 1 | Not yet started | Backlog, planned work |
|
|
78
|
+
| `in_progress` | 2 | Actively being worked on | Current focus |
|
|
79
|
+
| `waiting_review` | 3 | Awaiting feedback or approval | Code review, design review |
|
|
80
|
+
| `blocked` | 4 | Cannot proceed due to blocker | Dependency, question, issue |
|
|
81
|
+
| `done` | 5 | Completed | Finished work |
|
|
82
|
+
| `archived` | 6 | Completed and archived | Historical reference |
|
|
83
|
+
|
|
84
|
+
### Status Best Practices
|
|
85
|
+
|
|
86
|
+
**`todo`:**
|
|
87
|
+
- Use for backlog items
|
|
88
|
+
- No one actively working
|
|
89
|
+
- Ready to be picked up
|
|
90
|
+
|
|
91
|
+
**`in_progress`:**
|
|
92
|
+
- Active work happening
|
|
93
|
+
- Should have assignee
|
|
94
|
+
- Auto-transitions to `waiting_review` after 2 hours idle
|
|
95
|
+
|
|
96
|
+
**`waiting_review`:**
|
|
97
|
+
- Awaiting human/AI feedback
|
|
98
|
+
- Code review needed
|
|
99
|
+
- Design approval pending
|
|
100
|
+
- Auto-transitions to `todo` after 24 hours idle
|
|
101
|
+
|
|
102
|
+
**`blocked`:**
|
|
103
|
+
- Cannot proceed
|
|
104
|
+
- Has explicit blocker (dependency, question, issue)
|
|
105
|
+
- Should have comment explaining blocker
|
|
106
|
+
|
|
107
|
+
**`done`:**
|
|
108
|
+
- Work completed
|
|
109
|
+
- Verified/tested
|
|
110
|
+
- Can be archived
|
|
111
|
+
|
|
112
|
+
**`archived`:**
|
|
113
|
+
- Historical reference only
|
|
114
|
+
- Completed tasks no longer active
|
|
115
|
+
- Terminal state (no transitions out)
|
|
116
|
+
|
|
117
|
+
## State Machine Transitions
|
|
118
|
+
|
|
119
|
+
### Visual Diagram
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
todo → in_progress → waiting_review → done → archived
|
|
123
|
+
↓ ↓
|
|
124
|
+
blocked ────────┘
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Valid Transitions
|
|
128
|
+
|
|
129
|
+
| From Status | To Status(es) | Rationale |
|
|
130
|
+
|-------------|--------------|-----------|
|
|
131
|
+
| `todo` | `in_progress`, `blocked` | Start work or discover blocker |
|
|
132
|
+
| `in_progress` | `waiting_review`, `blocked`, `done` | Need review, hit blocker, or complete |
|
|
133
|
+
| `waiting_review` | `in_progress`, `todo`, `done` | Resume work, reset to backlog, or approve |
|
|
134
|
+
| `blocked` | `todo`, `in_progress` | Blocker resolved, resume or reset |
|
|
135
|
+
| `done` | `archived` | Archive completed work |
|
|
136
|
+
| `archived` | *(terminal state)* | No transitions allowed |
|
|
137
|
+
|
|
138
|
+
### Complete Transition Matrix
|
|
139
|
+
|
|
140
|
+
| From ↓ / To → | todo | in_progress | waiting_review | blocked | done | archived |
|
|
141
|
+
|---------------|------|-------------|----------------|---------|------|----------|
|
|
142
|
+
| **todo** | - | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
143
|
+
| **in_progress** | ❌ | - | ✅ | ✅ | ✅ | ❌ |
|
|
144
|
+
| **waiting_review** | ✅ | ✅ | - | ❌ | ✅ | ❌ |
|
|
145
|
+
| **blocked** | ✅ | ✅ | ❌ | - | ❌ | ❌ |
|
|
146
|
+
| **done** | ❌ | ❌ | ❌ | ❌ | - | ✅ |
|
|
147
|
+
| **archived** | ❌ | ❌ | ❌ | ❌ | ❌ | - |
|
|
148
|
+
|
|
149
|
+
✅ = Valid transition
|
|
150
|
+
❌ = Invalid transition
|
|
151
|
+
\- = Same status (no transition)
|
|
152
|
+
|
|
153
|
+
### Validation
|
|
154
|
+
|
|
155
|
+
- Enforced by `move` action
|
|
156
|
+
- Invalid transitions return error with valid options
|
|
157
|
+
- Use `update` action to bypass validation (use with caution)
|
|
158
|
+
|
|
159
|
+
**Example Error:**
|
|
160
|
+
```javascript
|
|
161
|
+
{
|
|
162
|
+
action: "move",
|
|
163
|
+
task_id: 1,
|
|
164
|
+
new_status: "archived" // Task is in_progress
|
|
165
|
+
}
|
|
166
|
+
// Error: Invalid status transition from in_progress to archived.
|
|
167
|
+
// Valid transitions: waiting_review, blocked, done
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Auto-Stale Detection
|
|
171
|
+
|
|
172
|
+
### Overview
|
|
173
|
+
|
|
174
|
+
Auto-stale detection automatically transitions idle tasks to prevent them from getting stuck.
|
|
175
|
+
|
|
176
|
+
**Why It's Needed:**
|
|
177
|
+
- AI agents hit usage limits mid-task
|
|
178
|
+
- Sessions get interrupted (network, timeout)
|
|
179
|
+
- Code generation takes longer than expected
|
|
180
|
+
- Reviews don't happen promptly
|
|
181
|
+
|
|
182
|
+
### Detection Rules
|
|
183
|
+
|
|
184
|
+
1. **`in_progress` → `waiting_review`** (>2 hours idle)
|
|
185
|
+
- Rationale: Likely waiting for review or hit usage limit
|
|
186
|
+
- Check: `updated_ts` older than 2 hours
|
|
187
|
+
|
|
188
|
+
2. **`waiting_review` → `todo`** (>24 hours idle)
|
|
189
|
+
- Rationale: Review not happening, reset to backlog
|
|
190
|
+
- Check: `updated_ts` older than 24 hours
|
|
191
|
+
|
|
192
|
+
### When It Runs
|
|
193
|
+
|
|
194
|
+
Automatically runs before:
|
|
195
|
+
1. **`list` action** - Ensures stale tasks show correct status
|
|
196
|
+
2. **`move` action** - Prevents moving already-stale tasks
|
|
197
|
+
|
|
198
|
+
**Response includes:**
|
|
199
|
+
- `stale_tasks_transitioned`: Count of auto-transitioned tasks
|
|
200
|
+
|
|
201
|
+
**Example Response:**
|
|
202
|
+
```javascript
|
|
203
|
+
{
|
|
204
|
+
tasks: [...],
|
|
205
|
+
count: 5,
|
|
206
|
+
stale_tasks_transitioned: 2 // 2 tasks auto-transitioned
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Configuration
|
|
211
|
+
|
|
212
|
+
**Default Settings:**
|
|
213
|
+
- `task_auto_stale_enabled`: '1' (enabled)
|
|
214
|
+
- `task_stale_hours_in_progress`: '2' (2 hours)
|
|
215
|
+
- `task_stale_hours_waiting_review`: '24' (24 hours)
|
|
216
|
+
|
|
217
|
+
**Enable/Disable:**
|
|
218
|
+
```sql
|
|
219
|
+
UPDATE m_config SET value = '1' WHERE key = 'task_auto_stale_enabled'; -- Enable
|
|
220
|
+
UPDATE m_config SET value = '0' WHERE key = 'task_auto_stale_enabled'; -- Disable
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Adjust Thresholds:**
|
|
224
|
+
```sql
|
|
225
|
+
-- in_progress → waiting_review after 4 hours
|
|
226
|
+
UPDATE m_config SET value = '4' WHERE key = 'task_stale_hours_in_progress';
|
|
227
|
+
|
|
228
|
+
-- waiting_review → todo after 48 hours
|
|
229
|
+
UPDATE m_config SET value = '48' WHERE key = 'task_stale_hours_waiting_review';
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Check Current Config:**
|
|
233
|
+
```sql
|
|
234
|
+
SELECT key, value FROM m_config WHERE key LIKE 'task_%';
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Monitoring
|
|
238
|
+
|
|
239
|
+
Track transitions via `t_activity_log` table:
|
|
240
|
+
|
|
241
|
+
```sql
|
|
242
|
+
-- Recent auto-transitions
|
|
243
|
+
SELECT * FROM t_activity_log
|
|
244
|
+
WHERE entity_type = 'task' AND action_type = 'status_change'
|
|
245
|
+
ORDER BY ts DESC LIMIT 20;
|
|
246
|
+
|
|
247
|
+
-- Frequently stale tasks (>2 auto-transitions)
|
|
248
|
+
SELECT task_id, COUNT(*) as stale_count FROM t_activity_log
|
|
249
|
+
WHERE entity_type = 'task' AND json_extract(details, '$.new_status') = 3
|
|
250
|
+
GROUP BY task_id HAVING stale_count > 2;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Priority System
|
|
254
|
+
|
|
255
|
+
### Priority Levels
|
|
256
|
+
|
|
257
|
+
| Priority | ID | Description | Use Case |
|
|
258
|
+
|----------|----|-----------|----|
|
|
259
|
+
| `low` | 1 | Nice to have | Documentation, cleanup |
|
|
260
|
+
| `medium` | 2 | Normal priority | Standard features |
|
|
261
|
+
| `high` | 3 | Important work | Critical features |
|
|
262
|
+
| `critical` | 4 | Urgent blocker | Production issues, blockers |
|
|
263
|
+
|
|
264
|
+
### Priority Usage
|
|
265
|
+
|
|
266
|
+
**For AI Agents:**
|
|
267
|
+
```javascript
|
|
268
|
+
// Critical blocker
|
|
269
|
+
{ action: "create", title: "Fix DB connection", priority: "critical" }
|
|
270
|
+
|
|
271
|
+
// High priority feature
|
|
272
|
+
{ action: "create", title: "Implement API", priority: "high" }
|
|
273
|
+
|
|
274
|
+
// Background work
|
|
275
|
+
{ action: "create", title: "Update docs", priority: "low" }
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Filtering by Priority:**
|
|
279
|
+
```javascript
|
|
280
|
+
// Get all critical tasks
|
|
281
|
+
{
|
|
282
|
+
action: "list",
|
|
283
|
+
priority: "critical"
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Quick Start
|
|
288
|
+
|
|
289
|
+
### Creating Your First Task
|
|
290
|
+
|
|
291
|
+
```javascript
|
|
292
|
+
// Minimal task creation
|
|
293
|
+
{
|
|
294
|
+
action: "create",
|
|
295
|
+
title: "Implement JWT authentication"
|
|
296
|
+
}
|
|
297
|
+
// Returns: { task_id: 1, message: "Task created successfully" }
|
|
298
|
+
|
|
299
|
+
// Complete task creation with metadata
|
|
300
|
+
{
|
|
301
|
+
action: "create",
|
|
302
|
+
title: "Implement JWT authentication",
|
|
303
|
+
description: "Add JWT-based authentication to API endpoints with refresh token support",
|
|
304
|
+
status: "todo",
|
|
305
|
+
priority: "high",
|
|
306
|
+
assignee: "auth-agent",
|
|
307
|
+
tags: ["security", "authentication", "api"],
|
|
308
|
+
layer: "business"
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Listing Tasks
|
|
313
|
+
|
|
314
|
+
```javascript
|
|
315
|
+
// List all tasks (metadata only - token efficient)
|
|
316
|
+
{
|
|
317
|
+
action: "list"
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// List filtered tasks
|
|
321
|
+
{
|
|
322
|
+
action: "list",
|
|
323
|
+
status: "in_progress",
|
|
324
|
+
assignee: "auth-agent",
|
|
325
|
+
tags: ["security"]
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Getting Task Details
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
// Get full task with description
|
|
333
|
+
{
|
|
334
|
+
action: "get",
|
|
335
|
+
task_id: 1
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Moving Tasks
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
// Move task to next status (validated)
|
|
343
|
+
{
|
|
344
|
+
action: "move",
|
|
345
|
+
task_id: 1,
|
|
346
|
+
new_status: "waiting_review"
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Related Documentation
|
|
351
|
+
|
|
352
|
+
- **[TASK_ACTIONS.md](TASK_ACTIONS.md)** - Complete action reference with examples
|
|
353
|
+
- **[TASK_LINKING.md](TASK_LINKING.md)** - Linking tasks to decisions/constraints/files
|
|
354
|
+
- **[TASK_MIGRATION.md](TASK_MIGRATION.md)** - Migrating from decision-based task tracking
|
|
355
|
+
- **[TASK_SYSTEM.md](TASK_SYSTEM.md)** - Complete documentation (original)
|
|
356
|
+
- **[AI_AGENT_GUIDE.md](AI_AGENT_GUIDE.md)** - Comprehensive AI agent guide
|
|
357
|
+
- **[README.md](../README.md)** - Project overview
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
**Version:** 3.0.0
|
|
362
|
+
**Last Updated:** 2025-10-17
|
|
363
|
+
**Author:** sin5ddd
|