sqlew 3.2.5 → 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 (291) hide show
  1. package/CHANGELOG.md +288 -1011
  2. package/README.md +80 -263
  3. package/assets/config.example.toml +97 -0
  4. package/assets/schema.sql +6 -1
  5. package/dist/adapters/index.d.ts +11 -0
  6. package/dist/adapters/index.d.ts.map +1 -0
  7. package/dist/adapters/index.js +21 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/adapters/mysql-adapter.d.ts +31 -0
  10. package/dist/adapters/mysql-adapter.d.ts.map +1 -0
  11. package/dist/adapters/mysql-adapter.js +63 -0
  12. package/dist/adapters/mysql-adapter.js.map +1 -0
  13. package/dist/adapters/postgresql-adapter.d.ts +31 -0
  14. package/dist/adapters/postgresql-adapter.d.ts.map +1 -0
  15. package/dist/adapters/postgresql-adapter.js +63 -0
  16. package/dist/adapters/postgresql-adapter.js.map +1 -0
  17. package/dist/adapters/sqlite-adapter.d.ts +37 -0
  18. package/dist/adapters/sqlite-adapter.d.ts.map +1 -0
  19. package/dist/adapters/sqlite-adapter.js +129 -0
  20. package/dist/adapters/sqlite-adapter.js.map +1 -0
  21. package/dist/adapters/types.d.ts +33 -0
  22. package/dist/adapters/types.d.ts.map +1 -0
  23. package/dist/adapters/types.js +2 -0
  24. package/dist/adapters/types.js.map +1 -0
  25. package/dist/cli.js +55 -54
  26. package/dist/cli.js.map +1 -1
  27. package/dist/config/example-generator.d.ts +11 -0
  28. package/dist/config/example-generator.d.ts.map +1 -0
  29. package/dist/config/example-generator.js +48 -0
  30. package/dist/config/example-generator.js.map +1 -0
  31. package/dist/config/loader.d.ts +46 -0
  32. package/dist/config/loader.d.ts.map +1 -0
  33. package/dist/config/loader.js +155 -0
  34. package/dist/config/loader.js.map +1 -0
  35. package/dist/config/types.d.ts +86 -0
  36. package/dist/config/types.d.ts.map +1 -0
  37. package/dist/config/types.js +28 -0
  38. package/dist/config/types.js.map +1 -0
  39. package/dist/constants.d.ts +9 -0
  40. package/dist/constants.d.ts.map +1 -1
  41. package/dist/constants.js +10 -0
  42. package/dist/constants.js.map +1 -1
  43. package/dist/database.d.ts +44 -122
  44. package/dist/database.d.ts.map +1 -1
  45. package/dist/database.js +145 -349
  46. package/dist/database.js.map +1 -1
  47. package/dist/index.js +223 -175
  48. package/dist/index.js.map +1 -1
  49. package/dist/knexfile.d.ts +6 -0
  50. package/dist/knexfile.d.ts.map +1 -0
  51. package/dist/knexfile.js +85 -0
  52. package/dist/knexfile.js.map +1 -0
  53. package/dist/migrations/add-help-system-tables.d.ts +35 -0
  54. package/dist/migrations/add-help-system-tables.d.ts.map +1 -0
  55. package/dist/migrations/add-help-system-tables.js +206 -0
  56. package/dist/migrations/add-help-system-tables.js.map +1 -0
  57. package/dist/migrations/add-token-tracking.d.ts +28 -0
  58. package/dist/migrations/add-token-tracking.d.ts.map +1 -0
  59. package/dist/migrations/add-token-tracking.js +108 -0
  60. package/dist/migrations/add-token-tracking.js.map +1 -0
  61. package/dist/migrations/add-v3.5.0-pruned-files.d.ts +26 -0
  62. package/dist/migrations/add-v3.5.0-pruned-files.d.ts.map +1 -0
  63. package/dist/migrations/add-v3.5.0-pruned-files.js +107 -0
  64. package/dist/migrations/add-v3.5.0-pruned-files.js.map +1 -0
  65. package/dist/migrations/index.d.ts +26 -12
  66. package/dist/migrations/index.d.ts.map +1 -1
  67. package/dist/migrations/index.js +162 -20
  68. package/dist/migrations/index.js.map +1 -1
  69. package/dist/migrations/knex/20251025020452_create_master_tables.d.ts +4 -0
  70. package/dist/migrations/knex/20251025020452_create_master_tables.d.ts.map +1 -0
  71. package/dist/migrations/knex/20251025020452_create_master_tables.js +65 -0
  72. package/dist/migrations/knex/20251025020452_create_master_tables.js.map +1 -0
  73. package/dist/migrations/knex/20251025021152_create_transaction_tables.d.ts +4 -0
  74. package/dist/migrations/knex/20251025021152_create_transaction_tables.d.ts.map +1 -0
  75. package/dist/migrations/knex/20251025021152_create_transaction_tables.js +235 -0
  76. package/dist/migrations/knex/20251025021152_create_transaction_tables.js.map +1 -0
  77. package/dist/migrations/knex/20251025021351_create_indexes.d.ts +4 -0
  78. package/dist/migrations/knex/20251025021351_create_indexes.d.ts.map +1 -0
  79. package/dist/migrations/knex/20251025021351_create_indexes.js +62 -0
  80. package/dist/migrations/knex/20251025021351_create_indexes.js.map +1 -0
  81. package/dist/migrations/knex/20251025021416_seed_master_data.d.ts +4 -0
  82. package/dist/migrations/knex/20251025021416_seed_master_data.d.ts.map +1 -0
  83. package/dist/migrations/knex/20251025021416_seed_master_data.js +58 -0
  84. package/dist/migrations/knex/20251025021416_seed_master_data.js.map +1 -0
  85. package/dist/migrations/knex/20251025070349_create_views.d.ts +4 -0
  86. package/dist/migrations/knex/20251025070349_create_views.d.ts.map +1 -0
  87. package/dist/migrations/knex/20251025070349_create_views.js +143 -0
  88. package/dist/migrations/knex/20251025070349_create_views.js.map +1 -0
  89. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.d.ts +4 -0
  90. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.d.ts.map +1 -0
  91. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.js +15 -0
  92. package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.js.map +1 -0
  93. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.d.ts +8 -0
  94. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.d.ts.map +1 -0
  95. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.js +12 -0
  96. package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.js.map +1 -0
  97. package/dist/migrations/knex/20251025090000_create_help_system_tables.d.ts +19 -0
  98. package/dist/migrations/knex/20251025090000_create_help_system_tables.d.ts.map +1 -0
  99. package/dist/migrations/knex/20251025090000_create_help_system_tables.js +115 -0
  100. package/dist/migrations/knex/20251025090000_create_help_system_tables.js.map +1 -0
  101. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.d.ts +13 -0
  102. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.d.ts.map +1 -0
  103. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.js +377 -0
  104. package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.js.map +1 -0
  105. package/dist/migrations/knex/20251025100000_seed_help_metadata.d.ts +15 -0
  106. package/dist/migrations/knex/20251025100000_seed_help_metadata.d.ts.map +1 -0
  107. package/dist/migrations/knex/20251025100000_seed_help_metadata.js +253 -0
  108. package/dist/migrations/knex/20251025100000_seed_help_metadata.js.map +1 -0
  109. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.d.ts +16 -0
  110. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.d.ts.map +1 -0
  111. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.js +276 -0
  112. package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.js.map +1 -0
  113. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.d.ts +8 -0
  114. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.d.ts.map +1 -0
  115. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.js +64 -0
  116. package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.js.map +1 -0
  117. package/dist/migrations/seed-help-data.d.ts +48 -0
  118. package/dist/migrations/seed-help-data.d.ts.map +1 -0
  119. package/dist/migrations/seed-help-data.js +1466 -0
  120. package/dist/migrations/seed-help-data.js.map +1 -0
  121. package/dist/migrations/seed-tool-metadata.d.ts +24 -0
  122. package/dist/migrations/seed-tool-metadata.d.ts.map +1 -0
  123. package/dist/migrations/seed-tool-metadata.js +392 -0
  124. package/dist/migrations/seed-tool-metadata.js.map +1 -0
  125. package/dist/migrations/v3.6.0-help-system-refactor.d.ts +46 -0
  126. package/dist/migrations/v3.6.0-help-system-refactor.d.ts.map +1 -0
  127. package/dist/migrations/v3.6.0-help-system-refactor.js +223 -0
  128. package/dist/migrations/v3.6.0-help-system-refactor.js.map +1 -0
  129. package/dist/schema.d.ts.map +1 -1
  130. package/dist/schema.js +2 -0
  131. package/dist/schema.js.map +1 -1
  132. package/dist/tests/git-aware-completion.test.d.ts +6 -0
  133. package/dist/tests/git-aware-completion.test.d.ts.map +1 -0
  134. package/dist/tests/git-aware-completion.test.js +160 -0
  135. package/dist/tests/git-aware-completion.test.js.map +1 -0
  136. package/dist/tests/help-system.test.d.ts +23 -0
  137. package/dist/tests/help-system.test.d.ts.map +1 -0
  138. package/dist/tests/help-system.test.js +374 -0
  139. package/dist/tests/help-system.test.js.map +1 -0
  140. package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts +6 -0
  141. package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts.map +1 -0
  142. package/dist/tests/tasks.auto-pruning-decision-link.test.js +264 -0
  143. package/dist/tests/tasks.auto-pruning-decision-link.test.js.map +1 -0
  144. package/dist/tests/tasks.auto-pruning-partial.test.d.ts +6 -0
  145. package/dist/tests/tasks.auto-pruning-partial.test.d.ts.map +1 -0
  146. package/dist/tests/tasks.auto-pruning-partial.test.js +285 -0
  147. package/dist/tests/tasks.auto-pruning-partial.test.js.map +1 -0
  148. package/dist/tests/tasks.auto-pruning-persistence.test.d.ts +6 -0
  149. package/dist/tests/tasks.auto-pruning-persistence.test.d.ts.map +1 -0
  150. package/dist/tests/tasks.auto-pruning-persistence.test.js +250 -0
  151. package/dist/tests/tasks.auto-pruning-persistence.test.js.map +1 -0
  152. package/dist/tests/tasks.auto-pruning-safety.test.d.ts +12 -0
  153. package/dist/tests/tasks.auto-pruning-safety.test.d.ts.map +1 -0
  154. package/dist/tests/tasks.auto-pruning-safety.test.js +217 -0
  155. package/dist/tests/tasks.auto-pruning-safety.test.js.map +1 -0
  156. package/dist/tests/tasks.dependencies.test.js +338 -307
  157. package/dist/tests/tasks.dependencies.test.js.map +1 -1
  158. package/dist/tests/tasks.link-file-backward-compat.test.d.ts +6 -0
  159. package/dist/tests/tasks.link-file-backward-compat.test.d.ts.map +1 -0
  160. package/dist/tests/tasks.link-file-backward-compat.test.js +247 -0
  161. package/dist/tests/tasks.link-file-backward-compat.test.js.map +1 -0
  162. package/dist/tests/tasks.watch-files-action.test.d.ts +6 -0
  163. package/dist/tests/tasks.watch-files-action.test.d.ts.map +1 -0
  164. package/dist/tests/tasks.watch-files-action.test.js +372 -0
  165. package/dist/tests/tasks.watch-files-action.test.js.map +1 -0
  166. package/dist/tests/tasks.watch-files-parameter.test.d.ts +6 -0
  167. package/dist/tests/tasks.watch-files-parameter.test.d.ts.map +1 -0
  168. package/dist/tests/tasks.watch-files-parameter.test.js +260 -0
  169. package/dist/tests/tasks.watch-files-parameter.test.js.map +1 -0
  170. package/dist/tests/two-step-git-completion.test.d.ts +6 -0
  171. package/dist/tests/two-step-git-completion.test.d.ts.map +1 -0
  172. package/dist/tests/two-step-git-completion.test.js +326 -0
  173. package/dist/tests/two-step-git-completion.test.js.map +1 -0
  174. package/dist/tests/vcs-staging.test.d.ts +6 -0
  175. package/dist/tests/vcs-staging.test.d.ts.map +1 -0
  176. package/dist/tests/vcs-staging.test.js +137 -0
  177. package/dist/tests/vcs-staging.test.js.map +1 -0
  178. package/dist/tools/config.d.ts +9 -4
  179. package/dist/tools/config.d.ts.map +1 -1
  180. package/dist/tools/config.js +16 -12
  181. package/dist/tools/config.js.map +1 -1
  182. package/dist/tools/constraints.d.ts +9 -3
  183. package/dist/tools/constraints.d.ts.map +1 -1
  184. package/dist/tools/constraints.js +66 -45
  185. package/dist/tools/constraints.js.map +1 -1
  186. package/dist/tools/context.d.ts +35 -16
  187. package/dist/tools/context.d.ts.map +1 -1
  188. package/dist/tools/context.js +374 -314
  189. package/dist/tools/context.js.map +1 -1
  190. package/dist/tools/files.d.ts +11 -4
  191. package/dist/tools/files.d.ts.map +1 -1
  192. package/dist/tools/files.js +173 -91
  193. package/dist/tools/files.js.map +1 -1
  194. package/dist/tools/help-queries.d.ts +130 -0
  195. package/dist/tools/help-queries.d.ts.map +1 -0
  196. package/dist/tools/help-queries.js +393 -0
  197. package/dist/tools/help-queries.js.map +1 -0
  198. package/dist/tools/messaging.d.ts +13 -6
  199. package/dist/tools/messaging.d.ts.map +1 -1
  200. package/dist/tools/messaging.js +217 -129
  201. package/dist/tools/messaging.js.map +1 -1
  202. package/dist/tools/tasks.d.ts +42 -12
  203. package/dist/tools/tasks.d.ts.map +1 -1
  204. package/dist/tools/tasks.js +809 -347
  205. package/dist/tools/tasks.js.map +1 -1
  206. package/dist/tools/utils.d.ts +13 -5
  207. package/dist/tools/utils.d.ts.map +1 -1
  208. package/dist/tools/utils.js +92 -115
  209. package/dist/tools/utils.js.map +1 -1
  210. package/dist/types.d.ts +4 -0
  211. package/dist/types.d.ts.map +1 -1
  212. package/dist/utils/activity-logging.d.ts +114 -0
  213. package/dist/utils/activity-logging.d.ts.map +1 -0
  214. package/dist/utils/activity-logging.js +162 -0
  215. package/dist/utils/activity-logging.js.map +1 -0
  216. package/dist/utils/batch.d.ts +2 -2
  217. package/dist/utils/batch.d.ts.map +1 -1
  218. package/dist/utils/batch.js +8 -8
  219. package/dist/utils/batch.js.map +1 -1
  220. package/dist/utils/cleanup.d.ts +21 -13
  221. package/dist/utils/cleanup.d.ts.map +1 -1
  222. package/dist/utils/cleanup.js +31 -24
  223. package/dist/utils/cleanup.js.map +1 -1
  224. package/dist/utils/debug-logger.d.ts +44 -0
  225. package/dist/utils/debug-logger.d.ts.map +1 -0
  226. package/dist/utils/debug-logger.js +116 -0
  227. package/dist/utils/debug-logger.js.map +1 -0
  228. package/dist/utils/file-pruning.d.ts +69 -0
  229. package/dist/utils/file-pruning.d.ts.map +1 -0
  230. package/dist/utils/file-pruning.js +185 -0
  231. package/dist/utils/file-pruning.js.map +1 -0
  232. package/dist/utils/help-tracking.d.ts +55 -0
  233. package/dist/utils/help-tracking.d.ts.map +1 -0
  234. package/dist/utils/help-tracking.js +88 -0
  235. package/dist/utils/help-tracking.js.map +1 -0
  236. package/dist/utils/quality-checks.d.ts +60 -0
  237. package/dist/utils/quality-checks.d.ts.map +1 -0
  238. package/dist/utils/quality-checks.js +228 -0
  239. package/dist/utils/quality-checks.js.map +1 -0
  240. package/dist/utils/retention.d.ts +13 -5
  241. package/dist/utils/retention.d.ts.map +1 -1
  242. package/dist/utils/retention.js +20 -8
  243. package/dist/utils/retention.js.map +1 -1
  244. package/dist/utils/task-stale-detection.d.ts +77 -7
  245. package/dist/utils/task-stale-detection.d.ts.map +1 -1
  246. package/dist/utils/task-stale-detection.js +309 -34
  247. package/dist/utils/task-stale-detection.js.map +1 -1
  248. package/dist/utils/token-estimation.d.ts +72 -0
  249. package/dist/utils/token-estimation.d.ts.map +1 -0
  250. package/dist/utils/token-estimation.js +71 -0
  251. package/dist/utils/token-estimation.js.map +1 -0
  252. package/dist/utils/token-logging.d.ts +48 -0
  253. package/dist/utils/token-logging.d.ts.map +1 -0
  254. package/dist/utils/token-logging.js +112 -0
  255. package/dist/utils/token-logging.js.map +1 -0
  256. package/dist/utils/vcs-adapter.d.ts +68 -0
  257. package/dist/utils/vcs-adapter.d.ts.map +1 -0
  258. package/dist/utils/vcs-adapter.js +187 -0
  259. package/dist/utils/vcs-adapter.js.map +1 -0
  260. package/dist/utils/view-queries.d.ts +34 -0
  261. package/dist/utils/view-queries.d.ts.map +1 -0
  262. package/dist/utils/view-queries.js +192 -0
  263. package/dist/utils/view-queries.js.map +1 -0
  264. package/dist/watcher/file-watcher.d.ts +54 -4
  265. package/dist/watcher/file-watcher.d.ts.map +1 -1
  266. package/dist/watcher/file-watcher.js +329 -33
  267. package/dist/watcher/file-watcher.js.map +1 -1
  268. package/dist/watcher/gitignore-parser.d.ts +70 -0
  269. package/dist/watcher/gitignore-parser.d.ts.map +1 -0
  270. package/dist/watcher/gitignore-parser.js +191 -0
  271. package/dist/watcher/gitignore-parser.js.map +1 -0
  272. package/dist/watcher/index.d.ts +1 -0
  273. package/dist/watcher/index.d.ts.map +1 -1
  274. package/dist/watcher/index.js +1 -0
  275. package/dist/watcher/index.js.map +1 -1
  276. package/docs/AI_AGENT_GUIDE.md +1 -1
  277. package/docs/ARCHITECTURE.md +12 -0
  278. package/docs/AUTO_FILE_TRACKING.md +486 -82
  279. package/docs/BEST_PRACTICES.md +56 -448
  280. package/docs/CONFIGURATION.md +908 -0
  281. package/docs/GIT_AWARE_AUTO_COMPLETE.md +645 -0
  282. package/docs/MIGRATION_v3.3.md +602 -0
  283. package/docs/MIGRATION_v3.6.0.md +170 -0
  284. package/docs/SHARED_CONCEPTS.md +65 -209
  285. package/docs/TASK_ACTIONS.md +12 -0
  286. package/docs/TASK_OVERVIEW.md +125 -24
  287. package/docs/TASK_PRUNING.md +589 -0
  288. package/docs/TASK_SYSTEM.md +83 -13
  289. package/docs/TOOL_REFERENCE.md +94 -6
  290. package/docs/TOOL_SELECTION.md +41 -248
  291. package/package.json +21 -7
