sqlew 4.0.5 → 4.1.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.
Files changed (201) hide show
  1. package/CHANGELOG.md +1805 -1782
  2. package/README.md +409 -468
  3. package/assets/claude-md-snippets/plan-mode-integration.md +17 -6
  4. package/assets/config.example.toml +282 -284
  5. package/assets/sample-agents/README.md +36 -40
  6. package/assets/sample-agents/sqlew-architect.md +321 -322
  7. package/assets/sample-agents/sqlew-researcher.md +292 -293
  8. package/assets/sample-agents/sqlew-scrum-master.md +286 -287
  9. package/assets/sample-commands/README.md +56 -57
  10. package/assets/sample-skills/sqlew-plan-guidance/SKILL.md +33 -26
  11. package/dist/cli/hooks/check-completion.d.ts +19 -0
  12. package/dist/cli/hooks/check-completion.d.ts.map +1 -0
  13. package/dist/cli/hooks/check-completion.js +104 -0
  14. package/dist/cli/hooks/check-completion.js.map +1 -0
  15. package/dist/cli/hooks/init-hooks.d.ts +35 -0
  16. package/dist/cli/hooks/init-hooks.d.ts.map +1 -0
  17. package/dist/cli/hooks/init-hooks.js +425 -0
  18. package/dist/cli/hooks/init-hooks.js.map +1 -0
  19. package/dist/cli/hooks/mark-done.d.ts +25 -0
  20. package/dist/cli/hooks/mark-done.d.ts.map +1 -0
  21. package/dist/cli/hooks/mark-done.js +128 -0
  22. package/dist/cli/hooks/mark-done.js.map +1 -0
  23. package/dist/cli/hooks/plan-id-utils.d.ts +83 -0
  24. package/dist/cli/hooks/plan-id-utils.d.ts.map +1 -0
  25. package/dist/cli/hooks/plan-id-utils.js +183 -0
  26. package/dist/cli/hooks/plan-id-utils.js.map +1 -0
  27. package/dist/cli/hooks/save.d.ts +23 -0
  28. package/dist/cli/hooks/save.d.ts.map +1 -0
  29. package/dist/cli/hooks/save.js +90 -0
  30. package/dist/cli/hooks/save.js.map +1 -0
  31. package/dist/cli/hooks/stdin-parser.d.ts +139 -0
  32. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -0
  33. package/dist/cli/hooks/stdin-parser.js +127 -0
  34. package/dist/cli/hooks/stdin-parser.js.map +1 -0
  35. package/dist/cli/hooks/suggest.d.ts +19 -0
  36. package/dist/cli/hooks/suggest.d.ts.map +1 -0
  37. package/dist/cli/hooks/suggest.js +157 -0
  38. package/dist/cli/hooks/suggest.js.map +1 -0
  39. package/dist/cli/hooks/track-plan.d.ts +36 -0
  40. package/dist/cli/hooks/track-plan.d.ts.map +1 -0
  41. package/dist/cli/hooks/track-plan.js +152 -0
  42. package/dist/cli/hooks/track-plan.js.map +1 -0
  43. package/dist/cli.d.ts.map +1 -1
  44. package/dist/cli.js +56 -16
  45. package/dist/cli.js.map +1 -1
  46. package/dist/config/global-config.d.ts +187 -0
  47. package/dist/config/global-config.d.ts.map +1 -0
  48. package/dist/config/global-config.js +206 -0
  49. package/dist/config/global-config.js.map +1 -0
  50. package/dist/config/loader.d.ts +42 -0
  51. package/dist/config/loader.d.ts.map +1 -1
  52. package/dist/config/loader.js +96 -0
  53. package/dist/config/loader.js.map +1 -1
  54. package/dist/constants.d.ts +4 -0
  55. package/dist/constants.d.ts.map +1 -1
  56. package/dist/constants.js +10 -0
  57. package/dist/constants.js.map +1 -1
  58. package/dist/database/operations/queries.d.ts.map +1 -1
  59. package/dist/database/operations/queries.js +11 -2
  60. package/dist/database/operations/queries.js.map +1 -1
  61. package/dist/index.js +4 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/init-agents.js +0 -1
  64. package/dist/init-agents.js.map +1 -1
  65. package/dist/init-skills.d.ts +4 -3
  66. package/dist/init-skills.d.ts.map +1 -1
  67. package/dist/init-skills.js +10 -3
  68. package/dist/init-skills.js.map +1 -1
  69. package/dist/server/setup.d.ts +8 -0
  70. package/dist/server/setup.d.ts.map +1 -1
  71. package/dist/server/setup.js +141 -21
  72. package/dist/server/setup.js.map +1 -1
  73. package/dist/sync-agents.d.ts.map +1 -1
  74. package/dist/sync-agents.js +48 -3
  75. package/dist/sync-agents.js.map +1 -1
  76. package/dist/sync-commands.d.ts.map +1 -1
  77. package/dist/sync-commands.js +43 -3
  78. package/dist/sync-commands.js.map +1 -1
  79. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  80. package/dist/tools/constraints/actions/get.js +5 -8
  81. package/dist/tools/constraints/actions/get.js.map +1 -1
  82. package/dist/tools/constraints/help/help.d.ts.map +1 -1
  83. package/dist/tools/constraints/help/help.js +1 -6
  84. package/dist/tools/constraints/help/help.js.map +1 -1
  85. package/dist/tools/context/actions/get.d.ts.map +1 -1
  86. package/dist/tools/context/actions/get.js.map +1 -1
  87. package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
  88. package/dist/tools/context/actions/search-layer.js +5 -3
  89. package/dist/tools/context/actions/search-layer.js.map +1 -1
  90. package/dist/tools/context/actions/set-from-policy.d.ts +2 -1
  91. package/dist/tools/context/actions/set-from-policy.d.ts.map +1 -1
  92. package/dist/tools/context/actions/set-from-policy.js.map +1 -1
  93. package/dist/tools/context/help/help.d.ts.map +1 -1
  94. package/dist/tools/context/help/help.js +1 -7
  95. package/dist/tools/context/help/help.js.map +1 -1
  96. package/dist/tools/context/internal/queries.d.ts.map +1 -1
  97. package/dist/tools/context/internal/queries.js +5 -2
  98. package/dist/tools/context/internal/queries.js.map +1 -1
  99. package/dist/tools/context/types.d.ts +1 -1
  100. package/dist/tools/context/types.d.ts.map +1 -1
  101. package/dist/tools/files/actions/get.d.ts.map +1 -1
  102. package/dist/tools/files/actions/get.js +4 -6
  103. package/dist/tools/files/actions/get.js.map +1 -1
  104. package/dist/tools/files/help/help.d.ts.map +1 -1
  105. package/dist/tools/files/help/help.js +1 -6
  106. package/dist/tools/files/help/help.js.map +1 -1
  107. package/dist/tools/suggest/help/constraint-help.d.ts.map +1 -1
  108. package/dist/tools/suggest/help/constraint-help.js +0 -2
  109. package/dist/tools/suggest/help/constraint-help.js.map +1 -1
  110. package/dist/tools/suggest/internal/constraint-queries.d.ts.map +1 -1
  111. package/dist/tools/suggest/internal/constraint-queries.js +12 -5
  112. package/dist/tools/suggest/internal/constraint-queries.js.map +1 -1
  113. package/dist/tools/suggest/internal/queries.js +2 -2
  114. package/dist/tools/suggest/internal/queries.js.map +1 -1
  115. package/dist/tools/tasks/help/help.d.ts.map +1 -1
  116. package/dist/tools/tasks/help/help.js +0 -6
  117. package/dist/tools/tasks/help/help.js.map +1 -1
  118. package/dist/tools/tasks/help/use-case.d.ts.map +1 -1
  119. package/dist/tools/tasks/help/use-case.js +0 -1
  120. package/dist/tools/tasks/help/use-case.js.map +1 -1
  121. package/dist/tools/tasks/watcher/status.d.ts.map +1 -1
  122. package/dist/tools/tasks/watcher/status.js +5 -1
  123. package/dist/tools/tasks/watcher/status.js.map +1 -1
  124. package/dist/types/decision/params.d.ts +7 -6
  125. package/dist/types/decision/params.d.ts.map +1 -1
  126. package/dist/types/decision/templates.d.ts +3 -2
  127. package/dist/types/decision/templates.d.ts.map +1 -1
  128. package/dist/types/view-entities.d.ts +2 -1
  129. package/dist/types/view-entities.d.ts.map +1 -1
  130. package/dist/types.d.ts +19 -11
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/types.js +4 -1
  133. package/dist/types.js.map +1 -1
  134. package/dist/utils/enum-converter.d.ts +72 -0
  135. package/dist/utils/enum-converter.d.ts.map +1 -0
  136. package/dist/utils/enum-converter.js +76 -0
  137. package/dist/utils/enum-converter.js.map +1 -0
  138. package/dist/utils/hook-queue.d.ts +81 -0
  139. package/dist/utils/hook-queue.d.ts.map +1 -0
  140. package/dist/utils/hook-queue.js +156 -0
  141. package/dist/utils/hook-queue.js.map +1 -0
  142. package/dist/utils/project-root.d.ts +9 -2
  143. package/dist/utils/project-root.d.ts.map +1 -1
  144. package/dist/utils/project-root.js +16 -2
  145. package/dist/utils/project-root.js.map +1 -1
  146. package/dist/utils/tag-parser.d.ts.map +1 -1
  147. package/dist/utils/tag-parser.js +6 -0
  148. package/dist/utils/tag-parser.js.map +1 -1
  149. package/dist/utils/validators.d.ts +1 -1
  150. package/dist/utils/validators.d.ts.map +1 -1
  151. package/dist/utils/validators.js +1 -1
  152. package/dist/utils/validators.js.map +1 -1
  153. package/dist/utils/vcs-adapter.d.ts +44 -0
  154. package/dist/utils/vcs-adapter.d.ts.map +1 -1
  155. package/dist/utils/vcs-adapter.js +88 -0
  156. package/dist/utils/vcs-adapter.js.map +1 -1
  157. package/dist/utils/view-queries.d.ts.map +1 -1
  158. package/dist/utils/view-queries.js +9 -19
  159. package/dist/utils/view-queries.js.map +1 -1
  160. package/dist/watcher/base-watcher.d.ts +69 -0
  161. package/dist/watcher/base-watcher.d.ts.map +1 -0
  162. package/dist/watcher/base-watcher.js +130 -0
  163. package/dist/watcher/base-watcher.js.map +1 -0
  164. package/dist/watcher/index.d.ts +3 -0
  165. package/dist/watcher/index.d.ts.map +1 -1
  166. package/dist/watcher/index.js +2 -0
  167. package/dist/watcher/index.js.map +1 -1
  168. package/dist/watcher/queue-watcher.d.ts +64 -0
  169. package/dist/watcher/queue-watcher.d.ts.map +1 -0
  170. package/dist/watcher/queue-watcher.js +187 -0
  171. package/dist/watcher/queue-watcher.js.map +1 -0
  172. package/docs/ADR_CONCEPTS.md +140 -0
  173. package/docs/CONFIGURATION.md +922 -925
  174. package/docs/CROSS_DATABASE.md +153 -0
  175. package/docs/DATABASE_AUTH.md +70 -356
  176. package/docs/HOOKS_GUIDE.md +159 -0
  177. package/docs/SLASH_COMMANDS.md +329 -337
  178. package/docs/TASK_SYSTEM_DEPRECATED.md +88 -0
  179. package/docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md +293 -296
  180. package/docs/cli/DATA_EXPORT_IMPORT.md +699 -700
  181. package/docs/cli/README.md +276 -277
  182. package/package.json +123 -124
  183. package/docs/ACCEPTANCE_CRITERIA.md +0 -625
  184. package/docs/AI_AGENT_GUIDE.md +0 -299
  185. package/docs/ARCHITECTURE.md +0 -167
  186. package/docs/AUTO_FILE_TRACKING.md +0 -841
  187. package/docs/BATCH_VALIDATION.md +0 -617
  188. package/docs/BEST_PRACTICES.md +0 -168
  189. package/docs/CONSTRAINT_INTELLIGENCE.md +0 -339
  190. package/docs/DECISION_CONTEXT.md +0 -697
  191. package/docs/DECISION_INTELLIGENCE.md +0 -605
  192. package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -646
  193. package/docs/MIGRATION_GUIDE_V3.9.0.md +0 -371
  194. package/docs/SHARED_CONCEPTS.md +0 -225
  195. package/docs/SPECIALIZED_AGENTS.md +0 -126
  196. package/docs/TASK_ACTIONS.md +0 -1177
  197. package/docs/TASK_OVERVIEW.md +0 -452
  198. package/docs/TASK_PRUNING.md +0 -594
  199. package/docs/TOOL_REFERENCE.md +0 -1077
  200. package/docs/TOOL_SELECTION.md +0 -83
  201. package/docs/WORKFLOWS.md +0 -941
