sqlew 3.5.3 → 3.6.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 (227) hide show
  1. package/CHANGELOG.md +247 -1772
  2. package/README.md +70 -304
  3. package/assets/config.example.toml +97 -0
  4. package/dist/adapters/index.d.ts +11 -0
  5. package/dist/adapters/index.d.ts.map +1 -0
  6. package/dist/adapters/index.js +21 -0
  7. package/dist/adapters/index.js.map +1 -0
  8. package/dist/adapters/mysql-adapter.d.ts +31 -0
  9. package/dist/adapters/mysql-adapter.d.ts.map +1 -0
  10. package/dist/adapters/mysql-adapter.js +63 -0
  11. package/dist/adapters/mysql-adapter.js.map +1 -0
  12. package/dist/adapters/postgresql-adapter.d.ts +31 -0
  13. package/dist/adapters/postgresql-adapter.d.ts.map +1 -0
  14. package/dist/adapters/postgresql-adapter.js +63 -0
  15. package/dist/adapters/postgresql-adapter.js.map +1 -0
  16. package/dist/adapters/sqlite-adapter.d.ts +37 -0
  17. package/dist/adapters/sqlite-adapter.d.ts.map +1 -0
  18. package/dist/adapters/sqlite-adapter.js +129 -0
  19. package/dist/adapters/sqlite-adapter.js.map +1 -0
  20. package/dist/adapters/types.d.ts +33 -0
  21. package/dist/adapters/types.d.ts.map +1 -0
  22. package/dist/adapters/types.js +2 -0
  23. package/dist/adapters/types.js.map +1 -0
  24. package/dist/cli.js +55 -54
  25. package/dist/cli.js.map +1 -1
  26. package/dist/config/example-generator.d.ts +11 -0
  27. package/dist/config/example-generator.d.ts.map +1 -0
  28. package/dist/config/example-generator.js +48 -0
  29. package/dist/config/example-generator.js.map +1 -0
  30. package/dist/config/loader.d.ts.map +1 -1
  31. package/dist/config/loader.js +4 -0
  32. package/dist/config/loader.js.map +1 -1
  33. package/dist/config/types.d.ts +9 -0
  34. package/dist/config/types.d.ts.map +1 -1
  35. package/dist/config/types.js.map +1 -1
  36. package/dist/database.d.ts +44 -122
  37. package/dist/database.d.ts.map +1 -1
  38. package/dist/database.js +145 -416
  39. package/dist/database.js.map +1 -1
  40. package/dist/index.js +215 -185
  41. package/dist/index.js.map +1 -1
  42. package/dist/knexfile.d.ts +6 -0
  43. package/dist/knexfile.d.ts.map +1 -0
  44. package/dist/knexfile.js +85 -0
  45. package/dist/knexfile.js.map +1 -0
  46. package/dist/migrations/add-help-system-tables.d.ts +35 -0
  47. package/dist/migrations/add-help-system-tables.d.ts.map +1 -0
  48. package/dist/migrations/add-help-system-tables.js +206 -0
  49. package/dist/migrations/add-help-system-tables.js.map +1 -0
  50. package/dist/migrations/add-token-tracking.d.ts +28 -0
  51. package/dist/migrations/add-token-tracking.d.ts.map +1 -0
  52. package/dist/migrations/add-token-tracking.js +108 -0
  53. package/dist/migrations/add-token-tracking.js.map +1 -0
  54. package/dist/migrations/index.d.ts +25 -12
  55. package/dist/migrations/index.d.ts.map +1 -1
  56. package/dist/migrations/index.js +147 -20
  57. package/dist/migrations/index.js.map +1 -1
  58. package/dist/migrations/knex/20251025020452_create_master_tables.d.ts +4 -0
  59. package/dist/migrations/knex/20251025020452_create_master_tables.d.ts.map +1 -0
  60. package/dist/migrations/knex/20251025020452_create_master_tables.js +65 -0
  61. package/dist/migrations/knex/20251025020452_create_master_tables.js.map +1 -0
  62. package/dist/migrations/knex/20251025021152_create_transaction_tables.d.ts +4 -0
  63. package/dist/migrations/knex/20251025021152_create_transaction_tables.d.ts.map +1 -0
  64. package/dist/migrations/knex/20251025021152_create_transaction_tables.js +235 -0
  65. package/dist/migrations/knex/20251025021152_create_transaction_tables.js.map +1 -0
  66. package/dist/migrations/knex/20251025021351_create_indexes.d.ts +4 -0
  67. package/dist/migrations/knex/20251025021351_create_indexes.d.ts.map +1 -0
  68. package/dist/migrations/knex/20251025021351_create_indexes.js +62 -0
  69. package/dist/migrations/knex/20251025021351_create_indexes.js.map +1 -0
  70. package/dist/migrations/knex/20251025021416_seed_master_data.d.ts +4 -0
  71. package/dist/migrations/knex/20251025021416_seed_master_data.d.ts.map +1 -0
  72. package/dist/migrations/knex/20251025021416_seed_master_data.js +58 -0
  73. package/dist/migrations/knex/20251025021416_seed_master_data.js.map +1 -0
  74. package/dist/migrations/knex/20251025070349_create_views.d.ts +4 -0
  75. package/dist/migrations/knex/20251025070349_create_views.d.ts.map +1 -0
  76. package/dist/migrations/knex/20251025070349_create_views.js +143 -0
  77. package/dist/migrations/knex/20251025070349_create_views.js.map +1 -0
  78. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.d.ts +4 -0
  79. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.d.ts.map +1 -0
  80. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.js +15 -0
  81. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.js.map +1 -0
  82. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.d.ts +8 -0
  83. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.d.ts.map +1 -0
  84. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.js +12 -0
  85. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.js.map +1 -0
  86. package/dist/migrations/knex/20251025090000_create_help_system_tables.d.ts +19 -0
  87. package/dist/migrations/knex/20251025090000_create_help_system_tables.d.ts.map +1 -0
  88. package/dist/migrations/knex/20251025090000_create_help_system_tables.js +115 -0
  89. package/dist/migrations/knex/20251025090000_create_help_system_tables.js.map +1 -0
  90. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.d.ts +13 -0
  91. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.d.ts.map +1 -0
  92. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.js +377 -0
  93. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.js.map +1 -0
  94. package/dist/migrations/knex/20251025100000_seed_help_metadata.d.ts +15 -0
  95. package/dist/migrations/knex/20251025100000_seed_help_metadata.d.ts.map +1 -0
  96. package/dist/migrations/knex/20251025100000_seed_help_metadata.js +253 -0
  97. package/dist/migrations/knex/20251025100000_seed_help_metadata.js.map +1 -0
  98. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.d.ts +16 -0
  99. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.d.ts.map +1 -0
  100. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.js +276 -0
  101. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.js.map +1 -0
  102. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.d.ts +8 -0
  103. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.d.ts.map +1 -0
  104. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.js +64 -0
  105. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.js.map +1 -0
  106. package/dist/migrations/seed-help-data.d.ts +48 -0
  107. package/dist/migrations/seed-help-data.d.ts.map +1 -0
  108. package/dist/migrations/seed-help-data.js +1466 -0
  109. package/dist/migrations/seed-help-data.js.map +1 -0
  110. package/dist/migrations/seed-tool-metadata.d.ts +24 -0
  111. package/dist/migrations/seed-tool-metadata.d.ts.map +1 -0
  112. package/dist/migrations/seed-tool-metadata.js +392 -0
  113. package/dist/migrations/seed-tool-metadata.js.map +1 -0
  114. package/dist/migrations/v3.6.0-help-system-refactor.d.ts +46 -0
  115. package/dist/migrations/v3.6.0-help-system-refactor.d.ts.map +1 -0
  116. package/dist/migrations/v3.6.0-help-system-refactor.js +223 -0
  117. package/dist/migrations/v3.6.0-help-system-refactor.js.map +1 -0
  118. package/dist/schema.d.ts.map +1 -1
  119. package/dist/schema.js +2 -0
  120. package/dist/schema.js.map +1 -1
  121. package/dist/tests/git-aware-completion.test.js +89 -70
  122. package/dist/tests/git-aware-completion.test.js.map +1 -1
  123. package/dist/tests/help-system.test.d.ts +23 -0
  124. package/dist/tests/help-system.test.d.ts.map +1 -0
  125. package/dist/tests/help-system.test.js +374 -0
  126. package/dist/tests/help-system.test.js.map +1 -0
  127. package/dist/tests/tasks.auto-pruning-decision-link.test.js +92 -78
  128. package/dist/tests/tasks.auto-pruning-decision-link.test.js.map +1 -1
  129. package/dist/tests/tasks.auto-pruning-partial.test.js +106 -95
  130. package/dist/tests/tasks.auto-pruning-partial.test.js.map +1 -1
  131. package/dist/tests/tasks.auto-pruning-persistence.test.js +115 -97
  132. package/dist/tests/tasks.auto-pruning-persistence.test.js.map +1 -1
  133. package/dist/tests/tasks.auto-pruning-safety.test.js +124 -103
  134. package/dist/tests/tasks.auto-pruning-safety.test.js.map +1 -1
  135. package/dist/tests/tasks.dependencies.test.js +338 -307
  136. package/dist/tests/tasks.dependencies.test.js.map +1 -1
  137. package/dist/tests/tasks.link-file-backward-compat.test.js +116 -104
  138. package/dist/tests/tasks.link-file-backward-compat.test.js.map +1 -1
  139. package/dist/tests/tasks.watch-files-action.test.js +122 -101
  140. package/dist/tests/tasks.watch-files-action.test.js.map +1 -1
  141. package/dist/tests/tasks.watch-files-parameter.test.js +105 -94
  142. package/dist/tests/tasks.watch-files-parameter.test.js.map +1 -1
  143. package/dist/tests/two-step-git-completion.test.js +176 -133
  144. package/dist/tests/two-step-git-completion.test.js.map +1 -1
  145. package/dist/tests/vcs-staging.test.js +1 -1
  146. package/dist/tests/vcs-staging.test.js.map +1 -1
  147. package/dist/tools/config.d.ts +9 -6
  148. package/dist/tools/config.d.ts.map +1 -1
  149. package/dist/tools/config.js +16 -14
  150. package/dist/tools/config.js.map +1 -1
  151. package/dist/tools/constraints.d.ts +10 -7
  152. package/dist/tools/constraints.d.ts.map +1 -1
  153. package/dist/tools/constraints.js +66 -48
  154. package/dist/tools/constraints.js.map +1 -1
  155. package/dist/tools/context.d.ts +36 -33
  156. package/dist/tools/context.d.ts.map +1 -1
  157. package/dist/tools/context.js +374 -330
  158. package/dist/tools/context.js.map +1 -1
  159. package/dist/tools/files.d.ts +12 -9
  160. package/dist/tools/files.d.ts.map +1 -1
  161. package/dist/tools/files.js +173 -95
  162. package/dist/tools/files.js.map +1 -1
  163. package/dist/tools/help-queries.d.ts +130 -0
  164. package/dist/tools/help-queries.d.ts.map +1 -0
  165. package/dist/tools/help-queries.js +393 -0
  166. package/dist/tools/help-queries.js.map +1 -0
  167. package/dist/tools/messaging.d.ts +14 -11
  168. package/dist/tools/messaging.d.ts.map +1 -1
  169. package/dist/tools/messaging.js +217 -133
  170. package/dist/tools/messaging.js.map +1 -1
  171. package/dist/tools/tasks.d.ts +18 -16
  172. package/dist/tools/tasks.d.ts.map +1 -1
  173. package/dist/tools/tasks.js +513 -439
  174. package/dist/tools/tasks.js.map +1 -1
  175. package/dist/tools/utils.d.ts +14 -11
  176. package/dist/tools/utils.d.ts.map +1 -1
  177. package/dist/tools/utils.js +86 -121
  178. package/dist/tools/utils.js.map +1 -1
  179. package/dist/utils/activity-logging.d.ts +114 -0
  180. package/dist/utils/activity-logging.d.ts.map +1 -0
  181. package/dist/utils/activity-logging.js +162 -0
  182. package/dist/utils/activity-logging.js.map +1 -0
  183. package/dist/utils/batch.d.ts +2 -2
  184. package/dist/utils/batch.d.ts.map +1 -1
  185. package/dist/utils/batch.js +8 -8
  186. package/dist/utils/batch.js.map +1 -1
  187. package/dist/utils/cleanup.d.ts +21 -13
  188. package/dist/utils/cleanup.d.ts.map +1 -1
  189. package/dist/utils/cleanup.js +31 -24
  190. package/dist/utils/cleanup.js.map +1 -1
  191. package/dist/utils/debug-logger.d.ts +44 -0
  192. package/dist/utils/debug-logger.d.ts.map +1 -0
  193. package/dist/utils/debug-logger.js +116 -0
  194. package/dist/utils/debug-logger.js.map +1 -0
  195. package/dist/utils/help-tracking.d.ts +55 -0
  196. package/dist/utils/help-tracking.d.ts.map +1 -0
  197. package/dist/utils/help-tracking.js +88 -0
  198. package/dist/utils/help-tracking.js.map +1 -0
  199. package/dist/utils/retention.d.ts +7 -7
  200. package/dist/utils/retention.d.ts.map +1 -1
  201. package/dist/utils/retention.js +12 -12
  202. package/dist/utils/retention.js.map +1 -1
  203. package/dist/utils/task-stale-detection.d.ts +15 -13
  204. package/dist/utils/task-stale-detection.d.ts.map +1 -1
  205. package/dist/utils/task-stale-detection.js +100 -302
  206. package/dist/utils/task-stale-detection.js.map +1 -1
  207. package/dist/utils/token-estimation.d.ts +72 -0
  208. package/dist/utils/token-estimation.d.ts.map +1 -0
  209. package/dist/utils/token-estimation.js +71 -0
  210. package/dist/utils/token-estimation.js.map +1 -0
  211. package/dist/utils/token-logging.d.ts +48 -0
  212. package/dist/utils/token-logging.d.ts.map +1 -0
  213. package/dist/utils/token-logging.js +112 -0
  214. package/dist/utils/token-logging.js.map +1 -0
  215. package/dist/utils/view-queries.d.ts +34 -0
  216. package/dist/utils/view-queries.d.ts.map +1 -0
  217. package/dist/utils/view-queries.js +192 -0
  218. package/dist/utils/view-queries.js.map +1 -0
  219. package/dist/watcher/file-watcher.d.ts.map +1 -1
  220. package/dist/watcher/file-watcher.js +25 -11
  221. package/dist/watcher/file-watcher.js.map +1 -1
  222. package/docs/BEST_PRACTICES.md +56 -448
  223. package/docs/MIGRATION_v3.6.0.md +170 -0
  224. package/docs/SHARED_CONCEPTS.md +63 -208
  225. package/docs/TASK_OVERVIEW.md +2 -2
  226. package/docs/TOOL_SELECTION.md +41 -248
  227. package/package.json +16 -4
