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
@@ -0,0 +1,170 @@
1
+ # Migration Guide: v3.3.x → v3.6.0
2
+
3
+ **Release Date**: 2025-10-25
4
+ **Migration Type**: ✅ Automatic (Zero Downtime)
5
+
6
+ ---
7
+
8
+ ## Overview
9
+
10
+ Version 3.6.0 introduces major improvements:
11
+ - **Knex.js Database Layer**: Cross-database support (SQLite/PostgreSQL/MySQL)
12
+ - **Help System Optimization**: Database-driven queries (60-70% token reduction)
13
+ - **Enhanced Performance**: Optimized query patterns and indexing
14
+
15
+ Migration is **fully automatic** and **backward compatible**.
16
+
17
+ ### What's New
18
+
19
+ - Cross-database support with automatic migrations
20
+ - 6 new help query actions (`help_action`, `help_params`, `help_tool`, `help_use_case`, `help_list_use_cases`, `help_next_actions`)
21
+ - 7 new database tables for help system
22
+ - 41 queryable use-cases across 6 categories
23
+ - v3.5.x branch deprecated (migrate directly from v3.3.x)
24
+
25
+ ---
26
+
27
+ ## Migration Checklist
28
+
29
+ ### ✅ Pre-Migration
30
+
31
+ - [ ] Backup database: `cp .claude/docs/sqlew.db .claude/docs/sqlew.db.backup`
32
+ - [ ] Ensure Node.js 18+
33
+ - [ ] Review [CHANGELOG.md](../CHANGELOG.md)
34
+
35
+ ### ✅ Migration Steps
36
+
37
+ 1. **Update & Rebuild**
38
+ ```bash
39
+ git pull origin main
40
+ npm install
41
+ npx tsc
42
+ ```
43
+
44
+ 2. **Start Server**
45
+ ```bash
46
+ node dist/index.js --db-path=.claude/docs/sqlew.db
47
+ ```
48
+
49
+ Migration runs automatically:
50
+ - Detects v3.3.x database
51
+ - Migrates to Knex.js schema
52
+ - Creates 7 help system tables
53
+ - Seeds 41 use-cases + metadata
54
+ - Completes in <5 seconds
55
+
56
+ 3. **Verify**
57
+ ```bash
58
+ # Check migration succeeded
59
+ sqlite3 .claude/docs/sqlew.db "SELECT COUNT(*) FROM knex_migrations;"
60
+ # Returns: 4
61
+ ```
62
+
63
+ ### ✅ Post-Migration
64
+
65
+ - [ ] Verify existing tools work
66
+ - [ ] Test new help actions (optional)
67
+
68
+ ---
69
+
70
+ ## Breaking Changes
71
+
72
+ **None** - 100% backward compatible. All existing actions work identically.
73
+
74
+ ---
75
+
76
+ ## New Features
77
+
78
+ ### 6 Help Query Actions (stats tool)
79
+
80
+ | Action | Purpose | Token Savings |
81
+ |--------|---------|---------------|
82
+ | `help_action` | Action parameters + examples | ~200 tokens (vs ~2,000) |
83
+ | `help_params` | Parameter list only | ~229 tokens (vs ~1,500) |
84
+ | `help_tool` | Tool overview + actions | ~139 tokens (vs ~5,000) |
85
+ | `help_use_case` | Single use-case workflow | ~150 tokens each |
86
+ | `help_list_use_cases` | Filter/list use-cases | ~282-584 tokens |
87
+ | `help_next_actions` | Common next actions | ~63 tokens |
88
+
89
+ Example:
90
+ ```json
91
+ {"tool": "stats", "action": "help_action", "tool": "decision", "action": "set"}
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Database Changes
97
+
98
+ ### New Tables (7)
99
+
100
+ **Master Tables:**
101
+ 1. `m_help_tools` - Tool metadata (7 tools)
102
+ 2. `m_help_actions` - Actions (41 total)
103
+ 3. `m_help_use_case_categories` - Categories (6)
104
+
105
+ **Transaction Tables:**
106
+ 4. `t_help_action_params` - Parameters (98)
107
+ 5. `t_help_action_examples` - Examples (41)
108
+ 6. `t_help_use_cases` - Use-cases (41)
109
+ 7. `t_help_action_sequences` - Common patterns
110
+
111
+ ### Impact
112
+
113
+ - Size: +210 KB (Knex overhead ~10 KB, help system ~200 KB)
114
+ - Performance: <200ms per help query
115
+ - Knex tracking: `knex_migrations` and `knex_migrations_lock` tables added
116
+
117
+ ---
118
+
119
+ ## Rollback Instructions
120
+
121
+ **Important**: v3.6.0 uses Knex.js schema - **must restore backup** to rollback.
122
+
123
+ 1. Stop server
124
+ 2. Restore backup: `cp .claude/docs/sqlew.db.backup .claude/docs/sqlew.db`
125
+ 3. Checkout v3.3.x:
126
+ ```bash
127
+ git checkout v3.3.x
128
+ npm install && npx tsc
129
+ node dist/index.js
130
+ ```
131
+
132
+ **Note**: v3.5.x deprecated - migrate directly v3.3.x → v3.6.0.
133
+
134
+ ---
135
+
136
+ ## FAQ
137
+
138
+ **Q: Do I need to change my code/workflows?**
139
+ A: No. All existing actions work identically.
140
+
141
+ **Q: Is the migration reversible?**
142
+ A: Yes, but requires restoring database backup (Knex schema incompatible with v3.3.x).
143
+
144
+ **Q: What if migration fails?**
145
+ A: Migration is transactional - auto-rollback on failure.
146
+
147
+ **Q: Can I disable the help system?**
148
+ A: Yes - simply don't use the new `help_*` actions.
149
+
150
+ **Q: How do I verify migration succeeded?**
151
+ A: Check logs for "✓ Migration complete: 3.3.x → 3.6.0" or run:
152
+ ```bash
153
+ sqlite3 .claude/docs/sqlew.db "SELECT COUNT(*) FROM knex_migrations;"
154
+ # Returns: 4
155
+ ```
156
+
157
+ **Q: Performance impact?**
158
+ A: Negligible. Help queries are optional and independent.
159
+
160
+ ---
161
+
162
+ ## Summary
163
+
164
+ - **Path**: v3.3.x → v3.6.0 (skip v3.5.x)
165
+ - **Type**: Automatic (zero downtime)
166
+ - **Breaking Changes**: None
167
+ - **Rollback**: Requires backup restore
168
+ - **Token Savings**: 60-70% (help queries)
169
+
170
+ **Always backup before upgrading.**
@@ -1,88 +1,43 @@
1
1
  # Shared Concepts Reference
2
2
 
3
- > **Single Source of Truth** - This document defines common concepts used across all MCP-SQLEW documentation. Always reference this file for authoritative definitions.
3
+ > **Single Source of Truth** - Common concepts used across all MCP-SQLEW documentation.
4
4
 
5
5
  ## Table of Contents
6
6
  - [Architecture Layers](#architecture-layers)
7
7
  - [Enum Values Reference](#enum-values-reference)
8
- - [Atomic Mode Explained](#atomic-mode-explained)
9
- - [Action Parameter Requirement](#action-parameter-requirement)
8
+ - [Atomic Mode](#atomic-mode)
9
+ - [Action Parameter](#action-parameter)
10
10
 
11
11
  ---
12
12
 
13
13
  ## Architecture Layers
14
14
 
15
- The system uses a 5-layer architecture for organizing decisions, constraints, file changes, and tasks:
15
+ 5-layer architecture for organizing decisions, constraints, file changes, and tasks:
16
16
 
17
- ### 1. **presentation** - User Interface Layer
18
- **Definition**: Components that handle user interaction and data presentation.
17
+ ### 1. **presentation** - User Interface
18
+ UI components, API endpoints, CLI handlers, forms, response formatting
19
19
 
20
- **Examples**:
21
- - React/Vue components, UI templates
22
- - API endpoints (REST/GraphQL controllers)
23
- - CLI command handlers
24
- - Web forms and validation logic
25
- - Response formatting and serialization
20
+ **Examples**: React components, REST controllers, web forms
26
21
 
27
- **When to Use**: Anything users directly interact with or that formats data for external consumption.
22
+ ### 2. **business** - Business Logic
23
+ Core application logic, business rules, domain operations
28
24
 
29
- ---
30
-
31
- ### 2. **business** - Business Logic Layer
32
- **Definition**: Core application logic, business rules, and domain operations.
33
-
34
- **Examples**:
35
- - Service classes and business workflows
36
- - Domain models and entities
37
- - Validation rules and business constraints
38
- - Use cases and application services
39
- - State machines and process orchestration
40
-
41
- **When to Use**: Core logic that defines "what" the application does, independent of how it's presented or stored.
42
-
43
- ---
44
-
45
- ### 3. **data** - Data Access Layer
46
- **Definition**: Components responsible for data persistence and retrieval.
47
-
48
- **Examples**:
49
- - Database schemas and migrations
50
- - Repository patterns and ORMs
51
- - Data access objects (DAOs)
52
- - Query builders and stored procedures
53
- - Database connection management
25
+ **Examples**: Service classes, domain models, workflows, validation rules
54
26
 
55
- **When to Use**: Anything that reads from or writes to persistent storage.
27
+ ### 3. **data** - Data Access
28
+ Data persistence and retrieval
56
29
 
57
- ---
58
-
59
- ### 4. **infrastructure** - Infrastructure Layer
60
- **Definition**: Technical capabilities and external service integrations.
30
+ **Examples**: Database schemas, repositories, ORMs, queries
61
31
 
62
- **Examples**:
63
- - Authentication/authorization mechanisms
64
- - Logging and monitoring systems
65
- - Message queues and event buses
66
- - Email/SMS service integrations
67
- - File storage and CDN integrations
68
- - Caching mechanisms (Redis, Memcached)
32
+ ### 4. **infrastructure** - Infrastructure
33
+ Technical capabilities and external services
69
34
 
70
- **When to Use**: Supporting services that provide technical capabilities to other layers.
71
-
72
- ---
35
+ **Examples**: Auth, logging, message queues, caching, email/SMS services
73
36
 
74
37
  ### 5. **cross-cutting** - Cross-Cutting Concerns
75
- **Definition**: Aspects that span multiple layers or affect the entire application.
38
+ Aspects spanning multiple layers
76
39
 
77
- **Examples**:
78
- - Error handling strategies
79
- - Security policies and encryption
80
- - Performance optimization patterns
81
- - Internationalization (i18n)
82
- - Audit logging across all layers
83
- - Configuration management
84
-
85
- **When to Use**: Concerns that don't belong to a single layer and affect multiple parts of the system.
40
+ **Examples**: Error handling, security, performance, i18n, configuration
86
41
 
87
42
  ---
88
43
 
@@ -166,175 +121,75 @@ type TaskStatus =
166
121
 
167
122
  ---
168
123
 
169
- ## Atomic Mode Explained
170
-
171
- ### What is Atomic Mode?
172
-
173
- **Atomic mode** determines how batch operations handle failures:
174
-
175
- - **`atomic: true`** (All-or-Nothing)
176
- - ALL operations succeed, or ALL fail
177
- - Uses database transactions
178
- - Rollback on any error
179
- - Data consistency guaranteed
180
-
181
- - **`atomic: false`** (Best-Effort)
182
- - Each operation attempted independently
183
- - Partial success possible
184
- - Failed items reported in response
185
- - Maximum throughput
186
-
187
- ### When to Use Each Mode
188
-
189
- #### Use `atomic: true` (Default) When:
190
- - **Data consistency is critical**
191
- - Financial transactions
192
- - Multi-step workflows that must complete together
193
- - Related records that must all exist or none exist
194
-
195
- - **Validation is important**
196
- - You want to validate ALL items before committing ANY
197
- - One invalid item should prevent all changes
198
-
199
- - **Examples**:
200
- ```typescript
201
- // All 3 decisions must be set together or none at all
202
- set_batch({
203
- decisions: [
204
- { key: "auth_method", value: "jwt", layer: "infrastructure" },
205
- { key: "session_timeout", value: "3600", layer: "infrastructure" },
206
- { key: "refresh_token_enabled", value: "true", layer: "infrastructure" }
207
- ],
208
- atomic: true // If any fails, rollback all
209
- })
210
- ```
211
-
212
- #### Use `atomic: false` When:
213
- - **Partial success is acceptable**
214
- - Bulk imports where some failures are expected
215
- - Idempotent operations (safe to retry)
216
- - Performance is critical
217
-
218
- - **AI agents making best-effort updates**
219
- - Don't want one bad item to block all others
220
- - Can handle partial success in response
221
-
222
- - **Examples**:
223
- ```typescript
224
- // Try to send all messages, report which ones failed
225
- send_batch({
226
- messages: [/* 50 messages */],
227
- atomic: false // Send as many as possible
228
- })
229
- ```
230
-
231
- ### Batch Operation Support
232
-
233
- Currently supported in:
234
- - `decision` tool: `action: "set_batch"` (atomic parameter available)
235
- - `message` tool: `action: "send_batch"` (atomic parameter available)
236
- - `file` tool: `action: "record_batch"` (atomic parameter available)
237
- - `task` tool: `action: "batch_create"` (atomic parameter available)
238
-
239
- ### Performance Implications
240
-
241
- - **Atomic mode (`atomic: true`)**:
242
- - Slower (transaction overhead)
243
- - Higher memory usage (holds all changes until commit)
244
- - Safer (guaranteed consistency)
245
-
246
- - **Non-atomic mode (`atomic: false`)**:
247
- - Faster (no transaction overhead)
248
- - Lower memory usage (commit per operation)
249
- - More flexible (partial success handling)
124
+ ## Atomic Mode
250
125
 
251
- ---
126
+ Determines batch operation failure handling:
252
127
 
253
- ## Action Parameter Requirement
128
+ **`atomic: true`** (All-or-Nothing) - Default
129
+ - ALL succeed or ALL fail
130
+ - Database transaction with rollback
131
+ - Guaranteed consistency
254
132
 
255
- ### Why is `action` Required?
133
+ **`atomic: false`** (Best-Effort)
134
+ - Independent operations
135
+ - Partial success possible
136
+ - Failed items reported
256
137
 
257
- **All MCP tools in this system use action-based routing**. The `action` parameter is **REQUIRED** in every tool call.
138
+ ### When to Use
258
139
 
259
- ### Design Rationale
140
+ **Use `atomic: true`** for:
141
+ - Critical data consistency (financial, multi-step workflows)
142
+ - All-or-nothing validation
260
143
 
261
- 1. **Token Efficiency** (96% reduction achieved)
262
- - Single tool with multiple actions vs. many separate tools
263
- - 20 tools 7 tools (v2.0.0 → v3.0.0)
264
- - Tool definitions: 12,848 tokens → 481 tokens
144
+ **Use `atomic: false`** for:
145
+ - Bulk imports with expected failures
146
+ - AI agent best-effort updates
147
+ - Performance-critical operations
265
148
 
266
- 2. **Logical Grouping**
267
- - Related operations grouped in one tool
268
- - `decision` tool handles all decision operations
269
- - `message` tool handles all messaging operations
270
- - Etc.
149
+ ### Supported Tools
150
+ - `decision`: `set_batch`
151
+ - `message`: `send_batch`
152
+ - `file`: `record_batch`
153
+ - `task`: `batch_create`
271
154
 
272
- 3. **Discoverability**
273
- - Each tool's actions are documented together
274
- - `action: "help"` provides on-demand documentation
275
- - Reduces upfront token cost (no documentation until requested)
155
+ ---
276
156
 
277
- ### Common Error
157
+ ## Action Parameter
278
158
 
279
- ```json
280
- ❌ ERROR: "Unknown action: undefined"
281
- ```
159
+ **`action` parameter is REQUIRED in all tool calls**
282
160
 
283
- **Cause**: Missing `action` parameter
161
+ ### Why Required?
162
+ - Token efficiency: 96% reduction (20 tools → 7 tools)
163
+ - Logical grouping of related operations
164
+ - On-demand help via `action: "help"`
284
165
 
285
- **Fix**: Always include `action` as the first parameter:
166
+ ### Common Error
286
167
  ```json