@@ -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
 
@@ -159,181 +114,82 @@ type TaskStatus =
159
114
  - `done` → `archived`
160
115
  - `archived` → (terminal state, no transitions)
161
116
 
162
- **Auto-Stale Detection**:
117
+ **Auto-Stale Detection & Auto-Archive**:
163
118
  - `in_progress` >2 hours → auto-move to `waiting_review`
164
119
  - `waiting_review` >24 hours → auto-move to `todo`
120
+ - `done` >48 hours → auto-move to `archived` (weekend-aware)
165
121
 
166
122
  ---
167
123
 
168
- ## Atomic Mode Explained
169
-
170
- ### What is Atomic Mode?
171
-
172
- **Atomic mode** determines how batch operations handle failures:
173
-
174
- - **`atomic: true`** (All-or-Nothing)
175
- - ALL operations succeed, or ALL fail
176
- - Uses database transactions
177
- - Rollback on any error
178
- - Data consistency guaranteed
179
-
180
- - **`atomic: false`** (Best-Effort)
181
- - Each operation attempted independently
182
- - Partial success possible
183
- - Failed items reported in response
184
- - Maximum throughput
185
-
186
- ### When to Use Each Mode
187
-
188
- #### Use `atomic: true` (Default) When:
189
- - **Data consistency is critical**
190
- - Financial transactions
191
- - Multi-step workflows that must complete together
192
- - Related records that must all exist or none exist
193
-
194
- - **Validation is important**
195
- - You want to validate ALL items before committing ANY
196
- - One invalid item should prevent all changes
197
-
198
- - **Examples**:
199
- ```typescript
200
- // All 3 decisions must be set together or none at all
201
- set_batch({
202
- decisions: [
203
- { key: "auth_method", value: "jwt", layer: "infrastructure" },
204
- { key: "session_timeout", value: "3600", layer: "infrastructure" },
205
- { key: "refresh_token_enabled", value: "true", layer: "infrastructure" }
206
- ],
207
- atomic: true // If any fails, rollback all
208
- })
209
- ```
210
-
211
- #### Use `atomic: false` When:
212
- - **Partial success is acceptable**
213
- - Bulk imports where some failures are expected
214
- - Idempotent operations (safe to retry)
215
- - Performance is critical
216
-
217
- - **AI agents making best-effort updates**
218
- - Don't want one bad item to block all others
219
- - Can handle partial success in response
220
-
221
- - **Examples**:
222
- ```typescript
223
- // Try to send all messages, report which ones failed
224
- send_batch({
225
- messages: [/* 50 messages */],
226
- atomic: false // Send as many as possible
227
- })
228
- ```
229
-
230
- ### Batch Operation Support
231
-
232
- Currently supported in:
233
- - `decision` tool: `action: "set_batch"` (atomic parameter available)
234
- - `message` tool: `action: "send_batch"` (atomic parameter available)
235
- - `file` tool: `action: "record_batch"` (atomic parameter available)
236
- - `task` tool: `action: "batch_create"` (atomic parameter available)
237
-
238
- ### Performance Implications
239
-
240
- - **Atomic mode (`atomic: true`)**:
241
- - Slower (transaction overhead)
242
- - Higher memory usage (holds all changes until commit)
243
- - Safer (guaranteed consistency)
244
-
245
- - **Non-atomic mode (`atomic: false`)**:
246
- - Faster (no transaction overhead)
247
- - Lower memory usage (commit per operation)
248
- - More flexible (partial success handling)
124
+ ## Atomic Mode
249
125
 
