sqlew 5.2.0 → 5.2.2

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 (109) hide show
  1. package/CHANGELOG.md +2169 -2110
  2. package/LICENSE +190 -190
  3. package/NOTICE +24 -24
  4. package/README.md +204 -199
  5. package/dist/adapters/mysql-adapter.js +3 -3
  6. package/dist/adapters/postgresql-adapter.js +3 -3
  7. package/dist/cli/db-export.js +32 -32
  8. package/dist/cli/db-import.js +30 -30
  9. package/dist/cli/hooks/codex-transcript.d.ts +23 -0
  10. package/dist/cli/hooks/codex-transcript.d.ts.map +1 -0
  11. package/dist/cli/hooks/codex-transcript.js +134 -0
  12. package/dist/cli/hooks/codex-transcript.js.map +1 -0
  13. package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -1
  14. package/dist/cli/hooks/on-exit-plan.js +30 -3
  15. package/dist/cli/hooks/on-exit-plan.js.map +1 -1
  16. package/dist/cli/hooks/on-prompt.d.ts +2 -2
  17. package/dist/cli/hooks/on-prompt.d.ts.map +1 -1
  18. package/dist/cli/hooks/on-prompt.js +33 -16
  19. package/dist/cli/hooks/on-prompt.js.map +1 -1
  20. package/dist/cli/hooks/plan-pattern-extractor.d.ts +2 -0
  21. package/dist/cli/hooks/plan-pattern-extractor.d.ts.map +1 -1
  22. package/dist/cli/hooks/plan-pattern-extractor.js +1 -0
  23. package/dist/cli/hooks/plan-pattern-extractor.js.map +1 -1
  24. package/dist/cli/hooks/plan-processor.d.ts.map +1 -1
  25. package/dist/cli/hooks/plan-processor.js +1 -0
  26. package/dist/cli/hooks/plan-processor.js.map +1 -1
  27. package/dist/cli/hooks/pr-adr.js +5 -5
  28. package/dist/cli/hooks/stdin-parser.d.ts +4 -2
  29. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
  30. package/dist/cli/hooks/stdin-parser.js +79 -9
  31. package/dist/cli/hooks/stdin-parser.js.map +1 -1
  32. package/dist/cli/hooks/track-plan.js +15 -15
  33. package/dist/cli.js +48 -48
  34. package/dist/config/global-config.js +19 -19
  35. package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +32 -32
  36. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +3 -3
  37. package/dist/database/migrations/v4/20260613000000_add_constraint_reason.d.ts +9 -0
  38. package/dist/database/migrations/v4/20260613000000_add_constraint_reason.d.ts.map +1 -0
  39. package/dist/database/migrations/v4/20260613000000_add_constraint_reason.js +31 -0
  40. package/dist/database/migrations/v4/20260613000000_add_constraint_reason.js.map +1 -0
  41. package/dist/help-data/constraint.toml +265 -259
  42. package/dist/help-data/decision.toml +845 -845
  43. package/dist/help-data/queue.toml +134 -134
  44. package/dist/schema.d.ts.map +1 -1
  45. package/dist/schema.js +4 -5
  46. package/dist/schema.js.map +1 -1
  47. package/dist/server/tool-schemas.js +30 -30
  48. package/dist/tests/docker/native/constraint-operations.test.js +38 -0
  49. package/dist/tests/docker/native/constraint-operations.test.js.map +1 -1
  50. package/dist/tests/docker/native/db-init.js +9 -9
  51. package/dist/tests/feature/constraint/reason.test.d.ts +7 -0
  52. package/dist/tests/feature/constraint/reason.test.d.ts.map +1 -0
  53. package/dist/tests/feature/constraint/reason.test.js +68 -0
  54. package/dist/tests/feature/constraint/reason.test.js.map +1 -0
  55. package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts +7 -0
  56. package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts.map +1 -0
  57. package/dist/tests/unit/hooks/codex-hook-normalization.test.js +112 -0
  58. package/dist/tests/unit/hooks/codex-hook-normalization.test.js.map +1 -0
  59. package/dist/tests/unit/hooks/grok-hook-normalization.test.js +45 -7
  60. package/dist/tests/unit/hooks/grok-hook-normalization.test.js.map +1 -1
  61. package/dist/tests/unit/hooks/plan-pattern-extractor.test.d.ts +8 -0
  62. package/dist/tests/unit/hooks/plan-pattern-extractor.test.d.ts.map +1 -0
  63. package/dist/tests/unit/hooks/plan-pattern-extractor.test.js +110 -0
  64. package/dist/tests/unit/hooks/plan-pattern-extractor.test.js.map +1 -0
  65. package/dist/tests/utils/db-schema.js +48 -48
  66. package/dist/tests/utils/test-helpers.js +48 -48
  67. package/dist/tools/constraints/actions/add.d.ts.map +1 -1
  68. package/dist/tools/constraints/actions/add.js +1 -0
  69. package/dist/tools/constraints/actions/add.js.map +1 -1
  70. package/dist/tools/constraints/actions/get.d.ts.map +1 -1
  71. package/dist/tools/constraints/actions/get.js +9 -7
  72. package/dist/tools/constraints/actions/get.js.map +1 -1
  73. package/dist/tools/constraints/help/example.js +1 -1
  74. package/dist/tools/constraints/help/example.js.map +1 -1
  75. package/dist/types/constraint/params.d.ts +2 -0
  76. package/dist/types/constraint/params.d.ts.map +1 -1
  77. package/dist/types/view-entities.d.ts +1 -0
  78. package/dist/types/view-entities.d.ts.map +1 -1
  79. package/dist/utils/action-specs/constraint-specs.d.ts.map +1 -1
  80. package/dist/utils/action-specs/constraint-specs.js +4 -3
  81. package/dist/utils/action-specs/constraint-specs.js.map +1 -1
  82. package/dist/utils/hook-queue.d.ts +2 -0
  83. package/dist/utils/hook-queue.d.ts.map +1 -1
  84. package/dist/utils/hook-queue.js.map +1 -1
  85. package/dist/utils/project-root.d.ts +1 -0
  86. package/dist/utils/project-root.d.ts.map +1 -1
  87. package/dist/utils/project-root.js +6 -0
  88. package/dist/utils/project-root.js.map +1 -1
  89. package/dist/utils/view-queries.d.ts.map +1 -1
  90. package/dist/utils/view-queries.js +1 -0
  91. package/dist/utils/view-queries.js.map +1 -1
  92. package/dist/watcher/queue-watcher.d.ts.map +1 -1
  93. package/dist/watcher/queue-watcher.js +1 -0
  94. package/dist/watcher/queue-watcher.js.map +1 -1
  95. package/docs/ADR_CONCEPTS.md +152 -152
  96. package/docs/CLI_USAGE.md +392 -392
  97. package/docs/CONFIGURATION.md +157 -157
  98. package/docs/CROSS_DATABASE.md +66 -66
  99. package/docs/DATABASE_AUTH.md +135 -135
  100. package/docs/HOOKS_GUIDE.md +116 -101
  101. package/docs/MIGRATION_TO_SAAS.md +176 -176
  102. package/docs/SHARED_DATABASE.md +108 -108
  103. package/package.json +88 -88
  104. package/scripts/copy-help-data.js +19 -19
  105. package/scripts/filter-test-output.js +78 -78
  106. package/dist/tests/docker/native/help-system.test.d.ts +0 -8
  107. package/dist/tests/docker/native/help-system.test.d.ts.map +0 -1
  108. package/dist/tests/docker/native/help-system.test.js +0 -508
  109. package/dist/tests/docker/native/help-system.test.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,2110 +1,2169 @@
