sqlew 3.2.5 → 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +815 -13
  2. package/README.md +53 -2
  3. package/assets/schema.sql +6 -1
  4. package/dist/config/loader.d.ts +46 -0
  5. package/dist/config/loader.d.ts.map +1 -0
  6. package/dist/config/loader.js +151 -0
  7. package/dist/config/loader.js.map +1 -0
  8. package/dist/config/types.d.ts +77 -0
  9. package/dist/config/types.d.ts.map +1 -0
  10. package/dist/config/types.js +28 -0
  11. package/dist/config/types.js.map +1 -0
  12. package/dist/constants.d.ts +9 -0
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +10 -0
  15. package/dist/constants.js.map +1 -1
  16. package/dist/database.d.ts +1 -1
  17. package/dist/database.d.ts.map +1 -1
  18. package/dist/database.js +77 -10
  19. package/dist/database.js.map +1 -1
  20. package/dist/index.js +21 -3
  21. package/dist/index.js.map +1 -1
  22. package/dist/migrations/add-v3.5.0-pruned-files.d.ts +26 -0
  23. package/dist/migrations/add-v3.5.0-pruned-files.d.ts.map +1 -0
  24. package/dist/migrations/add-v3.5.0-pruned-files.js +107 -0
  25. package/dist/migrations/add-v3.5.0-pruned-files.js.map +1 -0
  26. package/dist/migrations/index.d.ts +2 -1
  27. package/dist/migrations/index.d.ts.map +1 -1
  28. package/dist/migrations/index.js +16 -1
  29. package/dist/migrations/index.js.map +1 -1
  30. package/dist/tests/git-aware-completion.test.d.ts +6 -0
  31. package/dist/tests/git-aware-completion.test.d.ts.map +1 -0
  32. package/dist/tests/git-aware-completion.test.js +141 -0
  33. package/dist/tests/git-aware-completion.test.js.map +1 -0
  34. package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts +6 -0
  35. package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts.map +1 -0
  36. package/dist/tests/tasks.auto-pruning-decision-link.test.js +250 -0
  37. package/dist/tests/tasks.auto-pruning-decision-link.test.js.map +1 -0
  38. package/dist/tests/tasks.auto-pruning-partial.test.d.ts +6 -0
  39. package/dist/tests/tasks.auto-pruning-partial.test.d.ts.map +1 -0
  40. package/dist/tests/tasks.auto-pruning-partial.test.js +274 -0
  41. package/dist/tests/tasks.auto-pruning-partial.test.js.map +1 -0
  42. package/dist/tests/tasks.auto-pruning-persistence.test.d.ts +6 -0
  43. package/dist/tests/tasks.auto-pruning-persistence.test.d.ts.map +1 -0
  44. package/dist/tests/tasks.auto-pruning-persistence.test.js +232 -0
  45. package/dist/tests/tasks.auto-pruning-persistence.test.js.map +1 -0
  46. package/dist/tests/tasks.auto-pruning-safety.test.d.ts +12 -0
  47. package/dist/tests/tasks.auto-pruning-safety.test.d.ts.map +1 -0
  48. package/dist/tests/tasks.auto-pruning-safety.test.js +196 -0
  49. package/dist/tests/tasks.auto-pruning-safety.test.js.map +1 -0
  50. package/dist/tests/tasks.link-file-backward-compat.test.d.ts +6 -0
  51. package/dist/tests/tasks.link-file-backward-compat.test.d.ts.map +1 -0
  52. package/dist/tests/tasks.link-file-backward-compat.test.js +235 -0
  53. package/dist/tests/tasks.link-file-backward-compat.test.js.map +1 -0
  54. package/dist/tests/tasks.watch-files-action.test.d.ts +6 -0
  55. package/dist/tests/tasks.watch-files-action.test.d.ts.map +1 -0
  56. package/dist/tests/tasks.watch-files-action.test.js +351 -0
  57. package/dist/tests/tasks.watch-files-action.test.js.map +1 -0
  58. package/dist/tests/tasks.watch-files-parameter.test.d.ts +6 -0
  59. package/dist/tests/tasks.watch-files-parameter.test.d.ts.map +1 -0
  60. package/dist/tests/tasks.watch-files-parameter.test.js +249 -0
  61. package/dist/tests/tasks.watch-files-parameter.test.js.map +1 -0
  62. package/dist/tests/two-step-git-completion.test.d.ts +6 -0
  63. package/dist/tests/two-step-git-completion.test.d.ts.map +1 -0
  64. package/dist/tests/two-step-git-completion.test.js +283 -0
  65. package/dist/tests/two-step-git-completion.test.js.map +1 -0
  66. package/dist/tests/vcs-staging.test.d.ts +6 -0
  67. package/dist/tests/vcs-staging.test.d.ts.map +1 -0
  68. package/dist/tests/vcs-staging.test.js +137 -0
  69. package/dist/tests/vcs-staging.test.js.map +1 -0
  70. package/dist/tools/config.d.ts +4 -2
  71. package/dist/tools/config.d.ts.map +1 -1
  72. package/dist/tools/config.js +13 -11
  73. package/dist/tools/config.js.map +1 -1
  74. package/dist/tools/constraints.d.ts +7 -4
  75. package/dist/tools/constraints.d.ts.map +1 -1
  76. package/dist/tools/constraints.js +19 -16
  77. package/dist/tools/constraints.js.map +1 -1
  78. package/dist/tools/context.d.ts +33 -17
  79. package/dist/tools/context.d.ts.map +1 -1
  80. package/dist/tools/context.js +84 -68
  81. package/dist/tools/context.js.map +1 -1
  82. package/dist/tools/files.d.ts +9 -5
  83. package/dist/tools/files.d.ts.map +1 -1
  84. package/dist/tools/files.js +19 -15
  85. package/dist/tools/files.js.map +1 -1
  86. package/dist/tools/messaging.d.ts +9 -5
  87. package/dist/tools/messaging.d.ts.map +1 -1
  88. package/dist/tools/messaging.js +20 -16
  89. package/dist/tools/messaging.js.map +1 -1
  90. package/dist/tools/tasks.d.ts +40 -12
  91. package/dist/tools/tasks.d.ts.map +1 -1
  92. package/dist/tools/tasks.js +475 -87
  93. package/dist/tools/tasks.js.map +1 -1
  94. package/dist/tools/utils.d.ts +11 -6
  95. package/dist/tools/utils.d.ts.map +1 -1
  96. package/dist/tools/utils.js +56 -44
  97. package/dist/tools/utils.js.map +1 -1
  98. package/dist/types.d.ts +4 -0
  99. package/dist/types.d.ts.map +1 -1
  100. package/dist/utils/file-pruning.d.ts +69 -0
  101. package/dist/utils/file-pruning.d.ts.map +1 -0
  102. package/dist/utils/file-pruning.js +185 -0
  103. package/dist/utils/file-pruning.js.map +1 -0
  104. package/dist/utils/quality-checks.d.ts +60 -0
  105. package/dist/utils/quality-checks.d.ts.map +1 -0
  106. package/dist/utils/quality-checks.js +228 -0
  107. package/dist/utils/quality-checks.js.map +1 -0
  108. package/dist/utils/retention.d.ts +8 -0
  109. package/dist/utils/retention.d.ts.map +1 -1
  110. package/dist/utils/retention.js +12 -0
  111. package/dist/utils/retention.js.map +1 -1
  112. package/dist/utils/task-stale-detection.d.ts +69 -1
  113. package/dist/utils/task-stale-detection.d.ts.map +1 -1
  114. package/dist/utils/task-stale-detection.js +494 -17
  115. package/dist/utils/task-stale-detection.js.map +1 -1
  116. package/dist/utils/vcs-adapter.d.ts +68 -0
  117. package/dist/utils/vcs-adapter.d.ts.map +1 -0
  118. package/dist/utils/vcs-adapter.js +187 -0
  119. package/dist/utils/vcs-adapter.js.map +1 -0
  120. package/dist/watcher/file-watcher.d.ts +54 -4
  121. package/dist/watcher/file-watcher.d.ts.map +1 -1
  122. package/dist/watcher/file-watcher.js +312 -30
  123. package/dist/watcher/file-watcher.js.map +1 -1
  124. package/dist/watcher/gitignore-parser.d.ts +70 -0
  125. package/dist/watcher/gitignore-parser.d.ts.map +1 -0
  126. package/dist/watcher/gitignore-parser.js +191 -0
  127. package/dist/watcher/gitignore-parser.js.map +1 -0
  128. package/dist/watcher/index.d.ts +1 -0
  129. package/dist/watcher/index.d.ts.map +1 -1
  130. package/dist/watcher/index.js +1 -0
  131. package/dist/watcher/index.js.map +1 -1
  132. package/docs/AI_AGENT_GUIDE.md +1 -1
  133. package/docs/ARCHITECTURE.md +12 -0
  134. package/docs/AUTO_FILE_TRACKING.md +486 -82
  135. package/docs/CONFIGURATION.md +908 -0
  136. package/docs/GIT_AWARE_AUTO_COMPLETE.md +645 -0
  137. package/docs/MIGRATION_v3.3.md +602 -0
  138. package/docs/SHARED_CONCEPTS.md +2 -1
  139. package/docs/TASK_ACTIONS.md +12 -0
  140. package/docs/TASK_OVERVIEW.md +124 -23
  141. package/docs/TASK_PRUNING.md +589 -0
  142. package/docs/TASK_SYSTEM.md +83 -13
  143. package/docs/TOOL_REFERENCE.md +94 -6
  144. package/package.json +8 -6