250
- ---
126
+ Determines batch operation failure handling:
251
127
 
252
- ## Action Parameter Requirement
128
+ **`atomic: true`** (All-or-Nothing) - Default
129
+ - ALL succeed or ALL fail
130
+ - Database transaction with rollback
131
+ - Guaranteed consistency
253
132
 
254
- ### Why is `action` Required?
133
+ **`atomic: false`** (Best-Effort)
134
+ - Independent operations
135
+ - Partial success possible
136
+ - Failed items reported
255
137
 
256
- **All MCP tools in this system use action-based routing**. The `action` parameter is **REQUIRED** in every tool call.
138
+ ### When to Use
257
139
 
258
- ### Design Rationale
140
+ **Use `atomic: true`** for:
141
+ - Critical data consistency (financial, multi-step workflows)
142
+ - All-or-nothing validation
259
143
 
260
- 1. **Token Efficiency** (96% reduction achieved)
261
- - Single tool with multiple actions vs. many separate tools
262
- - 20 tools 7 tools (v2.0.0 → v3.0.0)
263
- - 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
264
148
 
265
- 2. **Logical Grouping**
266
- - Related operations grouped in one tool
267
- - `decision` tool handles all decision operations
268
- - `message` tool handles all messaging operations
269
- - Etc.
149
+ ### Supported Tools
150
+ - `decision`: `set_batch`
151
+ - `message`: `send_batch`
152
+ - `file`: `record_batch`
153
+ - `task`: `batch_create`
270
154
 
