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.
Files changed (78) hide show
  1. package/CONTRIBUTING.md +127 -0
  2. package/LICENSE +21 -0
  3. package/README.md +305 -0
  4. package/dist/index.js +38016 -0
  5. package/esbuild.config.js +26 -0
  6. package/package.json +63 -0
  7. package/src/cli/commands.ts +382 -0
  8. package/src/core/adr-exporter.ts +253 -0
  9. package/src/core/architecture/architecture-enforcement.ts +228 -0
  10. package/src/core/architecture/duplicate-detector.ts +288 -0
  11. package/src/core/architecture/index.ts +6 -0
  12. package/src/core/architecture/pattern-learner.ts +306 -0
  13. package/src/core/architecture/pattern-library.ts +403 -0
  14. package/src/core/architecture/pattern-validator.ts +324 -0
  15. package/src/core/change-intelligence/bug-correlator.ts +444 -0
  16. package/src/core/change-intelligence/change-intelligence.ts +221 -0
  17. package/src/core/change-intelligence/change-tracker.ts +334 -0
  18. package/src/core/change-intelligence/fix-suggester.ts +340 -0
  19. package/src/core/change-intelligence/index.ts +5 -0
  20. package/src/core/code-verifier.ts +843 -0
  21. package/src/core/confidence/confidence-scorer.ts +251 -0
  22. package/src/core/confidence/conflict-checker.ts +289 -0
  23. package/src/core/confidence/index.ts +5 -0
  24. package/src/core/confidence/source-tracker.ts +263 -0
  25. package/src/core/confidence/warning-detector.ts +241 -0
  26. package/src/core/context-rot/compaction.ts +284 -0
  27. package/src/core/context-rot/context-health.ts +243 -0
  28. package/src/core/context-rot/context-rot-prevention.ts +213 -0
  29. package/src/core/context-rot/critical-context.ts +221 -0
  30. package/src/core/context-rot/drift-detector.ts +255 -0
  31. package/src/core/context-rot/index.ts +7 -0
  32. package/src/core/context.ts +263 -0
  33. package/src/core/decision-extractor.ts +339 -0
  34. package/src/core/decisions.ts +69 -0
  35. package/src/core/deja-vu.ts +421 -0
  36. package/src/core/engine.ts +1455 -0
  37. package/src/core/feature-context.ts +726 -0
  38. package/src/core/ghost-mode.ts +412 -0
  39. package/src/core/learning.ts +485 -0
  40. package/src/core/living-docs/activity-tracker.ts +296 -0
  41. package/src/core/living-docs/architecture-generator.ts +428 -0
  42. package/src/core/living-docs/changelog-generator.ts +348 -0
  43. package/src/core/living-docs/component-generator.ts +230 -0
  44. package/src/core/living-docs/doc-engine.ts +110 -0
  45. package/src/core/living-docs/doc-validator.ts +282 -0
  46. package/src/core/living-docs/index.ts +8 -0
  47. package/src/core/project-manager.ts +297 -0
  48. package/src/core/summarizer.ts +267 -0
  49. package/src/core/test-awareness/change-validator.ts +499 -0
  50. package/src/core/test-awareness/index.ts +5 -0
  51. package/src/index.ts +49 -0
  52. package/src/indexing/ast.ts +563 -0
  53. package/src/indexing/embeddings.ts +85 -0
  54. package/src/indexing/indexer.ts +245 -0
  55. package/src/indexing/watcher.ts +78 -0
  56. package/src/server/gateways/aggregator.ts +374 -0
  57. package/src/server/gateways/index.ts +473 -0
  58. package/src/server/gateways/memory-ghost.ts +343 -0
  59. package/src/server/gateways/memory-query.ts +452 -0
  60. package/src/server/gateways/memory-record.ts +346 -0
  61. package/src/server/gateways/memory-review.ts +410 -0
  62. package/src/server/gateways/memory-status.ts +517 -0
  63. package/src/server/gateways/memory-verify.ts +392 -0
  64. package/src/server/gateways/router.ts +434 -0
  65. package/src/server/gateways/types.ts +610 -0
  66. package/src/server/mcp.ts +154 -0
  67. package/src/server/resources.ts +85 -0
  68. package/src/server/tools.ts +2261 -0
  69. package/src/storage/database.ts +262 -0
  70. package/src/storage/tier1.ts +135 -0
  71. package/src/storage/tier2.ts +764 -0
  72. package/src/storage/tier3.ts +123 -0
  73. package/src/types/documentation.ts +619 -0
  74. package/src/types/index.ts +222 -0
  75. package/src/utils/config.ts +193 -0
  76. package/src/utils/files.ts +117 -0
  77. package/src/utils/time.ts +37 -0
  78. package/src/utils/tokens.ts +52 -0