@@ -0,0 +1,908 @@
1
+ # sqlew Configuration Guide
2
+
3
+ **Complete guide to configuring sqlew via config files, CLI arguments, and MCP tools**
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Overview](#overview)
8
+ 2. [Configuration Priority](#configuration-priority)
9
+ 3. [Config File Format](#config-file-format)
10
+ 4. [Configuration Options](#configuration-options)
11
+ 5. [Setup Instructions](#setup-instructions)
12
+ 6. [Validation Rules](#validation-rules)
13
+ 7. [Runtime Configuration](#runtime-configuration)
14
+ 8. [Common Configurations](#common-configurations)
15
+ 9. [Troubleshooting](#troubleshooting)
16
+
17
+ ---
18
+
19
+ ## Overview
20
+
21
+ sqlew supports flexible configuration through multiple mechanisms:
22
+
23
+ - **Config file** (`.sqlew/config.toml`) - Persistent project settings
24
+ - **CLI arguments** - Override config file at startup
25
+ - **MCP tools** - Runtime configuration updates
26
+ - **Database** (`m_config` table) - Stores active configuration
27
+
28
+ ### Why Use Config Files?
29
+
30
+ **Benefits:**
31
+ - ✅ **Persistent settings** - No need to specify CLI args every time
32
+ - ✅ **Version control** - Commit config to share team settings
33
+ - ✅ **Documentation** - Self-documenting project requirements
34
+ - ✅ **Type safety** - TOML validation catches errors early
35
+ - ✅ **Separation of concerns** - Config separate from code
36
+
37
+ **When to use:**
38
+ - Multi-developer projects with shared settings
39
+ - Different settings per environment (dev/staging/prod)
40
+ - Complex retention policies (weekend-aware, long retention)
41
+ - Custom database locations
42
+
43
+ ---
44
+
45
+ ## Configuration Priority
46
+
47
+ sqlew applies configuration in this order (highest to lowest priority):
48
+
49
+ ```
50
+ 1. CLI Arguments (--autodelete-message-hours=48)
51
+
52
+ 2. Config File (.sqlew/config.toml)
53
+
54
+ 3. Database (m_config table)
55
+
56
+ 4. Code Defaults (DEFAULT_CONFIG in types.ts)
57
+ ```
58
+
59
+ **Example:**
60
+ ```toml
61
+ # .sqlew/config.toml
62
+ [autodelete]
63
+ message_hours = 24
64
+ ```
65
+
66
+ ```bash
67
+ # CLI overrides config file
68
+ npx sqlew --autodelete-message-hours=48
69
+
70
+ # Result: message_hours = 48 (CLI wins)
71
+ ```
72
+
73
+ **After startup:**
74
+ - All settings stored in `m_config` table
75
+ - CLI and config file values merged into database
76
+ - MCP `config` tool can update settings at runtime
77
+
78
+ ---
79
+
80
+ ## Config File Format
81
+
82
+ ### Location
83
+
84
+ **Default path:** `.sqlew/config.toml` (relative to project root)
85
+
86
+ **Custom path:** Specify via `--config-path` CLI argument
87
+ ```bash
88
+ npx sqlew --config-path=config/custom.toml
89
+ ```
90
+
91
+ ### TOML Structure
92
+
93
+ Config file uses TOML format with three sections:
94
+
95
+ ```toml
96
+ [database] # Database location
97
+ [autodelete] # Retention policies
98
+ [tasks] # Task management
99
+ ```
100
+
101
+ ### Complete Example
102
+
103
+ ```toml
104
+ # sqlew Configuration File
105
+ # Copy from .sqlew/config.toml.example and customize
106
+
107
+ # ============================================================================
108
+ # Database Settings
109
+ # ============================================================================
110
+ [database]
111
+ # Database file path (relative to project root or absolute)
112
+ # Default: ".sqlew/sqlew.db"
113
+ path = ".sqlew/custom.db"
114
+ # path = "/absolute/path/to/database.db"
115
+
116
+ # ============================================================================
117
+ # Auto-Deletion Settings
118
+ # ============================================================================
119
+ [autodelete]
120
+ # Skip weekends when calculating retention periods
121
+ # When true: 24 hours on Monday = previous Friday (skips Sat/Sun)
122
+ # When false: 24 hours = exactly 24 hours ago
123
+ # Default: false
124
+ ignore_weekend = false
125
+
126
+ # Message retention period in hours (1-720)
127
+ # Messages older than this are automatically deleted
128
+ # Default: 24 (1 day)
129
+ message_hours = 24
130
+
131
+ # File change history retention in days (1-365)
132
+ # File changes older than this are automatically deleted
133
+ # Default: 7 (1 week)
134
+ file_history_days = 7
135
+
136
+ # ============================================================================
137
+ # Task Management Settings
138
+ # ============================================================================
139
+ [tasks]
140
+ # Git-aware auto-complete (v3.4.0)
141
+ # Enable automatic completion when all watched files are committed
142
+ # Default: true
143
+ git_auto_complete_enabled = true
144
+
145
+ # Require all watched files to be committed for auto-complete
146
+ # When true: All watched files must be committed (strict)
147
+ # When false: At least one watched file committed (permissive)
148
+ # Default: true
149
+ require_all_files_committed = true
150
+
151
+ # Notification threshold for stale waiting_review tasks (hours, 1-720)
152
+ # Tasks stuck in 'waiting_review' longer than this → notification
153
+ # Note: v3.4.0 removed auto-revert to 'todo' behavior
154
+ # Default: 48 (2 days)
155
+ stale_review_notification_hours = 48
156
+
157
+ # Auto-archive done tasks after N days (1-365)
158
+ # Tasks in 'done' status older than this are moved to 'archived'
159
+ # Keeps task list clean while preserving history
160
+ # Default: 2 (48 hours)
161
+ auto_archive_done_days = 2
162
+
163
+ # Stale detection threshold for 'in_progress' tasks (hours, 1-168)
164
+ # Tasks stuck in 'in_progress' longer than this → move to 'waiting_review'
165
+ # Helps recover from interrupted AI sessions
166
+ # Default: 2 (2 hours)
167
+ stale_hours_in_progress = 2
168
+
169
+ # Stale detection threshold for 'waiting_review' tasks (hours, 1-720)
170
+ # DEPRECATED in v3.4.0 (kept for backward compatibility)
171
+ # No longer auto-reverts to 'todo' - use stale_review_notification_hours instead
172
+ # Default: 24 (1 day)
173
+ stale_hours_waiting_review = 24
174
+
175
+ # Enable automatic stale detection
176
+ # When true: Runs stale detection on startup and before task operations
177
+ # When false: Stale detection disabled (manual only)
178
+ # Default: true
179
+ auto_stale_enabled = true
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Configuration Options
185
+
186
+ ### Database Settings
187
+
188
+ #### `database.path`
189
+
190
+ **Description:** Database file location
191
+
192
+ **Type:** String (file path)
193
+
194
+ **Default:** `.sqlew/sqlew.db`
195
+
196
+ **Examples:**
197
+ ```toml
198
+ # Relative path (from project root)
199
+ [database]
200
+ path = ".sqlew/custom.db"
201
+
202
+ # Absolute path
203
+ path = "/var/data/sqlew/production.db"
204
+
205
+ # Per-environment config
206
+ path = ".sqlew/dev.db" # development
207
+ path = ".sqlew/prod.db" # production
208
+ ```
209
+
210
+ **CLI Override:**
211
+ ```bash
212
+ npx sqlew /path/to/database.db
213
+ ```
214
+
215
+ ---
216
+
217
+ ### Auto-Deletion Settings
218
+
219
+ #### `autodelete.ignore_weekend`
220
+
221
+ **Description:** Skip weekends when calculating retention periods
222
+
223
+ **Type:** Boolean
224
+
225
+ **Default:** `false`
226
+
227
+ **Behavior:**
228
+ - `false`: Standard time-based (24h = 24 hours ago)
229
+ - `true`: Skip weekends (24h on Monday = Friday 24h ago)
230
+
231
+ **Use cases:**
232
+ - Development teams (no work on weekends)
233
+ - Business-hours-only projects
234
+ - Preserve Friday context through Monday
235
+
236
+ **Examples:**
237
+ ```toml
238
+ [autodelete]
239
+ # Preserve weekend context
240
+ ignore_weekend = true
241
+ message_hours = 24
242
+
243
+ # Result on Monday 9am:
244
+ # - false: Deletes messages before Sunday 9am
245
+ # - true: Deletes messages before Friday 9am (skips Sat/Sun)
246
+ ```
247
+
248
+ **CLI Override:**
249
+ ```bash
250
+ npx sqlew --autodelete-ignore-weekend
251
+ npx sqlew --autodelete-ignore-weekend=true
252
+ ```
253
+
254
+ #### `autodelete.message_hours`
255
+
256
+ **Description:** Message retention period in hours
257
+
258
+ **Type:** Integer (1-720)
259
+
260
+ **Default:** `24` (1 day)
261
+
262
+ **Range:** 1 hour to 720 hours (30 days)
263
+
264
+ **Examples:**
265
+ ```toml
266
+ [autodelete]
267
+ message_hours = 1 # Aggressive cleanup (dev)
268
+ message_hours = 24 # Default (1 day)
269
+ message_hours = 168 # 1 week
270
+ message_hours = 720 # 30 days (max)
271
+ ```
272
+
273
+ **CLI Override:**
274
+ ```bash
275
+ npx sqlew --autodelete-message-hours=48
276
+ ```
277
+
278
+ #### `autodelete.file_history_days`
279
+
280
+ **Description:** File change history retention in days
281
+
282
+ **Type:** Integer (1-365)
283
+
284
+ **Default:** `7` (1 week)
285
+
286
+ **Range:** 1 day to 365 days (1 year)
287
+
288
+ **Examples:**
289
+ ```toml
290
+ [autodelete]
291
+ file_history_days = 1 # Aggressive cleanup (dev)
292
+ file_history_days = 7 # Default (1 week)
293
+ file_history_days = 30 # 1 month
294
+ file_history_days = 365 # 1 year (max)
295
+ ```
296
+
297
+ **CLI Override:**
298
+ ```bash
299
+ npx sqlew --autodelete-file-history-days=30
300
+ ```
301
+
302
+ ---
303
+
304
+ ### Task Management Settings
305
+
306
+ #### `tasks.git_auto_complete_enabled`
307
+
308
+ **Description:** Enable git-aware auto-complete for waiting_review tasks
309
+
310
+ **Type:** Boolean
311
+
312
+ **Default:** `true`
313
+
314
+ **Behavior:**
315
+ - `true`: Tasks in `waiting_review` auto-complete to `done` when all watched files are committed to git
316
+ - `false`: Manual completion required (no git integration)
317
+
318
+ **Use cases:**
319
+ - Auto-completion based on git commits
320
+ - Ensure work is properly tracked in version control
321
+ - Reduce manual task management overhead
322
+
323
+ **Examples:**
324
+ ```toml
325
+ [tasks]
326
+ # Enable git-aware auto-complete (default)
327
+ git_auto_complete_enabled = true
328
+
329
+ # Disable git-aware auto-complete
330
+ git_auto_complete_enabled = false
331
+ ```
332
+
333
+ **No CLI override** (use MCP `config` tool)
334
+
335
+ #### `tasks.require_all_files_committed`
336
+
337
+ **Description:** Require all watched files to be committed before auto-complete
338
+
339
+ **Type:** Boolean
340
+
341
+ **Default:** `true`
342
+
343
+ **Behavior:**
344
+ - `true`: All watched files must be committed (strict mode)
345
+ - `false`: At least one watched file committed triggers auto-complete (permissive mode)
346
+
347
+ **Use cases:**
348
+ - Strict mode: Ensure complete work is committed
349
+ - Permissive mode: Allow partial commits to trigger completion
350
+
351
+ **Examples:**
352
+ ```toml
353
+ [tasks]
354
+ # Require all watched files committed (strict - default)
355
+ require_all_files_committed = true
356
+
357
+ # Allow partial commits (permissive)
358
+ require_all_files_committed = false
359
+ ```
360
+
361
+ **No CLI override** (use MCP `config` tool)
362
+
363
+ #### `tasks.stale_review_notification_hours`
364
+
365
+ **Description:** Notification threshold for stale waiting_review tasks (hours)
366
+
367
+ **Type:** Integer (1-720)
368
+
369
+ **Default:** `48` (2 days)
370
+
371
+ **Range:** 1 hour to 720 hours (30 days)
372
+
373
+ **Behavior:**
374
+ - Tasks in `waiting_review` > threshold → generate notification
375
+ - Does NOT auto-transition (removed in v3.4.0)
376
+ - Helps identify tasks stuck in review
377
+
378
+ **Examples:**
379
+ ```toml
380
+ [tasks]
381
+ stale_review_notification_hours = 24 # Notify after 1 day
382
+ stale_review_notification_hours = 48 # Default (2 days)
383
+ stale_review_notification_hours = 72 # Notify after 3 days
384
+ stale_review_notification_hours = 168 # Notify after 1 week
385
+ ```
386
+
387
+ **No CLI override** (use MCP `config` tool)
388
+
389
+ #### `tasks.auto_archive_done_days`
390
+
391
+ **Description:** Auto-archive done tasks after N days
392
+
393
+ **Type:** Integer (1-365)
394
+
395
+ **Default:** `2` (48 hours)
396
+
397
+ **Range:** 1 day to 365 days
398
+
399
+ **Behavior:**
400
+ - Tasks in `done` status older than threshold → `archived`
401
+ - Keeps task board clean while preserving history
402
+ - Archived tasks still queryable via `task` tool
403
+
404
+ **Examples:**
405
+ ```toml
406
+ [tasks]
407
+ auto_archive_done_days = 1 # Quick cleanup (demo/dev)
408
+ auto_archive_done_days = 2 # Default (48 hours)
409
+ auto_archive_done_days = 7 # 1 week (production)
410
+ auto_archive_done_days = 30 # Long retention
411
+ ```
412
+
413
+ **No CLI override** (use MCP `config` tool)
414
+
415
+ #### `tasks.stale_hours_in_progress`
416
+
417
+ **Description:** Stale detection threshold for `in_progress` tasks
418
+
419
+ **Type:** Integer (1-168)
420
+
421
+ **Default:** `2` (2 hours)
422
+
423
+ **Range:** 1 hour to 168 hours (7 days)
424
+
425
+ **Behavior:**
426
+ - Tasks in `in_progress` > threshold → `waiting_review`
427
+ - Helps recover from interrupted AI sessions
428
+ - Runs on startup and before task operations
429
+
430
+ **Examples:**
431
+ ```toml
432
+ [tasks]
433
+ stale_hours_in_progress = 1 # Aggressive (1 hour)
434
+ stale_hours_in_progress = 2 # Default (2 hours)
435
+ stale_hours_in_progress = 4 # Relaxed (4 hours)
436
+ stale_hours_in_progress = 24 # Very relaxed (1 day)
437
+ ```
438
+
439
+ **No CLI override** (use MCP `config` tool)
440
+
441
+ #### `tasks.stale_hours_waiting_review`
442
+
443
+ **Description:** Stale detection threshold for `waiting_review` tasks
444
+
445
+ **Type:** Integer (1-720)
446
+
447
+ **Default:** `24` (1 day)
448
+
449
+ **Range:** 1 hour to 720 hours (30 days)
450
+
451
+ **Behavior:**
452
+ - Tasks in `waiting_review` > threshold → `todo`
453
+ - Prevents abandoned reviews from blocking workflow
454
+ - Runs on startup and before task operations
455
+
456
+ **Examples:**
457
+ ```toml
458
+ [tasks]
459
+ stale_hours_waiting_review = 8 # Aggressive (8 hours)
460
+ stale_hours_waiting_review = 24 # Default (1 day)
461
+ stale_hours_waiting_review = 48 # Relaxed (2 days)
462
+ stale_hours_waiting_review = 168 # Very relaxed (1 week)
463
+ ```
464
+
465
+ **No CLI override** (use MCP `config` tool)
466
+
467
+ #### `tasks.auto_stale_enabled`
468
+
469
+ **Description:** Enable automatic stale detection
470
+
471
+ **Type:** Boolean
472
+
473
+ **Default:** `true`
474
+
475
+ **Behavior:**
476
+ - `true`: Runs stale detection on startup and before task operations
477
+ - `false`: Stale detection disabled (manual only via MCP tool)
478
+
479
+ **Examples:**
480
+ ```toml
481
+ [tasks]
482
+ # Enable auto-stale (default)
483
+ auto_stale_enabled = true
484
+
485
+ # Disable auto-stale (manual control only)
486
+ auto_stale_enabled = false
487
+ ```
488
+
489
+ **No CLI override** (use MCP `config` tool)
490
+
491
+ ---
492
+
493
+ ## Setup Instructions
494
+
495
+ ### 1. Copy Example Config
496
+
497
+ ```bash
498
+ # Navigate to project root
499
+ cd /path/to/your/project
500
+
501
+ # Copy example config
502
+ cp .sqlew/config.toml.example .sqlew/config.toml
503
+ ```
504
+
505
+ ### 2. Customize Settings
506
+
507
+ Edit `.sqlew/config.toml`:
508
+
509
+ ```toml
510
+ [database]
511
+ # Use custom database location
512
+ path = ".sqlew/my-project.db"
513
+
514
+ [autodelete]
515
+ # Weekend-aware cleanup for development team
516
+ ignore_weekend = true
517
+ message_hours = 48
518
+ file_history_days = 14
519
+
520
+ [tasks]
521
+ # Quick archival for fast-paced projects
522
+ auto_archive_done_days = 1
523
+ stale_hours_in_progress = 1
524
+ stale_hours_waiting_review = 12
525
+ ```
526
+
527
+ ### 3. Version Control (Optional)
528
+
529
+ ```bash
530
+ # Add to git (share team settings)
531
+ git add .sqlew/config.toml
532
+ git commit -m "Add sqlew configuration"
533
+
534
+ # Or ignore (per-developer settings)
535
+ echo ".sqlew/config.toml" >> .gitignore
536
+ ```
537
+
538
+ ### 4. Start sqlew
539
+
540
+ ```bash
541
+ # Uses .sqlew/config.toml automatically
542
+ npx sqlew
543
+
544
+ # Or specify custom config path
545
+ npx sqlew --config-path=config/custom.toml
546
+ ```
547
+
548
+ ### 5. Verify Configuration
549
+
550
+ Use MCP `config` tool:
551
+
552
+ ```javascript
553
+ // Get all configuration
554
+ {
555
+ action: "get"
556
+ }
557
+
558
+ // Returns current settings from m_config table
559
+ ```
560
+
561
+ ---
562
+
563
+ ## Validation Rules
564
+
565
+ sqlew validates all configuration values on startup:
566
+
567
+ ### Auto-Deletion Rules
568
+
569
+ | Setting | Min | Max | Default |
570
+ |---------|-----|-----|---------|
571
+ | `message_hours` | 1 | 720 | 24 |
572
+ | `file_history_days` | 1 | 365 | 7 |
573
+
574
+ **Validation errors:**
575
+ ```toml
576
+ [autodelete]
577
+ message_hours = 0 # ❌ Error: must be >= 1
578
+ message_hours = 1000 # ❌ Error: must be <= 720
579
+ ```
580
+
581
+ ### Task Management Rules
582
+
583
+ | Setting | Min | Max | Default |
584
+ |---------|-----|-----|---------|
585
+ | `auto_archive_done_days` | 1 | 365 | 2 |
586
+ | `stale_hours_in_progress` | 1 | 168 | 2 |
587
+ | `stale_hours_waiting_review` | 1 | 720 | 24 |
588
+
589
+ **Validation errors:**
590
+ ```toml
591
+ [tasks]
592
+ stale_hours_in_progress = 0 # ❌ Error: must be >= 1
593
+ stale_hours_in_progress = 200 # ❌ Error: must be <= 168
594
+ ```
595
+
596
+ ### Error Handling
597
+
598
+ **On validation failure:**
599
+ 1. sqlew prints warnings to console
600
+ 2. Invalid values ignored
601
+ 3. Falls back to defaults
602
+ 4. Server continues to start
603
+
604
+ **Example output:**
605
+ ```
606
+ ⚠️ Configuration validation warnings:
607
+ - autodelete.message_hours must be between 1 and 720 (30 days)
608
+ - tasks.stale_hours_in_progress must be between 1 and 168 (7 days)
609
+ Using default configuration
610
+ ```
611
+
612
+ ---
613
+
614
+ ## Runtime Configuration
615
+
616
+ ### Update via MCP Tools
617
+
618
+ Use the `config` tool to change settings at runtime:
619
+
620
+ ```javascript
621
+ // Get current configuration
622
+ {
623
+ action: "get"
624
+ }
625
+
626
+ // Update settings (persists to m_config table)
627
+ {
628
+ action: "update",
629
+ autodelete_message_hours: 48,
630
+ autodelete_ignore_weekend: true
631
+ }
632
+ ```
633
+
634
+ ### Configuration Persistence
635
+
636
+ **How it works:**
637
+ 1. Config file loaded on startup
638
+ 2. Values merged with CLI arguments
639
+ 3. Final config written to `m_config` table
640
+ 4. MCP `config` tool updates `m_config` table
641
+ 5. Changes persist until next startup (then config file reloads)
642
+
643
+ **To persist runtime changes:**
644
+ 1. Update values via MCP `config` tool
645
+ 2. Manually update `.sqlew/config.toml` to match
646
+ 3. Or regenerate config file from database (manual export)
647
+
648
+ ---
649
+
650
+ ## Common Configurations
651
+
652
+ ### Development (Aggressive Cleanup)
653
+
654
+ **Use case:** Fast iteration, minimal data retention
655
+
656
+ ```toml
657
+ [autodelete]
658
+ ignore_weekend = false
659
+ message_hours = 1
660
+ file_history_days = 1
661
+
662
+ [tasks]
663
+ auto_archive_done_days = 1
664
+ stale_hours_in_progress = 1
665
+ stale_hours_waiting_review = 8
666
+ auto_stale_enabled = true
667
+ ```
668
+
669
+ ### Production (Conservative Retention)
670
+
671
+ **Use case:** Long-term projects, preserve history
672
+
673
+ ```toml
674
+ [autodelete]
675
+ ignore_weekend = false
676
+ message_hours = 168 # 7 days
677
+ file_history_days = 30
678
+
679
+ [tasks]
680
+ auto_archive_done_days = 7
681
+ stale_hours_in_progress = 4
682
+ stale_hours_waiting_review = 48
683
+ auto_stale_enabled = true
684
+ ```
685
+
686
+ ### Weekend-Aware Workflow
687
+
688
+ **Use case:** Developer teams (no weekend work)
689
+
690
+ ```toml
691
+ [autodelete]
692
+ ignore_weekend = true # Skip weekends
693
+ message_hours = 48
694
+ file_history_days = 14
695
+
696
+ [tasks]
697
+ auto_archive_done_days = 2
698
+ stale_hours_in_progress = 2
699
+ stale_hours_waiting_review = 24
700
+ auto_stale_enabled = true
701
+ ```
702
+
703
+ ### Manual Control (No Auto-Cleanup)
704
+
705
+ **Use case:** Full control, manual cleanup only
706
+
707
+ ```toml
708
+ [autodelete]
709
+ ignore_weekend = false
710
+ message_hours = 720 # Max retention (30 days)
711
+ file_history_days = 365 # Max retention (1 year)
712
+
713
+ [tasks]
714
+ auto_archive_done_days = 365
715
+ stale_hours_in_progress = 168 # 7 days (max)
716
+ stale_hours_waiting_review = 720 # 30 days (max)
717
+ auto_stale_enabled = false # Disable auto-stale
718
+ ```
719
+
720
+ ### Multi-Environment Setup
721
+
722
+ **Development:**
723
+ ```toml
724
+ # .sqlew/dev.toml
725
+ [database]
726
+ path = ".sqlew/dev.db"
727
+
728
+ [autodelete]
729
+ message_hours = 1
730
+ file_history_days = 1
731
+ ```
732
+
733
+ **Production:**
734
+ ```toml
735
+ # .sqlew/prod.toml
736
+ [database]
737
+ path = ".sqlew/prod.db"
738
+
739
+ [autodelete]
740
+ message_hours = 168
741
+ file_history_days = 30
742
+ ```
743
+
744
+ **Usage:**
745
+ ```bash
746
+ # Development
747
+ npx sqlew --config-path=.sqlew/dev.toml
748
+
749
+ # Production
750
+ npx sqlew --config-path=.sqlew/prod.toml
751
+ ```
752
+
753
+ ---
754
+
755
+ ## Troubleshooting
756
+
757
+ ### Config File Not Found
758
+
759
+ **Symptom:**
760
+ ```
761
+ ⚠️ Failed to load config file: .sqlew/config.toml
762
+ Error: ENOENT: no such file or directory
763
+ Using default configuration
764
+ ```
765
+
766
+ **Solution:**
767
+ 1. Config file is optional - this is not an error
768
+ 2. Create config file if needed:
769
+ ```bash
770
+ cp .sqlew/config.toml.example .sqlew/config.toml
771
+ ```
772
+
773
+ ### Invalid TOML Syntax
774
+
775
+ **Symptom:**
776
+ ```
777
+ ⚠️ Failed to load config file: .sqlew/config.toml
778
+ Error: Invalid TOML: Unexpected character at line 5
779
+ Using default configuration
780
+ ```
781
+
782
+ **Solution:**
783
+ 1. Validate TOML syntax: https://www.toml-lint.com/
784
+ 2. Common errors:
785
+ ```toml
786
+ # ❌ Wrong: Missing quotes for strings with spaces
787
+ path = /path with spaces/db.db
788
+
789
+ # ✅ Correct: Quote strings with spaces
790
+ path = "/path with spaces/db.db"
791
+
792
+ # ❌ Wrong: Invalid boolean
793
+ ignore_weekend = yes
794
+
795
+ # ✅ Correct: Use true/false
796
+ ignore_weekend = true
797
+ ```
798
+
799
+ ### Values Not Applied
800
+
801
+ **Symptom:** Changed config file but values not reflected
802
+
803
+ **Solution:**
804
+ 1. **Check priority:** CLI args override config file
805
+ ```bash
806
+ # CLI wins over config file
807
+ npx sqlew --autodelete-message-hours=24
808
+ ```
809
+
810
+ 2. **Verify config loading:**
811
+ ```bash
812
+ # Check console output on startup
813
+ ✓ Loaded 7 config values from file
814
+ ```
815
+
816
+ 3. **Query active config:**
817
+ ```javascript
818
+ {action: "get"} // via config tool
819
+ ```
820
+
821
+ ### Validation Warnings
822
+
823
+ **Symptom:**
824
+ ```
825
+ ⚠️ Configuration validation warnings:
826
+ - autodelete.message_hours must be between 1 and 720 (30 days)
827
+ ```
828
+
829
+ **Solution:**
830
+ 1. Check validation rules (see [Validation Rules](#validation-rules))
831
+ 2. Fix invalid values in config file
832
+ 3. Restart sqlew
833
+
834
+ ### Database Path Issues
835
+
836
+ **Symptom:**
837
+ ```
838
+ Error: SQLITE_CANTOPEN: unable to open database file
839
+ ```
840
+
841
+ **Solution:**
842
+ 1. **Check path syntax:**
843
+ ```toml
844
+ # ❌ Wrong: Relative to config file location
845
+ path = "sqlew.db"
846
+
847
+ # ✅ Correct: Relative to project root
848
+ path = ".sqlew/sqlew.db"
849
+ ```
850
+
851
+ 2. **Use absolute paths for clarity:**
852
+ ```toml
853
+ path = "/absolute/path/to/database.db"
854
+ ```
855
+
856
+ 3. **Ensure directory exists:**
857
+ - sqlew auto-creates parent directory
858
+ - Check file permissions
859
+
860
+ ### Weekend-Aware Not Working
861
+
862
+ **Symptom:** Weekend dates not skipped in retention
863
+
864
+ **Solution:**
865
+ 1. **Check configuration:**
866
+ ```toml
867
+ [autodelete]
868
+ ignore_weekend = true # Must be true, not "true"
869
+ ```
870
+
871
+ 2. **Verify via MCP tool:**
872
+ ```javascript
873
+ {action: "get"}
874
+ // Check: autodelete_ignore_weekend = "1" (true)
875
+ ```
876
+
877
+ 3. **Test behavior:**
878
+ - Monday cleanup should reference Friday
879
+ - Not Saturday/Sunday
880
+
881
+ ---
882
+
883
+ ## Related Documentation
884
+
885
+ - **[Architecture](ARCHITECTURE.md)** - Database schema and `m_config` table structure
886
+ - **[Tool Reference](TOOL_REFERENCE.md)** - MCP `config` tool usage
887
+ - **[Best Practices](BEST_PRACTICES.md)** - Configuration recommendations
888
+
889
+ ---
890
+
891
+ ## Example Files
892
+
893
+ ### Minimal Configuration
894
+
895
+ ```toml
896
+ # .sqlew/config.toml (minimal)
897
+ [autodelete]
898
+ ignore_weekend = true
899
+ message_hours = 48
900
+ ```
901
+
902
+ ### Full Configuration with Comments
903
+
904
+ See `.sqlew/config.toml.example` in project root for complete annotated example.
905
+
906
+ ---
907
+
908
+ **Last Updated:** v3.4.1 (2025-10-22)