sqlew 3.2.5 → 3.5.3

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.
Files changed (144) hide show
  1. package/CHANGELOG.md +815 -13
  2. package/README.md +53 -2
  3. package/assets/schema.sql +6 -1
  4. package/dist/config/loader.d.ts +46 -0
  5. package/dist/config/loader.d.ts.map +1 -0
  6. package/dist/config/loader.js +151 -0
  7. package/dist/config/loader.js.map +1 -0
  8. package/dist/config/types.d.ts +77 -0
  9. package/dist/config/types.d.ts.map +1 -0
  10. package/dist/config/types.js +28 -0
  11. package/dist/config/types.js.map +1 -0
  12. package/dist/constants.d.ts +9 -0
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +10 -0
  15. package/dist/constants.js.map +1 -1
  16. package/dist/database.d.ts +1 -1
  17. package/dist/database.d.ts.map +1 -1
  18. package/dist/database.js +77 -10
  19. package/dist/database.js.map +1 -1
  20. package/dist/index.js +21 -3
  21. package/dist/index.js.map +1 -1
  22. package/dist/migrations/add-v3.5.0-pruned-files.d.ts +26 -0
  23. package/dist/migrations/add-v3.5.0-pruned-files.d.ts.map +1 -0
  24. package/dist/migrations/add-v3.5.0-pruned-files.js +107 -0
  25. package/dist/migrations/add-v3.5.0-pruned-files.js.map +1 -0
  26. package/dist/migrations/index.d.ts +2 -1
  27. package/dist/migrations/index.d.ts.map +1 -1
  28. package/dist/migrations/index.js +16 -1
  29. package/dist/migrations/index.js.map +1 -1
  30. package/dist/tests/git-aware-completion.test.d.ts +6 -0
  31. package/dist/tests/git-aware-completion.test.d.ts.map +1 -0
  32. package/dist/tests/git-aware-completion.test.js +141 -0
  33. package/dist/tests/git-aware-completion.test.js.map +1 -0
  34. package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts +6 -0
  35. package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts.map +1 -0
  36. package/dist/tests/tasks.auto-pruning-decision-link.test.js +250 -0
  37. package/dist/tests/tasks.auto-pruning-decision-link.test.js.map +1 -0
  38. package/dist/tests/tasks.auto-pruning-partial.test.d.ts +6 -0
  39. package/dist/tests/tasks.auto-pruning-partial.test.d.ts.map +1 -0
  40. package/dist/tests/tasks.auto-pruning-partial.test.js +274 -0
  41. package/dist/tests/tasks.auto-pruning-partial.test.js.map +1 -0
  42. package/dist/tests/tasks.auto-pruning-persistence.test.d.ts +6 -0
  43. package/dist/tests/tasks.auto-pruning-persistence.test.d.ts.map +1 -0
  44. package/dist/tests/tasks.auto-pruning-persistence.test.js +232 -0
  45. package/dist/tests/tasks.auto-pruning-persistence.test.js.map +1 -0
  46. package/dist/tests/tasks.auto-pruning-safety.test.d.ts +12 -0
  47. package/dist/tests/tasks.auto-pruning-safety.test.d.ts.map +1 -0
  48. package/dist/tests/tasks.auto-pruning-safety.test.js +196 -0
  49. package/dist/tests/tasks.auto-pruning-safety.test.js.map +1 -0
  50. package/dist/tests/tasks.link-file-backward-compat.test.d.ts +6 -0
  51. package/dist/tests/tasks.link-file-backward-compat.test.d.ts.map +1 -0
  52. package/dist/tests/tasks.link-file-backward-compat.test.js +235 -0
  53. package/dist/tests/tasks.link-file-backward-compat.test.js.map +1 -0
  54. package/dist/tests/tasks.watch-files-action.test.d.ts +6 -0
  55. package/dist/tests/tasks.watch-files-action.test.d.ts.map +1 -0
  56. package/dist/tests/tasks.watch-files-action.test.js +351 -0
  57. package/dist/tests/tasks.watch-files-action.test.js.map +1 -0
  58. package/dist/tests/tasks.watch-files-parameter.test.d.ts +6 -0
  59. package/dist/tests/tasks.watch-files-parameter.test.d.ts.map +1 -0
  60. package/dist/tests/tasks.watch-files-parameter.test.js +249 -0
  61. package/dist/tests/tasks.watch-files-parameter.test.js.map +1 -0
  62. package/dist/tests/two-step-git-completion.test.d.ts +6 -0
  63. package/dist/tests/two-step-git-completion.test.d.ts.map +1 -0
  64. package/dist/tests/two-step-git-completion.test.js +283 -0
  65. package/dist/tests/two-step-git-completion.test.js.map +1 -0
  66. package/dist/tests/vcs-staging.test.d.ts +6 -0
  67. package/dist/tests/vcs-staging.test.d.ts.map +1 -0
  68. package/dist/tests/vcs-staging.test.js +137 -0
  69. package/dist/tests/vcs-staging.test.js.map +1 -0
  70. package/dist/tools/config.d.ts +4 -2
  71. package/dist/tools/config.d.ts.map +1 -1
  72. package/dist/tools/config.js +13 -11
  73. package/dist/tools/config.js.map +1 -1
  74. package/dist/tools/constraints.d.ts +7 -4
  75. package/dist/tools/constraints.d.ts.map +1 -1
  76. package/dist/tools/constraints.js +19 -16
  77. package/dist/tools/constraints.js.map +1 -1
  78. package/dist/tools/context.d.ts +33 -17
  79. package/dist/tools/context.d.ts.map +1 -1
  80. package/dist/tools/context.js +84 -68
  81. package/dist/tools/context.js.map +1 -1
  82. package/dist/tools/files.d.ts +9 -5
  83. package/dist/tools/files.d.ts.map +1 -1
  84. package/dist/tools/files.js +19 -15
  85. package/dist/tools/files.js.map +1 -1
  86. package/dist/tools/messaging.d.ts +9 -5
  87. package/dist/tools/messaging.d.ts.map +1 -1
  88. package/dist/tools/messaging.js +20 -16
  89. package/dist/tools/messaging.js.map +1 -1
  90. package/dist/tools/tasks.d.ts +40 -12
  91. package/dist/tools/tasks.d.ts.map +1 -1
  92. package/dist/tools/tasks.js +475 -87
  93. package/dist/tools/tasks.js.map +1 -1
  94. package/dist/tools/utils.d.ts +11 -6
  95. package/dist/tools/utils.d.ts.map +1 -1
  96. package/dist/tools/utils.js +56 -44
  97. package/dist/tools/utils.js.map +1 -1
  98. package/dist/types.d.ts +4 -0
  99. package/dist/types.d.ts.map +1 -1
  100. package/dist/utils/file-pruning.d.ts +69 -0
  101. package/dist/utils/file-pruning.d.ts.map +1 -0
  102. package/dist/utils/file-pruning.js +185 -0
  103. package/dist/utils/file-pruning.js.map +1 -0
  104. package/dist/utils/quality-checks.d.ts +60 -0
  105. package/dist/utils/quality-checks.d.ts.map +1 -0
  106. package/dist/utils/quality-checks.js +228 -0
  107. package/dist/utils/quality-checks.js.map +1 -0
  108. package/dist/utils/retention.d.ts +8 -0
  109. package/dist/utils/retention.d.ts.map +1 -1
  110. package/dist/utils/retention.js +12 -0
  111. package/dist/utils/retention.js.map +1 -1
  112. package/dist/utils/task-stale-detection.d.ts +69 -1
  113. package/dist/utils/task-stale-detection.d.ts.map +1 -1
  114. package/dist/utils/task-stale-detection.js +494 -17
  115. package/dist/utils/task-stale-detection.js.map +1 -1
  116. package/dist/utils/vcs-adapter.d.ts +68 -0
  117. package/dist/utils/vcs-adapter.d.ts.map +1 -0
  118. package/dist/utils/vcs-adapter.js +187 -0
  119. package/dist/utils/vcs-adapter.js.map +1 -0
  120. package/dist/watcher/file-watcher.d.ts +54 -4
  121. package/dist/watcher/file-watcher.d.ts.map +1 -1
  122. package/dist/watcher/file-watcher.js +312 -30
  123. package/dist/watcher/file-watcher.js.map +1 -1
  124. package/dist/watcher/gitignore-parser.d.ts +70 -0
  125. package/dist/watcher/gitignore-parser.d.ts.map +1 -0
  126. package/dist/watcher/gitignore-parser.js +191 -0
  127. package/dist/watcher/gitignore-parser.js.map +1 -0
  128. package/dist/watcher/index.d.ts +1 -0
  129. package/dist/watcher/index.d.ts.map +1 -1
  130. package/dist/watcher/index.js +1 -0
  131. package/dist/watcher/index.js.map +1 -1
  132. package/docs/AI_AGENT_GUIDE.md +1 -1
  133. package/docs/ARCHITECTURE.md +12 -0
  134. package/docs/AUTO_FILE_TRACKING.md +486 -82
  135. package/docs/CONFIGURATION.md +908 -0
  136. package/docs/GIT_AWARE_AUTO_COMPLETE.md +645 -0
  137. package/docs/MIGRATION_v3.3.md +602 -0
  138. package/docs/SHARED_CONCEPTS.md +2 -1
  139. package/docs/TASK_ACTIONS.md +12 -0
  140. package/docs/TASK_OVERVIEW.md +124 -23
  141. package/docs/TASK_PRUNING.md +589 -0
  142. package/docs/TASK_SYSTEM.md +83 -13
  143. package/docs/TOOL_REFERENCE.md +94 -6
  144. package/package.json +8 -6