271
- 3. **Discoverability**
272
- - Each tool's actions are documented together
273
- - `action: "help"` provides on-demand documentation
274
- - Reduces upfront token cost (no documentation until requested)
155
+ ---
275
156
 
276
- ### Common Error
157
+ ## Action Parameter
277
158
 
278
- ```json
279
- ❌ ERROR: "Unknown action: undefined"
280
- ```
159
+ **`action` parameter is REQUIRED in all tool calls**
281
160
 
282
- **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"`
283
165
 
284
- **Fix**: Always include `action` as the first parameter:
166
+ ### Common Error
285
167
  ```json
286
- CORRECT:
287
- {
288
- "action": "get",
289
- "key": "auth_method"
290
- }
291
-
292
- ❌ INCORRECT:
293
- {
294
- "key": "auth_method" // Missing action parameter
295
- }
296
- ```
297
-
298
- ### Available Actions by Tool
299
-
300
- - **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`
301
- - **message**: `send`, `get`, `mark_read`, `send_batch`, `help`
302
- - **file**: `record`, `get`, `check_lock`, `record_batch`, `help`
303
- - **constraint**: `add`, `get`, `deactivate`, `help`
304
- - **stats**: `layer_summary`, `db_stats`, `clear`, `activity_log`, `flush`, `help`
305
- - **config**: `get`, `update`, `help`
306
- - **task**: `create`, `update`, `get`, `list`, `move`, `link`, `archive`, `batch_create`, `help`
307
-
308
- ### Getting Help
168
+ ERROR: "Unknown action: undefined"
309
169
 
310
- Every tool supports `action: "help"` for comprehensive documentation:
311
- ```json
312
- {
313
- "action": "help"
314
- }
170
+ // Fix: Always include action
171
+ ✅ { "action": "get", "key": "auth_method" }
172
+ { "key": "auth_method" }
315
173
  ```
316
174
 
317
- 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
318
184
 
319
185
  ---
320
186
 
321
187
  ## Database Enum Mappings
322
188
 
323
- 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):
324
190
 
325
191
  - **status**: 1=active, 2=deprecated, 3=draft
326
192
  - **msg_type**: 1=decision, 2=warning, 3=request, 4=info
327
193
  - **priority**: 1=low, 2=medium, 3=high, 4=critical
328
194
  - **change_type**: 1=created, 2=modified, 3=deleted
329
195
  - **task_status**: 1=todo, 2=in_progress, 3=waiting_review, 4=blocked, 5=done, 6=archived
330
-
331
- The MCP tools handle string↔integer conversion automatically. Always use string values in tool calls.
332
-
333
- ---
334
-
335
- ## Version History
336
-
337
- - **v3.0.0**: Added task_status enum and Auto-Stale Detection section
338
- - **v2.1.0**: Added Atomic Mode Explained section
339
- - **v2.0.0**: Initial creation with action-based API concepts
@@ -562,6 +562,8 @@ Link task to decision, constraint, or file.
562
562
 
563
563
  Archive completed task (soft delete).
564
564
 
565
+ **Note:** Tasks in `done` status are automatically archived after 48 hours (configurable via `auto_archive_done_days`). Manual archiving is useful for immediate archival needs.
566
+
565
567
  ### Parameters
566
568
 
567
569
  **Required:**
@@ -570,6 +572,7 @@ Archive completed task (soft delete).
570
572
 
571
573
  ### Example
572
574
 
575
+ **Manual Archive:**
573
576
  ```javascript
574
577
  {
575
578
  action: "archive",
@@ -577,6 +580,15 @@ Archive completed task (soft delete).
577
580
  }
578
581
  ```
579
582
 
583
+ **Auto-Archive Configuration:**
584
+ ```javascript
585
+ // Change auto-archive threshold (via config tool)
586
+ {
587
+ action: "update",
588
+ auto_archive_done_days: "3" // Archive after 3 days instead of default 2 days
589
+ }
590
+ ```
591
+
580
592
  ### Response (Success)
581
593
 
582
594
  ```javascript