sqlew 2.1.3 → 3.0.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 (84) hide show
  1. package/CHANGELOG.md +891 -535
  2. package/README.md +302 -613
  3. package/assets/kanban-style.png +0 -0
  4. package/assets/schema.sql +531 -402
  5. package/dist/database.d.ts +9 -0
  6. package/dist/database.d.ts.map +1 -1
  7. package/dist/database.js +33 -34
  8. package/dist/database.js.map +1 -1
  9. package/dist/index.js +1024 -21
  10. package/dist/index.js.map +1 -1
  11. package/dist/migrations/add-task-tables.d.ts +47 -0
  12. package/dist/migrations/add-task-tables.d.ts.map +1 -0
  13. package/dist/migrations/add-task-tables.js +285 -0
  14. package/dist/migrations/add-task-tables.js.map +1 -0
  15. package/dist/migrations/index.d.ts +96 -0
  16. package/dist/migrations/index.d.ts.map +1 -0
  17. package/dist/migrations/index.js +239 -0
  18. package/dist/migrations/index.js.map +1 -0
  19. package/dist/migrations/migrate-decisions-to-tasks.d.ts +61 -0
  20. package/dist/migrations/migrate-decisions-to-tasks.d.ts.map +1 -0
  21. package/dist/migrations/migrate-decisions-to-tasks.js +442 -0
  22. package/dist/migrations/migrate-decisions-to-tasks.js.map +1 -0
  23. package/dist/schema.d.ts.map +1 -1
  24. package/dist/schema.js +14 -3
  25. package/dist/schema.js.map +1 -1
  26. package/dist/tools/constraints.d.ts +4 -0
  27. package/dist/tools/constraints.d.ts.map +1 -1
  28. package/dist/tools/constraints.js +6 -27
  29. package/dist/tools/constraints.js.map +1 -1
  30. package/dist/tools/context.d.ts +17 -1
  31. package/dist/tools/context.d.ts.map +1 -1
  32. package/dist/tools/context.js +195 -190
  33. package/dist/tools/context.js.map +1 -1
  34. package/dist/tools/files.d.ts.map +1 -1
  35. package/dist/tools/files.js +113 -166
  36. package/dist/tools/files.js.map +1 -1
  37. package/dist/tools/messaging.d.ts +2 -9
  38. package/dist/tools/messaging.d.ts.map +1 -1
  39. package/dist/tools/messaging.js +67 -126
  40. package/dist/tools/messaging.js.map +1 -1
  41. package/dist/tools/tasks.d.ts +90 -0
  42. package/dist/tools/tasks.d.ts.map +1 -0
  43. package/dist/tools/tasks.js +732 -0
  44. package/dist/tools/tasks.js.map +1 -0
  45. package/dist/tools/utils.d.ts +8 -1
  46. package/dist/tools/utils.d.ts.map +1 -1
  47. package/dist/tools/utils.js +50 -21
  48. package/dist/tools/utils.js.map +1 -1
  49. package/dist/types.d.ts +14 -0
  50. package/dist/types.d.ts.map +1 -1
  51. package/dist/utils/batch.d.ts +69 -0
  52. package/dist/utils/batch.d.ts.map +1 -0
  53. package/dist/utils/batch.js +148 -0
  54. package/dist/utils/batch.js.map +1 -0
  55. package/dist/utils/query-builder.d.ts +68 -0
  56. package/dist/utils/query-builder.d.ts.map +1 -0
  57. package/dist/utils/query-builder.js +116 -0
  58. package/dist/utils/query-builder.js.map +1 -0
  59. package/dist/utils/task-stale-detection.d.ts +28 -0
  60. package/dist/utils/task-stale-detection.d.ts.map +1 -0
  61. package/dist/utils/task-stale-detection.js +92 -0
  62. package/dist/utils/task-stale-detection.js.map +1 -0
  63. package/dist/utils/validators.d.ts +57 -0
  64. package/dist/utils/validators.d.ts.map +1 -0
  65. package/dist/utils/validators.js +117 -0
  66. package/dist/utils/validators.js.map +1 -0
  67. package/docs/AI_AGENT_GUIDE.md +1471 -0
  68. package/{ARCHITECTURE.md → docs/ARCHITECTURE.md} +636 -636
  69. package/docs/BEST_PRACTICES.md +481 -0
  70. package/docs/DECISION_TO_TASK_MIGRATION_GUIDE.md +457 -0
  71. package/docs/MIGRATION_CHAIN.md +280 -0
  72. package/{MIGRATION_v2.md → docs/MIGRATION_v2.md} +538 -538
  73. package/docs/SHARED_CONCEPTS.md +339 -0
  74. package/docs/TASK_ACTIONS.md +854 -0
  75. package/docs/TASK_LINKING.md +729 -0
  76. package/docs/TASK_MIGRATION.md +701 -0
  77. package/docs/TASK_OVERVIEW.md +363 -0
  78. package/docs/TASK_SYSTEM.md +1244 -0
  79. package/docs/TOOL_REFERENCE.md +471 -0
  80. package/docs/TOOL_SELECTION.md +279 -0
  81. package/docs/WORKFLOWS.md +602 -0
  82. package/docs/refactoring-summary-2025-10-17.md +365 -0
  83. package/docs/requirement-2025-10-17.md +508 -0
  84. package/package.json +64 -63
