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
package/CHANGELOG.md CHANGED
@@ -5,6 +5,819 @@ All notable changes to sqlew will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.5.2] - 2025-10-24
9
+
10
+ ### Added - Two-Step Git-Aware Task Workflow 🎯
11
+
12
+ **Major Feature: Automatic task completion and archiving based on Git staging and committing**
13
+
14
+ Task transitions now align with Git workflow stages:
15
+ - **Step 1 - Staging** (`git add`): `waiting_review` → `done` (work complete)
16
+ - **Step 2 - Committing** (`git commit`): `done` → `archived` (work finalized, board clean)
17
+
18
+ #### Key Benefits
19
+ 1. 🧹 Clean Task Board - Automatic archiving keeps active board focused
20
+ 2. ⚡ Fast Feedback - `git add` provides immediate completion signal
21
+ 3. 🔒 Finalized State - `git commit` represents permanent work
22
+ 4. 💰 Zero Token Cost - Fully automated, no manual MCP calls needed
23
+ 5. 🌍 Multi-VCS Support - Works with Git, Mercurial, and SVN
24
+
25
+ #### Implementation Details
26
+ - **VCS Adapter**: Added `getStagedFiles()` method to all adapters (Git/Mercurial/SVN)
27
+ - **Detection Functions**: `detectAndCompleteOnStaging()` and `detectAndArchiveOnCommit()`
28
+ - **File Watcher**: Enhanced to call both functions on VCS index change
29
+ - **Configuration**: 4 new config keys for granular control
30
+
31
+ #### Configuration (v3.5.2)
32
+ - `git_auto_complete_on_stage` (default: `'1'`) - Enable staging-based completion
33
+ - `git_auto_archive_on_commit` (default: `'1'`) - Enable commit-based archiving
34
+ - `require_all_files_staged` (default: `'1'`) - Require ALL files staged (vs ANY)
35
+ - `require_all_files_committed_for_archive` (default: `'1'`) - Require ALL files committed
36
+
37
+ #### Example Workflow
38
+ ```bash
39
+ # Create task
40
+ task action=create title="Feature" watch_files=["src/feature.ts"]
41
+
42
+ # Work on feature → todo → in_progress → waiting_review
43
+
44
+ # Stage changes
45
+ git add src/feature.ts # → Task: waiting_review → done ✅
46
+
47
+ # Commit changes
48
+ git commit -m "Add feature" # → Task: done → archived 📦
49
+ ```
50
+
51
+ #### Migration from v3.4.0
52
+ - **Backward Compatible** - No breaking changes
53
+ - Config defaults enable two-step workflow automatically
54
+ - Can be disabled via config if needed
55
+
56
+ ## [3.5.1] - 2025-10-24
57
+
58
+ ### Fixed - File Watcher WSL Compatibility and Path Matching
59
+
60
+ **Bugfix: Upgraded chokidar from v3 to v4 + Fixed path normalization bug**
61
+
62
+ File watcher was not detecting file changes on WSL due to two issues:
63
+ 1. Outdated chokidar v3.6.0 (requires manual polling configuration for WSL)
64
+ 2. Path mismatch bug: chokidar reports absolute paths but database stores relative paths
65
+
66
+ #### Changes Made
67
+
68
+ **1. Dependency Upgrade**
69
+ - **chokidar**: `^3.6.0` → `^4.0.3`
70
+ - **File**: `package.json`
71
+
72
+ **2. Configuration Simplification**
73
+ - Removed manual WSL detection and polling configuration
74
+ - Removed `usePolling` and `interval` options (handled automatically by v4)
75
+ - Updated error handler type: `Error` → `unknown` (chokidar v4 compatibility)
76
+ - **File**: `src/watcher/file-watcher.ts`
77
+
78
+ **3. Path Normalization Fix** (Critical Bug)
79
+ - Fixed `normalizePath()` to convert absolute paths to relative paths
80
+ - Chokidar reports: `/home/.../project/file.ts` (absolute)
81
+ - Database stores: `file.ts` (relative)
82
+ - **Before**: Map lookup failed (paths didn't match)
83
+ - **After**: Both normalized to `file.ts` (matches correctly)
84
+ - **File**: `src/watcher/file-watcher.ts:571-587`
85
+
86
+ **4. Documentation Updates**
87
+ - Updated version references to v3.5.1
88
+ - Added note that chokidar v4 handles WSL automatically
89
+ - **Files**: `src/watcher/file-watcher.ts`
90
+
91
+ #### Problem Solved
92
+
93
+ **Before v3.5.1:**
94
+ ```
95
+ Issue 1 - WSL Detection:
96
+ Cause: chokidar v3 requires manual polling configuration
97
+ Result: File changes not detected on WSL
98
+
99
+ Issue 2 - Path Matching:
100
+ Chokidar reports: /full/path/to/file.ts
101
+ Database stores: file.ts
102
+ Result: Map lookup fails, no auto-transition ❌
103
+ ```
104
+
105
+ **After v3.5.1:**
106
+ ```
107
+ WSL: chokidar v4 handles automatically
108
+ Path: Both normalized to relative paths
109
+ Result: Auto-tracking works correctly ✅
110
+ ```
111
+
112
+ #### Testing
113
+ - Verified on WSL with chokidar v4
114
+ - Created task watching `test-watcher-v3.5.1.ts`
115
+ - Edited file → Task auto-transitioned from todo → in_progress
116
+ - TypeScript compilation successful
117
+
118
+ ## [3.5.0] - 2025-10-22
119
+
120
+ ### Added - Non-Existent File Auto-Pruning with Audit Trail 🔧
121
+
122
+ **Major Feature: Automatic removal of non-existent watched files with project archaeology**
123
+
124
+ Tasks watching planned files that were never created (renamed, deleted, or scope-reduced during implementation) no longer block quality gates. Auto-pruning maintains clean watch lists while preserving complete audit trail for post-mortem analysis and team handoffs.
125
+
126
+ #### Core Implementation
127
+
128
+ **1. Database Schema Migration**
129
+ - **New Table**: `t_task_pruned_files` - Audit trail for pruned files
130
+ - **Columns**: id, task_id, file_path, pruned_ts, linked_decision_id
131
+ - **Indexes**: idx_pruned_task, idx_pruned_decision
132
+ - **File**: `src/migrations/add-v3.5.0-pruned-files.ts`
133
+ - **Persistence**: Audit records survive task archival for long-term archaeology
134
+
135
+ **2. Core Pruning Logic**
136
+ - **Function**: `pruneNonExistentFiles(db, taskId, projectRoot)`
137
+ - **Safety Check**: Blocks transition if ALL files non-existent (prevents zero-work completion)
138
+ - **Behavior**: Partial pruning (removes only non-existent files, keeps existing)
139
+ - **Audit Trail**: Records every pruned file with timestamp
140
+ - **File**: `src/utils/file-pruning.ts`
141
+
142
+ **3. Integration into Quality Gates**
143
+ - **Trigger Point**: During `in_progress → waiting_review` transition
144
+ - **Timing**: BEFORE quality gate validation (Decision #161)
145
+ - **Process**: Check existence → Prune non-existent → Validate remaining files
146
+ - **File**: `src/utils/task-stale-detection.ts`
147
+ - **Safety**: Cannot complete tasks with no work done (Decision #163)
148
+
149
+ **4. MCP Actions**
150
+ - **get_pruned_files**: Retrieve audit trail for a task
151
+ - Parameters: task_id, limit (optional)
152
+ - Returns: Pruned file records with timestamps and decision links
153
+ - **link_pruned_file**: Attach WHY reasoning to pruned files
154
+ - Parameters: pruned_file_id, decision_key
155
+ - Purpose: Project archaeology and team handoffs
156
+ - **File**: `src/tools/tasks.ts`, `src/index.ts`
157
+
158
+ **5. Documentation**
159
+ - **TASK_PRUNING.md**: Comprehensive 500+ line guide
160
+ - How it works, safety checks, audit trail
161
+ - MCP action reference with examples
162
+ - Use cases, best practices, troubleshooting
163
+ - Post-mortem analysis queries
164
+
165
+ #### Problem Solved
166
+
167
+ **Before v3.5.0:**
168
+ ```
169
+ Task watches: ["src/feature-a.ts", "src/feature-b.ts"]
170
+ During implementation: feature-b absorbed into feature-a
171
+ Result: Task stuck in in_progress (file-b.ts doesn't exist)
172
+ Resolution: Manual intervention required ❌
173
+ ```
174
+
175
+ **After v3.5.0:**
176
+ ```
177
+ Task watches: ["src/feature-a.ts", "src/feature-b.ts"]
178
+ During implementation: feature-b absorbed into feature-a
179
+ Auto-prune runs: Removes feature-b.ts from watch list
180
+ Audit trail: Records why file-b wasn't created
181
+ Result: Task proceeds to waiting_review ✅
182
+ ```
183
+
184
+ #### Use Cases
185
+
186
+ **Use Case 1: Endpoint Not Needed**
187
+ - Planned: `/api/v2/users` endpoint
188
+ - Actual: v1 endpoint sufficient
189
+ - Auto-prune: Removes v2 files, links to decision explaining why
190
+
191
+ **Use Case 2: Feature Absorbed into Existing Code**
192
+ - Planned: `src/utils/new-helper.ts`
193
+ - Actual: Functionality added to existing helper
194
+ - Auto-prune: Removes new-helper.ts, preserves audit trail
195
+
196
+ **Use Case 3: Test Strategy Changed**
197
+ - Planned: Integration tests
198
+ - Actual: Unit tests sufficient
199
+ - Auto-prune: Removes integration test files, decision linked
200
+
201
+ #### Safety Checks
202
+
203
+ **Zero-Work Prevention**:
204
+ ```typescript
205
+ // Example: ALL 3 watched files non-existent
206
+ watchedFiles = ["a.ts", "b.ts", "c.ts"] // all non-existent
207
+
208
+ // Safety check triggers:
209
+ Error: "Cannot prune files for task #42: ALL 3 watched files
210
+ are non-existent. This indicates no work was done."
211
+
212
+ // Task stays in in_progress - manual review required
213
+ ```
214
+
215
+ **Partial Pruning Allowed**:
216
+ ```typescript
217
+ // Example: 2 of 3 files exist
218
+ watchedFiles = ["a.ts", "b.ts", "c.ts"]
219
+ // a.ts exists, b.ts exists, c.ts non-existent
220
+
221
+ // Auto-prune: Removes only c.ts
222
+ // Task continues with a.ts and b.ts
223
+ ```
224
+
225
+ #### Configuration
226
+
227
+ Auto-pruning works with existing quality gate configuration:
228
+ - `review_idle_minutes`: Time before pruning check (default: 3)
229
+ - `review_require_all_files_modified`: Quality gate for remaining files (default: true)
230
+
231
+ #### Backward Compatibility
232
+
233
+ - **Zero Breaking Changes**: Works with existing tasks
234
+ - **Automatic Migration**: Runs on first startup of v3.5.0
235
+ - **Idempotent**: Safe to upgrade and downgrade
236
+
237
+ #### Token Efficiency
238
+
239
+ - File paths stored as raw strings (not normalized to m_files)
240
+ - Audit queries paginated with limit parameter
241
+ - No upfront cost - pruning only when needed
242
+
243
+ ### Fixed - File Watcher Architectural Compliance (v3.3.0)
244
+
245
+ **Critical architectural fix**: File watcher now monitors **all project files** with .gitignore filtering, as originally designed in v3.3.0 decision.
246
+
247
+ **What Changed:**
248
+ - ✅ Watches entire project root instead of individual files
249
+ - ✅ Automatic monitoring of all files (selective task linking for transitions)
250
+ - ✅ Removed explicit file add/remove operations (simplified architecture)
251
+ - ✅ Better performance (single watch root vs many individual watches)
252
+
253
+ **Impact:**
254
+ - **Zero breaking changes** - External API unchanged
255
+ - **Better performance** - Single chokidar watch root more efficient than 100+ individual file watches
256
+ - **Automatic discovery** - New files automatically monitored when created
257
+ - **Simpler code** - Removed watch control logic, `watchedFiles` map is now pure lookup
258
+
259
+ **Technical Details:**
260
+ - Modified `src/watcher/file-watcher.ts` line 80: `chokidar.watch(this.projectRoot)` instead of `chokidar.watch([])`
261
+ - Removed explicit `watcher.add()` calls in `registerFile()` method
262
+ - Removed explicit `watcher.unwatch()` calls in `unregisterFile()` method
263
+ - Global watching with .gitignore filtering (lines 87-94) now fully utilized
264
+
265
+ **Why This Matters:**
266
+ The v3.3.0 architectural decision mandated "Watch all project files with .gitignore support instead of individual file registration" but the implementation was selective (only task-linked files). This fix ensures compliance with the original design, providing better performance and simpler architecture.
267
+
268
+ ## [3.4.1] - 2025-10-22
269
+
270
+ ### Changed - VCS Abstraction Layer Enhancement
271
+
272
+ Extended v3.4.0 Git-aware auto-complete to support multiple version control systems through adapter pattern.
273
+
274
+ **New VCS Support:**
275
+ - ✅ **Mercurial (hg)** - Full support with `.hg/dirstate` watching
276
+ - ✅ **SVN (Subversion)** - Periodic check support (no local index file)
277
+
278
+ **Implementation:**
279
+ - Created VCS adapter interface (`src/utils/vcs-adapter.ts`)
280
+ - Implemented GitAdapter, MercurialAdapter, SVNAdapter
281
+ - Auto-detection logic with priority: Git → Mercurial → SVN
282
+ - Refactored `detectAndCompleteReviewedTasks()` to use VCS abstraction
283
+ - Enhanced file watcher to support multiple VCS index files
284
+
285
+ **Backward Compatible:** No breaking changes - fully compatible with Git-only workflows.
286
+
287
+ **Future Support:** Perforce and Plastic SCM planned (see [#19](https://github.com/sin5ddd/mcp-sqlew/issues/19))
288
+
289
+ ## [3.4.0] - 2025-10-22
290
+
291
+ ### Added - Git-Aware Auto-Complete 🎯
292
+
293
+ **Major Feature: Automatic Task Completion via Git Commits**
294
+
295
+ Replace flawed auto-revert logic with intelligent git-commit-based task completion. When ALL watched files for a task are committed to Git, the task automatically transitions from `waiting_review` → `done`. Git commits serve as implicit review approval.
296
+
297
+ #### Core Implementation
298
+
299
+ **1. `detectAndCompleteReviewedTasks()` Function**
300
+ - New core function for git-aware auto-complete detection
301
+ - Uses `git log --since="@<task.created_ts>" --name-only` to query commit history
302
+ - Validates ALL watched files are committed (configurable)
303
+ - Gracefully handles non-git repositories (skips auto-complete)
304
+ - **File**: `src/utils/task-stale-detection.ts`
305
+ - **Token Efficiency**: Zero token cost - uses local git commands
306
+
307
+ **2. Real-Time Git Index Watching**
308
+ - File watcher monitors `.git/index` for changes
309
+ - Detects `git add` and `git commit` operations in real-time
310
+ - Triggers `detectAndCompleteReviewedTasks()` automatically on git operations
311
+ - **Files**: `src/watcher/file-watcher.ts`, `src/watcher/index.ts`
312
+ - **Benefit**: Immediate task completion without manual intervention
313
+
314
+ **3. Periodic Git Checks**
315
+ - `task.list()` action now checks for committed files before returning
316
+ - Ensures eventual task completion even if file watcher missed events
317
+ - **File**: `src/tools/tasks.ts`
318
+ - **Response Fields**: `git_auto_completed` (count of auto-completed tasks)
319
+
320
+ **5. Enhanced Inline Status (v3.4.0)**
321
+ - `stats` tool now includes `review_status` section
322
+ - Shows `awaiting_commit` count (tasks in waiting_review)
323
+ - Shows `overdue_review` count (tasks in waiting_review >24h)
324
+ - **File**: `src/tools/utils.ts`
325
+
326
+ **6. Configuration Options**
327
+ - `git_auto_complete_enabled` (default: '1') - Enable/disable feature
328
+ - `require_all_files_committed` (default: '1') - ALL vs ANY files committed
329
+ - `stale_review_notification_hours` (default: '48') - Notification threshold
330
+ - **File**: `src/database.ts`
331
+
332
+ #### Problem Solved
333
+
334
+ **Before v3.4.0 (FLAWED):**
335
+ ```
336
+ waiting_review (24h idle) → todo (work discarded ❌)
337
+ ```
338
+
339
+ **After v3.4.0 (VCS-AWARE):**
340
+ ```
341
+ waiting_review (all files committed) → done (work preserved ✅)
342
+ ```
343
+
344
+ **Why This Matters:**
345
+ - Tasks reaching `waiting_review` have passed quality gates (files modified, tests pass, compile success)
346
+ - Work is essentially DONE - reverting to `todo` discarded completed work
347
+ - VCS commits are a natural, persistent signal that code has been reviewed and approved
348
+ - **Multi-VCS Support**: Works with Git, Mercurial, SVN - no configuration needed (auto-detection)
349
+
350
+ #### Usage Examples
351
+
352
+ **Example 1: Real-Time Auto-Complete**
353
+ ```typescript
354
+ // 1. Task created with watched files
355
+ task action=create
356
+ title: "Implement JWT auth"
357
+ watch_files: ["src/auth.ts", "src/auth.test.ts"]
358
+ // Status: todo
359
+
360
+ // 2. Edit files → auto-transition to in_progress
361
+ // 3. Quality gates pass → auto-transition to waiting_review
362
+ // 4. Developer commits files (any VCS):
363
+ git commit -m "feat: Add JWT authentication"
364
+ // OR: hg commit -m "feat: Add JWT authentication"
365
+ // OR: svn commit -m "feat: Add JWT authentication"
366
+
367
+ // 5. File watcher detects VCS index change (Git/Mercurial)
368
+ // 6. Auto-complete runs → Task moves to 'done' ✅
369
+ ```
370
+
371
+ **Example 2: Periodic Check**
372
+ ```typescript
373
+ // Task in waiting_review, files committed yesterday
374
+ task action=list
375
+ // Response includes:
376
+ {
377
+ tasks: [...],
378
+ git_auto_completed: 1, // This task just auto-completed
379
+ ...
380
+ }
381
+ ```
382
+
383
+ ### Changed
384
+
385
+ **1. Removed Flawed Auto-Revert Logic**
386
+ - **REMOVED**: `waiting_review` → `todo` after 24 hours
387
+ - **Rationale**: Tasks in waiting_review have completed work; reverting discarded progress
388
+ - **File**: `src/utils/task-stale-detection.ts` (lines 105-116 removed)
389
+
390
+ **2. Updated Review Idle Time Default**
391
+ - **Changed**: Default from 15 minutes → 3 minutes
392
+ - **Rationale**: 3 minutes is sufficient for quality gate detection
393
+ - **Config Key**: `review_idle_minutes`
394
+ - **File**: `src/utils/task-stale-detection.ts`
395
+
396
+ ### Fixed
397
+
398
+ - Zero-token overhead for git-aware auto-complete (uses local git commands)
399
+ - Multi-agent compatible (git state shared across all agents)
400
+ - Survives process restarts (git history is persistent)
401
+ - Handles edge cases: no git repo, no watched files, partial commits
402
+
403
+ ### Documentation
404
+
405
+ **Updated:**
406
+ - `docs/TASK_OVERVIEW.md` - Git-aware workflow diagram and waiting_review behavior
407
+ - `docs/AUTO_FILE_TRACKING.md` - Git integration explanation
408
+ - `docs/CONFIGURATION.md` - New config keys documented
409
+ - `README.md` - v3.4.0 feature highlights
410
+
411
+ **New:**
412
+ - `src/tests/git-aware-completion.test.ts` - Comprehensive test suite
413
+
414
+ ### Technical Details
415
+
416
+ **Files Modified:**
417
+ - `src/utils/task-stale-detection.ts` - Core git-aware logic, removed flawed auto-revert
418
+ - `src/tools/tasks.ts` - Periodic git checks in list action
419
+ - `src/tools/utils.ts` - Enhanced inline status with review_status
420
+ - `src/watcher/file-watcher.ts` - Git index watching
421
+ - `src/database.ts` - New v3.4.0 config keys
422
+
423
+ **Dependencies:**
424
+ - No new dependencies (uses Node.js built-in `child_process` for git commands)
425
+
426
+ **Token Efficiency:**
427
+ - Zero-token cost for git operations
428
+ - Periodic checks piggyback on existing list operations
429
+ - No additional API calls required
430
+
431
+ ### Migration
432
+
433
+ **From v3.4.1 to v3.4.0:**
434
+ - **Automatic**: Config keys auto-added on database initialization
435
+ - **Breaking Change**: None - fully backward compatible
436
+ - **Behavior Change**: Tasks in `waiting_review` no longer auto-revert to `todo`
437
+ - **Action Required**: None - feature enabled by default
438
+
439
+ **Configuration (Optional):**
440
+ ```toml
441
+ # .sqlew/config.toml
442
+ [tasks.review]
443
+ git_auto_complete_enabled = true # Default: true
444
+ require_all_files_committed = true # Default: true
445
+ stale_review_notification_hours = 48 # Default: 48
446
+
447
+ [tasks]
448
+ review_idle_minutes = 3 # Changed from 15 to 3
449
+ ```
450
+
451
+ ---
452
+
453
+ ## [3.4.1] - 2025-10-22
454
+
455
+ ### Added - File Watcher Redesign & Smart Filtering
456
+
457
+ #### New Features
458
+
459
+ **1. `watch_files` Parameter (task.create and task.update)**
460
+ - Add files to watch when creating or updating tasks in one step
461
+ - Replaces the need for separate `task.link(link_type="file")` calls
462
+ - Batch file registration with atomic watcher updates
463
+ - Example:
464
+ ```typescript
465
+ task action=create
466
+ title: "Implement auth"
467
+ watch_files: ["src/auth.ts", "src/auth.test.ts"]
468
+ ```
469
+ - **Token Savings**: 75% fewer MCP calls (1 vs 4), 35% token reduction
470
+ - **Files Modified**: `src/tools/tasks.ts`
471
+
472
+ **2. GitIgnore Support & Smart File Filtering**
473
+ - Automatic `.gitignore` parsing from project root
474
+ - 70+ built-in ignore patterns (node_modules, dist, .env, etc.)
475
+ - Prevents watching sensitive/build/dependency files
476
+ - Zero configuration - works out of the box
477
+ - Example patterns ignored:
478
+ - Version control: `.git`, `.gitignore`
479
+ - Dependencies: `node_modules`, `bower_components`
480
+ - Build outputs: `dist`, `build`, `.next`, `.nuxt`
481
+ - Logs: `*.log`, `npm-debug.log*`
482
+ - OS files: `.DS_Store`, `Thumbs.db`
483
+ - IDE files: `.vscode`, `.idea`, `*.swp`
484
+ - Environment: `.env`, `.env.local`
485
+ - Database: `*.db`, `.mcp-context`
486
+ - **New Module**: `src/watcher/gitignore-parser.ts`
487
+ - **Files Modified**: `src/watcher/file-watcher.ts`, `src/watcher/index.ts`
488
+ - **Dependencies Added**: `ignore` npm package
489
+
490
+ **3. `watch_files` Action**
491
+ - Dedicated action for managing file watches dynamically
492
+ - Three sub-actions: `watch`, `unwatch`, `list`
493
+ - Batch operations support (multiple files in one call)
494
+ - Example:
495
+ ```typescript
496
+ // Watch files
497
+ task action=watch_files task_id=123 action=watch file_paths=["src/file.ts"]
498
+
499
+ // Unwatch files
500
+ task action=watch_files task_id=123 action=unwatch file_paths=["src/file.ts"]
501
+
502
+ // List watched files
503
+ task action=watch_files task_id=123 action=list
504
+ ```
505
+ - **Files Modified**: `src/tools/tasks.ts`
506
+
507
+ **4. Updated Help Documentation**
508
+ - `task.help()` now documents new `watch_files` parameter and action
509
+ - Deprecation notices for `task.link(link_type="file")`
510
+ - Updated examples to use v3.4.1 API
511
+ - **Files Modified**: `src/tools/tasks.ts` (taskHelp function)
512
+
513
+ **5. Auto-Archive for Done Tasks**
514
+ - Automatic archiving of tasks in `done` status after 48 hours (2 days)
515
+ - Weekend-aware retention logic (consistent with message/file cleanup)
516
+ - Configurable via `auto_archive_done_days` setting (default: 2 days)
517
+ - Runs on startup and before task operations (`list`, `move`)
518
+ - Same-session context preservation: Tasks remain accessible for 1-2 day sprints
519
+ - After 48 hours: Tasks archived to keep active list clean
520
+ - Example:
521
+ ```
522
+ Friday 5pm: Task marked done
523
+ Tuesday 5pm: Auto-archived (skips weekend)
524
+ ```
525
+ - **New Config Key**: `auto_archive_done_days` in m_config table
526
+ - **New Function**: `autoArchiveOldDoneTasks()` in src/utils/task-stale-detection.ts
527
+ - **New Function**: `calculateTaskArchiveCutoff()` in src/utils/retention.ts
528
+ - **Files Modified**:
529
+ - `src/constants.ts` (added CONFIG_KEYS.AUTO_ARCHIVE_DONE_DAYS)
530
+ - `src/utils/retention.ts` (calculateTaskArchiveCutoff function)
531
+ - `src/utils/task-stale-detection.ts` (autoArchiveOldDoneTasks function, TASK_STATUS constants)
532
+ - `src/tools/tasks.ts` (listTasks, moveTask - integrated auto-archive calls)
533
+ - `src/database.ts` (initializeDatabase - runs auto-archive on startup)
534
+ - `assets/schema.sql` (default config value)
535
+
536
+ **6. TOML Configuration File Support**
537
+ - Load configuration from `.sqlew/config.toml` file
538
+ - Database path configurable via config file
539
+ - Hierarchical config structure with three sections:
540
+ - `[database]` - Database location settings
541
+ - `[autodelete]` - Retention policies (weekend-aware, message hours, file history)
542
+ - `[tasks]` - Task management settings (auto-archive, stale detection)
543
+ - Priority system: CLI args > config.toml > database m_config > code defaults
544
+ - Config validation with helpful error messages
545
+ - Comprehensive example file: `.sqlew/config.toml.example`
546
+ - All numeric settings have range validation:
547
+ - `message_hours`: 1-720 (1 hour to 30 days)
548
+ - `file_history_days`: 1-365 (1 day to 1 year)
549
+ - `auto_archive_done_days`: 1-365 (1 day to 1 year)
550
+ - `stale_hours_in_progress`: 1-168 (1 hour to 1 week)
551
+ - `stale_hours_waiting_review`: 1-720 (1 hour to 30 days)
552
+ - Example config:
553
+ ```toml
554
+ [database]
555
+ path = ".sqlew/custom.db"
556
+
557
+ [autodelete]
558
+ ignore_weekend = true
559
+ message_hours = 48
560
+ file_history_days = 14
561
+
562
+ [tasks]
563
+ auto_archive_done_days = 2
564
+ stale_hours_in_progress = 2
565
+ stale_hours_waiting_review = 24
566
+ auto_stale_enabled = true
567
+ ```
568
+ - **New Dependency**: `smol-toml@^1.4.2` - TOML parser
569
+ - **New Files**:
570
+ - `src/config/types.ts` (TypeScript interfaces, DEFAULT_CONFIG)
571
+ - `src/config/loader.ts` (loadConfigFile, flattenConfig, validateConfig functions)
572
+ - `.sqlew/config.toml.example` (comprehensive example with documentation)
573
+ - **Files Modified**:
574
+ - `src/database.ts` (initializeDatabase - loads config, validates, populates m_config)
575
+ - `package.json` (smol-toml dependency)
576
+
577
+ **7. Smart Review Detection - Quality-Based Auto-Transition**
578
+ - Automatic transition from `in_progress` → `waiting_review` when quality gates met
579
+ - **Four Quality Gates** (all must pass):
580
+ 1. **All Watched Files Modified**: Every file linked to task must be edited at least once
581
+ 2. **TypeScript Compiles**: If .ts/.tsx files present, `tsc --noEmit` must succeed
582
+ 3. **Tests Pass**: If test files exist (*.test.ts, *.spec.ts), tests must pass
583
+ 4. **Idle Time**: No file modifications for 15 minutes (configurable)
584
+ - **Purely Algorithmic**: No AI instructions needed - works automatically via FileWatcher
585
+ - **Configurable Gates**: Enable/disable individual checks via `.sqlew/config.toml`
586
+ - **Hybrid Mode**: Tasks with `acceptance_criteria` can skip `waiting_review` and go directly to `done`
587
+ - **Configuration Keys**:
588
+ - `review_idle_minutes` (default: 15) - Idle time before checking
589
+ - `review_require_all_files_modified` (default: true) - Require all files edited
590
+ - `review_require_tests_pass` (default: true) - Require tests to pass
591
+ - `review_require_compile` (default: true) - Require TypeScript compilation
592
+ - **Console Output**: Detailed feedback on quality check results (passed/failed)
593
+ - **Example Flow**:
594
+ ```
595
+ File modified → Track modification → Wait 15min idle
596
+
597
+ Check quality gates:
598
+ ✓ All files modified?
599
+ ✓ TypeScript compiles?
600
+ ✓ Tests pass?
601
+
602
+ All passed? → waiting_review
603
+ Some failed? → stay in_progress
604
+ ```
605
+ - **New Module**: `src/utils/quality-checks.ts`
606
+ - `checkAllFilesModified()` - Verify all watched files edited
607
+ - `checkTypeScriptCompiles()` - Run `tsc --noEmit` validation
608
+ - `checkTestsPass()` - Execute test command if test files exist
609
+ - `checkReadyForReview()` - Combine all checks based on config
610
+ - **Files Modified**:
611
+ - `src/constants.ts` (added 4 CONFIG_KEYS: REVIEW_*)
612
+ - `src/config/types.ts` (added review_* fields to TaskConfig, FlatConfig, DEFAULT_CONFIG)
613
+ - `assets/schema.sql` (added 4 config defaults)
614
+ - `src/watcher/file-watcher.ts`:
615
+ - Added tracking maps: `lastModifiedTimes`, `filesModifiedSet`
616
+ - Added `checkAndTransitionToReview()` method
617
+ - Updated `handleFileChange()` to track modifications and schedule review check
618
+ - `docs/AUTO_FILE_TRACKING.md` (new "Smart Review Detection" section)
619
+ - `docs/TASK_OVERVIEW.md` (updated state machine diagram, auto-stale detection section)
620
+ - `README.md` (added Smart Review Detection to Key Features)
621
+
622
+ ### Fixed
623
+
624
+ **1. MCP Router Missing Actions (Task #124)**
625
+ - Added missing actions to task tool enum: `watch_files`, `add_dependency`, `remove_dependency`, `get_dependencies`, `watcher`
626
+ - Added `watch_files` action handler in router switch statement
627
+ - **Files Modified**: `src/index.ts`
628
+
629
+ **2. MCP Schema watch_files Parameter (Task #131)**
630
+ - Added `watch_files` array parameter to task tool input schema
631
+ - Added `file_path` and `file_paths` parameters for watch_files action
632
+ - Added dependency-related parameters for completeness
633
+ - **Files Modified**: `src/index.ts`
634
+
635
+ **3. MCP SDK Array Parameter Handling (Critical)**
636
+ - **Issue**: MCP SDK converts JSON array string `'["file.txt"]'` to character array `['[', '"', 'f', ...']`
637
+ - **Solution**: Auto-detection and reassembly of character arrays back to proper file path arrays
638
+ - **Impact**: Fixes `watch_files` parameter storage corruption in createTask/updateTask
639
+ - **Files Modified**: `src/tools/tasks.ts` (createTaskInternal, updateTask functions)
640
+
641
+ **4. Missing Function Import (Build Error)**
642
+ - Added missing `watchFiles` function to imports from `./tools/tasks.js`
643
+ - Fixed `watch_files` action routing to call correct function instead of `linkTask`
644
+ - **Files Modified**: `src/index.ts`
645
+
646
+ **5. Verified Implementation (Tasks #125, #126, #127)**
647
+ - Task #125: Confirmed watch_files parameter correctly stored via t_task_file_links table - no bug found
648
+ - Task #126: Confirmed watcher query uses correct `f.path` column - no schema error
649
+ - Task #127: Root cause identified - file watcher requires proper database initialization, not a watcher bug
650
+
651
+ ### Changed
652
+
653
+ **1. Deprecated: `task.link(link_type="file")`**
654
+ - Still works but shows deprecation warning in console and response
655
+ - Warning message guides users to new API
656
+ - Backward compatible - no breaking changes
657
+ - Example warning:
658
+ ```
659
+ ⚠️ DEPRECATION WARNING: task.link(link_type="file") is deprecated as of v3.4.1.
660
+ Use task.create(watch_files=[...]) or watch_files action instead.
661
+ ```
662
+ - **Files Modified**: `src/tools/tasks.ts` (linkTask function)
663
+
664
+ ### Documentation
665
+
666
+ **1. NEW: `docs/MIGRATION_v3.3.md`**
667
+ - Comprehensive migration guide from v3.2.x to v3.4.1
668
+ - Step-by-step migration instructions
669
+ - API comparison tables
670
+ - Common migration patterns
671
+ - Backward compatibility details
672
+ - Testing and verification steps
673
+
674
+ **2. NEW: `docs/CONFIGURATION.md`**
675
+ - Complete configuration guide (800+ lines)
676
+ - TOML config file format and structure
677
+ - All configuration options with validation rules
678
+ - Priority system explanation (CLI > config.toml > database > defaults)
679
+ - Setup instructions and best practices
680
+ - Common configurations (development, production, weekend-aware)
681
+ - Troubleshooting section
682
+ - Created by subagent during v3.4.1 development
683
+
684
+ **3. Updated: `docs/AUTO_FILE_TRACKING.md`**
685
+ - Restructured with Quick Start section first (67% token reduction for new users)
686
+ - All examples updated to use v3.4.1 API
687
+ - New "API Changes (v3.4.1)" section
688
+ - Migration guidance for v3.2.x users
689
+ - Deprecation notices throughout
690
+
691
+ **4. Updated: `docs/TOOL_REFERENCE.md`**
692
+ - Task tool parameter table updated with `watch_files`
693
+ - New section: "File Watching with Tasks (v3.4.1)"
694
+ - watch_files action documented
695
+ - Migration examples
696
+ - Deprecation notices
697
+
698
+ **5. Updated: `docs/TASK_OVERVIEW.md`** (by subagent)
699
+ - Auto-archive feature documentation
700
+ - 48-hour retention policy
701
+ - Weekend-aware archiving examples
702
+
703
+ **6. Updated: `docs/TASK_ACTIONS.md`** (by subagent)
704
+ - Auto-archive behavior in list/move actions
705
+ - Updated status transition examples
706
+
707
+ **7. Updated: `docs/ARCHITECTURE.md`** (by subagent)
708
+ - Configuration system architecture
709
+ - Config file loading and priority system
710
+
711
+ **8. Updated: `README.md`** (by subagents)
712
+ - Configuration section added (lines 129-168)
713
+ - Auto-stale detection description updated
714
+ - CONFIGURATION.md reference in documentation section
715
+
716
+ **9. Updated: `CHANGELOG.md`**
717
+ - This entry documenting v3.4.1 changes
718
+
719
+ ### Technical Details
720
+
721
+ **Implementation:**
722
+ - `createTaskInternal()`: Added watch_files parameter and file linking logic
723
+ - `createTask()`: Added watch_files parameter to public API
724
+ - `updateTask()`: Added watch_files parameter to public API
725
+ - `watchFiles()`: New exported function handling watch/unwatch/list actions
726
+ - `linkTask()`: Added deprecation warning for link_type="file"
727
+ - `taskHelp()`: Updated documentation with v3.4.1 APIs
728
+
729
+ **Backward Compatibility:**
730
+ - ✅ All v3.2.x code works without changes
731
+ - ✅ Database schema unchanged
732
+ - ✅ File watcher behavior unchanged
733
+ - ✅ No breaking changes
734
+
735
+ **Performance:**
736
+ - Creating task with 3 files: 4 MCP calls → 1 MCP call (75% reduction)
737
+ - Token usage: ~1,400 → ~900 (35% reduction)
738
+ - Batch file registration: More efficient watcher updates
739
+
740
+ **Testing:**
741
+ - All 19 existing tests pass
742
+ - TypeScript compilation successful
743
+ - No regression in v3.2.x functionality
744
+
745
+ ### Migration Path
746
+
747
+ **Option 1: Gradual Migration (Recommended)**
748
+ - Continue using existing v3.2.x code
749
+ - Use v3.4.1 API for new tasks
750
+ - Both APIs work simultaneously
751
+
752
+ **Option 2: Full Migration**
753
+ - Update all task creation to use `watch_files` parameter
754
+ - Replace `task.link(file)` with `watch_files` action
755
+ - See `docs/MIGRATION_v3.3.md` for detailed steps
756
+
757
+ **Timeline:**
758
+ - v3.4.1: Deprecation warning only
759
+ - v3.4.x-v3.5.x: Backward compatibility maintained
760
+ - v4.0.0: `task.link(file)` may be removed (planned)
761
+
762
+ ### Files Changed
763
+
764
+ **New Files:**
765
+ - `src/config/types.ts` - TypeScript interfaces for TOML config (88 lines)
766
+ - `src/config/loader.ts` - Config loading, flattening, validation (173 lines)
767
+ - `.sqlew/config.toml.example` - Comprehensive example config with documentation (87 lines)
768
+ - `src/watcher/gitignore-parser.ts` - GitIgnore parsing module
769
+ - `docs/MIGRATION_v3.3.md` - Migration guide for v3.2.x → v3.4.1
770
+ - `docs/CONFIGURATION.md` - Complete configuration guide (800+ lines)
771
+
772
+ **Modified Code Files:**
773
+ - `src/index.ts` - Added missing MCP router actions, watch_files parameter schema
774
+ - `src/tools/tasks.ts` - watch_files parameter/action, deprecation, auto-archive integration
775
+ - `src/watcher/file-watcher.ts` - GitIgnore support integration
776
+ - `src/watcher/index.ts` - Updated watcher initialization
777
+ - `src/database.ts` - Config file loading, validation, auto-archive on startup
778
+ - `src/constants.ts` - Added AUTO_ARCHIVE_DONE_DAYS config key
779
+ - `src/utils/retention.ts` - Added calculateTaskArchiveCutoff function
780
+ - `src/utils/task-stale-detection.ts` - Added autoArchiveOldDoneTasks function, TASK_STATUS constants
781
+ - `assets/schema.sql` - Added auto_archive_done_days default config
782
+ - `package.json` - Added smol-toml dependency, version bump
783
+
784
+ **Modified Documentation Files:**
785
+ - `docs/AUTO_FILE_TRACKING.md` - Restructured with Quick Start, v3.4.1 API examples
786
+ - `docs/TOOL_REFERENCE.md` - Updated task tool parameter tables and examples
787
+ - `docs/TASK_OVERVIEW.md` - Auto-archive documentation
788
+ - `docs/TASK_ACTIONS.md` - Auto-archive behavior in list/move actions
789
+ - `docs/ARCHITECTURE.md` - Configuration system architecture
790
+ - `README.md` - Configuration section, auto-stale updates, CONFIGURATION.md reference
791
+ - `CHANGELOG.md` - This comprehensive v3.4.1 changelog entry
792
+
793
+ **Total Lines Changed:**
794
+ - New Code: ~348 lines (config system)
795
+ - Modified Code: ~200 lines (auto-archive + watch_files + gitignore)
796
+ - New Documentation: ~800 lines (CONFIGURATION.md)
797
+ - Modified Documentation: ~1,200 lines (multiple files updated by subagents)
798
+
799
+ ## [3.2.6] - 2025-10-21
800
+
801
+ ### Fixed
802
+
803
+ #### Critical Bug Fix: Task Creation with Missing Agent
804
+ - **Issue**: "NOT NULL constraint failed: t_activity_log.agent_id" error when creating tasks
805
+ - **Root Cause**: `createTaskInternal()` function allowed NULL `created_by_agent_id`, but activity log trigger required valid agent_id
806
+ - **Bug**: When task created without `created_by_agent` parameter, `created_by_agent_id` was NULL, causing trigger to fail
807
+ - **Impact**: All task creations without explicit `created_by_agent` parameter would fail
808
+ - **Solution**: Default to 'system' agent when no `created_by_agent` provided, ensuring valid agent_id always exists
809
+ - **File**: `src/tools/tasks.ts:116-119`
810
+
811
+ ### Technical Details
812
+ - Activity log trigger `trg_log_task_create` requires non-NULL agent_id
813
+ - Trigger uses COALESCE to fall back to 'system' agent, but 'system' may not exist on first use
814
+ - If both `created_by_agent_id` is NULL AND no 'system' agent exists, trigger fails with NOT NULL constraint
815
+ - Fix: Always create/use 'system' agent as default when no `created_by_agent` provided
816
+ - Now all tasks have a valid creator agent (explicit or 'system' default)
817
+ - Task creation now works with or without `created_by_agent` parameter
818
+ - All tests pass (19/19)
819
+ - Backward compatible
820
+
8
821
  ## [3.2.5] - 2025-10-21
9
822
 
10
823
  ### Fixed
@@ -29,19 +842,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
29
842
  - **After**: `key is required` (clear validation message)
30
843
 
31
844
  ### Technical Details
32
-
33
- **Constraint Bug:**
34
- - Schema-code mismatch - code was referencing non-existent columns
35
- - `m_constraint_categories` has `id` and `name` columns
36
- - Applied standard `INSERT OR IGNORE` + `SELECT` pattern consistent with other helper functions
37
-
38
- **Validator Bug:**
39
- - TypeScript type system doesn't prevent undefined at runtime for parameters from JSON/user input
40
- - Added defensive checks: undefined, null, type validation, then trim
41
- - Now provides helpful error messages for all invalid parameter scenarios
42
- - All validation errors are now user-friendly instead of JavaScript runtime errors
43
-
44
- **Testing:**
845
+ - Schema-code mismatch fixed in constraint creation
846
+ - TypeScript runtime safety added to validator
45
847
  - Both fixes verified with comprehensive test scripts
46
848
  - All existing tests pass (19/19)
47
849
  - Backward compatible - only fixes broken functionality