@@ -2,6 +2,52 @@
2
2
 
3
3
  **Zero-Token Task Management** - Automatic task status transitions based on file changes and acceptance criteria validation.
4
4
 
5
+ ## Quick Start
6
+
7
+ ### Basic Usage (v3.4.1+)
8
+
9
+ Create a task with automatic file watching in one step:
10
+
11
+ ```typescript
12
+ // Create task with files to watch
13
+ task action=create
14
+ title: "Implement user authentication"
15
+ acceptance_criteria: [
16
+ {type: "tests_pass", command: "npm test auth", expected_pattern: "passing"},
17
+ {type: "code_contains", file: "src/auth.ts", pattern: "export class AuthService"}
18
+ ]
19
+ watch_files: ["src/auth.ts", "src/auth.test.ts"]
20
+ assigned_agent: "backend-dev"
21
+ status: "todo"
22
+ ```
23
+
24
+ That's it! The file watcher automatically:
25
+ 1. Monitors `src/auth.ts` and `src/auth.test.ts`
26
+ 2. Moves task to `in_progress` when files change
27
+ 3. Runs acceptance checks when files stabilize
28
+ 4. Moves task to `done` if all checks pass
29
+
30
+ **Token Savings**: 97% reduction (4,650 tokens saved per 6-task session)
31
+
32
+ ### Alternative: Add Files to Existing Task
33
+
34
+ ```typescript
35
+ // Add files to watch using the watch_files action
36
+ task action=watch_files
37
+ task_id: 123
38
+ action: watch
39
+ file_paths: ["src/auth.ts", "src/auth.test.ts"]
40
+ ```
41
+
42
+ ### Check What's Being Watched
43
+
44
+ ```typescript
45
+ // List all watched files for a task
46
+ task action=watch_files
47
+ task_id: 123
48
+ action: list
49
+ ```
50
+
5
51
  ## Overview
