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,610 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway Pattern Types
|
|
3
|
+
*
|
|
4
|
+
* Reduces 51 MCP tools to 4 gateway tools + 6 standalone,
|
|
5
|
+
* saving ~5,000 tokens per API call on tool description overhead.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Memory Query Gateway Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export type MemoryQueryAction =
|
|
13
|
+
| 'context' // get_context
|
|
14
|
+
| 'search' // search_codebase
|
|
15
|
+
| 'file' // get_file_context
|
|
16
|
+
| 'summary' // get_file_summary
|
|
17
|
+
| 'symbol' // get_symbol
|
|
18
|
+
| 'dependencies' // get_dependencies
|
|
19
|
+
| 'predict' // get_predicted_files
|
|
20
|
+
| 'confidence' // get_confidence
|
|
21
|
+
| 'sources' // list_sources
|
|
22
|
+
| 'existing'; // suggest_existing
|
|
23
|
+
|
|
24
|
+
export interface MemoryQueryInput {
|
|
25
|
+
/** The search query or question */
|
|
26
|
+
query: string;
|
|
27
|
+
/** File path for file-specific operations */
|
|
28
|
+
file?: string;
|
|
29
|
+
/** Symbol name for symbol lookups */
|
|
30
|
+
symbol?: string;
|
|
31
|
+
/** Code snippet for confidence/source analysis */
|
|
32
|
+
code?: string;
|
|
33
|
+
/** Maximum number of results to return */
|
|
34
|
+
max_results?: number;
|
|
35
|
+
/** Include confidence scores in results */
|
|
36
|
+
include_confidence?: boolean;
|
|
37
|
+
/** Explicit action to perform (auto-detected if not provided) */
|
|
38
|
+
action?: MemoryQueryAction;
|
|
39
|
+
/** Symbol kind filter for symbol lookups */
|
|
40
|
+
symbol_kind?: 'function' | 'class' | 'interface' | 'type' | 'method' | 'enum';
|
|
41
|
+
/** Maximum tokens for context retrieval */
|
|
42
|
+
max_tokens?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface MemoryQueryResponse {
|
|
46
|
+
/** Sources used to generate response */
|
|
47
|
+
sources_used: string[];
|
|
48
|
+
/** Aggregated context from multiple tools */
|
|
49
|
+
context?: {
|
|
50
|
+
content: string;
|
|
51
|
+
sources: string[];
|
|
52
|
+
token_count: number;
|
|
53
|
+
decisions?: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
title: string;
|
|
56
|
+
description: string;
|
|
57
|
+
created_at: string;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
/** Search results */
|
|
61
|
+
search_results?: Array<{
|
|
62
|
+
file: string;
|
|
63
|
+
preview: string;
|
|
64
|
+
relevance: number;
|
|
65
|
+
line_start?: number;
|
|
66
|
+
line_end?: number;
|
|
67
|
+
}>;
|
|
68
|
+
/** File content */
|
|
69
|
+
file_content?: {
|
|
70
|
+
path: string;
|
|
71
|
+
content: string;
|
|
72
|
+
language: string;
|
|
73
|
+
lines: number;
|
|
74
|
+
};
|
|
75
|
+
/** File summary */
|
|
76
|
+
file_summary?: {
|
|
77
|
+
path: string;
|
|
78
|
+
summary: string;
|
|
79
|
+
};
|
|
80
|
+
/** Symbol results */
|
|
81
|
+
symbols?: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
kind: string;
|
|
84
|
+
file: string;
|
|
85
|
+
line_start: number;
|
|
86
|
+
line_end: number;
|
|
87
|
+
signature?: string;
|
|
88
|
+
exported: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
/** Dependency information */
|
|
91
|
+
dependencies?: {
|
|
92
|
+
file: string;
|
|
93
|
+
imports: Array<{ file: string; symbols: string[] }>;
|
|
94
|
+
imported_by: Array<{ file: string; symbols: string[] }>;
|
|
95
|
+
symbols: Array<{ name: string; kind: string; line: number; exported: boolean }>;
|
|
96
|
+
};
|
|
97
|
+
/** Predicted files */
|
|
98
|
+
predicted_files?: {
|
|
99
|
+
files: string[];
|
|
100
|
+
pre_fetched: number;
|
|
101
|
+
};
|
|
102
|
+
/** Confidence assessment */
|
|
103
|
+
confidence?: {
|
|
104
|
+
level: string;
|
|
105
|
+
score: number;
|
|
106
|
+
reasoning: string;
|
|
107
|
+
indicator: string;
|
|
108
|
+
};
|
|
109
|
+
/** Source attribution */
|
|
110
|
+
source_attribution?: {
|
|
111
|
+
codebase_matches: number;
|
|
112
|
+
decision_matches: number;
|
|
113
|
+
pattern_matches: number;
|
|
114
|
+
used_general_knowledge: boolean;
|
|
115
|
+
};
|
|
116
|
+
/** Existing function suggestions */
|
|
117
|
+
existing_functions?: Array<{
|
|
118
|
+
name: string;
|
|
119
|
+
file: string;
|
|
120
|
+
line: number;
|
|
121
|
+
signature: string;
|
|
122
|
+
similarity: number;
|
|
123
|
+
}>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Memory Record Gateway Types
|
|
128
|
+
// ============================================================================
|
|
129
|
+
|
|
130
|
+
export type MemoryRecordType =
|
|
131
|
+
| 'decision' // record_decision, record_decision_with_author
|
|
132
|
+
| 'pattern' // learn_pattern
|
|
133
|
+
| 'feedback' // mark_context_useful
|
|
134
|
+
| 'feature' // set_feature_context
|
|
135
|
+
| 'critical' // mark_critical
|
|
136
|
+
| 'example'; // add_pattern_example
|
|
137
|
+
|
|
138
|
+
export interface MemoryRecordInput {
|
|
139
|
+
/** Content or description of what to record */
|
|
140
|
+
content: string;
|
|
141
|
+
/** Title for decisions */
|
|
142
|
+
title?: string;
|
|
143
|
+
/** Code snippet for patterns */
|
|
144
|
+
code?: string;
|
|
145
|
+
/** Pattern name for patterns */
|
|
146
|
+
pattern_name?: string;
|
|
147
|
+
/** Related files */
|
|
148
|
+
files?: string[];
|
|
149
|
+
/** Tags for categorization */
|
|
150
|
+
tags?: string[];
|
|
151
|
+
/** Author attribution */
|
|
152
|
+
author?: string;
|
|
153
|
+
/** Record type (auto-detected if not provided) */
|
|
154
|
+
type?: MemoryRecordType;
|
|
155
|
+
/** Explicit action to perform */
|
|
156
|
+
action?: MemoryRecordType;
|
|
157
|
+
/** Was the context useful (for feedback) */
|
|
158
|
+
was_useful?: boolean;
|
|
159
|
+
/** Original query (for feedback) */
|
|
160
|
+
query?: string;
|
|
161
|
+
/** Decision status */
|
|
162
|
+
status?: 'proposed' | 'accepted' | 'deprecated' | 'superseded';
|
|
163
|
+
/** Pattern category */
|
|
164
|
+
category?: string;
|
|
165
|
+
/** Pattern ID (for adding examples) */
|
|
166
|
+
pattern_id?: string;
|
|
167
|
+
/** Is this an anti-pattern example */
|
|
168
|
+
is_anti_pattern?: boolean;
|
|
169
|
+
/** Explanation for pattern examples */
|
|
170
|
+
explanation?: string;
|
|
171
|
+
/** Critical content type */
|
|
172
|
+
critical_type?: 'decision' | 'requirement' | 'instruction' | 'custom';
|
|
173
|
+
/** Reason for marking as critical */
|
|
174
|
+
reason?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface MemoryRecordResponse {
|
|
178
|
+
/** Whether the operation succeeded */
|
|
179
|
+
success: boolean;
|
|
180
|
+
/** Type of record created */
|
|
181
|
+
type: MemoryRecordType;
|
|
182
|
+
/** ID of created record */
|
|
183
|
+
id?: string;
|
|
184
|
+
/** Human-readable message */
|
|
185
|
+
message: string;
|
|
186
|
+
/** Conflict warnings (for decisions) */
|
|
187
|
+
warnings?: Array<{
|
|
188
|
+
type: string;
|
|
189
|
+
message: string;
|
|
190
|
+
severity: 'low' | 'medium' | 'high';
|
|
191
|
+
}>;
|
|
192
|
+
/** Created record details */
|
|
193
|
+
record?: Record<string, unknown>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ============================================================================
|
|
197
|
+
// Memory Review Gateway Types
|
|
198
|
+
// ============================================================================
|
|
199
|
+
|
|
200
|
+
export type MemoryReviewAction =
|
|
201
|
+
| 'full' // Run all checks
|
|
202
|
+
| 'pattern' // validate_pattern only
|
|
203
|
+
| 'conflicts' // check_conflicts only
|
|
204
|
+
| 'tests' // check_tests only
|
|
205
|
+
| 'confidence' // get_confidence only
|
|
206
|
+
| 'bugs' // find_similar_bugs only
|
|
207
|
+
| 'coverage'; // get_test_coverage only
|
|
208
|
+
|
|
209
|
+
export interface MemoryReviewInput {
|
|
210
|
+
/** Code to review */
|
|
211
|
+
code: string;
|
|
212
|
+
/** File being changed (for test checks) */
|
|
213
|
+
file?: string;
|
|
214
|
+
/** What this code is for (context) */
|
|
215
|
+
intent?: string;
|
|
216
|
+
/** Include test impact analysis */
|
|
217
|
+
include_tests?: boolean;
|
|
218
|
+
/** Include pattern validation */
|
|
219
|
+
include_patterns?: boolean;
|
|
220
|
+
/** Error message (for bug search) */
|
|
221
|
+
error?: string;
|
|
222
|
+
/** Explicit action to perform */
|
|
223
|
+
action?: MemoryReviewAction;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface MemoryReviewResponse {
|
|
227
|
+
/** Overall verdict */
|
|
228
|
+
verdict: 'approve' | 'warning' | 'reject';
|
|
229
|
+
/** Unified risk score (0-100) */
|
|
230
|
+
risk_score: number;
|
|
231
|
+
/** Sources used for review */
|
|
232
|
+
sources_used: string[];
|
|
233
|
+
/** Pattern validation results */
|
|
234
|
+
patterns?: {
|
|
235
|
+
valid: boolean;
|
|
236
|
+
score: number;
|
|
237
|
+
matched_pattern?: string;
|
|
238
|
+
violations: Array<{
|
|
239
|
+
rule: string;
|
|
240
|
+
message: string;
|
|
241
|
+
severity: string;
|
|
242
|
+
suggestion?: string;
|
|
243
|
+
}>;
|
|
244
|
+
};
|
|
245
|
+
/** Conflict detection results */
|
|
246
|
+
conflicts?: {
|
|
247
|
+
has_conflicts: boolean;
|
|
248
|
+
conflicts: Array<{
|
|
249
|
+
decision_id: string;
|
|
250
|
+
decision_title: string;
|
|
251
|
+
conflict_description: string;
|
|
252
|
+
severity: string;
|
|
253
|
+
}>;
|
|
254
|
+
};
|
|
255
|
+
/** Existing alternatives found */
|
|
256
|
+
existing_alternatives?: Array<{
|
|
257
|
+
name: string;
|
|
258
|
+
file: string;
|
|
259
|
+
line: number;
|
|
260
|
+
signature: string;
|
|
261
|
+
similarity: number;
|
|
262
|
+
}>;
|
|
263
|
+
/** Test impact analysis */
|
|
264
|
+
test_impact?: {
|
|
265
|
+
safe: boolean;
|
|
266
|
+
coverage_percent: number;
|
|
267
|
+
would_fail: Array<{
|
|
268
|
+
test_name: string;
|
|
269
|
+
test_file: string;
|
|
270
|
+
reason: string;
|
|
271
|
+
suggested_fix?: string;
|
|
272
|
+
}>;
|
|
273
|
+
suggested_updates?: Array<{
|
|
274
|
+
file: string;
|
|
275
|
+
test_name: string;
|
|
276
|
+
before: string;
|
|
277
|
+
after: string;
|
|
278
|
+
reason: string;
|
|
279
|
+
}>;
|
|
280
|
+
};
|
|
281
|
+
/** Confidence assessment */
|
|
282
|
+
confidence?: {
|
|
283
|
+
level: string;
|
|
284
|
+
score: number;
|
|
285
|
+
reasoning: string;
|
|
286
|
+
};
|
|
287
|
+
/** Similar bugs from history */
|
|
288
|
+
similar_bugs?: Array<{
|
|
289
|
+
error: string;
|
|
290
|
+
similarity: number;
|
|
291
|
+
fix?: string;
|
|
292
|
+
file?: string;
|
|
293
|
+
}>;
|
|
294
|
+
/** Test coverage details */
|
|
295
|
+
coverage?: {
|
|
296
|
+
file: string;
|
|
297
|
+
total_tests: number;
|
|
298
|
+
coverage_percent: number;
|
|
299
|
+
uncovered_functions: string[];
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// ============================================================================
|
|
304
|
+
// Memory Status Gateway Types
|
|
305
|
+
// ============================================================================
|
|
306
|
+
|
|
307
|
+
export type MemoryStatusScope =
|
|
308
|
+
| 'project' // get_project_summary
|
|
309
|
+
| 'architecture' // get_architecture
|
|
310
|
+
| 'changes' // what_changed, what_happened
|
|
311
|
+
| 'docs' // validate_docs
|
|
312
|
+
| 'health' // get_context_health
|
|
313
|
+
| 'patterns' // list_patterns
|
|
314
|
+
| 'tests' // test statistics
|
|
315
|
+
| 'all'; // everything
|
|
316
|
+
|
|
317
|
+
export type MemoryStatusAction =
|
|
318
|
+
| 'summary' // get_project_summary
|
|
319
|
+
| 'happened' // what_happened
|
|
320
|
+
| 'changed' // what_changed
|
|
321
|
+
| 'architecture' // get_architecture
|
|
322
|
+
| 'changelog' // get_changelog
|
|
323
|
+
| 'health' // get_context_health
|
|
324
|
+
| 'patterns' // list_patterns
|
|
325
|
+
| 'stats' // get_architecture_stats
|
|
326
|
+
| 'undocumented' // find_undocumented
|
|
327
|
+
| 'critical' // get_critical_context
|
|
328
|
+
| 'learning'; // get_learning_stats
|
|
329
|
+
|
|
330
|
+
export interface MemoryStatusInput {
|
|
331
|
+
/** Scope of status to retrieve */
|
|
332
|
+
scope?: MemoryStatusScope;
|
|
333
|
+
/** Time period for change queries */
|
|
334
|
+
since?: string;
|
|
335
|
+
/** File or directory filter */
|
|
336
|
+
file?: string;
|
|
337
|
+
/** Author filter */
|
|
338
|
+
author?: string;
|
|
339
|
+
/** Explicit action to perform */
|
|
340
|
+
action?: MemoryStatusAction;
|
|
341
|
+
/** Include health history */
|
|
342
|
+
include_history?: boolean;
|
|
343
|
+
/** Pattern category filter */
|
|
344
|
+
category?: string;
|
|
345
|
+
/** Changelog grouping */
|
|
346
|
+
group_by?: 'day' | 'week';
|
|
347
|
+
/** Include decisions in changelog */
|
|
348
|
+
include_decisions?: boolean;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface MemoryStatusResponse {
|
|
352
|
+
/** Sources used to generate status */
|
|
353
|
+
sources_used: string[];
|
|
354
|
+
/** Project summary */
|
|
355
|
+
project?: {
|
|
356
|
+
name: string;
|
|
357
|
+
description?: string;
|
|
358
|
+
languages: string[];
|
|
359
|
+
total_files: number;
|
|
360
|
+
total_lines: number;
|
|
361
|
+
key_directories: string[];
|
|
362
|
+
recent_decisions: Array<{
|
|
363
|
+
id: string;
|
|
364
|
+
title: string;
|
|
365
|
+
created_at: string;
|
|
366
|
+
}>;
|
|
367
|
+
};
|
|
368
|
+
/** Architecture overview */
|
|
369
|
+
architecture?: {
|
|
370
|
+
name: string;
|
|
371
|
+
description: string;
|
|
372
|
+
diagram?: string;
|
|
373
|
+
layers: Array<{
|
|
374
|
+
name: string;
|
|
375
|
+
directory: string;
|
|
376
|
+
files_count: number;
|
|
377
|
+
purpose: string;
|
|
378
|
+
}>;
|
|
379
|
+
data_flow?: Array<{
|
|
380
|
+
from: string;
|
|
381
|
+
to: string;
|
|
382
|
+
description: string;
|
|
383
|
+
}>;
|
|
384
|
+
key_components: Array<{
|
|
385
|
+
name: string;
|
|
386
|
+
file: string;
|
|
387
|
+
purpose: string;
|
|
388
|
+
}>;
|
|
389
|
+
};
|
|
390
|
+
/** Recent changes */
|
|
391
|
+
changes?: {
|
|
392
|
+
period: string;
|
|
393
|
+
total_files: number;
|
|
394
|
+
total_lines_added: number;
|
|
395
|
+
total_lines_removed: number;
|
|
396
|
+
by_author: Record<string, number>;
|
|
397
|
+
recent: Array<{
|
|
398
|
+
file: string;
|
|
399
|
+
type: string;
|
|
400
|
+
lines_added: number;
|
|
401
|
+
lines_removed: number;
|
|
402
|
+
author?: string;
|
|
403
|
+
timestamp: string;
|
|
404
|
+
}>;
|
|
405
|
+
};
|
|
406
|
+
/** Activity summary (what_happened) */
|
|
407
|
+
activity?: {
|
|
408
|
+
time_range: {
|
|
409
|
+
since: string;
|
|
410
|
+
until: string;
|
|
411
|
+
};
|
|
412
|
+
summary: string;
|
|
413
|
+
changes_count: number;
|
|
414
|
+
decisions_count: number;
|
|
415
|
+
files_affected: string[];
|
|
416
|
+
};
|
|
417
|
+
/** Changelog */
|
|
418
|
+
changelog?: Array<{
|
|
419
|
+
date: string;
|
|
420
|
+
summary: string;
|
|
421
|
+
features: number;
|
|
422
|
+
fixes: number;
|
|
423
|
+
refactors: number;
|
|
424
|
+
}>;
|
|
425
|
+
/** Documentation health */
|
|
426
|
+
docs?: {
|
|
427
|
+
is_valid: boolean;
|
|
428
|
+
score: number;
|
|
429
|
+
outdated_count: number;
|
|
430
|
+
undocumented_count: number;
|
|
431
|
+
suggestions: Array<{
|
|
432
|
+
file: string;
|
|
433
|
+
suggestion: string;
|
|
434
|
+
priority: string;
|
|
435
|
+
}>;
|
|
436
|
+
};
|
|
437
|
+
/** Context health */
|
|
438
|
+
health?: {
|
|
439
|
+
health: string;
|
|
440
|
+
tokens_used: number;
|
|
441
|
+
tokens_limit: number;
|
|
442
|
+
utilization: string;
|
|
443
|
+
drift_detected: boolean;
|
|
444
|
+
compaction_needed: boolean;
|
|
445
|
+
suggestions: string[];
|
|
446
|
+
};
|
|
447
|
+
/** Pattern list */
|
|
448
|
+
patterns?: {
|
|
449
|
+
total: number;
|
|
450
|
+
by_category: Record<string, number>;
|
|
451
|
+
patterns: Array<{
|
|
452
|
+
id: string;
|
|
453
|
+
name: string;
|
|
454
|
+
category: string;
|
|
455
|
+
usage_count: number;
|
|
456
|
+
}>;
|
|
457
|
+
};
|
|
458
|
+
/** Architecture stats */
|
|
459
|
+
stats?: {
|
|
460
|
+
patterns_total: number;
|
|
461
|
+
functions_total: number;
|
|
462
|
+
functions_exported: number;
|
|
463
|
+
};
|
|
464
|
+
/** Critical context */
|
|
465
|
+
critical?: {
|
|
466
|
+
total: number;
|
|
467
|
+
by_type: Record<string, number>;
|
|
468
|
+
items: Array<{
|
|
469
|
+
id: string;
|
|
470
|
+
type: string;
|
|
471
|
+
content: string;
|
|
472
|
+
reason?: string;
|
|
473
|
+
}>;
|
|
474
|
+
};
|
|
475
|
+
/** Learning stats */
|
|
476
|
+
learning?: {
|
|
477
|
+
total_queries: number;
|
|
478
|
+
total_file_views: number;
|
|
479
|
+
top_files: Array<{ path: string; count: number }>;
|
|
480
|
+
cache_size: number;
|
|
481
|
+
};
|
|
482
|
+
/** Undocumented items */
|
|
483
|
+
undocumented?: {
|
|
484
|
+
total: number;
|
|
485
|
+
by_importance: Record<string, number>;
|
|
486
|
+
items: Array<{
|
|
487
|
+
file: string;
|
|
488
|
+
symbol?: string;
|
|
489
|
+
type: string;
|
|
490
|
+
importance: string;
|
|
491
|
+
}>;
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// ============================================================================
|
|
496
|
+
// Tool Definition Types
|
|
497
|
+
// ============================================================================
|
|
498
|
+
|
|
499
|
+
export interface ToolDefinition {
|
|
500
|
+
name: string;
|
|
501
|
+
description: string;
|
|
502
|
+
inputSchema: {
|
|
503
|
+
type: 'object';
|
|
504
|
+
properties: Record<string, unknown>;
|
|
505
|
+
required?: string[];
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// ============================================================================
|
|
510
|
+
// Memory Verify Gateway Types
|
|
511
|
+
// ============================================================================
|
|
512
|
+
|
|
513
|
+
export type MemoryVerifyCheck = 'imports' | 'security' | 'dependencies' | 'patterns' | 'tests' | 'all';
|
|
514
|
+
|
|
515
|
+
export interface MemoryVerifyInput {
|
|
516
|
+
/** Code to verify */
|
|
517
|
+
code: string;
|
|
518
|
+
/** Target file path (enables import resolution and test checks) */
|
|
519
|
+
file?: string;
|
|
520
|
+
/** Specific checks to run (default: all) */
|
|
521
|
+
checks?: MemoryVerifyCheck[];
|
|
522
|
+
/** Intent/purpose of the code (improves suggestions) */
|
|
523
|
+
intent?: string;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export interface MemoryVerifyResponse {
|
|
527
|
+
/** Overall verdict */
|
|
528
|
+
verdict: 'pass' | 'warning' | 'fail';
|
|
529
|
+
/** Quality score (0-100, higher is better) */
|
|
530
|
+
score: number;
|
|
531
|
+
/** Sources used for verification */
|
|
532
|
+
sources_used: string[];
|
|
533
|
+
/** Human-readable summary */
|
|
534
|
+
summary: string;
|
|
535
|
+
/** Import verification results */
|
|
536
|
+
imports?: {
|
|
537
|
+
valid: boolean;
|
|
538
|
+
issues: Array<{
|
|
539
|
+
import: string;
|
|
540
|
+
type: 'missing_package' | 'missing_file' | 'invalid_export' | 'deprecated' | 'hallucinated';
|
|
541
|
+
message: string;
|
|
542
|
+
suggestion?: string;
|
|
543
|
+
}>;
|
|
544
|
+
warnings: Array<{
|
|
545
|
+
import: string;
|
|
546
|
+
type: 'outdated' | 'security' | 'deprecated_api';
|
|
547
|
+
message: string;
|
|
548
|
+
suggestion?: string;
|
|
549
|
+
}>;
|
|
550
|
+
};
|
|
551
|
+
/** Security scan results */
|
|
552
|
+
security?: {
|
|
553
|
+
safe: boolean;
|
|
554
|
+
score: number;
|
|
555
|
+
issues: Array<{
|
|
556
|
+
type: string;
|
|
557
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
558
|
+
line?: number;
|
|
559
|
+
code?: string;
|
|
560
|
+
message: string;
|
|
561
|
+
cwe?: string;
|
|
562
|
+
suggestion?: string;
|
|
563
|
+
}>;
|
|
564
|
+
};
|
|
565
|
+
/** Dependency check results */
|
|
566
|
+
dependencies?: {
|
|
567
|
+
valid: boolean;
|
|
568
|
+
issues: Array<{
|
|
569
|
+
package: string;
|
|
570
|
+
type: 'not_installed' | 'version_mismatch' | 'deprecated' | 'vulnerable' | 'unlisted';
|
|
571
|
+
message: string;
|
|
572
|
+
suggestion?: string;
|
|
573
|
+
}>;
|
|
574
|
+
};
|
|
575
|
+
/** Pattern validation results */
|
|
576
|
+
patterns?: {
|
|
577
|
+
valid: boolean;
|
|
578
|
+
score: number;
|
|
579
|
+
matched_pattern?: string;
|
|
580
|
+
violations: Array<{
|
|
581
|
+
rule: string;
|
|
582
|
+
message: string;
|
|
583
|
+
severity: string;
|
|
584
|
+
suggestion?: string;
|
|
585
|
+
}>;
|
|
586
|
+
};
|
|
587
|
+
/** Test impact results */
|
|
588
|
+
test_impact?: {
|
|
589
|
+
safe: boolean;
|
|
590
|
+
coverage_percent: number;
|
|
591
|
+
would_fail: Array<{
|
|
592
|
+
test_name: string;
|
|
593
|
+
test_file: string;
|
|
594
|
+
reason: string;
|
|
595
|
+
suggested_fix?: string;
|
|
596
|
+
}>;
|
|
597
|
+
};
|
|
598
|
+
/** Decision conflict warnings */
|
|
599
|
+
conflicts?: {
|
|
600
|
+
has_conflicts: boolean;
|
|
601
|
+
conflicts: Array<{
|
|
602
|
+
decision_id: string;
|
|
603
|
+
decision_title: string;
|
|
604
|
+
warning: string;
|
|
605
|
+
severity: 'low' | 'medium' | 'high';
|
|
606
|
+
}>;
|
|
607
|
+
};
|
|
608
|
+
/** Actionable suggestions to fix issues */
|
|
609
|
+
suggestions: string[];
|
|
610
|
+
}
|