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
@@ -0,0 +1,471 @@
1
+ # Tool Reference
2
+
3
+ **Complete technical reference for all sqlew MCP tools**
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
+ ## Quick Start
27
+
28
+ ### Basic Decision Workflow
29
+
30
+ ```javascript
31
+ // 1. Set a decision
32
+ {
33
+ action: "set",
34
+ key: "auth_method",
35
+ value: "jwt",
36
+ layer: "business",
37
+ tags: ["security", "authentication"]
38
+ }
39
+
40
+ // 2. Get the decision
41
+ {
42
+ action: "get",
43
+ key: "auth_method"
44
+ }
45
+
46
+ // 3. List decisions with filters
47
+ {
48
+ action: "list",
49
+ status: "active",
50
+ layer: "business"
51
+ }
52
+ ```
53
+
54
+ ### Basic Messaging Workflow
55
+
56
+ ```javascript
57
+ // 1. Send a message
58
+ {
59
+ action: "send",
60
+ from_agent: "bot1",
61
+ msg_type: "info",
62
+ message: "Task completed successfully",
63
+ priority: "high"
64
+ }
65
+
66
+ // 2. Get messages
67
+ {
68
+ action: "get",
69
+ agent_name: "bot1",
70
+ unread_only: true
71
+ }
72
+
73
+ // 3. Mark as read
74
+ {
75
+ action: "mark_read",
76
+ agent_name: "bot1",
77
+ message_ids: [1, 2, 3]
78
+ }
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Parameter Requirements by Tool
84
+
85
+ ### `decision` Tool
86
+
87
+ | Action | Required | Optional |
88
+ |--------|----------|----------|
89
+ | **set** | action, key, value, layer | agent, version, status, tags, scopes |
90
+ | **get** | action, key | version |
91
+ | **list** | action | status, layer, tags, scope, tag_match, limit, offset |
92
+ | **search_tags** | action, tags | match_mode, status, layer |
93
+ | **search_layer** | action, layer | status, include_tags |
94
+ | **versions** | action, key | - |
95
+ | **quick_set** | action, key, value | agent, layer, version, status, tags, scopes |
96
+ | **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 |
97
+ | **set_batch** | action, decisions | atomic |
98
+ | **has_updates** | action, agent_name, since_timestamp | - |
99
+ | **set_from_template** | action, template, key, value, layer | agent, version, status, tags, scopes |
100
+ | **create_template** | action, name, defaults | required_fields, created_by |
101
+ | **list_templates** | action | - |
102
+
103
+ ### `message` Tool
104
+
105
+ | Action | Required | Optional |
106
+ |--------|----------|----------|
107
+ | **send** | action, from_agent, msg_type, message | to_agent, priority, payload |
108
+ | **get** | action, agent_name | unread_only, priority_filter, msg_type_filter, limit |
109
+ | **mark_read** | action, agent_name, message_ids | - |
110
+ | **send_batch** | action, messages | atomic |
111
+
112
+ ### `file` Tool
113
+
114
+ | Action | Required | Optional |
115
+ |--------|----------|----------|
116
+ | **record** | action, file_path, agent_name, change_type | layer, description |
117
+ | **get** | action | file_path, agent_name, layer, change_type, since, limit |
118
+ | **check_lock** | action, file_path | lock_duration |
119
+ | **record_batch** | action, file_changes | atomic |
120
+
121
+ ### `constraint` Tool
122
+
123
+ | Action | Required | Optional |
124
+ |--------|----------|----------|
125
+ | **add** | action, category, constraint_text | priority, layer, tags, created_by |
126
+ | **get** | action | category, layer, priority, tags, active_only, limit |
127
+ | **deactivate** | action, constraint_id | - |
128
+
129
+ ### `stats` Tool
130
+
131
+ | Action | Required | Optional |
132
+ |--------|----------|----------|
133
+ | **layer_summary** | action | - |
134
+ | **db_stats** | action | - |
135
+ | **clear** | action | messages_older_than_hours, file_changes_older_than_days |
136
+ | **activity_log** | action | since, agent_names, actions, limit |
137
+ | **flush** | action | - |
138
+
139
+ ### `config` Tool
140
+
141
+ | Action | Required | Optional |
142
+ |--------|----------|----------|
143
+ | **get** | action | - |
144
+ | **update** | action | ignoreWeekend, messageRetentionHours, fileHistoryRetentionDays |
145
+
146
+ ### `task` Tool
147
+
148
+ | Action | Required | Optional |
149
+ |--------|----------|----------|
150
+ | **create** | action, title | description, acceptance_criteria, notes, priority, assigned_agent, created_by_agent, layer, tags, status |
151
+ | **update** | action, task_id | title, priority, assigned_agent, layer, description, acceptance_criteria, notes |
152
+ | **get** | action, task_id | - |
153
+ | **list** | action | status, assigned_agent, layer, tags, limit, offset |
154
+ | **move** | action, task_id, new_status | - |
155
+ | **link** | action, task_id, link_type, target_id | link_relation |
156
+ | **archive** | action, task_id | - |
157
+ | **batch_create** | action, tasks | atomic |
158
+
159
+ ---
160
+
161
+ ## Search Actions Decision Tree
162
+
163
+ ### When to use which search action?
164
+
165
+ ```
166
+ ┌─────────────────────────────────────┐
167
+ │ What do you want to search by? │
168
+ └──────────┬──────────────────────────┘
169
+
170
+ ├─ Simple filters (status, layer, tags)?
171
+ │ └─> Use action: "list"
172
+
173
+ ├─ Primarily by tags?
174
+ │ └─> Use action: "search_tags"
175
+ │ • match_mode: "AND" (all tags) or "OR" (any tag)
176
+
177
+ ├─ Primarily by layer?
178
+ │ └─> Use action: "search_layer"
179
+
180
+ ├─ Complex multi-filter query?
181
+ │ └─> Use action: "search_advanced"
182
+ │ • Multiple layers (OR)
183
+ │ • Tag combinations (AND/OR)
184
+ │ • Temporal filtering
185
+ │ • Full-text search
186
+ │ • Pagination
187
+
188
+ └─ Need version history?
189
+ └─> Use action: "versions"
190
+ ```
191
+
192
+ ### Detailed Search Comparison
193
+
194
+ | Action | Use When | Key Features |
195
+ |--------|----------|--------------|
196
+ | **list** | Basic filtering | Simple status/layer/tag filters, no pagination |
197
+ | **search_tags** | Tag-focused search | AND/OR logic for tags, optional status/layer |
198
+ | **search_layer** | Layer-focused search | Get all decisions in specific layer(s) |
199
+ | **search_advanced** | Complex queries | Full filtering, pagination, sorting, text search |
200
+ | **versions** | History tracking | Get all versions of a specific decision |
201
+
202
+ ---
203
+
204
+ ## Batch Operations Guide
205
+
206
+ ### Atomic vs Non-Atomic Mode
207
+
208
+ **Atomic Mode** (`atomic: true`, default):
209
+ - All succeed or all fail as a single transaction
210
+ - If ANY item fails, entire batch is rolled back
211
+ - Error is thrown immediately on first failure
212
+ - Use for: Critical operations requiring consistency
213
+
214
+ **Non-Atomic Mode** (`atomic: false`, **recommended for AI agents**):
215
+ - Each item processed independently
216
+ - If some fail, others still succeed
217
+ - Returns partial results with per-item success/error status
218
+ - Use for: Best-effort batch operations, when individual failures are acceptable
219
+
220
+ ### Batch Operation Examples
221
+
222
+ #### Decision Batch (Recommended: atomic: false)
223
+
224
+ ```javascript
225
+ {
226
+ action: "set_batch",
227
+ atomic: false, // Recommended for AI agents
228
+ decisions: [
229
+ {
230
+ key: "feature-1",
231
+ value: "Implemented user authentication",
232
+ layer: "business",
233
+ tags: ["feature", "auth"],
234
+ status: "active"
235
+ },
236
+ {
237
+ key: "feature-2",
238
+ value: "Added rate limiting",
239
+ layer: "infrastructure",
240
+ tags: ["feature", "security"],
241
+ status: "active"
242
+ }
243
+ ]
244
+ }
245
+ ```
246
+
247
+ **Response Format:**
248
+ ```json
249
+ {
250
+ "success": true,
251
+ "inserted": 2,
252
+ "failed": 0,
253
+ "results": [
254
+ {
255
+ "key": "feature-1",
256
+ "key_id": 123,
257
+ "version": "1.0.0",
258
+ "success": true
259
+ },
260
+ {
261
+ "key": "feature-2",
262
+ "key_id": 124,
263
+ "version": "1.0.0",
264
+ "success": true
265
+ }
266
+ ]
267
+ }
268
+ ```
269
+
270
+ #### Message Batch
271
+
272
+ ```javascript
273
+ {
274
+ action: "send_batch",
275
+ atomic: false,
276
+ messages: [
277
+ {
278
+ from_agent: "bot1",
279
+ msg_type: "info",
280
+ message: "Task 1 completed",
281
+ priority: "medium"
282
+ },
283
+ {
284
+ from_agent: "bot1",
285
+ msg_type: "info",
286
+ message: "Task 2 completed",
287
+ priority: "medium"
288
+ }
289
+ ]
290
+ }
291
+ ```
292
+
293
+ #### File Change Batch
294
+
295
+ ```javascript
296
+ {
297
+ action: "record_batch",
298
+ atomic: false,
299
+ file_changes: [
300
+ {
301
+ file_path: "src/types.ts",
302
+ agent_name: "refactor-bot",
303
+ change_type: "modified",
304
+ layer: "data"
305
+ },
306
+ {
307
+ file_path: "src/index.ts",
308
+ agent_name: "refactor-bot",
309
+ change_type: "modified",
310
+ layer: "infrastructure"
311
+ }
312
+ ]
313
+ }
314
+ ```
315
+
316
+ ### Batch Limits
317
+
318
+ - **Maximum items per batch**: 50
319
+ - **Recommended batch size**: 10-20 (for readability and debugging)
320
+ - **Token savings**: ~52% vs individual calls
321
+
322
+ ---
323
+
324
+ ## Template System
325
+
326
+ ### What are Templates?
327
+
328
+ Templates provide reusable defaults for common decision patterns.
329
+
330
+ ### Built-in Templates
331
+
332
+ 1. **breaking_change**: Breaking API/interface changes
333
+ 2. **security_vulnerability**: Security issues
334
+ 3. **performance_optimization**: Performance improvements
335
+ 4. **deprecation**: Deprecation notices
336
+ 5. **architecture_decision**: Major architectural decisions
337
+
338
+ ### Using Templates
339
+
340
+ ```javascript
341
+ {
342
+ action: "set_from_template",
343
+ template: "breaking_change",
344
+ key: "oscillator-type-moved",
345
+ value: "oscillator_type moved to MonophonicSynthConfig",
346
+ // Optional overrides:
347
+ tags: ["migration", "v0.3.3"],
348
+ status: "active"
349
+ }
350
+ ```
351
+
352
+ ### Template vs Direct Parameters
353
+
354
+ **When to use `set_from_template`**:
355
+ - You have a common decision pattern
356
+ - You want consistent metadata (tags, status, layer)
357
+ - You want to enforce required fields
358
+
359
+ **When to use `set`**:
360
+ - One-off decisions
361
+ - Unique metadata requirements
362
+ - Full control over all parameters
363
+
364
+ ### Creating Custom Templates
365
+
366
+ ```javascript
367
+ {
368
+ action: "create_template",
369
+ name: "bug_fix",
370
+ defaults: {
371
+ layer: "business",
372
+ tags: ["bug", "fix"],
373
+ status: "active"
374
+ },
375
+ required_fields: ["version"],
376
+ created_by: "my-agent"
377
+ }
378
+ ```
379
+
380
+ ### Listing Templates
381
+
382
+ ```javascript
383
+ {
384
+ action: "list_templates"
385
+ }
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Valid Values Reference
391
+
392
+ ### Layers
393
+
394
+ 💡 **See [ARCHITECTURE.md](ARCHITECTURE.md#layers) for detailed layer definitions.**
395
+
396
+ Quick reference:
397
+ - **presentation**: UI, API endpoints, user-facing interfaces
398
+ - **business**: Service logic, workflows, business rules
399
+ - **data**: Database models, schemas, data access
400
+ - **infrastructure**: Configuration, deployment, DevOps
401
+ - **cross-cutting**: Logging, monitoring, security (affects multiple layers)
402
+
403
+ ### Statuses
404
+
405
+ - **active**: Currently active decision/constraint
406
+ - **deprecated**: No longer recommended but still valid
407
+ - **draft**: Work in progress, not finalized
408
+
409
+ ### Message Types
410
+
411
+ - **decision**: Notification about a decision made
412
+ - **warning**: Alert about issues or concerns
413
+ - **request**: Request for action or input
414
+ - **info**: General informational message
415
+
416
+ ### Priorities
417
+
418
+ - **low** (1): Non-urgent, can wait
419
+ - **medium** (2): Normal priority (default)
420
+ - **high** (3): Important, address soon
421
+ - **critical** (4): Urgent, immediate attention required
422
+
423
+ ### Change Types (File)
424
+
425
+ - **created**: New file created
426
+ - **modified**: Existing file changed
427
+ - **deleted**: File removed
428
+
429
+ ### Task Statuses
430
+
431
+ - **todo**: Not started
432
+ - **in_progress**: Currently being worked on
433
+ - **waiting_review**: Completed, awaiting review
434
+ - **blocked**: Cannot proceed due to blocker
435
+ - **done**: Completed successfully
436
+ - **archived**: No longer relevant
437
+
438
+ ### Constraint Categories
439
+
440
+ - **performance**: Performance requirements
441
+ - **architecture**: Architectural rules
442
+ - **security**: Security requirements
443
+
444
+ ---
445
+
446
+ ## Help Actions
447
+
448
+ All tools support `action: "help"` for comprehensive on-demand documentation:
449
+
450
+ ```javascript
451
+ // Get detailed help for decision tool
452
+ {
453
+ action: "help"
454
+ }
455
+ ```
456
+
457
+ This returns:
458
+ - All actions and their parameters
459
+ - Examples for each action
460
+ - Valid values for enum parameters
461
+ - Behavior descriptions
462
+
463
+ ---
464
+
465
+ ## Related Documentation
466
+
467
+ - **[TOOL_SELECTION.md](TOOL_SELECTION.md)** - Choosing the right tool for your task
468
+ - **[WORKFLOWS.md](WORKFLOWS.md)** - Multi-step workflow examples
469
+ - **[BEST_PRACTICES.md](BEST_PRACTICES.md)** - Common errors and best practices
470
+ - **[ARCHITECTURE.md](ARCHITECTURE.md)** - Layer definitions and system architecture
471
+ - **[AI_AGENT_GUIDE.md](AI_AGENT_GUIDE.md)** - Complete guide (original comprehensive version)