neuronlayer 0.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/CONTRIBUTING.md +127 -0
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/dist/index.js +38016 -0
- package/esbuild.config.js +26 -0
- package/package.json +63 -0
- package/src/cli/commands.ts +382 -0
- package/src/core/adr-exporter.ts +253 -0
- package/src/core/architecture/architecture-enforcement.ts +228 -0
- package/src/core/architecture/duplicate-detector.ts +288 -0
- package/src/core/architecture/index.ts +6 -0
- package/src/core/architecture/pattern-learner.ts +306 -0
- package/src/core/architecture/pattern-library.ts +403 -0
- package/src/core/architecture/pattern-validator.ts +324 -0
- package/src/core/change-intelligence/bug-correlator.ts +444 -0
- package/src/core/change-intelligence/change-intelligence.ts +221 -0
- package/src/core/change-intelligence/change-tracker.ts +334 -0
- package/src/core/change-intelligence/fix-suggester.ts +340 -0
- package/src/core/change-intelligence/index.ts +5 -0
- package/src/core/code-verifier.ts +843 -0
- package/src/core/confidence/confidence-scorer.ts +251 -0
- package/src/core/confidence/conflict-checker.ts +289 -0
- package/src/core/confidence/index.ts +5 -0
- package/src/core/confidence/source-tracker.ts +263 -0
- package/src/core/confidence/warning-detector.ts +241 -0
- package/src/core/context-rot/compaction.ts +284 -0
- package/src/core/context-rot/context-health.ts +243 -0
- package/src/core/context-rot/context-rot-prevention.ts +213 -0
- package/src/core/context-rot/critical-context.ts +221 -0
- package/src/core/context-rot/drift-detector.ts +255 -0
- package/src/core/context-rot/index.ts +7 -0
- package/src/core/context.ts +263 -0
- package/src/core/decision-extractor.ts +339 -0
- package/src/core/decisions.ts +69 -0
- package/src/core/deja-vu.ts +421 -0
- package/src/core/engine.ts +1455 -0
- package/src/core/feature-context.ts +726 -0
- package/src/core/ghost-mode.ts +412 -0
- package/src/core/learning.ts +485 -0
- package/src/core/living-docs/activity-tracker.ts +296 -0
- package/src/core/living-docs/architecture-generator.ts +428 -0
- package/src/core/living-docs/changelog-generator.ts +348 -0
- package/src/core/living-docs/component-generator.ts +230 -0
- package/src/core/living-docs/doc-engine.ts +110 -0
- package/src/core/living-docs/doc-validator.ts +282 -0
- package/src/core/living-docs/index.ts +8 -0
- package/src/core/project-manager.ts +297 -0
- package/src/core/summarizer.ts +267 -0
- package/src/core/test-awareness/change-validator.ts +499 -0
- package/src/core/test-awareness/index.ts +5 -0
- package/src/index.ts +49 -0
- package/src/indexing/ast.ts +563 -0
- package/src/indexing/embeddings.ts +85 -0
- package/src/indexing/indexer.ts +245 -0
- package/src/indexing/watcher.ts +78 -0
- package/src/server/gateways/aggregator.ts +374 -0
- package/src/server/gateways/index.ts +473 -0
- package/src/server/gateways/memory-ghost.ts +343 -0
- package/src/server/gateways/memory-query.ts +452 -0
- package/src/server/gateways/memory-record.ts +346 -0
- package/src/server/gateways/memory-review.ts +410 -0
- package/src/server/gateways/memory-status.ts +517 -0
- package/src/server/gateways/memory-verify.ts +392 -0
- package/src/server/gateways/router.ts +434 -0
- package/src/server/gateways/types.ts +610 -0
- package/src/server/mcp.ts +154 -0
- package/src/server/resources.ts +85 -0
- package/src/server/tools.ts +2261 -0
- package/src/storage/database.ts +262 -0
- package/src/storage/tier1.ts +135 -0
- package/src/storage/tier2.ts +764 -0
- package/src/storage/tier3.ts +123 -0
- package/src/types/documentation.ts +619 -0
- package/src/types/index.ts +222 -0
- package/src/utils/config.ts +193 -0
- package/src/utils/files.ts +117 -0
- package/src/utils/time.ts +37 -0
- package/src/utils/tokens.ts +52 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway Pattern Implementation
|
|
3
|
+
*
|
|
4
|
+
* Reduces 51 MCP tools to 6 gateway tools + 6 standalone (12 total),
|
|
5
|
+
* saving ~5,000 tokens per API call on tool description overhead.
|
|
6
|
+
*
|
|
7
|
+
* Benchmark Context: 759x speedup, 51.7% token reduction, p < 0.001, Cohen's d = 3.46
|
|
8
|
+
*
|
|
9
|
+
* Phase 12: Added memory_ghost for "Super Intelligent Brain" features
|
|
10
|
+
* Phase 13: Added memory_verify for pre-commit quality gate
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { MemoryLayerEngine } from '../../core/engine.js';
|
|
14
|
+
import type {
|
|
15
|
+
ToolDefinition,
|
|
16
|
+
MemoryQueryInput,
|
|
17
|
+
MemoryRecordInput,
|
|
18
|
+
MemoryReviewInput,
|
|
19
|
+
MemoryStatusInput,
|
|
20
|
+
MemoryVerifyInput,
|
|
21
|
+
} from './types.js';
|
|
22
|
+
import { handleMemoryQuery } from './memory-query.js';
|
|
23
|
+
import { handleMemoryRecord } from './memory-record.js';
|
|
24
|
+
import { handleMemoryReview } from './memory-review.js';
|
|
25
|
+
import { handleMemoryStatus } from './memory-status.js';
|
|
26
|
+
import { handleMemoryGhost, type MemoryGhostInput, type MemoryGhostResponse } from './memory-ghost.js';
|
|
27
|
+
import { handleMemoryVerify, type MemoryVerifyResponse } from './memory-verify.js';
|
|
28
|
+
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Gateway Tool Names
|
|
31
|
+
// ============================================================================
|
|
32
|
+
|
|
33
|
+
export const GATEWAY_TOOLS = [
|
|
34
|
+
'memory_query',
|
|
35
|
+
'memory_record',
|
|
36
|
+
'memory_review',
|
|
37
|
+
'memory_status',
|
|
38
|
+
'memory_ghost',
|
|
39
|
+
'memory_verify',
|
|
40
|
+
] as const;
|
|
41
|
+
|
|
42
|
+
export type GatewayToolName = typeof GATEWAY_TOOLS[number];
|
|
43
|
+
|
|
44
|
+
export function isGatewayTool(name: string): name is GatewayToolName {
|
|
45
|
+
return GATEWAY_TOOLS.includes(name as GatewayToolName);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Gateway Tool Definitions
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
export const gatewayDefinitions: ToolDefinition[] = [
|
|
53
|
+
{
|
|
54
|
+
name: 'memory_query',
|
|
55
|
+
description: 'PREFERRED over Grep/Glob/Read for codebase questions. Use this FIRST when you need to: understand how something works ("how does auth work?", "where is X used?"), find related code/decisions/patterns, get file content with context (pass file path as query), look up function/class definitions (pass symbol name), or check if code follows project patterns (pass code snippet). Returns semantic search results ranked by relevance. 759x faster than grep with 50% fewer tokens. Auto-routes based on input type.',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
query: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'The search query or question'
|
|
62
|
+
},
|
|
63
|
+
file: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'File path for file-specific operations'
|
|
66
|
+
},
|
|
67
|
+
symbol: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Symbol name for symbol lookups'
|
|
70
|
+
},
|
|
71
|
+
code: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'Code snippet for confidence/source analysis'
|
|
74
|
+
},
|
|
75
|
+
max_results: {
|
|
76
|
+
type: 'number',
|
|
77
|
+
description: 'Maximum number of results (default: 10)'
|
|
78
|
+
},
|
|
79
|
+
include_confidence: {
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
description: 'Include confidence scores in results'
|
|
82
|
+
},
|
|
83
|
+
action: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
enum: ['context', 'search', 'file', 'summary', 'symbol', 'dependencies', 'predict', 'confidence', 'sources', 'existing'],
|
|
86
|
+
description: 'Explicit action (auto-detected if not provided)'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
required: ['query']
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'memory_record',
|
|
94
|
+
description: 'Save important information to project memory. Use when: making architectural decisions (title + content auto-saves as decision), learning a code pattern (code + pattern_name auto-saves as pattern), user provides requirements (content + critical_type="requirement"), or starting work on a feature (content="feature name" tracks files touched). Decisions are checked for conflicts. Patterns are used in future code reviews. Critical items survive context compaction.',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
content: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Content or description of what to record'
|
|
101
|
+
},
|
|
102
|
+
title: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Title for decisions or patterns'
|
|
105
|
+
},
|
|
106
|
+
code: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Code snippet for patterns'
|
|
109
|
+
},
|
|
110
|
+
pattern_name: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Name for patterns'
|
|
113
|
+
},
|
|
114
|
+
files: {
|
|
115
|
+
type: 'array',
|
|
116
|
+
items: { type: 'string' },
|
|
117
|
+
description: 'Related files'
|
|
118
|
+
},
|
|
119
|
+
tags: {
|
|
120
|
+
type: 'array',
|
|
121
|
+
items: { type: 'string' },
|
|
122
|
+
description: 'Tags for categorization'
|
|
123
|
+
},
|
|
124
|
+
author: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
description: 'Author attribution'
|
|
127
|
+
},
|
|
128
|
+
type: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
enum: ['decision', 'pattern', 'feedback', 'feature', 'critical', 'example'],
|
|
131
|
+
description: 'Record type (auto-detected if not provided)'
|
|
132
|
+
},
|
|
133
|
+
was_useful: {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
description: 'For feedback: whether context was useful'
|
|
136
|
+
},
|
|
137
|
+
pattern_id: {
|
|
138
|
+
type: 'string',
|
|
139
|
+
description: 'For examples: pattern ID to add to'
|
|
140
|
+
},
|
|
141
|
+
is_anti_pattern: {
|
|
142
|
+
type: 'boolean',
|
|
143
|
+
description: 'For examples: mark as anti-pattern'
|
|
144
|
+
},
|
|
145
|
+
critical_type: {
|
|
146
|
+
type: 'string',
|
|
147
|
+
enum: ['decision', 'requirement', 'instruction', 'custom'],
|
|
148
|
+
description: 'For critical content: type of critical content'
|
|
149
|
+
},
|
|
150
|
+
reason: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
description: 'Reason for marking as critical'
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
required: ['content']
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'memory_review',
|
|
160
|
+
description: 'ALWAYS use before writing/suggesting code changes. Reviews against: project patterns (are you following conventions?), past decisions (does this conflict with architecture choices?), similar past bugs (has this error happened before?), and test coverage (will tests break?). Returns risk_score (0-100) and verdict (approve/warning/reject). Use verdict to decide whether to proceed. Include "intent" for better existing-function suggestions.',
|
|
161
|
+
inputSchema: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
properties: {
|
|
164
|
+
code: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Code to review'
|
|
167
|
+
},
|
|
168
|
+
file: {
|
|
169
|
+
type: 'string',
|
|
170
|
+
description: 'File being changed (enables test checks)'
|
|
171
|
+
},
|
|
172
|
+
intent: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
description: 'What this code is for (improves suggestions)'
|
|
175
|
+
},
|
|
176
|
+
include_tests: {
|
|
177
|
+
type: 'boolean',
|
|
178
|
+
description: 'Include test impact analysis (default: true if file provided)'
|
|
179
|
+
},
|
|
180
|
+
include_patterns: {
|
|
181
|
+
type: 'boolean',
|
|
182
|
+
description: 'Include pattern validation (default: true)'
|
|
183
|
+
},
|
|
184
|
+
error: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
description: 'Error message for bug search'
|
|
187
|
+
},
|
|
188
|
+
action: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
enum: ['full', 'pattern', 'conflicts', 'tests', 'confidence', 'bugs', 'coverage'],
|
|
191
|
+
description: 'Specific check to run (default: full review)'
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
required: ['code']
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'memory_status',
|
|
199
|
+
description: 'Use at SESSION START or when context feels stale. Returns: scope="project" for languages/file count/recent decisions/key directories, scope="architecture" for layer diagram/data flow/key components, scope="changes" + since="today" for what changed recently, scope="health" for context utilization/drift detection/compaction suggestions. Default (no args) gives project summary. Add since="this week" for recent activity.',
|
|
200
|
+
inputSchema: {
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: {
|
|
203
|
+
scope: {
|
|
204
|
+
type: 'string',
|
|
205
|
+
enum: ['project', 'architecture', 'changes', 'docs', 'health', 'patterns', 'tests', 'all'],
|
|
206
|
+
description: 'Scope of status to retrieve (default: project)'
|
|
207
|
+
},
|
|
208
|
+
since: {
|
|
209
|
+
type: 'string',
|
|
210
|
+
description: 'Time period for changes: "yesterday", "today", "this week", "this month", or date'
|
|
211
|
+
},
|
|
212
|
+
file: {
|
|
213
|
+
type: 'string',
|
|
214
|
+
description: 'File or directory to filter by'
|
|
215
|
+
},
|
|
216
|
+
author: {
|
|
217
|
+
type: 'string',
|
|
218
|
+
description: 'Author to filter changes by'
|
|
219
|
+
},
|
|
220
|
+
action: {
|
|
221
|
+
type: 'string',
|
|
222
|
+
enum: ['summary', 'happened', 'changed', 'architecture', 'changelog', 'health', 'patterns', 'stats', 'undocumented', 'critical', 'learning'],
|
|
223
|
+
description: 'Specific status to retrieve'
|
|
224
|
+
},
|
|
225
|
+
include_history: {
|
|
226
|
+
type: 'boolean',
|
|
227
|
+
description: 'Include health history'
|
|
228
|
+
},
|
|
229
|
+
category: {
|
|
230
|
+
type: 'string',
|
|
231
|
+
description: 'Pattern category filter'
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'memory_ghost',
|
|
238
|
+
description: 'The "Super Intelligent Brain" - provides proactive intelligence. Use mode="conflicts" before writing code to check for decision conflicts. Use mode="dejavu" to find "You solved this before" moments. Use mode="resurrect" at session start to get "Welcome back! Last time you were working on X". Use mode="full" (default) for complete ghost insight. Returns conflict warnings, déjà vu matches, and session resurrection data.',
|
|
239
|
+
inputSchema: {
|
|
240
|
+
type: 'object',
|
|
241
|
+
properties: {
|
|
242
|
+
mode: {
|
|
243
|
+
type: 'string',
|
|
244
|
+
enum: ['full', 'conflicts', 'dejavu', 'resurrect'],
|
|
245
|
+
description: 'What to check (default: full)'
|
|
246
|
+
},
|
|
247
|
+
code: {
|
|
248
|
+
type: 'string',
|
|
249
|
+
description: 'Code to check for conflicts/déjà vu'
|
|
250
|
+
},
|
|
251
|
+
file: {
|
|
252
|
+
type: 'string',
|
|
253
|
+
description: 'Current file being worked on'
|
|
254
|
+
},
|
|
255
|
+
query: {
|
|
256
|
+
type: 'string',
|
|
257
|
+
description: 'Query for déjà vu search'
|
|
258
|
+
},
|
|
259
|
+
feature_name: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
description: 'Feature name for resurrection'
|
|
262
|
+
},
|
|
263
|
+
max_results: {
|
|
264
|
+
type: 'number',
|
|
265
|
+
description: 'Maximum déjà vu results (default: 5)'
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'memory_verify',
|
|
272
|
+
description: 'Pre-commit quality gate for AI-generated code. Catches hallucinations, security issues, and integration problems BEFORE they land. Run before committing AI suggestions. Checks: imports (do they exist?), security (OWASP Top 10), dependencies (installed?), patterns (project conventions), tests (will they break?). Returns verdict (pass/warning/fail), score (0-100), and actionable suggestions.',
|
|
273
|
+
inputSchema: {
|
|
274
|
+
type: 'object',
|
|
275
|
+
properties: {
|
|
276
|
+
code: {
|
|
277
|
+
type: 'string',
|
|
278
|
+
description: 'Code to verify'
|
|
279
|
+
},
|
|
280
|
+
file: {
|
|
281
|
+
type: 'string',
|
|
282
|
+
description: 'Target file path (enables import resolution and test checks)'
|
|
283
|
+
},
|
|
284
|
+
checks: {
|
|
285
|
+
type: 'array',
|
|
286
|
+
items: {
|
|
287
|
+
type: 'string',
|
|
288
|
+
enum: ['imports', 'security', 'dependencies', 'patterns', 'tests', 'all']
|
|
289
|
+
},
|
|
290
|
+
description: 'Specific checks to run (default: all)'
|
|
291
|
+
},
|
|
292
|
+
intent: {
|
|
293
|
+
type: 'string',
|
|
294
|
+
description: 'What this code is for (improves suggestions)'
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
required: ['code']
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
];
|
|
301
|
+
|
|
302
|
+
// ============================================================================
|
|
303
|
+
// Standalone Tool Definitions (Require Explicit IDs/Actions)
|
|
304
|
+
// ============================================================================
|
|
305
|
+
|
|
306
|
+
export const standaloneDefinitions: ToolDefinition[] = [
|
|
307
|
+
{
|
|
308
|
+
name: 'switch_project',
|
|
309
|
+
description: 'Switch active project context. Use when user mentions a different project by name. Get project_id from memory_status first.',
|
|
310
|
+
inputSchema: {
|
|
311
|
+
type: 'object',
|
|
312
|
+
properties: {
|
|
313
|
+
project_id: {
|
|
314
|
+
type: 'string',
|
|
315
|
+
description: 'The project ID to switch to'
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
required: ['project_id']
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: 'switch_feature_context',
|
|
323
|
+
description: 'Resume tracking a previous feature. Use when user says "back to [feature]" or "continue [feature]". Get context_id from memory_status action=learning.',
|
|
324
|
+
inputSchema: {
|
|
325
|
+
type: 'object',
|
|
326
|
+
properties: {
|
|
327
|
+
context_id: {
|
|
328
|
+
type: 'string',
|
|
329
|
+
description: 'ID of the context to switch to (from list_recent_contexts)'
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
required: ['context_id']
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: 'trigger_compaction',
|
|
337
|
+
description: 'Reduce memory token usage when memory_status shows health="warning" or compaction_needed=true. Strategy: summarize (safe), selective (moderate), aggressive (maximum savings).',
|
|
338
|
+
inputSchema: {
|
|
339
|
+
type: 'object',
|
|
340
|
+
properties: {
|
|
341
|
+
strategy: {
|
|
342
|
+
type: 'string',
|
|
343
|
+
enum: ['summarize', 'selective', 'aggressive'],
|
|
344
|
+
description: 'Compaction strategy: summarize (gentle), selective (moderate), aggressive (maximum reduction)'
|
|
345
|
+
},
|
|
346
|
+
preserve_recent: {
|
|
347
|
+
type: 'number',
|
|
348
|
+
description: 'Number of recent messages to preserve (default: 10)'
|
|
349
|
+
},
|
|
350
|
+
target_utilization: {
|
|
351
|
+
type: 'number',
|
|
352
|
+
description: 'Target utilization percentage (e.g., 50 for 50%)'
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: 'update_decision_status',
|
|
359
|
+
description: 'Mark a decision as deprecated/superseded when architecture changes. Get decision_id from memory_query first. Use superseded_by to link to replacement decision.',
|
|
360
|
+
inputSchema: {
|
|
361
|
+
type: 'object',
|
|
362
|
+
properties: {
|
|
363
|
+
decision_id: {
|
|
364
|
+
type: 'string',
|
|
365
|
+
description: 'ID of the decision to update'
|
|
366
|
+
},
|
|
367
|
+
status: {
|
|
368
|
+
type: 'string',
|
|
369
|
+
enum: ['proposed', 'accepted', 'deprecated', 'superseded'],
|
|
370
|
+
description: 'New status for the decision'
|
|
371
|
+
},
|
|
372
|
+
superseded_by: {
|
|
373
|
+
type: 'string',
|
|
374
|
+
description: 'ID of the decision that supersedes this one (if status is superseded)'
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
required: ['decision_id', 'status']
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: 'export_decisions_to_adr',
|
|
382
|
+
description: 'Export decisions as Architecture Decision Records. Use when user asks for documentation or "ADRs". Creates docs/decisions/*.md files.',
|
|
383
|
+
inputSchema: {
|
|
384
|
+
type: 'object',
|
|
385
|
+
properties: {
|
|
386
|
+
output_dir: {
|
|
387
|
+
type: 'string',
|
|
388
|
+
description: 'Output directory for ADR files (default: docs/decisions)'
|
|
389
|
+
},
|
|
390
|
+
format: {
|
|
391
|
+
type: 'string',
|
|
392
|
+
enum: ['madr', 'nygard', 'simple'],
|
|
393
|
+
description: 'ADR format to use (default: madr)'
|
|
394
|
+
},
|
|
395
|
+
include_index: {
|
|
396
|
+
type: 'boolean',
|
|
397
|
+
description: 'Generate README index file (default: true)'
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
name: 'discover_projects',
|
|
404
|
+
description: 'Find git repositories on the system. Use when user wants to add/register a project to MemoryLayer.',
|
|
405
|
+
inputSchema: {
|
|
406
|
+
type: 'object',
|
|
407
|
+
properties: {}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
];
|
|
411
|
+
|
|
412
|
+
// ============================================================================
|
|
413
|
+
// Combined Definitions (for backward compatibility)
|
|
414
|
+
// ============================================================================
|
|
415
|
+
|
|
416
|
+
export const allToolDefinitions: ToolDefinition[] = [
|
|
417
|
+
...gatewayDefinitions,
|
|
418
|
+
...standaloneDefinitions,
|
|
419
|
+
];
|
|
420
|
+
|
|
421
|
+
// ============================================================================
|
|
422
|
+
// Gateway Handler
|
|
423
|
+
// ============================================================================
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Handle a gateway tool call, routing to the appropriate internal tools
|
|
427
|
+
*/
|
|
428
|
+
export async function handleGatewayCall(
|
|
429
|
+
engine: MemoryLayerEngine,
|
|
430
|
+
gatewayName: string,
|
|
431
|
+
args: Record<string, unknown>
|
|
432
|
+
): Promise<unknown> {
|
|
433
|
+
switch (gatewayName) {
|
|
434
|
+
case 'memory_query':
|
|
435
|
+
return handleMemoryQuery(engine, args as unknown as MemoryQueryInput);
|
|
436
|
+
|
|
437
|
+
case 'memory_record':
|
|
438
|
+
return handleMemoryRecord(engine, args as unknown as MemoryRecordInput);
|
|
439
|
+
|
|
440
|
+
case 'memory_review':
|
|
441
|
+
return handleMemoryReview(engine, args as unknown as MemoryReviewInput);
|
|
442
|
+
|
|
443
|
+
case 'memory_status':
|
|
444
|
+
return handleMemoryStatus(engine, args as unknown as MemoryStatusInput);
|
|
445
|
+
|
|
446
|
+
case 'memory_ghost':
|
|
447
|
+
return handleMemoryGhost(engine, args as unknown as MemoryGhostInput);
|
|
448
|
+
|
|
449
|
+
case 'memory_verify':
|
|
450
|
+
return handleMemoryVerify(engine, args as unknown as MemoryVerifyInput);
|
|
451
|
+
|
|
452
|
+
default:
|
|
453
|
+
throw new Error(`Unknown gateway: ${gatewayName}`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Re-export types
|
|
458
|
+
export type {
|
|
459
|
+
ToolDefinition,
|
|
460
|
+
MemoryQueryInput,
|
|
461
|
+
MemoryQueryResponse,
|
|
462
|
+
MemoryRecordInput,
|
|
463
|
+
MemoryRecordResponse,
|
|
464
|
+
MemoryReviewInput,
|
|
465
|
+
MemoryReviewResponse,
|
|
466
|
+
MemoryStatusInput,
|
|
467
|
+
MemoryStatusResponse,
|
|
468
|
+
MemoryVerifyInput,
|
|
469
|
+
MemoryVerifyResponse,
|
|
470
|
+
} from './types.js';
|
|
471
|
+
|
|
472
|
+
export type { MemoryGhostInput, MemoryGhostResponse } from './memory-ghost.js';
|
|
473
|
+
export type { MemoryVerifyResponse as VerifyResponse } from './memory-verify.js';
|