@@ -0,0 +1,127 @@
1
+ # Contributing to MemoryLayer
2
+
3
+ Thank you for your interest in contributing to MemoryLayer! This document provides guidelines and information for contributors.
4
+
5
+ ## Code of Conduct
6
+
7
+ Be respectful, inclusive, and constructive. We're all here to build something great together.
8
+
9
+ ## How to Contribute
10
+
11
+ ### Reporting Bugs
12
+
13
+ 1. Check existing issues to avoid duplicates
14
+ 2. Use a clear, descriptive title
15
+ 3. Include:
16
+ - Steps to reproduce
17
+ - Expected vs actual behavior
18
+ - Environment (OS, Node.js version)
19
+ - Relevant logs or error messages
20
+
21
+ ### Suggesting Features
22
+
23
+ 1. Check if the feature is already planned (see Roadmap in README)
24
+ 2. Open an issue with `[Feature]` prefix
25
+ 3. Describe the use case and proposed solution
26
+ 4. Be open to discussion and alternatives
27
+
28
+ ### Pull Requests
29
+
30
+ 1. Fork the repository
31
+ 2. Create a feature branch from `main`
32
+ 3. Make your changes
33
+ 4. Write/update tests as needed
34
+ 5. Run `npm run typecheck` and `npm test`
35
+ 6. Submit a PR with a clear description
36
+
37
+ ## Development Setup
38
+
39
+ ```bash
40
+ # Clone your fork
41
+ git clone https://github.com/YOUR_USERNAME/memorylayer.git
42
+ cd memorylayer
43
+
44
+ # Install dependencies
45
+ npm install
46
+
47
+ # Build
48
+ npm run build
49
+
50
+ # Run tests
51
+ npm test
52
+
53
+ # Type check
54
+ npm run typecheck
55
+ ```
56
+
57
+ ## Project Structure
58
+
59
+ ```
60
+ src/
61
+ ├── core/ # Business logic (engine, features)
62
+ ├── server/ # MCP server and tools
63
+ ├── storage/ # Data persistence (SQLite, vectors)
64
+ ├── indexing/ # File indexing and AST
65
+ ├── types/ # TypeScript type definitions
66
+ ├── utils/ # Shared utilities
67
+ └── agent/ # Standalone agent (optional)
68
+ ```
69
+
70
+ ## Coding Standards
71
+
72
+ ### TypeScript
73
+
74
+ - Use TypeScript strict mode
75
+ - Prefer explicit types over `any`
76
+ - Use interfaces for object shapes
77
+ - Export types from `src/types/`
78
+
79
+ ### Code Style
80
+
81
+ - Use meaningful variable/function names
82
+ - Keep functions focused and small
83
+ - Add comments for non-obvious logic
84
+ - Follow existing patterns in the codebase
85
+
86
+ ### Testing
87
+
88
+ - Write tests for new features
89
+ - Tests go in `__tests__/` directories or `*.test.ts` files
90
+ - Use Vitest for testing
91
+
92
+ ### Commits
93
+
94
+ - Use clear, descriptive commit messages
95
+ - Follow conventional commits when possible:
96
+ - `feat:` new features
97
+ - `fix:` bug fixes
98
+ - `docs:` documentation
99
+ - `refactor:` code restructuring
100
+ - `test:` test additions/changes
101
+
102
+ ## Areas Where Help Is Needed
103
+
104
+ ### High Priority
105
+
106
+ 1. **Language Support** - Add AST parsing for Python, Go, Rust
107
+ 2. **Bug Fixes** - Check open issues
108
+ 3. **Test Coverage** - Increase test coverage
109
+
110
+ ### Medium Priority
111
+
112
+ 1. **Documentation** - Improve README, add examples
113
+ 2. **Performance** - Optimize indexing and search
114
+ 3. **IDE Extensions** - VS Code extension
115
+
116
+ ### Good First Issues
117
+
118
+ Look for issues labeled `good-first-issue` for beginner-friendly tasks.
119
+
120
+ ## Questions?
121
+
122
+ - Open a Discussion on GitHub
123
+ - Check existing issues and documentation
124
+
125
+ ## License
126
+
127
+ By contributing, you agree that your contributions will be licensed under the MIT License.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abhishek Arun Savakar (https://savakar.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,305 @@
1
+ # MemoryLayer
2
+
3
+ **Persistent memory layer for AI coding assistants. Your codebase documents itself.**
4
+
5
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-339933.svg)](https://nodejs.org/)
7
+ [![MCP](https://img.shields.io/badge/MCP-Compatible-blue.svg)](https://modelcontextprotocol.io/)
8
+
9
+ ---
10
+
11
+ ## The Problem
12
+
13
+ AI coding assistants are powerful but forgetful:
14
+
15
+ | Problem | Stat |
16
+ |---------|------|
17
+ | Productivity paradox | 19% SLOWER with AI |
18
+ | "Almost right" frustration | 66% of developers |
19
+ | Trust issues | Only 29% trust AI code |
20
+ | Context collapse | AI forgets mid-session |
21
+ | Technical debt | 1.64x higher errors |
22
+ | Code duplication | 4x more cloning |
23
+
24
+ ## The Solution
25
+
26
+ MemoryLayer gives AI assistants persistent, intelligent memory:
27
+
28
+ - **Never forget context** - Decisions, patterns, and history persist across sessions
29
+ - **Self-documenting codebase** - Architecture docs generate automatically
30
+ - **Context rot prevention** - AI stays sharp even in long sessions
31
+ - **Pattern enforcement** - Stops code duplication before it happens
32
+ - **Test-aware suggestions** - AI respects your tests
33
+
34
+ ---
35
+
36
+ ## Features
37
+
38
+ ### Core Features (Free)
39
+
40
+ | Feature | Description |
41
+ |---------|-------------|
42
+ | **Semantic Search** | Find code by meaning, not just keywords |
43
+ | **Decision Recording** | Log architectural decisions with context |
44
+ | **Pattern Library** | Learn and enforce coding patterns |
45
+ | **File Indexing** | AST-based symbol extraction |
46
+
47
+ ### Advanced Features
48
+
49
+ | Feature | Description |
50
+ |---------|-------------|
51
+ | **Living Documentation** | Auto-generated architecture docs |
52
+ | **Context Rot Prevention** | Smart compaction keeps AI focused |
53
+ | **Confidence Scoring** | Know when AI is guessing vs confident |
54
+ | **Change Intelligence** | "What changed?" and "Why did it break?" |
55
+ | **Architecture Enforcement** | Suggest existing functions, prevent duplication |
56
+ | **Test-Aware Suggestions** | Predict test failures before they happen |
57
+
58
+ ---
59
+
60
+ ## Quick Start
61
+
62
+ ### Installation
63
+
64
+ ```bash
65
+ npm install -g memory-layer
66
+ ```
67
+
68
+ ### Usage with Claude Desktop
69
+
70
+ Add to your Claude Desktop config (`claude_desktop_config.json`):
71
+
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "memorylayer": {
76
+ "command": "npx",
77
+ "args": ["-y", "memory-layer", "--project", "/path/to/your/project"]
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### Usage with Any MCP Client
84
+
85
+ ```bash
86
+ # Start the MCP server
87
+ memorylayer --project /path/to/your/project
88
+ ```
89
+
90
+ ---
91
+
92
+ ## How It Works
93
+
94
+ ```
95
+ +-------------------------------------------------------------+
96
+ | MEMORYLAYER |
97
+ +-------------------------------------------------------------+
98
+ | |
99
+ | +--------------+ +--------------+ +--------------+ |
100
+ | | AI Tool |--->| MCP Server |--->| Memory | |
101
+ | | (Claude etc) | | (stdio) | | Engine | |
102
+ | +--------------+ +--------------+ +--------------+ |
103
+ | | |
104
+ | +--------------------+--+----+ |
105
+ | | v | |
106
+ | +--------------+ +-----+----+ +------------------+| |
107
+ | | Your Code |--->| Indexer |--->| SQLite + Vec DB || |
108
+ | | (watched) | | (AST/Git)| | (embeddings) || |
109
+ | +--------------+ +----------+ +------------------+| |
110
+ | | |
111
+ +-------------------------------------------------------------+
112
+ ```
113
+
114
+ ### Memory Tiers
115
+
116
+ 1. **Tier 1** - Hot cache for active files (instant)
117
+ 2. **Tier 2** - SQLite for decisions, patterns, history (fast)
118
+ 3. **Tier 3** - Vector embeddings for semantic search (smart)
119
+
120
+ ---
121
+
122
+ ## MCP Tools
123
+
124
+ MemoryLayer exposes 25+ MCP tools:
125
+
126
+ ### Query & Search
127
+ - `memory_query` - Semantic search across codebase
128
+ - `memory_status` - Project overview and health
129
+
130
+ ### Recording
131
+ - `memory_record` - Save decisions, patterns, feedback
132
+ - `memory_review` - Pre-flight check before code changes
133
+ - `memory_verify` - Validate AI-generated code
134
+
135
+ ### Ghost Mode (AI-Proactive)
136
+ - `memory_ghost` - Conflicts, deja vu, session resurrection
137
+
138
+ ### Living Documentation
139
+ - `get_architecture` - Project structure overview
140
+ - `get_changelog` - Recent changes with context
141
+ - `what_happened` - "What did we do yesterday?"
142
+
143
+ ### Architecture Enforcement
144
+ - `validate_pattern` - Check code against patterns
145
+ - `suggest_existing` - Find reusable functions
146
+ - `learn_pattern` - Teach new patterns
147
+
148
+ ### Test Awareness
149
+ - `get_related_tests` - Tests for a file/function
150
+ - `check_tests` - Predict test failures
151
+ - `suggest_test_update` - Test update suggestions
152
+
153
+ ---
154
+
155
+ ## Configuration
156
+
157
+ MemoryLayer stores data in:
158
+ - **Windows**: `%APPDATA%\.memorylayer\<project-hash>\`
159
+ - **macOS/Linux**: `~/.memorylayer/<project-hash>/`
160
+
161
+ ### CLI Commands
162
+
163
+ ```bash
164
+ # List all indexed projects
165
+ memorylayer projects
166
+
167
+ # Export decisions as ADRs
168
+ memorylayer export --format adr --output ./docs/decisions
169
+
170
+ # Show help
171
+ memorylayer help
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Architecture
177
+
178
+ ```
179
+ src/
180
+ ├── core/ # Business logic
181
+ │ ├── engine.ts # Main orchestrator
182
+ │ ├── living-docs/ # Auto-documentation
183
+ │ ├── context-rot/ # Context health management
184
+ │ ├── confidence/ # Trust scoring
185
+ │ ├── change-intelligence/ # What changed & why
186
+ │ ├── architecture/ # Pattern enforcement
187
+ │ └── test-awareness/ # Test-respecting suggestions
188
+ ├── server/
189
+ │ ├── mcp.ts # MCP protocol handler
190
+ │ ├── tools.ts # Tool definitions
191
+ │ └── gateways/ # Unified tool APIs
192
+ ├── storage/
193
+ │ ├── tier1.ts # Hot cache
194
+ │ ├── tier2.ts # SQLite storage
195
+ │ └── tier3.ts # Vector embeddings
196
+ ├── indexing/
197
+ │ ├── indexer.ts # File indexing
198
+ │ ├── ast.ts # AST parsing
199
+ │ ├── embeddings.ts # Embedding generation
200
+ │ └── watcher.ts # File watching
201
+ └── types/ # TypeScript definitions
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Development
207
+
208
+ ### Prerequisites
209
+
210
+ - Node.js 18+
211
+ - npm or yarn
212
+
213
+ ### Setup
214
+
215
+ ```bash
216
+ # Clone the repository
217
+ git clone https://github.com/anthropics/memorylayer.git
218
+ cd memorylayer
219
+
220
+ # Install dependencies
221
+ npm install
222
+
223
+ # Build
224
+ npm run build
225
+
226
+ # Run tests
227
+ npm test
228
+
229
+ # Type check
230
+ npm run typecheck
231
+ ```
232
+
233
+ ### Scripts
234
+
235
+ | Script | Description |
236
+ |--------|-------------|
237
+ | `npm run build` | Build the project |
238
+ | `npm run dev` | Development mode with watch |
239
+ | `npm run test` | Run tests |
240
+ | `npm run typecheck` | Type check without building |
241
+ | `npm run benchmark` | Run performance benchmarks |
242
+
243
+ ---
244
+
245
+ ## Privacy
246
+
247
+ MemoryLayer is **100% local by default**:
248
+
249
+ - All data stored on your machine
250
+ - No cloud services required
251
+ - No telemetry or tracking
252
+ - Works offline
253
+
254
+ Optional cloud features (coming soon) will use your own infrastructure.
255
+
256
+ ---
257
+
258
+ ## Contributing
259
+
260
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
261
+
262
+ ### Areas We Need Help
263
+
264
+ - Additional language support (Python, Go, Rust AST)
265
+ - IDE extensions (VS Code, JetBrains)
266
+ - Documentation improvements
267
+ - Performance optimizations
268
+ - Bug fixes and test coverage
269
+
270
+ ---
271
+
272
+ ## Roadmap
273
+
274
+ - [x] Core MCP server
275
+ - [x] Living Documentation
276
+ - [x] Context Rot Prevention
277
+ - [x] Confidence Scoring
278
+ - [x] Change Intelligence
279
+ - [x] Architecture Enforcement
280
+ - [x] Test-Aware Suggestions
281
+ - [ ] VS Code extension
282
+ - [ ] Team features (shared memory)
283
+ - [ ] Enterprise deployment (AWS Bedrock)
284
+
285
+ ---
286
+
287
+ ## License
288
+
289
+ MIT License - see [LICENSE](LICENSE) for details.
290
+
291
+ ---
292
+
293
+ ## Acknowledgments
294
+
295
+ Built with:
296
+ - [Model Context Protocol](https://modelcontextprotocol.io/) by Anthropic
297
+ - [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
298
+ - [tree-sitter](https://tree-sitter.github.io/tree-sitter/) for AST parsing
299
+ - [Xenova/transformers](https://github.com/xenova/transformers.js) for embeddings
300
+
301
+ ---
302
+
303
+ **Made with determination over a weekend.**
304
+
305
+ *Your codebase documents itself. AI that never forgets.*