1
- # Changelog
2
-
3
- All notable changes to sqlew will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ---
9
-
10
- ## [5.2.0] - 2026-06-11
11
-
12
- ### Added
13
-
14
- **Grok Build support (sqlew-plugin v5.2.0)**
15
-
16
- Unified Plan-to-ADR support for Grok Build alongside Claude Code via a single sqlew-plugin install. No separate sqlew-grok adapter required.
17
-
18
- - **`normalizeHookInput()`**Translates Grok hook payloads (`hookEventName`, `toolName`, `sessionId`, `workspaceRoot`) to canonical Claude-shaped `HookInput`. Claude payloads pass through unchanged.
19
- - **`computeGrokPlanPath()`**Resolves per-session plan file at `~/.grok/sessions/<encodeURIComponent(cwd)>/<sessionId>/plan.md`.
20
- - **`injectGrokPlanTemplate()`**Appends Decision/Constraint template to `plan.md` on `enter_plan_mode` (file side-effect). Grok ignores passive hook stdout; skills auto-invocation is unreliable.
21
- - **`GROK_WORKSPACE_ROOT`**Added to `determineProjectRoot()` for MCP server project root resolution.
22
- - **Grok `sendBlock()` compat** — PreToolUse deny hooks emit `{"decision":"deny","reason":"..."}` on stdout for Grok (in addition to exit 2 + stderr for Claude Code).
23
- - **Unit tests** — `grok-hook-normalization.test.ts`, `grok-plan-template-injection.test.ts`.
24
-
25
- ### Changed
26
-
27
- - **`on-prompt`** — Early return for Grok client (`UserPromptSubmit` stdout is ignored on Grok).
28
- - **`on-exit-plan` / `track-plan`** — Record `CurrentPlanInfo.plan_path` for Grok; always re-resolve from `session_id` on exit.
29
- - **`plan-processor`** — Prefer explicit `plan_path` over legacy Claude global plans resolver.
30
- - **`docs/HOOKS_GUIDE.md`** Replaced sqlew-grok adapter instructions with `grok plugin install sqlew-io/sqlew-plugin --trust` workflow.
31
-
32
- ### Plugin Changes (sqlew-plugin v5.2.0)
33
-
34
- - Hook matchers: `enter_plan_mode` / `exit_plan_mode` alongside Claude tool names
35
- - Skills: Grok-specific plan mode guidance (`sqlew-plan-guidance`, `sqlew-decision-format`)
36
-
37
- ---
38
-
39
- ## [5.1.0] - 2026-03-07
40
-
41
- ### Changed
42
-
43
- **📁 `.sqlew.env` relocated to `~/.config/sqlew/.sqlew.env`**
44
-
45
- The cloud API key file (`~/.sqlew.env`) has been moved to `~/.config/sqlew/.sqlew.env` to align with the v5.1 unified global config path. Automatic migration copies the old file and deletes it (API key security: no stale copies). `saveCachedProjectId()` now calls `ensureGlobalConfigDir()` for directory safety.
46
-
47
- **🔒 db:export Project Scope Auto-Detection (Security)**
48
-
49
- `db:export` no longer exports all projects by default. With the global shared database (v5.1.0), the default "export everything" behavior risked leaking other projects' decision data.
50
-
51
- - **Auto-detect**: Project name resolved from `.sqlew/config.toml` `[project].name` when no `project=` option is given
52
- - **Explicit all**: `project=all` required to export all projects (escape hatch)
53
- - **Error on ambiguity**: If no project name is found (no CLI arg, no config.toml), the command exits with an actionable error message
54
- - **Breaking change**: Previously, omitting `project=` exported all projects silently
55
-
56
- ### Resolution Priority
57
-
58
- ```
59
- 1. CLI argument: project=<name> (highest)
60
- 2. config.toml: [project].name
61
- 3. Error exit (lowest)
62
- ```
63
-
64
- ---
65
-
66
- ## [5.0.6] - 2026-02-14
67
-
68
- ### Changed
69
-
70
- **🧹 CLAUDE.md Injection Removed — Hook-based Plan Mode Enforcement**
71
-
72
- Plan mode enforcement migrated from `~/.claude/CLAUDE.md` injection (~193 lines always loaded) to `UserPromptSubmit` hook with `permission_mode` check (~5 lines, plan mode only).
73
-
74
- - New `on-prompt` CLI command: `UserPromptSubmit` hook handler that detects `permission_mode === "plan"` and injects enforcement context via plain text stdout
75
- - `track-plan` hook (EnterPlanMode): shares same enforcement context for agent-initiated plan mode coverage
76
- - Legacy `injectToGlobalClaudeMd()` replaced with `cleanupGlobalClaudeMd()` — auto-removes `<!-- sqlew:auto-injected -->` markers from `~/.claude/CLAUDE.md` on MCP startup
77
- - Removed `assets/claude-md-snippets/` directory (`plan-mode-integration.md`, `queue-monitoring.md`)
78
-
79
- ### Plugin Changes (sqlew-plugin)
80
-
81
- - Added `UserPromptSubmit` hook entry in `hooks.json` (`sqlew on-prompt`, timeout: 10s)
82
- - Skills descriptions strengthened to REQUIRED/MUST tone (`sqlew-decision-format`, `sqlew-plan-guidance`)
83
- - `sqlew-plan-guidance` expanded: suggest search steps, Related Context template, queue monitoring, failed queue resolution
84
-
85
- ### Technical Notes
86
-
87
- - `UserPromptSubmit` hook requires **plain text stdout** (not JSON `additionalContext` format). This is different from `SessionStart`/`PostToolUse` hooks which use JSON format.
88
- - Non-plan mode: hook outputs nothing and exits 0 (transparent, no system-reminder shown)
89
-
90
- ---
91
-
92
- ## [5.0.4] - 2026-02-04
93
-
94
- ### Added
95
-
96
- **📌 Decision Context Auto-Registration from Plan Mode**
97
-
98
- - Plan-to-ADR pipeline now automatically extracts and registers decision context (rationale, alternatives, tradeoffs) from plan files
99
- - New `decision_context` queue item type in `.sqlew/queue/pending.json`
100
- - `plan-pattern-extractor.ts`: Extracts `Rationale`, `Alternatives`, `Tradeoffs` fields from `📌 Decision` blocks
101
- - `plan-processor.ts`: Enqueues `decision_context` items after corresponding `decision` items (ordering guaranteed)
102
- - `hook-queue.ts`: New `enqueueDecisionContextCreate()` with duplicate prevention
103
- - `queue-watcher.ts`: New `processDecisionContextItem()` converts comma-separated alternatives to JSON array, routes through ToolBackend abstraction
104
-
105
- ### SaaS Compatibility
106
-
107
- - `add_decision_context` action fully supported via SaaS backend (`/api/v1/decision/add_decision_context`)
108
- - `suggest/by_context` for constraints: improved text matching for long constraint texts (server-side Levenshtein fix)
109
-
110
- ---
111
-
112
- ## [5.0.3] - 2026-02-04
113
-
114
- ### Fixed
115
-
116
- **🧟 Zombie Process on Parent Exit (Windows)**
117
-
118
- - MCP server processes remained alive after Claude Code exited, accumulating as zombie processes in Task Manager
119
- - Root cause: MCP SDK's `StdioServerTransport` only listens for stdin `data`/`error`, not `end`. When combined with chokidar's `persistent: true` file watcher (QueueWatcher), the Node.js event loop stayed alive indefinitely
120
- - Added `process.stdin.on('end')` handler to detect parent process exit and trigger graceful shutdown
121
- - Added `stopQueueWatcher()` to all shutdown handlers (`registerShutdownHandlers`, `performCleanup`) — the function existed since v4.1.0 but was never wired into the shutdown flow
122
-
123
- **🔍 Schema Version Detection for v5.0**
124
-
125
- - Fixed `[WARN] Unknown schema version detected` on every startup
126
- - `detectSchemaVersion()` checked for `v4_tasks` table (dropped in v5.0 migration), causing detection to always fail on v5 schema
127
- - Added v5 schema detection: checks `m_projects` + `t_decisions` + `t_constraints` with `v4_tasks` absence to distinguish from v4
128
- - Schema now correctly reports `v5.x (using m_/t_ tables)` with proper `tablePrefix='m_'` and `transactionPrefix='t_'`
129
-
130
- ---
131
-
132
- ## [5.0.2] - 2026-02-03
133
-
134
- ### Fixed
135
-
136
- **🐛 on-session-start Hook CLI Routing Bug**
137
-
138
- - Fixed `on-session-start` command being incorrectly routed to MCP server instead of CLI handler
139
- - The command name was being interpreted as a database path argument, causing incorrect DB connections
140
- - Added `on-session-start` to CLI command lists in both `index.ts` and `cli.ts`
141
- - Also added missing `on-enter-plan` to `index.ts` for consistency
142
-
143
- **Root Cause**: When SessionStart hook executed `sqlew on-session-start`, the command was not recognized as a CLI command and fell through to MCP server mode. The argument parser then treated `on-session-start` as a legacy positional argument for `--db-path`, resulting in a database file named `on-session-start` being created and used.
144
-
145
- ---
146
-
147
- ## [5.0.1] - 2026-02-02
148
-
149
- ### Changed
150
-
151
- **🔒 Security: saas-connector submodule integration (Issue #84)**
152
-
153
- - Integrated saas-connector submodule directly into `src/saas-connector/`
154
- - Removed `prebuild` script that triggered npm package scanner alerts
155
- - Converted saas-connector from CommonJS to ESM for unified tsc build
156
- - Eliminated separate esbuild step and `npm install` in subdirectory
157
- - No functional changes - same SaaS backend behavior
158
-
159
- **Rationale**: The `prebuild` script (`cd saas-connector && npm install && npm run build`) was flagged by npm security scanners as a potential risk. While the code itself was safe, the submodule architecture created unnecessary complexity and security perception issues.
160
-
161
- ---
162
-
163
- ## [5.0.0] - 2026-01-31
164
-
165
- ### Added
166
-
167
- **🌐 SaaS Backend Support (sqlew.io)**
168
-
169
- - Connect to sqlew.io cloud service with `type = "cloud"` in config.toml
170
- - Team-shared decision database - all team members see the same architectural decisions
171
- - Multiple AI agents can work simultaneously without conflicts
172
- - No local database setup required - just add your API key
173
- - Connection Identity for seat-based billing with project-scoped hashing
174
- - Project name resolution with UUID caching for optimized API calls
175
- - X-Agent header for MCP client tracking in audit logs
176
-
177
- **📚 Environment-aware Help Examples**
178
-
179
- - Examples filtered by environment (SQLite shows numeric IDs, SaaS shows UUIDs)
180
- - `target_type` attribute in TOML: `sqlite`, `cloud`, or `all`
181
- - Automatic filtering in help `query-action`, example `get`, `search`, `list-all` actions
182
-
183
- **🌳 Git Worktree Support**
184
-
185
- - Automatic worktree detection for multi-branch development
186
- - Config inheritance from main repository
187
- - Independent session cache per worktree
188
- - Seamless context sharing across worktrees
189
-
190
- **🔌 Plugin-first Architecture**
191
-
192
- - Skills/Hooks/Agents moved to separate `sqlew-plugin` repository
193
- - Global Rules auto-created at `~/.claude/rules/sqlew/` on MCP startup
194
- - Per-project Skills/Hooks installation removed (use plugin marketplace instead)
195
- - Simplified setup: just install the plugin and connect to sqlew.io
196
-
197
- **Queue Tool for Hook Queue Management**
198
-
199
- - New `queue` MCP tool to manage `.sqlew/queue/pending.json`
200
- - Actions: `list` (view pending items), `remove` (delete by index), `clear` (remove all)
201
- - Lock mechanism to prevent race conditions with QueueWatcher
202
- - Help documentation in `src/help-data/queue.toml`
203
- - Queue monitoring rule in `~/.claude/rules/sqlew/queue-monitoring.md`
204
-
205
- **TOML-based Help System**
206
-
207
- - Help documentation now stored in `src/help-data/*.toml` (version-controlled, human-editable)
208
- - `HelpSystemLoader` for startup-time loading with in-memory caching (O(1) lookups)
209
- - 15 TOML files: 8 tool files (including queue) + 6 use case workflows + 1 schema file
210
-
211
- ### Changed
212
-
213
- - **MCP tools: 6 7** (queue tool added)
214
- - `help`, `example`, `use_case` tools now load from TOML files instead of database
215
- - Database schema reduced: 18 tables (7 master + 11 transaction)
216
- - Table prefix renamed: `v4_` `m_/t_` (master/transaction convention)
217
- - Multi-database backend now includes Cloud option (SQLite/PostgreSQL/MySQL/Cloud)
218
- - Constraint ID now supports both `number` (SQLite) and `string` UUID (SaaS)
219
- - `constraint_id` parameter renamed to `id` (backward compatibility maintained via alias)
220
- - Lazy initialization of agent name after MCP handshake completion
221
-
222
- ### Removed
223
-
224
- - **Per-project Skills/Hooks installation** - Use sqlew-plugin from marketplace instead
225
- - **7 help database tables**: m_help_tools, m_help_actions, m_help_use_case_cats, t_help_action_params, t_help_action_examples, t_help_use_cases, t_help_action_sequences
226
- - `help-queries.ts` (replaced by HelpSystemLoader)
227
- - Task and file management tables (deprecated in v4.3.0)
228
-
229
- ---
230
-
231
- ## [4.3.1] - 2026-01-06
232
-
233
- ### Added
234
-
235
- - **`.claude/rules/` integration**: Plan mode templates now installed to `.claude/rules/plan-mode-integration.md` instead of modifying CLAUDE.md directly
236
- - Incremental `.gitignore` updates: Missing sqlew entries are now added even if sqlew section already exists
237
- - Deprecation notices added to `file` tool help (matching `task` tool)
238
-
239
- ### Changed
240
-
241
- - **BREAKING**: `sqlew --init` no longer edits CLAUDE.md - uses `.claude/rules/` directory instead
242
- - Plan mode template enhanced with stronger MUST/REQUIRED language for constraints
243
- - DRY improvements: Common suggest tool logic extracted to `suggest-helpers.ts`
244
-
245
- ### Deprecated
246
-
247
- - **Specialized agents** (`scrum_master`, `researcher`, `architect`): No longer needed with Claude Opus 4.5's improved capabilities. Disabled by default, will be removed in v5.0
248
-
249
- ### Removed
250
-
251
- - Obsolete types from `types.ts` (duplicate JSON Import types, deprecated message system types)
252
- - Unused `messagesCount` from `has-updates` action response
253
- - `[tasks]` and `[vcs]` sections from config.example.toml (task system deprecated in v4.3.0)
254
- - SSH tunnel configuration from config.example.toml (unsupported)
255
-
256
- ---
257
-
258
- ## [4.3.0] - 2026-01-04
259
-
260
- ### Added
261
-
262
- **Plan-to-ADR: Automatic Architecture Decision Records**
263
-
264
- - Automatic ADR generation from Claude Code Plan Mode
265
- - Markdown pattern extraction (📌 Decision / 🚫 Constraint markers)
266
- - File Queue Architecture for async decision processing
267
- - SubagentStop event integration for reliable pattern detection
268
- - Parameter aliases for simplified tool usage (`path` `file_path`, etc.)
269
-
270
- ### Changed
271
-
272
- - Documentation: Removed TOML format references (Markdown-only implementation)
273
- - Unified feature branding as "Plan-to-ADR"
274
- - Quick Start: `sqlew --init` as recommended one-shot setup
275
- - Skills: Updated sqlew-decision-format and sqlew-plan-guidance
276
-
277
- ### Deprecated
278
-
279
- - **`task` tool**: Will be removed in v5.0. Use Claude Code's native TodoWrite instead
280
- - **`file` tool**: Will be removed in v5.0. File tracking was primarily used with task system
281
-
282
- ### Fixed
283
-
284
- - Version alignment across package.json, README.md, CLAUDE.md
285
- - Constraints duplication on automation
286
- - Windows file locking issues with chokidar
287
-
288
- ---
289
-
290
- ## [4.1.2] - 2025-12-25
291
-
292
- ### Fixed
293
-
294
- **Help System & Clean Install**
295
-
296
- - Fixed help system seeding with correct FK constraints
297
- - Added seed migration for missing help system data (action params, examples)
298
- - Fixed `file.record` action no longer requiring `agent_name` parameter
299
- - Resolved clean install issues reported from Claude Desktop
300
-
301
- ---
302
-
303
- ## [4.1.1] - 2025-12-24
304
-
305
- ### Fixed
306
-
307
- **Claude Desktop Compatibility**
308
-
309
- - Fixed MCP protocol corruption caused by migration logs going to stdout
310
- - Changed all `console.log` to `console.error` in migration files (57 files)
311
- - MCP servers must only output JSON-RPC to stdout; debug logs now go to stderr
312
-
313
- ---
314
-
315
- ## [4.1.0] - 2025-12-24
316
-
317
- ### Added
318
-
319
- **Claude Code Hooks Integration**
320
-
321
- - File Queue Architecture for async decision operations
322
- - Hook commands: `suggest`, `track-plan`, `save`, `check-completion`, `mark-done`
323
- - QueueWatcher monitors `.sqlew/queue/pending.json` for changes
324
- - Auto-initialization with `sqlew init --hooks`
325
- - PreToolUse hooks (Task, Write triggers)
326
- - PostToolUse hooks (Edit/Write, TodoWrite, ExitPlanMode triggers)
327
- - Git hooks integration (post-merge, post-rewrite)
328
-
329
- **PostgreSQL Compatibility**
330
-
331
- - Replaced GROUP_CONCAT with string_agg for PostgreSQL
332
- - Expanded GROUP BY clauses for PostgreSQL strictness compliance
333
- - Cross-DB compatibility verified: SQLite, MySQL, MariaDB, PostgreSQL
334
-
335
- ### Changed
336
-
337
- - Hook operations now use file queue instead of direct DB access (<100ms latency)
338
- - QueueWatcher singleton monitors queue file and processes decisions asynchronously
339
-
340
- ---
341
-
342
- ## [4.0.5] - 2025-12-19
343
-
344
- ### Changed
345
-
346
- **License Change: AGPL-3.0 → Apache-2.0**
347
-
348
- - Changed license from AGPLv3 to Apache License 2.0
349
- - More permissive license for commercial and enterprise adoption
350
- - Added NOTICE file with third-party attributions
351
- - Updated LICENSE file with full Apache 2.0 text
352
- - Updated package.json license field
353
-
354
- **Why Apache 2.0?**
355
- - Patent protection for contributors and users
356
- - Widely adopted by major tech companies (Google, Microsoft, AWS)
357
- - Easier enterprise adoption without copyleft concerns
358
- - Compatible with most open source licenses
359
-
360
- ---
361
-
362
- ## [4.0.4] - 2025-12-10
363
-
364
- ### Fixed
365
-
366
- **Slash Command Sync Bug**
367
-
368
- - Fixed `sync-commands.ts` referencing obsolete command files (`sqw-scrum.md`, `sqw-documentor.md`, etc.)
369
- - Updated to use new unified `sqlew.md` command file
370
- - Resolves "Source file not found" errors during npm package installation
371
-
372
- ### Added
373
-
374
- **Agent Skills Configuration**
375
-
376
- - Added `skills` field to agent YAML frontmatter for automatic skill loading
377
- - All sqlew agents now reference `sqlew-plan-guidance` skill
378
- - Agents: `sqlew-architect`, `sqlew-researcher`, `sqlew-scrum-master`
379
-
380
- **Config Example Update**
381
-
382
- - Added `[commands]` section to `assets/config.example.toml`
383
- - Documents the unified `/sqlew` command configuration
384
-
385
- ### Changed
386
-
387
- **Plan Mode Integration Documentation**
388
-
389
- - Changed `Phase 1 (Research)` → `Research Phase` for flexibility
390
- - Changed `Phase 4 (Final Plan)` → `Final Plan Phase`
391
- - Plan mode phases are now semantically named instead of numbered
392
-
393
- **CommandsConfig Simplified**
394
-
395
- - Consolidated 6 individual command options into single `sqlew` option
396
- - Updated `src/config/types.ts` and `src/config/minimal-generator.ts`
397
-
398
- ---
399
-
400
- ## [4.0.3] - 2025-12-04
401
-
402
- ### Added
403
-
404
- **Unified `/sqlew` Slash Command**
405
-
406
- - Consolidated all slash commands (`/sqw-plan`, `/sqw-scrum`, `/sqw-research`, etc.) into single `/sqlew` command
407
- - Natural language interface with automatic intent detection
408
- - 6-level intent priority: List/Status Search Record → Update → Execute → Task Creation
409
- - Supports both English and Japanese keywords
410
- - Removed custom agent definitions (sqlew-architect, scrum-master, sqlew-researcher)
411
-
412
- **Usage Examples:**
413
- ```bash
414
- /sqlew # Show status and suggest next action
415
- /sqlew show remaining tasks # List/Status intent
416
- /sqlew search for auth decisions # Search intent
417
- /sqlew record that we use JWT # Record intent
418
- /sqlew execute pending tasks # Execute intent
419
- ```
420
-
421
- ### Fixed
422
-
423
- **v4_task_details JOIN Bug**
424
-
425
- - Fixed `task.get` action failing with "no such column: td.project_id" error
426
- - Root cause: `v4_task_details` table has only `task_id` as PK, not `project_id`
427
- - Removed invalid `.andOn('t.project_id', '=', 'td.project_id')` from JOIN conditions
428
- - Affected files: `task-queries.ts`, `get.ts`
429
-
430
- ### Changed
431
-
432
- **Documentation Updates**
433
-
434
- - Rewrote `CLAUDE.md` with unified `/sqlew` command section
435
- - Updated `README.md` Quick Start to use `/sqlew`
436
- - Rewrote `docs/SLASH_COMMANDS.md` as Unified /sqlew Command Guide
437
-
438
- ---
439
-
440
- ## [4.0.2] - 2025-11-28
441
-
442
- ### BREAKING CHANGES
443
-
444
- **SQL Dump No Longer Supports Cross-Database Format Conversion**
445
-
446
- The `db:dump` command now generates SQL for the **same database type only**. Cross-database migrations (e.g., SQLite → MySQL) must use JSON export/import instead.
447
-
448
- **Migration Required:**
449
- ```bash
450
- # Old approach (no longer supported)
451
- npx sqlew db:dump mysql backup.sql # Cross-DB conversion removed
452
-
453
- # ✅ New approach: Use JSON for cross-database migration
454
- npx sqlew db:export backup.json # Export to JSON
455
- npx sqlew db:import backup.json # Import to target database
456
- ```
457
-
458
- **Rationale:**
459
- - SQL syntax differences between databases caused data corruption issues
460
- - Case-insensitive pattern matching failed in certain scenarios
461
- - JSON format is database-agnostic and handles all data types correctly
462
-
463
- **Node.js 20+ Required**
464
-
465
- Minimum Node.js version updated from 18.0.0 to 20.0.0.
466
-
467
- ### Added
468
-
469
- **Unified CLI Entry Point**
470
-
471
- - `npx sqlew db:export`, `npx sqlew db:import`, `npx sqlew db:dump` now work directly
472
- - No `npm install` required - just use `npx sqlew <command>`
473
- - CLI commands and MCP server mode unified under single `sqlew` entry point
474
- - Removed separate `sqlew-cli` binary
475
-
476
- ### Fixed
477
-
478
- **Case-Insensitive Validation for Master Records**
479
-
480
- - Added case-insensitive duplicate detection when registering new records
481
- - Prevents duplicate entries like "MyTag" and "mytag" from being created
482
- - Applies to tags, scopes, layers, and other master table entries
483
- - New utility: `src/utils/case-insensitive-validator.ts`
484
-
485
- **SQLite to MySQL SQL Dump Case-Sensitivity Bug**
486
-
487
- - Fixed regex pattern matching that failed with case variations
488
- - SQL dump now correctly handles mixed-case identifiers
489
- - Enhanced schema table export for better compatibility
490
-
491
- ### Changed
492
-
493
- **Export Version Tracking**
494
-
495
- - Export JSON now includes proper version metadata
496
- - Version information helps with import compatibility checks
497
- - Clearer error messages when importing incompatible versions
498
-
499
- **CLI Documentation Update**
500
-
501
- - Updated `docs/cli/README.md` with JSON-first migration workflow
502
- - Added clear guidance on when to use `db:dump` vs `db:export`/`db:import`
503
- - Improved comparison table for migration scenarios
504
-
505
- ### Added
506
-
507
- **Case-Insensitive Validator Utility**
508
-
509
- - New `src/utils/case-insensitive-validator.ts` for consistent validation
510
- - Comprehensive test suite: `src/tests/unit/utils/case-insensitive-validator.test.ts`
511
- - Reusable across all master table operations
512
-
513
- ### Migration Notes
514
-
515
- **Backward Compatibility:**
516
- - Existing databases unaffected
517
- - JSON export/import workflows unchanged
518
- - SQL dumps for same-database-type operations still work
519
-
520
- **Action Required:**
521
- - Update any scripts that use `db:dump` for cross-database migrations
522
- - Switch to `db:export`/`db:import` for SQLite ↔ MySQL ↔ PostgreSQL migrations
523
-
524
- ---
525
-
526
- ## [4.0.1] - 2025-11-28
527
-
528
- ### Removed
529
-
530
- **Database Views Eliminated**
531
-
532
- - Dropped all database views (`v_tagged_constraints`, `v_recent_file_changes`, etc.)
533
- - Views caused migration complexity across SQLite/MySQL/PostgreSQL due to database-specific syntax
534
- - Migration: `20251128000000_drop_all_views.ts`
535
-
536
- ### Changed
537
-
538
- **JOIN-Based Queries**
539
-
540
- - `src/tools/constraints/actions/get.ts` - Replaced `v_tagged_constraints` view with JOIN query
541
- - `src/tools/files/actions/get.ts` - Replaced `v_recent_file_changes` view with JOIN query
542
- - Uses `UniversalKnex` wrapper for cross-database compatibility (date functions, boolean values, string aggregation)
543
-
544
- **VCS Test Cleanup**
545
-
546
- - `src/tests/feature/vcs/git-aware-completion.test.ts` - Added automatic git reset after tests
547
- - Test commits are now automatically dropped when tests complete
548
- - Prevents test artifacts from polluting git history
549
-
550
- ### Added
551
-
552
- **No-Views Guardrail Skill**
553
-
554
- - `.claude/skills/no-views/SKILL.md` - Documentation for view prohibition policy
555
- - `.claude/skills/skill-rules.json` - Added `no-views` rule (enforcement: block)
556
- - Blocks creation of database views, requires JOINs instead
557
-
558
- **Documentation Updates**
559
-
560
- - `CLAUDE.md` - Updated to reflect no-views policy
561
- - Removed Views section from database schema documentation
562
- - Added `no-views` to Guardrail Skills table
563
-
564
- ---
565
-
566
- ## [4.0.0] - 2025-11-27
567
-
568
- ### Changed
569
-
570
- **Concept & Positioning**
571
-
572
- - Reframed sqlew as a **shared SQL-backed context repository** and a **Decision & Constraint repository layer** for AI tools
573
- - Clarified that Decisions capture *why* changes were made and Constraints capture *how* code should be written
574
- - Updated README introduction to focus on "Never Start From Zero Context Again" and the repository-based metaphor instead of generic "memory"
575
-
576
- **Documentation & Cleanup**
577
-
578
- - Updated `README.md` to describe sqlew as a context repository rather than an abstract memory layer
579
- - Aligned terminology across docs around Decisions, Constraints, tasks, and the repository layer
580
- - Confirmed that previously removed/legacy features remain out of scope, keeping focus on decision history and constraint rules
581
-
582
- > Note: v4.0.0 is primarily a **concept and documentation alignment release**. Core Decision/Constraint features and the v3.9.x database schema remain compatible; no breaking API changes were introduced for existing integrations.
583
-
584
- ---
585
-
586
- ## [3.9.0] - 2025-01-15
587
-
588
- ### Added
589
-
590
- **🎯 Decision Intelligence System with Three-Tier Similarity Detection**
591
-
592
- **New `suggest` Tool:**
593
- - **by_key** - Pattern-based decision search (e.g., "api/*/latency" finds all API latency decisions)
594
- - **by_tags** - Tag similarity scoring for related decisions (Jaccard similarity)
595
- - **by_context** - Combined key + tags + layer search for best matches
596
- - **check_duplicate** - Duplicate decision detection with similarity scoring (0-100 points)
597
-
598
- **Three-Tier Duplicate Detection (Auto-Triggered):**
599
- - **Tier 1 (35-44 points):** Gentle nudge - Non-blocking warning with suggestions
600
- - **Tier 2 (45-59 points):** Hard block - Prevents creation, requires explicit override or update
601
- - **Tier 3 (60+ points):** Auto-update - Transparently updates existing decision, preserves new value
602
-
603
- **Similarity Scoring Algorithm:**
604
- - Tag overlap: 0-40 points (10 per matching tag, max 4)
605
- - Layer match: 0-25 points (same layer bonus)
606
- - Key similarity: 0-20 points (pattern + Levenshtein distance)
607
- - Recency: 0-10 points (recent updates prioritized)
608
- - Priority: 0-5 points (critical decisions weighted)
609
-
610
- **Policy-Based Auto-Triggering:**
611
- - Suggestions automatically triggered when policies have `suggest_similar=1`
612
- - Integrated with `decision.set` - returns suggestions in response
613
- - Configurable relevance threshold via `min_score` parameter (default: 30)
614
- - Policy validation rules support for targeted auto-triggering
615
-
616
- **Enhanced Decision Metadata:**
617
- - `duplicate_reason` - Similarity explanation with matched tags and layer info
618
- - `update_command` - Ready-to-use command for updating existing decisions
619
- - `version_info` - Existing decision version tracking
620
- - `auto_updated` flag - Indicates Tier 3 transparent updates
621
-
622
- **Supporting Features:**
623
- - Tag parser utility (`src/utils/tag-parser.ts`) for flexible tag handling
624
- - Policy validation integration (`src/utils/policy-validator.ts`)
625
- - Suggestion scorer (`src/utils/suggestion-scorer.ts`) with breakdown
626
- - Self-exclusion logic (prevents matching against own key during updates)
627
-
628
- ### Fixed
629
-
630
- **PostgreSQL Cross-Database Compatibility**
631
- - Fixed CAST type mismatch in `v_tagged_decisions` view export
632
- - PostgreSQL now correctly handles `COALESCE(TEXT, NUMERIC)` with `CAST(value AS TEXT)`
633
- - MySQL/MariaDB use `CAST(value AS CHAR)` for compatibility
634
- - Migration: `20251114000000_fix_v_tagged_decisions_numeric_support.ts`
635
- - SQL dump export: Enhanced view conversion in `src/utils/sql-dump/schema/views.ts`
636
- - Result: All 20 cross-database tests passing (MySQL, MariaDB, PostgreSQL)
637
-
638
- **Test Suite Improvements**
639
- - Fixed FK constraint cleanup order in `decision-intelligence-e2e.test.ts`
640
- - Child records now deleted before parent records (tags → scopes → context → decisions)
641
- - Result: 3/3 e2e workflow tests passing, no cleanup errors
642
-
643
- **Schema Fixes**
644
- - Migration `20251112000001_fix_task_file_links_schema_v3_9_0.ts` - Fixed UNIQUE constraint
645
- - Migration `20251112000002_fix_task_pruned_files_schema_v3_9_0.ts` - Enhanced task file tracking
646
- - All migrations idempotent with existence checks
647
-
648
- ### Changed
649
-
650
- **Test Organization (Docker Dependency Separation)**
651
- - Moved 7 Docker-dependent tests to `src/tests/docker/` directory
652
- - `npm test` now runs 481 unit tests without Docker (0 failures)
653
- - `npm run test:docker` runs cross-database tests (requires Docker containers)
654
- - Removed `test:all` script (caused database conflicts)
655
- - Updated `.husky/pre-commit` to reflect test separation
656
- - Decision documented in SQLew: `test-organization-docker-separation`
657
-
658
- **Git Hook Enhancement**
659
- - Pre-commit hook now checks for **PUSHED** migration files instead of just committed
660
- - Auto-detects remote branch (origin/main, origin/master, origin/dev)
661
- - Allows editing locally committed migrations (not yet pushed)
662
- - Prevents editing migrations that exist in remote
663
- - Graceful fallback for local-only repositories
664
-
665
- **Debug Output Cleanup**
666
- - Commented out scope validation warnings in test output
667
- - Removed DEBUG/DIAGNOSTIC console.log statements
668
- - Cleaner test output focusing on actual results
669
- - 75% reduction in test output verbosity
670
-
671
- ### Removed
672
-
673
- **Code Cleanup**
674
- - Deleted monolithic `src/utils/sql-dump.ts` (-1,799 lines)
675
- - Functionality now in modular structure:
676
- - `src/utils/sql-dump/schema/tables.ts`
677
- - `src/utils/sql-dump/schema/views.ts`
678
- - `src/utils/sql-dump/schema/primary-keys.ts`
679
- - `src/utils/sql-dump/schema/indexes.ts`
680
- - Deleted test tracking files (`test-tracking/file1.ts`, etc.)
681
-
682
- ### Documentation
683
-
684
- - Updated `CLAUDE.md` - Changed policy from "NEVER EDIT COMMITTED" to "NEVER EDIT PUSHED"
685
- - Created `STAGED_CHANGES_SUMMARY.md` - Comprehensive v3.9.0 change summary
686
- - Created `NEW_TOOL_DESCRIPTION.md` - Suggest tool reference
687
-
688
- ### Performance
689
-
690
- - Enhanced file pruning logic (`src/utils/file-pruning.ts`)
691
- - Improved VCS adapter file status tracking (`src/utils/vcs-adapter.ts`)
692
- - Better task stale detection (`src/utils/task-stale-detection.ts`)
693
- - Activity logging enhancements for suggestion tracking
694
-
695
- ### Testing
696
-
697
- **Test Results:**
698
- - **495/495 tests passing (100%)** - Production-ready
699
- - Tier 1 (Gentle Nudge): 5/5 tests passing
700
- - Tier 2 (Hard Block): 2/2 tests passing
701
- - ✅ Tier 3 (Auto-Update): 3/3 tests passing
702
- - ✅ Auto-trigger suggestions: 4/4 tests passing
703
- - Edge cases and error handling: All passing
704
- - 20/20 cross-database tests passing (MySQL, MariaDB, PostgreSQL)
705
- - 7 Docker test suites in separate directory
706
-
707
- **Test Suite Enhancements:**
708
- - AI-optimized quiet mode (80-90% token reduction, shows only failures + summary)
709
- - Verbose mode available with `:verbose` suffix (e.g., `npm run test:verbose`)
710
- - Cross-platform filter script (`scripts/filter-test-output.js`)
711
- - Comprehensive three-tier similarity detection test coverage
712
-
713
- **Coverage:**
714
- - Overall: 64.85% line coverage
715
- - All critical paths tested
716
- - Zero flaky tests
717
-
718
- ### Migration Notes
719
-
720
- **Backward Compatibility:**
721
- - v3.9.0 is fully backward compatible with v3.8.x
722
- - No breaking changes
723
- - Automatic migration on server startup
724
-
725
- **Database Changes:**
726
- - 3 new enhancement migrations (all idempotent)
727
- - Schema changes apply automatically
728
- - Safe to rollback by restoring backup
729
-
730
- **Files Changed:**
731
- - 50 files modified
732
- - 1,857 insertions, 2,096 deletions
733
- - Net: -239 lines (code reduction through refactoring)
734
-
735
- ---
736
-
737
- ## [3.8.1] - 2025-11-11
738
-
739
- ### Fixed
740
-
741
- **Critical Installation Bug**
742
-
743
- - Fixed `npm error Invalid Version:` error when installing sqlew@3.8.0
744
- - Changed `@modelcontextprotocol/sdk` dependency from `"latest"` to `"^1.21.1"` in package.json
745
- - The `"latest"` tag is not a valid semver version for published packages and caused npm dependency resolution to fail
746
- - This is a **hotfix release** that resolves installation issues preventing users from using v3.8.0
747
-
748
- **Impact:**
749
- - All users experiencing `Invalid Version:` errors when running `npx sqlew` can now install successfully
750
- - No functional changes from v3.8.0 - only dependency version fix
751
-
752
- ---
753
-
754
- ## [3.8.0] - 2025-11-09
755
-
756
- ### BREAKING CHANGES
757
-
758
- **Batch Action Naming Standardization**
759
-
760
- `task.batch_create` has been renamed to `task.create_batch` to follow the `<verb>_batch` naming pattern used by other batch actions (`set_batch`, `record_batch`).
761
-
762
- **Migration Required:**
763
- ```typescript
764
- // Old (v3.7.x and earlier)
765
- task({ action: "batch_create", tasks: [...] })
766
-
767
- // New (v3.8.0+)
768
- task({ action: "create_batch", tasks: [...] })
769
- ```
770
-
771
- **Rationale:**
772
- - Achieves 100% consistency across all batch actions
773
- - Improves alphabetical sorting in IDE auto-completion (create → create_batch)
774
- - Aligns with industry standard (REST APIs, GraphQL, ORMs use suffix pattern)
775
- - See docs/ADR-batch-naming-standard.md for full justification
776
-
777
- **Impact:**
778
- - All code using `task.batch_create` must update to `task.create_batch`
779
- - Simple find-replace migration (estimated 2-5 minutes per integration)
780
- - No database schema changes required
781
-
782
- ### Removed
783
-
784
- **Config Tool Removed (Phase 6)**
785
-
786
- The orphaned config tool has been removed in favor of CLI-only configuration:
787
-
788
- - **Deleted**: `src/tools/config.ts` (307 lines)
789
- - **Removed**: `ConfigAction` type from `src/types.ts` and `src/types/actions.ts`
790
- - **Removed**: ConfigAction import from `src/utils/parameter-validator.ts`
791
- - **Updated**: README.md with CLI-only config approach documentation
792
- - **Updated**: docs/CONFIGURATION.md already documented config tool removal
793
-
794
- **Why removed:**
795
- - Config tool was never registered in `tool-registry.ts` (orphaned code)
796
- - Messaging system deprecated (primary use case eliminated)
797
- - File-based configuration (`.sqlew/config.toml`) is clearer and more maintainable
798
- - Runtime updates were confusing (changes lost on restart unless manually synced to file)
799
- - Configuration drift between `m_config` table and config file
800
-
801
- **Migration Path:**
802
- - **Use `.sqlew/config.toml`** for all configuration (persistent, version-controlled)
803
- - **Use CLI arguments** for one-time overrides (`--autodelete-message-hours=48`)
804
- - **Internal config operations** preserved (`src/database/config/config-ops.ts`)
805
- - **m_config table** preserved (used internally by retention logic)
806
-
807
- **Impact:**
808
- - Cleaner codebase with ~300 lines removed
809
- - No functional impact - tool was never registered
810
- - Configuration via file and CLI arguments only
811
-
812
- **Message Tool Completely Removed**
813
-
814
- The deprecated message tool has been completely removed from the codebase:
815
-
816
- - **Deleted**: `src/tools/messaging.ts` (599 lines)
817
- - **Removed**: Message tool entry from `tool-registry.ts`
818
- - **Removed**: Message tool handler from `tool-handlers.ts`
819
- - **Removed**: Message imports from `cli.ts`
820
- - **Updated**: `MessageAction` type changed to `never` (backward compatibility stub)
821
- - **CLI**: `sqlew query messages` now returns error message
822
-
823
- **Migration Path**:
824
- - No action required - messaging system was already marked deprecated in v3.6.6
825
- - The `t_agent_messages` table was dropped in v3.6.6
826
- - All message tool actions returned deprecation warnings since v3.6.6
827
-
828
- **Impact**:
829
- - Cleaner codebase with ~700 lines removed
830
- - No functional impact - messaging system was unused
831
- - MessageAction type remains as deprecated stub for backward compatibility
832
-
833
- ### Added
834
-
835
- **Layer Expansion (5→9 layers)**
836
-
837
- Added 4 new layers to enable better task classification and semantic validation:
838
-
839
- **New FILE_REQUIRED layers:**
840
- - `documentation` - README, CHANGELOG, API docs, architecture docs (file_actions required)
841
-
842
- **New FILE_OPTIONAL layers:**
843
- - `planning` - Research, spike tasks, investigation (file_actions optional)
844
- - `coordination` - Multi-agent orchestration, task delegation (file_actions optional)
845
- - `review` - Code review, design review, verification (file_actions optional)
846
-
847
- **Existing layers** (5→6 FILE_REQUIRED):
848
- - presentation, business, data, infrastructure, cross-cutting (file_actions required or empty array)
849
-
850
- **Benefits:**
851
- - Documentation layer enforces file operations for docs work
852
- - Planning layers allow pure research tasks without file boilerplate
853
- - Better semantic task classification across the development lifecycle
854
-
855
- **file_actions Parameter for Tasks**
856
-
857
- Introduced semantic `file_actions` parameter to replace generic `watch_files`:
858
-
859
- ```typescript
860
- // New file_actions parameter
861
- task.create({
862
- title: "Implement OAuth",
863
- layer: "business",
864
- file_actions: [
865
- { action: "create", path: "src/auth/oauth.ts" },
866
- { action: "edit", path: "src/api/router.ts" },
867
- { action: "delete", path: "src/auth/legacy.ts" }
868
- ]
869
- });
870
-
871
- // Backward compatible - watch_files still works
872
- task.create({
873
- title: "Update config",
874
- layer: "infrastructure",
875
- watch_files: ["config.toml"] // Auto-converts to file_actions
876
- });
877
- ```
878
-
879
- **Layer-Based Validation:**
880
- - FILE_REQUIRED layers (6) Must provide `file_actions` or `[]`
881
- - FILE_OPTIONAL layers (3) → Can omit `file_actions` entirely
882
- - Clear error messages with layer-specific guidance
883
-
884
- **Benefits:**
885
- - Self-documenting: `action: 'create'` vs `action: 'edit'` shows intent
886
- - Prevents forgotten file watchers (validation enforced)
887
- - No boilerplate for planning tasks (can omit parameter)
888
- - Better token efficiency with automatic file watching
889
-
890
- **PostgreSQL Adapter Implementation**
891
-
892
- Full PostgreSQL 12+ support with complete adapter implementation:
893
-
894
- **Adapter Features:**
895
- - All 15 abstract methods implemented (`insertReturning`, `upsert`, `jsonExtract`, etc.)
896
- - PostgreSQL-specific SQL syntax (RETURNING, ON CONFLICT, string_agg)
897
- - Strict type handling (TRUE/FALSE for booleans, not 1/0)
898
- - Timezone-aware timestamp functions
899
- - Transaction support with savepoints
900
-
901
- **Migration Compatibility:**
902
- - All 22 migrations tested and verified on PostgreSQL 16.10
903
- - Cross-database helper functions for view creation
904
- - Proper CASCADE handling for foreign key dependencies
905
- - Sequence management after explicit ID inserts
906
- - GROUP BY strictness compliance
907
-
908
- **Supported Databases:**
909
- - SQLite 3.x (default, development)
910
- - MySQL 8.0 / MariaDB 10+ (production)
911
- - PostgreSQL 12+ (production) NEW
912
-
913
- **Configuration:**
914
- ```toml
915
- [database]
916
- type = "postgres"
917
-
918
- [database.connection]
919
- host = "localhost"
920
- port = 5432
921
- database = "sqlew_db"
922
-
923
- [database.auth]
924
- type = "direct"
925
- user = "sqlew_user"
926
- password = "secret"
927
- ```
928
-
929
- ### Fixed
930
-
931
- **Batch Action Parameter Parsing**
932
-
933
- Fixed MCP client array serialization issue affecting all batch actions:
934
-
935
- **Problem:** MCP client serializes array parameters as JSON strings:
936
- ```typescript
937
- // MCP sends:
938
- decisions: "[{\"key\": \"test\", \"value\": \"val\"}]" // String!
939
-
940
- // Expected:
941
- decisions: [{key: "test", value: "val"}] // Array
942
- ```
943
-
944
- **Solution:** Added JSON parsing in `tool-handlers.ts` for all batch actions:
945
- - `decision.set_batch` - parse `decisions` parameter
946
- - `file.record_batch` - parse `file_changes` parameter
947
- - `task.create_batch` - parse `tasks` parameter
948
-
949
- **Impact:** All batch actions now work correctly with array parameters from MCP client.
950
-
951
- **Help System Synchronization**
952
-
953
- Fixed critical bug where help database was severely out of sync with code:
954
-
955
- **Problem:** 25 actions missing from `m_help_actions` table, causing help system to lie about available actions.
956
-
957
- **Missing Actions:**
958
- - decision: 9 actions (quick_set, search_advanced, set_batch, has_updates, etc.)
959
- - task: 14 actions (update, get, list, move, link, archive, create_batch, etc.)
960
- - constraint: 1 action (use_case)
961
-
962
- **Solution:** Created migration `20251109020000_fix_missing_help_actions_v3_8_0.ts` to:
963
- - Add all 25 missing actions with correct descriptions
964
- - Idempotent checks to prevent duplicates
965
- - Full synchronization between code and database
966
-
967
- **Impact:** Help system now accurately reports all available actions.
968
-
969
- ### Changed
970
-
971
- **Tool Registry Schema Fix**
972
-
973
- Added `additionalProperties: true` to all tool schemas in `tool-registry.ts`:
974
-
975
- **Problem:** MCP couldn't pass action-specific parameters (key, value, tags, etc.) because schemas only defined `action` property.
976
-
977
- **Solution:**
978
- ```typescript
979
- {
980
- name: 'decision',
981
- inputSchema: {
982
- type: 'object',
983
- properties: {
984
- action: { ... }
985
- },
986
- required: ['action'],
987
- additionalProperties: true, // ← CRITICAL FIX
988
- },
989
- }
990
- ```
991
-
992
- **Impact:** All MCP tools now accept action-specific parameters correctly.
993
-
994
- ---
995
-
996
- ## [3.7.4] - 2025-11-08
997
-
998
- ### Added - Complete JSON Import/Export System
999
-
1000
- **Full-featured data migration system with smart ID remapping and dependency resolution**
1001
-
1002
- #### New Features
1003
-
1004
- - **db:import CLI Command** - Import project data from JSON exports with automatic ID remapping
1005
- - Smart conflict detection (skip-if-exists, project-name override)
1006
- - Dry-run mode for validation before import
1007
- - Comprehensive error messages with validation details
1008
- - **Topological Sort Algorithm** - Resolves task dependencies during import
1009
- - Circular dependency detection prevents import of invalid dependency graphs
1010
- - BFS-based topological sorting ensures dependencies imported before dependents
1011
- - Preserves all task relationships and blocking constraints
1012
- - **Smart ID Remapping** - Handles complex foreign key relationships
1013
- - Master table merge logic (reuse existing entries by name/path)
1014
- - Transaction table ID translation with bidirectional mapping
1015
- - Junction table relationship preservation
1016
- - Automatic orphan cleanup for invalid references
1017
-
1018
- #### Import System Architecture
1019
-
1020
- - **4 Core Modules**:
1021
- 1. `import.ts` - Main orchestrator with transaction management
1022
- 2. `master-tables.ts` - Master table merge logic (m_files, m_tags, m_scopes, etc.)
1023
- 3. `topological-sort.ts` - Dependency graph analysis and sorting
1024
- 4. `db-import.ts` - CLI command with argument parsing and validation
1025
-
1026
- #### Data Migration Strategy
1027
-
1028
- - **ID Remapping**: All imported data gets fresh auto-incremented IDs (no ID preservation)
1029
- - **Master Table Deduplication**: Reuse existing entries for agents, tags, scopes, files by name/path
1030
- - **Transaction Atomicity**: All-or-nothing semantics (full rollback on any error)
1031
- - **Project Isolation**: Each import creates independent project with no cross-contamination
1032
-
1033
- #### CLI Examples
1034
-
1035
- ```bash
1036
- # Import project from JSON export
1037
- npx sqlew db:import --source=project-backup.json
1038
-
1039
- # Import with custom project name
1040
- npx sqlew db:import --source=data.json --project-name=my-project
1041
-
1042
- # Dry-run validation (no actual import)
1043
- npx sqlew db:import --source=data.json --dry-run
1044
-
1045
- # Export project for migration
1046
- npx sqlew db:export --project=visualizer --output=visualizer-data.json
1047
- ```
1048
-
1049
- #### Technical Details
1050
-
1051
- - **Batch Inserts** - 10-row batches to avoid SQLite UNION ALL limits
1052
- - **Foreign Key Validation** - Validates all foreign key references before insertion
1053
- - **View Handling** - Temporarily drops/restores views during schema changes
1054
- - **Idempotent Operations** - Safe to retry on failure
1055
- - **Error Recovery** - Detailed error messages with validation guidance
1056
-
1057
- #### Use Cases
1058
-
1059
- - **Multi-Project Single Database** - Consolidate multiple projects when database creation permissions are limited
1060
- - **Project Sharing** - Share context with team members or between machines
1061
- - **Cross-Database Migration** - Move projects between different databases (different machine, SQLite → MySQL, etc.)
1062
-
1063
- **Note**: Import uses `--skip-if-exists=true` by default. This is NOT a backup/restore solution for the same database.
1064
- Use database-level backups (SQLite file copy, MySQL dump) for backup/restore scenarios.
1065
-
1066
- #### Impact
1067
-
1068
- - **Complete migration solution** - Export from one database, import to another
1069
- - ✅ **Multi-project support** - Merge multiple project exports into single database
1070
- - **Permission-friendly** - Works for users who can't create multiple databases
1071
- - **Data integrity** - Zero data loss, all relationships preserved
1072
- - **Production ready** - Comprehensive error handling and validation
1073
- - **Cross-database compatible** - JSON format works across SQLite, MySQL, PostgreSQL
1074
-
1075
- ---
1076
-
1077
- ### Fixed - Multi-Project Migration (HOTFIX)
1078
-
1079
- **Critical fix for v3.7.0-v3.7.2 migration in multi-project scenarios**
1080
-
1081
- #### Problem
1082
-
1083
- - Users upgrading from v3.6.10 to v3.7.0+ could end up with duplicate projects
1084
- - Migration 20251104000000 created project #1 with fake name "default-project"
1085
- - Users creating second project manually resulted in namespace conflicts
1086
-
1087
- #### Solution
1088
-
1089
- - Enhanced migration idempotency checks
1090
- - Improved project consolidation logic
1091
- - Better handling of existing project scenarios
1092
-
1093
- #### Impact
1094
-
1095
- - **Safe multi-project migration** - No duplicate projects created
1096
- - **Backward compatible** - Works for both fresh installs and upgrades
1097
- - ✅ **Data preservation** - All existing data maintained correctly
1098
-
1099
- ---
1100
-
1101
- ## [3.7.3] - 2025-11-06
1102
-
1103
- ### Fixed - Master Tables Namespace Collision Bug
1104
-
1105
- **Critical bug fix for incomplete multi-project support in v3.7.0-v3.7.2**
1106
-
1107
- #### Problem
1108
- - Master tables (m_files, m_tags, m_scopes) lacked `project_id` columns in v3.7.0-v3.7.2
1109
- - This caused **namespace collisions** where identical file paths/tag names/scope names from different projects would conflict
1110
- - Example: "src/index.ts" from ProjectA would collide with ProjectB's "src/index.ts"
1111
- - Users upgrading from v3.6.x would have fake project name "default-project" instead of detected real name
1112
-
1113
- #### Solution
1114
- - **20251106000000_fix_master_tables_project_id_v3_7_3.ts** - Comprehensive migration that:
1115
- 1. **Data Consolidation** - Detects v3.7.0-v3.7.2 upgrade scenario and consolidates project #2 data into project #1
1116
- 2. **Project Rename** - Renames fake "default-project" to real detected name (from config.toml/git remote/directory)
1117
- 3. **Schema Fix** - Adds `project_id` column to m_files, m_tags, m_scopes with composite UNIQUE constraints
1118
- 4. **Data Migration** - Maps all existing master table data to default project (ID 1)
1119
- 5. **Orphan Cleanup** - Filters out 95 orphaned foreign key references (deleted tasks/tags)
1120
- 6. **View Restoration** - Temporarily drops and restores 4 views during migration
1121
- 7. **Table Restoration** - Backs up and restores 6 referencing tables with updated foreign keys
1122
-
1123
- #### Migration Details
1124
- - **Idempotent** - Can run multiple times safely (checks for existing columns)
1125
- - **Version-Aware** - Only consolidates data for v3.7.0-v3.7.2 databases (detects fake project names)
1126
- - **Batch Inserts** - Uses 10-row batches to avoid SQLite UNION ALL limits
1127
- - **FK Filtering** - Validates foreign key references before restoration to prevent constraint errors
1128
- - **SQLite-Optimized** - Handles better-sqlite3 FK constraint behavior during table drops
1129
-
1130
- #### Technical Changes
1131
- - **m_files**: Added `project_id` column, changed UNIQUE constraint from `(path)` to `(project_id, path)`
1132
- - **m_tags**: Added `project_id` column, changed UNIQUE constraint from `(name)` to `(project_id, name)`
1133
- - **m_scopes**: Added `project_id` column, changed UNIQUE constraint from `(name)` to `(project_id, name)`
1134
- - **Referencing Tables**: Updated t_file_changes, t_task_file_links, t_decision_tags, t_task_tags, t_constraint_tags, t_decision_scopes
1135
- - **Views**: Restored v_layer_summary, v_task_board, v_tagged_decisions, v_tagged_constraints
1136
-
1137
- #### Impact
1138
- - ✅ **Fixed namespace collisions** - Files/tags/scopes from different projects can now have identical names
1139
- - ✅ **Data integrity** - All existing data preserved and mapped correctly
1140
- - ✅ **Project consolidation** - v3.7.0-v3.7.2 users get clean migration path
1141
- - ✅ **Real project names** - No more fake "default-project" names
1142
- - **Orphan cleanup** - Removed invalid foreign key references automatically
1143
- - **Full idempotency** - Migration can be safely re-run if interrupted
1144
-
1145
- #### Testing
1146
- - ✅ Tested on actual v3.7.2 production database (mcp-sqlew project)
1147
- - ✅ Successfully consolidated 77 decisions, 191 tasks, 61 file changes
1148
- - Filtered 95 orphaned task-tag references
1149
- - All views and referencing tables restored correctly
1150
- - Final database state validated with composite UNIQUE constraints working
1151
-
1152
- ---
1153
-
1154
- ## [3.7.2] - 2025-11-05
1155
-
1156
- ### Changed - Enhanced Sub-Agent Templates
1157
-
1158
- **Improved specialized agent templates for more efficient sqlew usage**
1159
-
1160
- #### Sub-Agent Template Updates
1161
- - **sqlew-scrum-master.md** - Enhanced multi-agent coordination and task management workflows
1162
- - **sqlew-researcher.md** - Improved decision querying and context analysis patterns
1163
- - **sqlew-architect.md** - Enhanced decision documentation and constraint enforcement workflows
1164
-
1165
- #### New Documentation
1166
- - Installation and configuration instructions
1167
- - Usage examples for each agent
1168
- - Token optimization guidelines
1169
- - Agent comparison and capability matrix
1170
- - Integration patterns
1171
- - Troubleshooting guide
1172
-
1173
- #### SQL Dump Enhancements
1174
- - Added type conversion testing (`src/tests/type-conversion.test.ts`)
1175
- - Enhanced SQL dump converters for better type handling
1176
- - Improved SQL dump utilities with expanded functionality
1177
-
1178
- ### Fixed - Git LFS PNG Display Issue
1179
-
1180
- **Removed Git LFS tracking for PNG files to fix GitHub display**
1181
-
1182
- #### Problem
1183
- - PNG files were tracked with Git LFS, causing display issues on GitHub
1184
- - Users without Git LFS saw ASCII pointers instead of images
1185
- - README images were not rendering properly
1186
-
1187
- #### Solution
1188
- - Removed `*.png filter=lfs diff=lfs merge=lfs -text` from .gitattributes
1189
- - Restored actual PNG binary files from pre-LFS commits
1190
- - All PNG images now display correctly on GitHub without requiring Git LFS
1191
-
1192
- #### Impact
1193
- - **Better agent templates** - More efficient sqlew usage patterns
1194
- - **Comprehensive documentation** - Clear installation and usage guides
1195
- - ✅ **Improved type handling** - Better SQL dump type conversion
1196
- - ✅ **Fixed GitHub display** - PNG images now render properly without Git LFS
1197
- - ✅ **Token efficient** - Optimized agent workflows reduce unnecessary tool calls
1198
-
1199
- ---
1200
-
1201
- ## [3.7.1] - 2025-11-05
1202
-
1203
- ### Fixed - Error Message Visibility
1204
-
1205
- **Fixed validation error messages being hidden by error wrapper**
1206
-
1207
- #### Problem
1208
- - Validation errors (JSON-structured responses) were being wrapped with stack traces
1209
- - Wrong-usage messages were hidden from MCP clients
1210
- - Users received generic error messages instead of helpful validation details
1211
-
1212
- #### Solution
1213
- - **Error Handler Enhancement** - Detect and unwrap JSON validation errors
1214
- - Validation errors now returned directly to MCP client without wrapping
1215
- - Stack traces written to logs only (not returned to client)
1216
- - Token-efficient responses without exposing internal stack details
1217
- - **Parameter Validator Enhancement** - Detect unexpected/invalid parameters
1218
- - Added validation for parameters that don't match valid list and have no typo suggestion
1219
- - Improved error messages: "Unexpected params: X. Valid params: Y, Z"
1220
-
1221
- #### Impact
1222
- - **Better UX** - Validation errors are now visible and actionable
1223
- - ✅ **Token efficiency** - No stack traces in MCP responses
1224
- - **Clearer feedback** - Users see helpful error messages immediately
1225
- - **Security** - Internal stack details not exposed to clients
1226
-
1227
- ---
1228
-
1229
- ## [3.7.0] - 2025-11-05
1230
-
1231
- ### Added - Runtime Database Reconnection
1232
-
1233
- **Automatic connection recovery with exponential backoff retry logic**
1234
-
1235
- #### Features
1236
- - **ConnectionManager** - Singleton wrapper for all database operations
1237
- - **Exponential Backoff** - Retry delays: 1s 2s → 4s → 8s → 16s (31 seconds total)
1238
- - **Smart Error Detection** - Recognizes connection errors across SQLite, MySQL, PostgreSQL
1239
- - **Process.exit on Exhaustion** - Exits cleanly after 5 failed retries
1240
- - **27 Operations Wrapped** - All transactional operations protected:
1241
- - context.ts: 5 operations
1242
- - tasks.ts: 9 operations
1243
- - files.ts: 3 operations
1244
- - constraints.ts: 3 operations
1245
- - config.ts: 2 operations
1246
- - utils.ts: 5 operations
1247
-
1248
- #### Connection Error Patterns Detected
1249
- - **Network Errors**: ECONNREFUSED, ENOTFOUND, ETIMEDOUT, ECONNRESET, EPIPE
1250
- - **SQLite**: "database is locked", "unable to open database"
1251
- - **MySQL/MariaDB**: "server has gone away", "lost connection to mysql server"
1252
- - **PostgreSQL**: "connection to server was lost", "could not connect to server"
1253
- - **Knex-specific**: "timeout acquiring a connection", "pool is destroyed"
1254
-
1255
- #### Test Coverage
1256
- - **41 tests passing** (22 unit + 19 integration)
1257
- - Retry behavior verification
1258
- - Production scenario simulation (server restart, network failures)
1259
- - Tool integration testing
1260
-
1261
- #### Impact
1262
- - **Resilient operations** - Automatic recovery from transient connection failures
1263
- - ✅ **Production ready** - Handles server restarts, network issues
1264
- - **Zero regressions** - All existing tests pass
1265
- - ✅ **Token efficient** - No manual retry logic needed in agent code
1266
-
1267
- ---
1268
-
1269
- ### Changed - Validation Error Messages
1270
-
1271
- **70-85% token reduction in error message size**
1272
-
1273
- #### Token Efficiency
1274
- - **Before**: ~1000+ characters (~300+ tokens) with full examples embedded
1275
- - **After**: ~200 characters (~50 tokens) with reference IDs
1276
- - **Reduction**: 70-85% token savings
1277
-
1278
- #### New Error Format
1279
- ```json
1280
- {
1281
- "error": "Missing: key, value",
1282
- "action": "set",
1283
- "reference": "decision.set",
1284
- "missing": ["key", "value"],
1285
- "hint": "Use 'quick_set' for simpler usage..."
1286
- }
1287
- ```
1288
-
1289
- #### Features
1290
- - **Reference IDs** - Compact `{tool}.{action}` format (e.g., "decision.set")
1291
- - **Concise Messages** - Essential information only
1292
- - **Conditional Fields** - Only include fields when present
1293
- - **Self-Documenting** - AI can query `action: "help"` for full docs if needed
1294
-
1295
- #### Error Types
1296
- - Missing params: `"Missing: key, value"`
1297
- - Typos: `"Invalid params: val value"`
1298
- - Unknown action: `"Unknown action 'sett'. Did you mean: set?"`
1299
-
1300
- #### Impact
1301
- - **Token efficiency** - 70-85% reduction in error size
1302
- - **Cost reduction** - Lower API costs for AI agents
1303
- - **Better UX** - Quick, scannable errors
1304
- - **Backward compatible** - Error structure unchanged
1305
-
1306
- ---
1307
-
1308
- ### Changed - Debug Log Format
1309
-
1310
- **Single-line log entries for easier parsing**
1311
-
1312
- #### Problem
1313
- Multi-line log messages broke standard text processing tools (grep, awk, log rotation).
1314
-
1315
- #### Solution
1316
- - **Sanitization Function** - Replaces newlines with spaces, collapses whitespace
1317
- - **Applied To**: All log messages, data values, JSON output
1318
- - **Result**: Every log entry is exactly one line
1319
-
1320
- #### Benefits
1321
- - ✅ **Easier parsing** - Line-based tools work correctly
1322
- - ✅ **Better grep** - Search across entire messages
1323
- - ✅ **Simpler analysis** - Standard text processing
1324
- - ✅ **Cleaner output** - No unexpected line breaks
1325
-
1326
- #### Example
1327
- **Before:**
1328
- ```
1329
- [2025-11-05T02:00:00.000Z] [ERROR] Error details:
1330
- Stack trace line 1
1331
- Stack trace line 2
1332
- ```
1333
-
1334
- **After:**
1335
- ```
1336
- [2025-11-05T02:00:00.000Z] [ERROR] Error details: Stack trace line 1 Stack trace line 2
1337
- ```
1338
-
1339
- ---
1340
-
1341
- ### Changed - Specialized Agent Templates (Error Prevention)
1342
-
1343
- **Restructured agent templates to reduce tool call errors from 60% to <10%**
1344
-
1345
- #### Problem
1346
- - 60% of agent errors: missing `action` parameter in tool calls
1347
- - Templates embedded outdated action samples that became obsolete
1348
- - Agents guessed syntax instead of using discovery workflow
1349
-
1350
- #### Solution
1351
- All three agent templates restructured with error-prevention focus:
1352
- - **sqlew-architect.md** - Decision documentation specialist
1353
- - **sqlew-researcher.md** - Context analysis specialist
1354
- - **sqlew-scrum-master.md** - Sprint coordination specialist
1355
-
1356
- #### Key Improvements
1357
- - ⚠️ **Prominent Error-Prevention Section** - "CRITICAL: Error-Free sqlew Tool Usage" at top
1358
- - 📚 **Discovery-First Workflow** - Guides agents: `action: "help"` → `action: "example"` → copy/modify
1359
- - ❌✅ **Zero-Error Pattern** - Clear WRONG/CORRECT examples for every common mistake:
1360
- - Missing `action` parameter
1361
- - Wrong data types (priority: string vs number)
1362
- - Wrong parameter names (old v2.x API)
1363
- - 🔍 **Pre-Execution Checklist** - Verify `action` parameter before every tool call
1364
- - 🗑️ **No Embedded Samples** - Removed action lists to prevent outdated syntax
1365
- - 🛠️ **Common Data Type Errors** - Shows tag arrays, boolean atomics, integer priorities
1366
-
1367
- #### Upgrade Path
1368
- **Note**: Existing `.claude/agents/` files NOT auto-upgraded (preserves customizations)
1369
-
1370
- **Manual upgrade required**:
1371
- ```bash
1372
- # Remove old templates
1373
- rm .claude/agents/sqlew-{architect,researcher,scrum-master}.md
1374
-
1375
- # Restart MCP server (auto-copies new templates from assets/sample-agents/)
1376
- ```
1377
-
1378
-
1379
- #### Impact
1380
- - ✅ **Target: 60% <10% error rate** for agent tool calls
1381
- - ✅ **Better UX** - Clear guidance prevents common mistakes
1382
- - ✅ **Self-Correcting** - Agents learn correct patterns from errors
1383
- - ✅ **Future-Proof** - Discovery workflow adapts to API changes
1384
-
1385
- ---
1386
-
1387
- ### Fixed - Multi-Project Migration (Critical)
1388
-
1389
- **Fixed migration for ALL users upgrading from v3.6.10 to v3.7.0**
1390
-
1391
- #### Problem
1392
- - SQLite's `ALTER TABLE` silently failed for 4 tables with complex foreign keys
1393
- - Migration reported success but columns weren't added
1394
- - Task creation would fail: `"table t_task_details has no column named project_id"`
1395
-
1396
- #### Root Cause
1397
- SQLite cannot modify tables with `ON DELETE CASCADE` constraints using ALTER TABLE.
1398
-
1399
- #### Solution
1400
- - **Table Recreation Strategy** - Backup Drop Recreate → Restore
1401
- - **4 Tables Fixed**:
1402
- - `t_task_details` (STEP 4.7)
1403
- - `t_task_file_links` (STEP 4.8)
1404
- - `t_task_decision_links` (STEP 4.9)
1405
- - `t_task_tags` (composite PRIMARY KEY)
1406
-
1407
- #### Idempotency
1408
- All recreation steps check if `project_id` exists before executing:
1409
- ```typescript
1410
- const hasProjectId = await knex.schema.hasColumn('table_name', 'project_id');
1411
- if (!hasProjectId) {
1412
- // Recreation logic
1413
- }
1414
- ```
1415
-
1416
- #### Data Preservation Verified
1417
- - 223 task detail rows preserved
1418
- - 632 task tag rows preserved
1419
- - All task links preserved
1420
- - 100% data integrity maintained
1421
-
1422
- #### Testing
1423
- - Fresh installation works
1424
- - v3.6.10 v3.7.0 upgrade works
1425
- - ✅ Migration can be re-run safely (idempotent)
1426
- - TypeScript compiles without errors
1427
-
1428
- #### Impact
1429
- - ✅ **Production ready** - Safe for all v3.6.10 users to upgrade
1430
- - ✅ **No data loss** - All existing data preserved
1431
- - **Idempotent** - Can re-run without errors
1432
-
1433
- ---
1434
-
1435
- ## [3.6.10] - 2025-10-30
1436
-
1437
- ### Added - Environment Variable Support for Project Root
1438
-
1439
- **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1440
-
1441
- #### Problem
1442
- - Junie AI and other MCP clients require absolute paths in configuration
1443
- - Users had to hardcode project-specific paths in MCP server config
1444
- - No easy way to use project-relative database paths
1445
-
1446
- #### Solution
1447
- - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1448
- - MCP clients can now pass project directory via environment variable
1449
- - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1450
-
1451
- #### Priority Order
1452
- 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1453
- 2. `--db-path` CLI argument (absolute path)
1454
- 3. `--config-path` CLI argument (absolute path)
1455
- 4. `database.path` in config file (absolute path)
1456
- 5. `process.cwd()` fallback
1457
-
1458
- #### Junie AI Configuration Example
1459
- ```json
1460
- {
1461
- "mcpServers": {
1462
- "sqlew": {
1463
- "command": "npx",
1464
- "args": ["sqlew"],
1465
- "env": {
1466
- "SQLEW_PROJECT_ROOT": "{projectDir}"
1467
- }
1468
- }
1469
- }
1470
- }
1471
- ```
1472
-
1473
- **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1474
-
1475
- #### Impact
1476
- - ✅ **Project-relative databases** without hardcoded absolute paths
1477
- - ✅ **Cleaner MCP configuration** (no per-project path updates needed)
1478
- - ✅ **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1479
- - ✅ **No breaking changes** (environment variable is optional)
1480
-
1481
- ---
1482
-
1483
- ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1484
-
1485
- **Eliminated console output for strict JSON-RPC protocol compliance**
1486
-
1487
- #### Problem
1488
- - EPIPE (broken pipe) errors when running with Junie AI on Windows
1489
- - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1490
- - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1491
-
1492
- #### Changes
1493
- - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1494
- - Modified `safeConsoleError()` to write to debug log instead of stderr
1495
- - Replaced 50+ console.log/console.error calls across codebase:
1496
- - `src/database.ts` - Database initialization messages
1497
- - `src/watcher/file-watcher.ts` - File watcher status and events
1498
- - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1499
- - `src/tools/tasks.ts` - Task file registration warnings
1500
- - `src/config/example-generator.ts` - First launch messages
1501
-
1502
- #### Technical Details
1503
- - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1504
- - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1505
- - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1506
- - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1507
-
1508
- #### Impact
1509
- - ✅ **Works with strict MCP clients** (Junie AI, etc.)
1510
- - **Maintains full diagnostics** via debug log file
1511
- - **Pure JSON-RPC protocol** compliance
1512
- - **No breaking changes** to MCP tool functionality
1513
-
1514
- ---
1515
-
1516
- ### Added - Environment Variable Support for Project Root
1517
-
1518
- **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1519
-
1520
- #### Problem
1521
- - Junie AI and other MCP clients require absolute paths in configuration
1522
- - Users had to hardcode project-specific paths in MCP server config
1523
- - No easy way to use project-relative database paths
1524
-
1525
- #### Solution
1526
- - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1527
- - MCP clients can now pass project directory via environment variable
1528
- - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1529
-
1530
- #### Priority Order
1531
- 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1532
- 2. `--db-path` CLI argument (absolute path)
1533
- 3. `--config-path` CLI argument (absolute path)
1534
- 4. `database.path` in config file (absolute path)
1535
- 5. `process.cwd()` fallback
1536
-
1537
- #### Junie AI Configuration Example
1538
- ```json
1539
- {
1540
- "mcpServers": {
1541
- "sqlew": {
1542
- "command": "npx",
1543
- "args": ["sqlew"],
1544
- "env": {
1545
- "SQLEW_PROJECT_ROOT": "{projectDir}"
1546
- }
1547
- }
1548
- }
1549
- }
1550
- ```
1551
-
1552
- **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1553
-
1554
- #### Impact
1555
- - **Project-relative databases** without hardcoded absolute paths
1556
- - **Cleaner MCP configuration** (no per-project path updates needed)
1557
- - **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1558
- - **No breaking changes** (environment variable is optional)
1559
-
1560
- ---
1561
-
1562
- ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1563
-
1564
- **Eliminated console output for strict JSON-RPC protocol compliance**
1565
-
1566
- #### Problem
1567
- - EPIPE (broken pipe) errors when running with Junie AI on Windows
1568
- - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1569
- - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1570
-
1571
- #### Changes
1572
- - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1573
- - Modified `safeConsoleError()` to write to debug log instead of stderr
1574
- - Replaced 50+ console.log/console.error calls across codebase:
1575
- - `src/database.ts` - Database initialization messages
1576
- - `src/watcher/file-watcher.ts` - File watcher status and events
1577
- - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1578
- - `src/tools/tasks.ts` - Task file registration warnings
1579
- - `src/config/example-generator.ts` - First launch messages
1580
-
1581
- #### Technical Details
1582
- - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1583
- - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1584
- - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1585
- - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1586
-
1587
- #### Impact
1588
- - ✅ **Works with strict MCP clients** (Junie AI, etc.)
1589
- - **Maintains full diagnostics** via debug log file
1590
- - **Pure JSON-RPC protocol** compliance
1591
- - **No breaking changes** to MCP tool functionality
1592
-
1593
- ---
1594
-
1595
- ### Added - Environment Variable Support for Project Root
1596
-
1597
- **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1598
-
1599
- #### Problem
1600
- - Junie AI and other MCP clients require absolute paths in configuration
1601
- - Users had to hardcode project-specific paths in MCP server config
1602
- - No easy way to use project-relative database paths
1603
-
1604
- #### Solution
1605
- - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1606
- - MCP clients can now pass project directory via environment variable
1607
- - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1608
-
1609
- #### Priority Order
1610
- 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1611
- 2. `--db-path` CLI argument (absolute path)
1612
- 3. `--config-path` CLI argument (absolute path)
1613
- 4. `database.path` in config file (absolute path)
1614
- 5. `process.cwd()` fallback
1615
-
1616
- #### Junie AI Configuration Example
1617
- ```json
1618
- {
1619
- "mcpServers": {
1620
- "sqlew": {
1621
- "command": "npx",
1622
- "args": ["sqlew"],
1623
- "env": {
1624
- "SQLEW_PROJECT_ROOT": "{projectDir}"
1625
- }
1626
- }
1627
- }
1628
- }
1629
- ```
1630
-
1631
- **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1632
-
1633
- #### Impact
1634
- - **Project-relative databases** without hardcoded absolute paths
1635
- - **Cleaner MCP configuration** (no per-project path updates needed)
1636
- - **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1637
- - **No breaking changes** (environment variable is optional)
1638
-
1639
- ---
1640
-
1641
- ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1642
-
1643
- **Eliminated console output for strict JSON-RPC protocol compliance**
1644
-
1645
- #### Problem
1646
- - EPIPE (broken pipe) errors when running with Junie AI on Windows
1647
- - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1648
- - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1649
-
1650
- #### Changes
1651
- - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1652
- - Modified `safeConsoleError()` to write to debug log instead of stderr
1653
- - Replaced 50+ console.log/console.error calls across codebase:
1654
- - `src/database.ts` - Database initialization messages
1655
- - `src/watcher/file-watcher.ts` - File watcher status and events
1656
- - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1657
- - `src/tools/tasks.ts` - Task file registration warnings
1658
- - `src/config/example-generator.ts` - First launch messages
1659
-
1660
- #### Technical Details
1661
- - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1662
- - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1663
- - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1664
- - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1665
-
1666
- #### Impact
1667
- - ✅ **Works with strict MCP clients** (Junie AI, etc.)
1668
- - **Maintains full diagnostics** via debug log file
1669
- - **Pure JSON-RPC protocol** compliance
1670
- - **No breaking changes** to MCP tool functionality
1671
-
1672
- ---
1673
-
1674
- ### Added - Environment Variable Support for Project Root
1675
-
1676
- **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1677
-
1678
- #### Problem
1679
- - Junie AI and other MCP clients require absolute paths in configuration
1680
- - Users had to hardcode project-specific paths in MCP server config
1681
- - No easy way to use project-relative database paths
1682
-
1683
- #### Solution
1684
- - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1685
- - MCP clients can now pass project directory via environment variable
1686
- - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1687
-
1688
- #### Priority Order
1689
- 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1690
- 2. `--db-path` CLI argument (absolute path)
1691
- 3. `--config-path` CLI argument (absolute path)
1692
- 4. `database.path` in config file (absolute path)
1693
- 5. `process.cwd()` fallback
1694
-
1695
- #### Junie AI Configuration Example
1696
- ```json
1697
- {
1698
- "mcpServers": {
1699
- "sqlew": {
1700
- "command": "npx",
1701
- "args": ["sqlew"],
1702
- "env": {
1703
- "SQLEW_PROJECT_ROOT": "{projectDir}"
1704
- }
1705
- }
1706
- }
1707
- }
1708
- ```
1709
-
1710
- **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1711
-
1712
- #### Impact
1713
- - **Project-relative databases** without hardcoded absolute paths
1714
- - **Cleaner MCP configuration** (no per-project path updates needed)
1715
- - **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1716
- - **No breaking changes** (environment variable is optional)
1717
-
1718
- ---
1719
-
1720
- ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1721
-
1722
- **Eliminated console output for strict JSON-RPC protocol compliance**
1723
-
1724
- #### Problem
1725
- - EPIPE (broken pipe) errors when running with Junie AI on Windows
1726
- - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1727
- - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1728
-
1729
- #### Changes
1730
- - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1731
- - Modified `safeConsoleError()` to write to debug log instead of stderr
1732
- - Replaced 50+ console.log/console.error calls across codebase:
1733
- - `src/database.ts` - Database initialization messages
1734
- - `src/watcher/file-watcher.ts` - File watcher status and events
1735
- - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1736
- - `src/tools/tasks.ts` - Task file registration warnings
1737
- - `src/config/example-generator.ts` - First launch messages
1738
-
1739
- #### Technical Details
1740
- - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1741
- - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1742
- - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1743
- - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1744
-
1745
- #### Impact
1746
- - ✅ **Works with strict MCP clients** (Junie AI, etc.)
1747
- - **Maintains full diagnostics** via debug log file
1748
- - **Pure JSON-RPC protocol** compliance
1749
- - **No breaking changes** to MCP tool functionality
1750
-
1751
- ---
1752
-
1753
- ### Added - Environment Variable Support for Project Root
1754
-
1755
- **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1756
-
1757
- #### Problem
1758
- - Junie AI and other MCP clients require absolute paths in configuration
1759
- - Users had to hardcode project-specific paths in MCP server config
1760
- - No easy way to use project-relative database paths
1761
-
1762
- #### Solution
1763
- - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1764
- - MCP clients can now pass project directory via environment variable
1765
- - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1766
-
1767
- #### Priority Order
1768
- 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1769
- 2. `--db-path` CLI argument (absolute path)
1770
- 3. `--config-path` CLI argument (absolute path)
1771
- 4. `database.path` in config file (absolute path)
1772
- 5. `process.cwd()` fallback
1773
-
1774
- #### Junie AI Configuration Example
1775
- ```json
1776
- {
1777
- "mcpServers": {
1778
- "sqlew": {
1779
- "command": "npx",
1780
- "args": ["sqlew"],
1781
- "env": {
1782
- "SQLEW_PROJECT_ROOT": "{projectDir}"
1783
- }
1784
- }
1785
- }
1786
- }
1787
- ```
1788
-
1789
- **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1790
-
1791
- #### Impact
1792
- - **Project-relative databases** without hardcoded absolute paths
1793
- - **Cleaner MCP configuration** (no per-project path updates needed)
1794
- - **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1795
- - **No breaking changes** (environment variable is optional)
1796
-
1797
- ---
1798
-
1799
- ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1800
-
1801
- **Eliminated console output for strict JSON-RPC protocol compliance**
1802
-
1803
- #### Problem
1804
- - EPIPE (broken pipe) errors when running with Junie AI on Windows
1805
- - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1806
- - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1807
-
1808
- #### Changes
1809
- - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1810
- - Modified `safeConsoleError()` to write to debug log instead of stderr
1811
- - Replaced 50+ console.log/console.error calls across codebase:
1812
- - `src/database.ts` - Database initialization messages
1813
- - `src/watcher/file-watcher.ts` - File watcher status and events
1814
- - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1815
- - `src/tools/tasks.ts` - Task file registration warnings
1816
- - `src/config/example-generator.ts` - First launch messages
1817
-
1818
- #### Technical Details
1819
- - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1820
- - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1821
- - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1822
- - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1823
-
1824
- #### Impact
1825
- - ✅ **Works with strict MCP clients** (Junie AI, etc.)
1826
- - **Maintains full diagnostics** via debug log file
1827
- - **Pure JSON-RPC protocol** compliance
1828
- - **No breaking changes** to MCP tool functionality
1829
-
1830
- ---
1831
-
1832
- ### Fixed - Windows Absolute Path Handling
1833
-
1834
- **Fixed path normalization for Windows environments**
1835
-
1836
- #### Changes
1837
- - Fixed absolute path to relative path conversion in `gitignore-parser.ts`
1838
- - Prevented `uname` Unix command calls on Windows
1839
- - Resolved "path should be a `path.relative()`d string" error on Windows
1840
- - Improved cross-platform path handling in file watcher
1841
-
1842
- #### Technical Details
1843
- - Enhanced path normalization logic to handle Windows drive letters (`C:/`)
1844
- - Added proper Windows-specific path handling checks
1845
- - Fixed compatibility with `ignore` library path requirements
1846
-
1847
- ---
1848
-
1849
- ## [3.6.8] - 2025-10-30
1850
-
1851
- ### Fixed - Windows Environment Compatibility
1852
-
1853
- **Updated better-sqlite3 for Windows support**
1854
-
1855
- #### Changes
1856
- - Updated `better-sqlite3` from `^11.0.0` to `^12.4.1`
1857
- - Fixes Windows environment compatibility issues
1858
- - Improves cross-platform stability
1859
-
1860
- ---
1861
-
1862
- ## [3.6.7] - 2025-10-30
1863
-
1864
- ### Fixed - Dependency Update
1865
-
1866
- **Removed deprecated dependency**
1867
-
1868
- #### Changes
1869
- - Removed deprecated dependency to ensure compatibility with latest ecosystem
1870
- - Maintenance update for long-term stability
1871
-
1872
- ---
1873
-
1874
- ## [3.6.6] - 2025-10-29
1875
-
1876
- ### Added - Parameter Validation & Error Handling
1877
-
1878
- **Comprehensive parameter validation with helpful error messages**
1879
-
1880
- #### Parameter Validation
1881
- - **Required/Optional Detection** - Clear indication of required vs optional parameters
1882
- - **Typo Suggestions** - Levenshtein distance-based "did you mean" suggestions for mistyped parameters
1883
- - **Structured Error Messages** - JSON format with examples showing correct usage
1884
- - **Visual Markers** - Help responses show 🔴 REQUIRED and ⚪ OPTIONAL parameter markers
1885
- - **Action Specs Registry** - Centralized action specification in `src/utils/action-specs.ts`
1886
- - **Comprehensive Test Suite** - 49 validation tests across all 5 tools
1887
-
1888
- ### Removed - Config Tool Deprecated
1889
-
1890
- **Config MCP tool removed in favor of file-based configuration**
1891
-
1892
- #### Why Removed
1893
- - Messaging system deprecated (primary use case eliminated)
1894
- - File-based configuration (`.sqlew/config.toml`) is clearer and more maintainable
1895
- - Runtime updates caused configuration drift between `m_config` table and config file
1896
- - Confusing UX (changes lost on restart unless manually synced)
1897
-
1898
- #### Migration Path
1899
- - Use `.sqlew/config.toml` for all configuration (persistent, version-controlled)
1900
- - ✅ Use CLI arguments for one-time overrides
1901
- - Do not use `config` tool (will error)
1902
-
1903
- #### Impact
1904
- - 5 MCP tools (down from 6): `decision`, `task`, `file`, `constraint`, `stats`
1905
- - ✅ Clearer configuration workflow (single source of truth)
1906
- - ✅ Better developer experience (validation errors with examples)
1907
- - ✅ Reduced cognitive load (no config drift issues)
1908
-
1909
- ---
1910
-
1911
- ## [3.6.5] - 2025-10-28
1912
-
1913
- ### Changed - Agent System Simplification & CI/CD Fix
1914
-
1915
- **Removed messaging system and eliminated agent pooling complexity**
1916
-
1917
- #### Agent System Cleanup
1918
- - **Removed messaging system** - `t_agent_messages` table dropped, `message` MCP tool deprecated
1919
- - Messaging system was unused and added unnecessary complexity
1920
- - Simplified agent architecture to single-purpose registry
1921
- - **Eliminated agent pooling** - Code no longer uses `in_use` and `is_reusable` columns
1922
- - Removed race conditions and UNIQUE constraint errors
1923
- - Each agent name creates one permanent record (no reuse/pooling)
1924
- - Generic agents (`generic-N`) auto-allocated for empty names
1925
- - **6 MCP Tools** - Down from 7 (messaging removed)
1926
- - `decision`, `file`, `constraint`, `stats`, `config`, `task`
1927
-
1928
- #### Infrastructure
1929
- - **CI/CD Workflow** - Removed npm publish step from GitHub Actions
1930
- - npm publish requires 2FA authentication
1931
- - Publishing must be done manually to prevent workflow failures
1932
-
1933
- #### Impact
1934
- - ✅ Simplified agent management (no pooling overhead)
1935
- - Reduced complexity (messaging system removed)
1936
- - ✅ CI/CD workflow no longer fails on npm publish
1937
-
1938
- ---
1939
-
1940
- ## [3.6.4] - 2025-10-28
1941
-
1942
- ### Fixed - WSL Git Add Detection
1943
-
1944
- **WSL-specific polling workaround for chokidar file watcher**
1945
-
1946
- #### Changes
1947
- - **1-second polling for WSL** - Added platform-specific chokidar configuration
1948
- - WSL filesystem events are unreliable with native watching
1949
- - Polling ensures git add operations are detected consistently
1950
- - **Platform detection** - Automatic WSL detection via `/proc/version`
1951
- - **Backward compatible** - Non-WSL platforms use native file watching (no polling)
1952
-
1953
- #### Impact
1954
- - Git add detection now works reliably on WSL
1955
- - VCS-aware auto-complete functional across all platforms
1956
-
1957
- ---
1958
-
1959
- ## [3.6.3] - 2025-10-27
1960
-
1961
- ### Fixed - Critical Bug Fixes & Git Add Detection
1962
-
1963
- **Transaction pool exhaustion and VCS-aware auto-complete implementation**
1964
-
1965
- #### Bug Fixes
1966
- - **Task Move Transaction Bug** - Fixed `moveTask` using base `knex` instead of transaction `trx` (line 880)
1967
- - Caused "Knex: Timeout acquiring a connection" errors
1968
- - Now properly uses transaction object for `logTaskStatusChange`
1969
- - **Task Link Transaction Bug** - Fixed `linkTask` using base `knex` instead of transaction `trx` (line 948)
1970
- - Same connection pool exhaustion issue
1971
- - Now properly uses transaction object for decision link insertion
1972
-
1973
- #### Features
1974
- - **Git Add Detection** - Implemented `detectAndCompleteOnStaging()` for VCS-aware workflow
1975
- - Detects `git add` operations and auto-completes tasks (`waiting_review` → `done`)
1976
- - Supports Git, Mercurial, and SVN
1977
- - Configurable via `git_auto_complete_on_stage` and `require_all_files_staged`
1978
- - **VCS Configuration** - Added comprehensive settings documentation to `config.example.toml`
1979
- - `git_auto_complete_on_stage` (default: true)
1980
- - `git_auto_archive_on_commit` (default: true)
1981
- - `require_all_files_staged` (default: true)
1982
- - `require_all_files_committed_for_archive` (default: true)
1983
-
1984
- #### Infrastructure
1985
- - **Line Ending Fix** - Added `.gitattributes` to enforce LF endings for shell scripts
1986
- - Prevents CRLF issues in Husky hooks on Windows/WSL
1987
- - Applies to `*.sh` and `.husky/*` files
1988
- - **Husky Hooks** - Fixed pre-commit/pre-push hooks (added shebang, normalized line endings)
1989
-
1990
- #### Impact
1991
- - ✅ Task operations no longer fail with connection pool timeouts
1992
- - ✅ Git add detection now functional (was stubbed in v3.5.2)
1993
- - ✅ Cross-platform compatibility for git hooks (Windows/WSL/Linux/macOS)
1994
-
1995
- ---
1996
-
1997
- ## [3.6.2] - 2025-10-27
1998
-
1999
- ### Changed - Migration System Modernization
2000
-
2001
- **Simplified to Knex-only migrations with organized directory structure**
2002
-
2003
- #### Migration System Cleanup
2004
- - **Removed custom migration system** (14 obsolete files from `src/migrations/`)
2005
- - **Pure Knex migrations** - Standardized on Knex.js migration framework
2006
- - **Organized structure** - 22 migrations grouped into 3 logical subdirectories:
2007
- - `upgrades/` (7 files) - Version upgrade paths (v1.0 → v3.6)
2008
- - `bootstrap/` (5 files) - Fresh install foundation
2009
- - `enhancements/` (10 files) - v3.6.0+ feature additions
2010
-
2011
- #### Testing & CI/CD
2012
- - **Migration tests updated** - Converted to use Knex migrations exclusively
2013
- - **Comprehensive test coverage** - 8/9 versions migrate successfully (89% backward compatibility)
2014
- - **Husky git hooks** - Pre-commit (build + tests), pre-push (migration tests)
2015
- - **GitHub Actions workflow** - CI/CD pipeline for Node 18.x/20.x
2016
-
2017
- #### Benefits
2018
- - **Better maintainability** - Clear organization, standard tooling
2019
- - **Easier onboarding** - Knex is industry-standard
2020
- - **Faster development** - 56% time efficiency via parallel execution
2021
-
2022
- ---
2023
-
2024
- ## [3.6.0] - 2025-10-25
2025
-
2026
- ### Added - Help System Optimization
2027
-
2028
- **Database-driven help system with 60-70% token efficiency improvement**
2029
-
2030
- #### Key Achievements
2031
- - **60-70% Token Reduction** - Average help query: ~200 tokens (vs ~2,150 legacy)
2032
- - **95.8% Schema Reduction** - MCP InputSchemas: 350 tokens (vs 8,400 legacy)
2033
- - **6 New Help Actions** - Granular queries for actions, parameters, tools, use-cases
2034
- - **41 Use-Cases** - Comprehensive workflow examples across 6 categories
2035
- - **100% Test Coverage** - 38/38 tests passing
2036
-
2037
- #### New MCP Actions (stats tool)
2038
- - `help_action` - Query single action with parameters and examples
2039
- - `help_params` - Query parameter list for an action
2040
- - `help_tool` - Query tool overview + all actions
2041
- - `help_use_case` - Get single use-case with full workflow
2042
- - `help_list_use_cases` - List/filter use-cases by category/complexity
2043
- - `help_next_actions` - Suggest common next actions
2044
-
2045
- #### Database Schema
2046
- 7 new tables: `m_help_tools`, `m_help_actions`, `m_help_use_case_categories`, `t_help_action_params`, `t_help_action_examples`, `t_help_use_cases`, `t_help_action_sequences`
2047
-
2048
- #### Migration from v3.5.x
2049
- - Automatic migration on startup
2050
- - Backward compatible - all existing MCP actions unchanged
2051
- - Zero downtime
2052
-
2053
- ---
2054
-
2055
- ## [3.5.2] - 2025-10-24
2056
-
2057
- ### Added - Two-Step Git-Aware Task Workflow
2058
-
2059
- **Automatic task completion and archiving based on Git staging and committing**
2060
-
2061
- #### Features
2062
- - **Step 1 - Staging** (`git add`): `waiting_review` → `done` (work complete)
2063
- - **Step 2 - Committing** (`git commit`): `done` `archived` (work finalized)
2064
- - **VCS Support**: Git, Mercurial, and SVN
2065
- - **Zero Token Cost**: Fully automated, no manual MCP calls needed
2066
-
2067
- #### Configuration
2068
- - `git_auto_complete_on_stage` (default: `'1'`)
2069
- - `git_auto_archive_on_commit` (default: `'1'`)
2070
- - `require_all_files_staged` (default: `'1'`)
2071
- - `require_all_files_committed_for_archive` (default: `'1'`)
2072
-
2073
- ---
2074
-
2075
- ## [3.5.1] - 2025-10-24
2076
-
2077
- ### Fixed - File Watcher WSL Compatibility
2078
-
2079
- **Upgraded chokidar from v3 to v4 + Fixed path normalization bug**
2080
-
2081
- #### Changes
2082
- - **chokidar**: `^3.6.0` → `^4.0.3` (automatic WSL support)
2083
- - Fixed path normalization: chokidar reports absolute paths, database stores relative
2084
- - Removed manual WSL detection and polling configuration
2085
-
2086
- ---
2087
-
2088
- ## [3.5.0] - 2025-10-22
2089
-
2090
- ### Added - Non-Existent File Auto-Pruning
2091
-
2092
- **Automatic removal of non-existent watched files with audit trail**
2093
-
2094
- #### Features
2095
- - New table: `t_task_pruned_files` - Audit trail for pruned files
2096
- - Auto-pruning during `in_progress waiting_review` transition
2097
- - Safety check: blocks if ALL files non-existent
2098
- - New MCP actions: `get_pruned_files`, `link_pruned_file`
2099
-
2100
- #### Documentation
2101
-
2102
- ---
2103
-
2104
-
2105
- ## Older Versions
2106
-
2107
- For changelog entries **v3.4.1 and older**, see:
2108
- - [docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md](docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md)
2109
-
2110
- This includes all versions from v1.0.0 through v3.4.1.
1
+ # Changelog
2
+
3
+ All notable changes to sqlew will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [5.2.2] - 2026-06-13
11
+
12
+ ### Added
13
+
14
+ **Optional `reason` field on constraints**
15
+
16
+ Constraints can now store WHY they exist alongside the rule itself, so future AI agents do not discard rules whose rationale is invisible in the code. Mirrors decision context support; the reason flows from plan `🚫 Constraint` blocks through the hook queue into the database.
17
+
18
+ - **Migration**Idempotent `add_constraint_reason` adds a nullable `reason` TEXT column to `t_constraints` (SQLite/MySQL/PostgreSQL).
19
+ - **Write/read path** `constraint.add` persists `reason`; `constraint.get` and `getTaggedConstraints` select it. Responses omit the field when NULL for token efficiency.
20
+ - **Action spec / types** `reason` added as an optional `constraint.add` parameter; `AddConstraintParams` and `TaggedConstraint` updated. The hint that "rationale is NOT supported" is replaced with guidance to use `reason`.
21
+ - **Plan-to-ADR hooks** `plan-pattern-extractor` reads `- **Reason**:` from constraint blocks and threads it through `hook-queue` `plan-processor` `queue-watcher` to `constraint.add`.
22
+ - **Enforcement message** — `on-prompt` plan-mode guidance now nudges recording the WHY and skipping facts derivable from code.
23
+ - **Help data** — `constraint.toml` and constraint help examples document the field.
24
+ - **Tests** — Unit (Reason extraction), feature (add → get round-trip, omitted when unset), and native RDBMS schema coverage.
25
+
26
+ > Pairs with sqlew-plugin: `sqlew-decision-format` adds a `- **Reason**:` line to the `🚫 Constraint` template.
27
+
28
+ ### Fixed
29
+
30
+ **Stale references to v5.0-dropped help tables**
31
+
32
+ v5.0 moved help documentation from DB tables to TOML files (`src/help-data/`) and dropped the 7 help tables, but two references were left behind.
33
+
34
+ - **`verifySchemaIntegrity`** Removed the 7 dropped help tables from `requiredTables` (now Master 7 / Transaction 11). This validator is currently unused, but would have flagged every v5 database as invalid if invoked.
35
+ - **Native test** — Deleted `src/tests/docker/native/help-system.test.ts`; it verified dropped tables and could not be fixed to test non-existent schema. TOML-based help remains covered by `src/tests/feature/help/help-system.test.ts`.
36
+
37
+ ---
38
+
39
+ ## [5.2.1] - 2026-06-12
40
+
41
+ ### Added
42
+
43
+ **Codex hook support (paired with sqlew-plugin v5.2.1)**
44
+
45
+ MCP hook layer for OpenAI Codex, following the same normalization pattern as Grok Build (v5.2.0). Plugin manifests and hook matchers ship in [sqlew-plugin](https://github.com/sqlew-io/sqlew-plugin) v5.2.1.
46
+
47
+ - **`normalizeHookInput()` Codex branch** Maps `shell_command`/`shell`/`exec_command` → `Bash`, `apply_patch` → `Edit`, reads `collaboration_mode` for Plan mode
48
+ - **`codex-transcript.ts`** — Locates `~/.codex/sessions/**/{sessionId}.jsonl` and extracts Plan-mode assistant text for ADR pattern processing
49
+ - **`on-prompt` / `on-exit-plan` Codex paths** Plan enforcement injection and transcript-based extraction on session `Stop`
50
+ - **`determineProjectRoot()`** — `CODEX_CWD` environment variable support
51
+ - **Unit tests** `codex-hook-normalization.test.ts`
52
+ - **Docs** `README.md` and `HOOKS_GUIDE.md` updated; manual `sqlew-codex-skills` copy install deprecated
53
+
54
+ ### Fixed
55
+
56
+ **`isPlanMode()` Grok plan-mode tool names not detected after normalization**
57
+
58
+ `normalizeHookInput()` maps Grok's `enter_plan_mode` / `exit_plan_mode` tool names to the canonical Claude-shaped `EnterPlanMode` / `ExitPlanMode` before any detection runs. `isPlanMode()` only checked the raw snake_case names, so the tool-name branch never matched and Grok Build's plan mode was never detected via tool context.
59
+
60
+ - **`isPlanMode()`** — Now matches the normalized `EnterPlanMode` / `ExitPlanMode` names. Raw snake_case names are still accepted defensively for callers that bypass normalization.
61
+ - **Tests** — Added `isPlanMode` regression coverage to `grok-hook-normalization.test.ts` (Claude `permission_mode`, normalized Grok payloads, raw snake_case, non-plan tools).
62
+
63
+ Claude Code was unaffected by this bug because it is detected via `permission_mode === 'plan'`, which is evaluated first.
64
+
65
+ > **Note:** Plan-mode ADR enforcement requires the sqlew plugin to be enabled in the active scope. Enabling it only per-project (`.claude/settings.local.json`) silently skips enforcement in other projects; enable `sqlew@sqlew-plugin` in the global `~/.claude/settings.json` for always-on coverage.
66
+
67
+ ---
68
+
69
+ ## [5.2.0] - 2026-06-11
70
+
71
+ ### Added
72
+
73
+ **Grok Build support (sqlew-plugin v5.2.0)**
74
+
75
+ Unified Plan-to-ADR support for Grok Build alongside Claude Code via a single sqlew-plugin install. No separate sqlew-grok adapter required.
76
+
77
+ - **`normalizeHookInput()`** Translates Grok hook payloads (`hookEventName`, `toolName`, `sessionId`, `workspaceRoot`) to canonical Claude-shaped `HookInput`. Claude payloads pass through unchanged.
78
+ - **`computeGrokPlanPath()`** — Resolves per-session plan file at `~/.grok/sessions/<encodeURIComponent(cwd)>/<sessionId>/plan.md`.
79
+ - **`injectGrokPlanTemplate()`** Appends Decision/Constraint template to `plan.md` on `enter_plan_mode` (file side-effect). Grok ignores passive hook stdout; skills auto-invocation is unreliable.
80
+ - **`GROK_WORKSPACE_ROOT`** — Added to `determineProjectRoot()` for MCP server project root resolution.
81
+ - **Grok `sendBlock()` compat** PreToolUse deny hooks emit `{"decision":"deny","reason":"..."}` on stdout for Grok (in addition to exit 2 + stderr for Claude Code).
82
+ - **Unit tests** `grok-hook-normalization.test.ts`, `grok-plan-template-injection.test.ts`.
83
+
84
+ ### Changed
85
+
86
+ - **`on-prompt`** — Early return for Grok client (`UserPromptSubmit` stdout is ignored on Grok).
87
+ - **`on-exit-plan` / `track-plan`** Record `CurrentPlanInfo.plan_path` for Grok; always re-resolve from `session_id` on exit.
88
+ - **`plan-processor`** Prefer explicit `plan_path` over legacy Claude global plans resolver.
89
+ - **`docs/HOOKS_GUIDE.md`** — Replaced sqlew-grok adapter instructions with `grok plugin install sqlew-io/sqlew-plugin --trust` workflow.
90
+
91
+ ### Plugin Changes (sqlew-plugin v5.2.0)
92
+
93
+ - Hook matchers: `enter_plan_mode` / `exit_plan_mode` alongside Claude tool names
94
+ - Skills: Grok-specific plan mode guidance (`sqlew-plan-guidance`, `sqlew-decision-format`)
95
+
96
+ ---
97
+
98
+ ## [5.1.0] - 2026-03-07
99
+
100
+ ### Changed
101
+
102
+ **📁 `.sqlew.env` relocated to `~/.config/sqlew/.sqlew.env`**
103
+
104
+ The cloud API key file (`~/.sqlew.env`) has been moved to `~/.config/sqlew/.sqlew.env` to align with the v5.1 unified global config path. Automatic migration copies the old file and deletes it (API key security: no stale copies). `saveCachedProjectId()` now calls `ensureGlobalConfigDir()` for directory safety.
105
+
106
+ **🔒 db:export Project Scope Auto-Detection (Security)**
107
+
108
+ `db:export` no longer exports all projects by default. With the global shared database (v5.1.0), the default "export everything" behavior risked leaking other projects' decision data.
109
+
110
+ - **Auto-detect**: Project name resolved from `.sqlew/config.toml` `[project].name` when no `project=` option is given
111
+ - **Explicit all**: `project=all` required to export all projects (escape hatch)
112
+ - **Error on ambiguity**: If no project name is found (no CLI arg, no config.toml), the command exits with an actionable error message
113
+ - **Breaking change**: Previously, omitting `project=` exported all projects silently
114
+
115
+ ### Resolution Priority
116
+
117
+ ```
118
+ 1. CLI argument: project=<name> (highest)
119
+ 2. config.toml: [project].name
120
+ 3. Error exit (lowest)
121
+ ```
122
+
123
+ ---
124
+
125
+ ## [5.0.6] - 2026-02-14
126
+
127
+ ### Changed
128
+
129
+ **🧹 CLAUDE.md Injection Removed — Hook-based Plan Mode Enforcement**
130
+
131
+ Plan mode enforcement migrated from `~/.claude/CLAUDE.md` injection (~193 lines always loaded) to `UserPromptSubmit` hook with `permission_mode` check (~5 lines, plan mode only).
132
+
133
+ - New `on-prompt` CLI command: `UserPromptSubmit` hook handler that detects `permission_mode === "plan"` and injects enforcement context via plain text stdout
134
+ - `track-plan` hook (EnterPlanMode): shares same enforcement context for agent-initiated plan mode coverage
135
+ - Legacy `injectToGlobalClaudeMd()` replaced with `cleanupGlobalClaudeMd()` — auto-removes `<!-- sqlew:auto-injected -->` markers from `~/.claude/CLAUDE.md` on MCP startup
136
+ - Removed `assets/claude-md-snippets/` directory (`plan-mode-integration.md`, `queue-monitoring.md`)
137
+
138
+ ### Plugin Changes (sqlew-plugin)
139
+
140
+ - Added `UserPromptSubmit` hook entry in `hooks.json` (`sqlew on-prompt`, timeout: 10s)
141
+ - Skills descriptions strengthened to REQUIRED/MUST tone (`sqlew-decision-format`, `sqlew-plan-guidance`)
142
+ - `sqlew-plan-guidance` expanded: suggest search steps, Related Context template, queue monitoring, failed queue resolution
143
+
144
+ ### Technical Notes
145
+
146
+ - `UserPromptSubmit` hook requires **plain text stdout** (not JSON `additionalContext` format). This is different from `SessionStart`/`PostToolUse` hooks which use JSON format.
147
+ - Non-plan mode: hook outputs nothing and exits 0 (transparent, no system-reminder shown)
148
+
149
+ ---
150
+
151
+ ## [5.0.4] - 2026-02-04
152
+
153
+ ### Added
154
+
155
+ **📌 Decision Context Auto-Registration from Plan Mode**
156
+
157
+ - Plan-to-ADR pipeline now automatically extracts and registers decision context (rationale, alternatives, tradeoffs) from plan files
158
+ - New `decision_context` queue item type in `.sqlew/queue/pending.json`
159
+ - `plan-pattern-extractor.ts`: Extracts `Rationale`, `Alternatives`, `Tradeoffs` fields from `📌 Decision` blocks
160
+ - `plan-processor.ts`: Enqueues `decision_context` items after corresponding `decision` items (ordering guaranteed)
161
+ - `hook-queue.ts`: New `enqueueDecisionContextCreate()` with duplicate prevention
162
+ - `queue-watcher.ts`: New `processDecisionContextItem()` converts comma-separated alternatives to JSON array, routes through ToolBackend abstraction
163
+
164
+ ### SaaS Compatibility
165
+
166
+ - `add_decision_context` action fully supported via SaaS backend (`/api/v1/decision/add_decision_context`)
167
+ - `suggest/by_context` for constraints: improved text matching for long constraint texts (server-side Levenshtein fix)
168
+
169
+ ---
170
+
171
+ ## [5.0.3] - 2026-02-04
172
+
173
+ ### Fixed
174
+
175
+ **🧟 Zombie Process on Parent Exit (Windows)**
176
+
177
+ - MCP server processes remained alive after Claude Code exited, accumulating as zombie processes in Task Manager
178
+ - Root cause: MCP SDK's `StdioServerTransport` only listens for stdin `data`/`error`, not `end`. When combined with chokidar's `persistent: true` file watcher (QueueWatcher), the Node.js event loop stayed alive indefinitely
179
+ - Added `process.stdin.on('end')` handler to detect parent process exit and trigger graceful shutdown
180
+ - Added `stopQueueWatcher()` to all shutdown handlers (`registerShutdownHandlers`, `performCleanup`) the function existed since v4.1.0 but was never wired into the shutdown flow
181
+
182
+ **🔍 Schema Version Detection for v5.0**
183
+
184
+ - Fixed `[WARN] Unknown schema version detected` on every startup
185
+ - `detectSchemaVersion()` checked for `v4_tasks` table (dropped in v5.0 migration), causing detection to always fail on v5 schema
186
+ - Added v5 schema detection: checks `m_projects` + `t_decisions` + `t_constraints` with `v4_tasks` absence to distinguish from v4
187
+ - Schema now correctly reports `v5.x (using m_/t_ tables)` with proper `tablePrefix='m_'` and `transactionPrefix='t_'`
188
+
189
+ ---
190
+
191
+ ## [5.0.2] - 2026-02-03
192
+
193
+ ### Fixed
194
+
195
+ **🐛 on-session-start Hook CLI Routing Bug**
196
+
197
+ - Fixed `on-session-start` command being incorrectly routed to MCP server instead of CLI handler
198
+ - The command name was being interpreted as a database path argument, causing incorrect DB connections
199
+ - Added `on-session-start` to CLI command lists in both `index.ts` and `cli.ts`
200
+ - Also added missing `on-enter-plan` to `index.ts` for consistency
201
+
202
+ **Root Cause**: When SessionStart hook executed `sqlew on-session-start`, the command was not recognized as a CLI command and fell through to MCP server mode. The argument parser then treated `on-session-start` as a legacy positional argument for `--db-path`, resulting in a database file named `on-session-start` being created and used.
203
+
204
+ ---
205
+
206
+ ## [5.0.1] - 2026-02-02
207
+
208
+ ### Changed
209
+
210
+ **🔒 Security: saas-connector submodule integration (Issue #84)**
211
+
212
+ - Integrated saas-connector submodule directly into `src/saas-connector/`
213
+ - Removed `prebuild` script that triggered npm package scanner alerts
214
+ - Converted saas-connector from CommonJS to ESM for unified tsc build
215
+ - Eliminated separate esbuild step and `npm install` in subdirectory
216
+ - No functional changes - same SaaS backend behavior
217
+
218
+ **Rationale**: The `prebuild` script (`cd saas-connector && npm install && npm run build`) was flagged by npm security scanners as a potential risk. While the code itself was safe, the submodule architecture created unnecessary complexity and security perception issues.
219
+
220
+ ---
221
+
222
+ ## [5.0.0] - 2026-01-31
223
+
224
+ ### Added
225
+
226
+ **🌐 SaaS Backend Support (sqlew.io)**
227
+
228
+ - Connect to sqlew.io cloud service with `type = "cloud"` in config.toml
229
+ - Team-shared decision database - all team members see the same architectural decisions
230
+ - Multiple AI agents can work simultaneously without conflicts
231
+ - No local database setup required - just add your API key
232
+ - Connection Identity for seat-based billing with project-scoped hashing
233
+ - Project name resolution with UUID caching for optimized API calls
234
+ - X-Agent header for MCP client tracking in audit logs
235
+
236
+ **📚 Environment-aware Help Examples**
237
+
238
+ - Examples filtered by environment (SQLite shows numeric IDs, SaaS shows UUIDs)
239
+ - `target_type` attribute in TOML: `sqlite`, `cloud`, or `all`
240
+ - Automatic filtering in help `query-action`, example `get`, `search`, `list-all` actions
241
+
242
+ **🌳 Git Worktree Support**
243
+
244
+ - Automatic worktree detection for multi-branch development
245
+ - Config inheritance from main repository
246
+ - Independent session cache per worktree
247
+ - Seamless context sharing across worktrees
248
+
249
+ **🔌 Plugin-first Architecture**
250
+
251
+ - Skills/Hooks/Agents moved to separate `sqlew-plugin` repository
252
+ - Global Rules auto-created at `~/.claude/rules/sqlew/` on MCP startup
253
+ - Per-project Skills/Hooks installation removed (use plugin marketplace instead)
254
+ - Simplified setup: just install the plugin and connect to sqlew.io
255
+
256
+ **Queue Tool for Hook Queue Management**
257
+
258
+ - New `queue` MCP tool to manage `.sqlew/queue/pending.json`
259
+ - Actions: `list` (view pending items), `remove` (delete by index), `clear` (remove all)
260
+ - Lock mechanism to prevent race conditions with QueueWatcher
261
+ - Help documentation in `src/help-data/queue.toml`
262
+ - Queue monitoring rule in `~/.claude/rules/sqlew/queue-monitoring.md`
263
+
264
+ **TOML-based Help System**
265
+
266
+ - Help documentation now stored in `src/help-data/*.toml` (version-controlled, human-editable)
267
+ - `HelpSystemLoader` for startup-time loading with in-memory caching (O(1) lookups)
268
+ - 15 TOML files: 8 tool files (including queue) + 6 use case workflows + 1 schema file
269
+
270
+ ### Changed
271
+
272
+ - **MCP tools: 6 7** (queue tool added)
273
+ - `help`, `example`, `use_case` tools now load from TOML files instead of database
274
+ - Database schema reduced: 18 tables (7 master + 11 transaction)
275
+ - Table prefix renamed: `v4_` `m_/t_` (master/transaction convention)
276
+ - Multi-database backend now includes Cloud option (SQLite/PostgreSQL/MySQL/Cloud)
277
+ - Constraint ID now supports both `number` (SQLite) and `string` UUID (SaaS)
278
+ - `constraint_id` parameter renamed to `id` (backward compatibility maintained via alias)
279
+ - Lazy initialization of agent name after MCP handshake completion
280
+
281
+ ### Removed
282
+
283
+ - **Per-project Skills/Hooks installation** - Use sqlew-plugin from marketplace instead
284
+ - **7 help database tables**: m_help_tools, m_help_actions, m_help_use_case_cats, t_help_action_params, t_help_action_examples, t_help_use_cases, t_help_action_sequences
285
+ - `help-queries.ts` (replaced by HelpSystemLoader)
286
+ - Task and file management tables (deprecated in v4.3.0)
287
+
288
+ ---
289
+
290
+ ## [4.3.1] - 2026-01-06
291
+
292
+ ### Added
293
+
294
+ - **`.claude/rules/` integration**: Plan mode templates now installed to `.claude/rules/plan-mode-integration.md` instead of modifying CLAUDE.md directly
295
+ - Incremental `.gitignore` updates: Missing sqlew entries are now added even if sqlew section already exists
296
+ - Deprecation notices added to `file` tool help (matching `task` tool)
297
+
298
+ ### Changed
299
+
300
+ - **BREAKING**: `sqlew --init` no longer edits CLAUDE.md - uses `.claude/rules/` directory instead
301
+ - Plan mode template enhanced with stronger MUST/REQUIRED language for constraints
302
+ - DRY improvements: Common suggest tool logic extracted to `suggest-helpers.ts`
303
+
304
+ ### Deprecated
305
+
306
+ - **Specialized agents** (`scrum_master`, `researcher`, `architect`): No longer needed with Claude Opus 4.5's improved capabilities. Disabled by default, will be removed in v5.0
307
+
308
+ ### Removed
309
+
310
+ - Obsolete types from `types.ts` (duplicate JSON Import types, deprecated message system types)
311
+ - Unused `messagesCount` from `has-updates` action response
312
+ - `[tasks]` and `[vcs]` sections from config.example.toml (task system deprecated in v4.3.0)
313
+ - SSH tunnel configuration from config.example.toml (unsupported)
314
+
315
+ ---
316
+
317
+ ## [4.3.0] - 2026-01-04
318
+
319
+ ### Added
320
+
321
+ **Plan-to-ADR: Automatic Architecture Decision Records**
322
+
323
+ - Automatic ADR generation from Claude Code Plan Mode
324
+ - Markdown pattern extraction (📌 Decision / 🚫 Constraint markers)
325
+ - File Queue Architecture for async decision processing
326
+ - SubagentStop event integration for reliable pattern detection
327
+ - Parameter aliases for simplified tool usage (`path` → `file_path`, etc.)
328
+
329
+ ### Changed
330
+
331
+ - Documentation: Removed TOML format references (Markdown-only implementation)
332
+ - Unified feature branding as "Plan-to-ADR"
333
+ - Quick Start: `sqlew --init` as recommended one-shot setup
334
+ - Skills: Updated sqlew-decision-format and sqlew-plan-guidance
335
+
336
+ ### Deprecated
337
+
338
+ - **`task` tool**: Will be removed in v5.0. Use Claude Code's native TodoWrite instead
339
+ - **`file` tool**: Will be removed in v5.0. File tracking was primarily used with task system
340
+
341
+ ### Fixed
342
+
343
+ - Version alignment across package.json, README.md, CLAUDE.md
344
+ - Constraints duplication on automation
345
+ - Windows file locking issues with chokidar
346
+
347
+ ---
348
+
349
+ ## [4.1.2] - 2025-12-25
350
+
351
+ ### Fixed
352
+
353
+ **Help System & Clean Install**
354
+
355
+ - Fixed help system seeding with correct FK constraints
356
+ - Added seed migration for missing help system data (action params, examples)
357
+ - Fixed `file.record` action no longer requiring `agent_name` parameter
358
+ - Resolved clean install issues reported from Claude Desktop
359
+
360
+ ---
361
+
362
+ ## [4.1.1] - 2025-12-24
363
+
364
+ ### Fixed
365
+
366
+ **Claude Desktop Compatibility**
367
+
368
+ - Fixed MCP protocol corruption caused by migration logs going to stdout
369
+ - Changed all `console.log` to `console.error` in migration files (57 files)
370
+ - MCP servers must only output JSON-RPC to stdout; debug logs now go to stderr
371
+
372
+ ---
373
+
374
+ ## [4.1.0] - 2025-12-24
375
+
376
+ ### Added
377
+
378
+ **Claude Code Hooks Integration**
379
+
380
+ - File Queue Architecture for async decision operations
381
+ - Hook commands: `suggest`, `track-plan`, `save`, `check-completion`, `mark-done`
382
+ - QueueWatcher monitors `.sqlew/queue/pending.json` for changes
383
+ - Auto-initialization with `sqlew init --hooks`
384
+ - PreToolUse hooks (Task, Write triggers)
385
+ - PostToolUse hooks (Edit/Write, TodoWrite, ExitPlanMode triggers)
386
+ - Git hooks integration (post-merge, post-rewrite)
387
+
388
+ **PostgreSQL Compatibility**
389
+
390
+ - Replaced GROUP_CONCAT with string_agg for PostgreSQL
391
+ - Expanded GROUP BY clauses for PostgreSQL strictness compliance
392
+ - Cross-DB compatibility verified: SQLite, MySQL, MariaDB, PostgreSQL
393
+
394
+ ### Changed
395
+
396
+ - Hook operations now use file queue instead of direct DB access (<100ms latency)
397
+ - QueueWatcher singleton monitors queue file and processes decisions asynchronously
398
+
399
+ ---
400
+
401
+ ## [4.0.5] - 2025-12-19
402
+
403
+ ### Changed
404
+
405
+ **License Change: AGPL-3.0 → Apache-2.0**
406
+
407
+ - Changed license from AGPLv3 to Apache License 2.0
408
+ - More permissive license for commercial and enterprise adoption
409
+ - Added NOTICE file with third-party attributions
410
+ - Updated LICENSE file with full Apache 2.0 text
411
+ - Updated package.json license field
412
+
413
+ **Why Apache 2.0?**
414
+ - Patent protection for contributors and users
415
+ - Widely adopted by major tech companies (Google, Microsoft, AWS)
416
+ - Easier enterprise adoption without copyleft concerns
417
+ - Compatible with most open source licenses
418
+
419
+ ---
420
+
421
+ ## [4.0.4] - 2025-12-10
422
+
423
+ ### Fixed
424
+
425
+ **Slash Command Sync Bug**
426
+
427
+ - Fixed `sync-commands.ts` referencing obsolete command files (`sqw-scrum.md`, `sqw-documentor.md`, etc.)
428
+ - Updated to use new unified `sqlew.md` command file
429
+ - Resolves "Source file not found" errors during npm package installation
430
+
431
+ ### Added
432
+
433
+ **Agent Skills Configuration**
434
+
435
+ - Added `skills` field to agent YAML frontmatter for automatic skill loading
436
+ - All sqlew agents now reference `sqlew-plan-guidance` skill
437
+ - Agents: `sqlew-architect`, `sqlew-researcher`, `sqlew-scrum-master`
438
+
439
+ **Config Example Update**
440
+
441
+ - Added `[commands]` section to `assets/config.example.toml`
442
+ - Documents the unified `/sqlew` command configuration
443
+
444
+ ### Changed
445
+
446
+ **Plan Mode Integration Documentation**
447
+
448
+ - Changed `Phase 1 (Research)` → `Research Phase` for flexibility
449
+ - Changed `Phase 4 (Final Plan)` → `Final Plan Phase`
450
+ - Plan mode phases are now semantically named instead of numbered
451
+
452
+ **CommandsConfig Simplified**
453
+
454
+ - Consolidated 6 individual command options into single `sqlew` option
455
+ - Updated `src/config/types.ts` and `src/config/minimal-generator.ts`
456
+
457
+ ---
458
+
459
+ ## [4.0.3] - 2025-12-04
460
+
461
+ ### Added
462
+
463
+ **Unified `/sqlew` Slash Command**
464
+
465
+ - Consolidated all slash commands (`/sqw-plan`, `/sqw-scrum`, `/sqw-research`, etc.) into single `/sqlew` command
466
+ - Natural language interface with automatic intent detection
467
+ - 6-level intent priority: List/Status → Search → Record → Update → Execute → Task Creation
468
+ - Supports both English and Japanese keywords
469
+ - Removed custom agent definitions (sqlew-architect, scrum-master, sqlew-researcher)
470
+
471
+ **Usage Examples:**
472
+ ```bash
473
+ /sqlew # Show status and suggest next action
474
+ /sqlew show remaining tasks # List/Status intent
475
+ /sqlew search for auth decisions # Search intent
476
+ /sqlew record that we use JWT # Record intent
477
+ /sqlew execute pending tasks # Execute intent
478
+ ```
479
+
480
+ ### Fixed
481
+
482
+ **v4_task_details JOIN Bug**
483
+
484
+ - Fixed `task.get` action failing with "no such column: td.project_id" error
485
+ - Root cause: `v4_task_details` table has only `task_id` as PK, not `project_id`
486
+ - Removed invalid `.andOn('t.project_id', '=', 'td.project_id')` from JOIN conditions
487
+ - Affected files: `task-queries.ts`, `get.ts`
488
+
489
+ ### Changed
490
+
491
+ **Documentation Updates**
492
+
493
+ - Rewrote `CLAUDE.md` with unified `/sqlew` command section
494
+ - Updated `README.md` Quick Start to use `/sqlew`
495
+ - Rewrote `docs/SLASH_COMMANDS.md` as Unified /sqlew Command Guide
496
+
497
+ ---
498
+
499
+ ## [4.0.2] - 2025-11-28
500
+
501
+ ### BREAKING CHANGES
502
+
503
+ **SQL Dump No Longer Supports Cross-Database Format Conversion**
504
+
505
+ The `db:dump` command now generates SQL for the **same database type only**. Cross-database migrations (e.g., SQLite → MySQL) must use JSON export/import instead.
506
+
507
+ **Migration Required:**
508
+ ```bash
509
+ # Old approach (no longer supported)
510
+ npx sqlew db:dump mysql backup.sql # Cross-DB conversion removed
511
+
512
+ # ✅ New approach: Use JSON for cross-database migration
513
+ npx sqlew db:export backup.json # Export to JSON
514
+ npx sqlew db:import backup.json # Import to target database
515
+ ```
516
+
517
+ **Rationale:**
518
+ - SQL syntax differences between databases caused data corruption issues
519
+ - Case-insensitive pattern matching failed in certain scenarios
520
+ - JSON format is database-agnostic and handles all data types correctly
521
+
522
+ **Node.js 20+ Required**
523
+
524
+ Minimum Node.js version updated from 18.0.0 to 20.0.0.
525
+
526
+ ### Added
527
+
528
+ **Unified CLI Entry Point**
529
+
530
+ - `npx sqlew db:export`, `npx sqlew db:import`, `npx sqlew db:dump` now work directly
531
+ - No `npm install` required - just use `npx sqlew <command>`
532
+ - CLI commands and MCP server mode unified under single `sqlew` entry point
533
+ - Removed separate `sqlew-cli` binary
534
+
535
+ ### Fixed
536
+
537
+ **Case-Insensitive Validation for Master Records**
538
+
539
+ - Added case-insensitive duplicate detection when registering new records
540
+ - Prevents duplicate entries like "MyTag" and "mytag" from being created
541
+ - Applies to tags, scopes, layers, and other master table entries
542
+ - New utility: `src/utils/case-insensitive-validator.ts`
543
+
544
+ **SQLite to MySQL SQL Dump Case-Sensitivity Bug**
545
+
546
+ - Fixed regex pattern matching that failed with case variations
547
+ - SQL dump now correctly handles mixed-case identifiers
548
+ - Enhanced schema table export for better compatibility
549
+
550
+ ### Changed
551
+
552
+ **Export Version Tracking**
553
+
554
+ - Export JSON now includes proper version metadata
555
+ - Version information helps with import compatibility checks
556
+ - Clearer error messages when importing incompatible versions
557
+
558
+ **CLI Documentation Update**
559
+
560
+ - Updated `docs/cli/README.md` with JSON-first migration workflow
561
+ - Added clear guidance on when to use `db:dump` vs `db:export`/`db:import`
562
+ - Improved comparison table for migration scenarios
563
+
564
+ ### Added
565
+
566
+ **Case-Insensitive Validator Utility**
567
+
568
+ - New `src/utils/case-insensitive-validator.ts` for consistent validation
569
+ - Comprehensive test suite: `src/tests/unit/utils/case-insensitive-validator.test.ts`
570
+ - Reusable across all master table operations
571
+
572
+ ### Migration Notes
573
+
574
+ **Backward Compatibility:**
575
+ - Existing databases unaffected
576
+ - JSON export/import workflows unchanged
577
+ - SQL dumps for same-database-type operations still work
578
+
579
+ **Action Required:**
580
+ - Update any scripts that use `db:dump` for cross-database migrations
581
+ - Switch to `db:export`/`db:import` for SQLite ↔ MySQL ↔ PostgreSQL migrations
582
+
583
+ ---
584
+
585
+ ## [4.0.1] - 2025-11-28
586
+
587
+ ### Removed
588
+
589
+ **Database Views Eliminated**
590
+
591
+ - Dropped all database views (`v_tagged_constraints`, `v_recent_file_changes`, etc.)
592
+ - Views caused migration complexity across SQLite/MySQL/PostgreSQL due to database-specific syntax
593
+ - Migration: `20251128000000_drop_all_views.ts`
594
+
595
+ ### Changed
596
+
597
+ **JOIN-Based Queries**
598
+
599
+ - `src/tools/constraints/actions/get.ts` - Replaced `v_tagged_constraints` view with JOIN query
600
+ - `src/tools/files/actions/get.ts` - Replaced `v_recent_file_changes` view with JOIN query
601
+ - Uses `UniversalKnex` wrapper for cross-database compatibility (date functions, boolean values, string aggregation)
602
+
603
+ **VCS Test Cleanup**
604
+
605
+ - `src/tests/feature/vcs/git-aware-completion.test.ts` - Added automatic git reset after tests
606
+ - Test commits are now automatically dropped when tests complete
607
+ - Prevents test artifacts from polluting git history
608
+
609
+ ### Added
610
+
611
+ **No-Views Guardrail Skill**
612
+
613
+ - `.claude/skills/no-views/SKILL.md` - Documentation for view prohibition policy
614
+ - `.claude/skills/skill-rules.json` - Added `no-views` rule (enforcement: block)
615
+ - Blocks creation of database views, requires JOINs instead
616
+
617
+ **Documentation Updates**
618
+
619
+ - `CLAUDE.md` - Updated to reflect no-views policy
620
+ - Removed Views section from database schema documentation
621
+ - Added `no-views` to Guardrail Skills table
622
+
623
+ ---
624
+
625
+ ## [4.0.0] - 2025-11-27
626
+
627
+ ### Changed
628
+
629
+ **Concept & Positioning**
630
+
631
+ - Reframed sqlew as a **shared SQL-backed context repository** and a **Decision & Constraint repository layer** for AI tools
632
+ - Clarified that Decisions capture *why* changes were made and Constraints capture *how* code should be written
633
+ - Updated README introduction to focus on "Never Start From Zero Context Again" and the repository-based metaphor instead of generic "memory"
634
+
635
+ **Documentation & Cleanup**
636
+
637
+ - Updated `README.md` to describe sqlew as a context repository rather than an abstract memory layer
638
+ - Aligned terminology across docs around Decisions, Constraints, tasks, and the repository layer
639
+ - Confirmed that previously removed/legacy features remain out of scope, keeping focus on decision history and constraint rules
640
+
641
+ > Note: v4.0.0 is primarily a **concept and documentation alignment release**. Core Decision/Constraint features and the v3.9.x database schema remain compatible; no breaking API changes were introduced for existing integrations.
642
+
643
+ ---
644
+
645
+ ## [3.9.0] - 2025-01-15
646
+
647
+ ### Added
648
+
649
+ **🎯 Decision Intelligence System with Three-Tier Similarity Detection**
650
+
651
+ **New `suggest` Tool:**
652
+ - **by_key** - Pattern-based decision search (e.g., "api/*/latency" finds all API latency decisions)
653
+ - **by_tags** - Tag similarity scoring for related decisions (Jaccard similarity)
654
+ - **by_context** - Combined key + tags + layer search for best matches
655
+ - **check_duplicate** - Duplicate decision detection with similarity scoring (0-100 points)
656
+
657
+ **Three-Tier Duplicate Detection (Auto-Triggered):**
658
+ - **Tier 1 (35-44 points):** Gentle nudge - Non-blocking warning with suggestions
659
+ - **Tier 2 (45-59 points):** Hard block - Prevents creation, requires explicit override or update
660
+ - **Tier 3 (60+ points):** Auto-update - Transparently updates existing decision, preserves new value
661
+
662
+ **Similarity Scoring Algorithm:**
663
+ - Tag overlap: 0-40 points (10 per matching tag, max 4)
664
+ - Layer match: 0-25 points (same layer bonus)
665
+ - Key similarity: 0-20 points (pattern + Levenshtein distance)
666
+ - Recency: 0-10 points (recent updates prioritized)
667
+ - Priority: 0-5 points (critical decisions weighted)
668
+
669
+ **Policy-Based Auto-Triggering:**
670
+ - Suggestions automatically triggered when policies have `suggest_similar=1`
671
+ - Integrated with `decision.set` - returns suggestions in response
672
+ - Configurable relevance threshold via `min_score` parameter (default: 30)
673
+ - Policy validation rules support for targeted auto-triggering
674
+
675
+ **Enhanced Decision Metadata:**
676
+ - `duplicate_reason` - Similarity explanation with matched tags and layer info
677
+ - `update_command` - Ready-to-use command for updating existing decisions
678
+ - `version_info` - Existing decision version tracking
679
+ - `auto_updated` flag - Indicates Tier 3 transparent updates
680
+
681
+ **Supporting Features:**
682
+ - Tag parser utility (`src/utils/tag-parser.ts`) for flexible tag handling
683
+ - Policy validation integration (`src/utils/policy-validator.ts`)
684
+ - Suggestion scorer (`src/utils/suggestion-scorer.ts`) with breakdown
685
+ - Self-exclusion logic (prevents matching against own key during updates)
686
+
687
+ ### Fixed
688
+
689
+ **PostgreSQL Cross-Database Compatibility**
690
+ - Fixed CAST type mismatch in `v_tagged_decisions` view export
691
+ - PostgreSQL now correctly handles `COALESCE(TEXT, NUMERIC)` with `CAST(value AS TEXT)`
692
+ - MySQL/MariaDB use `CAST(value AS CHAR)` for compatibility
693
+ - Migration: `20251114000000_fix_v_tagged_decisions_numeric_support.ts`
694
+ - SQL dump export: Enhanced view conversion in `src/utils/sql-dump/schema/views.ts`
695
+ - Result: All 20 cross-database tests passing (MySQL, MariaDB, PostgreSQL)
696
+
697
+ **Test Suite Improvements**
698
+ - Fixed FK constraint cleanup order in `decision-intelligence-e2e.test.ts`
699
+ - Child records now deleted before parent records (tags scopes context → decisions)
700
+ - Result: 3/3 e2e workflow tests passing, no cleanup errors
701
+
702
+ **Schema Fixes**
703
+ - Migration `20251112000001_fix_task_file_links_schema_v3_9_0.ts` - Fixed UNIQUE constraint
704
+ - Migration `20251112000002_fix_task_pruned_files_schema_v3_9_0.ts` - Enhanced task file tracking
705
+ - All migrations idempotent with existence checks
706
+
707
+ ### Changed
708
+
709
+ **Test Organization (Docker Dependency Separation)**
710
+ - Moved 7 Docker-dependent tests to `src/tests/docker/` directory
711
+ - `npm test` now runs 481 unit tests without Docker (0 failures)
712
+ - `npm run test:docker` runs cross-database tests (requires Docker containers)
713
+ - Removed `test:all` script (caused database conflicts)
714
+ - Updated `.husky/pre-commit` to reflect test separation
715
+ - Decision documented in SQLew: `test-organization-docker-separation`
716
+
717
+ **Git Hook Enhancement**
718
+ - Pre-commit hook now checks for **PUSHED** migration files instead of just committed
719
+ - Auto-detects remote branch (origin/main, origin/master, origin/dev)
720
+ - Allows editing locally committed migrations (not yet pushed)
721
+ - Prevents editing migrations that exist in remote
722
+ - Graceful fallback for local-only repositories
723
+
724
+ **Debug Output Cleanup**
725
+ - Commented out scope validation warnings in test output
726
+ - Removed DEBUG/DIAGNOSTIC console.log statements
727
+ - Cleaner test output focusing on actual results
728
+ - 75% reduction in test output verbosity
729
+
730
+ ### Removed
731
+
732
+ **Code Cleanup**
733
+ - Deleted monolithic `src/utils/sql-dump.ts` (-1,799 lines)
734
+ - Functionality now in modular structure:
735
+ - `src/utils/sql-dump/schema/tables.ts`
736
+ - `src/utils/sql-dump/schema/views.ts`
737
+ - `src/utils/sql-dump/schema/primary-keys.ts`
738
+ - `src/utils/sql-dump/schema/indexes.ts`
739
+ - Deleted test tracking files (`test-tracking/file1.ts`, etc.)
740
+
741
+ ### Documentation
742
+
743
+ - Updated `CLAUDE.md` - Changed policy from "NEVER EDIT COMMITTED" to "NEVER EDIT PUSHED"
744
+ - Created `STAGED_CHANGES_SUMMARY.md` - Comprehensive v3.9.0 change summary
745
+ - Created `NEW_TOOL_DESCRIPTION.md` - Suggest tool reference
746
+
747
+ ### Performance
748
+
749
+ - Enhanced file pruning logic (`src/utils/file-pruning.ts`)
750
+ - Improved VCS adapter file status tracking (`src/utils/vcs-adapter.ts`)
751
+ - Better task stale detection (`src/utils/task-stale-detection.ts`)
752
+ - Activity logging enhancements for suggestion tracking
753
+
754
+ ### Testing
755
+
756
+ **Test Results:**
757
+ - ✅ **495/495 tests passing (100%)** - Production-ready
758
+ - Tier 1 (Gentle Nudge): 5/5 tests passing
759
+ - ✅ Tier 2 (Hard Block): 2/2 tests passing
760
+ - Tier 3 (Auto-Update): 3/3 tests passing
761
+ - ✅ Auto-trigger suggestions: 4/4 tests passing
762
+ - ✅ Edge cases and error handling: All passing
763
+ - ✅ 20/20 cross-database tests passing (MySQL, MariaDB, PostgreSQL)
764
+ - 7 Docker test suites in separate directory
765
+
766
+ **Test Suite Enhancements:**
767
+ - AI-optimized quiet mode (80-90% token reduction, shows only failures + summary)
768
+ - Verbose mode available with `:verbose` suffix (e.g., `npm run test:verbose`)
769
+ - Cross-platform filter script (`scripts/filter-test-output.js`)
770
+ - Comprehensive three-tier similarity detection test coverage
771
+
772
+ **Coverage:**
773
+ - Overall: 64.85% line coverage
774
+ - All critical paths tested
775
+ - Zero flaky tests
776
+
777
+ ### Migration Notes
778
+
779
+ **Backward Compatibility:**
780
+ - v3.9.0 is fully backward compatible with v3.8.x
781
+ - No breaking changes
782
+ - Automatic migration on server startup
783
+
784
+ **Database Changes:**
785
+ - 3 new enhancement migrations (all idempotent)
786
+ - Schema changes apply automatically
787
+ - Safe to rollback by restoring backup
788
+
789
+ **Files Changed:**
790
+ - 50 files modified
791
+ - 1,857 insertions, 2,096 deletions
792
+ - Net: -239 lines (code reduction through refactoring)
793
+
794
+ ---
795
+
796
+ ## [3.8.1] - 2025-11-11
797
+
798
+ ### Fixed
799
+
800
+ **Critical Installation Bug**
801
+
802
+ - Fixed `npm error Invalid Version:` error when installing sqlew@3.8.0
803
+ - Changed `@modelcontextprotocol/sdk` dependency from `"latest"` to `"^1.21.1"` in package.json
804
+ - The `"latest"` tag is not a valid semver version for published packages and caused npm dependency resolution to fail
805
+ - This is a **hotfix release** that resolves installation issues preventing users from using v3.8.0
806
+
807
+ **Impact:**
808
+ - All users experiencing `Invalid Version:` errors when running `npx sqlew` can now install successfully
809
+ - No functional changes from v3.8.0 - only dependency version fix
810
+
811
+ ---
812
+
813
+ ## [3.8.0] - 2025-11-09
814
+
815
+ ### BREAKING CHANGES
816
+
817
+ **Batch Action Naming Standardization**
818
+
819
+ `task.batch_create` has been renamed to `task.create_batch` to follow the `<verb>_batch` naming pattern used by other batch actions (`set_batch`, `record_batch`).
820
+
821
+ **Migration Required:**
822
+ ```typescript
823
+ // ❌ Old (v3.7.x and earlier)
824
+ task({ action: "batch_create", tasks: [...] })
825
+
826
+ // New (v3.8.0+)
827
+ task({ action: "create_batch", tasks: [...] })
828
+ ```
829
+
830
+ **Rationale:**
831
+ - Achieves 100% consistency across all batch actions
832
+ - Improves alphabetical sorting in IDE auto-completion (create → create_batch)
833
+ - Aligns with industry standard (REST APIs, GraphQL, ORMs use suffix pattern)
834
+ - See docs/ADR-batch-naming-standard.md for full justification
835
+
836
+ **Impact:**
837
+ - All code using `task.batch_create` must update to `task.create_batch`
838
+ - Simple find-replace migration (estimated 2-5 minutes per integration)
839
+ - No database schema changes required
840
+
841
+ ### Removed
842
+
843
+ **Config Tool Removed (Phase 6)**
844
+
845
+ The orphaned config tool has been removed in favor of CLI-only configuration:
846
+
847
+ - **Deleted**: `src/tools/config.ts` (307 lines)
848
+ - **Removed**: `ConfigAction` type from `src/types.ts` and `src/types/actions.ts`
849
+ - **Removed**: ConfigAction import from `src/utils/parameter-validator.ts`
850
+ - **Updated**: README.md with CLI-only config approach documentation
851
+ - **Updated**: docs/CONFIGURATION.md already documented config tool removal
852
+
853
+ **Why removed:**
854
+ - Config tool was never registered in `tool-registry.ts` (orphaned code)
855
+ - Messaging system deprecated (primary use case eliminated)
856
+ - File-based configuration (`.sqlew/config.toml`) is clearer and more maintainable
857
+ - Runtime updates were confusing (changes lost on restart unless manually synced to file)
858
+ - Configuration drift between `m_config` table and config file
859
+
860
+ **Migration Path:**
861
+ - ✅ **Use `.sqlew/config.toml`** for all configuration (persistent, version-controlled)
862
+ - **Use CLI arguments** for one-time overrides (`--autodelete-message-hours=48`)
863
+ - ✅ **Internal config operations** preserved (`src/database/config/config-ops.ts`)
864
+ - ✅ **m_config table** preserved (used internally by retention logic)
865
+
866
+ **Impact:**
867
+ - Cleaner codebase with ~300 lines removed
868
+ - No functional impact - tool was never registered
869
+ - Configuration via file and CLI arguments only
870
+
871
+ **Message Tool Completely Removed**
872
+
873
+ The deprecated message tool has been completely removed from the codebase:
874
+
875
+ - **Deleted**: `src/tools/messaging.ts` (599 lines)
876
+ - **Removed**: Message tool entry from `tool-registry.ts`
877
+ - **Removed**: Message tool handler from `tool-handlers.ts`
878
+ - **Removed**: Message imports from `cli.ts`
879
+ - **Updated**: `MessageAction` type changed to `never` (backward compatibility stub)
880
+ - **CLI**: `sqlew query messages` now returns error message
881
+
882
+ **Migration Path**:
883
+ - No action required - messaging system was already marked deprecated in v3.6.6
884
+ - The `t_agent_messages` table was dropped in v3.6.6
885
+ - All message tool actions returned deprecation warnings since v3.6.6
886
+
887
+ **Impact**:
888
+ - Cleaner codebase with ~700 lines removed
889
+ - No functional impact - messaging system was unused
890
+ - MessageAction type remains as deprecated stub for backward compatibility
891
+
892
+ ### Added
893
+
894
+ **Layer Expansion (5→9 layers)**
895
+
896
+ Added 4 new layers to enable better task classification and semantic validation:
897
+
898
+ **New FILE_REQUIRED layers:**
899
+ - `documentation` - README, CHANGELOG, API docs, architecture docs (file_actions required)
900
+
901
+ **New FILE_OPTIONAL layers:**
902
+ - `planning` - Research, spike tasks, investigation (file_actions optional)
903
+ - `coordination` - Multi-agent orchestration, task delegation (file_actions optional)
904
+ - `review` - Code review, design review, verification (file_actions optional)
905
+
906
+ **Existing layers** (5→6 FILE_REQUIRED):
907
+ - presentation, business, data, infrastructure, cross-cutting (file_actions required or empty array)
908
+
909
+ **Benefits:**
910
+ - Documentation layer enforces file operations for docs work
911
+ - Planning layers allow pure research tasks without file boilerplate
912
+ - Better semantic task classification across the development lifecycle
913
+
914
+ **file_actions Parameter for Tasks**
915
+
916
+ Introduced semantic `file_actions` parameter to replace generic `watch_files`:
917
+
918
+ ```typescript
919
+ // New file_actions parameter
920
+ task.create({
921
+ title: "Implement OAuth",
922
+ layer: "business",
923
+ file_actions: [
924
+ { action: "create", path: "src/auth/oauth.ts" },
925
+ { action: "edit", path: "src/api/router.ts" },
926
+ { action: "delete", path: "src/auth/legacy.ts" }
927
+ ]
928
+ });
929
+
930
+ // Backward compatible - watch_files still works
931
+ task.create({
932
+ title: "Update config",
933
+ layer: "infrastructure",
934
+ watch_files: ["config.toml"] // Auto-converts to file_actions
935
+ });
936
+ ```
937
+
938
+ **Layer-Based Validation:**
939
+ - FILE_REQUIRED layers (6) → Must provide `file_actions` or `[]`
940
+ - FILE_OPTIONAL layers (3) → Can omit `file_actions` entirely
941
+ - Clear error messages with layer-specific guidance
942
+
943
+ **Benefits:**
944
+ - Self-documenting: `action: 'create'` vs `action: 'edit'` shows intent
945
+ - Prevents forgotten file watchers (validation enforced)
946
+ - No boilerplate for planning tasks (can omit parameter)
947
+ - Better token efficiency with automatic file watching
948
+
949
+ **PostgreSQL Adapter Implementation**
950
+
951
+ Full PostgreSQL 12+ support with complete adapter implementation:
952
+
953
+ **Adapter Features:**
954
+ - All 15 abstract methods implemented (`insertReturning`, `upsert`, `jsonExtract`, etc.)
955
+ - PostgreSQL-specific SQL syntax (RETURNING, ON CONFLICT, string_agg)
956
+ - Strict type handling (TRUE/FALSE for booleans, not 1/0)
957
+ - Timezone-aware timestamp functions
958
+ - Transaction support with savepoints
959
+
960
+ **Migration Compatibility:**
961
+ - All 22 migrations tested and verified on PostgreSQL 16.10
962
+ - Cross-database helper functions for view creation
963
+ - Proper CASCADE handling for foreign key dependencies
964
+ - Sequence management after explicit ID inserts
965
+ - GROUP BY strictness compliance
966
+
967
+ **Supported Databases:**
968
+ - SQLite 3.x (default, development)
969
+ - MySQL 8.0 / MariaDB 10+ (production)
970
+ - PostgreSQL 12+ (production) ✨ NEW
971
+
972
+ **Configuration:**
973
+ ```toml
974
+ [database]
975
+ type = "postgres"
976
+
977
+ [database.connection]
978
+ host = "localhost"
979
+ port = 5432
980
+ database = "sqlew_db"
981
+
982
+ [database.auth]
983
+ type = "direct"
984
+ user = "sqlew_user"
985
+ password = "secret"
986
+ ```
987
+
988
+ ### Fixed
989
+
990
+ **Batch Action Parameter Parsing**
991
+
992
+ Fixed MCP client array serialization issue affecting all batch actions:
993
+
994
+ **Problem:** MCP client serializes array parameters as JSON strings:
995
+ ```typescript
996
+ // MCP sends:
997
+ decisions: "[{\"key\": \"test\", \"value\": \"val\"}]" // String!
998
+
999
+ // Expected:
1000
+ decisions: [{key: "test", value: "val"}] // Array
1001
+ ```
1002
+
1003
+ **Solution:** Added JSON parsing in `tool-handlers.ts` for all batch actions:
1004
+ - `decision.set_batch` - parse `decisions` parameter
1005
+ - `file.record_batch` - parse `file_changes` parameter
1006
+ - `task.create_batch` - parse `tasks` parameter
1007
+
1008
+ **Impact:** All batch actions now work correctly with array parameters from MCP client.
1009
+
1010
+ **Help System Synchronization**
1011
+
1012
+ Fixed critical bug where help database was severely out of sync with code:
1013
+
1014
+ **Problem:** 25 actions missing from `m_help_actions` table, causing help system to lie about available actions.
1015
+
1016
+ **Missing Actions:**
1017
+ - decision: 9 actions (quick_set, search_advanced, set_batch, has_updates, etc.)
1018
+ - task: 14 actions (update, get, list, move, link, archive, create_batch, etc.)
1019
+ - constraint: 1 action (use_case)
1020
+
1021
+ **Solution:** Created migration `20251109020000_fix_missing_help_actions_v3_8_0.ts` to:
1022
+ - Add all 25 missing actions with correct descriptions
1023
+ - Idempotent checks to prevent duplicates
1024
+ - Full synchronization between code and database
1025
+
1026
+ **Impact:** Help system now accurately reports all available actions.
1027
+
1028
+ ### Changed
1029
+
1030
+ **Tool Registry Schema Fix**
1031
+
1032
+ Added `additionalProperties: true` to all tool schemas in `tool-registry.ts`:
1033
+
1034
+ **Problem:** MCP couldn't pass action-specific parameters (key, value, tags, etc.) because schemas only defined `action` property.
1035
+
1036
+ **Solution:**
1037
+ ```typescript
1038
+ {
1039
+ name: 'decision',
1040
+ inputSchema: {
1041
+ type: 'object',
1042
+ properties: {
1043
+ action: { ... }
1044
+ },
1045
+ required: ['action'],
1046
+ additionalProperties: true, // CRITICAL FIX
1047
+ },
1048
+ }
1049
+ ```
1050
+
1051
+ **Impact:** All MCP tools now accept action-specific parameters correctly.
1052
+
1053
+ ---
1054
+
1055
+ ## [3.7.4] - 2025-11-08
1056
+
1057
+ ### Added - Complete JSON Import/Export System
1058
+
1059
+ **Full-featured data migration system with smart ID remapping and dependency resolution**
1060
+
1061
+ #### New Features
1062
+
1063
+ - **db:import CLI Command** - Import project data from JSON exports with automatic ID remapping
1064
+ - Smart conflict detection (skip-if-exists, project-name override)
1065
+ - Dry-run mode for validation before import
1066
+ - Comprehensive error messages with validation details
1067
+ - **Topological Sort Algorithm** - Resolves task dependencies during import
1068
+ - Circular dependency detection prevents import of invalid dependency graphs
1069
+ - BFS-based topological sorting ensures dependencies imported before dependents
1070
+ - Preserves all task relationships and blocking constraints
1071
+ - **Smart ID Remapping** - Handles complex foreign key relationships
1072
+ - Master table merge logic (reuse existing entries by name/path)
1073
+ - Transaction table ID translation with bidirectional mapping
1074
+ - Junction table relationship preservation
1075
+ - Automatic orphan cleanup for invalid references
1076
+
1077
+ #### Import System Architecture
1078
+
1079
+ - **4 Core Modules**:
1080
+ 1. `import.ts` - Main orchestrator with transaction management
1081
+ 2. `master-tables.ts` - Master table merge logic (m_files, m_tags, m_scopes, etc.)
1082
+ 3. `topological-sort.ts` - Dependency graph analysis and sorting
1083
+ 4. `db-import.ts` - CLI command with argument parsing and validation
1084
+
1085
+ #### Data Migration Strategy
1086
+
1087
+ - **ID Remapping**: All imported data gets fresh auto-incremented IDs (no ID preservation)
1088
+ - **Master Table Deduplication**: Reuse existing entries for agents, tags, scopes, files by name/path
1089
+ - **Transaction Atomicity**: All-or-nothing semantics (full rollback on any error)
1090
+ - **Project Isolation**: Each import creates independent project with no cross-contamination
1091
+
1092
+ #### CLI Examples
1093
+
1094
+ ```bash
1095
+ # Import project from JSON export
1096
+ npx sqlew db:import --source=project-backup.json
1097
+
1098
+ # Import with custom project name
1099
+ npx sqlew db:import --source=data.json --project-name=my-project
1100
+
1101
+ # Dry-run validation (no actual import)
1102
+ npx sqlew db:import --source=data.json --dry-run
1103
+
1104
+ # Export project for migration
1105
+ npx sqlew db:export --project=visualizer --output=visualizer-data.json
1106
+ ```
1107
+
1108
+ #### Technical Details
1109
+
1110
+ - **Batch Inserts** - 10-row batches to avoid SQLite UNION ALL limits
1111
+ - **Foreign Key Validation** - Validates all foreign key references before insertion
1112
+ - **View Handling** - Temporarily drops/restores views during schema changes
1113
+ - **Idempotent Operations** - Safe to retry on failure
1114
+ - **Error Recovery** - Detailed error messages with validation guidance
1115
+
1116
+ #### Use Cases
1117
+
1118
+ - **Multi-Project Single Database** - Consolidate multiple projects when database creation permissions are limited
1119
+ - **Project Sharing** - Share context with team members or between machines
1120
+ - **Cross-Database Migration** - Move projects between different databases (different machine, SQLite → MySQL, etc.)
1121
+
1122
+ **Note**: Import uses `--skip-if-exists=true` by default. This is NOT a backup/restore solution for the same database.
1123
+ Use database-level backups (SQLite file copy, MySQL dump) for backup/restore scenarios.
1124
+
1125
+ #### Impact
1126
+
1127
+ - **Complete migration solution** - Export from one database, import to another
1128
+ - **Multi-project support** - Merge multiple project exports into single database
1129
+ - ✅ **Permission-friendly** - Works for users who can't create multiple databases
1130
+ - **Data integrity** - Zero data loss, all relationships preserved
1131
+ - **Production ready** - Comprehensive error handling and validation
1132
+ - **Cross-database compatible** - JSON format works across SQLite, MySQL, PostgreSQL
1133
+
1134
+ ---
1135
+
1136
+ ### Fixed - Multi-Project Migration (HOTFIX)
1137
+
1138
+ **Critical fix for v3.7.0-v3.7.2 migration in multi-project scenarios**
1139
+
1140
+ #### Problem
1141
+
1142
+ - Users upgrading from v3.6.10 to v3.7.0+ could end up with duplicate projects
1143
+ - Migration 20251104000000 created project #1 with fake name "default-project"
1144
+ - Users creating second project manually resulted in namespace conflicts
1145
+
1146
+ #### Solution
1147
+
1148
+ - Enhanced migration idempotency checks
1149
+ - Improved project consolidation logic
1150
+ - Better handling of existing project scenarios
1151
+
1152
+ #### Impact
1153
+
1154
+ - **Safe multi-project migration** - No duplicate projects created
1155
+ - ✅ **Backward compatible** - Works for both fresh installs and upgrades
1156
+ - **Data preservation** - All existing data maintained correctly
1157
+
1158
+ ---
1159
+
1160
+ ## [3.7.3] - 2025-11-06
1161
+
1162
+ ### Fixed - Master Tables Namespace Collision Bug
1163
+
1164
+ **Critical bug fix for incomplete multi-project support in v3.7.0-v3.7.2**
1165
+
1166
+ #### Problem
1167
+ - Master tables (m_files, m_tags, m_scopes) lacked `project_id` columns in v3.7.0-v3.7.2
1168
+ - This caused **namespace collisions** where identical file paths/tag names/scope names from different projects would conflict
1169
+ - Example: "src/index.ts" from ProjectA would collide with ProjectB's "src/index.ts"
1170
+ - Users upgrading from v3.6.x would have fake project name "default-project" instead of detected real name
1171
+
1172
+ #### Solution
1173
+ - **20251106000000_fix_master_tables_project_id_v3_7_3.ts** - Comprehensive migration that:
1174
+ 1. **Data Consolidation** - Detects v3.7.0-v3.7.2 upgrade scenario and consolidates project #2 data into project #1
1175
+ 2. **Project Rename** - Renames fake "default-project" to real detected name (from config.toml/git remote/directory)
1176
+ 3. **Schema Fix** - Adds `project_id` column to m_files, m_tags, m_scopes with composite UNIQUE constraints
1177
+ 4. **Data Migration** - Maps all existing master table data to default project (ID 1)
1178
+ 5. **Orphan Cleanup** - Filters out 95 orphaned foreign key references (deleted tasks/tags)
1179
+ 6. **View Restoration** - Temporarily drops and restores 4 views during migration
1180
+ 7. **Table Restoration** - Backs up and restores 6 referencing tables with updated foreign keys
1181
+
1182
+ #### Migration Details
1183
+ - **Idempotent** - Can run multiple times safely (checks for existing columns)
1184
+ - **Version-Aware** - Only consolidates data for v3.7.0-v3.7.2 databases (detects fake project names)
1185
+ - **Batch Inserts** - Uses 10-row batches to avoid SQLite UNION ALL limits
1186
+ - **FK Filtering** - Validates foreign key references before restoration to prevent constraint errors
1187
+ - **SQLite-Optimized** - Handles better-sqlite3 FK constraint behavior during table drops
1188
+
1189
+ #### Technical Changes
1190
+ - **m_files**: Added `project_id` column, changed UNIQUE constraint from `(path)` to `(project_id, path)`
1191
+ - **m_tags**: Added `project_id` column, changed UNIQUE constraint from `(name)` to `(project_id, name)`
1192
+ - **m_scopes**: Added `project_id` column, changed UNIQUE constraint from `(name)` to `(project_id, name)`
1193
+ - **Referencing Tables**: Updated t_file_changes, t_task_file_links, t_decision_tags, t_task_tags, t_constraint_tags, t_decision_scopes
1194
+ - **Views**: Restored v_layer_summary, v_task_board, v_tagged_decisions, v_tagged_constraints
1195
+
1196
+ #### Impact
1197
+ - ✅ **Fixed namespace collisions** - Files/tags/scopes from different projects can now have identical names
1198
+ - ✅ **Data integrity** - All existing data preserved and mapped correctly
1199
+ - ✅ **Project consolidation** - v3.7.0-v3.7.2 users get clean migration path
1200
+ - ✅ **Real project names** - No more fake "default-project" names
1201
+ - **Orphan cleanup** - Removed invalid foreign key references automatically
1202
+ - ✅ **Full idempotency** - Migration can be safely re-run if interrupted
1203
+
1204
+ #### Testing
1205
+ - Tested on actual v3.7.2 production database (mcp-sqlew project)
1206
+ - ✅ Successfully consolidated 77 decisions, 191 tasks, 61 file changes
1207
+ - ✅ Filtered 95 orphaned task-tag references
1208
+ - All views and referencing tables restored correctly
1209
+ - Final database state validated with composite UNIQUE constraints working
1210
+
1211
+ ---
1212
+
1213
+ ## [3.7.2] - 2025-11-05
1214
+
1215
+ ### Changed - Enhanced Sub-Agent Templates
1216
+
1217
+ **Improved specialized agent templates for more efficient sqlew usage**
1218
+
1219
+ #### Sub-Agent Template Updates
1220
+ - **sqlew-scrum-master.md** - Enhanced multi-agent coordination and task management workflows
1221
+ - **sqlew-researcher.md** - Improved decision querying and context analysis patterns
1222
+ - **sqlew-architect.md** - Enhanced decision documentation and constraint enforcement workflows
1223
+
1224
+ #### New Documentation
1225
+ - Installation and configuration instructions
1226
+ - Usage examples for each agent
1227
+ - Token optimization guidelines
1228
+ - Agent comparison and capability matrix
1229
+ - Integration patterns
1230
+ - Troubleshooting guide
1231
+
1232
+ #### SQL Dump Enhancements
1233
+ - Added type conversion testing (`src/tests/type-conversion.test.ts`)
1234
+ - Enhanced SQL dump converters for better type handling
1235
+ - Improved SQL dump utilities with expanded functionality
1236
+
1237
+ ### Fixed - Git LFS PNG Display Issue
1238
+
1239
+ **Removed Git LFS tracking for PNG files to fix GitHub display**
1240
+
1241
+ #### Problem
1242
+ - PNG files were tracked with Git LFS, causing display issues on GitHub
1243
+ - Users without Git LFS saw ASCII pointers instead of images
1244
+ - README images were not rendering properly
1245
+
1246
+ #### Solution
1247
+ - Removed `*.png filter=lfs diff=lfs merge=lfs -text` from .gitattributes
1248
+ - Restored actual PNG binary files from pre-LFS commits
1249
+ - All PNG images now display correctly on GitHub without requiring Git LFS
1250
+
1251
+ #### Impact
1252
+ - **Better agent templates** - More efficient sqlew usage patterns
1253
+ - **Comprehensive documentation** - Clear installation and usage guides
1254
+ - ✅ **Improved type handling** - Better SQL dump type conversion
1255
+ - **Fixed GitHub display** - PNG images now render properly without Git LFS
1256
+ - **Token efficient** - Optimized agent workflows reduce unnecessary tool calls
1257
+
1258
+ ---
1259
+
1260
+ ## [3.7.1] - 2025-11-05
1261
+
1262
+ ### Fixed - Error Message Visibility
1263
+
1264
+ **Fixed validation error messages being hidden by error wrapper**
1265
+
1266
+ #### Problem
1267
+ - Validation errors (JSON-structured responses) were being wrapped with stack traces
1268
+ - Wrong-usage messages were hidden from MCP clients
1269
+ - Users received generic error messages instead of helpful validation details
1270
+
1271
+ #### Solution
1272
+ - **Error Handler Enhancement** - Detect and unwrap JSON validation errors
1273
+ - Validation errors now returned directly to MCP client without wrapping
1274
+ - Stack traces written to logs only (not returned to client)
1275
+ - Token-efficient responses without exposing internal stack details
1276
+ - **Parameter Validator Enhancement** - Detect unexpected/invalid parameters
1277
+ - Added validation for parameters that don't match valid list and have no typo suggestion
1278
+ - Improved error messages: "Unexpected params: X. Valid params: Y, Z"
1279
+
1280
+ #### Impact
1281
+ - **Better UX** - Validation errors are now visible and actionable
1282
+ - ✅ **Token efficiency** - No stack traces in MCP responses
1283
+ - ✅ **Clearer feedback** - Users see helpful error messages immediately
1284
+ - **Security** - Internal stack details not exposed to clients
1285
+
1286
+ ---
1287
+
1288
+ ## [3.7.0] - 2025-11-05
1289
+
1290
+ ### Added - Runtime Database Reconnection
1291
+
1292
+ **Automatic connection recovery with exponential backoff retry logic**
1293
+
1294
+ #### Features
1295
+ - **ConnectionManager** - Singleton wrapper for all database operations
1296
+ - **Exponential Backoff** - Retry delays: 1s → 2s → 4s → 8s → 16s (31 seconds total)
1297
+ - **Smart Error Detection** - Recognizes connection errors across SQLite, MySQL, PostgreSQL
1298
+ - **Process.exit on Exhaustion** - Exits cleanly after 5 failed retries
1299
+ - **27 Operations Wrapped** - All transactional operations protected:
1300
+ - context.ts: 5 operations
1301
+ - tasks.ts: 9 operations
1302
+ - files.ts: 3 operations
1303
+ - constraints.ts: 3 operations
1304
+ - config.ts: 2 operations
1305
+ - utils.ts: 5 operations
1306
+
1307
+ #### Connection Error Patterns Detected
1308
+ - **Network Errors**: ECONNREFUSED, ENOTFOUND, ETIMEDOUT, ECONNRESET, EPIPE
1309
+ - **SQLite**: "database is locked", "unable to open database"
1310
+ - **MySQL/MariaDB**: "server has gone away", "lost connection to mysql server"
1311
+ - **PostgreSQL**: "connection to server was lost", "could not connect to server"
1312
+ - **Knex-specific**: "timeout acquiring a connection", "pool is destroyed"
1313
+
1314
+ #### Test Coverage
1315
+ - **41 tests passing** (22 unit + 19 integration)
1316
+ - Retry behavior verification
1317
+ - Production scenario simulation (server restart, network failures)
1318
+ - Tool integration testing
1319
+
1320
+ #### Impact
1321
+ - ✅ **Resilient operations** - Automatic recovery from transient connection failures
1322
+ - ✅ **Production ready** - Handles server restarts, network issues
1323
+ - ✅ **Zero regressions** - All existing tests pass
1324
+ - ✅ **Token efficient** - No manual retry logic needed in agent code
1325
+
1326
+ ---
1327
+
1328
+ ### Changed - Validation Error Messages
1329
+
1330
+ **70-85% token reduction in error message size**
1331
+
1332
+ #### Token Efficiency
1333
+ - **Before**: ~1000+ characters (~300+ tokens) with full examples embedded
1334
+ - **After**: ~200 characters (~50 tokens) with reference IDs
1335
+ - **Reduction**: 70-85% token savings
1336
+
1337
+ #### New Error Format
1338
+ ```json
1339
+ {
1340
+ "error": "Missing: key, value",
1341
+ "action": "set",
1342
+ "reference": "decision.set",
1343
+ "missing": ["key", "value"],
1344
+ "hint": "Use 'quick_set' for simpler usage..."
1345
+ }
1346
+ ```
1347
+
1348
+ #### Features
1349
+ - **Reference IDs** - Compact `{tool}.{action}` format (e.g., "decision.set")
1350
+ - **Concise Messages** - Essential information only
1351
+ - **Conditional Fields** - Only include fields when present
1352
+ - **Self-Documenting** - AI can query `action: "help"` for full docs if needed
1353
+
1354
+ #### Error Types
1355
+ - Missing params: `"Missing: key, value"`
1356
+ - Typos: `"Invalid params: val → value"`
1357
+ - Unknown action: `"Unknown action 'sett'. Did you mean: set?"`
1358
+
1359
+ #### Impact
1360
+ - **Token efficiency** - 70-85% reduction in error size
1361
+ - **Cost reduction** - Lower API costs for AI agents
1362
+ - **Better UX** - Quick, scannable errors
1363
+ - **Backward compatible** - Error structure unchanged
1364
+
1365
+ ---
1366
+
1367
+ ### Changed - Debug Log Format
1368
+
1369
+ **Single-line log entries for easier parsing**
1370
+
1371
+ #### Problem
1372
+ Multi-line log messages broke standard text processing tools (grep, awk, log rotation).
1373
+
1374
+ #### Solution
1375
+ - **Sanitization Function** - Replaces newlines with spaces, collapses whitespace
1376
+ - **Applied To**: All log messages, data values, JSON output
1377
+ - **Result**: Every log entry is exactly one line
1378
+
1379
+ #### Benefits
1380
+ - ✅ **Easier parsing** - Line-based tools work correctly
1381
+ - ✅ **Better grep** - Search across entire messages
1382
+ - ✅ **Simpler analysis** - Standard text processing
1383
+ - ✅ **Cleaner output** - No unexpected line breaks
1384
+
1385
+ #### Example
1386
+ **Before:**
1387
+ ```
1388
+ [2025-11-05T02:00:00.000Z] [ERROR] Error details:
1389
+ Stack trace line 1
1390
+ Stack trace line 2
1391
+ ```
1392
+
1393
+ **After:**
1394
+ ```
1395
+ [2025-11-05T02:00:00.000Z] [ERROR] Error details: Stack trace line 1 Stack trace line 2
1396
+ ```
1397
+
1398
+ ---
1399
+
1400
+ ### Changed - Specialized Agent Templates (Error Prevention)
1401
+
1402
+ **Restructured agent templates to reduce tool call errors from 60% to <10%**
1403
+
1404
+ #### Problem
1405
+ - 60% of agent errors: missing `action` parameter in tool calls
1406
+ - Templates embedded outdated action samples that became obsolete
1407
+ - Agents guessed syntax instead of using discovery workflow
1408
+
1409
+ #### Solution
1410
+ All three agent templates restructured with error-prevention focus:
1411
+ - **sqlew-architect.md** - Decision documentation specialist
1412
+ - **sqlew-researcher.md** - Context analysis specialist
1413
+ - **sqlew-scrum-master.md** - Sprint coordination specialist
1414
+
1415
+ #### Key Improvements
1416
+ - ⚠️ **Prominent Error-Prevention Section** - "CRITICAL: Error-Free sqlew Tool Usage" at top
1417
+ - 📚 **Discovery-First Workflow** - Guides agents: `action: "help"` → `action: "example"` → copy/modify
1418
+ - ❌✅ **Zero-Error Pattern** - Clear WRONG/CORRECT examples for every common mistake:
1419
+ - Missing `action` parameter
1420
+ - Wrong data types (priority: string vs number)
1421
+ - Wrong parameter names (old v2.x API)
1422
+ - 🔍 **Pre-Execution Checklist** - Verify `action` parameter before every tool call
1423
+ - 🗑️ **No Embedded Samples** - Removed action lists to prevent outdated syntax
1424
+ - 🛠️ **Common Data Type Errors** - Shows tag arrays, boolean atomics, integer priorities
1425
+
1426
+ #### Upgrade Path
1427
+ **Note**: Existing `.claude/agents/` files NOT auto-upgraded (preserves customizations)
1428
+
1429
+ **Manual upgrade required**:
1430
+ ```bash
1431
+ # Remove old templates
1432
+ rm .claude/agents/sqlew-{architect,researcher,scrum-master}.md
1433
+
1434
+ # Restart MCP server (auto-copies new templates from assets/sample-agents/)
1435
+ ```
1436
+
1437
+
1438
+ #### Impact
1439
+ - ✅ **Target: 60% <10% error rate** for agent tool calls
1440
+ - ✅ **Better UX** - Clear guidance prevents common mistakes
1441
+ - ✅ **Self-Correcting** - Agents learn correct patterns from errors
1442
+ - **Future-Proof** - Discovery workflow adapts to API changes
1443
+
1444
+ ---
1445
+
1446
+ ### Fixed - Multi-Project Migration (Critical)
1447
+
1448
+ **Fixed migration for ALL users upgrading from v3.6.10 to v3.7.0**
1449
+
1450
+ #### Problem
1451
+ - SQLite's `ALTER TABLE` silently failed for 4 tables with complex foreign keys
1452
+ - Migration reported success but columns weren't added
1453
+ - Task creation would fail: `"table t_task_details has no column named project_id"`
1454
+
1455
+ #### Root Cause
1456
+ SQLite cannot modify tables with `ON DELETE CASCADE` constraints using ALTER TABLE.
1457
+
1458
+ #### Solution
1459
+ - **Table Recreation Strategy** - Backup → Drop → Recreate → Restore
1460
+ - **4 Tables Fixed**:
1461
+ - `t_task_details` (STEP 4.7)
1462
+ - `t_task_file_links` (STEP 4.8)
1463
+ - `t_task_decision_links` (STEP 4.9)
1464
+ - `t_task_tags` (composite PRIMARY KEY)
1465
+
1466
+ #### Idempotency
1467
+ All recreation steps check if `project_id` exists before executing:
1468
+ ```typescript
1469
+ const hasProjectId = await knex.schema.hasColumn('table_name', 'project_id');
1470
+ if (!hasProjectId) {
1471
+ // Recreation logic
1472
+ }
1473
+ ```
1474
+
1475
+ #### Data Preservation Verified
1476
+ - ✅ 223 task detail rows preserved
1477
+ - ✅ 632 task tag rows preserved
1478
+ - ✅ All task links preserved
1479
+ - ✅ 100% data integrity maintained
1480
+
1481
+ #### Testing
1482
+ - ✅ Fresh installation works
1483
+ - v3.6.10 v3.7.0 upgrade works
1484
+ - ✅ Migration can be re-run safely (idempotent)
1485
+ - TypeScript compiles without errors
1486
+
1487
+ #### Impact
1488
+ - **Production ready** - Safe for all v3.6.10 users to upgrade
1489
+ - **No data loss** - All existing data preserved
1490
+ - **Idempotent** - Can re-run without errors
1491
+
1492
+ ---
1493
+
1494
+ ## [3.6.10] - 2025-10-30
1495
+
1496
+ ### Added - Environment Variable Support for Project Root
1497
+
1498
+ **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1499
+
1500
+ #### Problem
1501
+ - Junie AI and other MCP clients require absolute paths in configuration
1502
+ - Users had to hardcode project-specific paths in MCP server config
1503
+ - No easy way to use project-relative database paths
1504
+
1505
+ #### Solution
1506
+ - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1507
+ - MCP clients can now pass project directory via environment variable
1508
+ - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1509
+
1510
+ #### Priority Order
1511
+ 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1512
+ 2. `--db-path` CLI argument (absolute path)
1513
+ 3. `--config-path` CLI argument (absolute path)
1514
+ 4. `database.path` in config file (absolute path)
1515
+ 5. `process.cwd()` fallback
1516
+
1517
+ #### Junie AI Configuration Example
1518
+ ```json
1519
+ {
1520
+ "mcpServers": {
1521
+ "sqlew": {
1522
+ "command": "npx",
1523
+ "args": ["sqlew"],
1524
+ "env": {
1525
+ "SQLEW_PROJECT_ROOT": "{projectDir}"
1526
+ }
1527
+ }
1528
+ }
1529
+ }
1530
+ ```
1531
+
1532
+ **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1533
+
1534
+ #### Impact
1535
+ - **Project-relative databases** without hardcoded absolute paths
1536
+ - ✅ **Cleaner MCP configuration** (no per-project path updates needed)
1537
+ - ✅ **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1538
+ - ✅ **No breaking changes** (environment variable is optional)
1539
+
1540
+ ---
1541
+
1542
+ ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1543
+
1544
+ **Eliminated console output for strict JSON-RPC protocol compliance**
1545
+
1546
+ #### Problem
1547
+ - EPIPE (broken pipe) errors when running with Junie AI on Windows
1548
+ - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1549
+ - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1550
+
1551
+ #### Changes
1552
+ - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1553
+ - Modified `safeConsoleError()` to write to debug log instead of stderr
1554
+ - Replaced 50+ console.log/console.error calls across codebase:
1555
+ - `src/database.ts` - Database initialization messages
1556
+ - `src/watcher/file-watcher.ts` - File watcher status and events
1557
+ - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1558
+ - `src/tools/tasks.ts` - Task file registration warnings
1559
+ - `src/config/example-generator.ts` - First launch messages
1560
+
1561
+ #### Technical Details
1562
+ - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1563
+ - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1564
+ - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1565
+ - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1566
+
1567
+ #### Impact
1568
+ - **Works with strict MCP clients** (Junie AI, etc.)
1569
+ - **Maintains full diagnostics** via debug log file
1570
+ - ✅ **Pure JSON-RPC protocol** compliance
1571
+ - ✅ **No breaking changes** to MCP tool functionality
1572
+
1573
+ ---
1574
+
1575
+ ### Added - Environment Variable Support for Project Root
1576
+
1577
+ **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1578
+
1579
+ #### Problem
1580
+ - Junie AI and other MCP clients require absolute paths in configuration
1581
+ - Users had to hardcode project-specific paths in MCP server config
1582
+ - No easy way to use project-relative database paths
1583
+
1584
+ #### Solution
1585
+ - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1586
+ - MCP clients can now pass project directory via environment variable
1587
+ - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1588
+
1589
+ #### Priority Order
1590
+ 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1591
+ 2. `--db-path` CLI argument (absolute path)
1592
+ 3. `--config-path` CLI argument (absolute path)
1593
+ 4. `database.path` in config file (absolute path)
1594
+ 5. `process.cwd()` fallback
1595
+
1596
+ #### Junie AI Configuration Example
1597
+ ```json
1598
+ {
1599
+ "mcpServers": {
1600
+ "sqlew": {
1601
+ "command": "npx",
1602
+ "args": ["sqlew"],
1603
+ "env": {
1604
+ "SQLEW_PROJECT_ROOT": "{projectDir}"
1605
+ }
1606
+ }
1607
+ }
1608
+ }
1609
+ ```
1610
+
1611
+ **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1612
+
1613
+ #### Impact
1614
+ - **Project-relative databases** without hardcoded absolute paths
1615
+ - ✅ **Cleaner MCP configuration** (no per-project path updates needed)
1616
+ - ✅ **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1617
+ - ✅ **No breaking changes** (environment variable is optional)
1618
+
1619
+ ---
1620
+
1621
+ ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1622
+
1623
+ **Eliminated console output for strict JSON-RPC protocol compliance**
1624
+
1625
+ #### Problem
1626
+ - EPIPE (broken pipe) errors when running with Junie AI on Windows
1627
+ - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1628
+ - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1629
+
1630
+ #### Changes
1631
+ - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1632
+ - Modified `safeConsoleError()` to write to debug log instead of stderr
1633
+ - Replaced 50+ console.log/console.error calls across codebase:
1634
+ - `src/database.ts` - Database initialization messages
1635
+ - `src/watcher/file-watcher.ts` - File watcher status and events
1636
+ - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1637
+ - `src/tools/tasks.ts` - Task file registration warnings
1638
+ - `src/config/example-generator.ts` - First launch messages
1639
+
1640
+ #### Technical Details
1641
+ - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1642
+ - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1643
+ - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1644
+ - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1645
+
1646
+ #### Impact
1647
+ - **Works with strict MCP clients** (Junie AI, etc.)
1648
+ - **Maintains full diagnostics** via debug log file
1649
+ - ✅ **Pure JSON-RPC protocol** compliance
1650
+ - ✅ **No breaking changes** to MCP tool functionality
1651
+
1652
+ ---
1653
+
1654
+ ### Added - Environment Variable Support for Project Root
1655
+
1656
+ **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1657
+
1658
+ #### Problem
1659
+ - Junie AI and other MCP clients require absolute paths in configuration
1660
+ - Users had to hardcode project-specific paths in MCP server config
1661
+ - No easy way to use project-relative database paths
1662
+
1663
+ #### Solution
1664
+ - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1665
+ - MCP clients can now pass project directory via environment variable
1666
+ - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1667
+
1668
+ #### Priority Order
1669
+ 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1670
+ 2. `--db-path` CLI argument (absolute path)
1671
+ 3. `--config-path` CLI argument (absolute path)
1672
+ 4. `database.path` in config file (absolute path)
1673
+ 5. `process.cwd()` fallback
1674
+
1675
+ #### Junie AI Configuration Example
1676
+ ```json
1677
+ {
1678
+ "mcpServers": {
1679
+ "sqlew": {
1680
+ "command": "npx",
1681
+ "args": ["sqlew"],
1682
+ "env": {
1683
+ "SQLEW_PROJECT_ROOT": "{projectDir}"
1684
+ }
1685
+ }
1686
+ }
1687
+ }
1688
+ ```
1689
+
1690
+ **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1691
+
1692
+ #### Impact
1693
+ - **Project-relative databases** without hardcoded absolute paths
1694
+ - ✅ **Cleaner MCP configuration** (no per-project path updates needed)
1695
+ - ✅ **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1696
+ - ✅ **No breaking changes** (environment variable is optional)
1697
+
1698
+ ---
1699
+
1700
+ ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1701
+
1702
+ **Eliminated console output for strict JSON-RPC protocol compliance**
1703
+
1704
+ #### Problem
1705
+ - EPIPE (broken pipe) errors when running with Junie AI on Windows
1706
+ - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1707
+ - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1708
+
1709
+ #### Changes
1710
+ - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1711
+ - Modified `safeConsoleError()` to write to debug log instead of stderr
1712
+ - Replaced 50+ console.log/console.error calls across codebase:
1713
+ - `src/database.ts` - Database initialization messages
1714
+ - `src/watcher/file-watcher.ts` - File watcher status and events
1715
+ - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1716
+ - `src/tools/tasks.ts` - Task file registration warnings
1717
+ - `src/config/example-generator.ts` - First launch messages
1718
+
1719
+ #### Technical Details
1720
+ - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1721
+ - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1722
+ - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1723
+ - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1724
+
1725
+ #### Impact
1726
+ - **Works with strict MCP clients** (Junie AI, etc.)
1727
+ - **Maintains full diagnostics** via debug log file
1728
+ - ✅ **Pure JSON-RPC protocol** compliance
1729
+ - ✅ **No breaking changes** to MCP tool functionality
1730
+
1731
+ ---
1732
+
1733
+ ### Added - Environment Variable Support for Project Root
1734
+
1735
+ **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1736
+
1737
+ #### Problem
1738
+ - Junie AI and other MCP clients require absolute paths in configuration
1739
+ - Users had to hardcode project-specific paths in MCP server config
1740
+ - No easy way to use project-relative database paths
1741
+
1742
+ #### Solution
1743
+ - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1744
+ - MCP clients can now pass project directory via environment variable
1745
+ - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1746
+
1747
+ #### Priority Order
1748
+ 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1749
+ 2. `--db-path` CLI argument (absolute path)
1750
+ 3. `--config-path` CLI argument (absolute path)
1751
+ 4. `database.path` in config file (absolute path)
1752
+ 5. `process.cwd()` fallback
1753
+
1754
+ #### Junie AI Configuration Example
1755
+ ```json
1756
+ {
1757
+ "mcpServers": {
1758
+ "sqlew": {
1759
+ "command": "npx",
1760
+ "args": ["sqlew"],
1761
+ "env": {
1762
+ "SQLEW_PROJECT_ROOT": "{projectDir}"
1763
+ }
1764
+ }
1765
+ }
1766
+ }
1767
+ ```
1768
+
1769
+ **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1770
+
1771
+ #### Impact
1772
+ - **Project-relative databases** without hardcoded absolute paths
1773
+ - ✅ **Cleaner MCP configuration** (no per-project path updates needed)
1774
+ - ✅ **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1775
+ - ✅ **No breaking changes** (environment variable is optional)
1776
+
1777
+ ---
1778
+
1779
+ ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1780
+
1781
+ **Eliminated console output for strict JSON-RPC protocol compliance**
1782
+
1783
+ #### Problem
1784
+ - EPIPE (broken pipe) errors when running with Junie AI on Windows
1785
+ - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1786
+ - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1787
+
1788
+ #### Changes
1789
+ - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1790
+ - Modified `safeConsoleError()` to write to debug log instead of stderr
1791
+ - Replaced 50+ console.log/console.error calls across codebase:
1792
+ - `src/database.ts` - Database initialization messages
1793
+ - `src/watcher/file-watcher.ts` - File watcher status and events
1794
+ - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1795
+ - `src/tools/tasks.ts` - Task file registration warnings
1796
+ - `src/config/example-generator.ts` - First launch messages
1797
+
1798
+ #### Technical Details
1799
+ - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1800
+ - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1801
+ - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1802
+ - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1803
+
1804
+ #### Impact
1805
+ - **Works with strict MCP clients** (Junie AI, etc.)
1806
+ - **Maintains full diagnostics** via debug log file
1807
+ - ✅ **Pure JSON-RPC protocol** compliance
1808
+ - ✅ **No breaking changes** to MCP tool functionality
1809
+
1810
+ ---
1811
+
1812
+ ### Added - Environment Variable Support for Project Root
1813
+
1814
+ **New `SQLEW_PROJECT_ROOT` environment variable for project-relative databases**
1815
+
1816
+ #### Problem
1817
+ - Junie AI and other MCP clients require absolute paths in configuration
1818
+ - Users had to hardcode project-specific paths in MCP server config
1819
+ - No easy way to use project-relative database paths
1820
+
1821
+ #### Solution
1822
+ - Added `SQLEW_PROJECT_ROOT` environment variable support (inspired by serena-mcp pattern)
1823
+ - MCP clients can now pass project directory via environment variable
1824
+ - Database automatically created at `$SQLEW_PROJECT_ROOT/.sqlew/sqlew.db`
1825
+
1826
+ #### Priority Order
1827
+ 1. `SQLEW_PROJECT_ROOT` environment variable (NEW - highest priority)
1828
+ 2. `--db-path` CLI argument (absolute path)
1829
+ 3. `--config-path` CLI argument (absolute path)
1830
+ 4. `database.path` in config file (absolute path)
1831
+ 5. `process.cwd()` fallback
1832
+
1833
+ #### Junie AI Configuration Example
1834
+ ```json
1835
+ {
1836
+ "mcpServers": {
1837
+ "sqlew": {
1838
+ "command": "npx",
1839
+ "args": ["sqlew"],
1840
+ "env": {
1841
+ "SQLEW_PROJECT_ROOT": "{projectDir}"
1842
+ }
1843
+ }
1844
+ }
1845
+ }
1846
+ ```
1847
+
1848
+ **Note:** Junie AI uses `{projectDir}` variable which expands to the current project's absolute path. This ensures each project gets its own isolated database without hardcoded paths. Other MCP clients may use different variable names like `${workspaceFolder}` (VS Code/Cline) - check your client's documentation.
1849
+
1850
+ #### Impact
1851
+ - **Project-relative databases** without hardcoded absolute paths
1852
+ - ✅ **Cleaner MCP configuration** (no per-project path updates needed)
1853
+ - ✅ **Compatible with Junie AI, Claude Desktop, and other MCP clients**
1854
+ - ✅ **No breaking changes** (environment variable is optional)
1855
+
1856
+ ---
1857
+
1858
+ ### Fixed - MCP Protocol Compliance (EPIPE Fix)
1859
+
1860
+ **Eliminated console output for strict JSON-RPC protocol compliance**
1861
+
1862
+ #### Problem
1863
+ - EPIPE (broken pipe) errors when running with Junie AI on Windows
1864
+ - Console output to stdout/stderr violated MCP JSON-RPC protocol requirements
1865
+ - Strict MCP clients (like Junie AI) expect pure JSON-RPC on stdio streams
1866
+
1867
+ #### Changes
1868
+ - **Redirected all diagnostic output to debug log file** - stdout/stderr reserved exclusively for JSON-RPC
1869
+ - Modified `safeConsoleError()` to write to debug log instead of stderr
1870
+ - Replaced 50+ console.log/console.error calls across codebase:
1871
+ - `src/database.ts` - Database initialization messages
1872
+ - `src/watcher/file-watcher.ts` - File watcher status and events
1873
+ - `src/watcher/gitignore-parser.ts` - .gitignore loading warnings
1874
+ - `src/tools/tasks.ts` - Task file registration warnings
1875
+ - `src/config/example-generator.ts` - First launch messages
1876
+
1877
+ #### Technical Details
1878
+ - **MCP Protocol Requirement**: stdin/stdout/stderr must carry only JSON-RPC messages
1879
+ - **Debug Logging**: All diagnostic messages now use `debugLog()` with appropriate levels (INFO, WARN, ERROR)
1880
+ - **Zero stdout pollution**: Server starts silently, waits for JSON-RPC requests
1881
+ - **Tested with Junie AI**: Confirmed no EPIPE errors on Windows
1882
+
1883
+ #### Impact
1884
+ - **Works with strict MCP clients** (Junie AI, etc.)
1885
+ - **Maintains full diagnostics** via debug log file
1886
+ - **Pure JSON-RPC protocol** compliance
1887
+ - ✅ **No breaking changes** to MCP tool functionality
1888
+
1889
+ ---
1890
+
1891
+ ### Fixed - Windows Absolute Path Handling
1892
+
1893
+ **Fixed path normalization for Windows environments**
1894
+
1895
+ #### Changes
1896
+ - Fixed absolute path to relative path conversion in `gitignore-parser.ts`
1897
+ - Prevented `uname` Unix command calls on Windows
1898
+ - Resolved "path should be a `path.relative()`d string" error on Windows
1899
+ - Improved cross-platform path handling in file watcher
1900
+
1901
+ #### Technical Details
1902
+ - Enhanced path normalization logic to handle Windows drive letters (`C:/`)
1903
+ - Added proper Windows-specific path handling checks
1904
+ - Fixed compatibility with `ignore` library path requirements
1905
+
1906
+ ---
1907
+
1908
+ ## [3.6.8] - 2025-10-30
1909
+
1910
+ ### Fixed - Windows Environment Compatibility
1911
+
1912
+ **Updated better-sqlite3 for Windows support**
1913
+
1914
+ #### Changes
1915
+ - Updated `better-sqlite3` from `^11.0.0` to `^12.4.1`
1916
+ - Fixes Windows environment compatibility issues
1917
+ - Improves cross-platform stability
1918
+
1919
+ ---
1920
+
1921
+ ## [3.6.7] - 2025-10-30
1922
+
1923
+ ### Fixed - Dependency Update
1924
+
1925
+ **Removed deprecated dependency**
1926
+
1927
+ #### Changes
1928
+ - Removed deprecated dependency to ensure compatibility with latest ecosystem
1929
+ - Maintenance update for long-term stability
1930
+
1931
+ ---
1932
+
1933
+ ## [3.6.6] - 2025-10-29
1934
+
1935
+ ### Added - Parameter Validation & Error Handling
1936
+
1937
+ **Comprehensive parameter validation with helpful error messages**
1938
+
1939
+ #### Parameter Validation
1940
+ - **Required/Optional Detection** - Clear indication of required vs optional parameters
1941
+ - **Typo Suggestions** - Levenshtein distance-based "did you mean" suggestions for mistyped parameters
1942
+ - **Structured Error Messages** - JSON format with examples showing correct usage
1943
+ - **Visual Markers** - Help responses show 🔴 REQUIRED and ⚪ OPTIONAL parameter markers
1944
+ - **Action Specs Registry** - Centralized action specification in `src/utils/action-specs.ts`
1945
+ - **Comprehensive Test Suite** - 49 validation tests across all 5 tools
1946
+
1947
+ ### Removed - Config Tool Deprecated
1948
+
1949
+ **Config MCP tool removed in favor of file-based configuration**
1950
+
1951
+ #### Why Removed
1952
+ - Messaging system deprecated (primary use case eliminated)
1953
+ - File-based configuration (`.sqlew/config.toml`) is clearer and more maintainable
1954
+ - Runtime updates caused configuration drift between `m_config` table and config file
1955
+ - Confusing UX (changes lost on restart unless manually synced)
1956
+
1957
+ #### Migration Path
1958
+ - ✅ Use `.sqlew/config.toml` for all configuration (persistent, version-controlled)
1959
+ - Use CLI arguments for one-time overrides
1960
+ - ❌ Do not use `config` tool (will error)
1961
+
1962
+ #### Impact
1963
+ - 5 MCP tools (down from 6): `decision`, `task`, `file`, `constraint`, `stats`
1964
+ - ✅ Clearer configuration workflow (single source of truth)
1965
+ - Better developer experience (validation errors with examples)
1966
+ - Reduced cognitive load (no config drift issues)
1967
+
1968
+ ---
1969
+
1970
+ ## [3.6.5] - 2025-10-28
1971
+
1972
+ ### Changed - Agent System Simplification & CI/CD Fix
1973
+
1974
+ **Removed messaging system and eliminated agent pooling complexity**
1975
+
1976
+ #### Agent System Cleanup
1977
+ - **Removed messaging system** - `t_agent_messages` table dropped, `message` MCP tool deprecated
1978
+ - Messaging system was unused and added unnecessary complexity
1979
+ - Simplified agent architecture to single-purpose registry
1980
+ - **Eliminated agent pooling** - Code no longer uses `in_use` and `is_reusable` columns
1981
+ - Removed race conditions and UNIQUE constraint errors
1982
+ - Each agent name creates one permanent record (no reuse/pooling)
1983
+ - Generic agents (`generic-N`) auto-allocated for empty names
1984
+ - **6 MCP Tools** - Down from 7 (messaging removed)
1985
+ - `decision`, `file`, `constraint`, `stats`, `config`, `task`
1986
+
1987
+ #### Infrastructure
1988
+ - **CI/CD Workflow** - Removed npm publish step from GitHub Actions
1989
+ - npm publish requires 2FA authentication
1990
+ - Publishing must be done manually to prevent workflow failures
1991
+
1992
+ #### Impact
1993
+ - ✅ Simplified agent management (no pooling overhead)
1994
+ - ✅ Reduced complexity (messaging system removed)
1995
+ - ✅ CI/CD workflow no longer fails on npm publish
1996
+
1997
+ ---
1998
+
1999
+ ## [3.6.4] - 2025-10-28
2000
+
2001
+ ### Fixed - WSL Git Add Detection
2002
+
2003
+ **WSL-specific polling workaround for chokidar file watcher**
2004
+
2005
+ #### Changes
2006
+ - **1-second polling for WSL** - Added platform-specific chokidar configuration
2007
+ - WSL filesystem events are unreliable with native watching
2008
+ - Polling ensures git add operations are detected consistently
2009
+ - **Platform detection** - Automatic WSL detection via `/proc/version`
2010
+ - **Backward compatible** - Non-WSL platforms use native file watching (no polling)
2011
+
2012
+ #### Impact
2013
+ - Git add detection now works reliably on WSL
2014
+ - VCS-aware auto-complete functional across all platforms
2015
+
2016
+ ---
2017
+
2018
+ ## [3.6.3] - 2025-10-27
2019
+
2020
+ ### Fixed - Critical Bug Fixes & Git Add Detection
2021
+
2022
+ **Transaction pool exhaustion and VCS-aware auto-complete implementation**
2023
+
2024
+ #### Bug Fixes
2025
+ - **Task Move Transaction Bug** - Fixed `moveTask` using base `knex` instead of transaction `trx` (line 880)
2026
+ - Caused "Knex: Timeout acquiring a connection" errors
2027
+ - Now properly uses transaction object for `logTaskStatusChange`
2028
+ - **Task Link Transaction Bug** - Fixed `linkTask` using base `knex` instead of transaction `trx` (line 948)
2029
+ - Same connection pool exhaustion issue
2030
+ - Now properly uses transaction object for decision link insertion
2031
+
2032
+ #### Features
2033
+ - **Git Add Detection** - Implemented `detectAndCompleteOnStaging()` for VCS-aware workflow
2034
+ - Detects `git add` operations and auto-completes tasks (`waiting_review` → `done`)
2035
+ - Supports Git, Mercurial, and SVN
2036
+ - Configurable via `git_auto_complete_on_stage` and `require_all_files_staged`
2037
+ - **VCS Configuration** - Added comprehensive settings documentation to `config.example.toml`
2038
+ - `git_auto_complete_on_stage` (default: true)
2039
+ - `git_auto_archive_on_commit` (default: true)
2040
+ - `require_all_files_staged` (default: true)
2041
+ - `require_all_files_committed_for_archive` (default: true)
2042
+
2043
+ #### Infrastructure
2044
+ - **Line Ending Fix** - Added `.gitattributes` to enforce LF endings for shell scripts
2045
+ - Prevents CRLF issues in Husky hooks on Windows/WSL
2046
+ - Applies to `*.sh` and `.husky/*` files
2047
+ - **Husky Hooks** - Fixed pre-commit/pre-push hooks (added shebang, normalized line endings)
2048
+
2049
+ #### Impact
2050
+ - Task operations no longer fail with connection pool timeouts
2051
+ - Git add detection now functional (was stubbed in v3.5.2)
2052
+ - ✅ Cross-platform compatibility for git hooks (Windows/WSL/Linux/macOS)
2053
+
2054
+ ---
2055
+
2056
+ ## [3.6.2] - 2025-10-27
2057
+
2058
+ ### Changed - Migration System Modernization
2059
+
2060
+ **Simplified to Knex-only migrations with organized directory structure**
2061
+
2062
+ #### Migration System Cleanup
2063
+ - **Removed custom migration system** (14 obsolete files from `src/migrations/`)
2064
+ - **Pure Knex migrations** - Standardized on Knex.js migration framework
2065
+ - **Organized structure** - 22 migrations grouped into 3 logical subdirectories:
2066
+ - `upgrades/` (7 files) - Version upgrade paths (v1.0 → v3.6)
2067
+ - `bootstrap/` (5 files) - Fresh install foundation
2068
+ - `enhancements/` (10 files) - v3.6.0+ feature additions
2069
+
2070
+ #### Testing & CI/CD
2071
+ - **Migration tests updated** - Converted to use Knex migrations exclusively
2072
+ - **Comprehensive test coverage** - 8/9 versions migrate successfully (89% backward compatibility)
2073
+ - **Husky git hooks** - Pre-commit (build + tests), pre-push (migration tests)
2074
+ - **GitHub Actions workflow** - CI/CD pipeline for Node 18.x/20.x
2075
+
2076
+ #### Benefits
2077
+ - **Better maintainability** - Clear organization, standard tooling
2078
+ - **Easier onboarding** - Knex is industry-standard
2079
+ - **Faster development** - 56% time efficiency via parallel execution
2080
+
2081
+ ---
2082
+
2083
+ ## [3.6.0] - 2025-10-25
2084
+
2085
+ ### Added - Help System Optimization
2086
+
2087
+ **Database-driven help system with 60-70% token efficiency improvement**
2088
+
2089
+ #### Key Achievements
2090
+ - **60-70% Token Reduction** - Average help query: ~200 tokens (vs ~2,150 legacy)
2091
+ - **95.8% Schema Reduction** - MCP InputSchemas: 350 tokens (vs 8,400 legacy)
2092
+ - **6 New Help Actions** - Granular queries for actions, parameters, tools, use-cases
2093
+ - **41 Use-Cases** - Comprehensive workflow examples across 6 categories
2094
+ - **100% Test Coverage** - 38/38 tests passing
2095
+
2096
+ #### New MCP Actions (stats tool)
2097
+ - `help_action` - Query single action with parameters and examples
2098
+ - `help_params` - Query parameter list for an action
2099
+ - `help_tool` - Query tool overview + all actions
2100
+ - `help_use_case` - Get single use-case with full workflow
2101
+ - `help_list_use_cases` - List/filter use-cases by category/complexity
2102
+ - `help_next_actions` - Suggest common next actions
2103
+
2104
+ #### Database Schema
2105
+ 7 new tables: `m_help_tools`, `m_help_actions`, `m_help_use_case_categories`, `t_help_action_params`, `t_help_action_examples`, `t_help_use_cases`, `t_help_action_sequences`
2106
+
2107
+ #### Migration from v3.5.x
2108
+ - Automatic migration on startup
2109
+ - Backward compatible - all existing MCP actions unchanged
2110
+ - Zero downtime
2111
+
2112
+ ---
2113
+
2114
+ ## [3.5.2] - 2025-10-24
2115
+
2116
+ ### Added - Two-Step Git-Aware Task Workflow
2117
+
2118
+ **Automatic task completion and archiving based on Git staging and committing**
2119
+
2120
+ #### Features
2121
+ - **Step 1 - Staging** (`git add`): `waiting_review` → `done` (work complete)
2122
+ - **Step 2 - Committing** (`git commit`): `done` → `archived` (work finalized)
2123
+ - **VCS Support**: Git, Mercurial, and SVN
2124
+ - **Zero Token Cost**: Fully automated, no manual MCP calls needed
2125
+
2126
+ #### Configuration
2127
+ - `git_auto_complete_on_stage` (default: `'1'`)
2128
+ - `git_auto_archive_on_commit` (default: `'1'`)
2129
+ - `require_all_files_staged` (default: `'1'`)
2130
+ - `require_all_files_committed_for_archive` (default: `'1'`)
2131
+
2132
+ ---
2133
+
2134
+ ## [3.5.1] - 2025-10-24
2135
+
2136
+ ### Fixed - File Watcher WSL Compatibility
2137
+
2138
+ **Upgraded chokidar from v3 to v4 + Fixed path normalization bug**
2139
+
2140
+ #### Changes
2141
+ - **chokidar**: `^3.6.0` → `^4.0.3` (automatic WSL support)
2142
+ - Fixed path normalization: chokidar reports absolute paths, database stores relative
2143
+ - Removed manual WSL detection and polling configuration
2144
+
2145
+ ---
2146
+
2147
+ ## [3.5.0] - 2025-10-22
2148
+
2149
+ ### Added - Non-Existent File Auto-Pruning
2150
+
2151
+ **Automatic removal of non-existent watched files with audit trail**
2152
+
2153
+ #### Features
2154
+ - New table: `t_task_pruned_files` - Audit trail for pruned files
2155
+ - Auto-pruning during `in_progress → waiting_review` transition
2156
+ - Safety check: blocks if ALL files non-existent
2157
+ - New MCP actions: `get_pruned_files`, `link_pruned_file`
2158
+
2159
+ #### Documentation
2160
+
2161
+ ---
2162
+
2163
+
2164
+ ## Older Versions
2165
+
2166
+ For changelog entries **v3.4.1 and older**, see:
2167
+ - [docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md](docs/changelogs/CHANGELOG_ARCHIVE_v3.4_and_older.md)
2168
+
2169
+ This includes all versions from v1.0.0 through v3.4.1.