sqlew 1.0.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/ARCHITECTURE.md +636 -0
- package/CHANGELOG.md +107 -0
- package/LICENSE +21 -0
- package/README.md +359 -0
- package/assets/schema.sql +320 -0
- package/assets/sqlew-logo.png +0 -0
- package/dist/constants.d.ts +146 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +230 -0
- package/dist/constants.js.map +1 -0
- package/dist/database.d.ts +94 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +214 -0
- package/dist/database.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +771 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +50 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +161 -0
- package/dist/schema.js.map +1 -0
- package/dist/tools/constraints.d.ts +29 -0
- package/dist/tools/constraints.d.ts.map +1 -0
- package/dist/tools/constraints.js +192 -0
- package/dist/tools/constraints.js.map +1 -0
- package/dist/tools/context.d.ts +56 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +442 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/files.d.ts +30 -0
- package/dist/tools/files.d.ts.map +1 -0
- package/dist/tools/files.js +201 -0
- package/dist/tools/files.js.map +1 -0
- package/dist/tools/messaging.d.ts +50 -0
- package/dist/tools/messaging.d.ts.map +1 -0
- package/dist/tools/messaging.js +151 -0
- package/dist/tools/messaging.js.map +1 -0
- package/dist/tools/utils.d.ts +29 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +131 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/types.d.ts +388 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +50 -0
- package/dist/types.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context management tools for MCP Shared Context Server
|
|
3
|
+
* Implements set_decision, get_context, and get_decision tools
|
|
4
|
+
*/
|
|
5
|
+
import { getDatabase, getOrCreateAgent, getOrCreateContextKey, getOrCreateTag, getOrCreateScope, getLayerId, transaction } from '../database.js';
|
|
6
|
+
import { STRING_TO_STATUS, DEFAULT_VERSION, DEFAULT_STATUS } from '../constants.js';
|
|
7
|
+
/**
|
|
8
|
+
* Set or update a decision in the context
|
|
9
|
+
* Auto-detects numeric vs string values and routes to appropriate table
|
|
10
|
+
* Supports tags, layers, scopes, and version tracking
|
|
11
|
+
*
|
|
12
|
+
* @param params - Decision parameters
|
|
13
|
+
* @returns Response with success status and metadata
|
|
14
|
+
*/
|
|
15
|
+
export function setDecision(params) {
|
|
16
|
+
const db = getDatabase();
|
|
17
|
+
// Validate required parameters
|
|
18
|
+
if (!params.key || params.key.trim() === '') {
|
|
19
|
+
throw new Error('Parameter "key" is required and cannot be empty');
|
|
20
|
+
}
|
|
21
|
+
if (params.value === undefined || params.value === null) {
|
|
22
|
+
throw new Error('Parameter "value" is required');
|
|
23
|
+
}
|
|
24
|
+
// Determine if value is numeric
|
|
25
|
+
const isNumeric = typeof params.value === 'number';
|
|
26
|
+
const value = params.value;
|
|
27
|
+
// Set defaults
|
|
28
|
+
const version = params.version || DEFAULT_VERSION;
|
|
29
|
+
const status = params.status ? STRING_TO_STATUS[params.status] : DEFAULT_STATUS;
|
|
30
|
+
const agentName = params.agent || 'system';
|
|
31
|
+
// Validate status
|
|
32
|
+
if (params.status && !STRING_TO_STATUS[params.status]) {
|
|
33
|
+
throw new Error(`Invalid status: ${params.status}. Must be 'active', 'deprecated', or 'draft'`);
|
|
34
|
+
}
|
|
35
|
+
// Validate layer if provided
|
|
36
|
+
let layerId = null;
|
|
37
|
+
if (params.layer) {
|
|
38
|
+
layerId = getLayerId(db, params.layer);
|
|
39
|
+
if (layerId === null) {
|
|
40
|
+
throw new Error(`Invalid layer: ${params.layer}. Must be one of: presentation, business, data, infrastructure, cross-cutting`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
// Use transaction for atomicity
|
|
45
|
+
return transaction(db, () => {
|
|
46
|
+
// Get or create master records
|
|
47
|
+
const agentId = getOrCreateAgent(db, agentName);
|
|
48
|
+
const keyId = getOrCreateContextKey(db, params.key);
|
|
49
|
+
// Current timestamp
|
|
50
|
+
const ts = Math.floor(Date.now() / 1000);
|
|
51
|
+
// Insert or update decision based on value type
|
|
52
|
+
if (isNumeric) {
|
|
53
|
+
// Numeric decision
|
|
54
|
+
const stmt = db.prepare(`
|
|
55
|
+
INSERT INTO decisions_numeric (key_id, value, agent_id, layer_id, version, status, ts)
|
|
56
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
57
|
+
ON CONFLICT(key_id) DO UPDATE SET
|
|
58
|
+
value = excluded.value,
|
|
59
|
+
agent_id = excluded.agent_id,
|
|
60
|
+
layer_id = excluded.layer_id,
|
|
61
|
+
version = excluded.version,
|
|
62
|
+
status = excluded.status,
|
|
63
|
+
ts = excluded.ts
|
|
64
|
+
`);
|
|
65
|
+
stmt.run(keyId, value, agentId, layerId, version, status, ts);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// String decision
|
|
69
|
+
const stmt = db.prepare(`
|
|
70
|
+
INSERT INTO decisions (key_id, value, agent_id, layer_id, version, status, ts)
|
|
71
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
72
|
+
ON CONFLICT(key_id) DO UPDATE SET
|
|
73
|
+
value = excluded.value,
|
|
74
|
+
agent_id = excluded.agent_id,
|
|
75
|
+
layer_id = excluded.layer_id,
|
|
76
|
+
version = excluded.version,
|
|
77
|
+
status = excluded.status,
|
|
78
|
+
ts = excluded.ts
|
|
79
|
+
`);
|
|
80
|
+
stmt.run(keyId, String(value), agentId, layerId, version, status, ts);
|
|
81
|
+
}
|
|
82
|
+
// Handle tags (many-to-many)
|
|
83
|
+
if (params.tags && params.tags.length > 0) {
|
|
84
|
+
// Clear existing tags
|
|
85
|
+
db.prepare('DELETE FROM decision_tags WHERE decision_key_id = ?').run(keyId);
|
|
86
|
+
// Insert new tags
|
|
87
|
+
const tagStmt = db.prepare('INSERT INTO decision_tags (decision_key_id, tag_id) VALUES (?, ?)');
|
|
88
|
+
for (const tagName of params.tags) {
|
|
89
|
+
const tagId = getOrCreateTag(db, tagName);
|
|
90
|
+
tagStmt.run(keyId, tagId);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Handle scopes (many-to-many)
|
|
94
|
+
if (params.scopes && params.scopes.length > 0) {
|
|
95
|
+
// Clear existing scopes
|
|
96
|
+
db.prepare('DELETE FROM decision_scopes WHERE decision_key_id = ?').run(keyId);
|
|
97
|
+
// Insert new scopes
|
|
98
|
+
const scopeStmt = db.prepare('INSERT INTO decision_scopes (decision_key_id, scope_id) VALUES (?, ?)');
|
|
99
|
+
for (const scopeName of params.scopes) {
|
|
100
|
+
const scopeId = getOrCreateScope(db, scopeName);
|
|
101
|
+
scopeStmt.run(keyId, scopeId);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
success: true,
|
|
106
|
+
key: params.key,
|
|
107
|
+
key_id: keyId,
|
|
108
|
+
version: version,
|
|
109
|
+
message: `Decision "${params.key}" set successfully`
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
115
|
+
throw new Error(`Failed to set decision: ${message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get context decisions with advanced filtering
|
|
120
|
+
* Uses tagged_decisions view for token efficiency
|
|
121
|
+
* Supports filtering by status, layer, tags, and scope
|
|
122
|
+
*
|
|
123
|
+
* @param params - Filter parameters
|
|
124
|
+
* @returns Array of decisions with metadata
|
|
125
|
+
*/
|
|
126
|
+
export function getContext(params = {}) {
|
|
127
|
+
const db = getDatabase();
|
|
128
|
+
try {
|
|
129
|
+
// Build query dynamically based on filters
|
|
130
|
+
let query = 'SELECT * FROM tagged_decisions WHERE 1=1';
|
|
131
|
+
const queryParams = [];
|
|
132
|
+
// Filter by status
|
|
133
|
+
if (params.status) {
|
|
134
|
+
if (!STRING_TO_STATUS[params.status]) {
|
|
135
|
+
throw new Error(`Invalid status: ${params.status}`);
|
|
136
|
+
}
|
|
137
|
+
query += ' AND status = ?';
|
|
138
|
+
queryParams.push(params.status);
|
|
139
|
+
}
|
|
140
|
+
// Filter by layer
|
|
141
|
+
if (params.layer) {
|
|
142
|
+
query += ' AND layer = ?';
|
|
143
|
+
queryParams.push(params.layer);
|
|
144
|
+
}
|
|
145
|
+
// Filter by scope
|
|
146
|
+
if (params.scope) {
|
|
147
|
+
// Use LIKE for comma-separated scopes
|
|
148
|
+
query += ' AND (scopes LIKE ? OR scopes = ?)';
|
|
149
|
+
queryParams.push(`%${params.scope}%`, params.scope);
|
|
150
|
+
}
|
|
151
|
+
// Filter by tags
|
|
152
|
+
if (params.tags && params.tags.length > 0) {
|
|
153
|
+
const tagMatch = params.tag_match || 'OR';
|
|
154
|
+
if (tagMatch === 'AND') {
|
|
155
|
+
// All tags must be present
|
|
156
|
+
for (const tag of params.tags) {
|
|
157
|
+
query += ' AND (tags LIKE ? OR tags = ?)';
|
|
158
|
+
queryParams.push(`%${tag}%`, tag);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// Any tag must be present (OR)
|
|
163
|
+
const tagConditions = params.tags.map(() => '(tags LIKE ? OR tags = ?)').join(' OR ');
|
|
164
|
+
query += ` AND (${tagConditions})`;
|
|
165
|
+
for (const tag of params.tags) {
|
|
166
|
+
queryParams.push(`%${tag}%`, tag);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Order by most recent
|
|
171
|
+
query += ' ORDER BY updated DESC';
|
|
172
|
+
// Execute query
|
|
173
|
+
const stmt = db.prepare(query);
|
|
174
|
+
const rows = stmt.all(...queryParams);
|
|
175
|
+
return {
|
|
176
|
+
decisions: rows,
|
|
177
|
+
count: rows.length
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
182
|
+
throw new Error(`Failed to get context: ${message}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get a specific decision by key
|
|
187
|
+
* Returns full metadata including tags, layer, scopes, version
|
|
188
|
+
*
|
|
189
|
+
* @param params - Decision key
|
|
190
|
+
* @returns Decision details or not found
|
|
191
|
+
*/
|
|
192
|
+
export function getDecision(params) {
|
|
193
|
+
const db = getDatabase();
|
|
194
|
+
// Validate parameter
|
|
195
|
+
if (!params.key || params.key.trim() === '') {
|
|
196
|
+
throw new Error('Parameter "key" is required and cannot be empty');
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
// Query tagged_decisions view
|
|
200
|
+
const stmt = db.prepare('SELECT * FROM tagged_decisions WHERE key = ?');
|
|
201
|
+
const row = stmt.get(params.key);
|
|
202
|
+
if (!row) {
|
|
203
|
+
return {
|
|
204
|
+
found: false
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
found: true,
|
|
209
|
+
decision: row
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
214
|
+
throw new Error(`Failed to get decision: ${message}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Search for decisions by tags with AND/OR logic
|
|
219
|
+
* Provides flexible tag-based filtering with status and layer support
|
|
220
|
+
*
|
|
221
|
+
* @param params - Search parameters (tags, match_mode, status, layer)
|
|
222
|
+
* @returns Array of decisions matching tag criteria
|
|
223
|
+
*/
|
|
224
|
+
export function searchByTags(params) {
|
|
225
|
+
const db = getDatabase();
|
|
226
|
+
// Validate required parameters
|
|
227
|
+
if (!params.tags || params.tags.length === 0) {
|
|
228
|
+
throw new Error('Parameter "tags" is required and must contain at least one tag');
|
|
229
|
+
}
|
|
230
|
+
try {
|
|
231
|
+
const matchMode = params.match_mode || 'OR';
|
|
232
|
+
let query = 'SELECT * FROM tagged_decisions WHERE 1=1';
|
|
233
|
+
const queryParams = [];
|
|
234
|
+
// Apply tag filtering based on match mode
|
|
235
|
+
if (matchMode === 'AND') {
|
|
236
|
+
// All tags must be present
|
|
237
|
+
for (const tag of params.tags) {
|
|
238
|
+
query += ' AND (tags LIKE ? OR tags = ?)';
|
|
239
|
+
queryParams.push(`%${tag}%`, tag);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else if (matchMode === 'OR') {
|
|
243
|
+
// Any tag must be present
|
|
244
|
+
const tagConditions = params.tags.map(() => '(tags LIKE ? OR tags = ?)').join(' OR ');
|
|
245
|
+
query += ` AND (${tagConditions})`;
|
|
246
|
+
for (const tag of params.tags) {
|
|
247
|
+
queryParams.push(`%${tag}%`, tag);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
throw new Error(`Invalid match_mode: ${matchMode}. Must be 'AND' or 'OR'`);
|
|
252
|
+
}
|
|
253
|
+
// Optional status filter
|
|
254
|
+
if (params.status) {
|
|
255
|
+
if (!STRING_TO_STATUS[params.status]) {
|
|
256
|
+
throw new Error(`Invalid status: ${params.status}. Must be 'active', 'deprecated', or 'draft'`);
|
|
257
|
+
}
|
|
258
|
+
query += ' AND status = ?';
|
|
259
|
+
queryParams.push(params.status);
|
|
260
|
+
}
|
|
261
|
+
// Optional layer filter
|
|
262
|
+
if (params.layer) {
|
|
263
|
+
// Validate layer exists
|
|
264
|
+
const layerId = getLayerId(db, params.layer);
|
|
265
|
+
if (layerId === null) {
|
|
266
|
+
throw new Error(`Invalid layer: ${params.layer}. Must be one of: presentation, business, data, infrastructure, cross-cutting`);
|
|
267
|
+
}
|
|
268
|
+
query += ' AND layer = ?';
|
|
269
|
+
queryParams.push(params.layer);
|
|
270
|
+
}
|
|
271
|
+
// Order by most recent
|
|
272
|
+
query += ' ORDER BY updated DESC';
|
|
273
|
+
// Execute query
|
|
274
|
+
const stmt = db.prepare(query);
|
|
275
|
+
const rows = stmt.all(...queryParams);
|
|
276
|
+
return {
|
|
277
|
+
decisions: rows,
|
|
278
|
+
count: rows.length
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
283
|
+
throw new Error(`Failed to search by tags: ${message}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get version history for a specific decision key
|
|
288
|
+
* Returns all historical versions ordered by timestamp (newest first)
|
|
289
|
+
*
|
|
290
|
+
* @param params - Decision key to get history for
|
|
291
|
+
* @returns Array of historical versions with metadata
|
|
292
|
+
*/
|
|
293
|
+
export function getVersions(params) {
|
|
294
|
+
const db = getDatabase();
|
|
295
|
+
// Validate required parameter
|
|
296
|
+
if (!params.key || params.key.trim() === '') {
|
|
297
|
+
throw new Error('Parameter "key" is required and cannot be empty');
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
// Get key_id for the decision
|
|
301
|
+
const keyResult = db.prepare('SELECT id FROM context_keys WHERE key = ?').get(params.key);
|
|
302
|
+
if (!keyResult) {
|
|
303
|
+
// Key doesn't exist, return empty history
|
|
304
|
+
return {
|
|
305
|
+
key: params.key,
|
|
306
|
+
history: [],
|
|
307
|
+
count: 0
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
const keyId = keyResult.id;
|
|
311
|
+
// Query decision_history with agent join
|
|
312
|
+
const stmt = db.prepare(`
|
|
313
|
+
SELECT
|
|
314
|
+
dh.version,
|
|
315
|
+
dh.value,
|
|
316
|
+
a.name as agent_name,
|
|
317
|
+
datetime(dh.ts, 'unixepoch') as timestamp
|
|
318
|
+
FROM decision_history dh
|
|
319
|
+
LEFT JOIN agents a ON dh.agent_id = a.id
|
|
320
|
+
WHERE dh.key_id = ?
|
|
321
|
+
ORDER BY dh.ts DESC
|
|
322
|
+
`);
|
|
323
|
+
const rows = stmt.all(keyId);
|
|
324
|
+
// Transform to response format
|
|
325
|
+
const history = rows.map(row => ({
|
|
326
|
+
version: row.version,
|
|
327
|
+
value: row.value,
|
|
328
|
+
agent: row.agent_name,
|
|
329
|
+
timestamp: row.timestamp
|
|
330
|
+
}));
|
|
331
|
+
return {
|
|
332
|
+
key: params.key,
|
|
333
|
+
history: history,
|
|
334
|
+
count: history.length
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
339
|
+
throw new Error(`Failed to get versions: ${message}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Search for decisions within a specific architecture layer
|
|
344
|
+
* Supports status filtering and optional tag inclusion
|
|
345
|
+
*
|
|
346
|
+
* @param params - Layer name, optional status and include_tags
|
|
347
|
+
* @returns Array of decisions in the specified layer
|
|
348
|
+
*/
|
|
349
|
+
export function searchByLayer(params) {
|
|
350
|
+
const db = getDatabase();
|
|
351
|
+
// Validate required parameter
|
|
352
|
+
if (!params.layer || params.layer.trim() === '') {
|
|
353
|
+
throw new Error('Parameter "layer" is required and cannot be empty');
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
// Validate layer exists
|
|
357
|
+
const layerId = getLayerId(db, params.layer);
|
|
358
|
+
if (layerId === null) {
|
|
359
|
+
throw new Error(`Invalid layer: ${params.layer}. Must be one of: presentation, business, data, infrastructure, cross-cutting`);
|
|
360
|
+
}
|
|
361
|
+
// Determine which view/table to use
|
|
362
|
+
const includeTagsValue = params.include_tags !== undefined ? params.include_tags : true;
|
|
363
|
+
const statusValue = params.status || 'active';
|
|
364
|
+
// Validate status
|
|
365
|
+
if (!STRING_TO_STATUS[statusValue]) {
|
|
366
|
+
throw new Error(`Invalid status: ${statusValue}. Must be 'active', 'deprecated', or 'draft'`);
|
|
367
|
+
}
|
|
368
|
+
let query;
|
|
369
|
+
const queryParams = [params.layer, statusValue];
|
|
370
|
+
if (includeTagsValue) {
|
|
371
|
+
// Use tagged_decisions view for full metadata
|
|
372
|
+
query = `
|
|
373
|
+
SELECT * FROM tagged_decisions
|
|
374
|
+
WHERE layer = ? AND status = ?
|
|
375
|
+
ORDER BY updated DESC
|
|
376
|
+
`;
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
// Use base decisions table with minimal joins
|
|
380
|
+
query = `
|
|
381
|
+
SELECT
|
|
382
|
+
ck.key,
|
|
383
|
+
d.value,
|
|
384
|
+
d.version,
|
|
385
|
+
CASE d.status
|
|
386
|
+
WHEN 1 THEN 'active'
|
|
387
|
+
WHEN 2 THEN 'deprecated'
|
|
388
|
+
WHEN 3 THEN 'draft'
|
|
389
|
+
END as status,
|
|
390
|
+
l.name as layer,
|
|
391
|
+
NULL as tags,
|
|
392
|
+
NULL as scopes,
|
|
393
|
+
a.name as decided_by,
|
|
394
|
+
datetime(d.ts, 'unixepoch') as updated
|
|
395
|
+
FROM decisions d
|
|
396
|
+
INNER JOIN context_keys ck ON d.key_id = ck.id
|
|
397
|
+
LEFT JOIN layers l ON d.layer_id = l.id
|
|
398
|
+
LEFT JOIN agents a ON d.agent_id = a.id
|
|
399
|
+
WHERE l.name = ? AND d.status = ?
|
|
400
|
+
|
|
401
|
+
UNION ALL
|
|
402
|
+
|
|
403
|
+
SELECT
|
|
404
|
+
ck.key,
|
|
405
|
+
CAST(dn.value AS TEXT) as value,
|
|
406
|
+
dn.version,
|
|
407
|
+
CASE dn.status
|
|
408
|
+
WHEN 1 THEN 'active'
|
|
409
|
+
WHEN 2 THEN 'deprecated'
|
|
410
|
+
WHEN 3 THEN 'draft'
|
|
411
|
+
END as status,
|
|
412
|
+
l.name as layer,
|
|
413
|
+
NULL as tags,
|
|
414
|
+
NULL as scopes,
|
|
415
|
+
a.name as decided_by,
|
|
416
|
+
datetime(dn.ts, 'unixepoch') as updated
|
|
417
|
+
FROM decisions_numeric dn
|
|
418
|
+
INNER JOIN context_keys ck ON dn.key_id = ck.id
|
|
419
|
+
LEFT JOIN layers l ON dn.layer_id = l.id
|
|
420
|
+
LEFT JOIN agents a ON dn.agent_id = a.id
|
|
421
|
+
WHERE l.name = ? AND dn.status = ?
|
|
422
|
+
|
|
423
|
+
ORDER BY updated DESC
|
|
424
|
+
`;
|
|
425
|
+
// Add params for the numeric table part of UNION
|
|
426
|
+
queryParams.push(params.layer, statusValue);
|
|
427
|
+
}
|
|
428
|
+
// Execute query
|
|
429
|
+
const stmt = db.prepare(query);
|
|
430
|
+
const rows = stmt.all(...queryParams);
|
|
431
|
+
return {
|
|
432
|
+
layer: params.layer,
|
|
433
|
+
decisions: rows,
|
|
434
|
+
count: rows.length
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
439
|
+
throw new Error(`Failed to search by layer: ${message}`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tools/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjJ,OAAO,EAAE,gBAAgB,EAAoB,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAmBtG;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,MAAyB;IACnD,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEzB,+BAA+B;IAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,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|
+
* File tracking tools for MCP Shared Context Server
|
|
3
|
+
* Provides file change tracking with layer integration and lock detection
|
|
4
|
+
*/
|
|
5
|
+
import type { RecordFileChangeParams, RecordFileChangeResponse, GetFileChangesParams, GetFileChangesResponse, CheckFileLockParams, CheckFileLockResponse } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Record a file change with optional layer assignment and description.
|
|
8
|
+
* Auto-registers the file and agent if they don't exist.
|
|
9
|
+
*
|
|
10
|
+
* @param params - File change parameters
|
|
11
|
+
* @returns Success response with change ID and timestamp
|
|
12
|
+
*/
|
|
13
|
+
export declare function recordFileChange(params: RecordFileChangeParams): RecordFileChangeResponse;
|
|
14
|
+
/**
|
|
15
|
+
* Get file changes with advanced filtering.
|
|
16
|
+
* Uses token-efficient view when no specific filters are applied.
|
|
17
|
+
*
|
|
18
|
+
* @param params - Filter parameters
|
|
19
|
+
* @returns Array of file changes with metadata
|
|
20
|
+
*/
|
|
21
|
+
export declare function getFileChanges(params: GetFileChangesParams): GetFileChangesResponse;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a file is "locked" (recently modified by another agent).
|
|
24
|
+
* Useful to prevent concurrent edits by multiple agents.
|
|
25
|
+
*
|
|
26
|
+
* @param params - File path and lock duration
|
|
27
|
+
* @returns Lock status with details
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkFileLock(params: CheckFileLockParams): CheckFileLockResponse;
|
|
30
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/tools/files.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EAEtB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,wBAAwB,CAwDzF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,CAiGnF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAsDhF"}
|