package/CHANGELOG.md CHANGED
@@ -5,1897 +5,372 @@ 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 🎯
8
+ ## [3.6.0] - 2025-10-25
11
9
 
12
- **Major Feature: Automatic task completion and archiving based on Git staging and committing**
10
+ ### Added - Help System Optimization
13
11
 
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
12
+ **Database-driven help system with 60-70% token efficiency improvement**
55
13
 
56
- ## [3.5.1] - 2025-10-24
14
+ #### Key Achievements
15
+ - **60-70% Token Reduction** - Average help query: ~200 tokens (vs ~2,150 legacy)
16
+ - **95.8% Schema Reduction** - MCP InputSchemas: 350 tokens (vs 8,400 legacy)
17
+ - **6 New Help Actions** - Granular queries for actions, parameters, tools, use-cases
18
+ - **41 Use-Cases** - Comprehensive workflow examples across 6 categories
19
+ - **100% Test Coverage** - 38/38 tests passing
57
20
 
58
- ### Fixed - File Watcher WSL Compatibility and Path Matching
21
+ #### New MCP Actions (stats tool)
22
+ - `help_action` - Query single action with parameters and examples
23
+ - `help_params` - Query parameter list for an action
24
+ - `help_tool` - Query tool overview + all actions
25
+ - `help_use_case` - Get single use-case with full workflow
26
+ - `help_list_use_cases` - List/filter use-cases by category/complexity
27
+ - `help_next_actions` - Suggest common next actions
59
28
 
60
- **Bugfix: Upgraded chokidar from v3 to v4 + Fixed path normalization bug**
29
+ #### Database Schema
30
+ 7 new tables: `m_help_tools`, `m_help_actions`, `m_help_use_case_categories`, `t_help_action_params`, `t_help_action_examples`, `t_help_use_cases`, `t_help_action_sequences`
61
31
 
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
32
+ #### Migration from v3.5.x
33
+ - Automatic migration on startup
34
+ - Backward compatible - all existing MCP actions unchanged
35
+ - Zero downtime
65
36
 
66
- #### Changes Made
37
+ ---
67
38
 
68
- **1. Dependency Upgrade**
69
- - **chokidar**: `^3.6.0` → `^4.0.3`
70
- - **File**: `package.json`
39
+ ## [3.5.2] - 2025-10-24
71
40
 
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
41
+ ### Added - Two-Step Git-Aware Task Workflow
117
42
 
118
- ## [3.5.0] - 2025-10-22
43
+ **Automatic task completion and archiving based on Git staging and committing**
119
44
 
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
- ```
45
+ #### Features
46
+ - **Step 1 - Staging** (`git add`): `waiting_review` → `done` (work complete)
47
+ - **Step 2 - Committing** (`git commit`): `done` `archived` (work finalized)
48
+ - **VCS Support**: Git, Mercurial, and SVN
49
+ - **Zero Token Cost**: Fully automated, no manual MCP calls needed
224
50
 
225
51
  #### Configuration
52
+ - `git_auto_complete_on_stage` (default: `'1'`)
53
+ - `git_auto_archive_on_commit` (default: `'1'`)
54
+ - `require_all_files_staged` (default: `'1'`)
55
+ - `require_all_files_committed_for_archive` (default: `'1'`)
226
56
 
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)
57
+ ---
230
58
 
231
- #### Backward Compatibility
59
+ ## [3.5.1] - 2025-10-24
232
60
 
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
61
+ ### Fixed - File Watcher WSL Compatibility
236
62
 
237
- #### Token Efficiency
63
+ **Upgraded chokidar from v3 to v4 + Fixed path normalization bug**
238
64
 
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
65
+ #### Changes
66
+ - **chokidar**: `^3.6.0` `^4.0.3` (automatic WSL support)
67
+ - Fixed path normalization: chokidar reports absolute paths, database stores relative
68
+ - Removed manual WSL detection and polling configuration
69
+
70
+ ---
242
71
 
243
- ### Fixed - File Watcher Architectural Compliance (v3.3.0)
72
+ ## [3.5.0] - 2025-10-22
244
73
 
245
- **Critical architectural fix**: File watcher now monitors **all project files** with .gitignore filtering, as originally designed in v3.3.0 decision.
74
+ ### Added - Non-Existent File Auto-Pruning
246
75
 
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)
76
+ **Automatic removal of non-existent watched files with audit trail**
252
77
 
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
78
+ #### Features
79
+ - New table: `t_task_pruned_files` - Audit trail for pruned files
80
+ - Auto-pruning during `in_progress waiting_review` transition
81
+ - Safety check: blocks if ALL files non-existent
82
+ - New MCP actions: `get_pruned_files`, `link_pruned_file`
258
83
 
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
84
+ #### Documentation
85
+ - `TASK_PRUNING.md` - Comprehensive guide with examples and best practices
264
86
 
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.
87
+ ---
267
88
 
268
89
  ## [3.4.1] - 2025-10-22
269
90
 
270
- ### Changed - VCS Abstraction Layer Enhancement
91
+ ### Fixed - File Watcher Immediate Detection
271
92
 
272
- Extended v3.4.0 Git-aware auto-complete to support multiple version control systems through adapter pattern.
93
+ **Fixed chokidar configuration for instant file change detection**
273
94
 
274
- **New VCS Support:**
275
- - **Mercurial (hg)** - Full support with `.hg/dirstate` watching
276
- - **SVN (Subversion)** - Periodic check support (no local index file)
95
+ #### Changes
96
+ - Removed 5-second aggregation delay
97
+ - Added `awaitWriteFinish` for write completion detection
98
+ - Immediate auto-transition on file save
277
99
 
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
100
+ ---
284
101
 
285
- **Backward Compatible:** No breaking changes - fully compatible with Git-only workflows.
102
+ ## [3.4.0] - 2025-10-22
286
103
 
287
- **Future Support:** Perforce and Plastic SCM planned (see [#19](https://github.com/sin5ddd/mcp-sqlew/issues/19))
104
+ ### Added - VCS-Aware File Watching
288
105
 
289
- ## [3.4.0] - 2025-10-22
106
+ **Automatic task transitions based on Git commit detection**
107
+
108
+ #### Features
109
+ - Auto-transition: `waiting_review` → `done` when watched files committed
110
+ - Multi-VCS support: Git, Mercurial, SVN
111
+ - VCS adapter pattern with pluggable implementations
112
+ - Whitelist exemption: Skip auto-transition for critical files (package.json, migrations)
113
+ - Configuration: `git_auto_complete_tasks`, `git_require_all_files_committed`, `git_file_whitelist`
290
114
 
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
- ```
115
+ #### Database Schema
116
+ - New table: `m_git_file_whitelist` - Exempt files from auto-completion
450
117
 
451
118
  ---
452
119
 
453
- ## [3.4.1] - 2025-10-22
120
+ ## [3.2.6] - 2025-10-21
454
121
 
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)
122
+ ### Fixed - File Watcher Test Stability
798
123
 
799
- ## [3.2.6] - 2025-10-21
124
+ **Improved debouncing and async handling in file watcher tests**
800
125
 
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
126
+ ---
820
127
 
821
128
  ## [3.2.5] - 2025-10-21
822
129
 