287
- CORRECT:
288
- {
289
- "action": "get",
290
- "key": "auth_method"
291
- }
292
-
293
- ❌ INCORRECT:
294
- {
295
- "key": "auth_method" // Missing action parameter
296
- }
297
- ```
298
-
299
- ### Available Actions by Tool
300
-
301
- - **decision**: `set`, `get`, `list`, `search_tags`, `search_layer`, `versions`, `quick_set`, `search_advanced`, `set_batch`, `has_updates`, `set_from_template`, `create_template`, `list_templates`, `hard_delete`, `help`
302
- - **message**: `send`, `get`, `mark_read`, `send_batch`, `help`
303
- - **file**: `record`, `get`, `check_lock`, `record_batch`, `help`
304
- - **constraint**: `add`, `get`, `deactivate`, `help`
305
- - **stats**: `layer_summary`, `db_stats`, `clear`, `activity_log`, `flush`, `help`
306
- - **config**: `get`, `update`, `help`
307
- - **task**: `create`, `update`, `get`, `list`, `move`, `link`, `archive`, `batch_create`, `help`
308
-
309
- ### Getting Help
168
+ ERROR: "Unknown action: undefined"
310
169
 
311
- Every tool supports `action: "help"` for comprehensive documentation:
312
- ```json
313
- {
314
- "action": "help"
315
- }
170
+ // Fix: Always include action
171
+ ✅ { "action": "get", "key": "auth_method" }
172
+ { "key": "auth_method" }
316
173
  ```
317
174
 
318
- This returns detailed usage instructions, parameter requirements, valid values, and examples for that specific tool.
175
+ ### Available Actions
176
+
177
+ - **decision**: set, get, list, search_tags, search_layer, versions, set_batch, help
178
+ - **message**: send, get, mark_read, send_batch, help
179
+ - **file**: record, get, check_lock, record_batch, help
180
+ - **constraint**: add, get, deactivate, help
181
+ - **stats**: layer_summary, db_stats, clear, help
182
+ - **config**: get, update, help
183
+ - **task**: create, update, get, list, move, link, archive, batch_create, help
319
184
 
320
185
  ---
321
186
 
322
187
  ## Database Enum Mappings
323
188
 
324
- For reference, enum values are stored as integers in the database:
189
+ Enum values stored as integers (MCP tools auto-convert - use strings in calls):
325
190
 
326
191
  - **status**: 1=active, 2=deprecated, 3=draft
327
192
  - **msg_type**: 1=decision, 2=warning, 3=request, 4=info
328
193
  - **priority**: 1=low, 2=medium, 3=high, 4=critical
329
194
  - **change_type**: 1=created, 2=modified, 3=deleted
330
195
  - **task_status**: 1=todo, 2=in_progress, 3=waiting_review, 4=blocked, 5=done, 6=archived
331
-
332
- The MCP tools handle string↔integer conversion automatically. Always use string values in tool calls.
333
-
334
- ---
335
-
336
- ## Version History
337
-
338
- - **v3.0.0**: Added task_status enum and Auto-Stale Detection section
339
- - **v2.1.0**: Added Atomic Mode Explained section
340
- - **v2.0.0**: Initial creation with action-based API concepts
@@ -93,7 +93,7 @@ Every task has:
93
93
  - Should have assignee
94
94
  - Auto-transitions to `waiting_review` via:
95
95
  - Smart quality gates (v3.4.1): All files modified, tests pass, TypeScript compiles, 3min idle (default)
96
- - Time-based stale detection: 2 hours idle (fallback)
96
+ - Time-based stale detection: 18 hours idle (fallback, supports multi-day tasks)
97
97
 
98
98
  **`waiting_review`:**
99
99
  - Awaiting human/AI feedback or git commit
@@ -250,7 +250,7 @@ Automatically runs before:
250
250
 
251
251
  **Default Settings:**
252
252
  - `task_auto_stale_enabled`: '1' (enabled)
253
- - `task_stale_hours_in_progress`: '2' (2 hours)
253
+ - `task_stale_hours_in_progress`: '18' (18 hours - supports multi-day tasks and lunch breaks)
254
254
  - `task_stale_hours_waiting_review`: '24' (24 hours)
255
255
  - `auto_archive_done_days`: '2' (2 days / 48 hours)
256
256
  - `autodelete_ignore_weekend`: '0' (false) - Shared with messages/files cleanup