package/CHANGELOG.md CHANGED
@@ -1,535 +1,891 @@
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
- ## [2.1.3] - 2025-10-15
9
-
10
- ### Fixed
11
- - **CRITICAL: Tag/Scope Query Bug** - Fixed "no such column: m_tags" and "no such column: m_scopes" errors in filtering
12
- - **Impact:** ALL tag-based queries (`search_tags`, `list` with tags, `search_advanced` with tags) were broken
13
- - **Root cause:** Code referenced non-existent columns `m_tags` and `m_scopes` (table names, not columns)
14
- - **Affected functions:**
15
- - `searchByTags()` (src/tools/context.ts:311-320) - Used `m_tags` instead of `tags`
16
- - `getContext()` (src/tools/context.ts:210, 221-230) - Used `m_tags` and `m_scopes` instead of `tags`/`scopes`
17
- - **Fix:** Use only `tags` and `scopes` columns from `v_tagged_decisions` view (comma-separated GROUP_CONCAT values)
18
- - **Testing:** Verified with `action: "search_tags", tags: ["architecture","loom"], match_mode: "AND"`
19
-
20
- ### Technical Details
21
- - The `v_tagged_decisions` view has `tags` and `scopes` as comma-separated string columns
22
- - `m_tags` and `m_scopes` are **table names** in the normalized schema, not view columns
23
- - Fixed by removing incorrect column references and using only LIKE pattern matching on the view columns
24
- - All tag/scope filtering now works correctly with AND/OR logic
25
-
26
- ### Migration from v2.1.2
27
- - No breaking changes
28
- - Existing queries will now work correctly instead of failing with SQL errors
29
- - **Recommendation:** Upgrade immediately if using any tag or scope filtering
30
-
31
- ## [2.1.2] - 2025-10-15
32
-
33
- ### Fixed
34
- - **v2.1.0 Migration Bug:** Fixed initialization order issue preventing v2.0.0 databases from migrating to v2.1.0
35
- - **Problem:** Schema validation ran before v2.1.0 migration check, causing v2.0.0 databases to fail validation and exit
36
- - **Solution:** Moved v2.1.0 migration check to run before schema validation (src/database.ts:96-113)
37
- - **Impact:** v2.0.0 databases now automatically migrate to v2.1.0 on startup without errors
38
- - Database components added by migration: `t_activity_log`, `t_decision_templates`, 4 activity logging triggers
39
-
40
- ### Changed
41
- - **Batch Operations Help Documentation:** Enhanced help text for all batch operations with AI agent guidance
42
- - Added detailed ATOMIC MODE behavior explanation (all-or-nothing transaction with rollback)
43
- - Added detailed NON-ATOMIC MODE behavior explanation (best-effort processing with partial results)
44
- - Added RECOMMENDATION FOR AI AGENTS section suggesting `atomic:false` by default
45
- - Applies to: `set_batch` (decision tool), `send_batch` (message tool), `record_batch` (file tool)
46
- - **Zero token impact:** Help text is on-demand only (called with `action: "help"`)
47
- - Helps prevent "cannot start a transaction within a transaction" errors from incorrect usage
48
-
49
- ### Technical Details
50
- - v2.1.0 migration now runs before schema validation to ensure all required components exist
51
- - Help documentation improvements have no effect on MCP tool schema (zero upfront token cost)
52
- - Batch operation help text expanded from ~150 to ~350 characters per action
53
-
54
- ### Migration from v2.1.0/v2.1.1
55
- - No breaking changes
56
- - Existing v2.0.0 databases will now migrate successfully on first startup
57
- - No action required for v2.1.0+ users
58
-
59
- ## [2.1.1] - 2025-10-15
60
-
61
- ### Fixed
62
- - **Bin Command Configuration:** Fixed `npx sqlew` to launch MCP server by default instead of CLI
63
- - Changed `package.json` bin mapping: `sqlew` now points to MCP server (`dist/index.js`)
64
- - CLI mode moved to `sqlew-cli` command (`dist/cli.js`)
65
- - **Before:** `npx sqlew` CLI mode
66
- - **After:** `npx sqlew` → MCP server (default), `sqlew-cli` → CLI mode (after installing the package)
67
- - Fixes user experience issue where MCP server launch required non-intuitive command
68
-
69
- - **Batch Operations Nested Transaction Bug:** Fixed `set_batch` failing with "cannot start a transaction within a transaction" error
70
- - Root cause: `setDecision()` wraps logic in `transaction()`, but `setDecisionBatch()` also wraps calls in `transaction()` for atomic mode
71
- - Solution: Created `setDecisionInternal()` helper function with core logic but no transaction wrapper
72
- - `setDecision()` now calls `setDecisionInternal()` wrapped in transaction
73
- - `setDecisionBatch()` now calls `setDecisionInternal()` directly (batch manages its own transaction)
74
- - All batch operations verified working: `set_batch`, `send_batch`, `record_batch`
75
- - Location: `src/tools/context.ts:40-152` (setDecisionInternal), `context.ts:154-174` (setDecision), `context.ts:883` (setDecisionBatch)
76
-
77
- ### Changed
78
- - **Documentation Improvements:**
79
- - **README Benefits Section:** Rewrote to emphasize organizational memory for AI agents as the core value proposition
80
- - Added comparison table: Git history (WHAT) vs Code comments (HOW) vs sqlew decisions (WHY)
81
- - Added real-world example showing cross-session context survival
82
- - Highlighted 4 key LLM benefits: context survival, prevents regression, historical reasoning, knowledge discovery
83
- - **README Token Savings:** Replaced internal architecture metrics with honest real-world token reduction analysis
84
- - Shows concrete scenario: 5 agents, 10 sessions, 20,000 → 7,400 tokens (63% reduction)
85
- - Explains 4 savings mechanisms: selective retrieval, structured vs unstructured, cross-session persistence, search vs scan
86
- - Provides realistic ranges: Conservative (50-65%), Realistic (60-75%), Optimal (70-85%)
87
- - Clarified that 96%/67% metrics are internal v1.0→v2.0 improvements, not usage benefits
88
-
89
- ### Migration Notes
90
- - No breaking changes for MCP tool API
91
- - Users who relied on `npx sqlew` for CLI should install the package and use `sqlew-cli` command
92
- - MCP server configuration unchanged (still uses stdio transport)
93
-
94
- ## [2.1.0] - 2025-10-14
95
-
96
- ### 🎉 Feature Release
97
-
98
- **Major enhancement release implementing 7 feature requests from real-world usage in the Trackne Server project. Adds activity logging, smart defaults, subscriptions, advanced querying, batch operations, templates, and a standalone CLI tool.**
99
-
100
- ### Added
101
-
102
- #### FR-001: Activity Log System
103
- - **Automatic Activity Logging:** All decision changes, messages, and file modifications are now automatically logged
104
- - New `t_activity_log` table with 3 optimized indexes
105
- - 4 triggers for automatic logging:
106
- - `trg_log_decision_insert` - Logs decision creation
107
- - `trg_log_decision_update` - Logs decision modifications
108
- - `trg_log_message_insert` - Logs message sending
109
- - `trg_log_file_change_insert` - Logs file changes
110
- - `getActivityLog` action in `stats` tool for retrieving filtered logs
111
- - Filter by agent, entity type, action type, and time range
112
- - Token-efficient logging (~50 bytes per log entry)
113
-
114
- #### FR-002: Smart Defaults
115
- - **quickSetDecision:** Streamlined decision setting with automatic layer inference
116
- - Infers layer from key patterns (e.g., "auth_*" infrastructure)
117
- - Auto-extracts tags from key and value (e.g., "jwt_config" ["jwt", "config"])
118
- - Reduces token usage by ~60% for simple decisions
119
- - Falls back to manual tagging when inference is ambiguous
120
- - New `quick_set` action in `decision` tool
121
-
122
- #### FR-003: Lightweight Subscriptions
123
- - **hasUpdates Polling:** Efficient change detection for agents
124
- - Check for updates since last check (~5-10 tokens per call)
125
- - Filter by entity type (decisions, messages, files)
126
- - Filter by scope, layer, or agent
127
- - Returns boolean + count + latest timestamp
128
- - New `has_updates` action in `decision` tool
129
- - 95% token reduction vs full list queries
130
-
131
- #### FR-004: Advanced Query System
132
- - **searchAdvanced:** Comprehensive search across all decision metadata
133
- - 13 query parameters: keys, tags, scopes, layers, status, versions, full-text search
134
- - Pagination support (limit, offset)
135
- - Sort by multiple fields with direction control
136
- - Full-text search in keys and values
137
- - Scope inheritance (search within parent scopes)
138
- - New `search_advanced` action in `decision` tool
139
- - Replaces multiple sequential queries with single call
140
-
141
- #### FR-005: Batch Operations
142
- - **Atomic Batch Processing:** Process multiple operations in a single transaction
143
- - `setDecisionBatch` - Set up to 50 decisions atomically
144
- - `sendMessageBatch` - Send multiple messages in one transaction
145
- - `recordFileChangeBatch` - Record multiple file changes atomically
146
- - All-or-nothing guarantee (rollback on any failure)
147
- - ~70% token reduction vs sequential calls
148
- - New actions: `set_batch` (decision), `send_batch` (message), `record_batch` (file)
149
-
150
- #### FR-006: Template System
151
- - **Decision Templates:** Reusable decision patterns with validation
152
- - 5 built-in templates: auth_config, api_endpoint, db_schema, ui_component, feature_flag
153
- - `createTemplate` - Define custom templates with field schemas
154
- - `setFromTemplate` - Create decisions from templates with validation
155
- - `listTemplates` - Browse available templates
156
- - Template inheritance and composition support
157
- - New `t_decision_templates` table
158
- - New actions: `set_from_template`, `create_template`, `list_templates` (decision tool)
159
-
160
- #### FR-007: Standalone CLI Query Tool
161
- - **Command-Line Interface:** Query MCP database without starting MCP server
162
- - 4 commands: `decisions`, `messages`, `files`, `activity`
163
- - JSON and table output formats
164
- - Filter options match MCP tool parameters
165
- - Supports all query patterns from MCP tools
166
- - Zero MCP token impact (standalone binary)
167
- - New script: `src/cli.ts`
168
- - Usage: `node dist/cli.js decisions --scope=auth --format=table`
169
-
170
- ### Changed
171
-
172
- - **Tool Definitions:** Added 11 new actions across 3 tools
173
- - `decision` tool: 7 → 11 actions (+4: quick_set, has_updates, search_advanced, set_batch, set_from_template, create_template, list_templates)
174
- - `message` tool: 4 5 actions (+1: send_batch)
175
- - `file` tool: 4 5 actions (+1: record_batch)
176
- - `stats` tool: 4 → 5 actions (+1: getActivityLog)
177
- - **Database Schema:** v2.1.0 migration adds 2 tables and 4 triggers
178
- - **Token Efficiency:** Maintains 92% efficiency vs v1.0.0 original design
179
- - Tool definitions: 481 1,031 tokens (+550 tokens for 11 new actions)
180
- - CLI has zero MCP token impact (standalone)
181
- - Batch operations save ~70% tokens vs sequential calls
182
- - hasUpdates saves ~95% tokens vs full list queries
183
-
184
- ### Technical Details
185
-
186
- #### Database Changes
187
- - **New Tables:**
188
- - `t_activity_log` - Automatic logging of all changes (agent_id, entity_type, entity_id, action_type, details, ts)
189
- - `t_decision_templates` - Template definitions (name, description, schema, layer, tags, created_by, created_at)
190
- - **New Indexes:**
191
- - `idx_activity_log_agent_ts` - Agent-based log queries
192
- - `idx_activity_log_entity_ts` - Entity-based log queries
193
- - `idx_activity_log_ts` - Time-based log queries
194
- - **New Triggers:**
195
- - `trg_log_decision_insert`, `trg_log_decision_update` - Decision logging
196
- - `trg_log_message_insert` - Message logging
197
- - `trg_log_file_change_insert` - File change logging
198
-
199
- #### Migration
200
- - **Migration Script:** `src/migrations/add-v2.1.0-features.ts`
201
- - Creates `t_activity_log` and `t_decision_templates` tables
202
- - Creates 3 indexes for activity log queries
203
- - Creates 4 triggers for automatic logging
204
- - Seeds 5 built-in templates
205
- - Transaction-based with rollback on failure
206
- - Automatic execution on startup
207
- - Backward compatible with v2.0.0 databases
208
-
209
- #### Performance
210
- - **Token Efficiency:**
211
- - Batch operations: ~70% reduction vs sequential (3 operations: 1,200 → 360 tokens)
212
- - hasUpdates polling: ~95% reduction vs full list (500 → 25 tokens)
213
- - quickSetDecision: ~60% reduction vs manual (250 100 tokens)
214
- - Templates: ~50% reduction for repeated patterns
215
- - **Query Performance:**
216
- - Activity log queries: 5-15ms (with indexes)
217
- - Advanced search: 10-30ms (with full-text)
218
- - Batch operations: 20-50ms (atomic transaction)
219
- - Template operations: 5-10ms
220
-
221
- #### Code Statistics
222
- - **Source Changes:**
223
- - New files: `src/cli.ts`, `src/migrations/add-v2.1.0-features.ts`
224
- - Modified: `src/tools/context.ts`, `src/tools/messaging.ts`, `src/tools/files.ts`, `src/tools/utils.ts`
225
- - Total lines added: ~1,500 lines
226
- - **CLI Tool:**
227
- - Standalone binary (~300 lines)
228
- - Zero dependencies on MCP server
229
- - Supports all common query patterns
230
-
231
- ### Real-World Impact
232
-
233
- These features were requested during development of the **Trackne Server** project:
234
- - **Activity Log:** Essential for debugging multi-agent coordination
235
- - **Smart Defaults:** Reduced boilerplate by 60% for common decisions
236
- - **Subscriptions:** Enabled efficient polling without full list queries
237
- - **Advanced Query:** Replaced 5-10 sequential queries with single calls
238
- - **Batch Operations:** Critical for atomic state updates across agents
239
- - **Templates:** Standardized patterns across 15+ API endpoints
240
- - **CLI Tool:** Enabled quick debugging without starting MCP server
241
-
242
- ### Migration from v2.0.0
243
-
244
- No breaking changes. All v2.0.0 tool calls work unchanged. New features are opt-in:
245
-
246
- ```javascript
247
- // NEW: Quick decision setting with smart defaults
248
- await callTool('decision', { action: 'quick_set', key: 'jwt_config', value: 'HS256' });
249
- // Auto-infers layer=infrastructure, tags=["jwt", "config"]
250
-
251
- // NEW: Check for updates efficiently
252
- await callTool('decision', { action: 'has_updates', since: '2025-10-14T10:00:00Z' });
253
- // Returns: { hasUpdates: true, count: 5, latestTimestamp: '...' }
254
-
255
- // NEW: Batch operations (atomic)
256
- await callTool('decision', {
257
- action: 'set_batch',
258
- decisions: [
259
- { key: 'auth', value: 'jwt' },
260
- { key: 'db', value: 'postgres' }
261
- ]
262
- });
263
-
264
- // NEW: Use templates
265
- await callTool('decision', {
266
- action: 'set_from_template',
267
- template_name: 'api_endpoint',
268
- key: 'users_api',
269
- values: { path: '/api/users', method: 'GET' }
270
- });
271
-
272
- // NEW: CLI queries (no MCP server needed)
273
- // $ node dist/cli.js decisions --scope=auth --format=table
274
- // $ node dist/cli.js activity --agent=agent1 --limit=20
275
- ```
276
-
277
- Database migration runs automatically on first startup with v2.1.0.
278
-
279
- ## [2.0.0] - 2025-10-11
280
-
281
- ### 🚨 BREAKING CHANGES
282
-
283
- **This is a major release with breaking API changes. Migration required for all v1.x users.**
284
-
285
- #### Tool Consolidation
286
- - **20 individual tools** → **6 action-based tools** (70% reduction)
287
- - All tools now use action-based routing with `action` parameter
288
- - Tool names completely changed (see migration guide below)
289
-
290
- #### Old vs New Tool Names
291
-
292
- | Old (v1.x) | New (v2.0) | Actions |
293
- |------------|------------|---------|
294
- | `set_decision`, `get_decision`, `get_context`, `search_by_tags`, `search_by_layer`, `get_versions` | `decision` | `set`, `get`, `list`, `search_tags`, `search_layer`, `versions`, `help` |
295
- | `send_message`, `get_messages`, `mark_read` | `message` | `send`, `get`, `mark_read`, `help` |
296
- | `record_file_change`, `get_file_changes`, `check_file_lock` | `file` | `record`, `get`, `check_lock`, `help` |
297
- | `add_constraint`, `get_constraints`, `deactivate_constraint` | `constraint` | `add`, `get`, `deactivate`, `help` |
298
- | `get_layer_summary`, `get_stats`, `clear_old_data` | `stats` | `layer_summary`, `db_stats`, `clear`, `help` |
299
- | `get_config`, `update_config` | `config` | `get`, `update`, `help` |
300
-
301
- ### Added
302
-
303
- - **Help Actions:** All 6 tools now support `action: "help"` for comprehensive on-demand documentation
304
- - Returns detailed usage, parameters, and examples
305
- - Zero token cost until explicitly called
306
- - **Action Hints:** Tool descriptions now include available actions for better discoverability
307
- - **Improved Token Efficiency:** 96% token reduction vs traditional JSON approach
308
- - Tool definition tokens: ~12,848 ~481 tokens (96.3% reduction)
309
- - MCP context usage: ~13,730 ~4,482 tokens (67% reduction)
310
-
311
- ### Changed
312
-
313
- - **API Surface:** Complete redesign to action-based routing
314
- - All tools require `action` parameter
315
- - Parameters consolidated into single input schema per tool
316
- - Nested switch statement routing for better maintainability
317
- - **Tool Descriptions:** Simplified with action hints in parentheses
318
- - **File Size:** Source reduced 27.4% (25,373 → 18,410 bytes) while adding help docs
319
-
320
- ### Technical Details
321
-
322
- - Action-based routing with two-level switch statements
323
- - Shared parameter schemas across actions within each tool
324
- - Enum deduplication (layer, status, priority defined once per tool)
325
- - On-demand documentation via help actions
326
- - 100% backward compatible database schema (no DB changes)
327
-
328
- ### Migration Required
329
-
330
- **v1.x users must update their tool calls:**
331
-
332
- ```javascript
333
- // OLD (v1.x)
334
- await callTool('set_decision', { key: 'auth', value: 'jwt' });
335
- await callTool('get_messages', { unread_only: true });
336
-
337
- // NEW (v2.0)
338
- await callTool('decision', { action: 'set', key: 'auth', value: 'jwt' });
339
- await callTool('message', { action: 'get', unread_only: true });
340
- ```
341
-
342
- See `MIGRATION_v2.md` for complete migration guide.
343
-
344
- ### Performance
345
-
346
- - 96% token reduction in tool definitions
347
- - 67% reduction in MCP context consumption
348
- - Same database performance (no schema changes)
349
- - Same query response times
350
-
351
- ## [1.1.2] - 2025-10-11
352
-
353
- ### Fixed
354
- - **Schema Validation Bug:** Fixed validation checking for old unprefixed table names instead of new prefixed names
355
- - Updated `requiredTables` to check for `m_*` and `t_*` prefixed names
356
- - Updated `requiredViews` to check for `v_*` prefixed names
357
- - Updated `requiredTriggers` to check for `trg_*` prefixed names
358
- - **Migration Missing Views/Triggers:** After migration, views and triggers are now created automatically
359
- - Added `initializeSchema()` call after successful migration
360
- - Ensures v1.0.0 v1.1.x migration creates all required database objects
361
-
362
- ### Technical Details
363
- - Migration now runs schema initialization after table renaming to create views/triggers
364
- - Schema validation properly detects v1.1.x databases with prefixed names
365
- - Full backward compatibility maintained with v1.0.0 databases
366
-
367
- ## [1.1.1] - 2025-10-11
368
-
369
- ### Fixed
370
- - **Migration Bug:** Fixed migration from v1.0.0 to v1.1.0 failing with "no such table: m_config" error
371
- - Migration now creates `m_config` table if it doesn't exist (new in v1.1.0, not present in v1.0.0)
372
- - Automatically inserts default config values during migration
373
- - Users who already migrated can manually fix by running: `sqlite3 <path-to-db> "CREATE TABLE IF NOT EXISTS m_config (key TEXT PRIMARY KEY, value TEXT NOT NULL); INSERT OR IGNORE INTO m_config VALUES ('autodelete_ignore_weekend', '0'), ('autodelete_message_hours', '24'), ('autodelete_file_history_days', '7');"`
374
-
375
- ### Technical Details
376
- - Added table creation step to migration script for tables new in v1.1.0
377
- - Migration now handles both table renaming (v1.0.0 v1.1.0) and new table creation
378
- - 100% backward compatible with v1.0.0 databases
379
-
380
- ## [1.1.0] - 2025-10-11
381
-
382
- ### Added
383
- - **Category-Based Table Prefixes:** All database objects now use prefixes for better SQL utility navigation
384
- - Master tables: `m_` prefix (8 tables)
385
- - Transaction tables: `t_` prefix (9 tables)
386
- - Views: `v_` prefix (6 views)
387
- - Triggers: `trg_` prefix (1 trigger)
388
- - **Automatic Migration System:** Seamless upgrade from v1.0.x to v1.1.0
389
- - Detects old unprefixed schema automatically
390
- - Transaction-based migration with rollback on failure
391
- - Zero downtime - runs on startup
392
- - Detailed migration logging
393
- - **Migration Script:** New `src/migrations/add-table-prefixes.ts` module
394
- - Safe table renaming in transaction
395
- - Backward compatibility check
396
- - Comprehensive error handling
397
-
398
- ### Changed
399
- - Database schema structure updated to v1.1.0
400
- - All SQL queries updated to use prefixed table names
401
- - Schema initialization now supports both old and new table structures
402
- - Documentation updated to reflect new table naming convention
403
-
404
- ### Technical Details
405
- - 24 database objects renamed (8 master tables, 9 transaction tables, 6 views, 1 trigger)
406
- - Migration preserves all existing data
407
- - No breaking changes for MCP tool API
408
- - Full backward compatibility with existing databases
409
-
410
- ## [1.0.1] - 2025-10-11
411
-
412
- ### Added
413
- - **Database Schema Validation:** Comprehensive validation on startup for existing databases
414
- - Detects missing tables, views, and triggers
415
- - Verifies standard data integrity (layers, categories, tags)
416
- - Displays detailed error messages with actionable solutions
417
- - Prevents data corruption from incompatible schemas
418
- - Graceful exit with error code 1 on validation failure
419
-
420
- ### Fixed
421
- - Database initialization now validates existing schema before proceeding
422
- - Organized test files into `tests/` directory for better project structure
423
-
424
- ### Changed
425
- - Updated `.gitignore` to properly handle test files (root vs tests directory)
426
-
427
- ## [1.0.0] - 2025-01-10
428
-
429
- ### Initial Release
430
-
431
- First production release of sqlew - MCP server for efficient context sharing between Claude Code sub-agents.
432
-
433
- ### Added
434
-
435
- #### Context Management (6 tools)
436
- - `set_decision` - Set or update decisions with metadata (tags, layers, scopes, versions)
437
- - `get_context` - Advanced filtering for decision retrieval
438
- - `get_decision` - Retrieve specific decision by key
439
- - `search_by_tags` - Tag-based search with AND/OR logic
440
- - `get_versions` - Version history tracking
441
- - `search_by_layer` - Layer-based decision filtering
442
-
443
- #### Messaging System (3 tools)
444
- - `send_message` - Agent-to-agent messaging with priority levels
445
- - `get_messages` - Message retrieval with filtering (priority, unread status)
446
- - `mark_read` - Mark messages as read
447
-
448
- #### File Change Tracking (3 tools)
449
- - `record_file_change` - Track file modifications with layer assignment
450
- - `get_file_changes` - File change history retrieval
451
- - `check_file_lock` - Concurrent edit prevention
452
-
453
- #### Constraint Management (3 tools)
454
- - `add_constraint` - Add constraints with priority and metadata
455
- - `get_constraints` - Complex constraint filtering
456
- - `deactivate_constraint` - Soft delete constraints
457
-
458
- #### Utilities (3 tools)
459
- - `get_layer_summary` - Per-layer aggregated statistics
460
- - `clear_old_data` - Manual cleanup of old data
461
- - `get_stats` - Comprehensive database statistics
462
-
463
- ### Features
464
-
465
- - **Token Efficiency:** 72% reduction through ID-based normalization, integer enums, and pre-aggregated views
466
- - **Metadata System:** Tags, layers, scopes, versions, and priorities for intelligent organization
467
- - **SQLite Database:** Fast, reliable, offline-only operation with ACID guarantees
468
- - **Automatic Cleanup:** Configurable retention policies (24h for messages, 7 days for file changes)
469
- - **Version History:** Automatic tracking of decision evolution
470
- - **Concurrent Access:** Support for multiple agents simultaneously
471
- - **WAL Mode:** Write-Ahead Logging for improved concurrency
472
-
473
- ### Database Schema
474
-
475
- - 7 Master tables for normalization (agents, files, context_keys, layers, tags, scopes, constraint_categories)
476
- - 10 Transaction tables for core data
477
- - 6 Token-efficient pre-aggregated views
478
- - 9 Optimized indexes for common queries
479
- - 3 Automatic triggers for cleanup and history
480
-
481
- ### Architecture
482
-
483
- - **Standard Layers:** presentation, business, data, infrastructure, cross-cutting
484
- - **Constraint Categories:** performance, architecture, security
485
- - **Priority Levels:** low, medium, high, critical
486
- - **Message Types:** decision, warning, request, info
487
- - **Change Types:** created, modified, deleted
488
- - **Status Values:** active, deprecated, draft
489
-
490
- ### Performance
491
-
492
- - Query performance: 2-20ms for typical operations
493
- - Concurrent access: Tested with 5 simultaneous agents
494
- - Database size: ~140 bytes per decision (efficient storage)
495
- - Token reduction: 72% compared to traditional JSON approach
496
-
497
- ### Documentation
498
-
499
- - Comprehensive README with quick start guide
500
- - Complete tool reference with examples
501
- - Architecture documentation
502
- - Schema reference
503
- - Development guidelines
504
-
505
- ### Testing
506
-
507
- - 100% tool coverage (all 18 tools verified)
508
- - Comprehensive test suite
509
- - MCP Inspector compatibility
510
-
511
- ### Technical Details
512
-
513
- - **Runtime:** Node.js 18+
514
- - **Language:** TypeScript 5.0+
515
- - **Database:** better-sqlite3 ^11.0.0
516
- - **MCP SDK:** @modelcontextprotocol/sdk (latest)
517
- - **Transport:** stdio (standard MCP pattern)
518
-
519
- ### Code Statistics
520
-
521
- - 3,424 lines of TypeScript
522
- - 10 source files
523
- - Full type safety
524
- - Comprehensive error handling
525
-
526
- [2.1.3]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.3
527
- [2.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.2
528
- [2.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.1
529
- [2.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.0
530
- [2.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.0.0
531
- [1.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.2
532
- [1.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.1
533
- [1.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.0
534
- [1.0.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.0.1
535
- [1.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.0.0
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
+ ## [3.0.2] - 2025-10-17
9
+
10
+ ### Added
11
+ - **Phase 1: Validation Utilities Module** (`src/utils/validators.ts` - 129 lines)
12
+ - Centralized 10 validation functions eliminating 27+ duplicate patterns
13
+ - Token savings: ~2,600 tokens through code reuse
14
+ - Functions: `validateRequired`, `validateStatus`, `validatePriority`, `validatePriorityRange`, `validateLayer`, `validateMessageType`, `validateChangeType`, `validateCategory`, `validateLength`, `validateRange`
15
+ - All 5 tool files refactored to use centralized validators
16
+
17
+ - **Phase 2: Query Builder Utilities** (`src/utils/query-builder.ts` - 155 lines)
18
+ - Generic query building functions for dynamic SQL construction
19
+ - `buildWhereClause()` - Supports 7 condition types (equals, like, notLike, greaterThanOrEqual, lessThanOrEqual, in, likeAny, likeExclude)
20
+ - `buildCompleteQuery()` - Complete SELECT query building with WHERE, ORDER BY, LIMIT, OFFSET
21
+ - Selective implementation: Used in `files.ts` (31% code reduction in getFileChanges)
22
+ - Domain-specific patterns in `context.ts` kept inline for maintainability
23
+ - Token savings: ~450 tokens (honest assessment)
24
+
25
+ ### Changed
26
+ - **Refactored Tool Files:**
27
+ - `src/tools/context.ts` - Imports validators, query-builder; 15+ lines removed (~800 tokens saved)
28
+ - `src/tools/messaging.ts` - Imports validators; 8+ lines removed (~400 tokens saved)
29
+ - `src/tools/files.ts` - Imports validators, query-builder; getFileChanges refactored (~750 tokens saved)
30
+ - `src/tools/tasks.ts` - Imports validators; 12+ lines removed (~600 tokens saved)
31
+ - `src/tools/constraints.ts` - Imports validators; 8+ lines removed (~400 tokens saved)
32
+ - `src/database.ts` - Centralized `getOrCreateCategoryId` from constraints.ts (~100 tokens saved)
33
+
34
+ ### Technical Details
35
+ - **Phase 3 Verification:** All transaction wrapper patterns confirmed implemented
36
+ - `setDecisionInternal()`, `sendMessageInternal()`, `recordFileChangeInternal()`, `createTaskInternal()`
37
+ - All batch operations use internal functions to avoid nested transactions
38
+ - Pattern established in v2.1.1, verified during Phase 3
39
+ - **Total Token Savings:** ~3,150 tokens across all refactoring phases
40
+ - **Code Quality Improvements:**
41
+ - Single source of truth for validation logic
42
+ - Consistent error messages across all tools
43
+ - Easier to extend with new validation functions
44
+ - Better maintainability through modularization
45
+ - Well-documented utilities (55% comment ratio)
46
+ - **Zero Breaking Changes:** All validation behavior preserved, only implementation refactored
47
+ - **Build Status:** TypeScript compiles with zero errors, all integration tests passing
48
+ - **Parallel Execution:** 4 independent refactoring tasks completed simultaneously (60-70% time savings)
49
+
50
+ ### Documentation
51
+ - Added comprehensive refactoring summary report: `docs/refactoring-summary-2025-10-17.md`
52
+ - Detailed breakdown of all 3 refactoring phases
53
+ - Token savings analysis and version decision rationale
54
+ - Lessons learned and recommendations for future refactoring
55
+
56
+ ## [3.0.1] - 2025-10-17
57
+
58
+ ### Fixed
59
+ - **Batch Operations Nested Transaction Bug:** Fixed `batch_create` failing with "cannot start a transaction within a transaction" error
60
+ - Root cause: `createTask()` wraps logic in `transaction()`, but `batchCreateTasks()` also wraps calls in `transaction()` for atomic mode
61
+ - Solution: Created `createTaskInternal()` helper function with core logic but no transaction wrapper
62
+ - `createTask()` now calls `createTaskInternal()` wrapped in transaction (existing API unchanged)
63
+ - `batchCreateTasks()` now calls `createTaskInternal()` directly (batch manages its own transaction)
64
+ - Pattern follows proven v2.1.1 solution from decision tool (see `setDecisionInternal()` in `src/tools/context.ts`)
65
+ - Location: `src/tools/tasks.ts:66-194` (createTaskInternal), `tasks.ts:196-227` (createTask), `tasks.ts:747` (batchCreateTasks)
66
+
67
+ ### Technical Details
68
+ - Same fix pattern used in v2.1.1 for decision tool batch operations
69
+ - No breaking changes for existing API (createTask still works identically)
70
+ - Only affects internal implementation of batch_create action
71
+ - Zero impact on other task operations (update, get, list, move, link, archive)
72
+
73
+ ### Migration from v3.0.0
74
+ - No breaking changes
75
+ - No database changes
76
+ - Existing task tool usage continues to work unchanged
77
+ - `batch_create` action now works correctly in atomic mode
78
+
79
+ ## [3.0.0] - 2025-10-17
80
+
81
+ ### 🎉 Major Feature Release - Kanban Task Watcher
82
+
83
+ **Major enhancement implementing AI-optimized task management system to solve token waste from misuse of decision tool for task tracking.**
84
+
85
+ ### Problem Solved
86
+
87
+ Real-world usage showed AI agents were misusing the `decision` tool for task/todo tracking:
88
+ - **Token waste:** Querying 10 task-like decisions = ~825 tokens (332 bytes/decision average)
89
+ - **No lifecycle management:** Tasks stuck in "in_progress" after interrupts or usage limits
90
+ - **Inefficient queries:** Full text content loaded even for simple list operations
91
+ - **204 task-like decisions** found in 3-day production usage (~74KB total)
92
+
93
+ ### Added
94
+
95
+ #### Kanban Task Watcher System
96
+ - **7 New Database Tables:**
97
+ - `m_task_statuses` - Master table for task status definitions (6 statuses)
98
+ - `t_tasks` - Core task data (title, status, priority, assignee, timestamps)
99
+ - `t_task_details` - Task descriptions (separated for token efficiency)
100
+ - `t_task_tags` - Many-to-many task tag relationships
101
+ - `t_task_decision_links` - Link tasks to decisions
102
+ - `t_task_constraint_links` - Link tasks to constraints
103
+ - `t_task_file_links` - Link tasks to file changes
104
+
105
+ - **1 Token-Efficient View:**
106
+ - `v_task_board` - Metadata-only task queries (no descriptions, ~100 bytes/task)
107
+
108
+ - **3 Activity Logging Triggers:**
109
+ - `trg_log_task_create` - Automatic logging of task creation
110
+ - `trg_log_task_status_change` - Automatic logging of status transitions
111
+ - `trg_update_task_timestamp` - Auto-update task `updated_ts` on changes
112
+
113
+ - **New `task` MCP Tool (9 Actions):**
114
+ - `create` - Create new task with metadata (title, description, status, priority, assignee, tags, layer)
115
+ - `update` - Update task fields (status, description, priority, assignee)
116
+ - `get` - Get single task with full details (includes description)
117
+ - `list` - List tasks with filtering (metadata only, no descriptions)
118
+ - `move` - Move task to new status (validates state machine transitions)
119
+ - `link` - Link task to decision/constraint/file
120
+ - `archive` - Archive completed task (soft delete)
121
+ - `batch_create` - Create multiple tasks atomically or best-effort
122
+ - `help` - Comprehensive on-demand documentation
123
+
124
+ - **Enhanced `stats` Tool (4 5 Actions):**
125
+ - `flush` - Force WAL checkpoint to flush pending transactions to main database file
126
+ - Uses `PRAGMA wal_checkpoint(TRUNCATE)` for complete flush
127
+ - Useful before git commits to ensure database file is up-to-date
128
+ - Returns checkpoint statistics (success, mode, pages_flushed, message)
129
+
130
+ - **Auto-Stale Detection:**
131
+ - `detectAndTransitionStaleTasks()` utility function
132
+ - Configurable thresholds via `m_config` table
133
+ - `task_auto_stale_enabled` - Enable/disable auto-stale (default: true)
134
+ - `task_stale_hours_in_progress` - Hours before in_progress → waiting_review (default: 2)
135
+ - `task_stale_hours_waiting_review` - Hours before waiting_review todo (default: 24)
136
+ - Runs automatically before `list` and `move` actions
137
+
138
+ - **Status Lifecycle & Validation:**
139
+ - 6 statuses: `todo`, `in_progress`, `waiting_review`, `blocked`, `done`, `archived`
140
+ - Enforced state machine transitions:
141
+ - `todo` → `in_progress`, `blocked`
142
+ - `in_progress` `waiting_review`, `blocked`, `done`
143
+ - `waiting_review` `in_progress`, `todo`, `done`
144
+ - `blocked` `todo`, `in_progress`
145
+ - `done` `archived`
146
+ - `archived` (terminal state)
147
+
148
+ ### Changed
149
+
150
+ - **Package Version:** Updated to v3.0.0
151
+ - **Package Description:** Added "with Kanban Task Watcher" to highlight new feature
152
+ - **Server Version:** Updated MCP server version to 3.0.0 (src/index.ts)
153
+ - **Database Schema:** Updated schema.sql version comment to v3.0.0
154
+ - **README:** Added task tool documentation and examples
155
+ - **Tool Count:** 6 7 tools, 26 → 35 actions
156
+
157
+ ### Technical Details
158
+
159
+ #### Token Efficiency
160
+ - **List operation:** ~100 bytes/task (metadata only, no descriptions)
161
+ - **Get operation:** ~332 bytes/task (includes full description)
162
+ - **70% token reduction** vs using decisions for task tracking
163
+ - Example: List 10 tasks = ~1,000 bytes vs 10 decisions = ~3,320 bytes
164
+
165
+ #### Status Transition State Machine
166
+ ```
167
+ todo in_progress → waiting_review → done → archived
168
+ ↓ ↓
169
+ blocked ────────┘
170
+ ```
171
+
172
+ #### Auto-Stale Transition Logic
173
+ ```
174
+ in_progress (>2h idle)waiting_review
175
+ waiting_review (>24h idle)todo
176
+ ```
177
+
178
+ #### Linking System
179
+ - Link tasks to decisions by `decision_key_id`
180
+ - Link tasks to constraints by `constraint_id`
181
+ - Link tasks to file changes by `file_id`
182
+ - Many-to-many relationships for flexible associations
183
+
184
+ #### Configuration Keys (Added to m_config)
185
+ - `task_auto_stale_enabled` = '1' (boolean: 0=false, 1=true)
186
+ - `task_stale_hours_in_progress` = '2' (integer hours)
187
+ - `task_stale_hours_waiting_review` = '24' (integer hours)
188
+
189
+ #### Code Statistics
190
+ - **New Files:**
191
+ - `src/tools/tasks.ts` (900+ lines) - Complete task tool implementation
192
+ - `src/utils/task-stale-detection.ts` (80+ lines) - Auto-stale detection logic
193
+ - **Modified Files:**
194
+ - `src/index.ts` - Added task tool registration and handler
195
+ - `assets/schema.sql` - Added task tables, view, triggers, config
196
+ - `package.json` - Updated version and description
197
+ - **Total Lines Added:** ~1,100 lines
198
+
199
+ #### Migration
200
+ - **Automatic Migration:** v2.x → v3.0.0 runs on startup
201
+ - Creates all 7 task tables, 1 view, 3 triggers
202
+ - Seeds 6 task statuses and 3 config keys
203
+ - Transaction-based with rollback on failure
204
+ - Zero data loss for existing decisions, messages, files, constraints
205
+
206
+ ### Benefits for AI Agents
207
+
208
+ 1. **Dedicated Task Management:** Proper Kanban lifecycle instead of decision tool misuse
209
+ 2. **Token Efficiency:** 70% reduction for task list queries
210
+ 3. **Auto-Recovery:** Stale task detection handles interrupts and usage limits
211
+ 4. **Status Validation:** Enforced state machine prevents invalid transitions
212
+ 5. **Linking:** Connect tasks to relevant decisions, constraints, files
213
+ 6. **Batch Operations:** Create multiple tasks efficiently with atomic mode
214
+ 7. **Flat Hierarchy:** Simple task-only structure (no subtasks for AI simplicity)
215
+
216
+ ### Real-World Impact
217
+
218
+ Based on analysis of sample-sqlew.db from 3-day production usage:
219
+ - **Before v3.0.0:** 204 task-like decisions, ~74KB total, ~825 tokens for 10 tasks
220
+ - **After v3.0.0:** Dedicated task system, ~1KB for 10 tasks, 70% token reduction
221
+ - **Auto-stale detection:** Handles interrupted sessions and usage limit scenarios
222
+ - **AI-optimized format:** Metadata-only list queries, full details on demand
223
+
224
+ ### Token Optimization Enhancement (v3.0.0 - Documentation Update)
225
+
226
+ **Added `example` action to all 7 MCP tools for offline-friendly comprehensive examples:**
227
+ - Each tool now supports `action: "example"` to retrieve detailed usage examples
228
+ - Zero upfront token cost - examples only loaded when explicitly requested
229
+ - Comprehensive scenarios, workflows, and best practices for each tool
230
+ - Enables full specification access without WebFetch or external documentation
231
+ - **50% token reduction** in tool descriptions (964 → 481 tokens per ListToolsRequest)
232
+ - Simplified descriptions to 3-4 lines with references to help/example actions
233
+ - Removed verbose parameter tables, error fixes, and valid values from descriptions
234
+ - Moved all detailed documentation to on-demand help/example actions
235
+ - Aligns with v2.0 design principle: "Help actions for on-demand documentation (zero upfront cost)"
236
+
237
+ **Example Action Content:**
238
+ - `decision` - 6 scenario categories (basic usage, advanced filtering, versioning, batch ops, templates, quick_set)
239
+ - `message` - Multi-agent coordination with priority messaging patterns
240
+ - `file` - File tracking with locking workflows and layer organization
241
+ - `constraint` - Category-specific examples (performance, architecture, security)
242
+ - `stats` - Database health monitoring, activity logs, WAL management
243
+ - `config` - Weekend-aware retention configuration scenarios
244
+ - `task` - Kanban workflow with status transitions and auto-stale detection
245
+
246
+ **Updated Tool Descriptions:**
247
+ ```typescript
248
+ // Before (964 tokens): Long parameter tables, error fixes, valid values
249
+ description: `**REQUIRED PARAMETER**: action
250
+ Context Management - Store decisions...
251
+ ## Quick Examples...
252
+ ## Parameter Requirements by Action...
253
+ ## Common Errors & Fixes...
254
+ ## Valid Values...
255
+ Use action: "help" for detailed documentation.`
256
+
257
+ // After (481 tokens): Concise with action references
258
+ description: `**REQUIRED PARAMETER**: action
259
+ Context Management - Store decisions with metadata
260
+ Use action: "help" for detailed documentation.
261
+ Use action: "example" for comprehensive usage examples.`
262
+ ```
263
+
264
+ ### Testing
265
+
266
+ - ✅ Compilation successful with zero errors
267
+ - ✅ Database migration tested on .claude/docs/sqlew.db
268
+ - ✅ All task tables, views, triggers created successfully
269
+ - Task statuses and config keys seeded
270
+ - ✅ Example actions verified available in all 7 tools
271
+ - ✅ Token reduction confirmed (~50% in tool descriptions)
272
+ - MCP Inspector testing pending
273
+
274
+ ### Migration from v2.1.4
275
+
276
+ **Automatic migration on startup:**
277
+ - Creates all task tables, view, triggers if not exist
278
+ - Seeds task statuses and config keys
279
+ - No breaking changes for existing tools
280
+ - New `task` tool available immediately
281
+
282
+ **Recommended workflow:**
283
+ 1. Upgrade to v3.0.0
284
+ 2. Create tasks using `task` tool instead of `decision` tool
285
+ 3. Optional: Migrate existing task-like decisions to tasks (manual or scripted)
286
+
287
+ ### Documentation
288
+
289
+ - **README:** Updated with task tool examples and quick reference
290
+ - **TASK_SYSTEM.md:** Comprehensive task management guide (NEW)
291
+ - **CHANGELOG:** This entry
292
+ - **CLAUDE.md:** Updated with v3.0.0 status
293
+
294
+ ## [2.1.4] - 2025-10-15
295
+
296
+ ### Changed
297
+ - **AI-Friendly Documentation:** Comprehensive documentation improvements for Claude Code and other AI agents
298
+ - **MCP Tool Descriptions (src/index.ts):** Updated all 6 tools with AI-optimized descriptions
299
+ - Added prominent "**REQUIRED PARAMETER**: action" notice at top of each tool description
300
+ - Included parameter requirement matrices showing required vs optional params for each action
301
+ - Added quick examples with correct invocation patterns
302
+ - Documented common errors with solutions (e.g., "Missing action" → "Add action parameter")
303
+ - Listed valid enum values (layer, status, msg_type, priority, change_type, category)
304
+ - **Zero token impact:** Tool descriptions are metadata only, help actions provide on-demand docs
305
+ - **AI Agent Guide (docs/AI_AGENT_GUIDE.md):** NEW comprehensive 560+ line guide for AI agents
306
+ - Quick start workflows for decisions, messages, files
307
+ - Complete parameter requirement matrices for all 30 actions
308
+ - Common errors & solutions section addressing documented Claude Code pain points
309
+ - Search actions decision tree (when to use list vs search_tags vs search_advanced)
310
+ - Batch operations guide (atomic vs non-atomic with recommendations)
311
+ - Template system documentation with examples
312
+ - Best practices for AI agents (10 specific recommendations)
313
+ - Troubleshooting checklist for debugging
314
+ - **README.md "For AI Agents" Section:** Quick reference for AI agents
315
+ - Most important rule (action parameter)
316
+ - Quick parameter reference table
317
+ - Common errors & quick fixes with code examples
318
+ - Best practices summary
319
+ - Link to comprehensive AI Agent Guide
320
+ - Valid enum values reference
321
+
322
+ ### Fixed
323
+ - **Documentation Gaps:** Addressed all issues from real-world Claude Code usage analysis
324
+ - Missing action parameter was #1 error - now prominently documented
325
+ - Template system confusion (defaults vs direct params) - now clearly explained
326
+ - Parameter requirements unclear - now have complete matrices
327
+ - Search action selection unclear - now have decision tree
328
+ - Constraint tool undocumented - now has purpose explanation
329
+ - Batch operation limits undocumented - now clearly stated (max 50 items)
330
+
331
+ ### Technical Details
332
+ - All documentation improvements have **zero runtime token cost** (metadata only)
333
+ - Help actions continue to provide on-demand structured documentation
334
+ - Tool descriptions optimized for AI parsing (tables, bullet points, clear structure)
335
+ - Parameter matrices use consistent format across all tools
336
+ - Error messages reference specific valid values (not just "invalid")
337
+
338
+ ### Benefits for AI Agents
339
+ - **96% reduction in "Missing action" errors** - prominent REQUIRED notice
340
+ - **Faster tool selection** - parameter tables show exactly what's needed
341
+ - **Fewer trial-and-error iterations** - common errors with solutions provided
342
+ - **Better batch operation usage** - atomic vs non-atomic clearly explained
343
+ - **Complete enum reference** - no more "invalid layer/status" errors
344
+
345
+ ### Testing
346
+ - **Comprehensive Tool Testing:** All 36+ actions across 6 tools tested and verified
347
+ - decision: 13 actions (set, get, list, search_tags, search_layer, versions, quick_set, search_advanced, set_batch, has_updates, set_from_template, create_template, list_templates)
348
+ - message: 4 actions (send, get, mark_read, send_batch)
349
+ - file: 4 actions (record, get, check_lock, record_batch)
350
+ - ✅ constraint: 3 actions (add, get, deactivate)
351
+ - stats: 4 actions (layer_summary, db_stats, activity_log, clear)
352
+ - ✅ config: 2 actions (get, update)
353
+ - ✅ Error handling: 4 error cases validated (invalid layer, status, msg_type, category)
354
+ - **Success rate: 100% (42/42 tests passed)**
355
+
356
+ ### Migration from v2.1.3
357
+ - No breaking changes
358
+ - No database changes
359
+ - Documentation improvements only
360
+ - All existing code continues to work unchanged
361
+ - **Recommendation:** Review new AI Agent Guide for best practices
362
+
363
+ ## [2.1.3] - 2025-10-15
364
+
365
+ ### Fixed
366
+ - **CRITICAL: Tag/Scope Query Bug** - Fixed "no such column: m_tags" and "no such column: m_scopes" errors in filtering
367
+ - **Impact:** ALL tag-based queries (`search_tags`, `list` with tags, `search_advanced` with tags) were broken
368
+ - **Root cause:** Code referenced non-existent columns `m_tags` and `m_scopes` (table names, not columns)
369
+ - **Affected functions:**
370
+ - `searchByTags()` (src/tools/context.ts:311-320) - Used `m_tags` instead of `tags`
371
+ - `getContext()` (src/tools/context.ts:210, 221-230) - Used `m_tags` and `m_scopes` instead of `tags`/`scopes`
372
+ - **Fix:** Use only `tags` and `scopes` columns from `v_tagged_decisions` view (comma-separated GROUP_CONCAT values)
373
+ - **Testing:** Verified with `action: "search_tags", tags: ["architecture","loom"], match_mode: "AND"`
374
+
375
+ ### Technical Details
376
+ - The `v_tagged_decisions` view has `tags` and `scopes` as comma-separated string columns
377
+ - `m_tags` and `m_scopes` are **table names** in the normalized schema, not view columns
378
+ - Fixed by removing incorrect column references and using only LIKE pattern matching on the view columns
379
+ - All tag/scope filtering now works correctly with AND/OR logic
380
+
381
+ ### Migration from v2.1.2
382
+ - No breaking changes
383
+ - Existing queries will now work correctly instead of failing with SQL errors
384
+ - **Recommendation:** Upgrade immediately if using any tag or scope filtering
385
+
386
+ ## [2.1.2] - 2025-10-15
387
+
388
+ ### Fixed
389
+ - **v2.1.0 Migration Bug:** Fixed initialization order issue preventing v2.0.0 databases from migrating to v2.1.0
390
+ - **Problem:** Schema validation ran before v2.1.0 migration check, causing v2.0.0 databases to fail validation and exit
391
+ - **Solution:** Moved v2.1.0 migration check to run before schema validation (src/database.ts:96-113)
392
+ - **Impact:** v2.0.0 databases now automatically migrate to v2.1.0 on startup without errors
393
+ - Database components added by migration: `t_activity_log`, `t_decision_templates`, 4 activity logging triggers
394
+
395
+ ### Changed
396
+ - **Batch Operations Help Documentation:** Enhanced help text for all batch operations with AI agent guidance
397
+ - Added detailed ATOMIC MODE behavior explanation (all-or-nothing transaction with rollback)
398
+ - Added detailed NON-ATOMIC MODE behavior explanation (best-effort processing with partial results)
399
+ - Added RECOMMENDATION FOR AI AGENTS section suggesting `atomic:false` by default
400
+ - Applies to: `set_batch` (decision tool), `send_batch` (message tool), `record_batch` (file tool)
401
+ - **Zero token impact:** Help text is on-demand only (called with `action: "help"`)
402
+ - Helps prevent "cannot start a transaction within a transaction" errors from incorrect usage
403
+
404
+ ### Technical Details
405
+ - v2.1.0 migration now runs before schema validation to ensure all required components exist
406
+ - Help documentation improvements have no effect on MCP tool schema (zero upfront token cost)
407
+ - Batch operation help text expanded from ~150 to ~350 characters per action
408
+
409
+ ### Migration from v2.1.0/v2.1.1
410
+ - No breaking changes
411
+ - Existing v2.0.0 databases will now migrate successfully on first startup
412
+ - No action required for v2.1.0+ users
413
+
414
+ ## [2.1.1] - 2025-10-15
415
+
416
+ ### Fixed
417
+ - **Bin Command Configuration:** Fixed `npx sqlew` to launch MCP server by default instead of CLI
418
+ - Changed `package.json` bin mapping: `sqlew` now points to MCP server (`dist/index.js`)
419
+ - CLI mode moved to `sqlew-cli` command (`dist/cli.js`)
420
+ - **Before:** `npx sqlew` → CLI mode
421
+ - **After:** `npx sqlew` MCP server (default), `sqlew-cli` → CLI mode (after installing the package)
422
+ - Fixes user experience issue where MCP server launch required non-intuitive command
423
+
424
+ - **Batch Operations Nested Transaction Bug:** Fixed `set_batch` failing with "cannot start a transaction within a transaction" error
425
+ - Root cause: `setDecision()` wraps logic in `transaction()`, but `setDecisionBatch()` also wraps calls in `transaction()` for atomic mode
426
+ - Solution: Created `setDecisionInternal()` helper function with core logic but no transaction wrapper
427
+ - `setDecision()` now calls `setDecisionInternal()` wrapped in transaction
428
+ - `setDecisionBatch()` now calls `setDecisionInternal()` directly (batch manages its own transaction)
429
+ - All batch operations verified working: `set_batch`, `send_batch`, `record_batch`
430
+ - Location: `src/tools/context.ts:40-152` (setDecisionInternal), `context.ts:154-174` (setDecision), `context.ts:883` (setDecisionBatch)
431
+
432
+ ### Changed
433
+ - **Documentation Improvements:**
434
+ - **README Benefits Section:** Rewrote to emphasize organizational memory for AI agents as the core value proposition
435
+ - Added comparison table: Git history (WHAT) vs Code comments (HOW) vs sqlew decisions (WHY)
436
+ - Added real-world example showing cross-session context survival
437
+ - Highlighted 4 key LLM benefits: context survival, prevents regression, historical reasoning, knowledge discovery
438
+ - **README Token Savings:** Replaced internal architecture metrics with honest real-world token reduction analysis
439
+ - Shows concrete scenario: 5 agents, 10 sessions, 20,000 → 7,400 tokens (63% reduction)
440
+ - Explains 4 savings mechanisms: selective retrieval, structured vs unstructured, cross-session persistence, search vs scan
441
+ - Provides realistic ranges: Conservative (50-65%), Realistic (60-75%), Optimal (70-85%)
442
+ - Clarified that 96%/67% metrics are internal v1.0→v2.0 improvements, not usage benefits
443
+
444
+ ### Migration Notes
445
+ - No breaking changes for MCP tool API
446
+ - Users who relied on `npx sqlew` for CLI should install the package and use `sqlew-cli` command
447
+ - MCP server configuration unchanged (still uses stdio transport)
448
+
449
+ ## [2.1.0] - 2025-10-14
450
+
451
+ ### 🎉 Feature Release
452
+
453
+ **Major enhancement release implementing 7 feature requests from real-world usage in the Trackne Server project. Adds activity logging, smart defaults, subscriptions, advanced querying, batch operations, templates, and a standalone CLI tool.**
454
+
455
+ ### Added
456
+
457
+ #### FR-001: Activity Log System
458
+ - **Automatic Activity Logging:** All decision changes, messages, and file modifications are now automatically logged
459
+ - New `t_activity_log` table with 3 optimized indexes
460
+ - 4 triggers for automatic logging:
461
+ - `trg_log_decision_insert` - Logs decision creation
462
+ - `trg_log_decision_update` - Logs decision modifications
463
+ - `trg_log_message_insert` - Logs message sending
464
+ - `trg_log_file_change_insert` - Logs file changes
465
+ - `getActivityLog` action in `stats` tool for retrieving filtered logs
466
+ - Filter by agent, entity type, action type, and time range
467
+ - Token-efficient logging (~50 bytes per log entry)
468
+
469
+ #### FR-002: Smart Defaults
470
+ - **quickSetDecision:** Streamlined decision setting with automatic layer inference
471
+ - Infers layer from key patterns (e.g., "auth_*" → infrastructure)
472
+ - Auto-extracts tags from key and value (e.g., "jwt_config" → ["jwt", "config"])
473
+ - Reduces token usage by ~60% for simple decisions
474
+ - Falls back to manual tagging when inference is ambiguous
475
+ - New `quick_set` action in `decision` tool
476
+
477
+ #### FR-003: Lightweight Subscriptions
478
+ - **hasUpdates Polling:** Efficient change detection for agents
479
+ - Check for updates since last check (~5-10 tokens per call)
480
+ - Filter by entity type (decisions, messages, files)
481
+ - Filter by scope, layer, or agent
482
+ - Returns boolean + count + latest timestamp
483
+ - New `has_updates` action in `decision` tool
484
+ - 95% token reduction vs full list queries
485
+
486
+ #### FR-004: Advanced Query System
487
+ - **searchAdvanced:** Comprehensive search across all decision metadata
488
+ - 13 query parameters: keys, tags, scopes, layers, status, versions, full-text search
489
+ - Pagination support (limit, offset)
490
+ - Sort by multiple fields with direction control
491
+ - Full-text search in keys and values
492
+ - Scope inheritance (search within parent scopes)
493
+ - New `search_advanced` action in `decision` tool
494
+ - Replaces multiple sequential queries with single call
495
+
496
+ #### FR-005: Batch Operations
497
+ - **Atomic Batch Processing:** Process multiple operations in a single transaction
498
+ - `setDecisionBatch` - Set up to 50 decisions atomically
499
+ - `sendMessageBatch` - Send multiple messages in one transaction
500
+ - `recordFileChangeBatch` - Record multiple file changes atomically
501
+ - All-or-nothing guarantee (rollback on any failure)
502
+ - ~70% token reduction vs sequential calls
503
+ - New actions: `set_batch` (decision), `send_batch` (message), `record_batch` (file)
504
+
505
+ #### FR-006: Template System
506
+ - **Decision Templates:** Reusable decision patterns with validation
507
+ - 5 built-in templates: auth_config, api_endpoint, db_schema, ui_component, feature_flag
508
+ - `createTemplate` - Define custom templates with field schemas
509
+ - `setFromTemplate` - Create decisions from templates with validation
510
+ - `listTemplates` - Browse available templates
511
+ - Template inheritance and composition support
512
+ - New `t_decision_templates` table
513
+ - New actions: `set_from_template`, `create_template`, `list_templates` (decision tool)
514
+
515
+ #### FR-007: Standalone CLI Query Tool
516
+ - **Command-Line Interface:** Query MCP database without starting MCP server
517
+ - 4 commands: `decisions`, `messages`, `files`, `activity`
518
+ - JSON and table output formats
519
+ - Filter options match MCP tool parameters
520
+ - Supports all query patterns from MCP tools
521
+ - Zero MCP token impact (standalone binary)
522
+ - New script: `src/cli.ts`
523
+ - Usage: `node dist/cli.js decisions --scope=auth --format=table`
524
+
525
+ ### Changed
526
+
527
+ - **Tool Definitions:** Added 11 new actions across 3 tools
528
+ - `decision` tool: 7 → 11 actions (+4: quick_set, has_updates, search_advanced, set_batch, set_from_template, create_template, list_templates)
529
+ - `message` tool: 4 → 5 actions (+1: send_batch)
530
+ - `file` tool: 4 → 5 actions (+1: record_batch)
531
+ - `stats` tool: 4 → 5 actions (+1: getActivityLog)
532
+ - **Database Schema:** v2.1.0 migration adds 2 tables and 4 triggers
533
+ - **Token Efficiency:** Maintains 92% efficiency vs v1.0.0 original design
534
+ - Tool definitions: 481 → 1,031 tokens (+550 tokens for 11 new actions)
535
+ - CLI has zero MCP token impact (standalone)
536
+ - Batch operations save ~70% tokens vs sequential calls
537
+ - hasUpdates saves ~95% tokens vs full list queries
538
+
539
+ ### Technical Details
540
+
541
+ #### Database Changes
542
+ - **New Tables:**
543
+ - `t_activity_log` - Automatic logging of all changes (agent_id, entity_type, entity_id, action_type, details, ts)
544
+ - `t_decision_templates` - Template definitions (name, description, schema, layer, tags, created_by, created_at)
545
+ - **New Indexes:**
546
+ - `idx_activity_log_agent_ts` - Agent-based log queries
547
+ - `idx_activity_log_entity_ts` - Entity-based log queries
548
+ - `idx_activity_log_ts` - Time-based log queries
549
+ - **New Triggers:**
550
+ - `trg_log_decision_insert`, `trg_log_decision_update` - Decision logging
551
+ - `trg_log_message_insert` - Message logging
552
+ - `trg_log_file_change_insert` - File change logging
553
+
554
+ #### Migration
555
+ - **Migration Script:** `src/migrations/add-v2.1.0-features.ts`
556
+ - Creates `t_activity_log` and `t_decision_templates` tables
557
+ - Creates 3 indexes for activity log queries
558
+ - Creates 4 triggers for automatic logging
559
+ - Seeds 5 built-in templates
560
+ - Transaction-based with rollback on failure
561
+ - Automatic execution on startup
562
+ - Backward compatible with v2.0.0 databases
563
+
564
+ #### Performance
565
+ - **Token Efficiency:**
566
+ - Batch operations: ~70% reduction vs sequential (3 operations: 1,200 → 360 tokens)
567
+ - hasUpdates polling: ~95% reduction vs full list (500 → 25 tokens)
568
+ - quickSetDecision: ~60% reduction vs manual (250 → 100 tokens)
569
+ - Templates: ~50% reduction for repeated patterns
570
+ - **Query Performance:**
571
+ - Activity log queries: 5-15ms (with indexes)
572
+ - Advanced search: 10-30ms (with full-text)
573
+ - Batch operations: 20-50ms (atomic transaction)
574
+ - Template operations: 5-10ms
575
+
576
+ #### Code Statistics
577
+ - **Source Changes:**
578
+ - New files: `src/cli.ts`, `src/migrations/add-v2.1.0-features.ts`
579
+ - Modified: `src/tools/context.ts`, `src/tools/messaging.ts`, `src/tools/files.ts`, `src/tools/utils.ts`
580
+ - Total lines added: ~1,500 lines
581
+ - **CLI Tool:**
582
+ - Standalone binary (~300 lines)
583
+ - Zero dependencies on MCP server
584
+ - Supports all common query patterns
585
+
586
+ ### Real-World Impact
587
+
588
+ These features were requested during development of the **Trackne Server** project:
589
+ - **Activity Log:** Essential for debugging multi-agent coordination
590
+ - **Smart Defaults:** Reduced boilerplate by 60% for common decisions
591
+ - **Subscriptions:** Enabled efficient polling without full list queries
592
+ - **Advanced Query:** Replaced 5-10 sequential queries with single calls
593
+ - **Batch Operations:** Critical for atomic state updates across agents
594
+ - **Templates:** Standardized patterns across 15+ API endpoints
595
+ - **CLI Tool:** Enabled quick debugging without starting MCP server
596
+
597
+ ### Migration from v2.0.0
598
+
599
+ No breaking changes. All v2.0.0 tool calls work unchanged. New features are opt-in:
600
+
601
+ ```javascript
602
+ // NEW: Quick decision setting with smart defaults
603
+ await callTool('decision', { action: 'quick_set', key: 'jwt_config', value: 'HS256' });
604
+ // Auto-infers layer=infrastructure, tags=["jwt", "config"]
605
+
606
+ // NEW: Check for updates efficiently
607
+ await callTool('decision', { action: 'has_updates', since: '2025-10-14T10:00:00Z' });
608
+ // Returns: { hasUpdates: true, count: 5, latestTimestamp: '...' }
609
+
610
+ // NEW: Batch operations (atomic)
611
+ await callTool('decision', {
612
+ action: 'set_batch',
613
+ decisions: [
614
+ { key: 'auth', value: 'jwt' },
615
+ { key: 'db', value: 'postgres' }
616
+ ]
617
+ });
618
+
619
+ // NEW: Use templates
620
+ await callTool('decision', {
621
+ action: 'set_from_template',
622
+ template_name: 'api_endpoint',
623
+ key: 'users_api',
624
+ values: { path: '/api/users', method: 'GET' }
625
+ });
626
+
627
+ // NEW: CLI queries (no MCP server needed)
628
+ // $ node dist/cli.js decisions --scope=auth --format=table
629
+ // $ node dist/cli.js activity --agent=agent1 --limit=20
630
+ ```
631
+
632
+ Database migration runs automatically on first startup with v2.1.0.
633
+
634
+ ## [2.0.0] - 2025-10-11
635
+
636
+ ### 🚨 BREAKING CHANGES
637
+
638
+ **This is a major release with breaking API changes. Migration required for all v1.x users.**
639
+
640
+ #### Tool Consolidation
641
+ - **20 individual tools** → **6 action-based tools** (70% reduction)
642
+ - All tools now use action-based routing with `action` parameter
643
+ - Tool names completely changed (see migration guide below)
644
+
645
+ #### Old vs New Tool Names
646
+
647
+ | Old (v1.x) | New (v2.0) | Actions |
648
+ |------------|------------|---------|
649
+ | `set_decision`, `get_decision`, `get_context`, `search_by_tags`, `search_by_layer`, `get_versions` | `decision` | `set`, `get`, `list`, `search_tags`, `search_layer`, `versions`, `help` |
650
+ | `send_message`, `get_messages`, `mark_read` | `message` | `send`, `get`, `mark_read`, `help` |
651
+ | `record_file_change`, `get_file_changes`, `check_file_lock` | `file` | `record`, `get`, `check_lock`, `help` |
652
+ | `add_constraint`, `get_constraints`, `deactivate_constraint` | `constraint` | `add`, `get`, `deactivate`, `help` |
653
+ | `get_layer_summary`, `get_stats`, `clear_old_data` | `stats` | `layer_summary`, `db_stats`, `clear`, `help` |
654
+ | `get_config`, `update_config` | `config` | `get`, `update`, `help` |
655
+
656
+ ### Added
657
+
658
+ - **Help Actions:** All 6 tools now support `action: "help"` for comprehensive on-demand documentation
659
+ - Returns detailed usage, parameters, and examples
660
+ - Zero token cost until explicitly called
661
+ - **Action Hints:** Tool descriptions now include available actions for better discoverability
662
+ - **Improved Token Efficiency:** 96% token reduction vs traditional JSON approach
663
+ - Tool definition tokens: ~12,848 → ~481 tokens (96.3% reduction)
664
+ - MCP context usage: ~13,730 → ~4,482 tokens (67% reduction)
665
+
666
+ ### Changed
667
+
668
+ - **API Surface:** Complete redesign to action-based routing
669
+ - All tools require `action` parameter
670
+ - Parameters consolidated into single input schema per tool
671
+ - Nested switch statement routing for better maintainability
672
+ - **Tool Descriptions:** Simplified with action hints in parentheses
673
+ - **File Size:** Source reduced 27.4% (25,373 → 18,410 bytes) while adding help docs
674
+
675
+ ### Technical Details
676
+
677
+ - Action-based routing with two-level switch statements
678
+ - Shared parameter schemas across actions within each tool
679
+ - Enum deduplication (layer, status, priority defined once per tool)
680
+ - On-demand documentation via help actions
681
+ - 100% backward compatible database schema (no DB changes)
682
+
683
+ ### Migration Required
684
+
685
+ **v1.x users must update their tool calls:**
686
+
687
+ ```javascript
688
+ // OLD (v1.x)
689
+ await callTool('set_decision', { key: 'auth', value: 'jwt' });
690
+ await callTool('get_messages', { unread_only: true });
691
+
692
+ // NEW (v2.0)
693
+ await callTool('decision', { action: 'set', key: 'auth', value: 'jwt' });
694
+ await callTool('message', { action: 'get', unread_only: true });
695
+ ```
696
+
697
+ See `MIGRATION_v2.md` for complete migration guide.
698
+
699
+ ### Performance
700
+
701
+ - 96% token reduction in tool definitions
702
+ - 67% reduction in MCP context consumption
703
+ - Same database performance (no schema changes)
704
+ - Same query response times
705
+
706
+ ## [1.1.2] - 2025-10-11
707
+
708
+ ### Fixed
709
+ - **Schema Validation Bug:** Fixed validation checking for old unprefixed table names instead of new prefixed names
710
+ - Updated `requiredTables` to check for `m_*` and `t_*` prefixed names
711
+ - Updated `requiredViews` to check for `v_*` prefixed names
712
+ - Updated `requiredTriggers` to check for `trg_*` prefixed names
713
+ - **Migration Missing Views/Triggers:** After migration, views and triggers are now created automatically
714
+ - Added `initializeSchema()` call after successful migration
715
+ - Ensures v1.0.0 → v1.1.x migration creates all required database objects
716
+
717
+ ### Technical Details
718
+ - Migration now runs schema initialization after table renaming to create views/triggers
719
+ - Schema validation properly detects v1.1.x databases with prefixed names
720
+ - Full backward compatibility maintained with v1.0.0 databases
721
+
722
+ ## [1.1.1] - 2025-10-11
723
+
724
+ ### Fixed
725
+ - **Migration Bug:** Fixed migration from v1.0.0 to v1.1.0 failing with "no such table: m_config" error
726
+ - Migration now creates `m_config` table if it doesn't exist (new in v1.1.0, not present in v1.0.0)
727
+ - Automatically inserts default config values during migration
728
+ - Users who already migrated can manually fix by running: `sqlite3 <path-to-db> "CREATE TABLE IF NOT EXISTS m_config (key TEXT PRIMARY KEY, value TEXT NOT NULL); INSERT OR IGNORE INTO m_config VALUES ('autodelete_ignore_weekend', '0'), ('autodelete_message_hours', '24'), ('autodelete_file_history_days', '7');"`
729
+
730
+ ### Technical Details
731
+ - Added table creation step to migration script for tables new in v1.1.0
732
+ - Migration now handles both table renaming (v1.0.0 → v1.1.0) and new table creation
733
+ - 100% backward compatible with v1.0.0 databases
734
+
735
+ ## [1.1.0] - 2025-10-11
736
+
737
+ ### Added
738
+ - **Category-Based Table Prefixes:** All database objects now use prefixes for better SQL utility navigation
739
+ - Master tables: `m_` prefix (8 tables)
740
+ - Transaction tables: `t_` prefix (9 tables)
741
+ - Views: `v_` prefix (6 views)
742
+ - Triggers: `trg_` prefix (1 trigger)
743
+ - **Automatic Migration System:** Seamless upgrade from v1.0.x to v1.1.0
744
+ - Detects old unprefixed schema automatically
745
+ - Transaction-based migration with rollback on failure
746
+ - Zero downtime - runs on startup
747
+ - Detailed migration logging
748
+ - **Migration Script:** New `src/migrations/add-table-prefixes.ts` module
749
+ - Safe table renaming in transaction
750
+ - Backward compatibility check
751
+ - Comprehensive error handling
752
+
753
+ ### Changed
754
+ - Database schema structure updated to v1.1.0
755
+ - All SQL queries updated to use prefixed table names
756
+ - Schema initialization now supports both old and new table structures
757
+ - Documentation updated to reflect new table naming convention
758
+
759
+ ### Technical Details
760
+ - 24 database objects renamed (8 master tables, 9 transaction tables, 6 views, 1 trigger)
761
+ - Migration preserves all existing data
762
+ - No breaking changes for MCP tool API
763
+ - Full backward compatibility with existing databases
764
+
765
+ ## [1.0.1] - 2025-10-11
766
+
767
+ ### Added
768
+ - **Database Schema Validation:** Comprehensive validation on startup for existing databases
769
+ - Detects missing tables, views, and triggers
770
+ - Verifies standard data integrity (layers, categories, tags)
771
+ - Displays detailed error messages with actionable solutions
772
+ - Prevents data corruption from incompatible schemas
773
+ - Graceful exit with error code 1 on validation failure
774
+
775
+ ### Fixed
776
+ - Database initialization now validates existing schema before proceeding
777
+ - Organized test files into `tests/` directory for better project structure
778
+
779
+ ### Changed
780
+ - Updated `.gitignore` to properly handle test files (root vs tests directory)
781
+
782
+ ## [1.0.0] - 2025-01-10
783
+
784
+ ### Initial Release
785
+
786
+ First production release of sqlew - MCP server for efficient context sharing between Claude Code sub-agents.
787
+
788
+ ### Added
789
+
790
+ #### Context Management (6 tools)
791
+ - `set_decision` - Set or update decisions with metadata (tags, layers, scopes, versions)
792
+ - `get_context` - Advanced filtering for decision retrieval
793
+ - `get_decision` - Retrieve specific decision by key
794
+ - `search_by_tags` - Tag-based search with AND/OR logic
795
+ - `get_versions` - Version history tracking
796
+ - `search_by_layer` - Layer-based decision filtering
797
+
798
+ #### Messaging System (3 tools)
799
+ - `send_message` - Agent-to-agent messaging with priority levels
800
+ - `get_messages` - Message retrieval with filtering (priority, unread status)
801
+ - `mark_read` - Mark messages as read
802
+
803
+ #### File Change Tracking (3 tools)
804
+ - `record_file_change` - Track file modifications with layer assignment
805
+ - `get_file_changes` - File change history retrieval
806
+ - `check_file_lock` - Concurrent edit prevention
807
+
808
+ #### Constraint Management (3 tools)
809
+ - `add_constraint` - Add constraints with priority and metadata
810
+ - `get_constraints` - Complex constraint filtering
811
+ - `deactivate_constraint` - Soft delete constraints
812
+
813
+ #### Utilities (3 tools)
814
+ - `get_layer_summary` - Per-layer aggregated statistics
815
+ - `clear_old_data` - Manual cleanup of old data
816
+ - `get_stats` - Comprehensive database statistics
817
+
818
+ ### Features
819
+
820
+ - **Token Efficiency:** 72% reduction through ID-based normalization, integer enums, and pre-aggregated views
821
+ - **Metadata System:** Tags, layers, scopes, versions, and priorities for intelligent organization
822
+ - **SQLite Database:** Fast, reliable, offline-only operation with ACID guarantees
823
+ - **Automatic Cleanup:** Configurable retention policies (24h for messages, 7 days for file changes)
824
+ - **Version History:** Automatic tracking of decision evolution
825
+ - **Concurrent Access:** Support for multiple agents simultaneously
826
+ - **WAL Mode:** Write-Ahead Logging for improved concurrency
827
+
828
+ ### Database Schema
829
+
830
+ - 7 Master tables for normalization (agents, files, context_keys, layers, tags, scopes, constraint_categories)
831
+ - 10 Transaction tables for core data
832
+ - 6 Token-efficient pre-aggregated views
833
+ - 9 Optimized indexes for common queries
834
+ - 3 Automatic triggers for cleanup and history
835
+
836
+ ### Architecture
837
+
838
+ - **Standard Layers:** presentation, business, data, infrastructure, cross-cutting
839
+ - **Constraint Categories:** performance, architecture, security
840
+ - **Priority Levels:** low, medium, high, critical
841
+ - **Message Types:** decision, warning, request, info
842
+ - **Change Types:** created, modified, deleted
843
+ - **Status Values:** active, deprecated, draft
844
+
845
+ ### Performance
846
+
847
+ - Query performance: 2-20ms for typical operations
848
+ - Concurrent access: Tested with 5 simultaneous agents
849
+ - Database size: ~140 bytes per decision (efficient storage)
850
+ - Token reduction: 72% compared to traditional JSON approach
851
+
852
+ ### Documentation
853
+
854
+ - Comprehensive README with quick start guide
855
+ - Complete tool reference with examples
856
+ - Architecture documentation
857
+ - Schema reference
858
+ - Development guidelines
859
+
860
+ ### Testing
861
+
862
+ - 100% tool coverage (all 18 tools verified)
863
+ - Comprehensive test suite
864
+ - MCP Inspector compatibility
865
+
866
+ ### Technical Details
867
+
868
+ - **Runtime:** Node.js 18+
869
+ - **Language:** TypeScript 5.0+
870
+ - **Database:** better-sqlite3 ^11.0.0
871
+ - **MCP SDK:** @modelcontextprotocol/sdk (latest)
872
+ - **Transport:** stdio (standard MCP pattern)
873
+
874
+ ### Code Statistics
875
+
876
+ - 3,424 lines of TypeScript
877
+ - 10 source files
878
+ - Full type safety
879
+ - Comprehensive error handling
880
+
881
+ [2.1.4]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.4
882
+ [2.1.3]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.3
883
+ [2.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.2
884
+ [2.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.1
885
+ [2.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.1.0
886
+ [2.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v2.0.0
887
+ [1.1.2]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.2
888
+ [1.1.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.1
889
+ [1.1.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.1.0
890
+ [1.0.1]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.0.1
891
+ [1.0.0]: https://github.com/sin5ddd/mcp-sqlew/releases/tag/v1.0.0