sqlew 1.1.2 → 2.1.0
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 +259 -0
- package/MIGRATION_v2.md +538 -0
- package/README.md +444 -79
- package/assets/schema.sql +122 -36
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +312 -0
- package/dist/cli.js.map +1 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +18 -0
- package/dist/database.js.map +1 -1
- package/dist/index.js +373 -707
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-v2.1.0-features.d.ts +29 -0
- package/dist/migrations/add-v2.1.0-features.d.ts.map +1 -0
- package/dist/migrations/add-v2.1.0-features.js +198 -0
- package/dist/migrations/add-v2.1.0-features.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -0
- package/dist/schema.js.map +1 -1
- package/dist/tools/context.d.ts +91 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +614 -0
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts +10 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +98 -1
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +10 -1
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +107 -1
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/utils.d.ts +9 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +115 -0
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +196 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cleanup.d.ts +12 -1
- package/dist/utils/cleanup.d.ts.map +1 -1
- package/dist/utils/cleanup.js +20 -3
- package/dist/utils/cleanup.js.map +1 -1
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -8,11 +8,11 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
8
8
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
import { initializeDatabase, closeDatabase, setConfigValue, getAllConfig } from './database.js';
|
|
10
10
|
import { CONFIG_KEYS } from './constants.js';
|
|
11
|
-
import { setDecision, getContext, getDecision, searchByTags, getVersions, searchByLayer } from './tools/context.js';
|
|
12
|
-
import { sendMessage, getMessages, markRead } from './tools/messaging.js';
|
|
13
|
-
import { recordFileChange, getFileChanges, checkFileLock } from './tools/files.js';
|
|
11
|
+
import { setDecision, getContext, getDecision, searchByTags, getVersions, searchByLayer, quickSetDecision, searchAdvanced, setDecisionBatch, hasUpdates, setFromTemplate, createTemplate, listTemplates } from './tools/context.js';
|
|
12
|
+
import { sendMessage, getMessages, markRead, sendMessageBatch } from './tools/messaging.js';
|
|
13
|
+
import { recordFileChange, getFileChanges, checkFileLock, recordFileChangeBatch } from './tools/files.js';
|
|
14
14
|
import { addConstraint, getConstraints, deactivateConstraint } from './tools/constraints.js';
|
|
15
|
-
import { getLayerSummary, clearOldData, getStats } from './tools/utils.js';
|
|
15
|
+
import { getLayerSummary, clearOldData, getStats, getActivityLog } from './tools/utils.js';
|
|
16
16
|
import { getConfig, updateConfig } from './tools/config.js';
|
|
17
17
|
// Parse command-line arguments
|
|
18
18
|
const args = process.argv.slice(2);
|
|
@@ -92,505 +92,150 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
92
92
|
return {
|
|
93
93
|
tools: [
|
|
94
94
|
{
|
|
95
|
-
name: '
|
|
96
|
-
description: '
|
|
95
|
+
name: 'decision',
|
|
96
|
+
description: 'Manage decisions (13 actions + help)',
|
|
97
97
|
inputSchema: {
|
|
98
98
|
type: 'object',
|
|
99
99
|
properties: {
|
|
100
|
-
|
|
101
|
-
type: 'string',
|
|
102
|
-
description: '
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: 'get_context',
|
|
142
|
-
description: 'Retrieve decisions with advanced filtering. Returns token-efficient view with all metadata. Supports filtering by status, layer, tags, and scope.',
|
|
143
|
-
inputSchema: {
|
|
144
|
-
type: 'object',
|
|
145
|
-
properties: {
|
|
146
|
-
status: {
|
|
147
|
-
type: 'string',
|
|
148
|
-
description: 'Filter by decision status',
|
|
149
|
-
enum: ['active', 'deprecated', 'draft'],
|
|
150
|
-
},
|
|
151
|
-
layer: {
|
|
152
|
-
type: 'string',
|
|
153
|
-
description: 'Filter by architecture layer',
|
|
154
|
-
enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'],
|
|
155
|
-
},
|
|
156
|
-
tags: {
|
|
157
|
-
type: 'array',
|
|
158
|
-
items: { type: 'string' },
|
|
159
|
-
description: 'Filter by tags (use tag_match to control AND/OR logic)',
|
|
160
|
-
},
|
|
161
|
-
scope: {
|
|
162
|
-
type: 'string',
|
|
163
|
-
description: 'Filter by specific scope/module',
|
|
164
|
-
},
|
|
165
|
-
tag_match: {
|
|
166
|
-
type: 'string',
|
|
167
|
-
description: 'Tag matching mode: "AND" (all tags required) or "OR" (any tag)',
|
|
168
|
-
enum: ['AND', 'OR'],
|
|
169
|
-
default: 'OR',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
name: 'get_decision',
|
|
176
|
-
description: 'Get a specific decision by key. Returns full metadata including tags, layer, scopes, version, and timestamp.',
|
|
177
|
-
inputSchema: {
|
|
178
|
-
type: 'object',
|
|
179
|
-
properties: {
|
|
180
|
-
key: {
|
|
181
|
-
type: 'string',
|
|
182
|
-
description: 'Decision key to retrieve',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
required: ['key'],
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: 'search_by_tags',
|
|
190
|
-
description: 'Search for decisions by tags with AND/OR logic. Supports flexible tag-based filtering with optional status and layer filters.',
|
|
191
|
-
inputSchema: {
|
|
192
|
-
type: 'object',
|
|
193
|
-
properties: {
|
|
194
|
-
tags: {
|
|
195
|
-
type: 'array',
|
|
196
|
-
items: { type: 'string' },
|
|
197
|
-
description: 'Array of tags to search for (at least one required)',
|
|
198
|
-
},
|
|
199
|
-
match_mode: {
|
|
200
|
-
type: 'string',
|
|
201
|
-
description: 'Tag matching mode: "AND" (all tags required) or "OR" (any tag)',
|
|
202
|
-
enum: ['AND', 'OR'],
|
|
203
|
-
default: 'OR',
|
|
204
|
-
},
|
|
205
|
-
status: {
|
|
206
|
-
type: 'string',
|
|
207
|
-
description: 'Optional filter by decision status',
|
|
208
|
-
enum: ['active', 'deprecated', 'draft'],
|
|
209
|
-
},
|
|
210
|
-
layer: {
|
|
211
|
-
type: 'string',
|
|
212
|
-
description: 'Optional filter by architecture layer',
|
|
213
|
-
enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'],
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
required: ['tags'],
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
name: 'get_versions',
|
|
221
|
-
description: 'Get version history for a specific decision key. Returns all historical versions ordered by timestamp (newest first).',
|
|
222
|
-
inputSchema: {
|
|
223
|
-
type: 'object',
|
|
224
|
-
properties: {
|
|
225
|
-
key: {
|
|
226
|
-
type: 'string',
|
|
227
|
-
description: 'Decision key to get version history for',
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
required: ['key'],
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
name: 'search_by_layer',
|
|
235
|
-
description: 'Search for decisions within a specific architecture layer. Supports status filtering and optional tag inclusion.',
|
|
236
|
-
inputSchema: {
|
|
237
|
-
type: 'object',
|
|
238
|
-
properties: {
|
|
239
|
-
layer: {
|
|
240
|
-
type: 'string',
|
|
241
|
-
description: 'Architecture layer to search in',
|
|
242
|
-
enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'],
|
|
243
|
-
},
|
|
244
|
-
status: {
|
|
245
|
-
type: 'string',
|
|
246
|
-
description: 'Filter by decision status (defaults to "active")',
|
|
247
|
-
enum: ['active', 'deprecated', 'draft'],
|
|
248
|
-
default: 'active',
|
|
249
|
-
},
|
|
250
|
-
include_tags: {
|
|
251
|
-
type: 'boolean',
|
|
252
|
-
description: 'Include tag information in results (defaults to true)',
|
|
253
|
-
default: true,
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
required: ['layer'],
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
name: 'send_message',
|
|
261
|
-
description: 'Send a message from one agent to another (or broadcast to all). Supports priority levels and optional JSON payload.',
|
|
262
|
-
inputSchema: {
|
|
263
|
-
type: 'object',
|
|
264
|
-
properties: {
|
|
265
|
-
from_agent: {
|
|
266
|
-
type: 'string',
|
|
267
|
-
description: 'Name of the sending agent',
|
|
268
|
-
},
|
|
269
|
-
to_agent: {
|
|
270
|
-
type: ['string', 'null'],
|
|
271
|
-
description: 'Name of the receiving agent (null or omit for broadcast)',
|
|
272
|
-
},
|
|
273
|
-
msg_type: {
|
|
274
|
-
type: 'string',
|
|
275
|
-
description: 'Type of message',
|
|
276
|
-
enum: ['decision', 'warning', 'request', 'info'],
|
|
277
|
-
},
|
|
278
|
-
message: {
|
|
279
|
-
type: 'string',
|
|
280
|
-
description: 'The message content',
|
|
281
|
-
},
|
|
282
|
-
priority: {
|
|
283
|
-
type: 'string',
|
|
284
|
-
description: 'Message priority level (defaults to "medium")',
|
|
285
|
-
enum: ['low', 'medium', 'high', 'critical'],
|
|
286
|
-
default: 'medium',
|
|
287
|
-
},
|
|
288
|
-
payload: {
|
|
289
|
-
type: 'object',
|
|
290
|
-
description: 'Optional JSON payload with additional data',
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
required: ['from_agent', 'msg_type', 'message'],
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
name: 'get_messages',
|
|
298
|
-
description: 'Retrieve messages for an agent. Returns messages addressed to the agent or broadcast messages. Supports filtering by read status, priority, and message type.',
|
|
299
|
-
inputSchema: {
|
|
300
|
-
type: 'object',
|
|
301
|
-
properties: {
|
|
302
|
-
agent_name: {
|
|
303
|
-
type: 'string',
|
|
304
|
-
description: 'Name of the agent to retrieve messages for',
|
|
305
|
-
},
|
|
306
|
-
unread_only: {
|
|
307
|
-
type: 'boolean',
|
|
308
|
-
description: 'Only return unread messages (defaults to false)',
|
|
309
|
-
default: false,
|
|
310
|
-
},
|
|
311
|
-
priority_filter: {
|
|
312
|
-
type: 'string',
|
|
313
|
-
description: 'Filter by specific priority level',
|
|
314
|
-
enum: ['low', 'medium', 'high', 'critical'],
|
|
315
|
-
},
|
|
316
|
-
msg_type_filter: {
|
|
317
|
-
type: 'string',
|
|
318
|
-
description: 'Filter by message type',
|
|
319
|
-
enum: ['decision', 'warning', 'request', 'info'],
|
|
320
|
-
},
|
|
321
|
-
limit: {
|
|
322
|
-
type: 'number',
|
|
323
|
-
description: 'Maximum number of messages to return (defaults to 50)',
|
|
324
|
-
default: 50,
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
required: ['agent_name'],
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
name: 'mark_read',
|
|
332
|
-
description: 'Mark messages as read. Only marks messages addressed to the specified agent (security check). Idempotent operation.',
|
|
333
|
-
inputSchema: {
|
|
334
|
-
type: 'object',
|
|
335
|
-
properties: {
|
|
336
|
-
message_ids: {
|
|
337
|
-
type: 'array',
|
|
338
|
-
items: { type: 'number' },
|
|
339
|
-
description: 'Array of message IDs to mark as read',
|
|
340
|
-
},
|
|
341
|
-
agent_name: {
|
|
342
|
-
type: 'string',
|
|
343
|
-
description: 'Name of the agent marking messages as read',
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
required: ['message_ids', 'agent_name'],
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
name: 'record_file_change',
|
|
351
|
-
description: 'Record a file change with optional layer assignment and description. Auto-registers the file and agent. Useful for tracking file modifications across agents.',
|
|
352
|
-
inputSchema: {
|
|
353
|
-
type: 'object',
|
|
354
|
-
properties: {
|
|
355
|
-
file_path: {
|
|
356
|
-
type: 'string',
|
|
357
|
-
description: 'The file path (absolute or relative)',
|
|
358
|
-
},
|
|
359
|
-
agent_name: {
|
|
360
|
-
type: 'string',
|
|
361
|
-
description: 'Name of the agent making the change',
|
|
362
|
-
},
|
|
363
|
-
change_type: {
|
|
364
|
-
type: 'string',
|
|
365
|
-
description: 'Type of change made to the file',
|
|
366
|
-
enum: ['created', 'modified', 'deleted'],
|
|
367
|
-
},
|
|
368
|
-
layer: {
|
|
369
|
-
type: 'string',
|
|
370
|
-
description: 'Optional architecture layer assignment',
|
|
371
|
-
enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'],
|
|
372
|
-
},
|
|
373
|
-
description: {
|
|
374
|
-
type: 'string',
|
|
375
|
-
description: 'Optional description of the change',
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
required: ['file_path', 'agent_name', 'change_type'],
|
|
379
|
-
},
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
name: 'get_file_changes',
|
|
383
|
-
description: 'Retrieve file changes with advanced filtering. Supports filtering by file, agent, layer, change type, and time range. Returns token-efficient view when no filters applied.',
|
|
384
|
-
inputSchema: {
|
|
385
|
-
type: 'object',
|
|
386
|
-
properties: {
|
|
387
|
-
file_path: {
|
|
388
|
-
type: 'string',
|
|
389
|
-
description: 'Filter by specific file path',
|
|
390
|
-
},
|
|
391
|
-
agent_name: {
|
|
392
|
-
type: 'string',
|
|
393
|
-
description: 'Filter by agent who made the change',
|
|
394
|
-
},
|
|
395
|
-
layer: {
|
|
396
|
-
type: 'string',
|
|
397
|
-
description: 'Filter by architecture layer',
|
|
398
|
-
enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'],
|
|
399
|
-
},
|
|
400
|
-
change_type: {
|
|
401
|
-
type: 'string',
|
|
402
|
-
description: 'Filter by type of change',
|
|
403
|
-
enum: ['created', 'modified', 'deleted'],
|
|
404
|
-
},
|
|
405
|
-
since: {
|
|
406
|
-
type: 'string',
|
|
407
|
-
description: 'ISO 8601 timestamp - return changes since this time',
|
|
408
|
-
},
|
|
409
|
-
limit: {
|
|
410
|
-
type: 'number',
|
|
411
|
-
description: 'Maximum number of changes to return (default: 100)',
|
|
412
|
-
default: 100,
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
name: 'check_file_lock',
|
|
419
|
-
description: 'Check if a file is "locked" (recently modified). Useful to prevent concurrent edits by multiple agents. Returns lock status with details of last change.',
|
|
420
|
-
inputSchema: {
|
|
421
|
-
type: 'object',
|
|
422
|
-
properties: {
|
|
423
|
-
file_path: {
|
|
424
|
-
type: 'string',
|
|
425
|
-
description: 'The file path to check',
|
|
426
|
-
},
|
|
427
|
-
lock_duration: {
|
|
428
|
-
type: 'number',
|
|
429
|
-
description: 'Time window in seconds to consider "locked" (default: 300 = 5 minutes)',
|
|
430
|
-
default: 300,
|
|
431
|
-
},
|
|
100
|
+
action: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'Action',
|
|
103
|
+
enum: ['set', 'get', 'list', 'search_tags', 'search_layer', 'versions', 'quick_set', 'search_advanced', 'set_batch', 'has_updates', 'set_from_template', 'create_template', 'list_templates', 'help']
|
|
104
|
+
},
|
|
105
|
+
key: { type: 'string' },
|
|
106
|
+
value: { type: ['string', 'number'] },
|
|
107
|
+
agent: { type: 'string' },
|
|
108
|
+
layer: { type: 'string', enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'] },
|
|
109
|
+
version: { type: 'string' },
|
|
110
|
+
status: { type: 'string', enum: ['active', 'deprecated', 'draft'] },
|
|
111
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
112
|
+
scopes: { type: 'array', items: { type: 'string' } },
|
|
113
|
+
scope: { type: 'string' },
|
|
114
|
+
tag_match: { type: 'string', enum: ['AND', 'OR'] },
|
|
115
|
+
include_tags: { type: 'boolean' },
|
|
116
|
+
layers: { type: 'array', items: { type: 'string' } },
|
|
117
|
+
tags_all: { type: 'array', items: { type: 'string' } },
|
|
118
|
+
tags_any: { type: 'array', items: { type: 'string' } },
|
|
119
|
+
exclude_tags: { type: 'array', items: { type: 'string' } },
|
|
120
|
+
updated_after: { type: 'string' },
|
|
121
|
+
updated_before: { type: 'string' },
|
|
122
|
+
decided_by: { type: 'array', items: { type: 'string' } },
|
|
123
|
+
statuses: { type: 'array', items: { type: 'string', enum: ['active', 'deprecated', 'draft'] } },
|
|
124
|
+
search_text: { type: 'string' },
|
|
125
|
+
sort_by: { type: 'string', enum: ['updated', 'key', 'version'] },
|
|
126
|
+
sort_order: { type: 'string', enum: ['asc', 'desc'] },
|
|
127
|
+
limit: { type: 'number' },
|
|
128
|
+
offset: { type: 'number' },
|
|
129
|
+
decisions: { type: 'array' },
|
|
130
|
+
atomic: { type: 'boolean' },
|
|
131
|
+
agent_name: { type: 'string' },
|
|
132
|
+
since_timestamp: { type: 'string' },
|
|
133
|
+
template: { type: 'string' },
|
|
134
|
+
name: { type: 'string' },
|
|
135
|
+
defaults: { type: 'object' },
|
|
136
|
+
required_fields: { type: 'array', items: { type: 'string' } },
|
|
137
|
+
created_by: { type: 'string' },
|
|
432
138
|
},
|
|
433
|
-
required: ['
|
|
139
|
+
required: ['action'],
|
|
434
140
|
},
|
|
435
141
|
},
|
|
436
142
|
{
|
|
437
|
-
name: '
|
|
438
|
-
description: '
|
|
143
|
+
name: 'message',
|
|
144
|
+
description: 'Agent messaging (actions: send, get, mark_read, send_batch)',
|
|
439
145
|
inputSchema: {
|
|
440
146
|
type: 'object',
|
|
441
147
|
properties: {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
type: 'string',
|
|
459
|
-
description: 'Optional architecture layer assignment',
|
|
460
|
-
enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'],
|
|
461
|
-
},
|
|
462
|
-
tags: {
|
|
463
|
-
type: 'array',
|
|
464
|
-
items: { type: 'string' },
|
|
465
|
-
description: 'Optional tags for categorization (e.g., ["api", "security"])',
|
|
466
|
-
},
|
|
467
|
-
created_by: {
|
|
468
|
-
type: 'string',
|
|
469
|
-
description: 'Agent creating the constraint (defaults to "system")',
|
|
470
|
-
},
|
|
148
|
+
action: { type: 'string', description: 'Action (use "help" for usage)', enum: ['send', 'get', 'mark_read', 'send_batch', 'help'] },
|
|
149
|
+
agent_name: { type: 'string' },
|
|
150
|
+
from_agent: { type: 'string' },
|
|
151
|
+
to_agent: { type: ['string', 'null'] },
|
|
152
|
+
msg_type: { type: 'string', enum: ['decision', 'warning', 'request', 'info'] },
|
|
153
|
+
message: { type: 'string' },
|
|
154
|
+
priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'], default: 'medium' },
|
|
155
|
+
payload: { type: 'object' },
|
|
156
|
+
message_ids: { type: 'array', items: { type: 'number' } },
|
|
157
|
+
unread_only: { type: 'boolean', default: false },
|
|
158
|
+
msg_type_filter: { type: 'string', enum: ['decision', 'warning', 'request', 'info'] },
|
|
159
|
+
priority_filter: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
|
|
160
|
+
limit: { type: 'number', default: 50 },
|
|
161
|
+
// send_batch parameters
|
|
162
|
+
messages: { type: 'array', description: 'Array of messages for batch operation (max: 50)' },
|
|
163
|
+
atomic: { type: 'boolean', description: 'Atomic mode - all succeed or all fail (default: true)' },
|
|
471
164
|
},
|
|
472
|
-
required: ['
|
|
165
|
+
required: ['action'],
|
|
473
166
|
},
|
|
474
167
|
},
|
|
475
168
|
{
|
|
476
|
-
name: '
|
|
477
|
-
description: '
|
|
169
|
+
name: 'file',
|
|
170
|
+
description: 'File change tracking (actions: record, get, check_lock, record_batch)',
|
|
478
171
|
inputSchema: {
|
|
479
172
|
type: 'object',
|
|
480
173
|
properties: {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
},
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
description: 'Filter by priority level',
|
|
494
|
-
enum: ['low', 'medium', 'high', 'critical'],
|
|
495
|
-
},
|
|
496
|
-
tags: {
|
|
497
|
-
type: 'array',
|
|
498
|
-
items: { type: 'string' },
|
|
499
|
-
description: 'Filter by tags (OR logic - matches ANY tag)',
|
|
500
|
-
},
|
|
501
|
-
active_only: {
|
|
502
|
-
type: 'boolean',
|
|
503
|
-
description: 'Only return active constraints (defaults to true)',
|
|
504
|
-
default: true,
|
|
505
|
-
},
|
|
506
|
-
limit: {
|
|
507
|
-
type: 'number',
|
|
508
|
-
description: 'Maximum number of constraints to return (default: 50)',
|
|
509
|
-
default: 50,
|
|
510
|
-
},
|
|
174
|
+
action: { type: 'string', description: 'Action (use "help" for usage)', enum: ['record', 'get', 'check_lock', 'record_batch', 'help'] },
|
|
175
|
+
file_path: { type: 'string' },
|
|
176
|
+
agent_name: { type: 'string' },
|
|
177
|
+
change_type: { type: 'string', enum: ['created', 'modified', 'deleted'] },
|
|
178
|
+
layer: { type: 'string', enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'] },
|
|
179
|
+
description: { type: 'string' },
|
|
180
|
+
since: { type: 'string' },
|
|
181
|
+
limit: { type: 'number' },
|
|
182
|
+
lock_duration: { type: 'number' },
|
|
183
|
+
// record_batch parameters
|
|
184
|
+
file_changes: { type: 'array', description: 'Array of file changes for batch operation (max: 50)' },
|
|
185
|
+
atomic: { type: 'boolean', description: 'Atomic mode - all succeed or all fail (default: true)' },
|
|
511
186
|
},
|
|
187
|
+
required: ['action'],
|
|
512
188
|
},
|
|
513
189
|
},
|
|
514
190
|
{
|
|
515
|
-
name: '
|
|
516
|
-
description: '
|
|
191
|
+
name: 'constraint',
|
|
192
|
+
description: 'Constraint management (actions: add, get, deactivate)',
|
|
517
193
|
inputSchema: {
|
|
518
194
|
type: 'object',
|
|
519
195
|
properties: {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
},
|
|
196
|
+
action: { type: 'string', description: 'Action (use "help" for usage)', enum: ['add', 'get', 'deactivate', 'help'] },
|
|
197
|
+
constraint_id: { type: 'number' },
|
|
198
|
+
category: { type: 'string', enum: ['performance', 'architecture', 'security'] },
|
|
199
|
+
constraint_text: { type: 'string' },
|
|
200
|
+
priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'], default: 'medium' },
|
|
201
|
+
layer: { type: 'string', enum: ['presentation', 'business', 'data', 'infrastructure', 'cross-cutting'] },
|
|
202
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
203
|
+
created_by: { type: 'string' },
|
|
204
|
+
active_only: { type: 'boolean', default: true },
|
|
205
|
+
limit: { type: 'number', default: 50 },
|
|
524
206
|
},
|
|
525
|
-
required: ['
|
|
526
|
-
},
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
name: 'get_layer_summary',
|
|
530
|
-
description: 'Get summary statistics for all architecture layers. Returns decision counts, recent file changes (last 1 hour), and active constraints per layer.',
|
|
531
|
-
inputSchema: {
|
|
532
|
-
type: 'object',
|
|
533
|
-
properties: {},
|
|
207
|
+
required: ['action'],
|
|
534
208
|
},
|
|
535
209
|
},
|
|
536
210
|
{
|
|
537
|
-
name: '
|
|
538
|
-
description: '
|
|
211
|
+
name: 'stats',
|
|
212
|
+
description: 'Statistics and data cleanup (actions: layer_summary, db_stats, clear, activity_log)',
|
|
539
213
|
inputSchema: {
|
|
540
214
|
type: 'object',
|
|
541
215
|
properties: {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
description: 'Delete file changes older than this many days (default: 7)',
|
|
550
|
-
default: 7,
|
|
551
|
-
},
|
|
216
|
+
action: { type: 'string', description: 'Action (use "help" for usage)', enum: ['layer_summary', 'db_stats', 'clear', 'activity_log', 'help'] },
|
|
217
|
+
messages_older_than_hours: { type: 'number' },
|
|
218
|
+
file_changes_older_than_days: { type: 'number' },
|
|
219
|
+
since: { type: 'string', description: 'Time filter (e.g., "5m", "1h", "2d" or ISO timestamp)' },
|
|
220
|
+
agent_names: { type: 'array', items: { type: 'string' }, description: 'Filter by agents' },
|
|
221
|
+
actions: { type: 'array', items: { type: 'string' }, description: 'Filter by action types' },
|
|
222
|
+
limit: { type: 'number', description: 'Max results (default: 100)' },
|
|
552
223
|
},
|
|
224
|
+
required: ['action'],
|
|
553
225
|
},
|
|
554
226
|
},
|
|
555
227
|
{
|
|
556
|
-
name: '
|
|
557
|
-
description: '
|
|
558
|
-
inputSchema: {
|
|
559
|
-
type: 'object',
|
|
560
|
-
properties: {},
|
|
561
|
-
},
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
name: 'get_config',
|
|
565
|
-
description: 'Get current auto-deletion configuration settings. Returns weekend-awareness flag, message retention hours, and file history retention days.',
|
|
566
|
-
inputSchema: {
|
|
567
|
-
type: 'object',
|
|
568
|
-
properties: {},
|
|
569
|
-
},
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
name: 'update_config',
|
|
573
|
-
description: 'Update auto-deletion configuration settings. All parameters are optional. Changes take effect immediately for subsequent cleanup operations.',
|
|
228
|
+
name: 'config',
|
|
229
|
+
description: 'Auto-deletion config (actions: get, update)',
|
|
574
230
|
inputSchema: {
|
|
575
231
|
type: 'object',
|
|
576
232
|
properties: {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
},
|
|
581
|
-
messageRetentionHours: {
|
|
582
|
-
type: 'number',
|
|
583
|
-
description: 'Number of hours to retain messages (1-168 hours)',
|
|
584
|
-
minimum: 1,
|
|
585
|
-
maximum: 168,
|
|
586
|
-
},
|
|
587
|
-
fileHistoryRetentionDays: {
|
|
588
|
-
type: 'number',
|
|
589
|
-
description: 'Number of days to retain file change history (1-90 days)',
|
|
590
|
-
minimum: 1,
|
|
591
|
-
maximum: 90,
|
|
592
|
-
},
|
|
233
|
+
action: { type: 'string', description: 'Action (use "help" for usage)', enum: ['get', 'update', 'help'] },
|
|
234
|
+
ignoreWeekend: { type: 'boolean' },
|
|
235
|
+
messageRetentionHours: { type: 'number', minimum: 1, maximum: 168 },
|
|
236
|
+
fileHistoryRetentionDays: { type: 'number', minimum: 1, maximum: 90 },
|
|
593
237
|
},
|
|
238
|
+
required: ['action'],
|
|
594
239
|
},
|
|
595
240
|
},
|
|
596
241
|
],
|
|
@@ -599,258 +244,279 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
599
244
|
// Handle tool execution
|
|
600
245
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
601
246
|
const { name, arguments: args } = request.params;
|
|
247
|
+
const params = args;
|
|
602
248
|
try {
|
|
249
|
+
let result;
|
|
603
250
|
switch (name) {
|
|
604
|
-
case '
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
251
|
+
case 'decision':
|
|
252
|
+
switch (params.action) {
|
|
253
|
+
case 'set':
|
|
254
|
+
result = setDecision(params);
|
|
255
|
+
break;
|
|
256
|
+
case 'get':
|
|
257
|
+
result = getDecision(params);
|
|
258
|
+
break;
|
|
259
|
+
case 'list':
|
|
260
|
+
result = getContext(params);
|
|
261
|
+
break;
|
|
262
|
+
case 'search_tags':
|
|
263
|
+
result = searchByTags({ tags: params.tags, match_mode: params.tag_match, status: params.status, layer: params.layer });
|
|
264
|
+
break;
|
|
265
|
+
case 'search_layer':
|
|
266
|
+
result = searchByLayer({ layer: params.layer, status: params.status, include_tags: params.include_tags });
|
|
267
|
+
break;
|
|
268
|
+
case 'versions':
|
|
269
|
+
result = getVersions(params);
|
|
270
|
+
break;
|
|
271
|
+
case 'quick_set':
|
|
272
|
+
result = quickSetDecision(params);
|
|
273
|
+
break;
|
|
274
|
+
case 'search_advanced':
|
|
275
|
+
result = searchAdvanced({
|
|
276
|
+
layers: params.layers,
|
|
277
|
+
tags_all: params.tags_all,
|
|
278
|
+
tags_any: params.tags_any,
|
|
279
|
+
exclude_tags: params.exclude_tags,
|
|
280
|
+
scopes: params.scopes,
|
|
281
|
+
updated_after: params.updated_after,
|
|
282
|
+
updated_before: params.updated_before,
|
|
283
|
+
decided_by: params.decided_by,
|
|
284
|
+
statuses: params.statuses,
|
|
285
|
+
search_text: params.search_text,
|
|
286
|
+
sort_by: params.sort_by,
|
|
287
|
+
sort_order: params.sort_order,
|
|
288
|
+
limit: params.limit,
|
|
289
|
+
offset: params.offset
|
|
290
|
+
});
|
|
291
|
+
break;
|
|
292
|
+
case 'set_batch':
|
|
293
|
+
result = setDecisionBatch({ decisions: params.decisions, atomic: params.atomic });
|
|
294
|
+
break;
|
|
295
|
+
case 'has_updates':
|
|
296
|
+
result = hasUpdates({ agent_name: params.agent_name, since_timestamp: params.since_timestamp });
|
|
297
|
+
break;
|
|
298
|
+
case 'set_from_template':
|
|
299
|
+
result = setFromTemplate(params);
|
|
300
|
+
break;
|
|
301
|
+
case 'create_template':
|
|
302
|
+
result = createTemplate(params);
|
|
303
|
+
break;
|
|
304
|
+
case 'list_templates':
|
|
305
|
+
result = listTemplates(params);
|
|
306
|
+
break;
|
|
307
|
+
case 'help':
|
|
308
|
+
result = {
|
|
309
|
+
tool: 'decision',
|
|
310
|
+
description: 'Manage decisions with metadata (tags, layers, versions, scopes)',
|
|
311
|
+
actions: {
|
|
312
|
+
set: 'Set/update a decision. Params: key (required), value (required), agent, layer, version, status, tags, scopes',
|
|
313
|
+
get: 'Get specific decision by key. Params: key (required)',
|
|
314
|
+
list: 'List/filter decisions. Params: status, layer, tags, scope, tag_match',
|
|
315
|
+
search_tags: 'Search decisions by tags. Params: tags (required), match_mode, status, layer',
|
|
316
|
+
search_layer: 'Search decisions by layer. Params: layer (required), status, include_tags',
|
|
317
|
+
versions: 'Get version history for a decision. Params: key (required)',
|
|
318
|
+
quick_set: 'Quick set with smart defaults (FR-002). Params: key (required), value (required), agent, layer, version, status, tags, scopes. Auto-infers layer from key prefix (api/*→presentation, db/*→data, service/*→business, config/*→infrastructure), tags from key hierarchy, scope from parent path. Defaults: status=active, version=1.0.0. All inferred fields can be overridden.',
|
|
319
|
+
search_advanced: 'Advanced query with complex filtering (FR-004). Params: layers (OR), tags_all (AND), tags_any (OR), exclude_tags, scopes (wildcards), updated_after/before (ISO or relative like "7d"), decided_by, statuses, search_text, sort_by (updated/key/version), sort_order (asc/desc), limit (default:20, max:1000), offset (default:0). Returns decisions with total_count for pagination. All filters use parameterized queries (SQL injection protection).',
|
|
320
|
+
set_batch: 'Batch set decisions (FR-005). Params: decisions (required, array of SetDecisionParams, max: 50), atomic (default: true). Returns: {success, inserted, failed, results}. Atomic mode: all succeed or all fail (transaction). Non-atomic mode: process all, return individual results. 52% token reduction vs individual calls.',
|
|
321
|
+
has_updates: 'Check for updates since timestamp (FR-003 Phase A - Lightweight Polling). Params: agent_name (required), since_timestamp (required, ISO 8601 format like "2025-10-14T08:00:00Z"). Returns: {has_updates: boolean, counts: {decisions: N, messages: N, files: N}}. Token cost: ~5-10 tokens per check. Uses COUNT queries on t_decisions, t_agent_messages, t_file_changes with timestamp filtering. Enables efficient polling without full data retrieval.',
|
|
322
|
+
set_from_template: 'Set decision using template (FR-006). Params: template (required, template name), key (required), value (required), agent, layer (override), version, status (override), tags (override), scopes, plus any template-required fields. Applies template defaults (layer, status, tags) while allowing overrides. Validates required fields if specified by template. Returns: {success, key, key_id, version, template_used, applied_defaults, message}. Built-in templates: breaking_change, security_vulnerability, performance_optimization, deprecation, architecture_decision.',
|
|
323
|
+
create_template: 'Create new decision template (FR-006). Params: name (required, unique), defaults (required, object with layer/status/tags/priority), required_fields (optional, array of field names), created_by (optional, agent name). Returns: {success, template_id, template_name, message}. Example defaults: {"layer":"business","status":"active","tags":["breaking"]}. Validates layer/status values.',
|
|
324
|
+
list_templates: 'List all decision templates (FR-006). No params required. Returns: {templates: [{id, name, defaults, required_fields, created_by, created_at}], count}. Shows both built-in and custom templates.'
|
|
325
|
+
},
|
|
326
|
+
examples: {
|
|
327
|
+
set: '{ action: "set", key: "auth_method", value: "jwt", tags: ["security"] }',
|
|
328
|
+
get: '{ action: "get", key: "auth_method" }',
|
|
329
|
+
list: '{ action: "list", status: "active", layer: "infrastructure" }',
|
|
330
|
+
search_tags: '{ action: "search_tags", tags: ["security", "api"] }',
|
|
331
|
+
quick_set: '{ action: "quick_set", key: "api/instruments/oscillator-refactor", value: "Moved oscillator_type to MonophonicSynthConfig" }',
|
|
332
|
+
search_advanced: '{ action: "search_advanced", layers: ["business", "data"], tags_all: ["breaking", "v0.3.3"], tags_any: ["api", "synthesis"], exclude_tags: ["deprecated"], scopes: ["api/instruments/*"], updated_after: "2025-10-01", statuses: ["active", "draft"], search_text: "oscillator", sort_by: "updated", sort_order: "desc", limit: 20, offset: 0 }',
|
|
333
|
+
set_batch: '{ action: "set_batch", decisions: [{"key": "feat-1", "value": "...", "layer": "business"}, {"key": "feat-2", "value": "...", "layer": "data"}], atomic: true }',
|
|
334
|
+
has_updates: '{ action: "has_updates", agent_name: "my-agent", since_timestamp: "2025-10-14T08:00:00Z" }',
|
|
335
|
+
set_from_template: '{ action: "set_from_template", template: "breaking_change", key: "oscillator-type-moved", value: "oscillator_type moved to MonophonicSynthConfig" }',
|
|
336
|
+
create_template: '{ action: "create_template", name: "bug_fix", defaults: {"layer":"business","tags":["bug","fix"],"status":"active"}, created_by: "my-agent" }',
|
|
337
|
+
list_templates: '{ action: "list_templates" }'
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
break;
|
|
341
|
+
default: throw new Error(`Unknown action: ${params.action}`);
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
case 'message':
|
|
345
|
+
switch (params.action) {
|
|
346
|
+
case 'send':
|
|
347
|
+
result = sendMessage(params);
|
|
348
|
+
break;
|
|
349
|
+
case 'get':
|
|
350
|
+
result = getMessages(params);
|
|
351
|
+
break;
|
|
352
|
+
case 'mark_read':
|
|
353
|
+
result = markRead(params);
|
|
354
|
+
break;
|
|
355
|
+
case 'send_batch':
|
|
356
|
+
result = sendMessageBatch({ messages: params.messages, atomic: params.atomic });
|
|
357
|
+
break;
|
|
358
|
+
case 'help':
|
|
359
|
+
result = {
|
|
360
|
+
tool: 'message',
|
|
361
|
+
description: 'Send and retrieve messages between agents with priority levels',
|
|
362
|
+
actions: {
|
|
363
|
+
send: 'Send message. Params: from_agent (required), msg_type (required), message (required), to_agent, priority, payload',
|
|
364
|
+
get: 'Get messages for agent. Params: agent_name (required), unread_only, priority_filter, msg_type_filter, limit',
|
|
365
|
+
mark_read: 'Mark messages as read. Params: agent_name (required), message_ids (required)',
|
|
366
|
+
send_batch: 'Batch send messages (FR-005). Params: messages (required, array of SendMessageParams, max: 50), atomic (default: true). Returns: {success, inserted, failed, results}. Atomic mode: all succeed or all fail (transaction). Non-atomic mode: process all, return individual results. 52% token reduction vs individual calls.'
|
|
367
|
+
},
|
|
368
|
+
examples: {
|
|
369
|
+
send: '{ action: "send", from_agent: "bot1", msg_type: "info", message: "Task complete", priority: "high" }',
|
|
370
|
+
get: '{ action: "get", agent_name: "bot1", unread_only: true }',
|
|
371
|
+
mark_read: '{ action: "mark_read", agent_name: "bot1", message_ids: [1, 2, 3] }',
|
|
372
|
+
send_batch: '{ action: "send_batch", messages: [{"from_agent": "bot1", "msg_type": "info", "message": "Task 1 done"}, {"from_agent": "bot1", "msg_type": "info", "message": "Task 2 done"}], atomic: true }'
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
break;
|
|
376
|
+
default: throw new Error(`Unknown action: ${params.action}`);
|
|
377
|
+
}
|
|
378
|
+
break;
|
|
379
|
+
case 'file':
|
|
380
|
+
switch (params.action) {
|
|
381
|
+
case 'record':
|
|
382
|
+
result = recordFileChange(params);
|
|
383
|
+
break;
|
|
384
|
+
case 'get':
|
|
385
|
+
result = getFileChanges(params);
|
|
386
|
+
break;
|
|
387
|
+
case 'check_lock':
|
|
388
|
+
result = checkFileLock(params);
|
|
389
|
+
break;
|
|
390
|
+
case 'record_batch':
|
|
391
|
+
result = recordFileChangeBatch({ file_changes: params.file_changes, atomic: params.atomic });
|
|
392
|
+
break;
|
|
393
|
+
case 'help':
|
|
394
|
+
result = {
|
|
395
|
+
tool: 'file',
|
|
396
|
+
description: 'Track file changes across agents with layer classification',
|
|
397
|
+
actions: {
|
|
398
|
+
record: 'Record file change. Params: file_path (required), agent_name (required), change_type (required), layer, description',
|
|
399
|
+
get: 'Get file changes. Params: file_path, agent_name, layer, change_type, since, limit',
|
|
400
|
+
check_lock: 'Check if file locked. Params: file_path (required), lock_duration',
|
|
401
|
+
record_batch: 'Batch record file changes (FR-005). Params: file_changes (required, array of RecordFileChangeParams, max: 50), atomic (default: true). Returns: {success, inserted, failed, results}. Atomic mode: all succeed or all fail (transaction). Non-atomic mode: process all, return individual results. 52% token reduction vs individual calls.'
|
|
402
|
+
},
|
|
403
|
+
examples: {
|
|
404
|
+
record: '{ action: "record", file_path: "src/index.ts", agent_name: "refactor-bot", change_type: "modified", layer: "infrastructure" }',
|
|
405
|
+
get: '{ action: "get", agent_name: "refactor-bot", layer: "infrastructure", limit: 10 }',
|
|
406
|
+
check_lock: '{ action: "check_lock", file_path: "src/index.ts", lock_duration: 300 }',
|
|
407
|
+
record_batch: '{ action: "record_batch", file_changes: [{"file_path": "src/types.ts", "agent_name": "bot1", "change_type": "modified", "layer": "data"}, {"file_path": "src/index.ts", "agent_name": "bot1", "change_type": "modified", "layer": "infrastructure"}], atomic: true }'
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
break;
|
|
411
|
+
default: throw new Error(`Unknown action: ${params.action}`);
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
case 'constraint':
|
|
415
|
+
switch (params.action) {
|
|
416
|
+
case 'add':
|
|
417
|
+
result = addConstraint(params);
|
|
418
|
+
break;
|
|
419
|
+
case 'get':
|
|
420
|
+
result = getConstraints(params);
|
|
421
|
+
break;
|
|
422
|
+
case 'deactivate':
|
|
423
|
+
result = deactivateConstraint(params);
|
|
424
|
+
break;
|
|
425
|
+
case 'help':
|
|
426
|
+
result = {
|
|
427
|
+
tool: 'constraint',
|
|
428
|
+
description: 'Manage project constraints (performance, architecture, security)',
|
|
429
|
+
actions: {
|
|
430
|
+
add: 'Add constraint. Params: category (required), constraint_text (required), priority, layer, tags, created_by',
|
|
431
|
+
get: 'Get constraints. Params: category, layer, priority, tags, active_only, limit',
|
|
432
|
+
deactivate: 'Deactivate constraint. Params: constraint_id (required)'
|
|
433
|
+
},
|
|
434
|
+
examples: {
|
|
435
|
+
add: '{ action: "add", category: "performance", constraint_text: "API response time <100ms", priority: "high", tags: ["api"] }',
|
|
436
|
+
get: '{ action: "get", category: "performance", active_only: true }',
|
|
437
|
+
deactivate: '{ action: "deactivate", constraint_id: 5 }'
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
break;
|
|
441
|
+
default: throw new Error(`Unknown action: ${params.action}`);
|
|
442
|
+
}
|
|
443
|
+
break;
|
|
444
|
+
case 'stats':
|
|
445
|
+
switch (params.action) {
|
|
446
|
+
case 'layer_summary':
|
|
447
|
+
result = getLayerSummary();
|
|
448
|
+
break;
|
|
449
|
+
case 'db_stats':
|
|
450
|
+
result = getStats();
|
|
451
|
+
break;
|
|
452
|
+
case 'clear':
|
|
453
|
+
result = clearOldData(params);
|
|
454
|
+
break;
|
|
455
|
+
case 'activity_log':
|
|
456
|
+
result = getActivityLog({
|
|
457
|
+
since: params.since,
|
|
458
|
+
agent_names: params.agent_names,
|
|
459
|
+
actions: params.actions,
|
|
460
|
+
limit: params.limit,
|
|
461
|
+
});
|
|
462
|
+
break;
|
|
463
|
+
case 'help':
|
|
464
|
+
result = {
|
|
465
|
+
tool: 'stats',
|
|
466
|
+
description: 'View database statistics, activity logs, and manage data cleanup',
|
|
467
|
+
actions: {
|
|
468
|
+
layer_summary: 'Get summary by layer. No params required',
|
|
469
|
+
db_stats: 'Get database statistics. No params required',
|
|
470
|
+
clear: 'Clear old data. Params: messages_older_than_hours, file_changes_older_than_days',
|
|
471
|
+
activity_log: 'Get activity log (v3.0.0). Params: since (e.g., "5m", "1h", "2d"), agent_names (array or ["*"]), actions (filter by action types), limit (default: 100)'
|
|
472
|
+
},
|
|
473
|
+
examples: {
|
|
474
|
+
layer_summary: '{ action: "layer_summary" }',
|
|
475
|
+
db_stats: '{ action: "db_stats" }',
|
|
476
|
+
clear: '{ action: "clear", messages_older_than_hours: 48, file_changes_older_than_days: 14 }',
|
|
477
|
+
activity_log: '{ action: "activity_log", since: "1h", agent_names: ["bot1", "bot2"], limit: 50 }'
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
break;
|
|
481
|
+
default: throw new Error(`Unknown action: ${params.action}`);
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
case 'config':
|
|
485
|
+
switch (params.action) {
|
|
486
|
+
case 'get':
|
|
487
|
+
result = getConfig();
|
|
488
|
+
break;
|
|
489
|
+
case 'update':
|
|
490
|
+
result = updateConfig(params);
|
|
491
|
+
break;
|
|
492
|
+
case 'help':
|
|
493
|
+
result = {
|
|
494
|
+
tool: 'config',
|
|
495
|
+
description: 'Manage auto-deletion configuration (weekend-aware retention)',
|
|
496
|
+
actions: {
|
|
497
|
+
get: 'Get current config. No params required',
|
|
498
|
+
update: 'Update config. Params: ignoreWeekend, messageRetentionHours (1-168), fileHistoryRetentionDays (1-90)'
|
|
499
|
+
},
|
|
500
|
+
examples: {
|
|
501
|
+
get: '{ action: "get" }',
|
|
502
|
+
update: '{ action: "update", ignoreWeekend: true, messageRetentionHours: 48 }'
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
break;
|
|
506
|
+
default: throw new Error(`Unknown action: ${params.action}`);
|
|
507
|
+
}
|
|
508
|
+
break;
|
|
841
509
|
default:
|
|
842
510
|
throw new Error(`Unknown tool: ${name}`);
|
|
843
511
|
}
|
|
512
|
+
return {
|
|
513
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
514
|
+
};
|
|
844
515
|
}
|
|
845
516
|
catch (error) {
|
|
846
517
|
const message = error instanceof Error ? error.message : String(error);
|
|
847
518
|
return {
|
|
848
|
-
content: [
|
|
849
|
-
{
|
|
850
|
-
type: 'text',
|
|
851
|
-
text: JSON.stringify({ error: message }, null, 2),
|
|
852
|
-
},
|
|
853
|
-
],
|
|
519
|
+
content: [{ type: 'text', text: JSON.stringify({ error: message }, null, 2) }],
|
|
854
520
|
isError: true,
|
|
855
521
|
};
|
|
856
522
|
}
|