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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# Best Practices & Troubleshooting
|
|
2
|
+
|
|
3
|
+
**Essential guidelines and solutions for common sqlew usage issues**
|
|
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
|
+
## ⚠️ CRITICAL: What to Store in Decisions
|
|
27
|
+
|
|
28
|
+
**Second Most Important Rule**: Decisions table stores **WHY and REASON**, NOT **WHAT was done**.
|
|
29
|
+
|
|
30
|
+
### The Principle
|
|
31
|
+
|
|
32
|
+
sqlew provides **organizational memory** by filling the gap between Git and code comments:
|
|
33
|
+
|
|
34
|
+
- **Git history** → WHAT changed (files, lines, commits)
|
|
35
|
+
- **Code comments** → HOW it works (implementation details)
|
|
36
|
+
- **sqlew decisions** → **WHY it was changed** (reasoning, trade-offs, context)
|
|
37
|
+
- **sqlew tasks** → WHAT needs to be done (work items, status, completion)
|
|
38
|
+
|
|
39
|
+
### ✅ GOOD Examples: Store WHY and REASON
|
|
40
|
+
|
|
41
|
+
These explain **architectural reasoning** and **design rationale**:
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
// ✅ GOOD - Explains WHY with reasoning and trade-offs
|
|
45
|
+
{
|
|
46
|
+
action: "set",
|
|
47
|
+
key: "api/auth/jwt-choice",
|
|
48
|
+
value: "Chose JWT over session-based auth because: (1) Stateless design scales horizontally, (2) Mobile clients can cache tokens, (3) Microservice architecture requires distributed auth. Trade-off: Revocation requires token blacklist, but acceptable for 15-min token lifetime.",
|
|
49
|
+
layer: "business",
|
|
50
|
+
tags: ["authentication", "architecture-decision"]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ✅ GOOD - Problem analysis with solution rationale
|
|
54
|
+
{
|
|
55
|
+
action: "set",
|
|
56
|
+
key: "bug/batch-nested-transaction",
|
|
57
|
+
value: "Found nested transaction bug in setDecisionBatch. setDecision uses transaction() internally, but setDecisionBatch wraps calls to setDecision in its own transaction, causing 'cannot start a transaction within a transaction' error. Solution: Extract setDecisionInternal() without transaction wrapper, batch manages outer transaction.",
|
|
58
|
+
layer: "business",
|
|
59
|
+
tags: ["bug", "transaction", "root-cause-analysis"]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ✅ GOOD - Design trade-offs with honest assessment
|
|
63
|
+
{
|
|
64
|
+
action: "set",
|
|
65
|
+
key: "phase2-refactoring-assessment",
|
|
66
|
+
value: "Query builder provides value for simple filters (files.ts 31% reduction). Context.ts patterns are domain-specific and more maintainable inline. Real savings: ~450 tokens (not estimated 2,050). Learned: Not all 'duplication' should be abstracted - domain logic clarity > generic utilities.",
|
|
67
|
+
layer: "infrastructure",
|
|
68
|
+
tags: ["refactoring", "assessment", "design-decision"]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ✅ GOOD - Architectural constraint reasoning
|
|
72
|
+
{
|
|
73
|
+
action: "set",
|
|
74
|
+
key: "loom_material_duration_boundary",
|
|
75
|
+
value: "Duration calculation must NOT occur in Loom module. Loom generates abstract structures (pitches, timings). Material module calculates concrete note properties (duration, velocity, MIDI pitch). VIOLATION: groove_engine.rs calculates duration using dense parameter - breaks architectural separation.",
|
|
76
|
+
layer: "business",
|
|
77
|
+
tags: ["architecture", "separation-of-concerns"]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ✅ GOOD - Breaking change with migration rationale
|
|
81
|
+
{
|
|
82
|
+
action: "set",
|
|
83
|
+
key: "oscillator-type-refactor",
|
|
84
|
+
value: "oscillator_type moved from base SynthConfig to MonophonicSynthConfig only. Reason: FM synths use per-operator oscillator_type, wavetable/granular/sampler/physical-modeling use different synthesis methods. Breaking change necessary to support diverse synthesis architectures.",
|
|
85
|
+
layer: "data",
|
|
86
|
+
tags: ["breaking", "synthesis", "architecture"]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### ❌ BAD Examples: Don't Store WHAT Was Done
|
|
91
|
+
|
|
92
|
+
These are task completion logs, status updates, or implementation logs:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// ❌ BAD - Task completion log (use tasks tool instead)
|
|
96
|
+
{
|
|
97
|
+
action: "set",
|
|
98
|
+
key: "v3.0.2-testing-complete",
|
|
99
|
+
value: "v3.0.2 comprehensive testing complete. All refactored tools verified working: validators.ts integration confirmed, query-builder.ts functioning correctly."
|
|
100
|
+
}
|
|
101
|
+
// WHY BAD: This records WHAT was completed, not WHY design decisions were made.
|
|
102
|
+
// FIX: Delete. Use tasks tool to track testing progress.
|
|
103
|
+
|
|
104
|
+
// ❌ BAD - Implementation status (use git commit instead)
|
|
105
|
+
{
|
|
106
|
+
action: "set",
|
|
107
|
+
key: "phase1-validation-refactoring-complete",
|
|
108
|
+
value: "All 5 tool files successfully refactored to use validators.ts utility module. Eliminates 27+ duplicated validation patterns."
|
|
109
|
+
}
|
|
110
|
+
// WHY BAD: Records completion status, not architectural reasoning.
|
|
111
|
+
// FIX: Delete. If needed, create decision explaining WHY refactoring strategy was chosen.
|
|
112
|
+
|
|
113
|
+
// ❌ BAD - Test results (temporary status)
|
|
114
|
+
{
|
|
115
|
+
action: "set",
|
|
116
|
+
key: "refactoring/integration-test-results",
|
|
117
|
+
value: "PASS - All refactored utilities integrate correctly. Build succeeds, no breaking changes detected."
|
|
118
|
+
}
|
|
119
|
+
// WHY BAD: Test results are temporary status, not design rationale.
|
|
120
|
+
// FIX: Delete. Test results belong in CI/CD logs, not architectural decisions.
|
|
121
|
+
|
|
122
|
+
// ❌ BAD - Documentation updates (implementation log)
|
|
123
|
+
{
|
|
124
|
+
action: "set",
|
|
125
|
+
key: "doc-restructure-complete",
|
|
126
|
+
value: "Split AI_AGENT_GUIDE.md into 4 focused files. Achieved 68% average token reduction."
|
|
127
|
+
}
|
|
128
|
+
// WHY BAD: Records WHAT was done, not WHY documentation structure was chosen.
|
|
129
|
+
// FIX: Delete or rewrite to explain: "Documentation split into focused files because AI agents load only relevant sections - reduces token consumption by 81% vs loading full guide."
|
|
130
|
+
|
|
131
|
+
// ❌ BAD - Git commit summary (duplicate of git history)
|
|
132
|
+
{
|
|
133
|
+
action: "set",
|
|
134
|
+
key: "v2.1.1/git-commit",
|
|
135
|
+
value: "Created release commit 2bf55a0: 6 files changed (386 insertions, 537 deletions)."
|
|
136
|
+
}
|
|
137
|
+
// WHY BAD: Git already tracks commits - no need to duplicate.
|
|
138
|
+
// FIX: Delete. Git history serves this purpose.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Side-by-Side Comparison
|
|
142
|
+
|
|
143
|
+
| ✅ GOOD (WHY/REASON) | ❌ BAD (WHAT/STATUS) |
|
|
144
|
+
|---------------------|---------------------|
|
|
145
|
+
| "Chose JWT because stateless auth scales horizontally for microservices" | "Implemented JWT authentication. Tests passing." |
|
|
146
|
+
| "Nested transaction bug: setDecision wraps in transaction, batch also wraps → solution: extract internal helper" | "Fixed batch_create nested transaction bug." |
|
|
147
|
+
| "Query builder works for simple filters but domain logic better inline for maintainability" | "Phase 2 refactoring complete. Query builder created." |
|
|
148
|
+
| "Duration must NOT be in Loom - breaks architectural separation between abstract timing and concrete notes" | "Removed duration from Loom module. Fixed errors." |
|
|
149
|
+
|
|
150
|
+
### When to Use Each Tool
|
|
151
|
+
|
|
152
|
+
| Tool | Purpose | Example |
|
|
153
|
+
|------|---------|---------|
|
|
154
|
+
| **decision** | WHY: Architectural reasoning | "Chose Redis because sub-10ms latency required" |
|
|
155
|
+
| **task** | WHAT: Work items & status | "Implement Redis caching (status: in_progress)" |
|
|
156
|
+
| **constraint** | Requirements & rules | "Cache response time must be <10ms" |
|
|
157
|
+
| **message** | Agent coordination | "Redis blocked - waiting for infra approval" |
|
|
158
|
+
| **file** | Track changes | "Modified src/cache.ts - added Redis client" |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Common Errors & Solutions
|
|
163
|
+
|
|
164
|
+
💡 **See also**: [ARCHITECTURE.md](ARCHITECTURE.md) for detailed layer, enum, and status definitions.
|
|
165
|
+
|
|
166
|
+
### Error: "Unknown action: undefined"
|
|
167
|
+
|
|
168
|
+
**Cause**: Missing `action` parameter
|
|
169
|
+
|
|
170
|
+
**Solution**: Always include `action` as the first parameter
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
// ❌ WRONG
|
|
174
|
+
{
|
|
175
|
+
key: "some_key",
|
|
176
|
+
value: "some value",
|
|
177
|
+
layer: "business"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ✅ CORRECT
|
|
181
|
+
{
|
|
182
|
+
action: "set",
|
|
183
|
+
key: "some_key",
|
|
184
|
+
value: "some value",
|
|
185
|
+
layer: "business"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Error: "Parameter \"value\" is required"
|
|
190
|
+
|
|
191
|
+
**Cause**: Using `defaults` instead of direct parameters with templates
|
|
192
|
+
|
|
193
|
+
**Solution**: Provide parameters directly, not nested in `defaults`
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
// ❌ WRONG
|
|
197
|
+
{
|
|
198
|
+
action: "set_from_template",
|
|
199
|
+
template: "deprecation",
|
|
200
|
+
key: "some_key",
|
|
201
|
+
defaults: {
|
|
202
|
+
value: "...",
|
|
203
|
+
layer: "cross-cutting"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ✅ CORRECT
|
|
208
|
+
{
|
|
209
|
+
action: "set_from_template",
|
|
210
|
+
template: "deprecation",
|
|
211
|
+
key: "some_key",
|
|
212
|
+
value: "...",
|
|
213
|
+
layer: "cross-cutting"
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Error: "Invalid layer"
|
|
218
|
+
|
|
219
|
+
**Cause**: Using a layer name that doesn't exist
|
|
220
|
+
|
|
221
|
+
**Solution**: Use one of the 5 standard layers
|
|
222
|
+
|
|
223
|
+
**Valid layers**: `presentation`, `business`, `data`, `infrastructure`, `cross-cutting`
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
// ❌ WRONG
|
|
227
|
+
{
|
|
228
|
+
action: "set",
|
|
229
|
+
key: "my_key",
|
|
230
|
+
value: "my_value",
|
|
231
|
+
layer: "backend" // Invalid!
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ✅ CORRECT
|
|
235
|
+
{
|
|
236
|
+
action: "set",
|
|
237
|
+
key: "my_key",
|
|
238
|
+
value: "my_value",
|
|
239
|
+
layer: "business" // Valid!
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Error: "Invalid status"
|
|
244
|
+
|
|
245
|
+
**Cause**: Using a status value that doesn't exist
|
|
246
|
+
|
|
247
|
+
**Solution**: Use one of the 3 valid statuses
|
|
248
|
+
|
|
249
|
+
**Valid statuses**: `active`, `deprecated`, `draft`
|
|
250
|
+
|
|
251
|
+
### Error: "Batch operations are limited to 50 items maximum"
|
|
252
|
+
|
|
253
|
+
**Cause**: Too many items in batch array
|
|
254
|
+
|
|
255
|
+
**Solution**: Split into multiple batches of ≤50 items each
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Best Practices
|
|
260
|
+
|
|
261
|
+
### 1. Always Use `action` Parameter
|
|
262
|
+
|
|
263
|
+
**Never forget to include `action`** - it's required in ALL tool calls.
|
|
264
|
+
|
|
265
|
+
### 2. Use `atomic: false` for Batch Operations
|
|
266
|
+
|
|
267
|
+
Unless you specifically need all-or-nothing guarantees, use `atomic: false` to avoid transaction failures from validation errors.
|
|
268
|
+
|
|
269
|
+
```javascript
|
|
270
|
+
{
|
|
271
|
+
action: "set_batch",
|
|
272
|
+
atomic: false, // Recommended for AI agents
|
|
273
|
+
decisions: [...]
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 3. Choose the Right Search Action
|
|
278
|
+
|
|
279
|
+
- Simple queries → `list`
|
|
280
|
+
- Tag-focused → `search_tags`
|
|
281
|
+
- Complex multi-filter → `search_advanced`
|
|
282
|
+
|
|
283
|
+
See [TOOL_SELECTION.md](TOOL_SELECTION.md) for detailed guidance.
|
|
284
|
+
|
|
285
|
+
### 4. Use Templates for Common Patterns
|
|
286
|
+
|
|
287
|
+
If you're repeatedly setting decisions with the same metadata, create a template.
|
|
288
|
+
|
|
289
|
+
```javascript
|
|
290
|
+
{
|
|
291
|
+
action: "set_from_template",
|
|
292
|
+
template: "breaking_change",
|
|
293
|
+
key: "api_change_v2",
|
|
294
|
+
value: "Moved endpoint to /v2/users"
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### 5. Provide Meaningful Tags
|
|
299
|
+
|
|
300
|
+
Tags are crucial for searchability. Use descriptive, consistent tag naming:
|
|
301
|
+
|
|
302
|
+
```javascript
|
|
303
|
+
// ✅ GOOD
|
|
304
|
+
tags: ["authentication", "security", "jwt", "v1.2.0"]
|
|
305
|
+
|
|
306
|
+
// ❌ BAD
|
|
307
|
+
tags: ["stuff", "important", "thing"]
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 6. Always Specify `layer` for Decisions
|
|
311
|
+
|
|
312
|
+
Layer classification helps organize architectural concerns.
|
|
313
|
+
|
|
314
|
+
💡 **See [ARCHITECTURE.md](ARCHITECTURE.md#layers) for detailed layer definitions and usage examples.**
|
|
315
|
+
|
|
316
|
+
Quick reference:
|
|
317
|
+
- **presentation**: UI, API endpoints, user-facing interfaces
|
|
318
|
+
- **business**: Service logic, workflows, business rules
|
|
319
|
+
- **data**: Database models, schemas, data access
|
|
320
|
+
- **infrastructure**: Configuration, deployment, DevOps
|
|
321
|
+
- **cross-cutting**: Logging, monitoring, security (affects multiple layers)
|
|
322
|
+
|
|
323
|
+
### 7. Use `has_updates` for Efficient Polling
|
|
324
|
+
|
|
325
|
+
Instead of fetching all data repeatedly, check for updates first:
|
|
326
|
+
|
|
327
|
+
```javascript
|
|
328
|
+
// Check if anything changed
|
|
329
|
+
{
|
|
330
|
+
action: "has_updates",
|
|
331
|
+
agent_name: "my-agent",
|
|
332
|
+
since_timestamp: "2025-10-15T08:00:00Z"
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Response: {has_updates: true, counts: {decisions: 5, messages: 2, files: 3}}
|
|
336
|
+
|
|
337
|
+
// Only fetch if has_updates is true
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Token cost: ~5-10 tokens per check vs full data retrieval.
|
|
341
|
+
|
|
342
|
+
### 8. Handle Errors Gracefully
|
|
343
|
+
|
|
344
|
+
All tools return JSON responses. Check for `error` field:
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
// Response format
|
|
348
|
+
{
|
|
349
|
+
"error": "Invalid layer: backend"
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Success format
|
|
353
|
+
{
|
|
354
|
+
"success": true,
|
|
355
|
+
"key": "my_key",
|
|
356
|
+
...
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### 9. Use Constraints for Requirements
|
|
361
|
+
|
|
362
|
+
**Constraint** vs **Decision**:
|
|
363
|
+
|
|
364
|
+
- **Decision**: "We chose PostgreSQL" (a choice that was made)
|
|
365
|
+
- **Constraint**: "Response time must be <100ms" (a requirement to follow)
|
|
366
|
+
|
|
367
|
+
```javascript
|
|
368
|
+
{
|
|
369
|
+
action: "add",
|
|
370
|
+
category: "performance",
|
|
371
|
+
constraint_text: "API response time must be under 100ms",
|
|
372
|
+
priority: "critical",
|
|
373
|
+
layer: "business",
|
|
374
|
+
tags: ["api", "performance"]
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### 10. Clean Up Old Data Regularly
|
|
379
|
+
|
|
380
|
+
Use the `clear` action to prevent database bloat:
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
// Manual cleanup
|
|
384
|
+
{
|
|
385
|
+
action: "clear",
|
|
386
|
+
messages_older_than_hours: 48,
|
|
387
|
+
file_changes_older_than_days: 14
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Or rely on auto-cleanup (configured via config tool)
|
|
391
|
+
{
|
|
392
|
+
action: "update",
|
|
393
|
+
ignoreWeekend: true,
|
|
394
|
+
messageRetentionHours: 24,
|
|
395
|
+
fileHistoryRetentionDays: 7
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Troubleshooting Checklist
|
|
402
|
+
|
|
403
|
+
Before asking for help, check:
|
|
404
|
+
|
|
405
|
+
1. ✅ Did you include the `action` parameter?
|
|
406
|
+
2. ✅ Are all required parameters provided?
|
|
407
|
+
3. ✅ Are enum values spelled correctly? (layer, status, msg_type, etc.)
|
|
408
|
+
4. ✅ For templates: Are you passing parameters directly (not in `defaults`)?
|
|
409
|
+
5. ✅ For batch operations: Is array size ≤50?
|
|
410
|
+
6. ✅ For timestamps: Are you using ISO 8601 format?
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Summary: Most Common Mistakes
|
|
415
|
+
|
|
416
|
+
1. **Missing `action` parameter** ← #1 error!
|
|
417
|
+
2. Using `defaults` instead of direct parameters with templates
|
|
418
|
+
3. Invalid layer/status/priority values (use exact strings)
|
|
419
|
+
4. Forgetting to specify `layer` when setting decisions
|
|
420
|
+
5. Using `atomic: true` by default in batch operations (use `false`)
|
|
421
|
+
6. Using wrong search action (`list` vs `search_tags` vs `search_advanced`)
|
|
422
|
+
7. Empty arrays in batch operations
|
|
423
|
+
8. Typos in parameter names (e.g., `messsage` instead of `message`)
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Need More Help?
|
|
428
|
+
|
|
429
|
+
Use the built-in help action for any tool:
|
|
430
|
+
|
|
431
|
+
```javascript
|
|
432
|
+
// Get detailed help for decision tool
|
|
433
|
+
{
|
|
434
|
+
action: "help"
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
This returns comprehensive documentation with:
|
|
439
|
+
- All actions and their parameters
|
|
440
|
+
- Examples for each action
|
|
441
|
+
- Valid values for enum parameters
|
|
442
|
+
- Behavior descriptions
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Performance Tips
|
|
447
|
+
|
|
448
|
+
### Token Efficiency
|
|
449
|
+
|
|
450
|
+
1. **Use `has_updates` before fetching** - Save 95% tokens when no changes
|
|
451
|
+
2. **Use metadata-only task queries** - 70% smaller than decision tool
|
|
452
|
+
3. **Batch operations** - 52% token reduction vs individual calls
|
|
453
|
+
4. **Use search actions wisely** - `list` for simple queries, `search_advanced` for complex
|
|
454
|
+
|
|
455
|
+
### Database Health
|
|
456
|
+
|
|
457
|
+
1. **Monitor with `db_stats`** - Check database size regularly
|
|
458
|
+
2. **Enable auto-cleanup** - Configure retention via `config` tool
|
|
459
|
+
3. **Use weekend-aware mode** - Skip weekends for retention calculation
|
|
460
|
+
4. **Archive completed tasks** - Keep task board clean
|
|
461
|
+
|
|
462
|
+
### Multi-Agent Coordination
|
|
463
|
+
|
|
464
|
+
1. **Use priority levels** - Critical messages get attention first
|
|
465
|
+
2. **Broadcast sparingly** - Use targeted messages when possible
|
|
466
|
+
3. **Link tasks to decisions** - Maintain traceability
|
|
467
|
+
4. **Update task status promptly** - Enable auto-stale detection to work
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Related Documentation
|
|
472
|
+
|
|
473
|
+
- **[TOOL_SELECTION.md](TOOL_SELECTION.md)** - Choosing the right tool for your task
|
|
474
|
+
- **[TOOL_REFERENCE.md](TOOL_REFERENCE.md)** - Complete parameter reference
|
|
475
|
+
- **[WORKFLOWS.md](WORKFLOWS.md)** - Multi-step workflow examples
|
|
476
|
+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Layer definitions and system architecture
|
|
477
|
+
- **[AI_AGENT_GUIDE.md](AI_AGENT_GUIDE.md)** - Complete guide (original comprehensive version)
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
**Remember**: When in doubt, call `{action: "help"}` on any tool!
|