sqlew 3.6.5 → 3.6.6
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 +41 -0
- package/LICENSE +52 -52
- package/README.md +3 -2
- package/assets/sample-agents/sqlew-architect.md +89 -273
- package/assets/sample-agents/sqlew-researcher.md +87 -237
- package/assets/sample-agents/sqlew-scrum-master.md +105 -108
- package/dist/index.js +32 -71
- package/dist/index.js.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.d.ts.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js +49 -34
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.d.ts.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js +211 -175
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js.map +1 -1
- package/dist/tests/all-features.test.js +0 -71
- package/dist/tests/all-features.test.js.map +1 -1
- package/dist/tests/parameter-validation.test.d.ts +8 -0
- package/dist/tests/parameter-validation.test.d.ts.map +1 -0
- package/dist/tests/parameter-validation.test.js +461 -0
- package/dist/tests/parameter-validation.test.js.map +1 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +7 -8
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +68 -39
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +9 -7
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/help-queries.d.ts.map +1 -1
- package/dist/tools/help-queries.js +20 -14
- package/dist/tools/help-queries.js.map +1 -1
- package/dist/tools/messaging.d.ts +1 -1
- package/dist/tools/messaging.js +10 -10
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +13 -0
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +15 -12
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +93 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/action-specs.d.ts +46 -0
- package/dist/utils/action-specs.d.ts.map +1 -0
- package/dist/utils/action-specs.js +527 -0
- package/dist/utils/action-specs.js.map +1 -0
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +41 -24
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/parameter-validator.d.ts +53 -0
- package/dist/utils/parameter-validator.d.ts.map +1 -0
- package/dist/utils/parameter-validator.js +286 -0
- package/dist/utils/parameter-validator.js.map +1 -0
- package/docs/BEST_PRACTICES.md +69 -0
- package/docs/CONFIGURATION.md +35 -19
- package/docs/TOOL_REFERENCE.md +178 -0
- package/package.json +86 -86
- package/dist/tools/config.d.ts +0 -50
- package/dist/tools/config.d.ts.map +0 -1
- package/dist/tools/config.js +0 -170
- package/dist/tools/config.js.map +0 -1
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Specification Registry for MCP Tool Parameter Validation
|
|
3
|
+
*
|
|
4
|
+
* Centralized registry of all action-specific parameter requirements across
|
|
5
|
+
* sqlew MCP tools. Used by parameter-validator.ts to generate structured
|
|
6
|
+
* error messages with examples and typo suggestions.
|
|
7
|
+
*
|
|
8
|
+
* Each action spec includes:
|
|
9
|
+
* - required: Array of required parameter names
|
|
10
|
+
* - optional: Array of optional parameter names
|
|
11
|
+
* - example: Valid example object demonstrating correct usage
|
|
12
|
+
* - hint: Optional helpful tip for using the action
|
|
13
|
+
*/
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// DECISION TOOL (16 actions)
|
|
16
|
+
// ============================================================================
|
|
17
|
+
export const DECISION_ACTION_SPECS = {
|
|
18
|
+
set: {
|
|
19
|
+
required: ['key', 'value'],
|
|
20
|
+
optional: ['agent', 'layer', 'tags', 'status', 'version', 'scopes'],
|
|
21
|
+
example: {
|
|
22
|
+
action: 'set',
|
|
23
|
+
key: 'database/postgresql-choice',
|
|
24
|
+
value: 'Selected PostgreSQL over MongoDB because of complex relational queries and ACID compliance requirements',
|
|
25
|
+
layer: 'data',
|
|
26
|
+
tags: ['database', 'architecture'],
|
|
27
|
+
status: 'active',
|
|
28
|
+
version: '1.0.0'
|
|
29
|
+
},
|
|
30
|
+
hint: "Use 'quick_set' for simpler usage with auto-inferred metadata"
|
|
31
|
+
},
|
|
32
|
+
get: {
|
|
33
|
+
required: ['key'],
|
|
34
|
+
optional: ['include_context'],
|
|
35
|
+
example: {
|
|
36
|
+
action: 'get',
|
|
37
|
+
key: 'database/postgresql-choice',
|
|
38
|
+
include_context: true
|
|
39
|
+
},
|
|
40
|
+
hint: "Set include_context=true to get attached rationale and alternatives"
|
|
41
|
+
},
|
|
42
|
+
list: {
|
|
43
|
+
required: [],
|
|
44
|
+
optional: ['status', 'layer', 'tags', 'scope', 'tag_match', 'limit', 'offset'],
|
|
45
|
+
example: {
|
|
46
|
+
action: 'list',
|
|
47
|
+
status: 'active',
|
|
48
|
+
layer: 'business',
|
|
49
|
+
limit: 20
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
search_tags: {
|
|
53
|
+
required: ['tags'],
|
|
54
|
+
optional: ['match_mode', 'status', 'layer'],
|
|
55
|
+
example: {
|
|
56
|
+
action: 'search_tags',
|
|
57
|
+
tags: ['security', 'authentication'],
|
|
58
|
+
match_mode: 'AND',
|
|
59
|
+
status: 'active'
|
|
60
|
+
},
|
|
61
|
+
hint: "Use match_mode='AND' to find decisions with ALL tags, 'OR' for ANY tag"
|
|
62
|
+
},
|
|
63
|
+
search_layer: {
|
|
64
|
+
required: ['layer'],
|
|
65
|
+
optional: ['status', 'include_tags'],
|
|
66
|
+
example: {
|
|
67
|
+
action: 'search_layer',
|
|
68
|
+
layer: 'business',
|
|
69
|
+
status: 'active',
|
|
70
|
+
include_tags: true
|
|
71
|
+
},
|
|
72
|
+
hint: "Valid layers: presentation, business, data, infrastructure, cross-cutting"
|
|
73
|
+
},
|
|
74
|
+
versions: {
|
|
75
|
+
required: ['key'],
|
|
76
|
+
optional: [],
|
|
77
|
+
example: {
|
|
78
|
+
action: 'versions',
|
|
79
|
+
key: 'database/postgresql-choice'
|
|
80
|
+
},
|
|
81
|
+
hint: "Returns version history with timestamps and who made changes"
|
|
82
|
+
},
|
|
83
|
+
quick_set: {
|
|
84
|
+
required: ['key', 'value'],
|
|
85
|
+
optional: ['agent', 'layer', 'version', 'status', 'tags', 'scopes'],
|
|
86
|
+
example: {
|
|
87
|
+
action: 'quick_set',
|
|
88
|
+
key: 'api/instruments/oscillator-refactor',
|
|
89
|
+
value: 'Moved oscillator_type to MonophonicSynthConfig for better separation'
|
|
90
|
+
},
|
|
91
|
+
hint: "Auto-infers layer from key prefix (api/*→presentation, db/*→data, service/*→business). Reduces required parameters from 7 to 2."
|
|
92
|
+
},
|
|
93
|
+
search_advanced: {
|
|
94
|
+
required: [],
|
|
95
|
+
optional: [
|
|
96
|
+
'layers', 'tags_all', 'tags_any', 'exclude_tags', 'scopes',
|
|
97
|
+
'updated_after', 'updated_before', 'decided_by', 'statuses',
|
|
98
|
+
'search_text', 'sort_by', 'sort_order', 'limit', 'offset'
|
|
99
|
+
],
|
|
100
|
+
example: {
|
|
101
|
+
action: 'search_advanced',
|
|
102
|
+
layers: ['business', 'data'],
|
|
103
|
+
tags_all: ['breaking'],
|
|
104
|
+
updated_after: '2025-01-01',
|
|
105
|
+
sort_by: 'updated',
|
|
106
|
+
sort_order: 'desc',
|
|
107
|
+
limit: 20
|
|
108
|
+
},
|
|
109
|
+
hint: "Use tags_all for AND logic (must have ALL tags), tags_any for OR logic (must have ANY tag)"
|
|
110
|
+
},
|
|
111
|
+
set_batch: {
|
|
112
|
+
required: ['decisions'],
|
|
113
|
+
optional: ['atomic'],
|
|
114
|
+
example: {
|
|
115
|
+
action: 'set_batch',
|
|
116
|
+
decisions: [
|
|
117
|
+
{ key: 'cache/redis-choice', value: 'Using Redis for session storage', layer: 'infrastructure' },
|
|
118
|
+
{ key: 'cache/ttl', value: '3600', layer: 'infrastructure' }
|
|
119
|
+
],
|
|
120
|
+
atomic: false
|
|
121
|
+
},
|
|
122
|
+
hint: "Use atomic:false for best-effort batch operations (recommended for AI agents). Set atomic:true only when all-or-nothing is required. Max 50 decisions per batch."
|
|
123
|
+
},
|
|
124
|
+
has_updates: {
|
|
125
|
+
required: ['agent_name', 'since_timestamp'],
|
|
126
|
+
optional: [],
|
|
127
|
+
example: {
|
|
128
|
+
action: 'has_updates',
|
|
129
|
+
agent_name: 'my-agent',
|
|
130
|
+
since_timestamp: '2025-10-14T08:00:00Z'
|
|
131
|
+
},
|
|
132
|
+
hint: "Lightweight polling mechanism (~5-10 tokens per check). Use ISO 8601 timestamp format."
|
|
133
|
+
},
|
|
134
|
+
set_from_template: {
|
|
135
|
+
required: ['template', 'key', 'value'],
|
|
136
|
+
optional: ['agent', 'layer', 'version', 'status', 'tags', 'scopes'],
|
|
137
|
+
example: {
|
|
138
|
+
action: 'set_from_template',
|
|
139
|
+
template: 'breaking_change',
|
|
140
|
+
key: 'api/remove-legacy-endpoint',
|
|
141
|
+
value: 'Removed /v1/users endpoint - migrate to /v2/users'
|
|
142
|
+
},
|
|
143
|
+
hint: "Built-in templates: breaking_change, security_vulnerability, performance_optimization, deprecation, architecture_decision"
|
|
144
|
+
},
|
|
145
|
+
create_template: {
|
|
146
|
+
required: ['name', 'defaults'],
|
|
147
|
+
optional: ['required_fields', 'created_by'],
|
|
148
|
+
example: {
|
|
149
|
+
action: 'create_template',
|
|
150
|
+
name: 'bug_fix',
|
|
151
|
+
defaults: {
|
|
152
|
+
layer: 'business',
|
|
153
|
+
tags: ['bug', 'fix'],
|
|
154
|
+
status: 'active'
|
|
155
|
+
},
|
|
156
|
+
created_by: 'team-lead'
|
|
157
|
+
},
|
|
158
|
+
hint: "Templates enable reusable decision patterns with consistent metadata"
|
|
159
|
+
},
|
|
160
|
+
list_templates: {
|
|
161
|
+
required: [],
|
|
162
|
+
optional: [],
|
|
163
|
+
example: {
|
|
164
|
+
action: 'list_templates'
|
|
165
|
+
},
|
|
166
|
+
hint: "Returns both built-in and custom templates"
|
|
167
|
+
},
|
|
168
|
+
hard_delete: {
|
|
169
|
+
required: ['key'],
|
|
170
|
+
optional: [],
|
|
171
|
+
example: {
|
|
172
|
+
action: 'hard_delete',
|
|
173
|
+
key: 'old-test-decision'
|
|
174
|
+
},
|
|
175
|
+
hint: "⚠️ IRREVERSIBLE! Permanently deletes decision and all history. Use for cleanup after migration or removing sensitive data."
|
|
176
|
+
},
|
|
177
|
+
add_decision_context: {
|
|
178
|
+
required: ['key', 'rationale'],
|
|
179
|
+
optional: ['alternatives_considered', 'tradeoffs', 'decided_by', 'related_task_id', 'related_constraint_id'],
|
|
180
|
+
example: {
|
|
181
|
+
action: 'add_decision_context',
|
|
182
|
+
key: 'database/postgresql-choice',
|
|
183
|
+
rationale: 'PostgreSQL chosen for ACID compliance and complex query support',
|
|
184
|
+
alternatives_considered: ['MongoDB', 'MySQL', 'SQLite'],
|
|
185
|
+
tradeoffs: {
|
|
186
|
+
pros: ['Strong ACID compliance', 'Advanced query features'],
|
|
187
|
+
cons: ['Slightly higher resource usage', 'Steeper learning curve']
|
|
188
|
+
},
|
|
189
|
+
decided_by: 'architecture-team'
|
|
190
|
+
},
|
|
191
|
+
hint: "Add rich context explaining WHY decisions were made, not just WHAT was decided"
|
|
192
|
+
},
|
|
193
|
+
list_decision_contexts: {
|
|
194
|
+
required: [],
|
|
195
|
+
optional: ['decision_key', 'related_task_id', 'related_constraint_id', 'decided_by', 'limit', 'offset'],
|
|
196
|
+
example: {
|
|
197
|
+
action: 'list_decision_contexts',
|
|
198
|
+
decision_key: 'database/postgresql-choice',
|
|
199
|
+
limit: 50
|
|
200
|
+
},
|
|
201
|
+
hint: "Query decision contexts with optional filters for traceability"
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
// ============================================================================
|
|
205
|
+
// TASK TOOL (12 actions)
|
|
206
|
+
// ============================================================================
|
|
207
|
+
export const TASK_ACTION_SPECS = {
|
|
208
|
+
create: {
|
|
209
|
+
required: ['title'],
|
|
210
|
+
optional: ['description', 'acceptance_criteria', 'notes', 'priority', 'assigned_agent', 'created_by_agent', 'layer', 'tags', 'status', 'watch_files'],
|
|
211
|
+
example: {
|
|
212
|
+
action: 'create',
|
|
213
|
+
title: 'Implement JWT authentication',
|
|
214
|
+
description: 'Add JWT-based authentication to /api/login endpoint',
|
|
215
|
+
priority: 3,
|
|
216
|
+
assigned_agent: 'backend-agent',
|
|
217
|
+
layer: 'business',
|
|
218
|
+
tags: ['authentication', 'security'],
|
|
219
|
+
watch_files: ['src/api/auth.ts', 'src/middleware/jwt.ts']
|
|
220
|
+
},
|
|
221
|
+
hint: "⭐ Use watch_files to automatically link and monitor files. Priority: 1=low, 2=medium, 3=high, 4=critical"
|
|
222
|
+
},
|
|
223
|
+
update: {
|
|
224
|
+
required: ['task_id'],
|
|
225
|
+
optional: ['title', 'priority', 'assigned_agent', 'layer', 'description', 'acceptance_criteria', 'notes', 'watch_files'],
|
|
226
|
+
example: {
|
|
227
|
+
action: 'update',
|
|
228
|
+
task_id: 5,
|
|
229
|
+
priority: 4,
|
|
230
|
+
assigned_agent: 'senior-backend-agent',
|
|
231
|
+
watch_files: ['src/api/users.ts']
|
|
232
|
+
},
|
|
233
|
+
hint: "Only specified fields will be updated; others remain unchanged"
|
|
234
|
+
},
|
|
235
|
+
get: {
|
|
236
|
+
required: ['task_id'],
|
|
237
|
+
optional: ['include_dependencies'],
|
|
238
|
+
example: {
|
|
239
|
+
action: 'get',
|
|
240
|
+
task_id: 5,
|
|
241
|
+
include_dependencies: true
|
|
242
|
+
},
|
|
243
|
+
hint: "Set include_dependencies=true to see blocking/blocked relationships"
|
|
244
|
+
},
|
|
245
|
+
list: {
|
|
246
|
+
required: [],
|
|
247
|
+
optional: ['status', 'assigned_agent', 'layer', 'tags', 'limit', 'offset', 'include_dependency_counts'],
|
|
248
|
+
example: {
|
|
249
|
+
action: 'list',
|
|
250
|
+
status: 'in_progress',
|
|
251
|
+
assigned_agent: 'backend-agent',
|
|
252
|
+
limit: 20
|
|
253
|
+
},
|
|
254
|
+
hint: "Valid statuses: todo, in_progress, waiting_review, blocked, done, archived"
|
|
255
|
+
},
|
|
256
|
+
move: {
|
|
257
|
+
required: ['task_id', 'new_status'],
|
|
258
|
+
optional: [],
|
|
259
|
+
example: {
|
|
260
|
+
action: 'move',
|
|
261
|
+
task_id: 5,
|
|
262
|
+
new_status: 'in_progress'
|
|
263
|
+
},
|
|
264
|
+
hint: "Status transitions are validated. E.g., can't move from 'todo' directly to 'done'"
|
|
265
|
+
},
|
|
266
|
+
link: {
|
|
267
|
+
required: ['task_id', 'link_type', 'target_id'],
|
|
268
|
+
optional: ['link_relation'],
|
|
269
|
+
example: {
|
|
270
|
+
action: 'link',
|
|
271
|
+
task_id: 5,
|
|
272
|
+
link_type: 'decision',
|
|
273
|
+
target_id: 'api/auth-method',
|
|
274
|
+
link_relation: 'implements'
|
|
275
|
+
},
|
|
276
|
+
hint: "⚠️ link_type='file' is DEPRECATED in v3.4.1. Use watch_files parameter or watch_files action instead."
|
|
277
|
+
},
|
|
278
|
+
archive: {
|
|
279
|
+
required: ['task_id'],
|
|
280
|
+
optional: [],
|
|
281
|
+
example: {
|
|
282
|
+
action: 'archive',
|
|
283
|
+
task_id: 5
|
|
284
|
+
},
|
|
285
|
+
hint: "Task must be in 'done' status before archiving"
|
|
286
|
+
},
|
|
287
|
+
batch_create: {
|
|
288
|
+
required: ['tasks'],
|
|
289
|
+
optional: ['atomic'],
|
|
290
|
+
example: {
|
|
291
|
+
action: 'batch_create',
|
|
292
|
+
tasks: [
|
|
293
|
+
{ title: 'Design API', priority: 3 },
|
|
294
|
+
{ title: 'Implement API', priority: 3 },
|
|
295
|
+
{ title: 'Write tests', priority: 2 }
|
|
296
|
+
],
|
|
297
|
+
atomic: false
|
|
298
|
+
},
|
|
299
|
+
hint: "Max 50 tasks per batch. Use atomic:false for best-effort creation."
|
|
300
|
+
},
|
|
301
|
+
add_dependency: {
|
|
302
|
+
required: ['blocker_task_id', 'blocked_task_id'],
|
|
303
|
+
optional: [],
|
|
304
|
+
example: {
|
|
305
|
+
action: 'add_dependency',
|
|
306
|
+
blocker_task_id: 1,
|
|
307
|
+
blocked_task_id: 2
|
|
308
|
+
},
|
|
309
|
+
hint: "Task #1 must complete before Task #2 can start. Prevents circular dependencies."
|
|
310
|
+
},
|
|
311
|
+
remove_dependency: {
|
|
312
|
+
required: ['blocker_task_id', 'blocked_task_id'],
|
|
313
|
+
optional: [],
|
|
314
|
+
example: {
|
|
315
|
+
action: 'remove_dependency',
|
|
316
|
+
blocker_task_id: 1,
|
|
317
|
+
blocked_task_id: 2
|
|
318
|
+
},
|
|
319
|
+
hint: "Silently succeeds even if dependency doesn't exist (idempotent)"
|
|
320
|
+
},
|
|
321
|
+
get_dependencies: {
|
|
322
|
+
required: ['task_id'],
|
|
323
|
+
optional: ['include_details'],
|
|
324
|
+
example: {
|
|
325
|
+
action: 'get_dependencies',
|
|
326
|
+
task_id: 2,
|
|
327
|
+
include_details: false
|
|
328
|
+
},
|
|
329
|
+
hint: "Returns bidirectional: tasks that block this task AND tasks this task blocks"
|
|
330
|
+
},
|
|
331
|
+
watch_files: {
|
|
332
|
+
required: ['task_id', 'action'],
|
|
333
|
+
optional: ['file_paths'],
|
|
334
|
+
example: {
|
|
335
|
+
action: 'watch_files',
|
|
336
|
+
task_id: 5,
|
|
337
|
+
subaction: 'watch',
|
|
338
|
+
file_paths: ['src/api/auth.ts', 'src/middleware/jwt.ts']
|
|
339
|
+
},
|
|
340
|
+
hint: "⭐ NEW in v3.4.1: Replaces task.link(file). Actions: watch, unwatch, list"
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
// ============================================================================
|
|
344
|
+
// FILE TOOL (4 actions)
|
|
345
|
+
// ============================================================================
|
|
346
|
+
export const FILE_ACTION_SPECS = {
|
|
347
|
+
record: {
|
|
348
|
+
required: ['file_path', 'agent_name', 'change_type'],
|
|
349
|
+
optional: ['layer', 'description'],
|
|
350
|
+
example: {
|
|
351
|
+
action: 'record',
|
|
352
|
+
file_path: 'src/api/auth.ts',
|
|
353
|
+
agent_name: 'refactor-agent',
|
|
354
|
+
change_type: 'modified',
|
|
355
|
+
layer: 'business',
|
|
356
|
+
description: 'Added JWT validation'
|
|
357
|
+
},
|
|
358
|
+
hint: "Valid change_type: created, modified, deleted"
|
|
359
|
+
},
|
|
360
|
+
get: {
|
|
361
|
+
required: [],
|
|
362
|
+
optional: ['file_path', 'agent_name', 'layer', 'change_type', 'since', 'limit'],
|
|
363
|
+
example: {
|
|
364
|
+
action: 'get',
|
|
365
|
+
agent_name: 'refactor-agent',
|
|
366
|
+
layer: 'business',
|
|
367
|
+
limit: 10
|
|
368
|
+
},
|
|
369
|
+
hint: "Use 'since' with ISO 8601 timestamp for time-based filtering"
|
|
370
|
+
},
|
|
371
|
+
check_lock: {
|
|
372
|
+
required: ['file_path'],
|
|
373
|
+
optional: ['lock_duration'],
|
|
374
|
+
example: {
|
|
375
|
+
action: 'check_lock',
|
|
376
|
+
file_path: 'src/database/schema.sql',
|
|
377
|
+
lock_duration: 300
|
|
378
|
+
},
|
|
379
|
+
hint: "Default lock_duration is 300 seconds (5 minutes). Prevents concurrent edits."
|
|
380
|
+
},
|
|
381
|
+
record_batch: {
|
|
382
|
+
required: ['file_changes'],
|
|
383
|
+
optional: ['atomic'],
|
|
384
|
+
example: {
|
|
385
|
+
action: 'record_batch',
|
|
386
|
+
file_changes: [
|
|
387
|
+
{ file_path: 'src/api.ts', agent_name: 'bot1', change_type: 'modified', layer: 'presentation' },
|
|
388
|
+
{ file_path: 'src/types.ts', agent_name: 'bot1', change_type: 'modified', layer: 'data' }
|
|
389
|
+
],
|
|
390
|
+
atomic: false
|
|
391
|
+
},
|
|
392
|
+
hint: "Max 50 file changes per batch. Use atomic:false for best-effort recording."
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
// ============================================================================
|
|
396
|
+
// CONSTRAINT TOOL (3 actions)
|
|
397
|
+
// ============================================================================
|
|
398
|
+
export const CONSTRAINT_ACTION_SPECS = {
|
|
399
|
+
add: {
|
|
400
|
+
required: ['category', 'constraint_text', 'priority'],
|
|
401
|
+
optional: ['layer', 'tags', 'created_by'],
|
|
402
|
+
example: {
|
|
403
|
+
action: 'add',
|
|
404
|
+
category: 'performance',
|
|
405
|
+
constraint_text: 'API response time must be <100ms for 95th percentile',
|
|
406
|
+
priority: 'high',
|
|
407
|
+
layer: 'business',
|
|
408
|
+
tags: ['api', 'latency']
|
|
409
|
+
},
|
|
410
|
+
hint: "Valid categories: performance, architecture, security. Valid priorities: low, medium, high, critical"
|
|
411
|
+
},
|
|
412
|
+
get: {
|
|
413
|
+
required: [],
|
|
414
|
+
optional: ['category', 'layer', 'priority', 'tags', 'limit'],
|
|
415
|
+
example: {
|
|
416
|
+
action: 'get',
|
|
417
|
+
category: 'performance',
|
|
418
|
+
priority: 'high',
|
|
419
|
+
limit: 50
|
|
420
|
+
},
|
|
421
|
+
hint: "Returns only active constraints by default"
|
|
422
|
+
},
|
|
423
|
+
deactivate: {
|
|
424
|
+
required: ['constraint_id'],
|
|
425
|
+
optional: [],
|
|
426
|
+
example: {
|
|
427
|
+
action: 'deactivate',
|
|
428
|
+
constraint_id: 5
|
|
429
|
+
},
|
|
430
|
+
hint: "Soft delete - constraint remains in database but marked inactive"
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
// ============================================================================
|
|
434
|
+
// STATS TOOL (5 actions)
|
|
435
|
+
// ============================================================================
|
|
436
|
+
export const STATS_ACTION_SPECS = {
|
|
437
|
+
layer_summary: {
|
|
438
|
+
required: [],
|
|
439
|
+
optional: [],
|
|
440
|
+
example: {
|
|
441
|
+
action: 'layer_summary'
|
|
442
|
+
},
|
|
443
|
+
hint: "Returns decision, file change, and constraint counts per layer"
|
|
444
|
+
},
|
|
445
|
+
db_stats: {
|
|
446
|
+
required: [],
|
|
447
|
+
optional: [],
|
|
448
|
+
example: {
|
|
449
|
+
action: 'db_stats'
|
|
450
|
+
},
|
|
451
|
+
hint: "Comprehensive statistics including task counts by status and priority"
|
|
452
|
+
},
|
|
453
|
+
clear: {
|
|
454
|
+
required: [],
|
|
455
|
+
optional: ['messages_older_than_hours', 'file_changes_older_than_days'],
|
|
456
|
+
example: {
|
|
457
|
+
action: 'clear',
|
|
458
|
+
messages_older_than_hours: 48,
|
|
459
|
+
file_changes_older_than_days: 14
|
|
460
|
+
},
|
|
461
|
+
hint: "If no parameters provided, uses config-based weekend-aware retention"
|
|
462
|
+
},
|
|
463
|
+
activity_log: {
|
|
464
|
+
required: [],
|
|
465
|
+
optional: ['since', 'agent_names', 'actions', 'limit'],
|
|
466
|
+
example: {
|
|
467
|
+
action: 'activity_log',
|
|
468
|
+
since: '1h',
|
|
469
|
+
agent_names: ['bot1', 'bot2'],
|
|
470
|
+
limit: 50
|
|
471
|
+
},
|
|
472
|
+
hint: "Use relative time formats: '5m', '1h', '2d' or ISO 8601 timestamps"
|
|
473
|
+
},
|
|
474
|
+
flush: {
|
|
475
|
+
required: [],
|
|
476
|
+
optional: [],
|
|
477
|
+
example: {
|
|
478
|
+
action: 'flush'
|
|
479
|
+
},
|
|
480
|
+
hint: "Forces WAL checkpoint to flush pending transactions. Run before git commits."
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
// ============================================================================
|
|
484
|
+
// MASTER REGISTRY
|
|
485
|
+
// ============================================================================
|
|
486
|
+
export const ACTION_SPECS_BY_TOOL = {
|
|
487
|
+
decision: DECISION_ACTION_SPECS,
|
|
488
|
+
task: TASK_ACTION_SPECS,
|
|
489
|
+
file: FILE_ACTION_SPECS,
|
|
490
|
+
constraint: CONSTRAINT_ACTION_SPECS,
|
|
491
|
+
stats: STATS_ACTION_SPECS
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* Get action specification for a tool/action combination
|
|
495
|
+
* @param tool Tool name (e.g., 'decision', 'task')
|
|
496
|
+
* @param action Action name (e.g., 'set', 'create')
|
|
497
|
+
* @returns Action specification or null if not found
|
|
498
|
+
*/
|
|
499
|
+
export function getActionSpec(tool, action) {
|
|
500
|
+
const toolSpecs = ACTION_SPECS_BY_TOOL[tool];
|
|
501
|
+
if (!toolSpecs) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
return toolSpecs[action] || null;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Check if an action exists for a tool
|
|
508
|
+
* @param tool Tool name
|
|
509
|
+
* @param action Action name
|
|
510
|
+
* @returns True if action exists
|
|
511
|
+
*/
|
|
512
|
+
export function hasAction(tool, action) {
|
|
513
|
+
return getActionSpec(tool, action) !== null;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Get all action names for a tool
|
|
517
|
+
* @param tool Tool name
|
|
518
|
+
* @returns Array of action names or empty array if tool not found
|
|
519
|
+
*/
|
|
520
|
+
export function getToolActions(tool) {
|
|
521
|
+
const toolSpecs = ACTION_SPECS_BY_TOOL[tool];
|
|
522
|
+
if (!toolSpecs) {
|
|
523
|
+
return [];
|
|
524
|
+
}
|
|
525
|
+
return Object.keys(toolSpecs);
|
|
526
|
+
}
|
|
527
|
+
//# sourceMappingURL=action-specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-specs.js","sourceRoot":"","sources":["../../src/utils/action-specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E,MAAM,CAAC,MAAM,qBAAqB,GAA+B;IAC/D,GAAG,EAAE;QACH,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;QAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS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AM,CAAC,KAAK,IAAI,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoCH;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,GAAG,GACX;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAyBrC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAiB5D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,IAAI,CAsDN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAMR"}
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
* Provides consistent error logging, reporting, and recovery
|
|
4
4
|
*/
|
|
5
5
|
import { debugLog, debugLogError } from './debug-logger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Safe console error wrapper that prevents EPIPE errors from crashing the error handler
|
|
8
|
+
* When the pipe to Claude Code is broken, console.error throws EPIPE
|
|
9
|
+
* This wrapper silently fails instead of creating cascading errors
|
|
10
|
+
*/
|
|
11
|
+
function safeConsoleError(...args) {
|
|
12
|
+
try {
|
|
13
|
+
// Check if stderr is writable before attempting to write
|
|
14
|
+
if (process.stderr && process.stderr.writable) {
|
|
15
|
+
console.error(...args);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
// Silently ignore EPIPE and other write errors
|
|
20
|
+
// The debug logger will still capture the original error
|
|
21
|
+
}
|
|
22
|
+
}
|
|
6
23
|
/**
|
|
7
24
|
* Format error details for logging and reporting
|
|
8
25
|
*/
|
|
@@ -26,17 +43,17 @@ export function handleToolError(toolName, action, error, params) {
|
|
|
26
43
|
errorType: errorType,
|
|
27
44
|
stack: stack
|
|
28
45
|
});
|
|
29
|
-
// Log to stderr for immediate visibility
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
// Log to stderr for immediate visibility (pipe-safe)
|
|
47
|
+
safeConsoleError(`\n❌ ERROR in ${toolName}.${action}:`);
|
|
48
|
+
safeConsoleError(` Message: ${message}`);
|
|
32
49
|
if (stack) {
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
safeConsoleError(` Stack trace:`);
|
|
51
|
+
safeConsoleError(stack.split('\n').map(line => ` ${line}`).join('\n'));
|
|
35
52
|
}
|
|
36
53
|
if (params) {
|
|
37
|
-
|
|
54
|
+
safeConsoleError(` Params: ${JSON.stringify(params, null, 2)}`);
|
|
38
55
|
}
|
|
39
|
-
|
|
56
|
+
safeConsoleError('');
|
|
40
57
|
return { message, stack };
|
|
41
58
|
}
|
|
42
59
|
/**
|
|
@@ -49,13 +66,13 @@ export function handleInitializationError(error) {
|
|
|
49
66
|
errorType: errorType,
|
|
50
67
|
stack: stack
|
|
51
68
|
});
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
safeConsoleError('\n❌ INITIALIZATION ERROR:');
|
|
70
|
+
safeConsoleError(` Message: ${message}`);
|
|
54
71
|
if (stack) {
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
safeConsoleError(` Stack trace:`);
|
|
73
|
+
safeConsoleError(stack.split('\n').map(line => ` ${line}`).join('\n'));
|
|
57
74
|
}
|
|
58
|
-
|
|
75
|
+
safeConsoleError('');
|
|
59
76
|
return message;
|
|
60
77
|
}
|
|
61
78
|
/**
|
|
@@ -66,42 +83,42 @@ export function setupGlobalErrorHandlers(onCleanup) {
|
|
|
66
83
|
// Handle uncaught exceptions
|
|
67
84
|
process.on('uncaughtException', (error) => {
|
|
68
85
|
const { message, stack, errorType } = formatErrorDetails(error);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
safeConsoleError('\n❌ UNCAUGHT EXCEPTION (server continuing):');
|
|
87
|
+
safeConsoleError(` Message: ${message}`);
|
|
88
|
+
safeConsoleError(` Stack trace:`);
|
|
89
|
+
safeConsoleError(stack?.split('\n').map(line => ` ${line}`).join('\n'));
|
|
73
90
|
debugLogError('UNCAUGHT_EXCEPTION', error, {
|
|
74
91
|
errorType: errorType,
|
|
75
92
|
stack: stack
|
|
76
93
|
});
|
|
77
|
-
|
|
94
|
+
safeConsoleError(' ⚠️ Server continuing despite error\n');
|
|
78
95
|
});
|
|
79
96
|
// Handle unhandled promise rejections
|
|
80
97
|
process.on('unhandledRejection', (reason, promise) => {
|
|
81
98
|
const { message, stack, errorType } = formatErrorDetails(reason);
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
safeConsoleError('\n❌ UNHANDLED PROMISE REJECTION (server continuing):');
|
|
100
|
+
safeConsoleError(` Reason: ${message}`);
|
|
84
101
|
if (stack) {
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
safeConsoleError(` Stack trace:`);
|
|
103
|
+
safeConsoleError(stack.split('\n').map(line => ` ${line}`).join('\n'));
|
|
87
104
|
}
|
|
88
105
|
debugLogError('UNHANDLED_REJECTION', reason, {
|
|
89
106
|
errorType: errorType,
|
|
90
107
|
stack: stack,
|
|
91
108
|
promise: String(promise)
|
|
92
109
|
});
|
|
93
|
-
|
|
110
|
+
safeConsoleError(' ⚠️ Server continuing despite error\n');
|
|
94
111
|
});
|
|
95
112
|
// Handle graceful shutdown
|
|
96
113
|
process.on('SIGINT', async () => {
|
|
97
|
-
|
|
114
|
+
safeConsoleError('\n✓ Shutting down MCP server...');
|
|
98
115
|
if (onCleanup) {
|
|
99
116
|
onCleanup();
|
|
100
117
|
}
|
|
101
118
|
process.exit(0);
|
|
102
119
|
});
|
|
103
120
|
process.on('SIGTERM', async () => {
|
|
104
|
-
|
|
121
|
+
safeConsoleError('\n✓ Shutting down MCP server...');
|
|
105
122
|
if (onCleanup) {
|
|
106
123
|
onCleanup();
|
|
107
124
|
}
|