6
52
 
7
53
  The Auto File Tracking system monitors files linked to tasks and automatically manages task lifecycle:
@@ -10,7 +56,266 @@ The Auto File Tracking system monitors files linked to tasks and automatically m
10
56
  2. **Auto-Completion**: When all acceptance criteria pass for an `in_progress` task, it automatically moves to `done`
11
57
  3. **Zero Token Overhead**: All status updates happen automatically without manual MCP tool calls
12
58
 
13
- **Token Savings**: 97% reduction (4,650 tokens saved per 6-task session)
59
+ ## How It Works
60
+
61
+ ### Step 1: Create Task with Files
62
+
63
+ **Method 1: Using watch_files parameter (v3.4.1+, Recommended)**
64
+
65
+ ```typescript
66
+ task action=create
67
+ title: "Implement user authentication"
68
+ acceptance_criteria: [
69
+ {type: "tests_pass", command: "npm test auth", expected_pattern: "passing"},
70
+ {type: "code_contains", file: "src/auth.ts", pattern: "export class AuthService"}
71
+ ]
72
+ watch_files: ["src/auth.ts"]
73
+ assigned_agent: "backend-dev"
74
+ status: "todo"
75
+ ```
76
+
77
+ **Method 2: Using watch_files action (v3.4.1+)**
78
+
79
+ ```typescript
80
+ // Create task first
81
+ task action=create
82
+ title: "Implement user authentication"
83
+ acceptance_criteria: [...]
84
+ status: "todo"
85
+
86
+ // Then add files to watch
87
+ task action=watch_files
88
+ task_id: 123
89
+ action: watch
90
+ file_paths: ["src/auth.ts"]
91
+ ```
92
+
93
+ **Method 3: Using task.link (Deprecated)**
94
+
95
+ ```typescript
96
+ // ⚠️ DEPRECATED: This still works but shows deprecation warning
97
+ task action=link
98
+ task_id: 123
99
+ link_type: "file"
100
+ target_id: "src/auth.ts"
101
+ ```
102
+
103
+ ### Step 2: Automatic Monitoring
104
+
105
+ When the task is created and files are linked:
106
+
107
+ 1. FileWatcher registers `src/auth.ts` for monitoring
108
+ 2. Chokidar starts watching the file for changes
109
+ 3. Task remains in `todo` status
110
+
111
+ ### Step 3: Auto-Transition (todo → in_progress)
112
+
113
+ When an AI agent edits `src/auth.ts`:
114
+
115
+ 1. Chokidar detects file change (after 2s debounce)
116
+ 2. FileWatcher identifies task #123 is linked to this file
117
+ 3. Task status automatically updates: `todo` → `in_progress`
118
+ 4. Activity log records the auto-transition
119
+
120
+ **Console Output:**
121
+ ```
122
+ 📝 File changed: auth.ts
123
+ ✓ Task #123 "Implement user authentication": todo → in_progress
124
+ ```
125
+
126
+ ### Step 4: Auto-Completion (in_progress → done)
127
+
128
+ After the file change, FileWatcher checks acceptance criteria:
129
+
130
+ 1. Executes `npm test auth` command
131
+ 2. Checks if output contains "passing"
132
+ 3. Validates `src/auth.ts` contains `export class AuthService`
133
+ 4. If all checks pass → task moves to `done`
134
+
135
+ **Console Output:**
136
+ ```
137
+ 🔍 Checking acceptance criteria for task #123...
138
+ ✓ Check 1: Command succeeded and output matches pattern "passing"
139
+ ✓ Check 2: Pattern "export class AuthService" found in "src/auth.ts"
140
+ 🎉 Task #123 "Implement user authentication": in_progress → done (all checks passed!)
141
+ ```
142
+
143
+ ## Smart Review Detection (v3.4.1)
144
+
145
+ ### Overview
146
+
147
+ The Smart Review Detection feature automatically transitions tasks from `in_progress` to `waiting_review` when quality gates are met. This is purely algorithmic - no AI instructions needed!
148
+
149
+ ### Quality Gates
150
+
151
+ Four quality gates determine when a task is ready for review:
152
+
153
+ 1. **All Watched Files Modified** - Every file linked to the task must be edited at least once
154
+ 2. **TypeScript Compiles** - If .ts/.tsx files present, `tsc --noEmit` must succeed
155
+ 3. **Tests Pass** - If test files present (*.test.ts, *.spec.ts), tests must pass
156
+ 4. **Idle Time** - No file modifications for 15 minutes (configurable)
157
+
158
+ ### How It Works
159
+
160
+ **Automatic Tracking:**
161
+ - Every file modification updates `lastModifiedTime` for the task
162
+ - FileWatcher tracks which files have been modified
163
+ - After each file change, a timer starts for the idle period
164
+
165
+ **Quality Check Sequence:**
166
+ ```
167
+ File modified → Track modification → Wait idle period (15min)
168
+
169
+ Check quality gates:
170
+ ✓ All files modified?
171
+ ✓ TypeScript compiles?
172
+ ✓ Tests pass?
173
+
174
+ All passed? → waiting_review
175
+ Some failed? → stay in_progress
176
+ ```
177
+
178
+ **Console Output:**
179
+ ```
180
+ 📝 File changed: auth.ts
181
+ ✓ Task #123 "Implement user authentication": todo → in_progress
182
+
183
+ [15 minutes of idle time...]
184
+
185
+ ✓ Quality checks passed for task #123
186
+ • all_files_modified: All 2 watched files have been modified
187
+ • typescript_compiles: TypeScript compilation successful (2 .ts/.tsx files)
188
+ • tests_pass: Tests passed (1 test files)
189
+ → Task #123 auto-transitioned to waiting_review
190
+ ```
191
+
192
+ ### Configuration
193
+
194
+ Configure quality gates in `.sqlew/config.toml`:
195
+
196
+ ```toml
197
+ [tasks]
198
+ # Idle time before checking for review readiness (minutes)
199
+ review_idle_minutes = 15
200
+
201
+ # Require all watched files to be modified (boolean)
202
+ review_require_all_files_modified = true
203
+
204
+ # Require tests to pass (boolean)
205
+ review_require_tests_pass = true
206
+
207
+ # Require TypeScript to compile (boolean)
208
+ review_require_compile = true
209
+ ```
210
+
211
+ **Using MCP Tools:**
212
+ ```typescript
213
+ config action=update
214
+ key: "review_idle_minutes"
215
+ value: 20 // Wait 20 minutes before checking
216
+ ```
217
+
218
+ ### Hybrid Mode: Skip waiting_review
219
+
220
+ Tasks with `acceptance_criteria` can bypass `waiting_review` and go directly to `done`:
221
+
222
+ ```typescript
223
+ task action=create
224
+ title: "Implement feature"
225
+ acceptance_criteria: [
226
+ {type: "tests_pass", command: "npm test", expected_pattern: "passing"}
227
+ ]
228
+ watch_files: ["src/feature.ts"]
229
+ ```
230
+
231
+ **Behavior:**
232
+ - File modified → `todo` → `in_progress`
233
+ - Acceptance criteria met → `in_progress` → `done` (skips waiting_review)
234
+ - Quality gates still checked but not used for auto-transition
235
+
236
+ ### When Quality Checks Fail
237
+
238
+ If any gate fails, task stays in `in_progress` with diagnostic output:
239
+
240
+ ```
241
+ ℹ Task #123 not ready for review (2 checks failed)
242
+ • all_files_modified: 1 of 3 watched files not yet modified
243
+ Unmodified: src/auth.test.ts
244
+ • typescript_compiles: TypeScript compilation failed
245
+ src/auth.ts:15:3 - error TS2322: Type 'string' is not assignable to type 'number'
246
+ ```
247
+
248
+ ### Status Transition Flow (Updated)
249
+
250
+ ```
251
+ todo → in_progress → waiting_review → done
252
+ ↓ ↓ ↓
253
+ File Quality Manual
254
+ change gates review
255
+ met
256
+
257
+ Alternative (with acceptance_criteria):
258
+ todo → in_progress → done
259
+ ↓ ↓
260
+ File Acceptance
261
+ change criteria
262
+ met
263
+ ```
264
+
265
+ ## API Changes (v3.4.1)
266
+
267
+ ### New: watch_files Parameter
268
+
269
+ Add files to watch when creating or updating tasks:
270
+
271
+ ```typescript
272
+ // In create
273
+ task action=create
274
+ title: "..."
275
+ watch_files: ["src/file1.ts", "src/file2.ts"]
276
+
277
+ // In update
278
+ task action=update
279
+ task_id: 123
280
+ watch_files: ["src/file3.ts"] // Adds to existing watch list
281
+ ```
282
+
283
+ ### New: watch_files Action
284
+
285
+ Dedicated action for managing file watches:
286
+
287
+ ```typescript
288
+ // Watch files
289
+ task action=watch_files
290
+ task_id: 123
291
+ action: watch
292
+ file_paths: ["src/auth.ts", "src/auth.test.ts"]
293
+
294
+ // Unwatch files
295
+ task action=watch_files
296
+ task_id: 123
297
+ action: unwatch
298
+ file_paths: ["src/auth.test.ts"]
299
+
300
+ // List watched files
301
+ task action=watch_files
302
+ task_id: 123
303
+ action: list
304
+ ```
305
+
306
+ ### Deprecated: task.link(link_type="file")
307
+
308
+ Still works but shows deprecation warning. Use `watch_files` instead:
309
+
310
+ ```typescript
311
+ // OLD (deprecated)
312
+ task action=link task_id=123 link_type=file target_id="src/auth.ts"
313
+
314
+ // NEW (recommended)
315
+ task action=create watch_files=["src/auth.ts"] ...
316
+ // OR
317
+ task action=watch_files task_id=123 action=watch file_paths=["src/auth.ts"]
318
+ ```
14
319
 
