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
@@ -763,10 +763,15 @@ Auto-stale detection automatically transitions idle tasks to prevent them from g
763
763
 
764
764
  The logic:
765
765
  1. Check if enabled via `task_auto_stale_enabled` config
766
- 2. Get threshold hours from config (2h for in_progress, 24h for waiting_review)
766
+ 2. Get threshold hours/days from config
767
767
  3. Run SQL UPDATE to transition stale tasks based on `updated_ts`
768
768
  4. Return count of transitioned tasks
769
769
 
770
+ **Transition Rules:**
771
+ 1. **`in_progress` → `waiting_review`** (>2 hours idle)
772
+ 2. **`waiting_review` → `todo`** (>24 hours idle)
773
+ 3. **`done` → `archived`** (>48 hours idle, weekend-aware) - **Auto-Archive**
774
+
770
775
  SQL Pattern:
771
776
  ```sql
772
777
  UPDATE t_tasks
@@ -779,38 +784,67 @@ WHERE status_id = ? AND updated_ts < unixepoch() - ?
779
784
  1. **Before `list` action**
780
785
  - Ensures stale tasks show correct status
781
786
  - Returns `stale_tasks_transitioned` count
787
+ - Returns `archived_tasks` count
782
788
 
783
789
  2. **Before `move` action**
784
790
  - Prevents moving already-stale tasks
785
791
  - Ensures status consistency
786
792
 
793
+ 3. **On database startup**
794
+ - Maintenance on initialization
795
+ - Cleans up stale/old tasks
796
+
787
797
  ### Configuration
788
798
 
789
- **Enable/Disable:**
799
+ **Via MCP Tool (config):**
800
+ ```javascript
801
+ // Update auto-archive threshold
802
+ {
803
+ action: "update",
804
+ auto_archive_done_days: "3" // Archive after 3 days instead of 2
805
+ }
806
+
807
+ // Enable weekend-aware mode (affects auto-archive, messages, files)
808
+ {
809
+ action: "update",
810
+ autodelete_ignore_weekend: "1"
811
+ }
812
+ ```
813
+
814
+ **Via .sqlew/config.toml:**
815
+ ```toml
816
+ [tasks]
817
+ auto_archive_done_days = 3 # Archive after 3 days
818
+ stale_hours_in_progress = 4 # in_progress → waiting_review after 4 hours
819
+ stale_hours_waiting_review = 48 # waiting_review → todo after 48 hours
820
+ auto_stale_enabled = true
821
+
822
+ [autodelete]
823
+ ignore_weekend = true # Weekend-aware mode (shared setting)
824
+ ```
825
+
826
+ **Via SQL (Advanced):**
790
827
  ```sql
828
+ -- Enable/Disable
791
829
  UPDATE m_config SET value = '1' WHERE key = 'task_auto_stale_enabled'; -- Enable
792
830
  UPDATE m_config SET value = '0' WHERE key = 'task_auto_stale_enabled'; -- Disable
793
- ```
794
831
 
795
- **Adjust Thresholds:**
796
- ```sql
797
- -- in_progress → waiting_review after 4 hours
798
- UPDATE m_config SET value = '4' WHERE key = 'task_stale_hours_in_progress';
832
+ -- Adjust auto-archive threshold
833
+ UPDATE m_config SET value = '3' WHERE key = 'auto_archive_done_days'; -- 3 days
799
834
 
800
- -- waiting_review todo after 48 hours
835
+ -- Adjust stale detection thresholds
836
+ UPDATE m_config SET value = '4' WHERE key = 'task_stale_hours_in_progress';
801
837
  UPDATE m_config SET value = '48' WHERE key = 'task_stale_hours_waiting_review';
802
- ```
803
838
 
804
- **Check Current Config:**
805
- ```sql
806
- SELECT key, value FROM m_config WHERE key LIKE 'task_%';
839
+ -- Check current config
840
+ SELECT key, value FROM m_config WHERE key LIKE 'task_%' OR key LIKE 'auto_%';
807
841
  ```
808
842
 
809
843
  ### Monitoring
810
844
 
811
845
  Track transitions via `t_activity_log` table:
812
846
  ```sql
