agileflow 3.2.0 → 3.3.0

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.
@@ -0,0 +1,424 @@
1
+ # Portable Task Tracking System
2
+
3
+ A file-based, IDE-agnostic task tracking system for AgileFlow projects. Works with Claude Code, Cursor, Windsurf, Codex, and any IDE that can read/write files.
4
+
5
+ ## Overview
6
+
7
+ Unlike Claude Code's native `TaskCreate`/`TaskUpdate` tools (which only work in Claude Code), this system stores tasks in a simple markdown file (`.agileflow/tasks.md`) that ANY IDE's AI can read and modify.
8
+
9
+ **Key Features:**
10
+ - Pure markdown format - human-readable, git-friendly
11
+ - No dependencies beyond Node.js built-ins
12
+ - Works across all IDEs
13
+ - Supports filtering, custom fields, and blocking relationships
14
+ - Round-trip stable (parse → modify → format → parse)
15
+
16
+ ## Files
17
+
18
+ - **`portable-tasks.js`** - Core module (functions for CRUD operations)
19
+ - **`portable-tasks-cli.js`** - Command-line interface (callable from any IDE)
20
+
21
+ ## Installation
22
+
23
+ Copy both files to your project's `.agileflow/scripts/lib/` directory during setup. They are published with the agileflow npm package.
24
+
25
+ ## File Format
26
+
27
+ Tasks are stored in `.agileflow/tasks.md`:
28
+
29
+ ```markdown
30
+ # AgileFlow Tasks
31
+
32
+ > Auto-managed task list. Edit carefully - format matters.
33
+ > Last updated: 2026-02-20T15:30:00Z
34
+
35
+ ## Active Tasks
36
+
37
+ ### T-001: Implement user authentication [in_progress]
38
+ - **Owner**: AG-API
39
+ - **Created**: 2026-02-20
40
+ - **Story**: US-0042
41
+ - **Description**: Add JWT-based auth to /api/login endpoint
42
+
43
+ ### T-002: Write auth tests [pending]
44
+ - **Owner**: AG-CI
45
+ - **Created**: 2026-02-20
46
+ - **Story**: US-0042
47
+ - **Blocked by**: T-001
48
+ - **Description**: Unit and integration tests for auth flow
49
+
50
+ ## Completed Tasks
51
+
52
+ ### T-003: Setup database schema [completed]
53
+ - **Owner**: AG-DEVOPS
54
+ - **Created**: 2026-02-19
55
+ - **Completed**: 2026-02-20
56
+ - **Story**: US-0041
57
+ - **Description**: Create users and sessions tables
58
+ ```
59
+
60
+ ## API Reference
61
+
62
+ ### Module: `portable-tasks.js`
63
+
64
+ #### `loadTasks(projectDir)`
65
+ Load tasks from `.agileflow/tasks.md`.
66
+
67
+ ```javascript
68
+ const { loadTasks } = require('./portable-tasks');
69
+ const { activeTasks, completedTasks } = loadTasks(process.cwd());
70
+ ```
71
+
72
+ Returns: `{ activeTasks: [], completedTasks: [] }`
73
+
74
+ #### `saveTasks(projectDir, tasksData)`
75
+ Save tasks back to markdown file.
76
+
77
+ ```javascript
78
+ saveTasks(process.cwd(), { activeTasks, completedTasks });
79
+ ```
80
+
81
+ Returns: `boolean` (success/failure)
82
+
83
+ #### `addTask(projectDir, taskData)`
84
+ Create a new task.
85
+
86
+ ```javascript
87
+ const result = addTask(process.cwd(), {
88
+ subject: 'Write API tests',
89
+ description: 'Integration tests for new endpoints',
90
+ owner: 'AG-CI',
91
+ status: 'pending', // pending, in_progress, completed, blocked
92
+ story: 'US-0040',
93
+ blockedBy: 'T-001', // optional
94
+ });
95
+
96
+ // result: { ok: true, taskId: 'T-001' } or { ok: false, error: 'message' }
97
+ ```
98
+
99
+ #### `updateTask(projectDir, taskId, updates)`
100
+ Update an existing task.
101
+
102
+ ```javascript
103
+ updateTask(process.cwd(), 'T-001', {
104
+ status: 'in_progress',
105
+ description: 'Updated description',
106
+ owner: 'AG-DEVOPS',
107
+ });
108
+ ```
109
+
110
+ Returns: `{ ok: boolean, error?: string }`
111
+
112
+ Moves task between active/completed sections automatically when status changes.
113
+
114
+ #### `deleteTask(projectDir, taskId)`
115
+ Remove a task.
116
+
117
+ ```javascript
118
+ deleteTask(process.cwd(), 'T-001');
119
+ ```
120
+
121
+ Returns: `{ ok: boolean, error?: string }`
122
+
123
+ #### `getTask(projectDir, taskId)`
124
+ Retrieve a single task by ID.
125
+
126
+ ```javascript
127
+ const task = getTask(process.cwd(), 'T-001');
128
+ // Returns task object or null if not found
129
+ ```
130
+
131
+ #### `listTasks(projectDir, filters?)`
132
+ List tasks with optional filtering.
133
+
134
+ ```javascript
135
+ // All active tasks (default)
136
+ const tasks = listTasks(process.cwd());
137
+
138
+ // Filter by status
139
+ listTasks(process.cwd(), { status: 'pending' });
140
+ listTasks(process.cwd(), { status: ['pending', 'blocked'] });
141
+
142
+ // Filter by owner
143
+ listTasks(process.cwd(), { owner: 'AG-API' });
144
+
145
+ // Include completed tasks
146
+ listTasks(process.cwd(), { includeCompleted: true });
147
+
148
+ // Combine filters
149
+ listTasks(process.cwd(), {
150
+ status: 'pending',
151
+ owner: 'AG-API',
152
+ includeCompleted: true,
153
+ });
154
+ ```
155
+
156
+ Returns: `Array` of task objects
157
+
158
+ #### `getNextId(tasks)`
159
+ Generate the next sequential task ID.
160
+
161
+ ```javascript
162
+ const nextId = getNextId(allTasks); // 'T-001', 'T-002', etc.
163
+ ```
164
+
165
+ #### Parsing Functions
166
+ - `parseTasksFile(content)` - Parse markdown content into task objects
167
+ - `formatTasksFile(activeTasks, completedTasks)` - Generate markdown from tasks
168
+
169
+ ## CLI: `portable-tasks-cli.js`
170
+
171
+ Command-line interface for task management (works in any IDE's terminal).
172
+
173
+ ### Usage
174
+
175
+ ```bash
176
+ node portable-tasks-cli.js [command] [options]
177
+ ```
178
+
179
+ ### Commands
180
+
181
+ #### List Tasks
182
+ ```bash
183
+ # List active tasks
184
+ node portable-tasks-cli.js list
185
+
186
+ # Filter by status
187
+ node portable-tasks-cli.js list --status=pending
188
+ node portable-tasks-cli.js list --status=in_progress
189
+
190
+ # Filter by owner
191
+ node portable-tasks-cli.js list --owner=AG-API
192
+
193
+ # Include completed tasks
194
+ node portable-tasks-cli.js list --include-completed
195
+
196
+ # Output as JSON
197
+ node portable-tasks-cli.js list --json
198
+
199
+ # Combine filters
200
+ node portable-tasks-cli.js list --status=pending --owner=AG-CI
201
+ ```
202
+
203
+ #### Add Task
204
+ ```bash
205
+ # Minimal (subject required)
206
+ node portable-tasks-cli.js add --subject="Fix login bug"
207
+
208
+ # Full details
209
+ node portable-tasks-cli.js add \
210
+ --subject="Implement auth" \
211
+ --description="Add JWT tokens to API" \
212
+ --owner=AG-API \
213
+ --status=in_progress \
214
+ --story=US-0040 \
215
+ --blocked-by=T-001
216
+ ```
217
+
218
+ #### Update Task
219
+ ```bash
220
+ # Change status
221
+ node portable-tasks-cli.js update T-001 --status=completed
222
+
223
+ # Update multiple fields
224
+ node portable-tasks-cli.js update T-001 \
225
+ --status=in_progress \
226
+ --owner=AG-API \
227
+ --description="Started implementation"
228
+ ```
229
+
230
+ #### Get Task
231
+ ```bash
232
+ # Display task
233
+ node portable-tasks-cli.js get T-001
234
+
235
+ # Output as JSON
236
+ node portable-tasks-cli.js get T-001 --json
237
+ ```
238
+
239
+ #### Delete Task
240
+ ```bash
241
+ node portable-tasks-cli.js delete T-001
242
+ node portable-tasks-cli.js rm T-001 # alias
243
+ ```
244
+
245
+ ### Output Formats
246
+
247
+ **Human-readable (default):**
248
+ ```
249
+ T-001 [in_progress] Implement user auth (AG-API) [blocked by T-002]
250
+ T-002 [pending] Write tests (AG-CI)
251
+ ```
252
+
253
+ **JSON output:**
254
+ ```json
255
+ [
256
+ {
257
+ "id": "T-001",
258
+ "title": "Implement user auth",
259
+ "status": "in_progress",
260
+ "owner": "AG-API",
261
+ "created": "2026-02-20",
262
+ "completed": null,
263
+ "story": "US-0040",
264
+ "blockedBy": "T-002",
265
+ "description": "Add JWT tokens to /api/login endpoint"
266
+ }
267
+ ]
268
+ ```
269
+
270
+ ### Exit Codes
271
+ - **0**: Success
272
+ - **1**: Error (invalid command, missing task, etc.)
273
+
274
+ ## Task Fields
275
+
276
+ Every task has these fields:
277
+
278
+ | Field | Type | Required | Description |
279
+ |-------|------|----------|-------------|
280
+ | `id` | string | Yes | Auto-generated ID (T-001, T-002, etc.) |
281
+ | `title` | string | Yes | Task summary |
282
+ | `status` | string | Yes | One of: `pending`, `in_progress`, `completed`, `blocked` |
283
+ | `owner` | string | No | Responsible agent/team (e.g., AG-API) |
284
+ | `created` | date | No | Creation date (YYYY-MM-DD) |
285
+ | `completed` | date | No | Completion date (auto-set when status → completed) |
286
+ | `story` | string | No | Link to parent story (e.g., US-0040) |
287
+ | `blockedBy` | string | No | Task ID blocking this task (e.g., T-001) |
288
+ | `description` | string | No | Detailed task description |
289
+
290
+ ## Examples
291
+
292
+ ### Python Script Using Module
293
+ ```python
294
+ import subprocess
295
+ import json
296
+
297
+ # List all pending tasks
298
+ result = subprocess.run(
299
+ ['node', '.agileflow/scripts/lib/portable-tasks-cli.js', 'list', '--status=pending', '--json'],
300
+ capture_output=True,
301
+ text=True
302
+ )
303
+ tasks = json.loads(result.stdout)
304
+ for task in tasks:
305
+ print(f"{task['id']}: {task['title']} ({task['owner']})")
306
+ ```
307
+
308
+ ### JavaScript Using Module
309
+ ```javascript
310
+ const { addTask, listTasks, updateTask } = require('./.agileflow/scripts/lib/portable-tasks');
311
+
312
+ // Create task
313
+ const result = addTask(process.cwd(), {
314
+ subject: 'Run integration tests',
315
+ owner: 'AG-CI',
316
+ status: 'pending'
317
+ });
318
+
319
+ // List tasks for an owner
320
+ const tasks = listTasks(process.cwd(), { owner: 'AG-CI' });
321
+
322
+ // Update task
323
+ updateTask(process.cwd(), result.taskId, { status: 'in_progress' });
324
+ ```
325
+
326
+ ### Bash Script
327
+ ```bash
328
+ #!/bin/bash
329
+
330
+ # Add task
331
+ node .agileflow/scripts/lib/portable-tasks-cli.js add \
332
+ --subject="Deploy to staging" \
333
+ --owner=AG-DEVOPS
334
+
335
+ # Get all pending tasks for AG-API
336
+ node .agileflow/scripts/lib/portable-tasks-cli.js list \
337
+ --status=pending \
338
+ --owner=AG-API
339
+
340
+ # Mark task complete
341
+ node .agileflow/scripts/lib/portable-tasks-cli.js update T-001 \
342
+ --status=completed
343
+ ```
344
+
345
+ ## Status Values
346
+
347
+ - **`pending`** - Task not started
348
+ - **`in_progress`** - Task actively being worked on
349
+ - **`blocked`** - Task blocked by another (see `blockedBy` field)
350
+ - **`completed`** - Task finished
351
+
352
+ ## Markdown Format Details
353
+
354
+ The markdown format is strict for correct parsing:
355
+
356
+ **Correct:**
357
+ ```markdown
358
+ ### T-001: Task title [status]
359
+ - **Owner**: Value
360
+ - **Blocked by**: T-002
361
+ - **Description**: Description text
362
+ ```
363
+
364
+ **Incorrect (will not parse):**
365
+ ```markdown
366
+ ### T-001: Task title [status]
367
+ - Owner: Value # Missing **bold** markers
368
+ - **Blocked By**: T-002 # Wrong case (must be "Blocked by")
369
+ - **Description**: Description text
370
+ # Extra blank lines between fields are ok
371
+ ```
372
+
373
+ **Rules:**
374
+ - Task header: `### T-NNN: Title [status]`
375
+ - Field format: `- **Field name**: Value`
376
+ - Field names are case-insensitive (will be normalized)
377
+ - Extra blank lines, comments, headers are ignored
378
+ - Tasks can have any fields beyond the standard ones
379
+
380
+ ## Thread Safety
381
+
382
+ The system uses atomic writes (write to temp file, then rename) to prevent corruption if multiple processes write simultaneously. However, reads are NOT locked, so concurrent reads during writes may see partial data. For production use with high concurrency, implement file locking via `fcntl` or `flock`.
383
+
384
+ ## Testing
385
+
386
+ Run the comprehensive test suite:
387
+
388
+ ```bash
389
+ cd packages/cli
390
+ npm test -- __tests__/scripts/lib/portable-tasks.test.js --no-coverage
391
+ ```
392
+
393
+ Coverage:
394
+ - 47 tests across all functions
395
+ - Parsing, formatting, CRUD operations
396
+ - Round-trip integrity (parse → modify → format → parse)
397
+ - Error handling and edge cases
398
+ - Integration workflows
399
+
400
+ ## Design Decisions
401
+
402
+ 1. **Markdown format** - Human-readable, diff-friendly, git-compatible (vs JSON/YAML)
403
+ 2. **Status-driven sections** - Completed/active sections based on task status, not location
404
+ 3. **Auto-ID generation** - Sequential IDs (T-001) simplify references
405
+ 4. **No dependencies** - Only Node.js built-ins to minimize install footprint
406
+ 5. **Lazy parsing** - Parse on load, format on save (vs streaming)
407
+ 6. **Fail-safe writes** - Atomic writes prevent corruption on crashes
408
+
409
+ ## Limitations
410
+
411
+ - No encryption (store sensitive data elsewhere)
412
+ - No versioning/history (file is current state only)
413
+ - No concurrent write locking (implement if needed)
414
+ - No real-time sync (changes require reload)
415
+ - Task IDs are reassigned if you manually edit the file
416
+
417
+ ## Future Enhancements
418
+
419
+ - [ ] Watch mode (monitor file for external changes)
420
+ - [ ] Priority levels (high/medium/low)
421
+ - [ ] Time tracking (estimated/actual hours)
422
+ - [ ] Comments/notes per task
423
+ - [ ] Subtasks (nested hierarchy)
424
+ - [ ] Recurring tasks