15
320
  ## Architecture
16
321
 
@@ -61,66 +366,99 @@ CREATE TABLE t_task_file_links (
61
366
  );
62
367
  ```
63
368
 
64
- ## How It Works
369
+ ## Smart File Filtering (v3.4.1)
65
370
 
66
- ### Step 1: Create Task with File Links
371
+ ### GitIgnore Support
67
372
 
68
- ```typescript
69
- // Create task
70
- task action=create
71
- title: "Implement user authentication"
72
- acceptance_criteria: [
73
- {type: "tests_pass", command: "npm test auth", expected_pattern: "passing"},
74
- {type: "code_contains", file: "src/auth.ts", pattern: "export class AuthService"}
75
- ]
76
- assigned_agent: "backend-dev"
77
- status: "todo"
373
+ The FileWatcher automatically respects `.gitignore` patterns from your project root:
78
374
 
79
- // Link files to task
80
- task action=link
81
- task_id: 123
82
- link_type: "file"
83
- target_id: "src/auth.ts"
375
+ ```bash
376
+ # .gitignore example
377
+ node_modules/
378
+ dist/
379
+ *.log
380
+ .env
84
381
  ```
85
382
 
86
- ### Step 2: Automatic Monitoring
383
+ **Files matching these patterns will NOT trigger task transitions**, even if linked to a task.
87
384
 