813
- -- Recent transitions
847
+ -- Recent transitions (including auto-archive)
814
848
  SELECT * FROM t_activity_log
815
849
  WHERE entity_type = 'task' AND action_type = 'status_change'
816
850
  ORDER BY ts DESC LIMIT 20;
@@ -819,8 +853,44 @@ ORDER BY ts DESC LIMIT 20;
819
853
  SELECT task_id, COUNT(*) as stale_count FROM t_activity_log
820
854
  WHERE entity_type = 'task' AND json_extract(details, '$.new_status') = 3
821
855
  GROUP BY task_id HAVING stale_count > 2;
856
+
857
+ -- Recently auto-archived tasks
858
+ SELECT * FROM t_activity_log
859
+ WHERE entity_type = 'task'
860
+ AND action_type = 'status_change'
861
+ AND json_extract(details, '$.new_status') = 6 -- ARCHIVED status
862
+ ORDER BY ts DESC LIMIT 20;
863
+
864
+ -- Count of archived tasks per day
865
+ SELECT date(ts, 'unixepoch') as day, COUNT(*) as archived_count
866
+ FROM t_activity_log
867
+ WHERE entity_type = 'task'
868
+ AND action_type = 'status_change'
869
+ AND json_extract(details, '$.new_status') = 6
870
+ GROUP BY day
871
+ ORDER BY day DESC;
822
872
  ```
823
873
 
874
+ ### Weekend-Aware Behavior
875
+
876
+ When `autodelete_ignore_weekend` is enabled (via config.toml or MCP tool):
877
+
878
+ **Example 1 - Task Completed on Friday:**
879
+ - Task marked `done`: Friday 5:00 PM
880
+ - Default 48 hours: Would archive Sunday 5:00 PM
881
+ - **Weekend-aware**: Archives Tuesday 5:00 PM (skips Sat/Sun)
882
+
883
+ **Example 2 - Task Completed on Wednesday:**
884
+ - Task marked `done`: Wednesday 2:00 PM
885
+ - Default 48 hours: Would archive Friday 2:00 PM
886
+ - **Weekend-aware**: Archives Friday 2:00 PM (no weekend in between)
887
+
888
+ **Why Weekend-Aware Mode?**
889
+ - Teams/AI agents may not work on weekends
890
+ - Prevents premature archiving during weekend breaks
891
+ - Consistent with message/file retention behavior
892
+ - Configurable: Disable if you work 7 days/week
893
+
824
894
  ## Linking System
825
895
 
826
896
  ### Overview
@@ -149,14 +149,19 @@
149
149
 
150
150
  | Action | Required | Optional |
151
151
  |--------|----------|----------|
152
- | **create** | action, title | description, acceptance_criteria, notes, priority, assigned_agent, created_by_agent, layer, tags, status |
153
- | **update** | action, task_id | title, priority, assigned_agent, layer, description, acceptance_criteria, notes |
154
- | **get** | action, task_id | - |
155
- | **list** | action | status, assigned_agent, layer, tags, limit, offset |
152
+ | **create** | action, title | description, acceptance_criteria, notes, priority, assigned_agent, created_by_agent, layer, tags, status, **watch_files** (v3.4.1) |
153
+ | **update** | action, task_id | title, priority, assigned_agent, layer, description, acceptance_criteria, notes, **watch_files** (v3.4.1) |
154
+ | **get** | action, task_id | include_dependencies |
155
+ | **list** | action | status, assigned_agent, layer, tags, limit, offset, include_dependency_counts |
156
156
  | **move** | action, task_id, new_status | - |
157
- | **link** | action, task_id, link_type, target_id | link_relation |
157
+ | **link** | action, task_id, link_type, target_id | link_relation (⚠️ link_type="file" deprecated in v3.4.1) |
158
158
  | **archive** | action, task_id | - |
159
159
  | **batch_create** | action, tasks | atomic |
160
+ | **add_dependency** | action, blocker_task_id, blocked_task_id | - |
161
+ | **remove_dependency** | action, blocker_task_id, blocked_task_id | - |
162
+ | **get_dependencies** | action, task_id | include_details |
163
+ | **watch_files** (v3.4.1) | action, task_id, action (watch/unwatch/list) | file_paths |
164
+ | **watcher** | action | subaction (status/list_files/list_tasks/help) |
160
165
 
161
166
  ---
162
167
 
@@ -323,6 +328,89 @@
323
328
 
324
329
  ---
325
330
 
331
+ ## File Watching with Tasks (v3.4.1)
332
+
333
+ ### New: watch_files Parameter
334
+
335
+ **Replaces:** `task.link(link_type="file")` (deprecated in v3.4.1)
336
+
337
+ Create tasks with automatic file monitoring in one step:
338
+
339
+ ```javascript
340
+ {
341
+ action: "create",
342
+ title: "Implement user authentication",
343
+ watch_files: ["src/auth.ts", "src/auth.test.ts"],
344
+ acceptance_criteria: [
345
+ {type: "tests_pass", command: "npm test auth", expected_pattern: "passing"},
346
+ {type: "code_contains", file: "src/auth.ts", pattern: "export class AuthService"}
347
+ ],
348
+ priority: 3,
349
+ assigned_agent: "backend-dev"
350
+ }
351
+ ```
352
+
353
+ **Benefits:**
354
+ - 75% fewer MCP calls (1 call vs 4 calls in v3.2.x)
355
+ - 35% token reduction
356
+ - Clearer intent
357
+ - Atomic file registration
358
+
359
+ ### New: watch_files Action
360
+
361
+ Manage file watches dynamically:
362
+
363
+ ```javascript
364
+ // Watch files
365
+ {
366
+ action: "watch_files",
367
+ task_id: 123,
368
+ action: "watch",
369
+ file_paths: ["src/auth.ts", "src/middleware/jwt.ts"]
370
+ }
371
+
372
+ // Unwatch files
373
+ {
374
+ action: "watch_files",
375
+ task_id: 123,
376
+ action: "unwatch",
377
+ file_paths: ["src/middleware/jwt.ts"]
378
+ }
379
+
380
+ // List watched files
381
+ {
382
+ action: "watch_files",
383
+ task_id: 123,
384
+ action: "list"
385
+ }
386
+ // Response: { files: ["src/auth.ts"], files_count: 1 }
387
+ ```
388
+
389
+ ### Migration from v3.2.x
390
+
391
+ **Before (deprecated):**
392
+ ```javascript
393
+ // Create task
394
+ {action: "create", title: "Feature"}
395
+ // Link files (separate calls)
396
+ {action: "link", task_id: 123, link_type: "file", target_id: "src/file1.ts"}
397
+ {action: "link", task_id: 123, link_type: "file", target_id: "src/file2.ts"}
398
+ ```
399
+
400
+ **After (v3.4.1):**
401
+ ```javascript
402
+ // Create task with files in one call
403
+ {
404
+ action: "create",
405
+ title: "Feature",
406
+ watch_files: ["src/file1.ts", "src/file2.ts"]
407
+ }
408
+ ```
409
+
410
+ **See Also:** [MIGRATION_v3.3.md](./MIGRATION_v3.3.md) for complete migration guide.
411
+
412
+ ---
413
+
326
414
  ## Decision Context System (v3.2.2)
327
415
 
328
416
  ### What is Decision Context?
@@ -590,7 +678,7 @@ Quick reference:
590
678
  - **waiting_review**: Completed, awaiting review
591
679
  - **blocked**: Cannot proceed due to blocker
592
680
  - **done**: Completed successfully
593
- - **archived**: No longer relevant
681
+ - **archived**: Completed and archived (auto-archived after 48 hours)
594
682
 
595
683
  ### Constraint Categories
596
684
 
@@ -1,51 +1,6 @@
1
1
  # Tool Selection Guide
2
2
 
3
- **Quick reference for choosing the right sqlew tool for your task**
4
-
5
- ## Understanding Tool Purposes
6
-
7
- Each tool serves a distinct purpose in the MCP sqlew ecosystem:
8
-
9
- ```
10
- ┌──────────────────────────────────────────────────────────┐
11
- │ What do you need to do? │
12
- └────────────────┬─────────────────────────────────────────┘
13
-
14
- ├─ Record a CHOICE that was made?
15
- │ └─> Use `decision` tool
16
- │ • Examples: "We chose JWT auth", "Selected PostgreSQL"
17
- │ • Key: Captures PAST decisions
18
- │ • Supports: versioning, tags, layers, scopes
19
-
20
- ├─ Communicate with other agents?
21
- │ └─> Use `message` tool
22
- │ • Examples: Task updates, warnings, requests
23
- │ • Key: Real-time communication
24
- │ • Supports: priority, broadcast, read tracking
25
-
26
- ├─ Define a REQUIREMENT that must be followed?
27
- │ └─> Use `constraint` tool
28
- │ • Examples: "API must be <100ms", "Code coverage >80%"
29
- │ • Key: Enforces RULES
30
- │ • Supports: priority, categories, layers
31
-
32
- ├─ Track WORK to be done?
33
- │ └─> Use `task` tool
34
- │ • Examples: "Implement feature X", "Fix bug Y"
35
- │ • Key: Tracks TODO items and progress
36
- │ • Supports: status transitions, auto-stale, linking
37
-
38
- ├─ Record file modifications?
39
- │ └─> Use `file` tool
40
- │ • Examples: Track changes, check locks
41
- │ • Key: File change history
42
- │ • Supports: layers, change types, lock detection
43
-
44
- └─ Get statistics or manage data?
45
- └─> Use `stats` or `config` tools
46
- • stats: Database metrics, cleanup, activity logs
47
- • config: Retention settings, auto-deletion
48
- ```
3
+ **Quick reference for choosing the right tool**
49
4
 
50
5
  ## Tool Comparison Table
51
6
 
@@ -61,219 +16,57 @@ Each tool serves a distinct purpose in the MCP sqlew ecosystem:
61
16
 
62
17
  ## Decision vs Constraint vs Task
63
18
 
64
- This is the most common confusion. Here's the distinction:
65
-
66
- | Concept | Definition | Example | Tool |
67
- |---------|------------|---------|------|
68
- | **Decision** | A choice that WAS made | "We chose JWT authentication" | `decision` |
69
- | **Constraint** | A requirement that MUST be followed | "Response time must be <100ms" | `constraint` |
70
- | **Task** | Work that NEEDS to be done | "Implement JWT authentication" | `task` |
71
-
72
- ## ⚠️ Decision vs Task: WHY vs WHAT
73
-
74
- **Critical distinction**: `decision` stores WHY (reasoning), `task` stores WHAT (work status).
75
-
76
- | Question | Answer | Tool |
77
- |----------|--------|------|
78
- | **WHY** did we choose this approach? | "Chose JWT because stateless auth scales horizontally" | **decision** |
79
- | **WHAT** needs to be done? | "Implement JWT authentication (status: in_progress)" | **task** |
80
- | **WHY** was this bug introduced? | "Nested transaction bug: setDecision wraps in transaction, batch also wraps" | **decision** |
81
- | **WHAT** is the completion status? | "Fixed nested transaction bug (status: done)" | **task** |
82
-
83
- ### Common Mistakes
84
-
85
- ```javascript
86
- // ❌ WRONG - Using decision for task completion
87
- {
88
- action: "set",
89
- key: "jwt-implementation-complete",
90
- value: "JWT authentication implemented. All tests passing."
91
- }
92
- // This is WHAT was done (completion status), not WHY decisions were made.
93
- // FIX: Use task tool for tracking implementation progress.
94
-
95
- // ✅ CORRECT - Using decision for architectural reasoning
96
- {
97
- action: "set",
98
- key: "api/auth/jwt-choice",
99
- value: "Chose JWT over sessions because: (1) Stateless design scales, (2) Mobile clients cache tokens, (3) Microservice auth requires distributed validation."
100
- }
101
- // This explains WHY JWT was chosen with architectural reasoning.
102
-
103
- // ✅ CORRECT - Using task for work tracking
104
- {
105
- action: "create",
106
- title: "Implement JWT authentication with refresh tokens",
107
- status: "in_progress",
108
- assigned_agent: "backend-agent"
109
- }
110
- // This tracks WHAT work is being done and its current status.
111
- ```
112
-
113
- 💡 **See [BEST_PRACTICES.md](BEST_PRACTICES.md#critical-what-to-store-in-decisions) for detailed examples of WHY vs WHAT.**
114
-
115
- ## Scenario-Based Tool Selection
116
-
117
- ### Scenario 1: Breaking API Change
118
-
119
- ```javascript
120
- // 1. Record the decision (WHY the change was necessary)
121
- {
122
- action: "set",
123
- key: "api/v2/versioning-decision",
124
- value: "Moved /users to /v2/users because: (1) Enables backward compatibility via versioning, (2) Allows gradual client migration without breaking production apps, (3) Future API changes won't force all clients to update simultaneously. Trade-off: More complex routing layer, but necessary for production stability with 50+ client apps.",
125
- layer: "presentation",
126
- tags: ["api", "versioning", "architecture-decision"]
127
- }
128
-
129
- // 2. Add a constraint (requirement going forward)
130
- {
131
- action: "add",
132
- category: "architecture",
133
- constraint_text: "All API endpoints must include version prefix",
134
- layer: "presentation",
135
- tags: ["api", "versioning"]
136
- }
137
-
138
- // 3. Create migration task
139
- {
140
- action: "create",
141
- title: "Migrate clients to /v2/users endpoint",
142
- status: "todo",
143
- layer: "presentation",
144
- tags: ["migration", "v2.0.0"]
145
- }
146
-
147
- // 4. Notify other agents
148
- {
149
- action: "send",
150
- from_agent: "api-agent",
151
- msg_type: "warning",
152
- message: "Breaking change: /users moved to /v2/users",
153
- priority: "critical"
154
- }
155
- ```
156
-
157
- ### Scenario 2: Performance Issue
158
-
159
- ```javascript
160
- // 1. Record the analysis and solution decision (WHY this approach)
161
- {
162
- action: "set",
163
- key: "db/user_sessions/index-strategy",
164
- value: "Adding composite index (user_id, created_at DESC) to user_sessions table because: (1) Query analysis shows 300% latency increase from full table scans on 10M+ rows, (2) 95% of queries filter by user_id + sort by timestamp, (3) Index reduces query time from 850ms to <50ms in staging tests. Trade-off: 15% slower inserts and 200MB additional storage, but read performance critical for user experience.",
165
- layer: "data",
166
- tags: ["performance", "database", "indexing-strategy"]
167
- }
168
-
169
- // 2. Add performance constraint
170
- {
171
- action: "add",
172
- category: "performance",
173
- constraint_text: "Database queries must complete within 50ms",
174
- priority: "high",
175
- layer: "data"
176
- }
177
-
178
- // 3. Create optimization task
179
- {
180
- action: "create",
181
- title: "Add indexes to user_sessions table",
182
- status: "in_progress",
183
- priority: 4,
184
- layer: "data",
185
- tags: ["performance", "database"]
186
- }
187
- ```
188
-
189
- ### Scenario 3: Security Vulnerability
19
+ | Concept | Definition | Example |
20
+ |---------|------------|---------|
21
+ | **Decision** | A choice that WAS made | "We chose JWT authentication" |
22
+ | **Constraint** | A requirement that MUST be followed | "Response time must be <100ms" |
23
+ | **Task** | Work that NEEDS to be done | "Implement JWT authentication" |
190
24
 
191
- ```javascript
192
- // 1. Record the solution decision (WHY this mitigation approach)
193
- {
194
- action: "set",
195
- key: "security/jwt/timing-attack-mitigation",
196
- value: "Upgrading JWT library to v9.2.0+ and implementing constant-time comparison because: (1) CVE-2025-1234 timing attack allows token forgery via timing analysis, (2) Library v9.2.0+ includes constant-time string comparison preventing timing leaks, (3) Alternative approach (rewriting auth layer) would take 3 weeks vs 2-day upgrade. Trade-off: Breaking change requires updating all microservices, but security risk is critical and affects all user sessions.",
197
- layer: "business",
198
- tags: ["security", "authentication", "mitigation-strategy"]
199
- }
25
+ ## Decision vs Task: WHY vs WHAT
200
26
 