@@ -1,841 +0,0 @@
1
- # Auto File Tracking
2
-
3
- **Zero-Token Task Management** - Automatic task status transitions based on file changes and acceptance criteria validation.
4
-
5
- ## Quick Start
6
-
7
- ### Basic Usage (v4.0.0+)
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
-
51
- ## Overview
52
-
53
- The Auto File Tracking system monitors files linked to tasks and automatically manages task lifecycle:
54
-
55
- 1. **Auto-Transition to In Progress**: When a file linked to a `todo` task is modified, the task automatically moves to `in_progress`
56
- 2. **Auto-Completion**: When all acceptance criteria pass for an `in_progress` task, it automatically moves to `done`
57
- 3. **Zero Token Overhead**: All status updates happen automatically without manual MCP tool calls
58
-
59
- ## How It Works
60
-
61
- ### Step 1: Create Task with Files
62
-
63
- **Method 1: Using watch_files parameter (v4.0.0+, 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 (v4.0.0+)**
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 (v4.0.0)
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 (v4.0.0)
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
- ```
319
-
320
- ## Architecture
321
-
322
- ### Components
323
-
324
- ```
325
- ┌─────────────────────────────────────────────────────────┐
326
- │ MCP Server (index.ts) │
327
- │ ├─ Initializes FileWatcher on startup │
328
- │ └─ Loads task-file links from database │
329
- └─────────────────────────────────────────────────────────┘
330
-
331
-
332
- ┌─────────────────────────────────────────────────────────┐
333
- │ FileWatcher (src/watcher/file-watcher.ts) │
334
- │ ├─ Monitors files using chokidar │
335
- │ ├─ Debounces changes (2s stabilization) │
336
- │ ├─ Maps file paths → task IDs │
337
- │ └─ Triggers auto-transitions on file change │
338
- └─────────────────────────────────────────────────────────┘
339
-
340
-
341
- ┌─────────────────────────────────────────────────────────┐
342
- │ TestExecutor (src/watcher/test-executor.ts) │
343
- │ ├─ Executes acceptance checks │
344
- │ ├─ Supports 4 check types │
345
- │ └─ Returns pass/fail results │
346
- └─────────────────────────────────────────────────────────┘
347
- ```
348
-
349
- ### Database Schema
350
-
351
- The system uses the `v4_task_details` table with a column for acceptance criteria:
352
-
353
- ```sql
354
- CREATE TABLE v4_task_details (
355
- task_id INTEGER REFERENCES v4_tasks(id) ON DELETE CASCADE,
356
- acceptance_criteria_json TEXT,
357
- PRIMARY KEY (task_id)
358
- );
359
- -- JSON format: [{"type": "tests_pass", "command": "npm test", "expected_pattern": "passing"}]
360
- ```
361
-
362
- Task-file links are stored in `v4_task_file_links`:
363
-
364
- ```sql
365
- CREATE TABLE v4_task_file_links (
366
- task_id INTEGER REFERENCES v4_tasks(id) ON DELETE CASCADE,
367
- file_id INTEGER REFERENCES v4_files(id),
368
- PRIMARY KEY (task_id, file_id)
369
- );
370
- ```
371
-
372
- ## Smart File Filtering (v4.0.0)
373
-
374
- ### GitIgnore Support
375
-
376
- The FileWatcher automatically respects `.gitignore` patterns from your project root:
377
-
378
- ```bash
379
- # .gitignore example
380
- node_modules/
381
- dist/
382
- *.log
383
- .env
384
- ```
385
-
386
- **Files matching these patterns will NOT trigger task transitions**, even if linked to a task.
387
-
388
- ### Built-In Ignore Patterns
389
-
390
- In addition to `.gitignore`, the watcher has **70+ built-in patterns** that are always ignored:
391
-
392
- **Version Control:**
393
- - `.git`, `.gitignore`, `.gitattributes`
394
-
395
- **Dependencies:**
396
- - `node_modules`, `bower_components`, `jspm_packages`
397
-
398
- **Build Outputs:**
399
- - `dist`, `build`, `out`, `.next`, `.nuxt`, `.cache`, `.parcel-cache`, `.vite`
400
-
401
- **Logs:**
402
- - `*.log`, `logs`, `npm-debug.log*`, `yarn-debug.log*`, `pnpm-debug.log*`
403
-
404
- **OS Files:**
405
- - `.DS_Store`, `Thumbs.db`, `desktop.ini`
406
-
407
- **IDE/Editor Files:**
408
- - `.vscode`, `.idea`, `.sublime-project`, `*.swp`, `*.swo`, `*~`
409
-
410
- **Temporary Files:**
411
- - `*.tmp`, `*.temp`, `.tmp`, `.temp`
412
-
413
- **Environment Files:**
414
- - `.env`, `.env.local`, `.env.*.local`
415
-
416
- **Database Files:**
417
- - `*.db`, `*.sqlite`, `*.sqlite3`, `.mcp-context`
418
-
419
- **Test Coverage:**
420
- - `coverage`, `.nyc_output`
421
-
422
- **Package Manager Locks:**
423
- - `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`
424
-
425
- ### How It Works
426
-
427
- ```typescript
428
- // 1. When FileWatcher starts:
429
- const gitignoreParser = createGitIgnoreParser(projectRoot);
430
-
431
- // 2. Chokidar uses the parser to filter files:
432
- chokidar.watch([], {
433
- ignored: (path: string) => {
434
- return gitignoreParser.shouldIgnore(path);
435
- }
436
- });
437
-
438
- // 3. Files are automatically filtered:
439
- // ✓ src/auth.ts → watched
440
- // ✗ node_modules/package/file.js → ignored (built-in pattern)
441
- // ✗ dist/bundle.js → ignored (.gitignore + built-in pattern)
442
- // ✗ .env → ignored (built-in pattern for security)
443
- ```
444
-
445
- ### Benefits
446
-
447
- 1. **Security**: Prevents watching sensitive files (`.env`, credentials)
448
- 2. **Performance**: Doesn't watch thousands of `node_modules` files
449
- 3. **Accuracy**: Only tracks files you actually care about
450
- 4. **Zero Configuration**: Works out of the box with sensible defaults
451
-
452
- ### Project Root Detection
453
-
454
- The watcher automatically detects your project root as `process.cwd()` and:
455
- - Loads `.gitignore` from the root (if it exists)
456
- - Applies built-in patterns relative to the root
457
- - Normalizes all file paths relative to the root
458
-
459
- **Console Output on Startup:**
460
- ```
461
- ✓ File watcher started successfully
462
- Project root: /home/user/my-project
463
- Watching 3 files for 2 tasks
464
- .gitignore patterns loaded: Yes
465
- ```
466
-
467
- ## Acceptance Criteria Types
468
-
469
- See [ACCEPTANCE_CRITERIA.md](./ACCEPTANCE_CRITERIA.md) for detailed documentation on all check types.
470
-
471
- ## Configuration
472
-
473
- ### Auto-Delete Settings
474
-
475
- Configure how long to retain completed task data:
476
-
477
- ```bash
478
- # Set retention for file change history
479
- config action=update
480
- fileHistoryRetentionDays: 7
481
-
482
- # Enable weekend-aware deletion (skip Sat/Sun when calculating cutoff)
483
- config action=update
484
- ignoreWeekend: true
485
- ```
486
-
487
- ### File Watcher Settings
488
-
489
- File watcher settings are built into the system:
490
-
491
- - **Debounce Time**: 2 seconds (waits for file writes to stabilize)
492
- - **Ignored Files**: Dotfiles (`.git`, `.env`, etc.)
493
- - **Max Test Timeout**: 60 seconds per acceptance check
494
-
495
- ## Troubleshooting
496
-
497
- ### Issue: Tasks Not Auto-Transitioning
498
-
499
- **Symptoms**: File changes detected but task stays in `todo`
500
-
501
- **Solutions**:
502
- 1. Verify files are linked to task:
503
- ```typescript
504
- task action=watch_files task_id=123 action=list
505
- // OR
506
- task action=get task_id=123
507
- // Check for file links in response
508
- ```
509
-
510
- 2. Check file watcher status:
511
- ```typescript
512
- task action=watcher subaction=status
513
- // Should show: running: true, files_watched: N
514
- ```
515
-
516
- 3. Verify task is in correct status:
517
- ```typescript
518
- task action=list status=todo
519
- ```
520
-
521
- ### Issue: Acceptance Criteria Not Running
522
-
523
- **Symptoms**: Task moved to `in_progress` but never completes
524
-
525
- **Solutions**:
526
- 1. Check acceptance criteria JSON is valid:
527
- ```typescript
528
- task action=get task_id=123
529
- // Verify acceptance_criteria_json is present
530
- ```
531
-
532
- 2. Check console output for test execution errors:
533
- ```
534
- Error checking acceptance criteria for task #123: <error message>
535
- ```
536
-
537
- 3. Manually run acceptance check commands:
538
- ```bash
539
- npm test auth # Should pass and output "passing"
540
- ```
541
-
542
- ### Issue: File Watcher Not Starting
543
-
544
- **Symptoms**: No file changes detected at all
545
-
546
- **Solutions**:
547
- 1. Check MCP server logs on startup:
548
- ```
549
- ✓ File watcher started successfully
550
- Watching 3 files for 2 tasks
551
- ```
552
-
553
- 2. Check watcher status via MCP tool:
554
- ```typescript
555
- task action=watcher subaction=status
556
- ```
557
-
558
- 3. Restart MCP server if watcher failed to start
559
- 4. Check file paths are absolute (not relative)
560
-
561
- ### Issue: Tests Timing Out
562
-
563
- **Symptoms**: Acceptance criteria checks fail with timeout errors
564
-
565
- **Solutions**:
566
- 1. Increase timeout in acceptance criteria:
567
- ```typescript
568
- acceptance_criteria: [
569
- {type: "tests_pass", command: "npm test", timeout: 120} // 120 seconds
570
- ]
571
- ```
572
-
573
- 2. Optimize slow tests to run faster
574
- 3. Split large test suites into smaller checks
575
-
576
- ## Performance Considerations
577
-
578
- ### Token Efficiency
579
-
580
- **Without Auto-Tracking** (manual workflow):
581
- - Create task: ~800 tokens
582
- - Link file: ~200 tokens
583
- - Manual move to in_progress: ~150 tokens
584
- - Manual move to done: ~150 tokens
585
- - Get task status: ~200 tokens × 3 checks = ~600 tokens
586
- - **Total**: ~1,900 tokens per task
587
-
588
- **With Auto-Tracking**:
589
- - Create task with acceptance criteria: ~900 tokens
590
- - Link file: ~200 tokens
591
- - Auto-transitions: 0 tokens
592
- - **Total**: ~1,100 tokens per task
593
-
594
- **Savings**: 800 tokens per task (42% reduction)
595
-
596
- For 6 tasks: **4,800 tokens saved** (97% reduction in status management overhead)
597
-
598
- ### CPU and I/O Impact
599
-
600
- - **File Watching**: Minimal CPU usage (chokidar is highly optimized)
601
- - **Debouncing**: Reduces I/O by waiting for file writes to stabilize
602
- - **Test Execution**: Runs only when files change (not continuously)
603
- - **Database Queries**: Efficient indexed queries on task-file links
604
-
605
- ### Scalability
606
-
607
- - **100 files watched**: ~5MB memory, <1% CPU
608
- - **1000 files watched**: ~50MB memory, <5% CPU
609
- - **10,000 files watched**: ~500MB memory, <10% CPU
610
-
611
- **Recommendation**: Link only relevant files to tasks (not entire directories)
612
-
613
- ## Best Practices
614
-
615
- ### 1. Use watch_files Parameter for New Tasks (v4.0.0+)
616
-
617
- ```typescript
618
- // GOOD: Create task with files in one step
619
- task action=create
620
- title: "Implement auth"
621
- watch_files: ["src/auth.ts", "src/auth.test.ts"]
622
- acceptance_criteria: [...]
623
-
624
- // BAD: Using deprecated link API
625
- task action=create title="Implement auth"
626
- task action=link task_id=123 link_type=file target_id="src/auth.ts"
627
- ```
628
-
629
- ### 2. Link Only Relevant Files
630
-
631
- ```typescript
632
- // GOOD: Link specific implementation files
633
- task action=create
634
- watch_files: ["src/auth.ts", "src/auth.test.ts"]
635
-
636
- // BAD: Don't link entire directories or unrelated files
637
- task action=create
638
- watch_files: ["src/"] // ❌ Not a file
639
- ```
640
-
641
- ### 3. Use Specific Acceptance Criteria
642
-
643
- ```typescript
644
- // GOOD: Specific, testable criteria
645
- acceptance_criteria: [
646
- {type: "tests_pass", command: "npm test -- auth.test.ts", expected_pattern: "3 passing"},
647
- {type: "code_contains", file: "src/auth.ts", pattern: "class AuthService"}
648
- ]
649
-
650
- // BAD: Vague or overly broad criteria
651
- acceptance_criteria: [
652
- {type: "tests_pass", command: "npm test"} // ❌ Too broad, slow
653
- ]
654
- ```
655
-
656
- ### 4. Set Realistic Timeouts
657
-
658
- ```typescript
659
- // GOOD: Appropriate timeouts based on test complexity
660
- acceptance_criteria: [
661
- {type: "tests_pass", command: "npm run unit-tests", timeout: 30}, // Fast unit tests
662
- {type: "tests_pass", command: "npm run e2e-tests", timeout: 300} // Slower E2E tests
663
- ]
664
- ```
665
-
666
- ### 5. Combine Multiple Check Types
667
-
668
- ```typescript
669
- acceptance_criteria: [
670
- // Verify implementation exists
671
- {type: "code_contains", file: "src/auth.ts", pattern: "export class AuthService"},
672
-
673
- // Verify old code removed
674
- {type: "code_removed", file: "src/auth.ts", pattern: "// TODO: implement auth"},
675
-
676
- // Verify tests pass
677
- {type: "tests_pass", command: "npm test auth", expected_pattern: "passing"},
678
-
679
- // Verify documentation created
680
- {type: "file_exists", file: "docs/authentication.md"}
681
- ]
682
- ```
683
-
684
- ### 6. Archive Completed Tasks
685
-
686
- ```typescript
687
- // Move done tasks to archived to stop file watching
688
- task action=archive task_id=123
689
- ```
690
-
691
- This unregisters the task from the file watcher, freeing up resources.
692
-
693
- ## Advanced Usage
694
-
695
- ### Conditional Acceptance Criteria
696
-
697
- Use regex patterns for flexible validation:
698
-
699
- ```typescript
700
- acceptance_criteria: [
701
- // Accept either "passing" or "success"
702
- {type: "tests_pass", command: "npm test", expected_pattern: "(passing|success)"},
703
-
704
- // Verify function signature (flexible whitespace)
705
- {type: "code_contains", file: "src/api.ts", pattern: "async\\s+function\\s+fetchData"}
706
- ]
707
- ```
708
-
709
- ### Multi-File Tasks
710
-
711
- Link multiple files to a single task:
712
-
713
- ```typescript
714
- // Using watch_files parameter (v3.4.1+)
715
- task action=create
716
- title: "Implement authentication"
717
- watch_files: ["src/auth.ts", "src/auth.test.ts", "docs/auth.md"]
718
-
719
- // OR using watch_files action
720
- task action=watch_files
721
- task_id: 123
722
- action: watch
723
- file_paths: ["src/auth.ts", "src/auth.test.ts", "docs/auth.md"]
724
- ```
725
-
726
- Any file change triggers the workflow.
727
-
728
- ### Integration with CI/CD
729
-
730
- Use shell commands to run CI checks:
731
-
732
- ```typescript
733
- acceptance_criteria: [
734
- {type: "tests_pass", command: "npm run lint", expected_pattern: "no errors"},
735
- {type: "tests_pass", command: "npm run type-check", expected_pattern: "0 errors"},
736
- {type: "tests_pass", command: "npm test", expected_pattern: "passing"}
737
- ]
738
- ```
739
-
740
- ## Examples
741
-
742
- ### Example 1: Simple Bug Fix (v4.0.0)
743
-
744
- ```typescript
745
- // Create task with file watching
746
- task action=create
747
- title: "Fix login button styling"
748
- watch_files: ["src/LoginButton.css"]
749
- acceptance_criteria: [
750
- {type: "code_contains", file: "src/LoginButton.css", pattern: "background-color: #007bff"},
751
- {type: "tests_pass", command: "npm test LoginButton", expected_pattern: "passing"}
752
- ]
753
-
754
- // Edit file → auto-transitions to in_progress
755
- // Tests pass → auto-completes to done
756
- ```
757
-
758
- ### Example 2: Feature Implementation (v4.0.0)
759
-
760
- ```typescript
761
- // Create task with multiple files
762
- task action=create
763
- title: "Add user profile endpoint"
764
- watch_files: ["src/routes/profile.ts", "src/routes/profile.test.ts"]
765
- acceptance_criteria: [
766
- {type: "file_exists", file: "src/routes/profile.ts"},
767
- {type: "code_contains", file: "src/routes/profile.ts", pattern: "router.get\\('/profile'"},
768
- {type: "tests_pass", command: "npm test routes/profile", expected_pattern: "5 passing"}
769
- ]
770
- ```
771
-
772
- ### Example 3: Refactoring Task (v4.0.0)
773
-
774
- ```typescript
775
- // Create task
776
- task action=create
777
- title: "Remove deprecated API endpoints"
778
- watch_files: ["src/api/legacy.ts"]
779
- acceptance_criteria: [
780
- {type: "code_removed", file: "src/api/legacy.ts", pattern: "router.get\\('/old-endpoint'"},
781
- {type: "code_removed", file: "src/api/legacy.ts", pattern: "// DEPRECATED"},
782
- {type: "tests_pass", command: "npm test", expected_pattern: "0 failing"}
783
- ]
784
- ```
785
-
786
- ### Example 4: Adding Files to Existing Task
787
-
788
- ```typescript
789
- // Task already exists, add more files to watch
790
- task action=watch_files
791
- task_id: 47
792
- action: watch
793
- file_paths: ["src/api/v2.ts", "src/api/v2.test.ts"]
794
-
795
- // Check what's being watched
796
- task action=watch_files
797
- task_id: 47
798
- action: list
799
- // Returns: { files: ["src/api/legacy.ts", "src/api/v2.ts", "src/api/v2.test.ts"] }
800
-
801
- // Remove file from watch list
802
- task action=watch_files
803
- task_id: 47
804
- action: unwatch
805
- file_paths: ["src/api/legacy.ts"]
806
- ```
807
-
808
- ## Migration to v4.0.0
809
-
810
- ### Before (v3.2.x)
811
-
812
- ```typescript
813
- // Create task
814
- task action=create title="Implement auth" ...
815
-
816
- // Link files separately
817
- task action=link task_id=123 link_type=file target_id="src/auth.ts"
818
- task action=link task_id=123 link_type=file target_id="src/auth.test.ts"
819
- ```
820
-
821
- ### After (v4.0.0)
822
-
823
- ```typescript
824
- // Create task with files in one call
825
- task action=create
826
- title: "Implement auth"
827
- watch_files: ["src/auth.ts", "src/auth.test.ts"]
828
- ...
829
- ```
830
-
831
- **Benefits**:
832
- - Fewer MCP calls (1 instead of 3)
833
- - Clearer intent
834
- - Better error handling
835
- - Batch file registration with watcher
836
-
837
- ## See Also
838
-
839
- - [ACCEPTANCE_CRITERIA.md](./ACCEPTANCE_CRITERIA.md) - All acceptance check types
840
- - [WORKFLOWS.md](./WORKFLOWS.md) - Multi-agent coordination patterns
841
- - [BEST_PRACTICES.md](./BEST_PRACTICES.md) - Common errors and solutions