88
- When the task is created and files are linked:
385
+ ### Built-In Ignore Patterns
89
386
 
90
- 1. FileWatcher registers `src/auth.ts` for monitoring
91
- 2. Chokidar starts watching the file for changes
92
- 3. Task remains in `todo` status
387
+ In addition to `.gitignore`, the watcher has **70+ built-in patterns** that are always ignored:
93
388
 
94
- ### Step 3: Auto-Transition (todo → in_progress)
389
+ **Version Control:**
390
+ - `.git`, `.gitignore`, `.gitattributes`
95
391
 
96
- When an AI agent edits `src/auth.ts`:
392
+ **Dependencies:**
393
+ - `node_modules`, `bower_components`, `jspm_packages`
97
394
 
98
- 1. Chokidar detects file change (after 2s debounce)
99
- 2. FileWatcher identifies task #123 is linked to this file
100
- 3. Task status automatically updates: `todo` → `in_progress`
101
- 4. Activity log records the auto-transition
395
+ **Build Outputs:**
396
+ - `dist`, `build`, `out`, `.next`, `.nuxt`, `.cache`, `.parcel-cache`, `.vite`
102
397
 
103
- **Console Output:**
104
- ```
105
- 📝 File changed: auth.ts
106
- Task #123 "Implement user authentication": todo → in_progress
398
+ **Logs:**
399
+ - `*.log`, `logs`, `npm-debug.log*`, `yarn-debug.log*`, `pnpm-debug.log*`
400
+
401
+ **OS Files:**
402
+ - `.DS_Store`, `Thumbs.db`, `desktop.ini`
403
+
404
+ **IDE/Editor Files:**
405
+ - `.vscode`, `.idea`, `.sublime-project`, `*.swp`, `*.swo`, `*~`
406
+
407
+ **Temporary Files:**
408
+ - `*.tmp`, `*.temp`, `.tmp`, `.temp`
409
+
410
+ **Environment Files:**
411
+ - `.env`, `.env.local`, `.env.*.local`
412
+
413
+ **Database Files:**
414
+ - `*.db`, `*.sqlite`, `*.sqlite3`, `.mcp-context`
415
+
416
+ **Test Coverage:**
417
+ - `coverage`, `.nyc_output`
418
+
419
+ **Package Manager Locks:**
420
+ - `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`
421
+
422
+ ### How It Works
423
+
424
+ ```typescript
425
+ // 1. When FileWatcher starts:
426
+ const gitignoreParser = createGitIgnoreParser(projectRoot);
427
+
428
+ // 2. Chokidar uses the parser to filter files:
429
+ chokidar.watch([], {
430
+ ignored: (path: string) => {
431
+ return gitignoreParser.shouldIgnore(path);
432
+ }
433
+ });
434
+
435
+ // 3. Files are automatically filtered:
436
+ // ✓ src/auth.ts → watched
437
+ // ✗ node_modules/package/file.js → ignored (built-in pattern)
438
+ // ✗ dist/bundle.js → ignored (.gitignore + built-in pattern)
439
+ // ✗ .env → ignored (built-in pattern for security)
107
440
  ```
108
441
 
109
- ### Step 4: Auto-Completion (in_progress → done)
442
+ ### Benefits
110
443
 
111
- After the file change, FileWatcher checks acceptance criteria:
444
+ 1. **Security**: Prevents watching sensitive files (`.env`, credentials)
445
+ 2. **Performance**: Doesn't watch thousands of `node_modules` files
446
+ 3. **Accuracy**: Only tracks files you actually care about
447
+ 4. **Zero Configuration**: Works out of the box with sensible defaults
112
448
 
113
- 1. Executes `npm test auth` command
114
- 2. Checks if output contains "passing"
115
- 3. Validates `src/auth.ts` contains `export class AuthService`
116
- 4. If all checks pass → task moves to `done`
449
+ ### Project Root Detection
117
450
 
118
- **Console Output:**
451
+ The watcher automatically detects your project root as `process.cwd()` and:
452
+ - Loads `.gitignore` from the root (if it exists)
453
+ - Applies built-in patterns relative to the root
454
+ - Normalizes all file paths relative to the root
455
+
456
+ **Console Output on Startup:**
119
457
  ```