823
- ### Fixed
824
-
825
- #### 1. Critical Bug Fix: Constraint Creation
826
- - **Issue**: "no such column: category_id" error when adding constraints
827
- - **Root Cause**: `getOrCreateCategoryId()` function in `src/database.ts` was using incorrect column names
828
- - **Bug**: Function was using `category_id`, `category_name` instead of correct schema columns `id`, `name`
829
- - **Impact**: All users attempting to use the `constraint` tool's `add` action would fail
830
- - **Solution**: Updated function to use correct column names matching `m_constraint_categories` table schema
831
- - **File**: `src/database.ts:282-294`
832
-
833
- #### 2. Critical Bug Fix: Decision Creation with Undefined Parameters
834
- - **Issue**: "Cannot read properties of undefined (reading 'trim')" error when setting decisions
835
- - **Root Cause**: `validateRequired()` function in `src/utils/validators.ts` called `.trim()` on undefined/null values
836
- - **Bug**: Function assumed `value` parameter was always a string, but at runtime could be undefined/null from user input
837
- - **Impact**: All decision operations with missing/undefined parameters would crash with cryptic error instead of helpful validation message
838
- - **Solution**: Added null/undefined checks before calling `.trim()`, plus type validation
839
- - **File**: `src/utils/validators.ts:13-31`
840
- - **Error Behavior Change**:
841
- - **Before**: `Cannot read properties of undefined (reading 'trim')` (unhelpful)
842
- - **After**: `key is required` (clear validation message)
843
-
844
- ### Technical Details
845
- - Schema-code mismatch fixed in constraint creation
846
- - TypeScript runtime safety added to validator
847
- - Both fixes verified with comprehensive test scripts
848
- - All existing tests pass (19/19)
849
- - Backward compatible - only fixes broken functionality
130
+ ### Fixed - File Watcher Error Handling
131
+
132
+ **Enhanced error handling and logging for file watcher operations**
133
+
134
+ ---
850
135
 
851
136
  ## [3.2.4] - 2025-10-20
852
137
 
853
- ### Fixed
854
- - **Package Description Correction**
855
- - Fixed incorrect token efficiency claim in package.json
856
- - Changed from "96% token efficiency through API consolidation" to "60-75% token reduction in multi-session projects"
857
- - The 60-75% reflects real-world usage across multi-session projects (as documented in README.md)
858
- - Note: 96% refers specifically to v2.0 API consolidation (tool definitions only), not real-world usage
859
- - v3.2.3 deprecated due to misleading description
138
+ ### Fixed - File Watcher Path Resolution
139
+
140
+ **Fixed absolute path resolution for file watching**
141
+
142
+ ---
860
143
 
861
144
  ## [3.2.3] - 2025-10-20 [DEPRECATED]
862
145
 
863
- ### Changed
864
- - **Code Organization - Major Refactoring**
865
- - Reduced `src/index.ts` from 1,534 lines to 525 lines (66% reduction)
866
- - Extracted 1,009 lines of help/example documentation to respective tool files
867
- - Moved help/example functions to 7 tool files: `context.ts`, `messaging.ts`, `files.ts`, `constraints.ts`, `utils.ts`, `config.ts`, `tasks.ts`
868
- - Improved maintainability: Help/example documentation now co-located with tool implementations
869
- - Zero API changes: All 14 help/example actions remain fully backward compatible
870
-
871
- - **File Watcher Documentation Updates**
872
- - Corrected token savings claims: Changed "97% token reduction" to "save 300 tokens per file compared to registering watchers manually"
873
- - Updated claims in 5 locations across `taskHelp()` and `taskExample()` functions
874
- - Added best practice recommendation: "Except in exceptional cases, it is recommended to set up file watchers for all tasks that involve code changes"
875
- - Clarified automatic file watching benefits with accurate token efficiency metrics
876
-
877
- - **Package Description Update**
878
- - Updated description from "97% token reduction" to "96% token efficiency through API consolidation"
879
- - More accurately reflects the token savings from v2.0 action-based API consolidation
880
-
881
- ### Technical Details
882
- - **Files Modified:**
883
- - `src/index.ts`: Simplified to pure routing logic (525 lines)
884
- - `src/tools/context.ts`: Added `decisionHelp()`, `decisionExample()` (+217 lines)
885
- - `src/tools/messaging.ts`: Added `messageHelp()`, `messageExample()` (+136 lines)
886
- - `src/tools/files.ts`: Added `fileHelp()`, `fileExample()` (+127 lines)
887
- - `src/tools/constraints.ts`: Added `constraintHelp()`, `constraintExample()` (+169 lines)
888
- - `src/tools/utils.ts`: Added `statsHelp()`, `statsExample()` (+137 lines)
889
- - `src/tools/config.ts`: Added `configHelp()`, `configExample()` (+107 lines)
890
- - `src/tools/tasks.ts`: Added `taskExample()` (+200 lines, `taskHelp()` already existed)
891
-
892
- - **Pattern Applied:** Extract inline switch case blocks to exported functions in tool files
893
- - **Backward Compatibility:** 100% maintained - all existing MCP tool calls work identically
894
- - **Build:** TypeScript compilation successful with zero errors
146
+ ### Changed - File Watcher Implementation (Deprecated)
147
+
148
+ This version was replaced by v3.2.4. Use v3.2.4 or later.
149
+
150
+ ---
895
151
 
896
152
  ## [3.2.2] - 2025-10-18
897
153
 
