neuronlayer 0.1.8 → 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.
Files changed (80) hide show
  1. package/README.md +95 -269
  2. package/dist/index.js +478 -126
  3. package/dist/index.js.map +7 -0
  4. package/package.json +7 -2
  5. package/esbuild.config.js +0 -26
  6. package/src/cli/commands.ts +0 -518
  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 -49
  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/mcp.ts +0 -154
  69. package/src/server/resources.ts +0 -85
  70. package/src/server/tools.ts +0 -2460
  71. package/src/storage/database.ts +0 -271
  72. package/src/storage/tier1.ts +0 -135
  73. package/src/storage/tier2.ts +0 -972
  74. package/src/storage/tier3.ts +0 -123
  75. package/src/types/documentation.ts +0 -619
  76. package/src/types/index.ts +0 -222
  77. package/src/utils/config.ts +0 -193
  78. package/src/utils/files.ts +0 -117
  79. package/src/utils/time.ts +0 -37
  80. package/src/utils/tokens.ts +0 -52
package/README.md CHANGED
@@ -1,296 +1,163 @@
1
1
  # NeuronLayer
2
2
 
3
- **Code intelligence layer disguised as memory.**
3
+ **Persistent codebase understanding for AI assistants.**
4
4
 
5
- NeuronLayer isn't another memory tool. It's a code-intelligence layer that gives AI assistants deep understanding of your codebase - understanding that persists across sessions.
5
+ NeuronLayer is an MCP server that indexes your codebase and gives AI assistants like Claude the ability to understand your project's structure, dependencies, and history across sessions.
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/neuronlayer.svg)](https://www.npmjs.com/package/neuronlayer)
8
+ [![npm downloads](https://img.shields.io/npm/dw/neuronlayer.svg)](https://www.npmjs.com/package/neuronlayer)
8
9
  [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
9
10
  [![Node.js](https://img.shields.io/badge/Node.js-18+-339933.svg)](https://nodejs.org/)
10
11
  [![MCP](https://img.shields.io/badge/MCP-Compatible-blue.svg)](https://modelcontextprotocol.io/)
11
12
 
12
13
  ---
13
14
 
14
- ## What Makes NeuronLayer Different
15
+ ## What NeuronLayer Does
15
16
 
16
- Most "memory tools" for AI are just note-taking with embeddings. NeuronLayer does something fundamentally different:
17
+ - **Indexes your code** - Extracts functions, classes, imports, and exports using true Tree-sitter AST parsing
18
+ - **Builds a dependency graph** - Tracks what files import what, transitively
19
+ - **Analyzes impact** - Shows which files are affected when you change something
20
+ - **Detects circular dependencies** - Finds import cycles in your codebase
21
+ - **Indexes tests** - Identifies test files and what source files they cover
22
+ - **Records decisions** - Stores architectural decisions that persist across sessions
23
+ - **Semantic search** - Find code by meaning using local embeddings
17
24
 
18
- | Memory Tools | NeuronLayer |
19
- |--------------|-------------|
20
- | Store text, retrieve by similarity | **Parse code structure** (regex-based extraction) |
21
- | Keyword/embedding search | **Understand dependencies** (what imports what) |
22
- | Tag-based organization | **Transitive impact analysis** (change X → affects Y, Z) |
23
- | Session notes | **Circular dependency detection** |
24
- | | **Test indexing** (identifies test files and what they test) |
25
- | | **Conflict detection** with recorded decisions |
26
-
27
- **The AI thinks it's using memory tools. It's actually getting code intelligence.**
28
-
29
- ---
30
-
31
- ## The Problem
32
-
33
- AI coding assistants are powerful but blind:
34
-
35
- - **No structural understanding** - AI doesn't know your dependency graph
36
- - **No impact awareness** - "changing this file breaks 12 others"
37
- - **No test knowledge** - AI suggestions break tests it doesn't know exist
38
- - **No persistent decisions** - architectural choices forgotten each session
39
-
40
- ## The Solution
41
-
42
- NeuronLayer gives AI assistants **persistent code intelligence**:
43
-
44
- - **Dependency graph** - knows what imports what, transitively
45
- - **Impact analysis** - "changing auth.ts affects 8 files and 4 tests"
46
- - **Test awareness** - indexes tests, predicts failures, suggests updates
47
- - **Decision memory** - architectural decisions survive across sessions
48
- - **Circular dependency detection** - finds import cycles automatically
49
-
50
- ---
51
-
52
- ## Compatibility
53
-
54
- | Tool | Supported | Auto-Configure |
55
- |------|-----------|----------------|
56
- | Claude Desktop | Yes | `neuronlayer init` |
57
- | Claude Code (CLI) | Yes | `neuronlayer init` |
58
- | Cursor | Yes | Via MCP support |
59
- | OpenCode | Yes | `neuronlayer init` |
60
- | VS Code + Continue | Yes | Manual config |
61
- | Any MCP Client | Yes | Manual config |
25
+ All processing happens locally on your machine. No cloud services, no telemetry.
62
26
 
63
27
  ---
64
28
 
65
29
  ## Quick Start
66
30
 
67
- ### Installation
68
-
69
31
  ```bash
32
+ # Install
70
33
  npm install -g neuronlayer
71
- ```
72
34
 
73
- ### One-Command Setup
74
-
75
- ```bash
35
+ # Initialize in your project
76
36
  cd your-project
77
37
  neuronlayer init
78
38
  ```
79
39
 
80
- That's it! This automatically:
81
- 1. Registers your project
82
- 2. Configures Claude Desktop, Claude Code, and OpenCode
83
- 3. Indexes your codebase (symbol extraction, dependency graph, tests)
84
-
85
- Just restart your AI tool and NeuronLayer is active.
40
+ This registers your project and configures Claude Desktop, Claude Code, and OpenCode automatically. Restart your AI tool and you're ready.
86
41
 
87
42
  ---
88
43
 
89
- ## Code Intelligence Features
44
+ ## Supported AI Tools
90
45
 
91
- ### Dependency Graph
46
+ | Tool | Setup |
47
+ |------|-------|
48
+ | Claude Desktop | `neuronlayer init` (auto) |
49
+ | Claude Code (CLI) | `neuronlayer init` (auto) |
50
+ | Cursor | `neuronlayer init` (auto) |
51
+ | OpenCode | `neuronlayer init` (auto) |
52
+ | Any MCP Client | Manual config |
53
+ | **Any tool (HTTP)** | `neuronlayer serve` |
92
54
 
93
- NeuronLayer builds a complete dependency graph of your codebase:
55
+ All tools share the same data - switch between them freely.
94
56
 
95
- ```
96
- src/auth/login.ts
97
- ├── imports: ./utils, ../api/client, ./types
98
- └── imported by: src/pages/auth.tsx, src/hooks/useAuth.ts
99
- ```
57
+ ---
100
58
 
101
- ### Impact Analysis
59
+ ## What You Can Ask
102
60
 
103
- Before making changes, the AI can ask "what's the blast radius?"
61
+ Once NeuronLayer is running, your AI assistant can:
104
62
 
63
+ **Understand dependencies:**
105
64
  ```
106
- get_impact_analysis({ file: "src/auth/login.ts" })
107
-
108
- → Risk Level: MEDIUM
109
- → Direct dependents: 3 files
110
- → Indirect dependents: 5 files (2 hops)
111
- → Affected tests: 4 tests
112
- → Circular dependencies: none
65
+ "What files depend on src/auth/login.ts?"
66
+ "Show me the import chain for this module"
113
67
  ```
114
68
 
115
- ### Circular Dependency Detection
116
-
117
- Automatically finds import cycles that cause subtle bugs:
118
-
69
+ **Analyze impact:**
119
70
  ```
120
- find_circular_deps()
121
-
122
- → Found 2 circular dependency chains:
123
- 1. src/a.ts → src/b.ts → src/c.ts → src/a.ts
124
- 2. src/utils/index.ts → src/utils/helpers.ts → src/utils/index.ts
71
+ "If I change this file, what else might break?"
72
+ "What tests cover this function?"
125
73
  ```
126
74
 
127
- ### Test Awareness
128
-
129
- NeuronLayer indexes your test files:
130
- - Detects test framework (Jest, Vitest, Mocha, pytest, etc.)
131
- - Identifies test files by naming conventions and patterns
132
- - Maps tests to source files they import
133
- - Shows which tests may be affected when files change
134
-
135
- ### Real-Time Impact Warnings
136
-
137
- When you save a file, NeuronLayer tells you what's affected:
75
+ **Find code:**
76
+ ```
77
+ "Find all authentication-related code"
78
+ "Where is the user validation logic?"
79
+ ```
138
80
 
81
+ **Check for issues:**
139
82
  ```
140
- [Impact] src/auth/login.ts changed 3 file(s) may be affected
141
- src/pages/auth.tsx
142
- → src/hooks/useAuth.ts
143
- → src/components/LoginForm.tsx
83
+ "Are there any circular dependencies?"
84
+ "What decisions have we made about authentication?"
144
85
  ```
145
86
 
146
87
  ---
147
88
 
148
- ## MCP Tools
89
+ ## How It Works
149
90
 
150
- ### Gateway Tools (Smart Routing)
91
+ NeuronLayer watches your project and maintains:
151
92
 
152
- | Tool | Purpose |
153
- |------|---------|
154
- | `memory_query` | Search codebase, find code, look up symbols, get file context |
155
- | `memory_record` | Save decisions, learn patterns, record feedback, track features |
156
- | `memory_review` | Pre-code review: check patterns, conflicts, tests, get suggestions |
157
- | `memory_status` | Project overview, architecture, recent changes, health check |
158
- | `memory_ghost` | Proactive intelligence: conflicts, "you solved this before", session resume |
159
- | `memory_verify` | Pre-commit check: validate imports, security, dependencies |
93
+ 1. **Symbol index** - Functions, classes, imports, exports
94
+ 2. **Dependency graph** - File-to-file import relationships
95
+ 3. **Decision log** - Architectural decisions you've recorded
96
+ 4. **Embeddings** - For semantic search (using MiniLM-L6 locally)
160
97
 
161
- ### Code Intelligence Tools
162
-
163
- | Tool | Purpose |
164
- |------|---------|
165
- | `get_impact_analysis` | **Analyze blast radius** - all affected files, tests, risk level |
166
- | `find_circular_deps` | **Detect import cycles** - find circular dependencies |
167
- | `get_dependencies` | Get imports and importers for a file |
168
- | `get_file_summary` | Compressed file overview (10x smaller than full content) |
169
-
170
- ### Utility Tools
171
-
172
- | Tool | Purpose |
173
- |------|---------|
174
- | `memory_refresh` | Trigger manual refresh after external changes |
175
- | `switch_project` | Switch between registered projects |
176
- | `trigger_compaction` | Reduce memory when context is full |
177
- | `export_decisions_to_adr` | Export decisions as ADR markdown files |
98
+ When your AI assistant asks a question, NeuronLayer provides the relevant context.
178
99
 
179
100
  ---
180
101
 
181
102
  ## Language Support
182
103
 
183
- All languages use regex-based parsing for reliable cross-platform support.
104
+ | Language | What's Extracted |
105
+ |----------|------------------|
106
+ | TypeScript/JavaScript | Functions, classes, imports, exports |
107
+ | Python | Functions, classes, imports |
108
+ | Go | Functions, structs, imports |
109
+ | Rust | Functions, structs, imports |
110
+ | Java | Classes, methods, imports |
184
111
 
185
- | Language | Symbol Extraction | Dependency Tracking |
186
- |----------|-------------------|---------------------|
187
- | TypeScript/JavaScript | Functions, classes, imports, exports | Yes |
188
- | Python | Functions, classes, imports | Yes |
189
- | Go | Functions, structs, imports | Yes |
190
- | Rust | Functions, structs, imports | Yes |
191
- | Java | Classes, methods, imports | Yes |
112
+ Parsing is powered by **Tree-sitter WASM**, providing true Abstract Syntax Tree (AST) understanding rather than fragile regex matching. This ensures 100% accurate symbol extraction, boundary detection, and method signatures across all supported languages.
192
113
 
193
114
  ---
194
115
 
195
- ## Features
196
-
197
- | Feature | Status | Description |
198
- |---------|--------|-------------|
199
- | **Dependency Graph** | Working | Tracks imports via regex, builds transitive dependency graph |
200
- | **Impact Analysis** | Working | Shows blast radius using BFS graph traversal |
201
- | **Circular Detection** | Working | Finds import cycles using DFS |
202
- | **Test Indexing** | Working | Indexes test files, identifies what functions they test |
203
- | **Semantic Search** | Working | Find code by meaning using local embeddings (MiniLM-L6) |
204
- | **Decision Recording** | Working | Log architectural decisions with context |
205
- | **Pattern Library** | Working | Learn and validate coding patterns |
206
- | **Symbol Extraction** | Working | Extract functions, classes, imports via regex |
207
- | **Context Compaction** | Working | Smart summarization when context fills |
208
- | **Git Integration** | Working | Track changes, correlate with decisions |
209
- | **Multi-Project** | Working | Switch between projects seamlessly |
210
- | **Impact Warnings** | Working | Real-time notifications on file changes |
211
-
212
- ---
213
-
214
- ## Architecture
215
-
216
- ```
217
- +-------------------------------------------------------------+
218
- | NEURONLAYER |
219
- +-------------------------------------------------------------+
220
- | |
221
- | +--------------+ +--------------+ +--------------+ |
222
- | | AI Tool |--->| MCP Server |--->| Code | |
223
- | | Claude/etc | | (stdio) | | Intelligence | |
224
- | +--------------+ +--------------+ +--------------+ |
225
- | | |
226
- | +--------------------+--+----+ |
227
- | | v | |
228
- | +--------------+ +-----+----+ +------------------+| |
229
- | | Your Code |--->| Indexer |--->| SQLite + Vec DB || |
230
- | | (watched) | | AST/Deps | | + Dep Graph || |
231
- | +--------------+ +----------+ +------------------+| |
232
- | | |
233
- +-------------------------------------------------------------+
234
- ```
235
-
236
- ### Core Modules
116
+ ## CLI Commands
237
117
 
238
- ```
239
- src/core/
240
- ├── engine.ts # Main engine, coordinates everything
241
- ├── ghost-mode.ts # Proactive conflict detection
242
- ├── test-awareness/ # Test indexing & failure prediction
243
- ├── change-intelligence/ # Git tracking & impact analysis
244
- ├── architecture/ # Pattern library & validation
245
- ├── context-rot/ # Context health & compaction
246
- ├── living-docs/ # Architecture & changelog generation
247
- └── refresh/ # Intelligent refresh system
248
-
249
- src/storage/
250
- ├── tier1.ts # Hot cache (instant)
251
- ├── tier2.ts # SQLite + dependency graph (fast)
252
- └── tier3.ts # Vector embeddings (semantic)
253
-
254
- src/indexing/
255
- ├── ast.ts # Regex-based parsing (TS/JS/Python/Go/Rust/Java)
256
- ├── indexer.ts # File indexing + dependency building
257
- └── embeddings.ts # Local embedding generation (MiniLM-L6)
118
+ ```bash
119
+ neuronlayer init # Set up project + configure AI tools
120
+ neuronlayer serve # Start HTTP API server
121
+ neuronlayer projects list # List registered projects
122
+ neuronlayer projects add . # Add current directory
123
+ neuronlayer projects switch # Switch active project
124
+ neuronlayer export # Export decisions to ADR files
125
+ neuronlayer help # Show help
258
126
  ```
259
127
 
260
128
  ---
261
129
 
262
- ## CLI Commands
263
-
264
- ```bash
265
- # Quick setup (auto-configures AI tools)
266
- neuronlayer init
130
+ ## HTTP API
267
131
 
268
- # Initialize specific project
269
- neuronlayer init /path/to/project
132
+ For tools that don't support MCP, NeuronLayer provides a REST API:
270
133
 
271
- # List all registered projects
272
- neuronlayer projects list
273
-
274
- # Add a new project
275
- neuronlayer projects add /path/to/my-project
134
+ ```bash
135
+ neuronlayer serve --project /path/to/project --port 3333
136
+ ```
276
137
 
277
- # Switch active project
278
- neuronlayer projects switch <id>
138
+ **Endpoints:**
279
139
 
280
- # Export decisions to ADR files
281
- neuronlayer export --format madr
140
+ | Method | Endpoint | Description |
141
+ |--------|----------|-------------|
142
+ | GET | `/status` | Project stats |
143
+ | GET | `/search?q=...` | Semantic code search |
144
+ | GET | `/dependencies?file=...` | File dependencies |
145
+ | GET | `/impact?file=...` | Impact analysis |
146
+ | GET | `/circular` | Find circular deps |
147
+ | GET | `/decisions` | List decisions |
148
+ | POST | `/decisions` | Record a decision |
149
+ | GET | `/symbols?file=...` | Get file symbols |
282
150
 
283
- # Show help
284
- neuronlayer help
151
+ **Example:**
152
+ ```bash
153
+ curl "http://localhost:3333/impact?file=src/auth/login.ts"
285
154
  ```
286
155
 
287
156
  ---
288
157
 
289
158
  ## Manual Configuration
290
159
 
291
- ### Claude Desktop
292
-
293
- Add to `claude_desktop_config.json`:
160
+ If `neuronlayer init` doesn't work for your setup, add to your Claude Desktop config:
294
161
 
295
162
  ```json
296
163
  {
@@ -312,86 +179,45 @@ Config locations:
312
179
 
313
180
  ## Data Storage
314
181
 
315
- Each project has isolated data:
182
+ Project data is stored locally:
316
183
 
317
184
  ```
318
185
  ~/.memorylayer/
319
186
  ├── projects/
320
- ├── project-a-abc123/
321
- ├── neuronlayer.db # SQLite + dependency graph
322
- └── embeddings/ # Vector index
323
- └── project-b-def456/
324
- │ └── ...
325
- └── registry.json # Project registry
187
+ └── your-project-abc123/
188
+ ├── neuronlayer.db # SQLite database
189
+ └── embeddings/ # Vector index
190
+ └── registry.json # Project list
326
191
  ```
327
192
 
328
193
  ---
329
194
 
330
- ## NeuronLayer vs Other Tools
331
-
332
- ### vs grep/ripgrep
333
-
334
- NeuronLayer **doesn't compete with grep** - Claude already has grep. They serve different purposes:
335
-
336
- | grep does | NeuronLayer does |
337
- |-----------|------------------|
338
- | Text matching | **Semantic search** ("how does auth work?") |
339
- | Regex patterns | **Dependency analysis** (what depends on this?) |
340
- | Fast file search | **Impact prediction** (what breaks if I change this?) |
341
- | | **Test awareness** (which tests cover this function?) |
342
-
343
- ### vs Simple Memory Tools
344
-
345
- | Memory tools do | NeuronLayer does |
346
- |-----------------|------------------|
347
- | Store notes | **Parse code structure** |
348
- | Keyword search | **Graph traversal** |
349
- | Tag organization | **Circular dependency detection** |
350
- | | **Test failure prediction** |
351
-
352
- ---
353
-
354
195
  ## Privacy
355
196
 
356
- NeuronLayer is **100% local**:
357
-
358
- - All data stored on your machine
197
+ - All data stays on your machine
359
198
  - No cloud services
360
199
  - No telemetry
361
- - No LLM calls (pure code analysis)
362
- - Works completely offline
200
+ - Works offline
363
201
 
364
202
  ---
365
203
 
366
204
  ## Development
367
205
 
368
206
  ```bash
369
- # Clone
370
207
  git clone https://github.com/abhisavakar/neuronlayer.git
371
208
  cd neuronlayer
372
-
373
- # Install
374
209
  npm install
375
-
376
- # Build
377
210
  npm run build
378
-
379
- # Type check
380
- npm run typecheck
381
211
  ```
382
212
 
383
213
  ---
384
214
 
385
215
  ## License
386
216
 
387
- MIT License - see [LICENSE](LICENSE)
217
+ MIT - see [LICENSE](LICENSE)
388
218
 
389
219
  ---
390
220
 
391
- ## Author
392
-
393
- **Abhishek Arun Savakar** - [savakar.com](https://savakar.com)
394
-
395
- ---
221
+ **Author:** Abhishek Arun Savakar - [savakar.com](https://savakar.com)
396
222
 
397
223
  Built with [Model Context Protocol](https://modelcontextprotocol.io/) by Anthropic.