neuronlayer 0.1.0 → 1.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.
Files changed (78) hide show
  1. package/README.md +203 -123
  2. package/dist/index.js +635 -710
  3. package/dist/index.js.map +7 -0
  4. package/package.json +67 -63
  5. package/CONTRIBUTING.md +0 -127
  6. package/esbuild.config.js +0 -26
  7. package/src/cli/commands.ts +0 -382
  8. package/src/core/adr-exporter.ts +0 -253
  9. package/src/core/architecture/architecture-enforcement.ts +0 -228
  10. package/src/core/architecture/duplicate-detector.ts +0 -288
  11. package/src/core/architecture/index.ts +0 -6
  12. package/src/core/architecture/pattern-learner.ts +0 -306
  13. package/src/core/architecture/pattern-library.ts +0 -403
  14. package/src/core/architecture/pattern-validator.ts +0 -324
  15. package/src/core/change-intelligence/bug-correlator.ts +0 -444
  16. package/src/core/change-intelligence/change-intelligence.ts +0 -221
  17. package/src/core/change-intelligence/change-tracker.ts +0 -334
  18. package/src/core/change-intelligence/fix-suggester.ts +0 -340
  19. package/src/core/change-intelligence/index.ts +0 -5
  20. package/src/core/code-verifier.ts +0 -843
  21. package/src/core/confidence/confidence-scorer.ts +0 -251
  22. package/src/core/confidence/conflict-checker.ts +0 -289
  23. package/src/core/confidence/index.ts +0 -5
  24. package/src/core/confidence/source-tracker.ts +0 -263
  25. package/src/core/confidence/warning-detector.ts +0 -241
  26. package/src/core/context-rot/compaction.ts +0 -284
  27. package/src/core/context-rot/context-health.ts +0 -243
  28. package/src/core/context-rot/context-rot-prevention.ts +0 -213
  29. package/src/core/context-rot/critical-context.ts +0 -221
  30. package/src/core/context-rot/drift-detector.ts +0 -255
  31. package/src/core/context-rot/index.ts +0 -7
  32. package/src/core/context.ts +0 -263
  33. package/src/core/decision-extractor.ts +0 -339
  34. package/src/core/decisions.ts +0 -69
  35. package/src/core/deja-vu.ts +0 -421
  36. package/src/core/engine.ts +0 -1455
  37. package/src/core/feature-context.ts +0 -726
  38. package/src/core/ghost-mode.ts +0 -412
  39. package/src/core/learning.ts +0 -485
  40. package/src/core/living-docs/activity-tracker.ts +0 -296
  41. package/src/core/living-docs/architecture-generator.ts +0 -428
  42. package/src/core/living-docs/changelog-generator.ts +0 -348
  43. package/src/core/living-docs/component-generator.ts +0 -230
  44. package/src/core/living-docs/doc-engine.ts +0 -110
  45. package/src/core/living-docs/doc-validator.ts +0 -282
  46. package/src/core/living-docs/index.ts +0 -8
  47. package/src/core/project-manager.ts +0 -297
  48. package/src/core/summarizer.ts +0 -267
  49. package/src/core/test-awareness/change-validator.ts +0 -499
  50. package/src/core/test-awareness/index.ts +0 -5
  51. package/src/index.ts +0 -49
  52. package/src/indexing/ast.ts +0 -563
  53. package/src/indexing/embeddings.ts +0 -85
  54. package/src/indexing/indexer.ts +0 -245
  55. package/src/indexing/watcher.ts +0 -78
  56. package/src/server/gateways/aggregator.ts +0 -374
  57. package/src/server/gateways/index.ts +0 -473
  58. package/src/server/gateways/memory-ghost.ts +0 -343
  59. package/src/server/gateways/memory-query.ts +0 -452
  60. package/src/server/gateways/memory-record.ts +0 -346
  61. package/src/server/gateways/memory-review.ts +0 -410
  62. package/src/server/gateways/memory-status.ts +0 -517
  63. package/src/server/gateways/memory-verify.ts +0 -392
  64. package/src/server/gateways/router.ts +0 -434
  65. package/src/server/gateways/types.ts +0 -610
  66. package/src/server/mcp.ts +0 -154
  67. package/src/server/resources.ts +0 -85
  68. package/src/server/tools.ts +0 -2261
  69. package/src/storage/database.ts +0 -262
  70. package/src/storage/tier1.ts +0 -135
  71. package/src/storage/tier2.ts +0 -764
  72. package/src/storage/tier3.ts +0 -123
  73. package/src/types/documentation.ts +0 -619
  74. package/src/types/index.ts +0 -222
  75. package/src/utils/config.ts +0 -193
  76. package/src/utils/files.ts +0 -117
  77. package/src/utils/time.ts +0 -37
  78. package/src/utils/tokens.ts +0 -52
@@ -1,619 +0,0 @@
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
- }