120
- 🔍 Checking acceptance criteria for task #123...
121
- Check 1: Command succeeded and output matches pattern "passing"
122
- Check 2: Pattern "export class AuthService" found in "src/auth.ts"
123
- 🎉 Task #123 "Implement user authentication": in_progress → done (all checks passed!)
458
+ File watcher started successfully
459
+ Project root: /home/user/my-project
460
+ Watching 3 files for 2 tasks
461
+ .gitignore patterns loaded: Yes
124
462
  ```
125
463
 
126
464
  ## Acceptance Criteria Types
@@ -158,16 +496,18 @@ File watcher settings are built into the system:
158
496
  **Symptoms**: File changes detected but task stays in `todo`
159
497
 
160
498
  **Solutions**:
161
- 1. Verify file is linked to task:
499
+ 1. Verify files are linked to task:
162
500
  ```typescript
501
+ task action=watch_files task_id=123 action=list
502
+ // OR
163
503
  task action=get task_id=123
164
504
  // Check for file links in response
165
505
  ```
166
506
 
167
507
  2. Check file watcher status:
168
508
  ```typescript
169
- stats action=db_stats
170
- // Look for file_watcher_running: true
509
+ task action=watcher subaction=status
510
+ // Should show: running: true, files_watched: N
171
511
  ```
172
512
 
173
513
  3. Verify task is in correct status:
@@ -207,8 +547,13 @@ File watcher settings are built into the system:
207
547
  Watching 3 files for 2 tasks
208
548
  ```
209
549
 