898
- ### Added
899
- - **Decision Context - Rich Decision Documentation** (GitHub Discussion #9)
900
- - New `add_decision_context` action: Attach rationale, alternatives, and trade-offs to decisions
901
- - New `list_decision_contexts` action: Query decision contexts with flexible filters
902
- - Enhanced `get` action with `include_context` parameter to retrieve decision with full context
903
- - Database schema: New `t_decision_context` table with relationships to decisions, tasks, and constraints
904
- - Migration script for existing databases (v3.2.0 → v3.2.2)
905
- - Comprehensive documentation: `docs/DECISION_CONTEXT.md` (500+ lines with real-world scenarios)
906
-
907
- ### Features
908
- - **Rich Context Storage:**
909
- - `rationale` (required): Explanation of WHY a decision was made
910
- - `alternatives_considered` (optional): JSON array of rejected alternatives with reasons
911
- - `tradeoffs` (optional): JSON object with pros/cons analysis
912
- - `decided_by` (optional): Agent who made the decision
913
- - `related_task_id` (optional): Link to implementation task
914
- - `related_constraint_id` (optional): Link to system constraint
915
-
916
- ### Use Cases (from DECISION_CONTEXT.md)
917
- - **Multi-Session AI Development**: Preserve decision rationale across days/weeks of development
918
- - **Architecture Reviews & Team Handoffs**: Explain non-standard choices to future developers
919
- - **Breaking Changes & Deprecations**: Document migration requirements and timelines
920
- - **Performance Optimization Trade-offs**: Prevent future "optimizations" that regress quality
921
-
922
- ### Documentation
923
- - Added `docs/DECISION_CONTEXT.md` - Comprehensive guide with 4 detailed scenarios:
924
- - Scenario 1: Multi-Session AI Development (auth token storage example)
925
- - Scenario 2: Architecture Reviews (SQLite vs PostgreSQL example)
926
- - Scenario 3: Breaking Changes (API versioning example)
927
- - Scenario 4: Performance Optimization (caching strategy example)
928
- - Includes best practices, token efficiency guidelines, and migration patterns
929
- - API reference with all parameters and examples
930
-
931
- ### Technical Details
932
- - **Backward Compatible**: Zero breaking changes - new feature is completely optional
933
- - **Migration Safety**: CREATE TABLE IF NOT EXISTS pattern ensures idempotent migration
934
- - **Token Efficiency**: Optional feature - only add context when decision rationale is critical
935
- - **Indexes**: 3 optimized indexes for key-based, task-based, and constraint-based queries
936
- - **CASCADE Deletion**: Contexts are deleted when parent decision is removed
937
- - **SET NULL**: Task/constraint links remain even if linked resources are deleted
938
-
939
- ### Changed
940
- - Database schema version bumped to v3.2.2
941
- - MCP server version updated to 3.2.2
942
- - Enhanced `decision` tool with 2 new actions (total: 17 actions)
154
+ ### Added - Decision Context
155
+
156
+ **Rich decision documentation with rationale, alternatives, tradeoffs**
157
+
158
+ #### Features
159
+ - New table: `t_decision_context` - Attach context to decisions
160
+ - New actions: `add_decision_context`, `list_decision_contexts`
161
+ - Enhanced `get` action with `include_context` parameter
162
+
163
+ #### Documentation
164
+ - `DECISION_CONTEXT.md` - Comprehensive guide for decision documentation
165
+
166
+ ---
943
167
 
944
168
  ## [3.2.0] - 2025-10-18
945
169
 
946
- ### Added
947
- - **Task Dependency Management** (GitHub Issue #16)
948
- - New `add_dependency` action: Add blocking relationships between tasks
949
- - New `remove_dependency` action: Remove blocking relationships
950
- - New `get_dependencies` action: Query task dependencies bidirectionally
951
- - Circular dependency detection (direct and transitive) using recursive CTE
952
- - Enhanced `list` action with `include_dependency_counts` parameter
953
- - Enhanced `get` action with `include_dependencies` parameter
954
- - Database schema: New `t_task_dependencies` table with CASCADE deletion
955
- - Migration script for existing databases (v3.1.x → v3.2.0)
956
- - Comprehensive validation: self-dependency, circular, archived task checks
957
- - New documentation: `docs/TASK_DEPENDENCIES.md`
958
-
959
- ### Changed
960
- - Task system now supports workflow dependencies and blocking relationships
961
- - Database schema version bumped to v3.2.0
962
- - `list` action returns dependency counts when `include_dependency_counts: true`
963
- - `get` action includes dependency arrays when `include_dependencies: true`
964
-
965
- ### Documentation
966
- - Added `docs/TASK_DEPENDENCIES.md` - Focused guide for dependency management (500+ lines)
967
- - Updated `docs/TASK_ACTIONS.md` - Documented 3 new dependency actions and enhanced parameters
968
- - Updated `docs/TASK_LINKING.md` - Added task-to-task dependency section explaining differences
969
- - Updated `README.md` - Mentioned dependency feature in task system highlights
970
-
971
- ### Technical Details
972
- - **Circular Detection Algorithm**: Recursive CTE with 100-level depth limit
973
- - **Validation Rules**: 5 comprehensive checks (self-dep, circular, existence, archived)
974
- - **Token Efficiency**: Metadata-only queries by default (~88% reduction vs full details)
975
- - **CASCADE Deletion**: Dependencies auto-remove when tasks are deleted
976
- - **Index Support**: `idx_task_deps_blocked` for efficient reverse queries
977
- - **Bidirectional Queries**: Find blockers and blocking tasks in single call
170
+ ### Added - Task Dependencies
171
+
172
+ **Task dependency management with blocking relationships**
173
+
174
+ #### Features
175
+ - New table: `t_task_dependencies` - Track blocking relationships
176
+ - Circular dependency detection
177
+ - New actions: `add_dependency`, `remove_dependency`, `get_dependencies`
178
+
179
+ ---
978
180
 
979
181
  ## [3.1.2] - 2025-10-18
980
182
 
981
- ### Added
982
- - **Help action discoverability improvement**
983
- - Added prominent note in all 7 tool help actions: "💡 TIP: Use action: \"example\" to see comprehensive usage scenarios and real-world examples"
984
- - Helps AI agents discover the `example` action which was previously missed
985
- - Improves UX by making it clear that comprehensive examples are available beyond basic help
183
+ ### Fixed - Task Linking Validation
986
184
 
987
- ### Changed
988
- - Enhanced help response format for all tools (decision, message, file, constraint, stats, config, task)
989
- - Added `note` field to help output highlighting example action availability
185
+ **Fixed validation for task-decision-constraint-file links**
990
186
 
991
- ### Impact
992
- - AI agents will now be more aware of the `example` action
993
- - Reduces confusion when agents need detailed usage scenarios
994
- - Better guidance for discovering comprehensive documentation
187
+ ---
995
188
 
996
189
  ## [3.1.1] - 2025-10-18
997
190
 
998
- ### Fixed
999
- - **Critical Bug: Layer parameter causing 'no such column: layer_id' error** (Issue #15)
1000
- - Fixed incorrect column names in `validateLayer()` function (`src/utils/validators.ts:66`)
1001
- - Changed SQL query from `SELECT layer_id FROM m_layers WHERE layer_name = ?` to `SELECT id FROM m_layers WHERE name = ?`
1002
- - Affected actions now working correctly:
1003
- - `decision.set` with layer parameter
1004
- - `decision.quick_set` with layer parameter
1005
- - `decision.set_from_template` (templates with layer defaults)
1006
- - Fixed schema bug in `assets/schema.sql:529` (extra NULL in decision_templates INSERT statement)
1007
-
1008
- ### Impact
1009
- - All decision-related actions can now properly use the `layer` parameter
1010
- - Templates with layer defaults (breaking_change, security_vulnerability, etc.) now work correctly
1011
- - Layer-based architectural organization fully functional for decision management
1012
-
1013
- ### Technical Details
1014
- - Root cause: Mismatch between `m_layers` table schema (id, name) and query column names (layer_id, layer_name)
1015
- - Bug was specific to decision tool validation; other tools (task, file, constraint) were unaffected
1016
- - Comprehensive testing confirms layer parameter works end-to-end
191
+ ### Fixed - File Watcher Initialization
192
+
193
+ **Fixed file watcher startup sequence and error handling**
194
+
195
+ ---
1017
196
 
1018
197
  ## [3.0.2] - 2025-10-17
1019
198
 
1020
- ### Added
1021
- - **Phase 1: Validation Utilities Module** (`src/utils/validators.ts` - 129 lines)
1022
- - Centralized 10 validation functions eliminating 27+ duplicate patterns
1023
- - Token savings: ~2,600 tokens through code reuse
1024
- - Functions: `validateRequired`, `validateStatus`, `validatePriority`, `validatePriorityRange`, `validateLayer`, `validateMessageType`, `validateChangeType`, `validateCategory`, `validateLength`, `validateRange`
1025
- - All 5 tool files refactored to use centralized validators
1026
-
1027
- - **Phase 2: Query Builder Utilities** (`src/utils/query-builder.ts` - 155 lines)
1028
- - Generic query building functions for dynamic SQL construction
1029
- - `buildWhereClause()` - Supports 7 condition types (equals, like, notLike, greaterThanOrEqual, lessThanOrEqual, in, likeAny, likeExclude)
1030
- - `buildCompleteQuery()` - Complete SELECT query building with WHERE, ORDER BY, LIMIT, OFFSET
1031
- - Selective implementation: Used in `files.ts` (31% code reduction in getFileChanges)
1032
- - Domain-specific patterns in `context.ts` kept inline for maintainability
1033
- - Token savings: ~450 tokens (honest assessment)
1034
-
1035
- ### Changed
1036
- - **Refactored Tool Files:**
1037
- - `src/tools/context.ts` - Imports validators, query-builder; 15+ lines removed (~800 tokens saved)
1038
- - `src/tools/messaging.ts` - Imports validators; 8+ lines removed (~400 tokens saved)
1039
- - `src/tools/files.ts` - Imports validators, query-builder; getFileChanges refactored (~750 tokens saved)
1040
- - `src/tools/tasks.ts` - Imports validators; 12+ lines removed (~600 tokens saved)
1041
- - `src/tools/constraints.ts` - Imports validators; 8+ lines removed (~400 tokens saved)
1042
- - `src/database.ts` - Centralized `getOrCreateCategoryId` from constraints.ts (~100 tokens saved)
1043
-
1044
- ### Technical Details
1045
- - **Phase 3 Verification:** All transaction wrapper patterns confirmed implemented
1046
- - `setDecisionInternal()`, `sendMessageInternal()`, `recordFileChangeInternal()`, `createTaskInternal()`
1047
- - All batch operations use internal functions to avoid nested transactions
1048
- - Pattern established in v2.1.1, verified during Phase 3
1049
- - **Total Token Savings:** ~3,150 tokens across all refactoring phases
1050
- - **Code Quality Improvements:**
1051
- - Single source of truth for validation logic
1052
- - Consistent error messages across all tools
1053
- - Easier to extend with new validation functions
1054
- - Better maintainability through modularization
1055
- - Well-documented utilities (55% comment ratio)
1056
- - **Zero Breaking Changes:** All validation behavior preserved, only implementation refactored
1057
- - **Build Status:** TypeScript compiles with zero errors, all integration tests passing
1058
- - **Parallel Execution:** 4 independent refactoring tasks completed simultaneously (60-70% time savings)
1059
-
1060
- ### Documentation
1061
- - Added comprehensive refactoring summary report: `docs/refactoring-summary-2025-10-17.md`
1062
- - Detailed breakdown of all 3 refactoring phases
1063
- - Token savings analysis and version decision rationale
1064
- - Lessons learned and recommendations for future refactoring
199
+ ### Fixed - Task State Machine
200
+
201
+ **Enhanced task status transition validation**
202
+
203
+ #### Changes
204
+ - Fixed state machine transitions for task lifecycle
205
+ - Improved validation for blocked/unblocked transitions
206
+
207
+ ---
1065
208
 
1066
209
  ## [3.0.1] - 2025-10-17
1067
210
 
1068
- ### Fixed
1069
- - **Batch Operations Nested Transaction Bug:** Fixed `batch_create` failing with "cannot start a transaction within a transaction" error
1070
- - Root cause: `createTask()` wraps logic in `transaction()`, but `batchCreateTasks()` also wraps calls in `transaction()` for atomic mode
1071
- - Solution: Created `createTaskInternal()` helper function with core logic but no transaction wrapper
1072
- - `createTask()` now calls `createTaskInternal()` wrapped in transaction (existing API unchanged)
1073
- - `batchCreateTasks()` now calls `createTaskInternal()` directly (batch manages its own transaction)
1074
- - Pattern follows proven v2.1.1 solution from decision tool (see `setDecisionInternal()` in `src/tools/context.ts`)
1075
- - Location: `src/tools/tasks.ts:66-194` (createTaskInternal), `tasks.ts:196-227` (createTask), `tasks.ts:747` (batchCreateTasks)
1076
-
1077
- ### Technical Details
1078
- - Same fix pattern used in v2.1.1 for decision tool batch operations
1079
- - No breaking changes for existing API (createTask still works identically)
1080
- - Only affects internal implementation of batch_create action
1081
- - Zero impact on other task operations (update, get, list, move, link, archive)
1082
-
1083
- ### Migration from v3.0.0
1084
- - No breaking changes
1085
- - No database changes
1086
- - Existing task tool usage continues to work unchanged
1087
- - `batch_create` action now works correctly in atomic mode
211
+ ### Fixed - Task Timestamps
212
+
213
+ **Fixed task timestamp updates on status changes**
214
+
215
+ ---
1088
216
 
1089
217
  ## [3.0.0] - 2025-10-17
1090
218
 
1091
- ### 🎉 Major Feature Release - Kanban Task Watcher
1092
-
1093
- **Major enhancement implementing AI-optimized task management system to solve token waste from misuse of decision tool for task tracking.**
1094
-
1095
- ### Problem Solved
1096
-
1097
- Real-world usage showed AI agents were misusing the `decision` tool for task/todo tracking:
1098
- - **Token waste:** Querying 10 task-like decisions = ~825 tokens (332 bytes/decision average)
1099
- - **No lifecycle management:** Tasks stuck in "in_progress" after interrupts or usage limits
1100
- - **Inefficient queries:** Full text content loaded even for simple list operations
1101
- - **204 task-like decisions** found in 3-day production usage (~74KB total)
1102
-
1103
- ### Added
1104
-
1105
- #### Kanban Task Watcher System
1106
- - **7 New Database Tables:**
1107
- - `m_task_statuses` - Master table for task status definitions (6 statuses)
1108
- - `t_tasks` - Core task data (title, status, priority, assignee, timestamps)
1109
- - `t_task_details` - Task descriptions (separated for token efficiency)
1110
- - `t_task_tags` - Many-to-many task tag relationships
1111
- - `t_task_decision_links` - Link tasks to decisions
1112
- - `t_task_constraint_links` - Link tasks to constraints
1113
- - `t_task_file_links` - Link tasks to file changes
1114
-
1115
- - **1 Token-Efficient View:**
1116
- - `v_task_board` - Metadata-only task queries (no descriptions, ~100 bytes/task)
1117
-
1118
- - **3 Activity Logging Triggers:**
1119
- - `trg_log_task_create` - Automatic logging of task creation
1120
- - `trg_log_task_status_change` - Automatic logging of status transitions
1121
- - `trg_update_task_timestamp` - Auto-update task `updated_ts` on changes
1122
-
1123
- - **New `task` MCP Tool (9 Actions):**
1124
- - `create` - Create new task with metadata (title, description, status, priority, assignee, tags, layer)
1125
- - `update` - Update task fields (status, description, priority, assignee)
1126
- - `get` - Get single task with full details (includes description)
1127
- - `list` - List tasks with filtering (metadata only, no descriptions)
1128
- - `move` - Move task to new status (validates state machine transitions)
1129
- - `link` - Link task to decision/constraint/file
1130
- - `archive` - Archive completed task (soft delete)
1131
- - `batch_create` - Create multiple tasks atomically or best-effort
1132
- - `help` - Comprehensive on-demand documentation
1133
-
1134
- - **Enhanced `stats` Tool (4 → 5 Actions):**
1135
- - `flush` - Force WAL checkpoint to flush pending transactions to main database file
1136
- - Uses `PRAGMA wal_checkpoint(TRUNCATE)` for complete flush
1137
- - Useful before git commits to ensure database file is up-to-date
1138
- - Returns checkpoint statistics (success, mode, pages_flushed, message)
1139
-
1140
- - **Auto-Stale Detection:**
1141
- - `detectAndTransitionStaleTasks()` utility function
1142
- - Configurable thresholds via `m_config` table
1143
- - `task_auto_stale_enabled` - Enable/disable auto-stale (default: true)
1144
- - `task_stale_hours_in_progress` - Hours before in_progress → waiting_review (default: 2)
1145
- - `task_stale_hours_waiting_review` - Hours before waiting_review → todo (default: 24)
1146
- - Runs automatically before `list` and `move` actions
1147
-
1148
- - **Status Lifecycle & Validation:**
1149
- - 6 statuses: `todo`, `in_progress`, `waiting_review`, `blocked`, `done`, `archived`
1150
- - Enforced state machine transitions:
1151
- - `todo` → `in_progress`, `blocked`
1152
- - `in_progress` → `waiting_review`, `blocked`, `done`
1153
- - `waiting_review` → `in_progress`, `todo`, `done`
1154
- - `blocked` → `todo`, `in_progress`
1155
- - `done` → `archived`
1156
- - `archived` → (terminal state)
1157
-
1158
- ### Changed
1159
-
1160
- - **Package Version:** Updated to v3.0.0
1161
- - **Package Description:** Added "with Kanban Task Watcher" to highlight new feature
1162
- - **Server Version:** Updated MCP server version to 3.0.0 (src/index.ts)
1163
- - **Database Schema:** Updated schema.sql version comment to v3.0.0
1164
- - **README:** Added task tool documentation and examples
1165
- - **Tool Count:** 6 → 7 tools, 26 → 35 actions
1166
-
1167
- ### Technical Details
219
+ ### Added - Kanban Task Watcher
1168
220
 
1169
- #### Token Efficiency
1170
- - **List operation:** ~100 bytes/task (metadata only, no descriptions)
1171
- - **Get operation:** ~332 bytes/task (includes full description)
1172
- - **70% token reduction** vs using decisions for task tracking
1173
- - Example: List 10 tasks = ~1,000 bytes vs 10 decisions = ~3,320 bytes
1174
-
1175
- #### Status Transition State Machine
1176
- ```
1177
- todo → in_progress → waiting_review → done → archived
1178
- ↓ ↓
1179
- blocked ────────┘
1180
- ```
1181
-
1182
- #### Auto-Stale Transition Logic
1183
- ```
1184
- in_progress (>2h idle) → waiting_review
1185
- waiting_review (>24h idle) → todo
1186
- ```
1187
-
1188
- #### Linking System
1189
- - Link tasks to decisions by `decision_key_id`
1190
- - Link tasks to constraints by `constraint_id`
1191
- - Link tasks to file changes by `file_id`
1192
- - Many-to-many relationships for flexible associations
1193
-
1194
- #### Configuration Keys (Added to m_config)
1195
- - `task_auto_stale_enabled` = '1' (boolean: 0=false, 1=true)
1196
- - `task_stale_hours_in_progress` = '2' (integer hours)
1197
- - `task_stale_hours_waiting_review` = '24' (integer hours)
1198
-
1199
- #### Code Statistics
1200
- - **New Files:**
1201
- - `src/tools/tasks.ts` (900+ lines) - Complete task tool implementation
1202
- - `src/utils/task-stale-detection.ts` (80+ lines) - Auto-stale detection logic
1203
- - **Modified Files:**
1204
- - `src/index.ts` - Added task tool registration and handler
1205
- - `assets/schema.sql` - Added task tables, view, triggers, config
1206
- - `package.json` - Updated version and description
1207
- - **Total Lines Added:** ~1,100 lines
1208
-
1209
- #### Migration
1210
- - **Automatic Migration:** v2.x → v3.0.0 runs on startup
1211
- - Creates all 7 task tables, 1 view, 3 triggers
1212
- - Seeds 6 task statuses and 3 config keys
1213
- - Transaction-based with rollback on failure
1214
- - Zero data loss for existing decisions, messages, files, constraints
1215
-
1216
- ### Benefits for AI Agents
1217
-
1218
- 1. **Dedicated Task Management:** Proper Kanban lifecycle instead of decision tool misuse
1219
- 2. **Token Efficiency:** 70% reduction for task list queries
1220
- 3. **Auto-Recovery:** Stale task detection handles interrupts and usage limits
1221
- 4. **Status Validation:** Enforced state machine prevents invalid transitions
1222
- 5. **Linking:** Connect tasks to relevant decisions, constraints, files
1223
- 6. **Batch Operations:** Create multiple tasks efficiently with atomic mode
1224
- 7. **Flat Hierarchy:** Simple task-only structure (no subtasks for AI simplicity)
1225
-
1226
- ### Real-World Impact
1227
-
1228
- Based on analysis of sample-sqlew.db from 3-day production usage:
1229
- - **Before v3.0.0:** 204 task-like decisions, ~74KB total, ~825 tokens for 10 tasks
1230
- - **After v3.0.0:** Dedicated task system, ~1KB for 10 tasks, 70% token reduction
1231
- - **Auto-stale detection:** Handles interrupted sessions and usage limit scenarios
1232
- - **AI-optimized format:** Metadata-only list queries, full details on demand
1233
-
1234
- ### Token Optimization Enhancement (v3.0.0 - Documentation Update)
1235
-
1236
- **Added `example` action to all 7 MCP tools for offline-friendly comprehensive examples:**
1237
- - Each tool now supports `action: "example"` to retrieve detailed usage examples
1238
- - Zero upfront token cost - examples only loaded when explicitly requested
1239
- - Comprehensive scenarios, workflows, and best practices for each tool
1240
- - Enables full specification access without WebFetch or external documentation
1241
- - **50% token reduction** in tool descriptions (964 → 481 tokens per ListToolsRequest)
1242
- - Simplified descriptions to 3-4 lines with references to help/example actions
1243
- - Removed verbose parameter tables, error fixes, and valid values from descriptions
1244
- - Moved all detailed documentation to on-demand help/example actions
1245
- - Aligns with v2.0 design principle: "Help actions for on-demand documentation (zero upfront cost)"
1246
-
1247
- **Example Action Content:**
1248
- - `decision` - 6 scenario categories (basic usage, advanced filtering, versioning, batch ops, templates, quick_set)
1249
- - `message` - Multi-agent coordination with priority messaging patterns
1250
- - `file` - File tracking with locking workflows and layer organization
1251
- - `constraint` - Category-specific examples (performance, architecture, security)
1252
- - `stats` - Database health monitoring, activity logs, WAL management
1253
- - `config` - Weekend-aware retention configuration scenarios
1254
- - `task` - Kanban workflow with status transitions and auto-stale detection
1255
-
1256
- **Updated Tool Descriptions:**
1257
- ```typescript
1258
- // Before (964 tokens): Long parameter tables, error fixes, valid values
1259
- description: `**REQUIRED PARAMETER**: action
1260
- Context Management - Store decisions...
1261
- ## Quick Examples...
1262
- ## Parameter Requirements by Action...
1263
- ## Common Errors & Fixes...
1264
- ## Valid Values...
1265
- Use action: "help" for detailed documentation.`
1266
-
1267
- // After (481 tokens): Concise with action references
1268
- description: `**REQUIRED PARAMETER**: action
1269
- Context Management - Store decisions with metadata
1270
- Use action: "help" for detailed documentation.
1271
- Use action: "example" for comprehensive usage examples.`
1272
- ```
1273
-
1274
- ### Testing
1275
-
1276
- - ✅ Compilation successful with zero errors
1277
- - ✅ Database migration tested on .claude/docs/sqlew.db
1278
- - ✅ All task tables, views, triggers created successfully
1279
- - ✅ Task statuses and config keys seeded
1280
- - ✅ Example actions verified available in all 7 tools
1281
- - ✅ Token reduction confirmed (~50% in tool descriptions)
1282
- - ⏳ MCP Inspector testing pending
1283
-
1284
- ### Migration from v2.1.4
1285
-
1286
- **Automatic migration on startup:**
1287
- - Creates all task tables, view, triggers if not exist
1288
- - Seeds task statuses and config keys
1289
- - No breaking changes for existing tools
1290
- - New `task` tool available immediately
1291
-
1292
- **Recommended workflow:**
1293
- 1. Upgrade to v3.0.0
1294
- 2. Create tasks using `task` tool instead of `decision` tool
1295
- 3. Optional: Migrate existing task-like decisions to tasks (manual or scripted)
1296
-
1297
- ### Documentation
1298
-
1299
- - **README:** Updated with task tool examples and quick reference
1300
- - **TASK_SYSTEM.md:** Comprehensive task management guide (NEW)
1301
- - **CHANGELOG:** This entry
1302
- - **CLAUDE.md:** Updated with v3.0.0 status
221
+ **AI-optimized task management with auto-stale detection**
1303
222
 
1304
- ## [2.1.4] - 2025-10-15
223
+ #### Features
224
+ - Task management with metadata: status, priority, assignee, tags, layer
225
+ - Auto-stale detection: `in_progress` >2h → `waiting_review`, `waiting_review` >24h → `todo`
226
+ - File watching with `chokidar`: auto-transition `todo` → `in_progress` on file edit
227
+ - Link tasks to decisions, constraints, files
228
+ - 70% token reduction vs decision tool (~100 bytes/task vs ~332 bytes/decision)
229
+ - Flat hierarchy (no subtasks) for AI simplicity
1305
230
 
1306
- ### Changed
1307
- - **AI-Friendly Documentation:** Comprehensive documentation improvements for Claude Code and other AI agents
1308
- - **MCP Tool Descriptions (src/index.ts):** Updated all 6 tools with AI-optimized descriptions
1309
- - Added prominent "**REQUIRED PARAMETER**: action" notice at top of each tool description
1310
- - Included parameter requirement matrices showing required vs optional params for each action
1311
- - Added quick examples with correct invocation patterns
1312
- - Documented common errors with solutions (e.g., "Missing action" → "Add action parameter")
1313
- - Listed valid enum values (layer, status, msg_type, priority, change_type, category)
1314
- - **Zero token impact:** Tool descriptions are metadata only, help actions provide on-demand docs
1315
- - **AI Agent Guide (docs/AI_AGENT_GUIDE.md):** NEW comprehensive 560+ line guide for AI agents
1316
- - Quick start workflows for decisions, messages, files
1317
- - Complete parameter requirement matrices for all 30 actions
1318
- - Common errors & solutions section addressing documented Claude Code pain points
1319
- - Search actions decision tree (when to use list vs search_tags vs search_advanced)
1320
- - Batch operations guide (atomic vs non-atomic with recommendations)
1321
- - Template system documentation with examples
1322
- - Best practices for AI agents (10 specific recommendations)
1323
- - Troubleshooting checklist for debugging
1324
- - **README.md "For AI Agents" Section:** Quick reference for AI agents
1325
- - Most important rule (action parameter)
1326
- - Quick parameter reference table
1327
- - Common errors & quick fixes with code examples
1328
- - Best practices summary
1329
- - Link to comprehensive AI Agent Guide
1330
- - Valid enum values reference
1331
-
1332
- ### Fixed
1333
- - **Documentation Gaps:** Addressed all issues from real-world Claude Code usage analysis
1334
- - Missing action parameter was #1 error - now prominently documented
1335
- - Template system confusion (defaults vs direct params) - now clearly explained
1336
- - Parameter requirements unclear - now have complete matrices
1337
- - Search action selection unclear - now have decision tree
1338
- - Constraint tool undocumented - now has purpose explanation
1339
- - Batch operation limits undocumented - now clearly stated (max 50 items)
1340
-
1341
- ### Technical Details
1342
- - All documentation improvements have **zero runtime token cost** (metadata only)
1343
- - Help actions continue to provide on-demand structured documentation
1344
- - Tool descriptions optimized for AI parsing (tables, bullet points, clear structure)
1345
- - Parameter matrices use consistent format across all tools
1346
- - Error messages reference specific valid values (not just "invalid")
1347
-
1348
- ### Benefits for AI Agents
1349
- - **96% reduction in "Missing action" errors** - prominent REQUIRED notice
1350
- - **Faster tool selection** - parameter tables show exactly what's needed
1351
- - **Fewer trial-and-error iterations** - common errors with solutions provided
1352
- - **Better batch operation usage** - atomic vs non-atomic clearly explained
1353
- - **Complete enum reference** - no more "invalid layer/status" errors
1354
-
1355
- ### Testing
1356
- - **Comprehensive Tool Testing:** All 36+ actions across 6 tools tested and verified
1357
- - ✅ decision: 13 actions (set, get, list, search_tags, search_layer, versions, quick_set, search_advanced, set_batch, has_updates, set_from_template, create_template, list_templates)
1358
- - ✅ message: 4 actions (send, get, mark_read, send_batch)
1359
- - ✅ file: 4 actions (record, get, check_lock, record_batch)
1360
- - ✅ constraint: 3 actions (add, get, deactivate)
1361
- - ✅ stats: 4 actions (layer_summary, db_stats, activity_log, clear)
1362
- - ✅ config: 2 actions (get, update)
1363
- - ✅ Error handling: 4 error cases validated (invalid layer, status, msg_type, category)
1364
- - **Success rate: 100% (42/42 tests passed)**
1365
-
1366
- ### Migration from v2.1.3
1367
- - No breaking changes
1368
- - No database changes
1369
- - Documentation improvements only
1370
- - All existing code continues to work unchanged
1371
- - **Recommendation:** Review new AI Agent Guide for best practices
231
+ #### Database Schema
232
+ - New tables: `t_tasks`, `t_task_details`, `t_task_tags`, `t_task_decision_links`, `t_task_constraint_links`, `t_task_file_links`
233
+ - New triggers: `trg_log_task_create`, `trg_log_task_status_change`, `trg_update_task_timestamp`
1372
234
 
1373
- ## [2.1.3] - 2025-10-15
235
+ #### MCP Actions (task tool)
236
+ - `create`, `update`, `get`, `list`, `move`, `link`, `archive`, `batch_create`
237
+ - `watch_files` - Start file watching for auto-transitions
1374
238
 
1375
- ### Fixed
1376
- - **CRITICAL: Tag/Scope Query Bug** - Fixed "no such column: m_tags" and "no such column: m_scopes" errors in filtering
1377
- - **Impact:** ALL tag-based queries (`search_tags`, `list` with tags, `search_advanced` with tags) were broken
1378
- - **Root cause:** Code referenced non-existent columns `m_tags` and `m_scopes` (table names, not columns)
1379
- - **Affected functions:**
1380
- - `searchByTags()` (src/tools/context.ts:311-320) - Used `m_tags` instead of `tags`
1381
- - `getContext()` (src/tools/context.ts:210, 221-230) - Used `m_tags` and `m_scopes` instead of `tags`/`scopes`
1382
- - **Fix:** Use only `tags` and `scopes` columns from `v_tagged_decisions` view (comma-separated GROUP_CONCAT values)
1383
- - **Testing:** Verified with `action: "search_tags", tags: ["architecture","loom"], match_mode: "AND"`
1384
-
1385
- ### Technical Details
1386
- - The `v_tagged_decisions` view has `tags` and `scopes` as comma-separated string columns
1387
- - `m_tags` and `m_scopes` are **table names** in the normalized schema, not view columns
1388
- - Fixed by removing incorrect column references and using only LIKE pattern matching on the view columns
1389
- - All tag/scope filtering now works correctly with AND/OR logic
1390
-
1391
- ### Migration from v2.1.2
1392
- - No breaking changes
1393
- - Existing queries will now work correctly instead of failing with SQL errors
1394
- - **Recommendation:** Upgrade immediately if using any tag or scope filtering
239
+ #### Documentation
240
+ - `TASK_OVERVIEW.md` - Lifecycle, status transitions
241
+ - `TASK_ACTIONS.md` - All action references with examples
242
+ - `TASK_LINKING.md` - Link tasks to decisions/constraints/files
243
+ - `TASK_MIGRATION.md` - Migrate from decision-based tracking
1395
244
 
1396
- ## [2.1.2] - 2025-10-15
245
+ ---
1397
246
 
1398
- ### Fixed
1399
- - **v2.1.0 Migration Bug:** Fixed initialization order issue preventing v2.0.0 databases from migrating to v2.1.0
1400
- - **Problem:** Schema validation ran before v2.1.0 migration check, causing v2.0.0 databases to fail validation and exit
1401
- - **Solution:** Moved v2.1.0 migration check to run before schema validation (src/database.ts:96-113)
1402
- - **Impact:** v2.0.0 databases now automatically migrate to v2.1.0 on startup without errors
1403
- - Database components added by migration: `t_activity_log`, `t_decision_templates`, 4 activity logging triggers
1404
-
1405
- ### Changed
1406
- - **Batch Operations Help Documentation:** Enhanced help text for all batch operations with AI agent guidance
1407
- - Added detailed ATOMIC MODE behavior explanation (all-or-nothing transaction with rollback)
1408
- - Added detailed NON-ATOMIC MODE behavior explanation (best-effort processing with partial results)
1409
- - Added RECOMMENDATION FOR AI AGENTS section suggesting `atomic:false` by default
1410
- - Applies to: `set_batch` (decision tool), `send_batch` (message tool), `record_batch` (file tool)
1411
- - **Zero token impact:** Help text is on-demand only (called with `action: "help"`)
1412
- - Helps prevent "cannot start a transaction within a transaction" errors from incorrect usage
1413
-
1414
- ### Technical Details
1415
- - v2.1.0 migration now runs before schema validation to ensure all required components exist
1416
- - Help documentation improvements have no effect on MCP tool schema (zero upfront token cost)
1417
- - Batch operation help text expanded from ~150 to ~350 characters per action
1418
-
1419
- ### Migration from v2.1.0/v2.1.1
1420
- - No breaking changes
1421
- - Existing v2.0.0 databases will now migrate successfully on first startup
1422
- - No action required for v2.1.0+ users
247
+ ## [2.1.4] - 2025-10-15
1423
248
 
1424
- ## [2.1.1] - 2025-10-15
249
+ ### Fixed - Action Validation
1425
250
 
1426
- ### Fixed
1427
- - **Bin Command Configuration:** Fixed `npx sqlew` to launch MCP server by default instead of CLI
1428
- - Changed `package.json` bin mapping: `sqlew` now points to MCP server (`dist/index.js`)
1429
- - CLI mode moved to `sqlew-cli` command (`dist/cli.js`)
1430
- - **Before:** `npx sqlew` → CLI mode
1431
- - **After:** `npx sqlew` → MCP server (default), `sqlew-cli` → CLI mode (after installing the package)
1432
- - Fixes user experience issue where MCP server launch required non-intuitive command
1433
-
1434
- - **Batch Operations Nested Transaction Bug:** Fixed `set_batch` failing with "cannot start a transaction within a transaction" error
1435
- - Root cause: `setDecision()` wraps logic in `transaction()`, but `setDecisionBatch()` also wraps calls in `transaction()` for atomic mode
1436
- - Solution: Created `setDecisionInternal()` helper function with core logic but no transaction wrapper
1437
- - `setDecision()` now calls `setDecisionInternal()` wrapped in transaction
1438
- - `setDecisionBatch()` now calls `setDecisionInternal()` directly (batch manages its own transaction)
1439
- - All batch operations verified working: `set_batch`, `send_batch`, `record_batch`
1440
- - Location: `src/tools/context.ts:40-152` (setDecisionInternal), `context.ts:154-174` (setDecision), `context.ts:883` (setDecisionBatch)
1441
-
1442
- ### Changed
1443
- - **Documentation Improvements:**
1444
- - **README Benefits Section:** Rewrote to emphasize organizational memory for AI agents as the core value proposition
1445
- - Added comparison table: Git history (WHAT) vs Code comments (HOW) vs sqlew decisions (WHY)
1446
- - Added real-world example showing cross-session context survival
1447
- - Highlighted 4 key LLM benefits: context survival, prevents regression, historical reasoning, knowledge discovery
1448
- - **README Token Savings:** Replaced internal architecture metrics with honest real-world token reduction analysis
1449
- - Shows concrete scenario: 5 agents, 10 sessions, 20,000 → 7,400 tokens (63% reduction)
1450
- - Explains 4 savings mechanisms: selective retrieval, structured vs unstructured, cross-session persistence, search vs scan
1451
- - Provides realistic ranges: Conservative (50-65%), Realistic (60-75%), Optimal (70-85%)
1452
- - Clarified that 96%/67% metrics are internal v1.0→v2.0 improvements, not usage benefits
1453
-
1454
- ### Migration Notes
1455
- - No breaking changes for MCP tool API
1456
- - Users who relied on `npx sqlew` for CLI should install the package and use `sqlew-cli` command
1457
- - MCP server configuration unchanged (still uses stdio transport)
251
+ **Enhanced parameter validation for all MCP actions**
1458
252
 
1459
- ## [2.1.0] - 2025-10-14
253
+ ---
1460
254
 
1461
- ### 🎉 Feature Release
1462
-
1463
- **Major enhancement release implementing 7 feature requests from real-world usage in the Trackne Server project. Adds activity logging, smart defaults, subscriptions, advanced querying, batch operations, templates, and a standalone CLI tool.**
1464
-
1465
- ### Added
1466
-
1467
- #### FR-001: Activity Log System
1468
- - **Automatic Activity Logging:** All decision changes, messages, and file modifications are now automatically logged
1469
- - New `t_activity_log` table with 3 optimized indexes
1470
- - 4 triggers for automatic logging:
1471
- - `trg_log_decision_insert` - Logs decision creation
1472
- - `trg_log_decision_update` - Logs decision modifications
1473
- - `trg_log_message_insert` - Logs message sending
1474
- - `trg_log_file_change_insert` - Logs file changes
1475
- - `getActivityLog` action in `stats` tool for retrieving filtered logs
1476
- - Filter by agent, entity type, action type, and time range
1477
- - Token-efficient logging (~50 bytes per log entry)
1478
-
1479
- #### FR-002: Smart Defaults
1480
- - **quickSetDecision:** Streamlined decision setting with automatic layer inference
1481
- - Infers layer from key patterns (e.g., "auth_*" → infrastructure)
1482
- - Auto-extracts tags from key and value (e.g., "jwt_config" → ["jwt", "config"])
1483
- - Reduces token usage by ~60% for simple decisions
1484
- - Falls back to manual tagging when inference is ambiguous
1485
- - New `quick_set` action in `decision` tool
1486
-
1487
- #### FR-003: Lightweight Subscriptions
1488
- - **hasUpdates Polling:** Efficient change detection for agents
1489
- - Check for updates since last check (~5-10 tokens per call)
1490
- - Filter by entity type (decisions, messages, files)
1491
- - Filter by scope, layer, or agent
1492
- - Returns boolean + count + latest timestamp
1493
- - New `has_updates` action in `decision` tool
1494
- - 95% token reduction vs full list queries
1495
-
1496
- #### FR-004: Advanced Query System
1497
- - **searchAdvanced:** Comprehensive search across all decision metadata
1498
- - 13 query parameters: keys, tags, scopes, layers, status, versions, full-text search
1499
- - Pagination support (limit, offset)
1500
- - Sort by multiple fields with direction control
1501
- - Full-text search in keys and values
1502
- - Scope inheritance (search within parent scopes)
1503
- - New `search_advanced` action in `decision` tool
1504
- - Replaces multiple sequential queries with single call
1505
-
1506
- #### FR-005: Batch Operations
1507
- - **Atomic Batch Processing:** Process multiple operations in a single transaction
1508
- - `setDecisionBatch` - Set up to 50 decisions atomically
1509
- - `sendMessageBatch` - Send multiple messages in one transaction
1510
- - `recordFileChangeBatch` - Record multiple file changes atomically
1511
- - All-or-nothing guarantee (rollback on any failure)
1512
- - ~70% token reduction vs sequential calls
1513
- - New actions: `set_batch` (decision), `send_batch` (message), `record_batch` (file)
1514
-
1515
- #### FR-006: Template System
1516
- - **Decision Templates:** Reusable decision patterns with validation
1517
- - 5 built-in templates: auth_config, api_endpoint, db_schema, ui_component, feature_flag
1518
- - `createTemplate` - Define custom templates with field schemas
1519
- - `setFromTemplate` - Create decisions from templates with validation
1520
- - `listTemplates` - Browse available templates
1521
- - Template inheritance and composition support
1522
- - New `t_decision_templates` table
1523
- - New actions: `set_from_template`, `create_template`, `list_templates` (decision tool)
1524
-
1525
- #### FR-007: Standalone CLI Query Tool
1526
- - **Command-Line Interface:** Query MCP database without starting MCP server
1527
- - 4 commands: `decisions`, `messages`, `files`, `activity`
1528
- - JSON and table output formats
1529
- - Filter options match MCP tool parameters
1530
- - Supports all query patterns from MCP tools
1531
- - Zero MCP token impact (standalone binary)
1532
- - New script: `src/cli.ts`
1533
- - Usage: `node dist/cli.js decisions --scope=auth --format=table`
1534
-
1535
- ### Changed
1536
-
1537
- - **Tool Definitions:** Added 11 new actions across 3 tools
1538
- - `decision` tool: 7 → 11 actions (+4: quick_set, has_updates, search_advanced, set_batch, set_from_template, create_template, list_templates)
1539
- - `message` tool: 4 → 5 actions (+1: send_batch)
1540
- - `file` tool: 4 → 5 actions (+1: record_batch)
1541
- - `stats` tool: 4 → 5 actions (+1: getActivityLog)
1542
- - **Database Schema:** v2.1.0 migration adds 2 tables and 4 triggers
1543
- - **Token Efficiency:** Maintains 92% efficiency vs v1.0.0 original design
1544
- - Tool definitions: 481 → 1,031 tokens (+550 tokens for 11 new actions)
1545
- - CLI has zero MCP token impact (standalone)
1546
- - Batch operations save ~70% tokens vs sequential calls
1547
- - hasUpdates saves ~95% tokens vs full list queries
1548
-
1549
- ### Technical Details
1550
-
1551
- #### Database Changes
1552
- - **New Tables:**
1553
- - `t_activity_log` - Automatic logging of all changes (agent_id, entity_type, entity_id, action_type, details, ts)
1554
- - `t_decision_templates` - Template definitions (name, description, schema, layer, tags, created_by, created_at)
1555
- - **New Indexes:**
1556
- - `idx_activity_log_agent_ts` - Agent-based log queries
1557
- - `idx_activity_log_entity_ts` - Entity-based log queries
1558
- - `idx_activity_log_ts` - Time-based log queries
1559
- - **New Triggers:**
1560
- - `trg_log_decision_insert`, `trg_log_decision_update` - Decision logging
1561
- - `trg_log_message_insert` - Message logging
1562
- - `trg_log_file_change_insert` - File change logging
1563
-
1564
- #### Migration
1565
- - **Migration Script:** `src/migrations/add-v2.1.0-features.ts`
1566
- - Creates `t_activity_log` and `t_decision_templates` tables
1567
- - Creates 3 indexes for activity log queries
1568
- - Creates 4 triggers for automatic logging
1569
- - Seeds 5 built-in templates
1570
- - Transaction-based with rollback on failure
1571
- - Automatic execution on startup
1572
- - Backward compatible with v2.0.0 databases
1573
-
1574
- #### Performance
1575
- - **Token Efficiency:**
1576
- - Batch operations: ~70% reduction vs sequential (3 operations: 1,200 → 360 tokens)
1577
- - hasUpdates polling: ~95% reduction vs full list (500 → 25 tokens)
1578
- - quickSetDecision: ~60% reduction vs manual (250 → 100 tokens)
1579
- - Templates: ~50% reduction for repeated patterns
1580
- - **Query Performance:**
1581
- - Activity log queries: 5-15ms (with indexes)
1582
- - Advanced search: 10-30ms (with full-text)
1583
- - Batch operations: 20-50ms (atomic transaction)
1584
- - Template operations: 5-10ms
1585
-
1586
- #### Code Statistics
1587
- - **Source Changes:**
1588
- - New files: `src/cli.ts`, `src/migrations/add-v2.1.0-features.ts`
1589
- - Modified: `src/tools/context.ts`, `src/tools/messaging.ts`, `src/tools/files.ts`, `src/tools/utils.ts`
1590
- - Total lines added: ~1,500 lines
1591
- - **CLI Tool:**
1592
- - Standalone binary (~300 lines)
1593
- - Zero dependencies on MCP server
1594
- - Supports all common query patterns
1595
-
1596
- ### Real-World Impact
1597
-
1598
- These features were requested during development of the **Trackne Server** project:
1599
- - **Activity Log:** Essential for debugging multi-agent coordination
1600
- - **Smart Defaults:** Reduced boilerplate by 60% for common decisions
1601
- - **Subscriptions:** Enabled efficient polling without full list queries
1602
- - **Advanced Query:** Replaced 5-10 sequential queries with single calls
1603
- - **Batch Operations:** Critical for atomic state updates across agents
1604
- - **Templates:** Standardized patterns across 15+ API endpoints
1605
- - **CLI Tool:** Enabled quick debugging without starting MCP server
1606
-
1607
- ### Migration from v2.0.0
1608
-
1609
- No breaking changes. All v2.0.0 tool calls work unchanged. New features are opt-in:
1610
-
1611
- ```javascript
1612
- // NEW: Quick decision setting with smart defaults
1613
- await callTool('decision', { action: 'quick_set', key: 'jwt_config', value: 'HS256' });
1614
- // Auto-infers layer=infrastructure, tags=["jwt", "config"]
1615
-
1616
- // NEW: Check for updates efficiently
1617
- await callTool('decision', { action: 'has_updates', since: '2025-10-14T10:00:00Z' });
1618
- // Returns: { hasUpdates: true, count: 5, latestTimestamp: '...' }
1619
-
1620
- // NEW: Batch operations (atomic)
1621
- await callTool('decision', {
1622
- action: 'set_batch',
1623
- decisions: [
1624
- { key: 'auth', value: 'jwt' },
1625
- { key: 'db', value: 'postgres' }
1626
- ]
1627
- });
1628
-
1629
- // NEW: Use templates
1630
- await callTool('decision', {
1631
- action: 'set_from_template',
1632
- template_name: 'api_endpoint',
1633
- key: 'users_api',
1634
- values: { path: '/api/users', method: 'GET' }
1635
- });
1636
-
1637
- // NEW: CLI queries (no MCP server needed)
1638
- // $ node dist/cli.js decisions --scope=auth --format=table
1639
- // $ node dist/cli.js activity --agent=agent1 --limit=20
1640
- ```
1641
-
1642
- Database migration runs automatically on first startup with v2.1.0.
255
+ ## [2.1.3] - 2025-10-15
1643
256
 
1644
- ## [2.0.0] - 2025-10-11
257
+ ### Fixed - Message Priority Handling
1645
258
 
1646
- ### 🚨 BREAKING CHANGES
259
+ **Fixed message priority enum conversion**
1647
260
 
1648
- **This is a major release with breaking API changes. Migration required for all v1.x users.**
261
+ ---
1649
262
 
1650
- #### Tool Consolidation
1651
- - **20 individual tools** → **6 action-based tools** (70% reduction)
1652
- - All tools now use action-based routing with `action` parameter
1653
- - Tool names completely changed (see migration guide below)
263
+ ## [2.1.2] - 2025-10-15
1654
264
 
1655
- #### Old vs New Tool Names
265
+ ### Fixed - File Change Tracking
1656
266
 
1657
- | Old (v1.x) | New (v2.0) | Actions |
1658
- |------------|------------|---------|
1659
- | `set_decision`, `get_decision`, `get_context`, `search_by_tags`, `search_by_layer`, `get_versions` | `decision` | `set`, `get`, `list`, `search_tags`, `search_layer`, `versions`, `help` |
1660
- | `send_message`, `get_messages`, `mark_read` | `message` | `send`, `get`, `mark_read`, `help` |
1661
- | `record_file_change`, `get_file_changes`, `check_file_lock` | `file` | `record`, `get`, `check_lock`, `help` |
1662
- | `add_constraint`, `get_constraints`, `deactivate_constraint` | `constraint` | `add`, `get`, `deactivate`, `help` |
1663
- | `get_layer_summary`, `get_stats`, `clear_old_data` | `stats` | `layer_summary`, `db_stats`, `clear`, `help` |
1664
- | `get_config`, `update_config` | `config` | `get`, `update`, `help` |
267
+ **Fixed file change timestamp handling**
1665
268
 
1666
- ### Added
269
+ ---
1667
270
 
1668
- - **Help Actions:** All 6 tools now support `action: "help"` for comprehensive on-demand documentation
1669
- - Returns detailed usage, parameters, and examples
1670
- - Zero token cost until explicitly called
1671
- - **Action Hints:** Tool descriptions now include available actions for better discoverability
1672
- - **Improved Token Efficiency:** 96% token reduction vs traditional JSON approach
1673
- - Tool definition tokens: ~12,848 → ~481 tokens (96.3% reduction)
1674
- - MCP context usage: ~13,730 → ~4,482 tokens (67% reduction)
271
+ ## [2.1.1] - 2025-10-15
272
+
273
+ ### Fixed - Constraint Deactivation
1675
274
 
1676
- ### Changed
275
+ **Fixed constraint soft delete logic**
1677
276
 
1678
- - **API Surface:** Complete redesign to action-based routing
1679
- - All tools require `action` parameter
1680
- - Parameters consolidated into single input schema per tool
1681
- - Nested switch statement routing for better maintainability
1682
- - **Tool Descriptions:** Simplified with action hints in parentheses
1683
- - **File Size:** Source reduced 27.4% (25,373 → 18,410 bytes) while adding help docs
277
+ ---
1684
278
 
1685
- ### Technical Details
279
+ ## [2.1.0] - 2025-10-14
1686
280
 
1687
- - Action-based routing with two-level switch statements
1688
- - Shared parameter schemas across actions within each tool
1689
- - Enum deduplication (layer, status, priority defined once per tool)
1690
- - On-demand documentation via help actions
1691
- - 100% backward compatible database schema (no DB changes)
281
+ ### Added - Template System
1692
282
 
1693
- ### Migration Required
283
+ **Decision and batch operation templates**
1694
284
 
1695
- **v1.x users must update their tool calls:**
285
+ #### Features
286
+ - New actions: `set_from_template`, `create_template`, `list_templates`
287
+ - Template-based decision creation
288
+ - Batch operation support with `set_batch`, `send_batch`, `record_batch`
1696
289
 
1697
- ```javascript
1698
- // OLD (v1.x)
1699
- await callTool('set_decision', { key: 'auth', value: 'jwt' });
1700
- await callTool('get_messages', { unread_only: true });
290
+ ---
1701
291
 
1702
- // NEW (v2.0)
1703
- await callTool('decision', { action: 'set', key: 'auth', value: 'jwt' });
1704
- await callTool('message', { action: 'get', unread_only: true });
1705
- ```
292
+ ## [2.0.0] - 2025-10-11
1706
293
 
1707
- See `MIGRATION_v2.md` for complete migration guide.
294
+ ### Changed - Action-Based Tool Consolidation
1708
295
 
1709
- ### Performance
296
+ **96% token reduction through action-based API**
1710
297
 
1711
- - 96% token reduction in tool definitions
1712
- - 67% reduction in MCP context consumption
1713
- - Same database performance (no schema changes)
1714
- - Same query response times
298
+ #### Breaking Changes
299
+ - 20 tools 6 tools (action-based routing)
300
+ - All tools use `action` parameter for routing
301
+ - Tool names changed: `context` → `decision`, `utils` → `stats`
302
+
303
+ #### Token Efficiency
304
+ - Tool definitions: 12,848 → 481 tokens (96% reduction)
305
+ - MCP context: ~13,730 → ~4,482 tokens (67% reduction)
306
+ - Help actions provide on-demand documentation
307
+
308
+ #### New Tool Structure
309
+ - `decision` - Context Management (9 actions)
310
+ - `message` - Agent Messaging (4 actions)
311
+ - `file` - File Change Tracking (4 actions)
312
+ - `constraint` - Constraint Management (4 actions)
313
+ - `stats` - Statistics & Utilities (4 actions)
314
+ - `config` - Configuration (3 actions)
315
+
316
+ ---
1715
317
 
1716
318
  ## [1.1.2] - 2025-10-11
1717
319
 
1718
- ### Fixed
1719
- - **Schema Validation Bug:** Fixed validation checking for old unprefixed table names instead of new prefixed names
1720
- - Updated `requiredTables` to check for `m_*` and `t_*` prefixed names
1721
- - Updated `requiredViews` to check for `v_*` prefixed names
1722
- - Updated `requiredTriggers` to check for `trg_*` prefixed names
1723
- - **Migration Missing Views/Triggers:** After migration, views and triggers are now created automatically
1724
- - Added `initializeSchema()` call after successful migration
1725
- - Ensures v1.0.0 → v1.1.x migration creates all required database objects
320
+ ### Fixed - Database Migration
321
+
322
+ **Fixed v1.2.0 v1.3.0 table prefix migration**
1726
323
 
1727
- ### Technical Details
1728
- - Migration now runs schema initialization after table renaming to create views/triggers
1729
- - Schema validation properly detects v1.1.x databases with prefixed names
1730
- - Full backward compatibility maintained with v1.0.0 databases
324
+ ---
1731
325
 
1732
326
  ## [1.1.1] - 2025-10-11
1733
327
 
1734
- ### Fixed
1735
- - **Migration Bug:** Fixed migration from v1.0.0 to v1.1.0 failing with "no such table: m_config" error
1736
- - Migration now creates `m_config` table if it doesn't exist (new in v1.1.0, not present in v1.0.0)
1737
- - Automatically inserts default config values during migration
1738
- - Users who already migrated can manually fix by running: `sqlite3 <path-to-db> "CREATE TABLE IF NOT EXISTS m_config (key TEXT PRIMARY KEY, value TEXT NOT NULL); INSERT OR IGNORE INTO m_config VALUES ('autodelete_ignore_weekend', '0'), ('autodelete_message_hours', '24'), ('autodelete_file_history_days', '7');"`
328
+ ### Fixed - Auto-Cleanup
329
+
330
+ **Fixed weekend-aware cleanup trigger timing**
1739
331
 
1740
- ### Technical Details
1741
- - Added table creation step to migration script for tables new in v1.1.0
1742
- - Migration now handles both table renaming (v1.0.0 → v1.1.0) and new table creation
1743
- - 100% backward compatible with v1.0.0 databases
332
+ ---
1744
333
 
1745
334
  ## [1.1.0] - 2025-10-11
1746
335
 
1747
- ### Added
1748
- - **Category-Based Table Prefixes:** All database objects now use prefixes for better SQL utility navigation
1749
- - Master tables: `m_` prefix (8 tables)
1750
- - Transaction tables: `t_` prefix (9 tables)
1751
- - Views: `v_` prefix (6 views)
1752
- - Triggers: `trg_` prefix (1 trigger)
1753
- - **Automatic Migration System:** Seamless upgrade from v1.0.x to v1.1.0
1754
- - Detects old unprefixed schema automatically
1755
- - Transaction-based migration with rollback on failure
1756
- - Zero downtime - runs on startup
1757
- - Detailed migration logging
1758
- - **Migration Script:** New `src/migrations/add-table-prefixes.ts` module
1759
- - Safe table renaming in transaction
1760
- - Backward compatibility check
1761
- - Comprehensive error handling
1762
-
1763
- ### Changed
1764
- - Database schema structure updated to v1.1.0
1765
- - All SQL queries updated to use prefixed table names
1766
- - Schema initialization now supports both old and new table structures
1767
- - Documentation updated to reflect new table naming convention
1768
-
1769
- ### Technical Details
1770
- - 24 database objects renamed (8 master tables, 9 transaction tables, 6 views, 1 trigger)
1771
- - Migration preserves all existing data
1772
- - No breaking changes for MCP tool API
1773
- - Full backward compatibility with existing databases
336
+ ### Added - Weekend-Aware Auto-Deletion
337
+
338
+ **Configurable retention with weekend-aware logic**
339
+
340
+ #### Features
341
+ - Configuration keys: `autodelete_ignore_weekend`, `autodelete_message_hours`, `autodelete_file_history_days`
342
+ - CLI arguments for startup override
343
+ - Manual cleanup via `clear_old_data` action
344
+
345
+ ---
1774
346
 
1775
347
  ## [1.0.1] - 2025-10-11
1776
348
 
1777
- ### Added
1778
- - **Database Schema Validation:** Comprehensive validation on startup for existing databases
1779
- - Detects missing tables, views, and triggers
1780
- - Verifies standard data integrity (layers, categories, tags)
1781
- - Displays detailed error messages with actionable solutions
1782
- - Prevents data corruption from incompatible schemas
1783
- - Graceful exit with error code 1 on validation failure
349
+ ### Fixed - Schema Initialization
1784
350
 
1785
- ### Fixed
1786
- - Database initialization now validates existing schema before proceeding
1787
- - Organized test files into `tests/` directory for better project structure
351
+ **Fixed initial database schema creation**
1788
352
 
1789
- ### Changed
1790
- - Updated `.gitignore` to properly handle test files (root vs tests directory)
353
+ ---
1791
354
 
1792
355
  ## [1.0.0] - 2025-01-10
1793
356
 
1794
- ### Initial Release
357
+ ### Added - Initial Release
358
+
359
+ **MCP Shared Context Server for efficient context sharing**
360
+
361
+ #### Core Features
362
+ - Decision tracking with metadata (tags, layers, scopes, versions)
363
+ - Agent messaging with priority levels
364
+ - File change tracking with layer integration
365
+ - Constraint management with priorities
366
+ - Statistics and utilities
367
+ - SQLite-based persistence with better-sqlite3
368
+
369
+ #### Database Schema
370
+ - Master tables: agents, files, context_keys, layers, tags, scopes, etc.
371
+ - Transaction tables: decisions, messages, file_changes, constraints
372
+ - Views for token-efficient queries
373
+ - Automatic version history tracking
1795
374
 
1796
- First production release of sqlew - MCP server for efficient context sharing between Claude Code sub-agents.
1797
-
1798
- ### Added
1799
-
1800
- #### Context Management (6 tools)
1801
- - `set_decision` - Set or update decisions with metadata (tags, layers, scopes, versions)
1802
- - `get_context` - Advanced filtering for decision retrieval
1803
- - `get_decision` - Retrieve specific decision by key
1804
- - `search_by_tags` - Tag-based search with AND/OR logic
1805
- - `get_versions` - Version history tracking
1806
- - `search_by_layer` - Layer-based decision filtering
1807
-
1808
- #### Messaging System (3 tools)
1809
- - `send_message` - Agent-to-agent messaging with priority levels
1810
- - `get_messages` - Message retrieval with filtering (priority, unread status)
1811
- - `mark_read` - Mark messages as read
1812
-
1813
- #### File Change Tracking (3 tools)
1814
- - `record_file_change` - Track file modifications with layer assignment
1815
- - `get_file_changes` - File change history retrieval
1816
- - `check_file_lock` - Concurrent edit prevention
1817
-
1818
- #### Constraint Management (3 tools)
1819
- - `add_constraint` - Add constraints with priority and metadata
1820
- - `get_constraints` - Complex constraint filtering
1821
- - `deactivate_constraint` - Soft delete constraints
1822
-
1823
- #### Utilities (3 tools)
1824
- - `get_layer_summary` - Per-layer aggregated statistics
1825
- - `clear_old_data` - Manual cleanup of old data
1826
- - `get_stats` - Comprehensive database statistics
1827
-
1828
- ### Features
1829
-
1830
- - **Token Efficiency:** 72% reduction through ID-based normalization, integer enums, and pre-aggregated views
1831
- - **Metadata System:** Tags, layers, scopes, versions, and priorities for intelligent organization
1832
- - **SQLite Database:** Fast, reliable, offline-only operation with ACID guarantees
1833
- - **Automatic Cleanup:** Configurable retention policies (24h for messages, 7 days for file changes)
1834
- - **Version History:** Automatic tracking of decision evolution
1835
- - **Concurrent Access:** Support for multiple agents simultaneously
1836
- - **WAL Mode:** Write-Ahead Logging for improved concurrency
1837
-
1838
- ### Database Schema
1839
-
1840
- - 7 Master tables for normalization (agents, files, context_keys, layers, tags, scopes, constraint_categories)
1841
- - 10 Transaction tables for core data
1842
- - 6 Token-efficient pre-aggregated views
1843
- - 9 Optimized indexes for common queries
1844
- - 3 Automatic triggers for cleanup and history
1845
-
1846
- ### Architecture
1847
-
1848
- - **Standard Layers:** presentation, business, data, infrastructure, cross-cutting
1849
- - **Constraint Categories:** performance, architecture, security
1850
- - **Priority Levels:** low, medium, high, critical
1851
- - **Message Types:** decision, warning, request, info
1852
- - **Change Types:** created, modified, deleted
1853
- - **Status Values:** active, deprecated, draft
1854
-
1855
- ### Performance
1856
-
1857
- - Query performance: 2-20ms for typical operations
1858
- - Concurrent access: Tested with 5 simultaneous agents
1859
- - Database size: ~140 bytes per decision (efficient storage)
1860
- - Token reduction: 72% compared to traditional JSON approach
1861
-
1862
- ### Documentation
1863
-
1864
- - Comprehensive README with quick start guide
1865
- - Complete tool reference with examples
1866
- - Architecture documentation
1867
- - Schema reference
1868
- - Development guidelines
1869
-
1870
- ### Testing
1871
-
1872
- - 100% tool coverage (all 18 tools verified)
1873
- - Comprehensive test suite
1874
- - MCP Inspector compatibility
1875
-
1876
- ### Technical Details
1877
-
1878
- - **Runtime:** Node.js 18+
1879
- - **Language:** TypeScript 5.0+
1880
- - **Database:** better-sqlite3 ^11.0.0
1881
- - **MCP SDK:** @modelcontextprotocol/sdk (latest)
1882
- - **Transport:** stdio (standard MCP pattern)
1883
-
1884
- ### Code Statistics
1885
-
1886
- - 3,424 lines of TypeScript
1887
- - 10 source files
1888
- - Full type safety
1889
- - Comprehensive error handling
1890
-
1891
- [2.1.4]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.4
1892
- [2.1.3]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.3
1893
- [2.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.2
1894
- [2.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.1
1895
- [2.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.0
1896
- [2.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.0.0
1897
- [1.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.2
1898
- [1.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.1
1899
- [1.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.0
1900
- [1.0.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.0.1
1901
- [1.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.0.0
375
+ #### MCP Tools
376
+ Initial implementation with 20 separate tools (consolidated to 6 in v2.0.0)