sqlew 2.1.4 → 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.
- package/CHANGELOG.md +891 -605
- package/README.md +302 -690
- package/assets/kanban-style.png +0 -0
- package/assets/schema.sql +531 -402
- package/dist/database.d.ts +9 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +33 -34
- package/dist/database.js.map +1 -1
- package/dist/index.js +1024 -213
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-task-tables.d.ts +47 -0
- package/dist/migrations/add-task-tables.d.ts.map +1 -0
- package/dist/migrations/add-task-tables.js +285 -0
- package/dist/migrations/add-task-tables.js.map +1 -0
- package/dist/migrations/index.d.ts +96 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +239 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts +61 -0
- package/dist/migrations/migrate-decisions-to-tasks.d.ts.map +1 -0
- package/dist/migrations/migrate-decisions-to-tasks.js +442 -0
- package/dist/migrations/migrate-decisions-to-tasks.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -3
- package/dist/schema.js.map +1 -1
- package/dist/tools/constraints.d.ts +4 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +6 -27
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts +17 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +195 -190
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +113 -166
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +2 -9
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +67 -126
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/tasks.d.ts +90 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +732 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/utils.d.ts +8 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +50 -21
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/batch.d.ts +69 -0
- package/dist/utils/batch.d.ts.map +1 -0
- package/dist/utils/batch.js +148 -0
- package/dist/utils/batch.js.map +1 -0
- package/dist/utils/query-builder.d.ts +68 -0
- package/dist/utils/query-builder.d.ts.map +1 -0
- package/dist/utils/query-builder.js +116 -0
- package/dist/utils/query-builder.js.map +1 -0
- package/dist/utils/task-stale-detection.d.ts +28 -0
- package/dist/utils/task-stale-detection.d.ts.map +1 -0
- package/dist/utils/task-stale-detection.js +92 -0
- package/dist/utils/task-stale-detection.js.map +1 -0
- package/dist/utils/validators.d.ts +57 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +117 -0
- package/dist/utils/validators.js.map +1 -0
- package/docs/AI_AGENT_GUIDE.md +1471 -648
- package/{ARCHITECTURE.md → docs/ARCHITECTURE.md} +636 -636
- package/docs/BEST_PRACTICES.md +481 -0
- package/docs/DECISION_TO_TASK_MIGRATION_GUIDE.md +457 -0
- package/docs/MIGRATION_CHAIN.md +280 -0
- package/{MIGRATION_v2.md → docs/MIGRATION_v2.md} +538 -538
- package/docs/SHARED_CONCEPTS.md +339 -0
- package/docs/TASK_ACTIONS.md +854 -0
- package/docs/TASK_LINKING.md +729 -0
- package/docs/TASK_MIGRATION.md +701 -0
- package/docs/TASK_OVERVIEW.md +363 -0
- package/docs/TASK_SYSTEM.md +1244 -0
- package/docs/TOOL_REFERENCE.md +471 -0
- package/docs/TOOL_SELECTION.md +279 -0
- package/docs/WORKFLOWS.md +602 -0
- package/docs/refactoring-summary-2025-10-17.md +365 -0
- package/docs/requirement-2025-10-17.md +508 -0
- package/package.json +64 -64
package/README.md
CHANGED
|
@@ -1,690 +1,302 @@
|
|
|
1
|
-
# sqlew
|
|
2
|
-