210
- 2. Restart MCP server if watcher failed to start
211
- 3. Check file paths are absolute (not relative)
550
+ 2. Check watcher status via MCP tool:
551
+ ```typescript
552
+ task action=watcher subaction=status
553
+ ```
554
+
555
+ 3. Restart MCP server if watcher failed to start
556
+ 4. Check file paths are absolute (not relative)
212
557
 
213
558
  ### Issue: Tests Timing Out
214
559
 
@@ -264,18 +609,33 @@ For 6 tasks: **4,800 tokens saved** (97% reduction in status management overhead
264
609
 
265
610
  ## Best Practices
266
611
 
267
- ### 1. Link Only Relevant Files
612
+ ### 1. Use watch_files Parameter for New Tasks (v3.4.1+)
268
613
 
269
614
  ```typescript
270
- // GOOD: Link specific implementation files
615
+ // GOOD: Create task with files in one step
616
+ task action=create
617
+ title: "Implement auth"
618
+ watch_files: ["src/auth.ts", "src/auth.test.ts"]
619
+ acceptance_criteria: [...]
620
+
621
+ // BAD: Using deprecated link API
622
+ task action=create title="Implement auth"
271
623
  task action=link task_id=123 link_type=file target_id="src/auth.ts"
272
- task action=link task_id=123 link_type=file target_id="src/auth.test.ts"
624
+ ```
625
+
626
+ ### 2. Link Only Relevant Files
627
+
628
+ ```typescript
629
+ // GOOD: Link specific implementation files
630
+ task action=create
631
+ watch_files: ["src/auth.ts", "src/auth.test.ts"]
273
632
 
274
633
  // BAD: Don't link entire directories or unrelated files
275
- task action=link task_id=123 link_type=file target_id="src/" // ❌ Not a file
634
+ task action=create
635
+ watch_files: ["src/"] // ❌ Not a file
276
636
  ```
277
637
 
278
- ### 2. Use Specific Acceptance Criteria
638
+ ### 3. Use Specific Acceptance Criteria
279
639
 
280
640
  ```typescript
281
641
  // GOOD: Specific, testable criteria
@@ -290,7 +650,7 @@ acceptance_criteria: [
290
650
  ]
291
651
  ```
292
652
 
293
- ### 3. Set Realistic Timeouts
653
+ ### 4. Set Realistic Timeouts
294
654
 
295
655
  ```typescript
296
656
  // GOOD: Appropriate timeouts based on test complexity
@@ -300,7 +660,7 @@ acceptance_criteria: [
300
660
  ]
301
661
  ```
302
662
 
303
- ### 4. Combine Multiple Check Types
663
+ ### 5. Combine Multiple Check Types
304
664
 
305
665
  ```typescript
306
666
  acceptance_criteria: [
@@ -318,7 +678,7 @@ acceptance_criteria: [
318
678
  ]
319
679
  ```
320
680
 
321
- ### 5. Archive Completed Tasks
681
+ ### 6. Archive Completed Tasks
322
682
 
323
683
  ```typescript
324
684
  // Move done tasks to archived to stop file watching
@@ -348,9 +708,16 @@ acceptance_criteria: [
348
708
  Link multiple files to a single task:
349
709
 
350
710
  ```typescript
351
- task action=link task_id=123 link_type=file target_id="src/auth.ts"
352
- task action=link task_id=123 link_type=file target_id="src/auth.test.ts"
353
- task action=link task_id=123 link_type=file target_id="docs/auth.md"
711
+ // Using watch_files parameter (v3.4.1+)
712
+ task action=create
713
+ title: "Implement authentication"
714
+ watch_files: ["src/auth.ts", "src/auth.test.ts", "docs/auth.md"]
715
+
716
+ // OR using watch_files action
717
+ task action=watch_files
718
+ task_id: 123
719
+ action: watch
720
+ file_paths: ["src/auth.ts", "src/auth.test.ts", "docs/auth.md"]
354
721
  ```
355
722
 
356
723
  Any file change triggers the workflow.
@@ -367,70 +734,107 @@ acceptance_criteria: [
367
734
  ]
368
735
  ```
369
736
 
370
- ## Migration from Manual Task Management
371
-
372
- See [TASK_MIGRATION.md](./TASK_MIGRATION.md) for detailed migration guide.
373
-
374
- ## API Reference
375
-
376
- See [TOOL_REFERENCE.md](./TOOL_REFERENCE.md) for complete API documentation.
377
-
378
737
  ## Examples
379
738
 
380
- ### Example 1: Simple Bug Fix
739
+ ### Example 1: Simple Bug Fix (v3.4.1)
381
740
 
382
741
  ```typescript
383
- // Create task
742
+ // Create task with file watching
384
743
  task action=create
385
744
  title: "Fix login button styling"
745
+ watch_files: ["src/LoginButton.css"]
386
746
  acceptance_criteria: [
387
747
  {type: "code_contains", file: "src/LoginButton.css", pattern: "background-color: #007bff"},
388
748
  {type: "tests_pass", command: "npm test LoginButton", expected_pattern: "passing"}
389
749
  ]
390
750
 
391
- // Link file
392
- task action=link task_id=45 link_type=file target_id="src/LoginButton.css"
393
-
394
751
  // Edit file → auto-transitions to in_progress
395
752
  // Tests pass → auto-completes to done
396
753
  ```
397
754
 
398
- ### Example 2: Feature Implementation
755
+ ### Example 2: Feature Implementation (v3.4.1)
399
756
 
400
757
  ```typescript
401
- // Create task
758
+ // Create task with multiple files
402
759
  task action=create
403
760
  title: "Add user profile endpoint"
761
+ watch_files: ["src/routes/profile.ts", "src/routes/profile.test.ts"]
404
762
  acceptance_criteria: [
405
763
  {type: "file_exists", file: "src/routes/profile.ts"},
406
764
  {type: "code_contains", file: "src/routes/profile.ts", pattern: "router.get\\('/profile'"},
407
765
  {type: "tests_pass", command: "npm test routes/profile", expected_pattern: "5 passing"}
408
766
  ]
409
-
410
- // Link implementation and test files
411
- task action=link task_id=46 link_type=file target_id="src/routes/profile.ts"
412
- task action=link task_id=46 link_type=file target_id="src/routes/profile.test.ts"
413
767
  ```
414
768
 
415
- ### Example 3: Refactoring Task
769
+ ### Example 3: Refactoring Task (v3.4.1)
416
770
 
417
771
  ```typescript
418
772
  // Create task
419
773
  task action=create
420
774
  title: "Remove deprecated API endpoints"
775
+ watch_files: ["src/api/legacy.ts"]
421
776
  acceptance_criteria: [
422
777
  {type: "code_removed", file: "src/api/legacy.ts", pattern: "router.get\\('/old-endpoint'"},
423
778
  {type: "code_removed", file: "src/api/legacy.ts", pattern: "// DEPRECATED"},
424
779
  {type: "tests_pass", command: "npm test", expected_pattern: "0 failing"}
425
780
  ]
781
+ ```
782
+
783
+ ### Example 4: Adding Files to Existing Task
426
784
 
427
- // Link file to watch
428
- task action=link task_id=47 link_type=file target_id="src/api/legacy.ts"
785
+ ```typescript
786
+ // Task already exists, add more files to watch
787
+ task action=watch_files
788
+ task_id: 47
789
+ action: watch
790
+ file_paths: ["src/api/v2.ts", "src/api/v2.test.ts"]
791
+
792
+ // Check what's being watched
793
+ task action=watch_files
794
+ task_id: 47
795
+ action: list
796
+ // Returns: { files: ["src/api/legacy.ts", "src/api/v2.ts", "src/api/v2.test.ts"] }
797
+
798
+ // Remove file from watch list
799
+ task action=watch_files
800
+ task_id: 47
801
+ action: unwatch
802
+ file_paths: ["src/api/legacy.ts"]
803
+ ```
804
+
805
+ ## Migration from v3.2.x to v3.4.1
806
+
807
+ ### Before (v3.2.x)
808
+
809
+ ```typescript
810
+ // Create task
811
+ task action=create title="Implement auth" ...
812
+
813
+ // Link files separately
814
+ task action=link task_id=123 link_type=file target_id="src/auth.ts"
815
+ task action=link task_id=123 link_type=file target_id="src/auth.test.ts"
816
+ ```
817
+
818
+ ### After (v3.4.1)
819
+
820
+ ```typescript
821
+ // Create task with files in one call
822
+ task action=create
823
+ title: "Implement auth"
824
+ watch_files: ["src/auth.ts", "src/auth.test.ts"]
825
+ ...
429
826
  ```
430
827
 
828
+ **Benefits**:
829
+ - Fewer MCP calls (1 instead of 3)
830
+ - Clearer intent
831
+ - Better error handling
832
+ - Batch file registration with watcher
833
+
431
834
  ## See Also
432
835
 
433
836
  - [ACCEPTANCE_CRITERIA.md](./ACCEPTANCE_CRITERIA.md) - All acceptance check types
434
837
  - [WORKFLOWS.md](./WORKFLOWS.md) - Multi-agent coordination patterns
435
838
  - [BEST_PRACTICES.md](./BEST_PRACTICES.md) - Common errors and solutions
436
839
  - [TASK_MIGRATION.md](./TASK_MIGRATION.md) - Migrate from decision-based tracking
840
+ - [MIGRATION_v3.3.md](./MIGRATION_v3.3.md) - Migration guide from v3.2.x to v3.4.1