sqlew 2.1.2 → 2.1.4
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 +94 -0
- package/README.md +77 -0
- package/dist/index.js +199 -7
- package/dist/index.js.map +1 -1
- package/dist/tools/context.js +12 -12
- package/dist/tools/context.js.map +1 -1
- package/docs/AI_AGENT_GUIDE.md +648 -0
- package/package.json +3 -2
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
# AI Agent Guide for MCP SQLew
|
|
2
|
+
|
|
3
|
+
**Quick Reference for Claude Code and other AI agents using sqlew**
|
|
4
|
+
|
|
5
|
+
## 🚨 Most Important Rule
|
|
6
|
+
|
|
7
|
+
**ALWAYS include the `action` parameter in EVERY tool call.** This is the #1 cause of errors.
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
// ❌ WRONG - Missing action
|
|
11
|
+
{
|
|
12
|
+
key: "some_key",
|
|
13
|
+
value: "some value"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ✅ CORRECT - action parameter present
|
|
17
|
+
{
|
|
18
|
+
action: "set",
|
|
19
|
+
key: "some_key",
|
|
20
|
+
value: "some value"
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Table of Contents
|
|
27
|
+
|
|
28
|
+
1. [Quick Start](#quick-start)
|
|
29
|
+
2. [Parameter Requirements by Tool](#parameter-requirements-by-tool)
|
|
30
|
+
3. [Common Errors & Solutions](#common-errors--solutions)
|
|
31
|
+
4. [Search Actions Decision Tree](#search-actions-decision-tree)
|
|
32
|
+
5. [Batch Operations Guide](#batch-operations-guide)
|
|
33
|
+
6. [Template System](#template-system)
|
|
34
|
+
7. [Best Practices](#best-practices)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
### Basic Decision Workflow
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
// 1. Set a decision
|
|
44
|
+
{
|
|
45
|
+
action: "set",
|
|
46
|
+
key: "auth_method",
|
|
47
|
+
value: "jwt",
|
|
48
|
+
layer: "business",
|
|
49
|
+
tags: ["security", "authentication"]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 2. Get the decision
|
|
53
|
+
{
|
|
54
|
+
action: "get",
|
|
55
|
+
key: "auth_method"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 3. List decisions with filters
|
|
59
|
+
{
|
|
60
|
+
action: "list",
|
|
61
|
+
status: "active",
|
|
62
|
+
layer: "business"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Basic Messaging Workflow
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// 1. Send a message
|
|
70
|
+
{
|
|
71
|
+
action: "send",
|
|
72
|
+
from_agent: "bot1",
|
|
73
|
+
msg_type: "info",
|
|
74
|
+
message: "Task completed successfully",
|
|
75
|
+
priority: "high"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 2. Get messages
|
|
79
|
+
{
|
|
80
|
+
action: "get",
|
|
81
|
+
agent_name: "bot1",
|
|
82
|
+
unread_only: true
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 3. Mark as read
|
|
86
|
+
{
|
|
87
|
+
action: "mark_read",
|
|
88
|
+
agent_name: "bot1",
|
|
89
|
+
message_ids: [1, 2, 3]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Parameter Requirements by Tool
|
|
96
|
+
|
|
97
|
+
### `decision` Tool
|
|
98
|
+
|
|
99
|
+
| Action | Required | Optional |
|
|
100
|
+
|--------|----------|----------|
|
|
101
|
+
| **set** | action, key, value, layer | agent, version, status, tags, scopes |
|
|
102
|
+
| **get** | action, key | version |
|
|
103
|
+
| **list** | action | status, layer, tags, scope, tag_match, limit, offset |
|
|
104
|
+
| **search_tags** | action, tags | match_mode, status, layer |
|
|
105
|
+
| **search_layer** | action, layer | status, include_tags |
|
|
106
|
+
| **versions** | action, key | - |
|
|
107
|
+
| **quick_set** | action, key, value | agent, layer, version, status, tags, scopes |
|
|
108
|
+
| **search_advanced** | action | layers, tags_all, tags_any, exclude_tags, scopes, updated_after, updated_before, decided_by, statuses, search_text, sort_by, sort_order, limit, offset |
|
|
109
|
+
| **set_batch** | action, decisions | atomic |
|
|
110
|
+
| **has_updates** | action, agent_name, since_timestamp | - |
|
|
111
|
+
| **set_from_template** | action, template, key, value, layer | agent, version, status, tags, scopes |
|
|
112
|
+
| **create_template** | action, name, defaults | required_fields, created_by |
|
|
113
|
+
| **list_templates** | action | - |
|
|
114
|
+
|
|
115
|
+
### `message` Tool
|
|
116
|
+
|
|
117
|
+
| Action | Required | Optional |
|
|
118
|
+
|--------|----------|----------|
|
|
119
|
+
| **send** | action, from_agent, msg_type, message | to_agent, priority, payload |
|
|
120
|
+
| **get** | action, agent_name | unread_only, priority_filter, msg_type_filter, limit |
|
|
121
|
+
| **mark_read** | action, agent_name, message_ids | - |
|
|
122
|
+
| **send_batch** | action, messages | atomic |
|
|
123
|
+
|
|
124
|
+
### `file` Tool
|
|
125
|
+
|
|
126
|
+
| Action | Required | Optional |
|
|
127
|
+
|--------|----------|----------|
|
|
128
|
+
| **record** | action, file_path, agent_name, change_type | layer, description |
|
|
129
|
+
| **get** | action | file_path, agent_name, layer, change_type, since, limit |
|
|
130
|
+
| **check_lock** | action, file_path | lock_duration |
|
|
131
|
+
| **record_batch** | action, file_changes | atomic |
|
|
132
|
+
|
|
133
|
+
### `constraint` Tool
|
|
134
|
+
|
|
135
|
+
| Action | Required | Optional |
|
|
136
|
+
|--------|----------|----------|
|
|
137
|
+
| **add** | action, category, constraint_text | priority, layer, tags, created_by |
|
|
138
|
+
| **get** | action | category, layer, priority, tags, active_only, limit |
|
|
139
|
+
| **deactivate** | action, constraint_id | - |
|
|
140
|
+
|
|
141
|
+
### `stats` Tool
|
|
142
|
+
|
|
143
|
+
| Action | Required | Optional |
|
|
144
|
+
|--------|----------|----------|
|
|
145
|
+
| **layer_summary** | action | - |
|
|
146
|
+
| **db_stats** | action | - |
|
|
147
|
+
| **clear** | action | messages_older_than_hours, file_changes_older_than_days |
|
|
148
|
+
| **activity_log** | action | since, agent_names, actions, limit |
|
|
149
|
+
|
|
150
|
+
### `config` Tool
|
|
151
|
+
|
|
152
|
+
| Action | Required | Optional |
|
|
153
|
+
|--------|----------|----------|
|
|
154
|
+
| **get** | action | - |
|
|
155
|
+
| **update** | action | ignoreWeekend, messageRetentionHours, fileHistoryRetentionDays |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Common Errors & Solutions
|
|
160
|
+
|
|
161
|
+
### Error: "Unknown action: undefined"
|
|
162
|
+
|
|
163
|
+
**Cause**: Missing `action` parameter
|
|
164
|
+
|
|
165
|
+
**Solution**: Always include `action` as the first parameter
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
// ❌ WRONG
|
|
169
|
+
{
|
|
170
|
+
key: "some_key",
|
|
171
|
+
value: "some value",
|
|
172
|
+
layer: "business"
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ✅ CORRECT
|
|
176
|
+
{
|
|
177
|
+
action: "set",
|
|
178
|
+
key: "some_key",
|
|
179
|
+
value: "some value",
|
|
180
|
+
layer: "business"
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Error: "Parameter \"value\" is required"
|
|
185
|
+
|
|
186
|
+
**Cause**: Using `defaults` instead of direct parameters with templates
|
|
187
|
+
|
|
188
|
+
**Solution**: Provide parameters directly, not nested in `defaults`
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
// ❌ WRONG
|
|
192
|
+
{
|
|
193
|
+
action: "set_from_template",
|
|
194
|
+
template: "deprecation",
|
|
195
|
+
key: "some_key",
|
|
196
|
+
defaults: {
|
|
197
|
+
value: "...",
|
|
198
|
+
layer: "cross-cutting"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ✅ CORRECT
|
|
203
|
+
{
|
|
204
|
+
action: "set_from_template",
|
|
205
|
+
template: "deprecation",
|
|
206
|
+
key: "some_key",
|
|
207
|
+
value: "...",
|
|
208
|
+
layer: "cross-cutting"
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Error: "Invalid layer"
|
|
213
|
+
|
|
214
|
+
**Cause**: Using a layer name that doesn't exist
|
|
215
|
+
|
|
216
|
+
**Solution**: Use one of the 5 standard layers
|
|
217
|
+
|
|
218
|
+
**Valid layers**: `presentation`, `business`, `data`, `infrastructure`, `cross-cutting`
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
// ❌ WRONG
|
|
222
|
+
{
|
|
223
|
+
action: "set",
|
|
224
|
+
key: "my_key",
|
|
225
|
+
value: "my_value",
|
|
226
|
+
layer: "backend" // Invalid!
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ✅ CORRECT
|
|
230
|
+
{
|
|
231
|
+
action: "set",
|
|
232
|
+
key: "my_key",
|
|
233
|
+
value: "my_value",
|
|
234
|
+
layer: "business" // Valid!
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Error: "Invalid status"
|
|
239
|
+
|
|
240
|
+
**Cause**: Using a status value that doesn't exist
|
|
241
|
+
|
|
242
|
+
**Solution**: Use one of the 3 valid statuses
|
|
243
|
+
|
|
244
|
+
**Valid statuses**: `active`, `deprecated`, `draft`
|
|
245
|
+
|
|
246
|
+
### Error: "Batch operations are limited to 50 items maximum"
|
|
247
|
+
|
|
248
|
+
**Cause**: Too many items in batch array
|
|
249
|
+
|
|
250
|
+
**Solution**: Split into multiple batches of ≤50 items each
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Search Actions Decision Tree
|
|
255
|
+
|
|
256
|
+
### When to use which search action?
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
┌─────────────────────────────────────┐
|
|
260
|
+
│ What do you want to search by? │
|
|
261
|
+
└──────────┬──────────────────────────┘
|
|
262
|
+
│
|
|
263
|
+
├─ Simple filters (status, layer, tags)?
|
|
264
|
+
│ └─> Use action: "list"
|
|
265
|
+
│
|
|
266
|
+
├─ Primarily by tags?
|
|
267
|
+
│ └─> Use action: "search_tags"
|
|
268
|
+
│ • match_mode: "AND" (all tags) or "OR" (any tag)
|
|
269
|
+
│
|
|
270
|
+
├─ Primarily by layer?
|
|
271
|
+
│ └─> Use action: "search_layer"
|
|
272
|
+
│
|
|
273
|
+
├─ Complex multi-filter query?
|
|
274
|
+
│ └─> Use action: "search_advanced"
|
|
275
|
+
│ • Multiple layers (OR)
|
|
276
|
+
│ • Tag combinations (AND/OR)
|
|
277
|
+
│ • Temporal filtering
|
|
278
|
+
│ • Full-text search
|
|
279
|
+
│ • Pagination
|
|
280
|
+
│
|
|
281
|
+
└─ Need version history?
|
|
282
|
+
└─> Use action: "versions"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Detailed Search Comparison
|
|
286
|
+
|
|
287
|
+
| Action | Use When | Key Features |
|
|
288
|
+
|--------|----------|--------------|
|
|
289
|
+
| **list** | Basic filtering | Simple status/layer/tag filters, no pagination |
|
|
290
|
+
| **search_tags** | Tag-focused search | AND/OR logic for tags, optional status/layer |
|
|
291
|
+
| **search_layer** | Layer-focused search | Get all decisions in specific layer(s) |
|
|
292
|
+
| **search_advanced** | Complex queries | Full filtering, pagination, sorting, text search |
|
|
293
|
+
| **versions** | History tracking | Get all versions of a specific decision |
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Batch Operations Guide
|
|
298
|
+
|
|
299
|
+
### Atomic vs Non-Atomic Mode
|
|
300
|
+
|
|
301
|
+
**Atomic Mode** (`atomic: true`, default):
|
|
302
|
+
- All succeed or all fail as a single transaction
|
|
303
|
+
- If ANY item fails, entire batch is rolled back
|
|
304
|
+
- Error is thrown immediately on first failure
|
|
305
|
+
- Use for: Critical operations requiring consistency
|
|
306
|
+
|
|
307
|
+
**Non-Atomic Mode** (`atomic: false`, **recommended for AI agents**):
|
|
308
|
+
- Each item processed independently
|
|
309
|
+
- If some fail, others still succeed
|
|
310
|
+
- Returns partial results with per-item success/error status
|
|
311
|
+
- Use for: Best-effort batch operations, when individual failures are acceptable
|
|
312
|
+
|
|
313
|
+
### Batch Operation Examples
|
|
314
|
+
|
|
315
|
+
#### Decision Batch (Recommended: atomic: false)
|
|
316
|
+
|
|
317
|
+
```javascript
|
|
318
|
+
{
|
|
319
|
+
action: "set_batch",
|
|
320
|
+
atomic: false, // Recommended for AI agents
|
|
321
|
+
decisions: [
|
|
322
|
+
{
|
|
323
|
+
key: "feature-1",
|
|
324
|
+
value: "Implemented user authentication",
|
|
325
|
+
layer: "business",
|
|
326
|
+
tags: ["feature", "auth"],
|
|
327
|
+
status: "active"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
key: "feature-2",
|
|
331
|
+
value: "Added rate limiting",
|
|
332
|
+
layer: "infrastructure",
|
|
333
|
+
tags: ["feature", "security"],
|
|
334
|
+
status: "active"
|
|
335
|
+
}
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Response Format:**
|
|
341
|
+
```json
|
|
342
|
+
{
|
|
343
|
+
"success": true,
|
|
344
|
+
"inserted": 2,
|
|
345
|
+
"failed": 0,
|
|
346
|
+
"results": [
|
|
347
|
+
{
|
|
348
|
+
"key": "feature-1",
|
|
349
|
+
"key_id": 123,
|
|
350
|
+
"version": "1.0.0",
|
|
351
|
+
"success": true
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"key": "feature-2",
|
|
355
|
+
"key_id": 124,
|
|
356
|
+
"version": "1.0.0",
|
|
357
|
+
"success": true
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
#### Message Batch
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
{
|
|
367
|
+
action: "send_batch",
|
|
368
|
+
atomic: false,
|
|
369
|
+
messages: [
|
|
370
|
+
{
|
|
371
|
+
from_agent: "bot1",
|
|
372
|
+
msg_type: "info",
|
|
373
|
+
message: "Task 1 completed",
|
|
374
|
+
priority: "medium"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
from_agent: "bot1",
|
|
378
|
+
msg_type: "info",
|
|
379
|
+
message: "Task 2 completed",
|
|
380
|
+
priority: "medium"
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### File Change Batch
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
{
|
|
390
|
+
action: "record_batch",
|
|
391
|
+
atomic: false,
|
|
392
|
+
file_changes: [
|
|
393
|
+
{
|
|
394
|
+
file_path: "src/types.ts",
|
|
395
|
+
agent_name: "refactor-bot",
|
|
396
|
+
change_type: "modified",
|
|
397
|
+
layer: "data"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
file_path: "src/index.ts",
|
|
401
|
+
agent_name: "refactor-bot",
|
|
402
|
+
change_type: "modified",
|
|
403
|
+
layer: "infrastructure"
|
|
404
|
+
}
|
|
405
|
+
]
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Batch Limits
|
|
410
|
+
|
|
411
|
+
- **Maximum items per batch**: 50
|
|
412
|
+
- **Recommended batch size**: 10-20 (for readability and debugging)
|
|
413
|
+
- **Token savings**: ~52% vs individual calls
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Template System
|
|
418
|
+
|
|
419
|
+
### What are Templates?
|
|
420
|
+
|
|
421
|
+
Templates provide reusable defaults for common decision patterns.
|
|
422
|
+
|
|
423
|
+
### Built-in Templates
|
|
424
|
+
|
|
425
|
+
1. **breaking_change**: Breaking API/interface changes
|
|
426
|
+
2. **security_vulnerability**: Security issues
|
|
427
|
+
3. **performance_optimization**: Performance improvements
|
|
428
|
+
4. **deprecation**: Deprecation notices
|
|
429
|
+
5. **architecture_decision**: Major architectural decisions
|
|
430
|
+
|
|
431
|
+
### Using Templates
|
|
432
|
+
|
|
433
|
+
```javascript
|
|
434
|
+
{
|
|
435
|
+
action: "set_from_template",
|
|
436
|
+
template: "breaking_change",
|
|
437
|
+
key: "oscillator-type-moved",
|
|
438
|
+
value: "oscillator_type moved to MonophonicSynthConfig",
|
|
439
|
+
// Optional overrides:
|
|
440
|
+
tags: ["migration", "v0.3.3"],
|
|
441
|
+
status: "active"
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### Template vs Direct Parameters
|
|
446
|
+
|
|
447
|
+
**When to use `set_from_template`**:
|
|
448
|
+
- You have a common decision pattern
|
|
449
|
+
- You want consistent metadata (tags, status, layer)
|
|
450
|
+
- You want to enforce required fields
|
|
451
|
+
|
|
452
|
+
**When to use `set`**:
|
|
453
|
+
- One-off decisions
|
|
454
|
+
- Unique metadata requirements
|
|
455
|
+
- Full control over all parameters
|
|
456
|
+
|
|
457
|
+
### Creating Custom Templates
|
|
458
|
+
|
|
459
|
+
```javascript
|
|
460
|
+
{
|
|
461
|
+
action: "create_template",
|
|
462
|
+
name: "bug_fix",
|
|
463
|
+
defaults: {
|
|
464
|
+
layer: "business",
|
|
465
|
+
tags: ["bug", "fix"],
|
|
466
|
+
status: "active"
|
|
467
|
+
},
|
|
468
|
+
required_fields: ["version"],
|
|
469
|
+
created_by: "my-agent"
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Listing Templates
|
|
474
|
+
|
|
475
|
+
```javascript
|
|
476
|
+
{
|
|
477
|
+
action: "list_templates"
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## Best Practices
|
|
484
|
+
|
|
485
|
+
### 1. Always Use `action` Parameter
|
|
486
|
+
|
|
487
|
+
**Never forget to include `action`** - it's required in ALL tool calls.
|
|
488
|
+
|
|
489
|
+
### 2. Use `atomic: false` for Batch Operations
|
|
490
|
+
|
|
491
|
+
Unless you specifically need all-or-nothing guarantees, use `atomic: false` to avoid transaction failures from validation errors.
|
|
492
|
+
|
|
493
|
+
### 3. Choose the Right Search Action
|
|
494
|
+
|
|
495
|
+
- Simple queries → `list`
|
|
496
|
+
- Tag-focused → `search_tags`
|
|
497
|
+
- Complex multi-filter → `search_advanced`
|
|
498
|
+
|
|
499
|
+
### 4. Use Templates for Common Patterns
|
|
500
|
+
|
|
501
|
+
If you're repeatedly setting decisions with the same metadata, create a template.
|
|
502
|
+
|
|
503
|
+
### 5. Provide Meaningful Tags
|
|
504
|
+
|
|
505
|
+
Tags are crucial for searchability. Use descriptive, consistent tag naming:
|
|
506
|
+
|
|
507
|
+
```javascript
|
|
508
|
+
// ✅ GOOD
|
|
509
|
+
tags: ["authentication", "security", "jwt", "v1.2.0"]
|
|
510
|
+
|
|
511
|
+
// ❌ BAD
|
|
512
|
+
tags: ["stuff", "important", "thing"]
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### 6. Always Specify `layer` for Decisions
|
|
516
|
+
|
|
517
|
+
Layer classification helps organize architectural concerns:
|
|
518
|
+
|
|
519
|
+
- **presentation**: UI, API endpoints, user-facing interfaces
|
|
520
|
+
- **business**: Service logic, workflows, business rules
|
|
521
|
+
- **data**: Database models, schemas, data access
|
|
522
|
+
- **infrastructure**: Configuration, deployment, DevOps
|
|
523
|
+
- **cross-cutting**: Logging, monitoring, security (affects multiple layers)
|
|
524
|
+
|
|
525
|
+
### 7. Use `has_updates` for Efficient Polling
|
|
526
|
+
|
|
527
|
+
Instead of fetching all data repeatedly, check for updates first:
|
|
528
|
+
|
|
529
|
+
```javascript
|
|
530
|
+
// Check if anything changed
|
|
531
|
+
{
|
|
532
|
+
action: "has_updates",
|
|
533
|
+
agent_name: "my-agent",
|
|
534
|
+
since_timestamp: "2025-10-15T08:00:00Z"
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Response: {has_updates: true, counts: {decisions: 5, messages: 2, files: 3}}
|
|
538
|
+
|
|
539
|
+
// Only fetch if has_updates is true
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Token cost: ~5-10 tokens per check vs full data retrieval.
|
|
543
|
+
|
|
544
|
+
### 8. Handle Errors Gracefully
|
|
545
|
+
|
|
546
|
+
All tools return JSON responses. Check for `error` field:
|
|
547
|
+
|
|
548
|
+
```javascript
|
|
549
|
+
// Response format
|
|
550
|
+
{
|
|
551
|
+
"error": "Invalid layer: backend"
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Success format
|
|
555
|
+
{
|
|
556
|
+
"success": true,
|
|
557
|
+
"key": "my_key",
|
|
558
|
+
...
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### 9. Use Constraints for Requirements
|
|
563
|
+
|
|
564
|
+
**Constraint** vs **Decision**:
|
|
565
|
+
|
|
566
|
+
- **Decision**: "We chose PostgreSQL" (a choice that was made)
|
|
567
|
+
- **Constraint**: "Response time must be <100ms" (a requirement to follow)
|
|
568
|
+
|
|
569
|
+
```javascript
|
|
570
|
+
{
|
|
571
|
+
action: "add",
|
|
572
|
+
category: "performance",
|
|
573
|
+
constraint_text: "API response time must be under 100ms",
|
|
574
|
+
priority: "critical",
|
|
575
|
+
layer: "business",
|
|
576
|
+
tags: ["api", "performance"]
|
|
577
|
+
}
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### 10. Clean Up Old Data Regularly
|
|
581
|
+
|
|
582
|
+
Use the `clear` action to prevent database bloat:
|
|
583
|
+
|
|
584
|
+
```javascript
|
|
585
|
+
// Manual cleanup
|
|
586
|
+
{
|
|
587
|
+
action: "clear",
|
|
588
|
+
messages_older_than_hours: 48,
|
|
589
|
+
file_changes_older_than_days: 14
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// Or rely on auto-cleanup (configured via config tool)
|
|
593
|
+
{
|
|
594
|
+
action: "update",
|
|
595
|
+
ignoreWeekend: true,
|
|
596
|
+
messageRetentionHours: 24,
|
|
597
|
+
fileHistoryRetentionDays: 7
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## Troubleshooting Checklist
|
|
604
|
+
|
|
605
|
+
Before asking for help, check:
|
|
606
|
+
|
|
607
|
+
1. ✅ Did you include the `action` parameter?
|
|
608
|
+
2. ✅ Are all required parameters provided?
|
|
609
|
+
3. ✅ Are enum values spelled correctly? (layer, status, msg_type, etc.)
|
|
610
|
+
4. ✅ For templates: Are you passing parameters directly (not in `defaults`)?
|
|
611
|
+
5. ✅ For batch operations: Is array size ≤50?
|
|
612
|
+
6. ✅ For timestamps: Are you using ISO 8601 format?
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## Need More Help?
|
|
617
|
+
|
|
618
|
+
Use the built-in help action for any tool:
|
|
619
|
+
|
|
620
|
+
```javascript
|
|
621
|
+
// Get detailed help for decision tool
|
|
622
|
+
{
|
|
623
|
+
action: "help"
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
This returns comprehensive documentation with:
|
|
628
|
+
- All actions and their parameters
|
|
629
|
+
- Examples for each action
|
|
630
|
+
- Valid values for enum parameters
|
|
631
|
+
- Behavior descriptions
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
## Summary: Most Common Mistakes
|
|
636
|
+
|
|
637
|
+
1. **Missing `action` parameter** ← #1 error!
|
|
638
|
+
2. Using `defaults` instead of direct parameters with templates
|
|
639
|
+
3. Invalid layer/status/priority values (use exact strings)
|
|
640
|
+
4. Forgetting to specify `layer` when setting decisions
|
|
641
|
+
5. Using `atomic: true` by default in batch operations (use `false`)
|
|
642
|
+
6. Using wrong search action (`list` vs `search_tags` vs `search_advanced`)
|
|
643
|
+
7. Empty arrays in batch operations
|
|
644
|
+
8. Typos in parameter names (e.g., `messsage` instead of `message`)
|
|
645
|
+
|
|
646
|
+
---
|
|
647
|
+
|
|
648
|
+
**Remember**: When in doubt, call `{action: "help"}` on any tool!
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqlew",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "MCP server for efficient context sharing between Claude Code sub-agents with
|
|
3
|
+
"version": "2.1.4",
|
|
4
|
+
"description": "MCP server for efficient context sharing between Claude Code sub-agents with 63% token reduction via action-based tools",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|
|
13
13
|
"assets/",
|
|
14
|
+
"docs/",
|
|
14
15
|
"README.md",
|
|
15
16
|
"LICENSE",
|
|
16
17
|
"CHANGELOG.md",
|