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,343 +0,0 @@
1
- /**
2
- * Memory Ghost Gateway
3
- *
4
- * The "Super Intelligent Brain" - provides proactive intelligence about current work.
5
- *
6
- * Modes:
7
- * - full: Complete ghost data (ghost insight + déjà vu + resurrection)
8
- * - conflicts: Check for conflicts with past decisions
9
- * - dejavu: Find similar past problems
10
- * - resurrect: Get context from last session
11
- */
12
-
13
- import type { MemoryLayerEngine, GhostInsight, ConflictWarning, DejaVuMatch, ResurrectedContext } from '../../core/engine.js';
14
-
15
- export type MemoryGhostMode = 'full' | 'conflicts' | 'dejavu' | 'resurrect';
16
-
17
- export interface MemoryGhostInput {
18
- /** What to check (default: full) */
19
- mode?: MemoryGhostMode;
20
- /** Code to check for conflicts/déjà vu */
21
- code?: string;
22
- /** Current file being worked on */
23
- file?: string;
24
- /** Query for déjà vu search */
25
- query?: string;
26
- /** Feature name for resurrection */
27
- feature_name?: string;
28
- /** Maximum results for déjà vu */
29
- max_results?: number;
30
- }
31
-
32
- export interface MemoryGhostResponse {
33
- /** Mode that was executed */
34
- mode: MemoryGhostMode;
35
- /** Sources used to generate response */
36
- sources_used: string[];
37
- /** Ghost insight - current work awareness */
38
- ghost?: {
39
- active_files: string[];
40
- recent_decisions: Array<{
41
- id: string;
42
- title: string;
43
- description: string;
44
- }>;
45
- suggestions: string[];
46
- };
47
- /** Conflict warnings */
48
- conflicts?: {
49
- has_conflicts: boolean;
50
- warnings: Array<{
51
- decision_id: string;
52
- decision_title: string;
53
- warning: string;
54
- severity: 'low' | 'medium' | 'high';
55
- matched_terms: string[];
56
- }>;
57
- };
58
- /** Déjà vu matches - similar past problems */
59
- deja_vu?: {
60
- has_matches: boolean;
61
- matches: Array<{
62
- type: 'query' | 'solution' | 'fix' | 'pattern';
63
- similarity: number;
64
- when: string;
65
- file: string;
66
- snippet: string;
67
- message: string;
68
- context?: string;
69
- }>;
70
- };
71
- /** Context resurrection - session continuity */
72
- resurrection?: {
73
- active_files: string[];
74
- last_queries: string[];
75
- last_edited_file: string | null;
76
- last_edit_time: string | null;
77
- possible_blocker: string | null;
78
- suggested_actions: string[];
79
- summary: string;
80
- time_since_last_active: string;
81
- };
82
- /** Resurrectable contexts */
83
- resurrectable_contexts?: Array<{
84
- id: string;
85
- name: string;
86
- last_active: string;
87
- summary: string;
88
- }>;
89
- /** Stats */
90
- stats?: {
91
- deja_vu: {
92
- total_queries: number;
93
- useful_queries: number;
94
- avg_usefulness: number;
95
- };
96
- };
97
- }
98
-
99
- /**
100
- * Handle a memory_ghost gateway call
101
- */
102
- export async function handleMemoryGhost(
103
- engine: MemoryLayerEngine,
104
- input: MemoryGhostInput
105
- ): Promise<MemoryGhostResponse> {
106
- const mode = input.mode || 'full';
107
- const sourcesUsed: string[] = [];
108
-
109
- switch (mode) {
110
- case 'conflicts':
111
- return handleConflictsMode(engine, input, sourcesUsed);
112
-
113
- case 'dejavu':
114
- return handleDejaVuMode(engine, input, sourcesUsed);
115
-
116
- case 'resurrect':
117
- return handleResurrectMode(engine, input, sourcesUsed);
118
-
119
- case 'full':
120
- default:
121
- return handleFullMode(engine, input, sourcesUsed);
122
- }
123
- }
124
-
125
- /**
126
- * Full ghost mode - everything
127
- */
128
- async function handleFullMode(
129
- engine: MemoryLayerEngine,
130
- input: MemoryGhostInput,
131
- sourcesUsed: string[]
132
- ): Promise<MemoryGhostResponse> {
133
- sourcesUsed.push('ghost_insight', 'deja_vu', 'resurrect_context');
134
-
135
- // Notify file access if provided
136
- if (input.file) {
137
- await engine.notifyFileAccess(input.file);
138
- }
139
-
140
- // Get full ghost data
141
- const fullData = await engine.getFullGhostData('full', {
142
- code: input.code,
143
- file: input.file,
144
- query: input.query,
145
- });
146
-
147
- const response: MemoryGhostResponse = {
148
- mode: 'full',
149
- sources_used: sourcesUsed,
150
- };
151
-
152
- // Add ghost insight
153
- if (fullData.ghost) {
154
- response.ghost = formatGhostInsight(fullData.ghost);
155
- }
156
-
157
- // Add conflicts
158
- if (fullData.conflicts && fullData.conflicts.length > 0) {
159
- response.conflicts = formatConflicts(fullData.conflicts);
160
- }
161
-
162
- // Add déjà vu
163
- if (fullData.dejaVu && fullData.dejaVu.length > 0) {
164
- response.deja_vu = formatDejaVu(fullData.dejaVu);
165
- }
166
-
167
- // Add resurrection
168
- if (fullData.resurrection) {
169
- response.resurrection = formatResurrection(fullData.resurrection);
170
- }
171
-
172
- // Add resurrectable contexts
173
- const contexts = engine.getResurrectableContexts();
174
- if (contexts.length > 0) {
175
- response.resurrectable_contexts = contexts.map(c => ({
176
- id: c.id,
177
- name: c.name,
178
- last_active: c.lastActive.toISOString(),
179
- summary: c.summary,
180
- }));
181
- }
182
-
183
- // Add stats
184
- response.stats = {
185
- deja_vu: engine.getDejaVuStats(),
186
- };
187
-
188
- return response;
189
- }
190
-
191
- /**
192
- * Conflicts mode - check for decision conflicts
193
- */
194
- async function handleConflictsMode(
195
- engine: MemoryLayerEngine,
196
- input: MemoryGhostInput,
197
- sourcesUsed: string[]
198
- ): Promise<MemoryGhostResponse> {
199
- sourcesUsed.push('check_ghost_conflicts');
200
-
201
- if (!input.code) {
202
- return {
203
- mode: 'conflicts',
204
- sources_used: sourcesUsed,
205
- conflicts: {
206
- has_conflicts: false,
207
- warnings: [],
208
- },
209
- };
210
- }
211
-
212
- // Notify file access if provided
213
- if (input.file) {
214
- await engine.notifyFileAccess(input.file);
215
- }
216
-
217
- const warnings = engine.checkGhostConflicts(input.code, input.file);
218
-
219
- return {
220
- mode: 'conflicts',
221
- sources_used: sourcesUsed,
222
- conflicts: formatConflicts(warnings),
223
- };
224
- }
225
-
226
- /**
227
- * Déjà vu mode - find similar past problems
228
- */
229
- async function handleDejaVuMode(
230
- engine: MemoryLayerEngine,
231
- input: MemoryGhostInput,
232
- sourcesUsed: string[]
233
- ): Promise<MemoryGhostResponse> {
234
- sourcesUsed.push('find_deja_vu');
235
-
236
- const searchText = input.query || input.code || '';
237
-
238
- if (!searchText) {
239
- return {
240
- mode: 'dejavu',
241
- sources_used: sourcesUsed,
242
- deja_vu: {
243
- has_matches: false,
244
- matches: [],
245
- },
246
- };
247
- }
248
-
249
- const matches = await engine.findDejaVu(searchText, input.max_results || 5);
250
-
251
- return {
252
- mode: 'dejavu',
253
- sources_used: sourcesUsed,
254
- deja_vu: formatDejaVu(matches),
255
- stats: {
256
- deja_vu: engine.getDejaVuStats(),
257
- },
258
- };
259
- }
260
-
261
- /**
262
- * Resurrect mode - get context from last session
263
- */
264
- async function handleResurrectMode(
265
- engine: MemoryLayerEngine,
266
- input: MemoryGhostInput,
267
- sourcesUsed: string[]
268
- ): Promise<MemoryGhostResponse> {
269
- sourcesUsed.push('resurrect_context');
270
-
271
- const resurrection = engine.resurrectContext({
272
- featureName: input.feature_name,
273
- });
274
-
275
- const contexts = engine.getResurrectableContexts();
276
-
277
- return {
278
- mode: 'resurrect',
279
- sources_used: sourcesUsed,
280
- resurrection: formatResurrection(resurrection),
281
- resurrectable_contexts: contexts.map(c => ({
282
- id: c.id,
283
- name: c.name,
284
- last_active: c.lastActive.toISOString(),
285
- summary: c.summary,
286
- })),
287
- };
288
- }
289
-
290
- // ========== Formatters ==========
291
-
292
- function formatGhostInsight(insight: GhostInsight): MemoryGhostResponse['ghost'] {
293
- return {
294
- active_files: insight.activeFiles,
295
- recent_decisions: insight.recentDecisions.map(d => ({
296
- id: d.id,
297
- title: d.title,
298
- description: d.description.slice(0, 200),
299
- })),
300
- suggestions: insight.suggestions,
301
- };
302
- }
303
-
304
- function formatConflicts(warnings: ConflictWarning[]): NonNullable<MemoryGhostResponse['conflicts']> {
305
- return {
306
- has_conflicts: warnings.length > 0,
307
- warnings: warnings.map(w => ({
308
- decision_id: w.decision.id,
309
- decision_title: w.decision.title,
310
- warning: w.warning,
311
- severity: w.severity,
312
- matched_terms: w.matchedTerms,
313
- })),
314
- };
315
- }
316
-
317
- function formatDejaVu(matches: DejaVuMatch[]): NonNullable<MemoryGhostResponse['deja_vu']> {
318
- return {
319
- has_matches: matches.length > 0,
320
- matches: matches.map(m => ({
321
- type: m.type,
322
- similarity: m.similarity,
323
- when: m.when.toISOString(),
324
- file: m.file,
325
- snippet: m.snippet,
326
- message: m.message,
327
- context: m.context,
328
- })),
329
- };
330
- }
331
-
332
- function formatResurrection(resurrection: ResurrectedContext): NonNullable<MemoryGhostResponse['resurrection']> {
333
- return {
334
- active_files: resurrection.activeFiles,
335
- last_queries: resurrection.lastQueries,
336
- last_edited_file: resurrection.lastEditedFile,
337
- last_edit_time: resurrection.lastEditTime?.toISOString() || null,
338
- possible_blocker: resurrection.possibleBlocker,
339
- suggested_actions: resurrection.suggestedActions,
340
- summary: resurrection.summary,
341
- time_since_last_active: resurrection.timeSinceLastActive,
342
- };
343
- }