neuronlayer 0.2.6 → 0.2.8

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.
@@ -0,0 +1,425 @@
1
+ # MemoryLayer + OpenCode Setup Guide
2
+
3
+ This guide explains how to configure MemoryLayer as an MCP server for [OpenCode](https://opencode.ai).
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ 1. **Node.js 18+** installed
10
+ 2. **OpenCode** installed (`npm install -g opencode`)
11
+ 3. **MemoryLayer** built (`npm run build`)
12
+
13
+ ---
14
+
15
+ ## Quick Setup (Recommended)
16
+
17
+ The easiest and most reliable way to configure MemoryLayer for OpenCode is using our automated initialization command.
18
+
19
+ ### Step 1: Initialize MemoryLayer
20
+
21
+ Run this command in the root of your project:
22
+
23
+ ```bash
24
+ npx neuronlayer init .
25
+ ```
26
+
27
+ This will automatically detect your operating system and generate the correct `opencode.json` configuration file with the exact absolute paths required for OpenCode to connect to MemoryLayer.
28
+
29
+ ### Step 2: Start OpenCode
30
+
31
+ ```bash
32
+ opencode
33
+ ```
34
+
35
+ ### Step 3: Verify Connection
36
+
37
+ Inside OpenCode, type:
38
+ ```
39
+ /mcp
40
+ ```
41
+
42
+ You should see:
43
+ ```
44
+ MCP Servers
45
+ neuronlayer (local)
46
+ Status: connected
47
+ ```
48
+
49
+ Or from your terminal:
50
+ ```bash
51
+ opencode mcp list
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Manual Configuration (Advanced)
57
+
58
+ If you prefer to configure OpenCode manually, create an `opencode.json` file in your project root.
59
+
60
+ **IMPORTANT:** You must use **absolute paths** for reliable operation, and on Windows you must use `cmd` to wrap the Node execution.
61
+
62
+ **Windows Example:**
63
+ ```json
64
+ {
65
+ "$schema": "https://opencode.ai/config.json",
66
+ "mcp": {
67
+ "neuronlayer": {
68
+ "type": "local",
69
+ "command": ["cmd", "/c", "node", "C:\\Users\\YOUR_USERNAME\\path\\to\\memorylayer\\dist\\index.js", "--project", "C:\\Users\\YOUR_USERNAME\\path\\to\\your\\project"],
70
+ "enabled": true
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ **macOS/Linux Example:**
77
+ ```json
78
+ {
79
+ "$schema": "https://opencode.ai/config.json",
80
+ "mcp": {
81
+ "neuronlayer": {
82
+ "type": "local",
83
+ "command": ["node", "/home/user/memorylayer/dist/index.js", "--project", "/home/user/myproject"],
84
+ "enabled": true
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Global Setup
93
+
94
+ For system-wide availability, create the config in your home directory:
95
+
96
+ **Windows:** `%USERPROFILE%\.config\opencode\opencode.json`
97
+ **macOS/Linux:** `~/.config/opencode/opencode.json`
98
+
99
+ ```json
100
+ {
101
+ "$schema": "https://opencode.ai/config.json",
102
+ "mcp": {
103
+ "memorylayer": {
104
+ "type": "local",
105
+ "command": ["node", "/absolute/path/to/memorylayer/dist/index.js", "--project", "."],
106
+ "enabled": true
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ ---
113
+
114
+ ## After npm Publish
115
+
116
+ Once MemoryLayer is published to npm, setup becomes simpler:
117
+
118
+ ### Using npx
119
+
120
+ ```json
121
+ {
122
+ "$schema": "https://opencode.ai/config.json",
123
+ "mcp": {
124
+ "memorylayer": {
125
+ "type": "local",
126
+ "command": ["npx", "-y", "memorylayer", "--project", "."],
127
+ "enabled": true
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ ### Global Install
134
+
135
+ ```bash
136
+ npm install -g memorylayer
137
+ ```
138
+
139
+ ```json
140
+ {
141
+ "$schema": "https://opencode.ai/config.json",
142
+ "mcp": {
143
+ "memorylayer": {
144
+ "type": "local",
145
+ "command": ["memorylayer", "--project", "."],
146
+ "enabled": true
147
+ }
148
+ }
149
+ }
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Configuration Reference
155
+
156
+ | Field | Type | Required | Description |
157
+ |-------|------|----------|-------------|
158
+ | `type` | `"local"` \| `"remote"` | Yes | Server type |
159
+ | `command` | `string[]` | Yes (local) | Command array (NOT a string) |
160
+ | `enabled` | `boolean` | Yes | Must be `true` to connect |
161
+ | `environment` | `object` | No | Environment variables |
162
+
163
+ ### Example with Environment Variables
164
+
165
+ ```json
166
+ {
167
+ "$schema": "https://opencode.ai/config.json",
168
+ "mcp": {
169
+ "memorylayer": {
170
+ "type": "local",
171
+ "command": ["node", "C:\\path\\to\\memorylayer\\dist\\index.js", "--project", "."],
172
+ "enabled": true,
173
+ "environment": {
174
+ "MEMORYLAYER_MAX_TOKENS": "8000",
175
+ "MEMORYLAYER_DEBUG": "true"
176
+ }
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Available Tools (51 Total)
185
+
186
+ Once connected, OpenCode's AI can use all MemoryLayer tools:
187
+
188
+ ### Core Tools (5)
189
+ | Tool | Description |
190
+ |------|-------------|
191
+ | `get_context` | Get relevant codebase context for a query |
192
+ | `search_codebase` | Semantic search across all files |
193
+ | `record_decision` | Save an architectural decision |
194
+ | `get_file_context` | Get content of a specific file |
195
+ | `get_project_summary` | Overview of project structure |
196
+
197
+ ### Symbol & Dependency Tools (3)
198
+ | Tool | Description |
199
+ |------|-------------|
200
+ | `get_symbol` | Find functions, classes, types by name |
201
+ | `get_dependencies` | See imports/exports for a file |
202
+ | `get_file_summary` | Get compressed file summary (10x smaller) |
203
+
204
+ ### Learning Tools (3)
205
+ | Tool | Description |
206
+ |------|-------------|
207
+ | `get_predicted_files` | Files predicted to be relevant |
208
+ | `get_learning_stats` | Usage statistics |
209
+ | `mark_context_useful` | Feedback for learning |
210
+
211
+ ### Multi-Project Tools (6)
212
+ | Tool | Description |
213
+ |------|-------------|
214
+ | `list_projects` | List all registered projects |
215
+ | `switch_project` | Switch active project |
216
+ | `search_all_projects` | Search across all projects |
217
+ | `discover_projects` | Find projects on system |
218
+ | `record_decision_with_author` | Decision with author attribution |
219
+ | `update_decision_status` | Update decision lifecycle |
220
+ | `export_decisions_to_adr` | Export to ADR markdown files |
221
+
222
+ ### Feature Context Tools (4)
223
+ | Tool | Description |
224
+ |------|-------------|
225
+ | `get_active_context` | Get current work session context |
226
+ | `set_feature_context` | Start tracking a feature |
227
+ | `list_recent_contexts` | List recent work sessions |
228
+ | `switch_feature_context` | Switch to previous session |
229
+
230
+ ### Living Documentation Tools (7)
231
+ | Tool | Description |
232
+ |------|-------------|
233
+ | `generate_docs` | Generate documentation |
234
+ | `get_architecture` | Get project architecture overview |
235
+ | `get_component_doc` | Get detailed component docs |
236
+ | `get_changelog` | Get changelog of recent changes |
237
+ | `validate_docs` | Check for outdated docs |
238
+ | `what_happened` | Query recent project activity |
239
+ | `find_undocumented` | Find code lacking docs |
240
+
241
+ ### Context Rot Prevention Tools (4)
242
+ | Tool | Description |
243
+ |------|-------------|
244
+ | `get_context_health` | Check context health |
245
+ | `trigger_compaction` | Manually compact context |
246
+ | `mark_critical` | Mark content as critical |
247
+ | `get_critical_context` | Get critical items |
248
+
249
+ ### Confidence Scoring Tools (3)
250
+ | Tool | Description |
251
+ |------|-------------|
252
+ | `get_confidence` | Get confidence score for code |
253
+ | `list_sources` | List sources for a suggestion |
254
+ | `check_conflicts` | Check for decision conflicts |
255
+
256
+ ### Change Intelligence Tools (4)
257
+ | Tool | Description |
258
+ |------|-------------|
259
+ | `what_changed` | Query what changed |
260
+ | `why_broke` | Diagnose why something broke |
261
+ | `find_similar_bugs` | Find similar bugs from history |
262
+ | `suggest_fix` | Get fix suggestions |
263
+
264
+ ### Architecture Enforcement Tools (7)
265
+ | Tool | Description |
266
+ |------|-------------|
267
+ | `validate_pattern` | Validate code against patterns |
268
+ | `suggest_existing` | Find existing functions |
269
+ | `learn_pattern` | Teach a new pattern |
270
+ | `list_patterns` | List all patterns |
271
+ | `get_pattern` | Get pattern details |
272
+ | `add_pattern_example` | Add example to pattern |
273
+ | `get_architecture_stats` | Get architecture statistics |
274
+
275
+ ### Test Awareness Tools (4)
276
+ | Tool | Description |
277
+ |------|-------------|
278
+ | `get_related_tests` | Get tests for a file/function |
279
+ | `check_tests` | Check if change breaks tests |
280
+ | `suggest_test_update` | Get test update suggestions |
281
+ | `get_test_coverage` | Get test coverage |
282
+
283
+ ---
284
+
285
+ ## Troubleshooting
286
+
287
+ ### "MCP server failed" or won't connect
288
+
289
+ **Most common cause:** Relative paths don't work reliably.
290
+
291
+ ```json
292
+ // ❌ WRONG - Relative path
293
+ "command": ["node", "dist/index.js", "--project", "."]
294
+
295
+ // ✅ CORRECT - Absolute path
296
+ "command": ["node", "C:\\Users\\you\\memorylayer\\dist\\index.js", "--project", "."]
297
+ ```
298
+
299
+ ### "Configuration is invalid"
300
+
301
+ Ensure `command` is an array of strings:
302
+
303
+ ```json
304
+ // ❌ WRONG - Single string
305
+ "command": "node dist/index.js --project ."
306
+
307
+ // ✅ CORRECT - Array of strings
308
+ "command": ["node", "dist/index.js", "--project", "."]
309
+ ```
310
+
311
+ ### Server starts but immediately fails
312
+
313
+ **Check if MemoryLayer runs manually first:**
314
+
315
+ ```bash
316
+ node C:\path\to\memorylayer\dist\index.js --project C:\path\to\your\project
317
+ ```
318
+
319
+ If you see errors, the issue is with MemoryLayer itself, not OpenCode.
320
+
321
+ **Common errors:**
322
+ - "Cannot find module" - Run `npm run build` first
323
+ - "ENOENT" - Path is wrong
324
+ - Database errors - Delete `~/.memorylayer/projects/` and retry
325
+
326
+ ### "No tools available" after connecting
327
+
328
+ 1. Verify connection with `/mcp` inside OpenCode
329
+ 2. Ensure `enabled: true` is set in config
330
+ 3. Restart OpenCode after config changes
331
+
332
+ ### Check Server Startup Manually
333
+
334
+ Test if MemoryLayer starts correctly:
335
+
336
+ ```bash
337
+ # Windows
338
+ node C:\path\to\memorylayer\dist\index.js --project C:\path\to\project
339
+
340
+ # macOS/Linux
341
+ node /path/to/memorylayer/dist/index.js --project /path/to/project
342
+ ```
343
+
344
+ You should see:
345
+ ```
346
+ MemoryLayer starting...
347
+ Project: /path/to/project
348
+ Indexing started...
349
+ Indexing complete: XX files indexed
350
+ MemoryLayer MCP server started
351
+ ```
352
+
353
+ ### View Debug Logs
354
+
355
+ Run OpenCode with debug logging:
356
+
357
+ ```bash
358
+ opencode --log-level DEBUG
359
+ ```
360
+
361
+ ### Reset MemoryLayer Data
362
+
363
+ If you have persistent issues, clear the data:
364
+
365
+ ```bash
366
+ # Windows
367
+ rmdir /s %USERPROFILE%\.memorylayer
368
+
369
+ # macOS/Linux
370
+ rm -rf ~/.memorylayer
371
+ ```
372
+
373
+ ---
374
+
375
+ ## Example Usage in OpenCode
376
+
377
+ Once configured, try these prompts:
378
+
379
+ ```
380
+ > Search for authentication code in this project
381
+
382
+ > What architectural decisions have been made?
383
+
384
+ > Show me the project summary
385
+
386
+ > Find the function that handles user login
387
+
388
+ > What changed yesterday?
389
+
390
+ > Why did the tests break?
391
+
392
+ > Check if this code follows our patterns: async function fetchData() { ... }
393
+
394
+ > Get tests related to src/auth/login.ts
395
+
396
+ > Record a decision: We chose SQLite because it requires no server setup
397
+ ```
398
+
399
+ ---
400
+
401
+ ## Data Storage
402
+
403
+ MemoryLayer stores data in:
404
+
405
+ ```
406
+ ~/.memorylayer/
407
+ ├── registry.json # Project registry
408
+ └── projects/
409
+ └── {project-name}-{hash}/
410
+ ├── memorylayer.db # SQLite database
411
+ └── tier1.json # Working context
412
+ ```
413
+
414
+ ---
415
+
416
+ ## Links
417
+
418
+ - [OpenCode Documentation](https://opencode.ai/docs/)
419
+ - [MCP Protocol](https://modelcontextprotocol.io/)
420
+ - [MemoryLayer API Reference](./API.md)
421
+ - [MemoryLayer Architecture](./ARCHITECTURE.md)
422
+
423
+ ---
424
+
425
+ *Last updated: February 2026*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neuronlayer",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "MCP server that gives AI assistants persistent understanding of your codebase",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "files": [
11
11
  "dist/**",
12
- "wasm/**"
12
+ "wasm/**",
13
+ "doc/**"
13
14
  ],
14
15
  "scripts": {
15
16
  "build": "node esbuild.config.js",
@@ -56,4 +57,4 @@
56
57
  "engines": {
57
58
  "node": ">=18.0.0"
58
59
  }
59
- }
60
+ }