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,619 @@
|
|
|
1
|
+
// Living Documentation Types
|
|
2
|
+
|
|
3
|
+
// Architecture Documentation Types
|
|
4
|
+
export interface ArchitectureDoc {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
diagram: string; // ASCII art diagram
|
|
8
|
+
layers: ArchitectureLayer[];
|
|
9
|
+
dataFlow: DataFlowStep[];
|
|
10
|
+
keyComponents: ComponentReference[];
|
|
11
|
+
dependencies: DependencyInfo[];
|
|
12
|
+
generatedAt: Date;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ArchitectureLayer {
|
|
16
|
+
name: string; // e.g., "API Layer", "Business Logic"
|
|
17
|
+
directory: string; // e.g., "src/server"
|
|
18
|
+
files: string[];
|
|
19
|
+
purpose: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DataFlowStep {
|
|
23
|
+
from: string;
|
|
24
|
+
to: string;
|
|
25
|
+
description: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ComponentReference {
|
|
29
|
+
name: string;
|
|
30
|
+
file: string;
|
|
31
|
+
purpose: string;
|
|
32
|
+
exports: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DependencyInfo {
|
|
36
|
+
name: string;
|
|
37
|
+
version?: string;
|
|
38
|
+
type: 'runtime' | 'dev';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Component Documentation Types
|
|
42
|
+
export interface ComponentDoc {
|
|
43
|
+
file: string;
|
|
44
|
+
name: string;
|
|
45
|
+
purpose: string;
|
|
46
|
+
created?: Date;
|
|
47
|
+
lastModified: Date;
|
|
48
|
+
|
|
49
|
+
publicInterface: SymbolDoc[];
|
|
50
|
+
dependencies: DependencyDoc[];
|
|
51
|
+
dependents: DependentDoc[];
|
|
52
|
+
|
|
53
|
+
changeHistory: ChangeHistoryEntry[];
|
|
54
|
+
contributors: string[];
|
|
55
|
+
|
|
56
|
+
complexity: 'low' | 'medium' | 'high';
|
|
57
|
+
documentationScore: number; // 0-100%
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SymbolDoc {
|
|
61
|
+
name: string;
|
|
62
|
+
kind: string;
|
|
63
|
+
signature?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
lineStart: number;
|
|
66
|
+
lineEnd: number;
|
|
67
|
+
exported: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface DependencyDoc {
|
|
71
|
+
file: string;
|
|
72
|
+
symbols: string[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface DependentDoc {
|
|
76
|
+
file: string;
|
|
77
|
+
symbols: string[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ChangeHistoryEntry {
|
|
81
|
+
date: Date;
|
|
82
|
+
change: string;
|
|
83
|
+
author: string;
|
|
84
|
+
commit: string;
|
|
85
|
+
linesChanged: { added: number; removed: number };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Changelog Types
|
|
89
|
+
export interface DailyChangelog {
|
|
90
|
+
date: Date;
|
|
91
|
+
summary: string;
|
|
92
|
+
features: ChangeEntry[];
|
|
93
|
+
fixes: ChangeEntry[];
|
|
94
|
+
refactors: ChangeEntry[];
|
|
95
|
+
filesModified: FileChangeInfo[];
|
|
96
|
+
decisions: string[];
|
|
97
|
+
metrics: ChangeMetrics;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ChangeEntry {
|
|
101
|
+
type: 'feature' | 'fix' | 'refactor' | 'docs' | 'test' | 'chore';
|
|
102
|
+
description: string;
|
|
103
|
+
files: string[];
|
|
104
|
+
commit?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface FileChangeInfo {
|
|
108
|
+
file: string;
|
|
109
|
+
added: number;
|
|
110
|
+
removed: number;
|
|
111
|
+
type: 'new' | 'modified' | 'deleted';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ChangeMetrics {
|
|
115
|
+
commits: number;
|
|
116
|
+
filesChanged: number;
|
|
117
|
+
linesAdded: number;
|
|
118
|
+
linesRemoved: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ChangelogOptions {
|
|
122
|
+
since?: Date | string;
|
|
123
|
+
until?: Date;
|
|
124
|
+
groupBy?: 'day' | 'week' | 'feature';
|
|
125
|
+
includeDecisions?: boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Activity Query Types
|
|
129
|
+
export interface ActivityResult {
|
|
130
|
+
timeRange: { since: Date; until: Date };
|
|
131
|
+
scope: string;
|
|
132
|
+
summary: string;
|
|
133
|
+
changes: ActivityChange[];
|
|
134
|
+
decisions: ActivityDecision[];
|
|
135
|
+
filesAffected: string[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ActivityChange {
|
|
139
|
+
timestamp: Date;
|
|
140
|
+
type: 'commit' | 'file_change' | 'decision';
|
|
141
|
+
description: string;
|
|
142
|
+
details: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface ActivityDecision {
|
|
146
|
+
id: string;
|
|
147
|
+
title: string;
|
|
148
|
+
date: Date;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Validation Types
|
|
152
|
+
export interface ValidationResult {
|
|
153
|
+
isValid: boolean;
|
|
154
|
+
outdatedDocs: OutdatedDoc[];
|
|
155
|
+
undocumentedCode: UndocumentedItem[];
|
|
156
|
+
suggestions: DocSuggestion[];
|
|
157
|
+
score: number; // 0-100%
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface OutdatedDoc {
|
|
161
|
+
file: string;
|
|
162
|
+
reason: string;
|
|
163
|
+
lastDocUpdate: Date;
|
|
164
|
+
lastCodeChange: Date;
|
|
165
|
+
severity: 'low' | 'medium' | 'high';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface UndocumentedItem {
|
|
169
|
+
file: string;
|
|
170
|
+
symbol?: string;
|
|
171
|
+
type: 'file' | 'function' | 'class' | 'interface';
|
|
172
|
+
importance: 'low' | 'medium' | 'high';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface DocSuggestion {
|
|
176
|
+
file: string;
|
|
177
|
+
suggestion: string;
|
|
178
|
+
priority: 'low' | 'medium' | 'high';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ============================================
|
|
182
|
+
// Context Rot Prevention Types
|
|
183
|
+
// ============================================
|
|
184
|
+
|
|
185
|
+
export interface ContextHealth {
|
|
186
|
+
// Metrics
|
|
187
|
+
tokensUsed: number;
|
|
188
|
+
tokensLimit: number;
|
|
189
|
+
utilizationPercent: number;
|
|
190
|
+
|
|
191
|
+
// Health Indicators
|
|
192
|
+
health: 'good' | 'warning' | 'critical';
|
|
193
|
+
relevanceScore: number; // 0-1, how relevant is old context
|
|
194
|
+
driftScore: number; // 0-1, how much has AI drifted
|
|
195
|
+
criticalContextCount: number; // Number of critical items
|
|
196
|
+
|
|
197
|
+
// Detection
|
|
198
|
+
driftDetected: boolean;
|
|
199
|
+
compactionNeeded: boolean;
|
|
200
|
+
|
|
201
|
+
// Suggestions
|
|
202
|
+
suggestions: string[];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface CompactionSuggestion {
|
|
206
|
+
// What to keep
|
|
207
|
+
critical: ContextChunk[];
|
|
208
|
+
|
|
209
|
+
// What to summarize
|
|
210
|
+
summarizable: ContextChunk[];
|
|
211
|
+
|
|
212
|
+
// What to remove
|
|
213
|
+
removable: ContextChunk[];
|
|
214
|
+
|
|
215
|
+
// Estimated savings
|
|
216
|
+
tokensSaved: number;
|
|
217
|
+
newUtilization: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ContextChunk {
|
|
221
|
+
id: string;
|
|
222
|
+
content: string;
|
|
223
|
+
tokens: number;
|
|
224
|
+
timestamp: Date;
|
|
225
|
+
relevanceScore: number;
|
|
226
|
+
isCritical: boolean;
|
|
227
|
+
type: 'message' | 'decision' | 'requirement' | 'instruction' | 'code';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface CompactionResult {
|
|
231
|
+
success: boolean;
|
|
232
|
+
strategy: 'summarize' | 'selective' | 'aggressive';
|
|
233
|
+
tokensBefore: number;
|
|
234
|
+
tokensAfter: number;
|
|
235
|
+
tokensSaved: number;
|
|
236
|
+
preservedCritical: number;
|
|
237
|
+
summarizedChunks: number;
|
|
238
|
+
removedChunks: number;
|
|
239
|
+
summaries: string[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface CriticalContext {
|
|
243
|
+
id: string;
|
|
244
|
+
type: 'decision' | 'requirement' | 'instruction' | 'custom';
|
|
245
|
+
content: string;
|
|
246
|
+
reason?: string;
|
|
247
|
+
createdAt: Date;
|
|
248
|
+
source?: string; // Where this came from (file, message, etc.)
|
|
249
|
+
neverCompress: boolean;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface DriftResult {
|
|
253
|
+
driftScore: number; // 0-1, higher = more drift
|
|
254
|
+
driftDetected: boolean;
|
|
255
|
+
missingRequirements: string[];
|
|
256
|
+
contradictions: Contradiction[];
|
|
257
|
+
suggestedReminders: string[];
|
|
258
|
+
topicShift: number; // 0-1, how much topic has shifted
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface Contradiction {
|
|
262
|
+
earlier: string;
|
|
263
|
+
later: string;
|
|
264
|
+
severity: 'low' | 'medium' | 'high';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface CompactionOptions {
|
|
268
|
+
strategy: 'summarize' | 'selective' | 'aggressive';
|
|
269
|
+
preserveRecent?: number; // Number of recent messages to preserve
|
|
270
|
+
targetUtilization?: number; // Target % (e.g., 50%)
|
|
271
|
+
preserveCritical?: boolean; // Always preserve critical (default: true)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ============================================
|
|
275
|
+
// Confidence Scoring Types
|
|
276
|
+
// ============================================
|
|
277
|
+
|
|
278
|
+
export type ConfidenceLevel = 'high' | 'medium' | 'low' | 'guessing';
|
|
279
|
+
|
|
280
|
+
export interface ConfidenceResult {
|
|
281
|
+
confidence: ConfidenceLevel;
|
|
282
|
+
score: number; // 0-100
|
|
283
|
+
reasoning: string;
|
|
284
|
+
sources: ConfidenceSources;
|
|
285
|
+
warnings: ConfidenceWarning[];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface ConfidenceSources {
|
|
289
|
+
codebase: CodebaseMatch[];
|
|
290
|
+
decisions: DecisionMatch[];
|
|
291
|
+
patterns: PatternMatch[];
|
|
292
|
+
usedGeneralKnowledge: boolean;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface CodebaseMatch {
|
|
296
|
+
file: string;
|
|
297
|
+
line?: number;
|
|
298
|
+
function?: string;
|
|
299
|
+
similarity: number; // 0-100
|
|
300
|
+
snippet?: string;
|
|
301
|
+
lastModified?: Date;
|
|
302
|
+
usageCount?: number;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface DecisionMatch {
|
|
306
|
+
id: string;
|
|
307
|
+
title: string;
|
|
308
|
+
date: Date;
|
|
309
|
+
relevance: number; // 0-100
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface PatternMatch {
|
|
313
|
+
pattern: string;
|
|
314
|
+
confidence: number; // 0-100
|
|
315
|
+
examples: string[];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export type WarningType =
|
|
319
|
+
| 'no_similar_pattern'
|
|
320
|
+
| 'conflicts_with_decision'
|
|
321
|
+
| 'untested_approach'
|
|
322
|
+
| 'high_complexity'
|
|
323
|
+
| 'potential_security_issue'
|
|
324
|
+
| 'deprecated_approach';
|
|
325
|
+
|
|
326
|
+
export interface ConfidenceWarning {
|
|
327
|
+
type: WarningType;
|
|
328
|
+
message: string;
|
|
329
|
+
severity: 'info' | 'warning' | 'critical';
|
|
330
|
+
suggestion?: string;
|
|
331
|
+
relatedDecision?: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export interface SourceTracking {
|
|
335
|
+
codebaseMatches: Array<{
|
|
336
|
+
file: string;
|
|
337
|
+
function?: string;
|
|
338
|
+
similarity: number;
|
|
339
|
+
lastModified?: Date;
|
|
340
|
+
usageCount: number;
|
|
341
|
+
}>;
|
|
342
|
+
decisionMatches: Array<{
|
|
343
|
+
id: string;
|
|
344
|
+
title: string;
|
|
345
|
+
date: Date;
|
|
346
|
+
relevance: number;
|
|
347
|
+
}>;
|
|
348
|
+
patternMatches: Array<{
|
|
349
|
+
pattern: string;
|
|
350
|
+
confidence: number;
|
|
351
|
+
examples: string[];
|
|
352
|
+
}>;
|
|
353
|
+
generalKnowledge: {
|
|
354
|
+
used: boolean;
|
|
355
|
+
topics: string[];
|
|
356
|
+
reliability: 'high' | 'medium' | 'low';
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface ConflictResult {
|
|
361
|
+
hasConflicts: boolean;
|
|
362
|
+
conflicts: Array<{
|
|
363
|
+
decisionId: string;
|
|
364
|
+
decisionTitle: string;
|
|
365
|
+
decisionDate: Date;
|
|
366
|
+
conflictDescription: string;
|
|
367
|
+
severity: 'low' | 'medium' | 'high';
|
|
368
|
+
}>;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// ============================================
|
|
372
|
+
// Change Intelligence Types
|
|
373
|
+
// ============================================
|
|
374
|
+
|
|
375
|
+
export interface Change {
|
|
376
|
+
id: string;
|
|
377
|
+
file: string;
|
|
378
|
+
diff: string;
|
|
379
|
+
timestamp: Date;
|
|
380
|
+
author: string;
|
|
381
|
+
commitHash: string;
|
|
382
|
+
commitMessage: string;
|
|
383
|
+
linesAdded: number;
|
|
384
|
+
linesRemoved: number;
|
|
385
|
+
type: 'add' | 'modify' | 'delete' | 'rename';
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface ChangeQueryResult {
|
|
389
|
+
period: string;
|
|
390
|
+
since: Date;
|
|
391
|
+
until: Date;
|
|
392
|
+
changes: Change[];
|
|
393
|
+
totalFiles: number;
|
|
394
|
+
totalLinesAdded: number;
|
|
395
|
+
totalLinesRemoved: number;
|
|
396
|
+
byAuthor: Record<string, number>;
|
|
397
|
+
byType: Record<string, number>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface Bug {
|
|
401
|
+
id: string;
|
|
402
|
+
error: string;
|
|
403
|
+
stackTrace?: string;
|
|
404
|
+
file?: string;
|
|
405
|
+
line?: number;
|
|
406
|
+
timestamp: Date;
|
|
407
|
+
status: 'open' | 'fixed';
|
|
408
|
+
relatedChanges: string[];
|
|
409
|
+
fixedBy?: string;
|
|
410
|
+
fixedAt?: Date;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export interface PastBug {
|
|
414
|
+
id: string;
|
|
415
|
+
error: string;
|
|
416
|
+
cause?: string;
|
|
417
|
+
fix?: string;
|
|
418
|
+
fixDiff?: string;
|
|
419
|
+
file?: string;
|
|
420
|
+
date: Date;
|
|
421
|
+
similarity: number;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export interface Diagnosis {
|
|
425
|
+
likelyCause: Change | null;
|
|
426
|
+
confidence: number;
|
|
427
|
+
relatedChanges: Change[];
|
|
428
|
+
pastSimilarBugs: PastBug[];
|
|
429
|
+
suggestedFix: string | null;
|
|
430
|
+
reasoning: string;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export interface FixSuggestion {
|
|
434
|
+
confidence: number;
|
|
435
|
+
fix: string;
|
|
436
|
+
reason: string;
|
|
437
|
+
diff?: string;
|
|
438
|
+
pastFix?: {
|
|
439
|
+
date: Date;
|
|
440
|
+
file: string;
|
|
441
|
+
bugId?: string;
|
|
442
|
+
};
|
|
443
|
+
source: 'history' | 'pattern' | 'general';
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export interface ChangeQueryOptions {
|
|
447
|
+
since?: string | Date;
|
|
448
|
+
until?: Date;
|
|
449
|
+
file?: string;
|
|
450
|
+
author?: string;
|
|
451
|
+
type?: 'add' | 'modify' | 'delete' | 'rename';
|
|
452
|
+
limit?: number;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// ============================================
|
|
456
|
+
// Architecture Enforcement Types
|
|
457
|
+
// ============================================
|
|
458
|
+
|
|
459
|
+
export interface Pattern {
|
|
460
|
+
id: string;
|
|
461
|
+
name: string;
|
|
462
|
+
category: PatternCategory;
|
|
463
|
+
description: string;
|
|
464
|
+
examples: CodeExample[];
|
|
465
|
+
antiPatterns: CodeExample[];
|
|
466
|
+
rules: PatternRule[];
|
|
467
|
+
createdAt: Date;
|
|
468
|
+
usageCount: number;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export type PatternCategory =
|
|
472
|
+
| 'error_handling'
|
|
473
|
+
| 'api_call'
|
|
474
|
+
| 'component'
|
|
475
|
+
| 'state_management'
|
|
476
|
+
| 'data_fetching'
|
|
477
|
+
| 'authentication'
|
|
478
|
+
| 'validation'
|
|
479
|
+
| 'logging'
|
|
480
|
+
| 'custom';
|
|
481
|
+
|
|
482
|
+
export interface CodeExample {
|
|
483
|
+
code: string;
|
|
484
|
+
explanation: string;
|
|
485
|
+
file?: string;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export interface PatternRule {
|
|
489
|
+
rule: string;
|
|
490
|
+
severity: 'info' | 'warning' | 'critical';
|
|
491
|
+
check?: string; // Regex or keyword to check
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export interface PatternValidationResult {
|
|
495
|
+
valid: boolean;
|
|
496
|
+
score: number; // 0-100
|
|
497
|
+
matchedPattern?: string;
|
|
498
|
+
violations: PatternViolation[];
|
|
499
|
+
suggestions: PatternSuggestion[];
|
|
500
|
+
existingAlternatives: ExistingFunction[];
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export interface PatternViolation {
|
|
504
|
+
rule: string;
|
|
505
|
+
message: string;
|
|
506
|
+
severity: 'info' | 'warning' | 'critical';
|
|
507
|
+
line?: number;
|
|
508
|
+
suggestion?: string;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export interface PatternSuggestion {
|
|
512
|
+
description: string;
|
|
513
|
+
code?: string;
|
|
514
|
+
priority: 'low' | 'medium' | 'high';
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export interface ExistingFunction {
|
|
518
|
+
name: string;
|
|
519
|
+
file: string;
|
|
520
|
+
line: number;
|
|
521
|
+
signature: string;
|
|
522
|
+
description?: string;
|
|
523
|
+
usageCount: number;
|
|
524
|
+
purpose: string;
|
|
525
|
+
similarity: number;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export interface FunctionIndex {
|
|
529
|
+
name: string;
|
|
530
|
+
file: string;
|
|
531
|
+
line: number;
|
|
532
|
+
signature: string;
|
|
533
|
+
exported: boolean;
|
|
534
|
+
usageCount: number;
|
|
535
|
+
parameters: string[];
|
|
536
|
+
returnType?: string;
|
|
537
|
+
docstring?: string;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// ============================================
|
|
541
|
+
// Test-Aware Suggestions Types (Phase 11)
|
|
542
|
+
// ============================================
|
|
543
|
+
|
|
544
|
+
export type TestFramework = 'jest' | 'mocha' | 'vitest' | 'pytest' | 'unittest' | 'go' | 'unknown';
|
|
545
|
+
|
|
546
|
+
export interface TestInfo {
|
|
547
|
+
id: string;
|
|
548
|
+
file: string;
|
|
549
|
+
name: string;
|
|
550
|
+
describes: string; // Parent describe block
|
|
551
|
+
coversFiles: string[]; // Files this test covers (via imports)
|
|
552
|
+
coversFunctions: string[]; // Functions this test calls
|
|
553
|
+
assertions: Assertion[];
|
|
554
|
+
lastRun?: Date;
|
|
555
|
+
lastStatus?: 'pass' | 'fail' | 'skip';
|
|
556
|
+
lineStart: number;
|
|
557
|
+
lineEnd: number;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export interface Assertion {
|
|
561
|
+
type: 'equality' | 'truthiness' | 'error' | 'mock' | 'snapshot' | 'other';
|
|
562
|
+
subject: string; // What's being tested
|
|
563
|
+
expected?: string; // Expected value (if extractable)
|
|
564
|
+
code: string; // Actual assertion code
|
|
565
|
+
line: number;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export interface TestIndex {
|
|
569
|
+
framework: TestFramework;
|
|
570
|
+
tests: TestInfo[];
|
|
571
|
+
fileToCoverage: Map<string, string[]>; // file -> test IDs
|
|
572
|
+
functionToCoverage: Map<string, string[]>; // function -> test IDs
|
|
573
|
+
lastIndexed: Date;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export interface ChangeAnalysis {
|
|
577
|
+
file: string;
|
|
578
|
+
functions: string[];
|
|
579
|
+
type: 'refactor' | 'add' | 'delete' | 'modify';
|
|
580
|
+
affectedTests: TestInfo[];
|
|
581
|
+
testCoverage: number; // % of change covered by tests
|
|
582
|
+
risk: 'low' | 'medium' | 'high';
|
|
583
|
+
reasoning: string;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export interface TestValidationResult {
|
|
587
|
+
safe: boolean;
|
|
588
|
+
relatedTests: TestInfo[];
|
|
589
|
+
wouldPass: TestInfo[];
|
|
590
|
+
wouldFail: PredictedFailure[];
|
|
591
|
+
uncertain: TestInfo[];
|
|
592
|
+
suggestedTestUpdates: TestUpdate[];
|
|
593
|
+
coveragePercent: number;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export interface PredictedFailure {
|
|
597
|
+
test: TestInfo;
|
|
598
|
+
assertion?: Assertion;
|
|
599
|
+
reason: string;
|
|
600
|
+
confidence: number; // 0-100
|
|
601
|
+
suggestedFix?: string;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export interface TestUpdate {
|
|
605
|
+
file: string;
|
|
606
|
+
testName: string;
|
|
607
|
+
line: number;
|
|
608
|
+
before: string;
|
|
609
|
+
after: string;
|
|
610
|
+
reason: string;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export interface TestCoverage {
|
|
614
|
+
file: string;
|
|
615
|
+
totalTests: number;
|
|
616
|
+
coveredFunctions: string[];
|
|
617
|
+
uncoveredFunctions: string[];
|
|
618
|
+
coveragePercent: number;
|
|
619
|
+
}
|