neuronlayer 0.1.9 → 0.2.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.

Potentially problematic release.


This version of neuronlayer might be problematic. Click here for more details.

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