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
@@ -1,538 +1,538 @@
1
- # Migration Guide: v1.x → v2.0.0
2
-
3
- This guide helps you migrate from sqlew v1.x to v2.0.0. The v2.0 release consolidates 20 individual tools into 6 action-based tools for 96% token reduction.
4
-
5
- ## Breaking Changes Summary
6
-
7
- ### What Changed
8
- - **Tool Names:** All 20 tool names changed
9
- - **API Structure:** All tools now use action-based routing with an `action` parameter
10
- - **Tool Count:** 20 → 6 tools
11
-
12
- ### What Didn't Change
13
- - **Database Schema:** 100% compatible - no migration needed ✅
14
- - **Functionality:** All 20 original functions preserved
15
- - **Parameters:** Same parameter names and types (except `action` is now required)
16
- - **Return Values:** Identical response structures
17
-
18
- ## Database Compatibility
19
-
20
- **Good news:** Your v1.x database works with v2.0 without any changes!
21
-
22
- - ✅ v1.x database → v2.0 server (works immediately)
23
- - ✅ v2.0 database → v1.x server (if you need to downgrade)
24
- - ✅ No data migration required
25
- - ✅ No schema changes
26
-
27
- The v2.0 consolidation is purely an MCP interface redesign - the database layer is unchanged.
28
-
29
- ## Tool Mapping Reference
30
-
31
- | v1.x Tool | v2.0 Tool | Action |
32
- |-----------|-----------|--------|
33
- | `set_decision` | `decision` | `set` |
34
- | `get_decision` | `decision` | `get` |
35
- | `get_context` | `decision` | `list` |
36
- | `search_by_tags` | `decision` | `search_tags` |
37
- | `search_by_layer` | `decision` | `search_layer` |
38
- | `get_versions` | `decision` | `versions` |
39
- | `send_message` | `message` | `send` |
40
- | `get_messages` | `message` | `get` |
41
- | `mark_read` | `message` | `mark_read` |
42
- | `record_file_change` | `file` | `record` |
43
- | `get_file_changes` | `file` | `get` |
44
- | `check_file_lock` | `file` | `check_lock` |
45
- | `add_constraint` | `constraint` | `add` |
46
- | `get_constraints` | `constraint` | `get` |
47
- | `deactivate_constraint` | `constraint` | `deactivate` |
48
- | `get_layer_summary` | `stats` | `layer_summary` |
49
- | `get_stats` | `stats` | `db_stats` |
50
- | `clear_old_data` | `stats` | `clear` |
51
- | `get_config` | `config` | `get` |
52
- | `update_config` | `config` | `update` |
53
-
54
- ## Migration Examples
55
-
56
- ### Context Management
57
-
58
- **v1.x:**
59
- ```typescript
60
- // Set decision
61
- await callTool('set_decision', {
62
- key: 'auth_method',
63
- value: 'JWT',
64
- tags: ['security']
65
- });
66
-
67
- // Get decision
68
- await callTool('get_decision', {
69
- key: 'auth_method'
70
- });
71
-
72
- // Search by tags
73
- await callTool('search_by_tags', {
74
- tags: ['security', 'api'],
75
- match_mode: 'AND'
76
- });
77
- ```
78
-
79
- **v2.0:**
80
- ```typescript
81
- // Set decision
82
- await callTool('decision', {
83
- action: 'set',
84
- key: 'auth_method',
85
- value: 'JWT',
86
- tags: ['security']
87
- });
88
-
89
- // Get decision
90
- await callTool('decision', {
91
- action: 'get',
92
- key: 'auth_method'
93
- });
94
-
95
- // Search by tags
96
- await callTool('decision', {
97
- action: 'search_tags',
98
- tags: ['security', 'api'],
99
- tag_match: 'AND' // Note: parameter renamed from match_mode
100
- });
101
- ```
102
-
103
- ### Messaging
104
-
105
- **v1.x:**
106
- ```typescript
107
- // Send message
108
- await callTool('send_message', {
109
- from_agent: 'agent1',
110
- to_agent: 'agent2',
111
- message: 'Task complete',
112
- priority: 'high'
113
- });
114
-
115
- // Get messages
116
- await callTool('get_messages', {
117
- unread_only: true
118
- });
119
-
120
- // Mark as read
121
- await callTool('mark_read', {
122
- message_ids: [1, 2, 3]
123
- });
124
- ```
125
-
126
- **v2.0:**
127
- ```typescript
128
- // Send message
129
- await callTool('message', {
130
- action: 'send',
131
- from_agent: 'agent1',
132
- to_agent: 'agent2',
133
- message: 'Task complete',
134
- priority: 'high'
135
- });
136
-
137
- // Get messages
138
- await callTool('message', {
139
- action: 'get',
140
- unread_only: true
141
- });
142
-
143
- // Mark as read
144
- await callTool('message', {
145
- action: 'mark_read',
146
- message_ids: [1, 2, 3]
147
- });
148
- ```
149
-
150
- ### File Tracking
151
-
152
- **v1.x:**
153
- ```typescript
154
- // Record file change
155
- await callTool('record_file_change', {
156
- file_path: '/src/auth.ts',
157
- agent_name: 'auth-agent',
158
- change_type: 'modified',
159
- layer: 'business'
160
- });
161
-
162
- // Get file changes
163
- await callTool('get_file_changes', {
164
- since: '2025-01-10T10:00:00Z'
165
- });
166
-
167
- // Check file lock
168
- await callTool('check_file_lock', {
169
- file_path: '/src/auth.ts'
170
- });
171
- ```
172
-
173
- **v2.0:**
174
- ```typescript
175
- // Record file change
176
- await callTool('file', {
177
- action: 'record',
178
- file_path: '/src/auth.ts',
179
- agent_name: 'auth-agent',
180
- change_type: 'modified',
181
- layer: 'business'
182
- });
183
-
184
- // Get file changes
185
- await callTool('file', {
186
- action: 'get',
187
- since: '2025-01-10T10:00:00Z'
188
- });
189
-
190
- // Check file lock
191
- await callTool('file', {
192
- action: 'check_lock',
193
- file_path: '/src/auth.ts'
194
- });
195
- ```
196
-
197
- ### Constraints
198
-
199
- **v1.x:**
200
- ```typescript
201
- // Add constraint
202
- await callTool('add_constraint', {
203
- category: 'performance',
204
- constraint_text: 'Response time < 200ms',
205
- priority: 'high'
206
- });
207
-
208
- // Get constraints
209
- await callTool('get_constraints', {
210
- category: 'performance'
211
- });
212
-
213
- // Deactivate constraint
214
- await callTool('deactivate_constraint', {
215
- constraint_id: 42
216
- });
217
- ```
218
-
219
- **v2.0:**
220
- ```typescript
221
- // Add constraint
222
- await callTool('constraint', {
223
- action: 'add',
224
- category: 'performance',
225
- constraint_text: 'Response time < 200ms',
226
- priority: 'high'
227
- });
228
-
229
- // Get constraints
230
- await callTool('constraint', {
231
- action: 'get',
232
- category: 'performance'
233
- });
234
-
235
- // Deactivate constraint
236
- await callTool('constraint', {
237
- action: 'deactivate',
238
- constraint_id: 42
239
- });
240
- ```
241
-
242
- ### Utilities
243
-
244
- **v1.x:**
245
- ```typescript
246
- // Layer summary
247
- await callTool('get_layer_summary');
248
-
249
- // Database stats
250
- await callTool('get_stats');
251
-
252
- // Clear old data
253
- await callTool('clear_old_data', {
254
- messages_older_than_hours: 48
255
- });
256
- ```
257
-
258
- **v2.0:**
259
- ```typescript
260
- // Layer summary
261
- await callTool('stats', {
262
- action: 'layer_summary'
263
- });
264
-
265
- // Database stats
266
- await callTool('stats', {
267
- action: 'db_stats'
268
- });
269
-
270
- // Clear old data
271
- await callTool('stats', {
272
- action: 'clear',
273
- messages_older_than_hours: 48
274
- });
275
- ```
276
-
277
- ### Configuration
278
-
279
- **v1.x:**
280
- ```typescript
281
- // Get config
282
- await callTool('get_config');
283
-
284
- // Update config
285
- await callTool('update_config', {
286
- ignoreWeekend: true,
287
- messageRetentionHours: 48
288
- });
289
- ```
290
-
291
- **v2.0:**
292
- ```typescript
293
- // Get config
294
- await callTool('config', {
295
- action: 'get'
296
- });
297
-
298
- // Update config
299
- await callTool('config', {
300
- action: 'update',
301
- ignoreWeekend: true,
302
- messageRetentionHours: 48
303
- });
304
- ```
305
-
306
- ## New Feature: Help Actions
307
-
308
- v2.0 adds `action: "help"` to all tools for on-demand comprehensive documentation:
309
-
310
- ```typescript
311
- // Get help for any tool
312
- await callTool('decision', { action: 'help' });
313
- await callTool('message', { action: 'help' });
314
- await callTool('file', { action: 'help' });
315
- await callTool('constraint', { action: 'help' });
316
- await callTool('stats', { action: 'help' });
317
- await callTool('config', { action: 'help' });
318
- ```
319
-
320
- Each help action returns:
321
- - Tool description
322
- - Complete action list with parameters
323
- - Usage examples
324
- - Parameter requirements
325
-
326
- **Zero token cost** until explicitly called!
327
-
328
- ## Migration Checklist
329
-
330
- ### 1. Update Package
331
- ```bash
332
- npm install sqlew@2.0.0
333
- # or
334
- npm update sqlew
335
- ```
336
-
337
- ### 2. Update Tool Calls
338
-
339
- Search your codebase for v1.x tool calls:
340
-
341
- ```bash
342
- # Find all v1.x tool calls
343
- grep -r "set_decision\|get_decision\|get_context\|search_by_tags" .
344
- grep -r "send_message\|get_messages\|mark_read" .
345
- grep -r "record_file_change\|get_file_changes\|check_file_lock" .
346
- grep -r "add_constraint\|get_constraints\|deactivate_constraint" .
347
- grep -r "get_layer_summary\|get_stats\|clear_old_data" .
348
- grep -r "get_config\|update_config" .
349
- ```
350
-
351
- Replace each with v2.0 equivalent using the mapping table above.
352
-
353
- ### 3. Test Your Changes
354
-
355
- Use MCP Inspector to verify tool calls:
356
-
357
- ```bash
358
- npx @modelcontextprotocol/inspector npx sqlew
359
- ```
360
-
361
- Test each migrated tool call to ensure:
362
- - ✅ Correct tool name
363
- - ✅ `action` parameter included
364
- - ✅ All other parameters unchanged
365
- - ✅ Response structure matches expectations
366
-
367
- ### 4. Verify Database Works
368
-
369
- Your existing database should work immediately with v2.0:
370
-
371
- ```bash
372
- # Start v2.0 server with your existing database
373
- npx sqlew /path/to/your/existing/v1.db
374
-
375
- # Test a few operations
376
- # Your data should be intact
377
- ```
378
-
379
- ## Parameter Changes
380
-
381
- ### search_by_tags
382
-
383
- **v1.x:** `match_mode` parameter
384
- **v2.0:** `tag_match` parameter
385
-
386
- ```typescript
387
- // v1.x
388
- search_by_tags({ tags: ['api'], match_mode: 'AND' })
389
-
390
- // v2.0
391
- decision({ action: 'search_tags', tags: ['api'], tag_match: 'AND' })
392
- ```
393
-
394
- All other parameters remain unchanged.
395
-
396
- ## Common Pitfalls
397
-
398
- ### ❌ Forgetting `action` Parameter
399
-
400
- ```typescript
401
- // WRONG - will fail
402
- await callTool('decision', { key: 'auth_method' });
403
-
404
- // CORRECT
405
- await callTool('decision', { action: 'get', key: 'auth_method' });
406
- ```
407
-
408
- ### ❌ Using Old Tool Names
409
-
410
- ```typescript
411
- // WRONG - tool doesn't exist
412
- await callTool('set_decision', { action: 'set', key: 'auth' });
413
-
414
- // CORRECT
415
- await callTool('decision', { action: 'set', key: 'auth' });
416
- ```
417
-
418
- ### ❌ Wrong Action Name
419
-
420
- ```typescript
421
- // WRONG - action doesn't exist
422
- await callTool('decision', { action: 'search_tags', match_mode: 'AND' });
423
-
424
- // CORRECT - parameter also renamed
425
- await callTool('decision', { action: 'search_tags', tag_match: 'AND' });
426
- ```
427
-
428
- ## Rollback Plan
429
-
430
- If you need to rollback to v1.x:
431
-
432
- ```bash
433
- # Downgrade package
434
- npm install sqlew@1.1.2
435
-
436
- # Your database will continue to work
437
- # No schema migration needed
438
- ```
439
-
440
- Your v2.0 database is 100% compatible with v1.x servers.
441
-
442
- ## Benefits of v2.0
443
-
444
- After migration, you'll enjoy:
445
-
446
- - **96% Token Reduction:** Tool definitions use 481 tokens instead of 12,848
447
- - **67% MCP Context Reduction:** From ~13,730 to ~4,482 tokens
448
- - **On-Demand Help:** Use `action: "help"` for comprehensive documentation
449
- - **Same Functionality:** All 20 original functions preserved
450
- - **Better Organization:** Related operations grouped into single tools
451
-
452
- ## Support
453
-
454
- Need help with migration?
455
-
456
- - **Issues:** [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
457
- - **Changelog:** See [CHANGELOG.md](CHANGELOG.md) for complete v2.0 details
458
- - **Documentation:** Updated [README.md](README.md) with v2.0 examples
459
-
460
- ## Example: Complete Migration
461
-
462
- Here's a complete before/after example showing typical usage:
463
-
464
- ### Before (v1.x)
465
-
466
- ```typescript
467
- // Set up authentication decision
468
- await callTool('set_decision', {
469
- key: 'auth_method',
470
- value: 'JWT',
471
- tags: ['security', 'api'],
472
- layer: 'business'
473
- });
474
-
475
- // Send notification
476
- await callTool('send_message', {
477
- from_agent: 'auth-agent',
478
- to_agent: 'api-agent',
479
- message: 'Auth configured',
480
- priority: 'high'
481
- });
482
-
483
- // Track file change
484
- await callTool('record_file_change', {
485
- file_path: '/src/auth.ts',
486
- agent_name: 'auth-agent',
487
- change_type: 'created',
488
- layer: 'business'
489
- });
490
-
491
- // Add constraint
492
- await callTool('add_constraint', {
493
- category: 'security',
494
- constraint_text: 'Use JWT with RS256',
495
- priority: 'critical'
496
- });
497
- ```
498
-
499
- ### After (v2.0)
500
-
501
- ```typescript
502
- // Set up authentication decision
503
- await callTool('decision', {
504
- action: 'set',
505
- key: 'auth_method',
506
- value: 'JWT',
507
- tags: ['security', 'api'],
508
- layer: 'business'
509
- });
510
-
511
- // Send notification
512
- await callTool('message', {
513
- action: 'send',
514
- from_agent: 'auth-agent',
515
- to_agent: 'api-agent',
516
- message: 'Auth configured',
517
- priority: 'high'
518
- });
519
-
520
- // Track file change
521
- await callTool('file', {
522
- action: 'record',
523
- file_path: '/src/auth.ts',
524
- agent_name: 'auth-agent',
525
- change_type: 'created',
526
- layer: 'business'
527
- });
528
-
529
- // Add constraint
530
- await callTool('constraint', {
531
- action: 'add',
532
- category: 'security',
533
- constraint_text: 'Use JWT with RS256',
534
- priority: 'critical'
535
- });
536
- ```
537
-
538
- Only changes: tool names and added `action` parameters. All other parameters identical!
1
+ # Migration Guide: v1.x → v2.0.0
2
+
3
+ This guide helps you migrate from sqlew v1.x to v2.0.0. The v2.0 release consolidates 20 individual tools into 6 action-based tools for 96% token reduction.
4
+
5
+ ## Breaking Changes Summary
6
+
7
+ ### What Changed
8
+ - **Tool Names:** All 20 tool names changed
9
+ - **API Structure:** All tools now use action-based routing with an `action` parameter
10
+ - **Tool Count:** 20 → 6 tools
11
+
12
+ ### What Didn't Change
13
+ - **Database Schema:** 100% compatible - no migration needed ✅
14
+ - **Functionality:** All 20 original functions preserved
15
+ - **Parameters:** Same parameter names and types (except `action` is now required)
16
+ - **Return Values:** Identical response structures
17
+
18
+ ## Database Compatibility
19
+
20
+ **Good news:** Your v1.x database works with v2.0 without any changes!
21
+
22
+ - ✅ v1.x database → v2.0 server (works immediately)
23
+ - ✅ v2.0 database → v1.x server (if you need to downgrade)
24
+ - ✅ No data migration required
25
+ - ✅ No schema changes
26
+
27
+ The v2.0 consolidation is purely an MCP interface redesign - the database layer is unchanged.
28
+
29
+ ## Tool Mapping Reference
30
+
31
+ | v1.x Tool | v2.0 Tool | Action |
32
+ |-----------|-----------|--------|
33
+ | `set_decision` | `decision` | `set` |
34
+ | `get_decision` | `decision` | `get` |
35
+ | `get_context` | `decision` | `list` |
36
+ | `search_by_tags` | `decision` | `search_tags` |
37
+ | `search_by_layer` | `decision` | `search_layer` |
38
+ | `get_versions` | `decision` | `versions` |
39
+ | `send_message` | `message` | `send` |
40
+ | `get_messages` | `message` | `get` |
41
+ | `mark_read` | `message` | `mark_read` |
42
+ | `record_file_change` | `file` | `record` |
43
+ | `get_file_changes` | `file` | `get` |
44
+ | `check_file_lock` | `file` | `check_lock` |
45
+ | `add_constraint` | `constraint` | `add` |
46
+ | `get_constraints` | `constraint` | `get` |
47
+ | `deactivate_constraint` | `constraint` | `deactivate` |
48
+ | `get_layer_summary` | `stats` | `layer_summary` |
49
+ | `get_stats` | `stats` | `db_stats` |
50
+ | `clear_old_data` | `stats` | `clear` |
51
+ | `get_config` | `config` | `get` |
52
+ | `update_config` | `config` | `update` |
53
+
54
+ ## Migration Examples
55
+
56
+ ### Context Management
57
+
58
+ **v1.x:**
59
+ ```typescript
60
+ // Set decision
61
+ await callTool('set_decision', {
62
+ key: 'auth_method',
63
+ value: 'JWT',
64
+ tags: ['security']
65
+ });
66
+
67
+ // Get decision
68
+ await callTool('get_decision', {
69
+ key: 'auth_method'
70
+ });
71
+
72
+ // Search by tags
73
+ await callTool('search_by_tags', {
74
+ tags: ['security', 'api'],
75
+ match_mode: 'AND'
76
+ });
77
+ ```
78
+
79
+ **v2.0:**
80
+ ```typescript
81
+ // Set decision
82
+ await callTool('decision', {
83
+ action: 'set',
84
+ key: 'auth_method',
85
+ value: 'JWT',
86
+ tags: ['security']
87
+ });
88
+
89
+ // Get decision
90
+ await callTool('decision', {
91
+ action: 'get',
92
+ key: 'auth_method'
93
+ });
94
+
95
+ // Search by tags
96
+ await callTool('decision', {
97
+ action: 'search_tags',
98
+ tags: ['security', 'api'],
99
+ tag_match: 'AND' // Note: parameter renamed from match_mode
100
+ });
101
+ ```
102
+
103
+ ### Messaging
104
+
105
+ **v1.x:**
106
+ ```typescript
107
+ // Send message
108
+ await callTool('send_message', {
109
+ from_agent: 'agent1',
110
+ to_agent: 'agent2',
111
+ message: 'Task complete',
112
+ priority: 'high'
113
+ });
114
+
115
+ // Get messages
116
+ await callTool('get_messages', {
117
+ unread_only: true
118
+ });
119
+
120
+ // Mark as read
121
+ await callTool('mark_read', {
122
+ message_ids: [1, 2, 3]
123
+ });
124
+ ```
125
+
126
+ **v2.0:**
127
+ ```typescript
128
+ // Send message
129
+ await callTool('message', {
130
+ action: 'send',
131
+ from_agent: 'agent1',
132
+ to_agent: 'agent2',
133
+ message: 'Task complete',
134
+ priority: 'high'
135
+ });
136
+
137
+ // Get messages
138
+ await callTool('message', {
139
+ action: 'get',
140
+ unread_only: true
141
+ });
142
+
143
+ // Mark as read
144
+ await callTool('message', {
145
+ action: 'mark_read',
146
+ message_ids: [1, 2, 3]
147
+ });
148
+ ```
149
+
150
+ ### File Tracking
151
+
152
+ **v1.x:**
153
+ ```typescript
154
+ // Record file change
155
+ await callTool('record_file_change', {
156
+ file_path: '/src/auth.ts',
157
+ agent_name: 'auth-agent',
158
+ change_type: 'modified',
159
+ layer: 'business'
160
+ });
161
+
162
+ // Get file changes
163
+ await callTool('get_file_changes', {
164
+ since: '2025-01-10T10:00:00Z'
165
+ });
166
+
167
+ // Check file lock
168
+ await callTool('check_file_lock', {
169
+ file_path: '/src/auth.ts'
170
+ });
171
+ ```
172
+
173
+ **v2.0:**
174
+ ```typescript
175
+ // Record file change
176
+ await callTool('file', {
177
+ action: 'record',
178
+ file_path: '/src/auth.ts',
179
+ agent_name: 'auth-agent',
180
+ change_type: 'modified',
181
+ layer: 'business'
182
+ });
183
+
184
+ // Get file changes
185
+ await callTool('file', {
186
+ action: 'get',
187
+ since: '2025-01-10T10:00:00Z'
188
+ });
189
+
190
+ // Check file lock
191
+ await callTool('file', {
192
+ action: 'check_lock',
193
+ file_path: '/src/auth.ts'
194
+ });
195
+ ```
196
+
197
+ ### Constraints
198
+
199
+ **v1.x:**
200
+ ```typescript
201
+ // Add constraint
202
+ await callTool('add_constraint', {
203
+ category: 'performance',
204
+ constraint_text: 'Response time < 200ms',
205
+ priority: 'high'
206
+ });
207
+
208
+ // Get constraints
209
+ await callTool('get_constraints', {
210
+ category: 'performance'
211
+ });
212
+
213
+ // Deactivate constraint
214
+ await callTool('deactivate_constraint', {
215
+ constraint_id: 42
216
+ });
217
+ ```
218
+
219
+ **v2.0:**
220
+ ```typescript
221
+ // Add constraint
222
+ await callTool('constraint', {
223
+ action: 'add',
224
+ category: 'performance',
225
+ constraint_text: 'Response time < 200ms',
226
+ priority: 'high'
227
+ });
228
+
229
+ // Get constraints
230
+ await callTool('constraint', {
231
+ action: 'get',
232
+ category: 'performance'
233
+ });
234
+
235
+ // Deactivate constraint
236
+ await callTool('constraint', {
237
+ action: 'deactivate',
238
+ constraint_id: 42
239
+ });
240
+ ```
241
+
242
+ ### Utilities
243
+
244
+ **v1.x:**
245
+ ```typescript
246
+ // Layer summary
247
+ await callTool('get_layer_summary');
248
+
249
+ // Database stats
250
+ await callTool('get_stats');
251
+
252
+ // Clear old data
253
+ await callTool('clear_old_data', {
254
+ messages_older_than_hours: 48
255
+ });
256
+ ```
257
+
258
+ **v2.0:**
259
+ ```typescript
260
+ // Layer summary
261
+ await callTool('stats', {
262
+ action: 'layer_summary'
263
+ });
264
+
265
+ // Database stats
266
+ await callTool('stats', {
267
+ action: 'db_stats'
268
+ });
269
+
270
+ // Clear old data
271
+ await callTool('stats', {
272
+ action: 'clear',
273
+ messages_older_than_hours: 48
274
+ });
275
+ ```
276
+
277
+ ### Configuration
278
+
279
+ **v1.x:**
280
+ ```typescript
281
+ // Get config
282
+ await callTool('get_config');
283
+
284
+ // Update config
285
+ await callTool('update_config', {
286
+ ignoreWeekend: true,
287
+ messageRetentionHours: 48
288
+ });
289
+ ```
290
+
291
+ **v2.0:**
292
+ ```typescript
293
+ // Get config
294
+ await callTool('config', {
295
+ action: 'get'
296
+ });
297
+
298
+ // Update config
299
+ await callTool('config', {
300
+ action: 'update',
301
+ ignoreWeekend: true,
302
+ messageRetentionHours: 48
303
+ });
304
+ ```
305
+
306
+ ## New Feature: Help Actions
307
+
308
+ v2.0 adds `action: "help"` to all tools for on-demand comprehensive documentation:
309
+
310
+ ```typescript
311
+ // Get help for any tool
312
+ await callTool('decision', { action: 'help' });
313
+ await callTool('message', { action: 'help' });
314
+ await callTool('file', { action: 'help' });
315
+ await callTool('constraint', { action: 'help' });
316
+ await callTool('stats', { action: 'help' });
317
+ await callTool('config', { action: 'help' });
318
+ ```
319
+
320
+ Each help action returns:
321
+ - Tool description
322
+ - Complete action list with parameters
323
+ - Usage examples
324
+ - Parameter requirements
325
+
326
+ **Zero token cost** until explicitly called!
327
+
328
+ ## Migration Checklist
329
+
330
+ ### 1. Update Package
331
+ ```bash
332
+ npm install sqlew@2.0.0
333
+ # or
334
+ npm update sqlew
335
+ ```
336
+
337
+ ### 2. Update Tool Calls
338
+
339
+ Search your codebase for v1.x tool calls:
340
+
341
+ ```bash
342
+ # Find all v1.x tool calls
343
+ grep -r "set_decision\|get_decision\|get_context\|search_by_tags" .
344
+ grep -r "send_message\|get_messages\|mark_read" .
345
+ grep -r "record_file_change\|get_file_changes\|check_file_lock" .
346
+ grep -r "add_constraint\|get_constraints\|deactivate_constraint" .
347
+ grep -r "get_layer_summary\|get_stats\|clear_old_data" .
348
+ grep -r "get_config\|update_config" .
349
+ ```
350
+
351
+ Replace each with v2.0 equivalent using the mapping table above.
352
+
353
+ ### 3. Test Your Changes
354
+
355
+ Use MCP Inspector to verify tool calls:
356
+
357
+ ```bash
358
+ npx @modelcontextprotocol/inspector npx sqlew
359
+ ```
360
+
361
+ Test each migrated tool call to ensure:
362
+ - ✅ Correct tool name
363
+ - ✅ `action` parameter included
364
+ - ✅ All other parameters unchanged
365
+ - ✅ Response structure matches expectations
366
+
367
+ ### 4. Verify Database Works
368
+
369
+ Your existing database should work immediately with v2.0:
370
+
371
+ ```bash
372
+ # Start v2.0 server with your existing database
373
+ npx sqlew /path/to/your/existing/v1.db
374
+
375
+ # Test a few operations
376
+ # Your data should be intact
377
+ ```
378
+
379
+ ## Parameter Changes
380
+
381
+ ### search_by_tags
382
+
383
+ **v1.x:** `match_mode` parameter
384
+ **v2.0:** `tag_match` parameter
385
+
386
+ ```typescript
387
+ // v1.x
388
+ search_by_tags({ tags: ['api'], match_mode: 'AND' })
389
+
390
+ // v2.0
391
+ decision({ action: 'search_tags', tags: ['api'], tag_match: 'AND' })
392
+ ```
393
+
394
+ All other parameters remain unchanged.
395
+
396
+ ## Common Pitfalls
397
+
398
+ ### ❌ Forgetting `action` Parameter
399
+
400
+ ```typescript
401
+ // WRONG - will fail
402
+ await callTool('decision', { key: 'auth_method' });
403
+
404
+ // CORRECT
405
+ await callTool('decision', { action: 'get', key: 'auth_method' });
406
+ ```
407
+
408
+ ### ❌ Using Old Tool Names
409
+
410
+ ```typescript
411
+ // WRONG - tool doesn't exist
412
+ await callTool('set_decision', { action: 'set', key: 'auth' });
413
+
414
+ // CORRECT
415
+ await callTool('decision', { action: 'set', key: 'auth' });
416
+ ```
417
+
418
+ ### ❌ Wrong Action Name
419
+
420
+ ```typescript
421
+ // WRONG - action doesn't exist
422
+ await callTool('decision', { action: 'search_tags', match_mode: 'AND' });
423
+
424
+ // CORRECT - parameter also renamed
425
+ await callTool('decision', { action: 'search_tags', tag_match: 'AND' });
426
+ ```
427
+
428
+ ## Rollback Plan
429
+
430
+ If you need to rollback to v1.x:
431
+
432
+ ```bash
433
+ # Downgrade package
434
+ npm install sqlew@1.1.2
435
+
436
+ # Your database will continue to work
437
+ # No schema migration needed
438
+ ```
439
+
440
+ Your v2.0 database is 100% compatible with v1.x servers.
441
+
442
+ ## Benefits of v2.0
443
+
444
+ After migration, you'll enjoy:
445
+
446
+ - **96% Token Reduction:** Tool definitions use 481 tokens instead of 12,848
447
+ - **67% MCP Context Reduction:** From ~13,730 to ~4,482 tokens
448
+ - **On-Demand Help:** Use `action: "help"` for comprehensive documentation
449
+ - **Same Functionality:** All 20 original functions preserved
450
+ - **Better Organization:** Related operations grouped into single tools
451
+
452
+ ## Support
453
+
454
+ Need help with migration?
455
+
456
+ - **Issues:** [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
457
+ - **Changelog:** See [CHANGELOG.md](CHANGELOG.md) for complete v2.0 details
458
+ - **Documentation:** Updated [README.md](README.md) with v2.0 examples
459
+
460
+ ## Example: Complete Migration
461
+
462
+ Here's a complete before/after example showing typical usage:
463
+
464
+ ### Before (v1.x)
465
+
466
+ ```typescript
467
+ // Set up authentication decision
468
+ await callTool('set_decision', {
469
+ key: 'auth_method',
470
+ value: 'JWT',
471
+ tags: ['security', 'api'],
472
+ layer: 'business'
473
+ });
474
+
475
+ // Send notification
476
+ await callTool('send_message', {
477
+ from_agent: 'auth-agent',
478
+ to_agent: 'api-agent',
479
+ message: 'Auth configured',
480
+ priority: 'high'
481
+ });
482
+
483
+ // Track file change
484
+ await callTool('record_file_change', {
485
+ file_path: '/src/auth.ts',
486
+ agent_name: 'auth-agent',
487
+ change_type: 'created',
488
+ layer: 'business'
489
+ });
490
+
491
+ // Add constraint
492
+ await callTool('add_constraint', {
493
+ category: 'security',
494
+ constraint_text: 'Use JWT with RS256',
495
+ priority: 'critical'
496
+ });
497
+ ```
498
+
499
+ ### After (v2.0)
500
+
501
+ ```typescript
502
+ // Set up authentication decision
503
+ await callTool('decision', {
504
+ action: 'set',
505
+ key: 'auth_method',
506
+ value: 'JWT',
507
+ tags: ['security', 'api'],
508
+ layer: 'business'
509
+ });
510
+
511
+ // Send notification
512
+ await callTool('message', {
513
+ action: 'send',
514
+ from_agent: 'auth-agent',
515
+ to_agent: 'api-agent',
516
+ message: 'Auth configured',
517
+ priority: 'high'
518
+ });
519
+
520
+ // Track file change
521
+ await callTool('file', {
522
+ action: 'record',
523
+ file_path: '/src/auth.ts',
524
+ agent_name: 'auth-agent',
525
+ change_type: 'created',
526
+ layer: 'business'
527
+ });
528
+
529
+ // Add constraint
530
+ await callTool('constraint', {
531
+ action: 'add',
532
+ category: 'security',
533
+ constraint_text: 'Use JWT with RS256',
534
+ priority: 'critical'
535
+ });
536
+ ```
537
+
538
+ Only changes: tool names and added `action` parameters. All other parameters identical!