201
- // 2. Add security constraint
202
- {
203
- action: "add",
204
- category: "security",
205
- constraint_text: "All auth tokens must use constant-time comparison",
206
- priority: "critical",
207
- layer: "business"
208
- }
27
+ **Critical**: `decision` = WHY (reasoning), `task` = WHAT (work status)
209
28
 
210
- // 3. Create fix task
211
- {
212
- action: "create",
213
- title: "Upgrade JWT library and implement constant-time comparison",
214
- status: "in_progress",
215
- priority: 4,
216
- assigned_agent: "security-agent",
217
- layer: "business"
218
- }
29
+ | Question | Tool |
30
+ |----------|------|
31
+ | WHY did we choose this? | **decision** |
32
+ | WHAT needs to be done? | **task** |
33
+ | WHY was this bug introduced? | **decision** |
34
+ | WHAT is the completion status? | **task** |
219
35
 
220
- // 4. Alert all agents
221
- {
222
- action: "send",
223
- from_agent: "security-agent",
224
- to_agent: null, // Broadcast
225
- msg_type: "warning",
226
- message: "URGENT: Auth vulnerability found, fix in progress",
227
- priority: "critical"
228
- }
229
- ```
36
+ ## Common Scenarios
230
37
 
231
- ## Search Actions Decision Tree
38
+ **Breaking API Change:**
39
+ 1. `decision` - Record WHY change was necessary with reasoning
40
+ 2. `constraint` - Add requirement for version prefixes going forward
41
+ 3. `task` - Create migration work item
42
+ 4. `message` - Alert other agents
232
43
 
233
- ### When to use which search action?
44
+ **Performance Issue:**
45
+ 1. `decision` - Record analysis and WHY this solution
46
+ 2. `constraint` - Add performance requirement
47
+ 3. `task` - Create optimization work item
234
48
 
235
- ```
236
- ┌─────────────────────────────────────┐
237
- What do you want to search by? │
238
- └──────────┬──────────────────────────┘
239
-
240
- ├─ Simple filters (status, layer, tags)?
241
- │ └─> Use action: "list"
242
-
243
- ├─ Primarily by tags?
244
- │ └─> Use action: "search_tags"
245
- │ • match_mode: "AND" (all tags) or "OR" (any tag)
246
-
247
- ├─ Primarily by layer?
248
- │ └─> Use action: "search_layer"
249
-
250
- ├─ Complex multi-filter query?
251
- │ └─> Use action: "search_advanced"
252
- │ • Multiple layers (OR)
253
- │ • Tag combinations (AND/OR)
254
- │ • Temporal filtering
255
- │ • Full-text search
256
- │ • Pagination
257
-
258
- └─ Need version history?
259
- └─> Use action: "versions"
260
- ```
49
+ **Security Vulnerability:**
50
+ 1. `decision` - Record WHY this mitigation approach
51
+ 2. `constraint` - Add security requirement
52
+ 3. `task` - Create fix work item
53
+ 4. `message` - Alert all agents
261
54
 
262
- ### Detailed Search Comparison
55
+ ## Search Action Selection
263
56
 
264
- | Action | Use When | Key Features |
265
- |--------|----------|--------------|
266
- | **list** | Basic filtering | Simple status/layer/tag filters, no pagination |
267
- | **search_tags** | Tag-focused search | AND/OR logic for tags, optional status/layer |
268
- | **search_layer** | Layer-focused search | Get all decisions in specific layer(s) |
269
- | **search_advanced** | Complex queries | Full filtering, pagination, sorting, text search |
270
- | **versions** | History tracking | Get all versions of a specific decision |
57
+ | Action | Use For |
58
+ |--------|---------|
59
+ | **list** | Simple status/layer/tag filters |
60
+ | **search_tags** | Tag-focused with AND/OR logic |
61
+ | **search_layer** | Layer-focused queries |
62
+ | **search_advanced** | Complex multi-filter, pagination, full-text |
63
+ | **versions** | Version history of specific decision |
271
64
 
272
65
  ---
273
66
 
274
67
  ## Related Documentation
275
68
 
276
- - **[TOOL_REFERENCE.md](TOOL_REFERENCE.md)** - Complete parameter reference for all tools
277
- - **[WORKFLOWS.md](WORKFLOWS.md)** - Multi-step workflow examples
278
- - **[BEST_PRACTICES.md](BEST_PRACTICES.md)** - Common errors and best practices
279
- - **[ARCHITECTURE.md](ARCHITECTURE.md)** - Layer definitions and system architecture
69
+ - [TOOL_REFERENCE.md](TOOL_REFERENCE.md) - Parameter reference
70
+ - [WORKFLOWS.md](WORKFLOWS.md) - Multi-step workflows
71
+ - [BEST_PRACTICES.md](BEST_PRACTICES.md) - Common errors
72
+ - [SHARED_CONCEPTS.md](SHARED_CONCEPTS.md) - Layers, enums, concepts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sqlew",
3
- "version": "3.2.5",
4
- "description": "MCP server for efficient context sharing between Claude Code sub-agents with Kanban Task Watcher, Decision Context, auto-file-tracking, and 60-75% token reduction in multi-session projects",
3
+ "version": "3.6.0",
4
+ "description": "MCP server for efficient context sharing between Claude Code sub-agents with database-driven help system (60-70% token reduction), Kanban Task Watcher, Git-aware auto-complete, Decision Context, and streamlined documentation",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -28,7 +28,15 @@
28
28
  "rebuild": "npm run clean && npm run build",
29
29
  "test": "npm run build && node --test dist/tests/tasks.dependencies.test.js",
30
30
  "test:migrations": "npm run build && node dist/tests/migrations/test-v3.2-migration.js",
31
- "prepublishOnly": "npm run rebuild"
31
+ "prepublishOnly": "npm run rebuild",
32
+ "knex": "tsx node_modules/.bin/knex --knexfile src/knexfile.ts",
33
+ "migrate:make": "npm run knex migrate:make",
34
+ "migrate:latest": "npm run knex migrate:latest",
35
+ "migrate:rollback": "npm run knex migrate:rollback",
36
+ "migrate:rollback:all": "npm run knex migrate:rollback --all",
37
+ "migrate:status": "npm run knex migrate:status",
38
+ "seed:make": "npm run knex seed:make",
39
+ "seed:run": "npm run knex seed:run"
32
40
  },
33
41
  "engines": {
34
42
  "node": ">=18.0.0"
@@ -55,13 +63,19 @@
55
63
  "author": "sin5ddd",
56
64
  "license": "AGPL-3.0",
57
65
  "dependencies": {
58
- "better-sqlite3": "^11.0.0",
59
66
  "@modelcontextprotocol/sdk": "latest",
60
- "chokidar": "^3.6.0"
67
+ "better-sqlite3": "^11.0.0",
68
+ "chokidar": "^4.0.3",
69
+ "ignore": "^7.0.5",
70
+ "knex": "^3.1.0",
71
+ "smol-toml": "^1.4.2",
72
+ "sqlite3": "^5.1.7"
61
73
  },
62
74
  "devDependencies": {
63
- "typescript": "^5.0.0",
64
75
  "@types/better-sqlite3": "^7.6.0",
65
- "@types/node": "^20.0.0"
76
+ "@types/knex": "^0.15.2",
77
+ "@types/node": "^20.0.0",
78
+ "tsx": "^4.20.6",
79
+ "typescript": "^5.0.0"
66
80
  }
67
81
  }