|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/sqlew)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
|
|
7
|
-
> **SQL Efficient Workflow** - MCP server for efficient context sharing between Claude Code sub-agents
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
**sqlew** is a Model Context Protocol (MCP) server that
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
→
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
"
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
###
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
action: "set_batch",
|
|
304
|
-
decisions: [
|
|
305
|
-
{ key: "api_v1", value: "REST", layer: "presentation" },
|
|
306
|
-
{ key: "api_v2", value: "GraphQL", layer: "presentation" }
|
|
307
|
-
],
|
|
308
|
-
atomic: true
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Check for updates (lightweight polling)
|
|
312
|
-
{
|
|
313
|
-
action: "has_updates",
|
|
314
|
-
agent_name: "my-agent",
|
|
315
|
-
since_timestamp: "2025-10-15T10:00:00Z"
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Advanced search with complex filtering
|
|
319
|
-
{
|
|
320
|
-
action: "search_advanced",
|
|
321
|
-
layers: ["business", "data"],
|
|
322
|
-
tags_all: ["security"],
|
|
323
|
-
search_text: "authentication",
|
|
324
|
-
status: "active",
|
|
325
|
-
limit: 20
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Set from template
|
|
329
|
-
{
|
|
330
|
-
action: "set_from_template",
|
|
331
|
-
template: "api-endpoint",
|
|
332
|
-
key: "user_api",
|
|
333
|
-
value: "GET /api/users"
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Get decision
|
|
337
|
-
{
|
|
338
|
-
action: "get",
|
|
339
|
-
key: "auth_method"
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Get version history
|
|
343
|
-
{
|
|
344
|
-
action: "versions",
|
|
345
|
-
key: "auth_method"
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Get help
|
|
349
|
-
{ action: "help" }
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### 2. `message` - Agent Messaging
|
|
353
|
-
|
|
354
|
-
Send and retrieve messages with priority levels.
|
|
355
|
-
|
|
356
|
-
**Actions:** `send`, `get`, `mark_read`, `send_batch`, `help`
|
|
357
|
-
|
|
358
|
-
**Examples:**
|
|
359
|
-
|
|
360
|
-
```typescript
|
|
361
|
-
// Send message
|
|
362
|
-
{
|
|
363
|
-
action: "send",
|
|
364
|
-
from_agent: "agent1",
|
|
365
|
-
to_agent: "agent2",
|
|
366
|
-
msg_type: "warning",
|
|
367
|
-
message: "File locked",
|
|
368
|
-
priority: "high",
|
|
369
|
-
payload: { file: "/src/auth.ts" }
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Batch send (up to 50 messages)
|
|
373
|
-
{
|
|
374
|
-
action: "send_batch",
|
|
375
|
-
messages: [
|
|
376
|
-
{
|
|
377
|
-
from_agent: "orchestrator",
|
|
378
|
-
to_agent: "auth-agent",
|
|
379
|
-
msg_type: "request",
|
|
380
|
-
message: "Start setup",
|
|
381
|
-
priority: "high"
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
from_agent: "orchestrator",
|
|
385
|
-
to_agent: "db-agent",
|
|
386
|
-
msg_type: "request",
|
|
387
|
-
message: "Initialize schema",
|
|
388
|
-
priority: "high"
|
|
389
|
-
}
|
|
390
|
-
]
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Get messages
|
|
394
|
-
{
|
|
395
|
-
action: "get",
|
|
396
|
-
agent_name: "agent1",
|
|
397
|
-
unread_only: true,
|
|
398
|
-
priority_filter: "high"
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// Mark as read
|
|
402
|
-
{
|
|
403
|
-
action: "mark_read",
|
|
404
|
-
agent_name: "agent1",
|
|
405
|
-
message_ids: [1, 2, 3]
|
|
406
|
-
}
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
### 3. `file` - File Change Tracking
|
|
410
|
-
|
|
411
|
-
Track file modifications with layer assignment.
|
|
412
|
-
|
|
413
|
-
**Actions:** `record`, `get`, `check_lock`, `record_batch`, `help`
|
|
414
|
-
|
|
415
|
-
**Examples:**
|
|
416
|
-
|
|
417
|
-
```typescript
|
|
418
|
-
// Record file change
|
|
419
|
-
{
|
|
420
|
-
action: "record",
|
|
421
|
-
file_path: "/src/auth.ts",
|
|
422
|
-
agent_name: "auth-agent",
|
|
423
|
-
change_type: "modified",
|
|
424
|
-
layer: "business",
|
|
425
|
-
description: "Updated JWT validation"
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// Batch record (up to 50 file changes)
|
|
429
|
-
{
|
|
430
|
-
action: "record_batch",
|
|
431
|
-
file_changes: [
|
|
432
|
-
{
|
|
433
|
-
file_path: "/src/auth/jwt.ts",
|
|
434
|
-
agent_name: "auth-agent",
|
|
435
|
-
change_type: "created",
|
|
436
|
-
layer: "business"
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
file_path: "/src/auth/validation.ts",
|
|
440
|
-
agent_name: "auth-agent",
|
|
441
|
-
change_type: "created",
|
|
442
|
-
layer: "business"
|
|
443
|
-
}
|
|
444
|
-
]
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// Get file changes
|
|
448
|
-
{
|
|
449
|
-
action: "get",
|
|
450
|
-
since: "2025-10-15T10:00:00Z",
|
|
451
|
-
layer: "business"
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// Check file lock
|
|
455
|
-
{
|
|
456
|
-
action: "check_lock",
|
|
457
|
-
file_path: "/src/auth.ts",
|
|
458
|
-
lock_duration: 300
|
|
459
|
-
}
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
### 4. `constraint` - Constraint Management
|
|
463
|
-
|
|
464
|
-
Manage architectural, performance, and security constraints.
|
|
465
|
-
|
|
466
|
-
**Actions:** `add`, `get`, `deactivate`, `help`
|
|
467
|
-
|
|
468
|
-
**Examples:**
|
|
469
|
-
|
|
470
|
-
```typescript
|
|
471
|
-
// Add constraint
|
|
472
|
-
{
|
|
473
|
-
action: "add",
|
|
474
|
-
category: "performance",
|
|
475
|
-
constraint_text: "Response time < 200ms",
|
|
476
|
-
priority: "high",
|
|
477
|
-
layer: "business",
|
|
478
|
-
tags: ["api", "performance"]
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
// Get constraints
|
|
482
|
-
{
|
|
483
|
-
action: "get",
|
|
484
|
-
category: "performance",
|
|
485
|
-
active_only: true
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// Deactivate constraint
|
|
489
|
-
{
|
|
490
|
-
action: "deactivate",
|
|
491
|
-
constraint_id: 42
|
|
492
|
-
}
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### 5. `stats` - Statistics & Utilities
|
|
496
|
-
|
|
497
|
-
Get database statistics and manage data cleanup.
|
|
498
|
-
|
|
499
|
-
**Actions:** `layer_summary`, `db_stats`, `clear`, `activity_log`, `help`
|
|
500
|
-
|
|
501
|
-
**Examples:**
|
|
502
|
-
|
|
503
|
-
```typescript
|
|
504
|
-
// Layer summary
|
|
505
|
-
{ action: "layer_summary" }
|
|
506
|
-
|
|
507
|
-
// Database stats
|
|
508
|
-
{ action: "db_stats" }
|
|
509
|
-
|
|
510
|
-
// Activity log (v2.1.0)
|
|
511
|
-
{
|
|
512
|
-
action: "activity_log",
|
|
513
|
-
since: "1h",
|
|
514
|
-
agent_names: ["auth-agent"],
|
|
515
|
-
limit: 100
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// Clear old data (weekend-aware)
|
|
519
|
-
{
|
|
520
|
-
action: "clear",
|
|
521
|
-
messages_older_than_hours: 48,
|
|
522
|
-
file_changes_older_than_days: 14
|
|
523
|
-
}
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
### 6. `config` - Configuration
|
|
527
|
-
|
|
528
|
-
Manage auto-deletion and retention settings.
|
|
529
|
-
|
|
530
|
-
**Actions:** `get`, `update`, `help`
|
|
531
|
-
|
|
532
|
-
**Examples:**
|
|
533
|
-
|
|
534
|
-
```typescript
|
|
535
|
-
// Get config
|
|
536
|
-
{ action: "get" }
|
|
537
|
-
|
|
538
|
-
// Update config
|
|
539
|
-
{
|
|
540
|
-
action: "update",
|
|
541
|
-
ignoreWeekend: true,
|
|
542
|
-
messageRetentionHours: 48,
|
|
543
|
-
fileHistoryRetentionDays: 10
|
|
544
|
-
}
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
## CLI Tool (v2.1.0)
|
|
548
|
-
|
|
549
|
-
Query your database directly from terminal without MCP server.
|
|
550
|
-
|
|
551
|
-
### Available Commands
|
|
552
|
-
|
|
553
|
-
```bash
|
|
554
|
-
# Query decisions
|
|
555
|
-
npx sqlew-cli query decisions --layer=business --tags=breaking --output=table
|
|
556
|
-
|
|
557
|
-
# Query messages
|
|
558
|
-
npx sqlew-cli query messages --unread --priority=high --output=json
|
|
559
|
-
|
|
560
|
-
# Query file changes
|
|
561
|
-
npx sqlew-cli query files --since=1h --layer=data --output=table
|
|
562
|
-
|
|
563
|
-
# Query activity log
|
|
564
|
-
npx sqlew-cli query activity --since=5m --agent=* --output=json
|
|
565
|
-
```
|
|
566
|
-
|
|
567
|
-
### Common Options
|
|
568
|
-
|
|
569
|
-
- `--output <format>` - Output format: `json` or `table` (default: json)
|
|
570
|
-
- `--layer <layer>` - Filter by layer
|
|
571
|
-
- `--tags <tags>` - Filter by tags (comma-separated)
|
|
572
|
-
- `--since <time>` - Time filter (e.g., "5m", "1h", "2d", or ISO timestamp)
|
|
573
|
-
- `--limit <number>` - Limit results
|
|
574
|
-
- `--db-path <path>` - Custom database path
|
|
575
|
-
- `--help` - Show help
|
|
576
|
-
|
|
577
|
-
## Architecture Layers
|
|
578
|
-
|
|
579
|
-
sqlew organizes code by standard architecture layers:
|
|
580
|
-
|
|
581
|
-
- **presentation** - UI, API endpoints, views
|
|
582
|
-
- **business** - Business logic, services, use cases
|
|
583
|
-
- **data** - Repositories, database access
|
|
584
|
-
- **infrastructure** - Configuration, external services
|
|
585
|
-
- **cross-cutting** - Logging, security, utilities
|
|
586
|
-
|
|
587
|
-
## Database Schema
|
|
588
|
-
|
|
589
|
-
**Master Tables (m_ prefix):** Normalization layer (agents, files, keys, layers, tags, scopes, categories, config, templates)
|
|
590
|
-
|
|
591
|
-
**Transaction Tables (t_ prefix):** Core data (decisions, history, messages, file changes, constraints, activity log)
|
|
592
|
-
|
|
593
|
-
**Views (v_ prefix):** Token-efficient pre-aggregated queries
|
|
594
|
-
|
|
595
|
-
**Triggers (trg_ prefix):** Automatic version history and activity logging
|
|
596
|
-
|
|
597
|
-
### Automatic Migration
|
|
598
|
-
|
|
599
|
-
- **v1.x → v2.x:** Automatic migration adds table prefixes and new features
|
|
600
|
-
- **v2.0 → v2.1:** Adds activity log and template tables
|
|
601
|
-
- All migrations are safe with rollback protection
|
|
602
|
-
|
|
603
|
-
## Development
|
|
604
|
-
|
|
605
|
-
### Building from Source
|
|
606
|
-
|
|
607
|
-
```bash
|
|
608
|
-
git clone https://github.com/sin5ddd/mcp-sqlew.git
|
|
609
|
-
cd mcp-sqlew
|
|
610
|
-
npm install
|
|
611
|
-
npm run build
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
### Available Scripts
|
|
615
|
-
|
|
616
|
-
```bash
|
|
617
|
-
npm start # Start MCP server
|
|
618
|
-
npm run cli # Run CLI tool
|
|
619
|
-
npm run inspector # Test with MCP Inspector
|
|
620
|
-
npm run build # Build TypeScript
|
|
621
|
-
npm run dev # Watch mode
|
|
622
|
-
npm run rebuild # Clean and rebuild
|
|
623
|
-
```
|
|
624
|
-
|
|
625
|
-
## Configuration
|
|
626
|
-
|
|
627
|
-
### Retention Periods (Defaults)
|
|
628
|
-
|
|
629
|
-
- **Messages:** 24 hours (weekend-aware optional)
|
|
630
|
-
- **File Changes:** 7 days (weekend-aware optional)
|
|
631
|
-
- **Decisions:** Permanent (version history preserved)
|
|
632
|
-
- **Constraints:** Permanent (soft delete only)
|
|
633
|
-
|
|
634
|
-
### Weekend-Aware Cleanup
|
|
635
|
-
|
|
636
|
-
When enabled, weekends (Saturday/Sunday) don't count toward retention periods:
|
|
637
|
-
|
|
638
|
-
- Message sent Friday 3pm → Deleted Monday 3pm (skips weekend)
|
|
639
|
-
- Message sent Monday 10am → Deleted Tuesday 10am
|
|
640
|
-
|
|
641
|
-
Configure via CLI args or MCP tools at runtime.
|
|
642
|
-
|
|
643
|
-
## Migration Guide
|
|
644
|
-
|
|
645
|
-
### From v2.1.0 to v2.1.1
|
|
646
|
-
|
|
647
|
-
No breaking changes. Only bin command configuration changed:
|
|
648
|
-
|
|
649
|
-
- **Old:** `npx sqlew` → CLI, `npx sqlew-server` → MCP server
|
|
650
|
-
- **New:** `npx sqlew` → MCP server (default), `sqlew-cli` → CLI (after installing the package)
|
|
651
|
-
|
|
652
|
-
Update Claude Desktop config if using custom commands.
|
|
653
|
-
|
|
654
|
-
### From v2.0.0 to v2.1.0
|
|
655
|
-
|
|
656
|
-
No breaking changes. Database migrates automatically on startup.
|
|
657
|
-
|
|
658
|
-
New features are opt-in via new actions.
|
|
659
|
-
|
|
660
|
-
### From v1.x to v2.0.0
|
|
661
|
-
|
|
662
|
-
Requires migration. See [MIGRATION_v2.md](MIGRATION_v2.md) for details.
|
|
663
|
-
|
|
664
|
-
## License
|
|
665
|
-
|
|
666
|
-
MIT - see [LICENSE](LICENSE) file for details
|
|
667
|
-
|
|
668
|
-
## Links
|
|
669
|
-
|
|
670
|
-
- [npm package](https://www.npmjs.com/package/sqlew)
|
|
671
|
-
- [GitHub repository](https://github.com/sin5ddd/mcp-sqlew)
|
|
672
|
-
- [Changelog](CHANGELOG.md)
|
|
673
|
-
- [Architecture Documentation](ARCHITECTURE.md)
|
|
674
|
-
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
675
|
-
|
|
676
|
-
## Author
|
|
677
|
-
|
|
678
|
-
**sin5ddd**
|
|
679
|
-
|
|
680
|
-
## Support
|
|
681
|
-
|
|
682
|
-
- **Issues:** [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
|
|
683
|
-
- **Documentation:** See [ARCHITECTURE.md](ARCHITECTURE.md) for technical details
|
|
684
|
-
|
|
685
|
-
## Acknowledgments
|
|
686
|
-
|
|
687
|
-
Built with:
|
|
688
|
-
- [Model Context Protocol SDK](https://github.com/modelcontextprotocol/sdk)
|
|
689
|
-
- [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
|
|
690
|
-
- TypeScript
|
|
1
|
+
# sqlew
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/sqlew)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
> **SQL Efficient Workflow** - MCP server for efficient context sharing between Claude Code sub-agents
|
|
8
|
+
|
|
9
|
+
## What is sqlew?
|
|
10
|
+
|
|
11
|
+
**sqlew** is a Model Context Protocol (MCP) server that gives AI agents organizational memory. It solves a critical problem: **AI agents can't remember decisions across sessions**.
|
|
12
|
+
|
|
13
|
+
### The Problem
|
|
14
|
+
|
|
15
|
+
Without sqlew:
|
|
16
|
+
- 🔴 Every new Claude session starts with zero context
|
|
17
|
+
- 🔴 Must re-explain architectural decisions every time
|
|
18
|
+
- 🔴 Agents can reintroduce bugs that were already fixed
|
|
19
|
+
- 🔴 No way to track WHY decisions were made
|
|
20
|
+
|
|
21
|
+
### The Solution
|
|
22
|
+
|
|
23
|
+
With sqlew, AI agents can:
|
|
24
|
+
- ✅ **Remember** architectural decisions across sessions
|
|
25
|
+
- ✅ **Query** past context: "What breaking changes were made to the API?"
|
|
26
|
+
- ✅ **Prevent** regressions by storing constraints: "Duration must NOT occur in Loom module"
|
|
27
|
+
- ✅ **Coordinate** between multiple agents with messaging and task tracking
|
|
28
|
+
|
|
29
|
+
**Real-World Example:**
|
|
30
|
+
```typescript
|
|
31
|
+
// Agent in Session 1 records:
|
|
32
|
+
{
|
|
33
|
+
key: "api_v1_deprecated",
|
|
34
|
+
value: "/v1/users endpoint deprecated, use /v2/users",
|
|
35
|
+
tags: ["api", "breaking-change"]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Agent in Session 2 (days later) queries:
|
|
39
|
+
"What API changes should I know about?"
|
|
40
|
+
→ Finds the deprecation decision
|
|
41
|
+
→ Uses /v2/users endpoint automatically!
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Why Use sqlew?
|
|
45
|
+
|
|
46
|
+
### 🧠 Organizational Memory
|
|
47
|
+
Traditional code only tells you **WHAT** and **HOW**. sqlew adds **WHY**:
|
|
48
|
+
- Git history → WHAT changed
|
|
49
|
+
- Code comments → HOW it works
|
|
50
|
+
- **sqlew decisions** → **WHY** it was changed
|
|
51
|
+
- **sqlew constraints** → **WHY** it must work this way
|
|
52
|
+
|
|
53
|
+
### ⚡ Token Efficiency
|
|
54
|
+
**60-75% token reduction** in multi-session projects:
|
|
55
|
+
- Store decisions once, query selectively
|
|
56
|
+
- Structured data (20-30 tokens) vs prose (50-200 tokens)
|
|
57
|
+
- Cross-session persistence eliminates context re-explanation
|
|
58
|
+
|
|
59
|
+
### 🎯 Key Features
|
|
60
|
+
- **7 Specialized Tools**: decisions, messages, tasks, files, constraints, stats, config
|
|
61
|
+
- **Metadata-Driven**: Tag, layer, scope, and version everything
|
|
62
|
+
- **Auto-Stale Detection**: Tasks automatically transition when idle
|
|
63
|
+
- **Weekend-Aware Cleanup**: Smart retention that pauses during weekends
|
|
64
|
+
- **Batch Operations**: Process up to 50 items atomically
|
|
65
|
+
|
|
66
|
+
### 🔖Kanban-style AI Scrum
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
### Requirements
|
|
72
|
+
- Node.js 18.0.0 or higher
|
|
73
|
+
- npm or npx
|
|
74
|
+
|
|
75
|
+
### Quick Install
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install sqlew
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Add to Claude Desktop
|
|
82
|
+
|
|
83
|
+
Edit `claude_desktop_config.json`:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"sqlew": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["sqlew"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
That's it! Restart Claude Desktop and sqlew is ready.
|
|
97
|
+
|
|
98
|
+
### Custom Database Path (Optional)
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"mcpServers": {
|
|
103
|
+
"sqlew": {
|
|
104
|
+
"command": "npx",
|
|
105
|
+
"args": ["sqlew", "/path/to/database.db"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Default location: `.sqlew/sqlew.db` in current directory
|
|
112
|
+
|
|
113
|
+
## Quick Start
|
|
114
|
+
|
|
115
|
+
### For AI Agents
|
|
116
|
+
|
|
117
|
+
⚠️ **Most Important Rule**: ALWAYS include the `action` parameter in every tool call.
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// ❌ WRONG
|
|
121
|
+
{key: "auth_method", value: "jwt"}
|
|
122
|
+
|
|
123
|
+
// ✅ CORRECT
|
|
124
|
+
{action: "set", key: "auth_method", value: "jwt", layer: "business"}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Basic Usage
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
// Store a decision
|
|
131
|
+
{
|
|
132
|
+
action: "set",
|
|
133
|
+
key: "auth_method",
|
|
134
|
+
value: "JWT with refresh tokens",
|
|
135
|
+
layer: "business",
|
|
136
|
+
tags: ["authentication", "security"]
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Query it later
|
|
140
|
+
{
|
|
141
|
+
action: "get",
|
|
142
|
+
key: "auth_method"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Search by tags
|
|
146
|
+
{
|
|
147
|
+
action: "search_tags",
|
|
148
|
+
tags: ["security"],
|
|
149
|
+
status: "active"
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Available Tools
|
|
154
|
+
|
|
155
|
+
| Tool | Purpose | Example Use |
|
|
156
|
+
|------|---------|------------|
|
|
157
|
+
| **decision** | Record choices | "We chose PostgreSQL" |
|
|
158
|
+
| **message** | Agent communication | "Task completed" |
|
|
159
|
+
| **task** | Track work | "Implement feature X" |
|
|
160
|
+
| **file** | Track changes | "Modified auth.ts" |
|
|
161
|
+
| **constraint** | Define rules | "API must be <100ms" |
|
|
162
|
+
| **stats** | Database metrics | Get layer summary |
|
|
163
|
+
| **config** | Retention settings | Auto-cleanup config |
|
|
164
|
+
|
|
165
|
+
Each tool supports `action: "help"` for full documentation and `action: "example"` for comprehensive usage examples.
|
|
166
|
+
|
|
167
|
+
## Documentation
|
|
168
|
+
|
|
169
|
+
### On-Demand Documentation
|
|
170
|
+
|
|
171
|
+
**All tools provide built-in documentation with zero upfront token cost:**
|
|
172
|
+
- `action: "help"` - Detailed parameter reference, action descriptions, examples
|
|
173
|
+
- `action: "example"` - Comprehensive usage scenarios, workflows, best practices
|
|
174
|
+
|
|
175
|
+
**Example:**
|
|
176
|
+
```javascript
|
|
177
|
+
// Get detailed help for decision tool
|
|
178
|
+
{action: "help"}
|
|
179
|
+
|
|
180
|
+
// Get comprehensive examples for task tool
|
|
181
|
+
{action: "example"}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### For AI Agents (68% Token Reduction)
|
|
185
|
+
|
|
186
|
+
**Tool Selection & Workflows:**
|
|
187
|
+
- 📖 **[Tool Selection](docs/TOOL_SELECTION.md)** - Decision tree, when to use each tool (236 lines, ~12k tokens)
|
|
188
|
+
- 🔄 **[Workflows](docs/WORKFLOWS.md)** - Multi-step examples, multi-agent coordination (602 lines, ~30k tokens)
|
|
189
|
+
- 📚 **[Tool Reference](docs/TOOL_REFERENCE.md)** - Parameters, batch operations, templates (471 lines, ~24k tokens)
|
|
190
|
+
- ✅ **[Best Practices](docs/BEST_PRACTICES.md)** - Common errors, troubleshooting (345 lines, ~17k tokens)
|
|
191
|
+
|
|
192
|
+
**Task System:**
|
|
193
|
+
- 📋 **[Task Overview](docs/TASK_OVERVIEW.md)** - Lifecycle, status transitions, auto-stale (363 lines, ~10k tokens)
|
|
194
|
+
- ⚙️ **[Task Actions](docs/TASK_ACTIONS.md)** - All actions with examples (854 lines, ~21k tokens)
|
|
195
|
+
- 🔗 **[Task Linking](docs/TASK_LINKING.md)** - Link tasks to decisions/constraints/files (729 lines, ~18k tokens)
|
|
196
|
+
- 🔄 **[Task Migration](docs/TASK_MIGRATION.md)** - Migrate from decision-based tracking (701 lines, ~18k tokens)
|
|
197
|
+
|
|
198
|
+
**Shared References:**
|
|
199
|
+
- 📘 **[Shared Concepts](docs/SHARED_CONCEPTS.md)** - Layer definitions, enum values, atomic mode (339 lines, ~17k tokens)
|
|
200
|
+
- 🏗️ **[Architecture](docs/ARCHITECTURE.md)** - Technical architecture and database schema
|
|
201
|
+
|
|
202
|
+
### For Developers
|
|
203
|
+
|
|
204
|
+
- **[Building from Source](docs/ARCHITECTURE.md#development)** - Setup and build instructions
|
|
205
|
+
- **[Migration Guides](docs/MIGRATION_v2.md)** - Version upgrade guides
|
|
206
|
+
- **[CLI Tool](docs/AI_AGENT_GUIDE.md#cli-usage)** - Query database from terminal
|
|
207
|
+
|
|
208
|
+
## Examples
|
|
209
|
+
|
|
210
|
+
### Multi-Agent Coordination
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
// Orchestrator creates tasks
|
|
214
|
+
{
|
|
215
|
+
action: "batch_create",
|
|
216
|
+
tasks: [
|
|
217
|
+
{title: "Setup database", assigned_agent: "db-agent"},
|
|
218
|
+
{title: "Create API", assigned_agent: "api-agent"}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Agents send status updates
|
|
223
|
+
{
|
|
224
|
+
action: "send",
|
|
225
|
+
from_agent: "db-agent",
|
|
226
|
+
to_agent: "orchestrator",
|
|
227
|
+
message: "Database ready",
|
|
228
|
+
priority: "high"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Breaking Change Management
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
// Record deprecation
|
|
236
|
+
{
|
|
237
|
+
action: "set",
|
|
238
|
+
key: "api_v1_deprecated",
|
|
239
|
+
value: "/v1 endpoints deprecated, use /v2",
|
|
240
|
+
tags: ["breaking-change", "api"]
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Add constraint
|
|
244
|
+
{
|
|
245
|
+
action: "add",
|
|
246
|
+
category: "architecture",
|
|
247
|
+
constraint_text: "All endpoints must use /v2 prefix",
|
|
248
|
+
priority: "high"
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Session Continuity
|
|
253
|
+
|
|
254
|
+
```javascript
|
|
255
|
+
// Session 1: Save state
|
|
256
|
+
{
|
|
257
|
+
action: "set",
|
|
258
|
+
key: "refactor_progress",
|
|
259
|
+
value: "Completed 3/5 modules",
|
|
260
|
+
tags: ["session-state"]
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Session 2: Resume work
|
|
264
|
+
{
|
|
265
|
+
action: "get",
|
|
266
|
+
key: "refactor_progress"
|
|
267
|
+
}
|
|
268
|
+
// → Returns: "Completed 3/5 modules"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Performance
|
|
272
|
+
|
|
273
|
+
- **Query speed**: 2-50ms
|
|
274
|
+
- **Concurrent agents**: 5+ simultaneous
|
|
275
|
+
- **Storage efficiency**: ~140 bytes per decision
|
|
276
|
+
- **Token savings**: 60-75% in typical projects
|
|
277
|
+
|
|
278
|
+
## Version
|
|
279
|
+
|
|
280
|
+
Current version: **3.0.0**
|
|
281
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT - see [LICENSE](LICENSE) file
|
|
286
|
+
|
|
287
|
+
## Links
|
|
288
|
+
|
|
289
|
+
- [npm package](https://www.npmjs.com/package/sqlew)
|
|
290
|
+
- [GitHub repository](https://github.com/sin5ddd/mcp-sqlew)
|
|
291
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
292
|
+
|
|
293
|
+
## Support
|
|
294
|
+
|
|
295
|
+
- **Issues**: [GitHub Issues](https://github.com/sin5ddd/mcp-sqlew/issues)
|
|
296
|
+
- **Documentation**: [docs/](docs/) directory
|
|
297
|
+
|
|
298
|
+
## Acknowledgments
|
|
299
|
+
|
|
300
|
+
Built with [Model Context Protocol SDK](https://github.com/modelcontextprotocol/sdk), [better-sqlite3](https://github.com/WiseLibs/better-sqlite3), and TypeScript.
|
|
301
|
+
|
|
302
|
+
**Author**: sin5ddd
|