@nano-step/nano-brain 2026.1.14
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.
- package/.opencode/command/nano-brain-init.md +13 -0
- package/.opencode/command/nano-brain-reindex.md +11 -0
- package/.opencode/command/nano-brain-status.md +12 -0
- package/AGENTS.md +41 -0
- package/AGENTS_SNIPPET.md +44 -0
- package/CHANGELOG.md +186 -0
- package/README.md +298 -0
- package/SKILL.md +109 -0
- package/bin/cli.js +29 -0
- package/commands/nano-brain-init.md +36 -0
- package/commands/nano-brain-reindex.md +31 -0
- package/commands/nano-brain-status.md +32 -0
- package/index.html +929 -0
- package/nano-brain +4 -0
- package/opencode-mcp.json +9 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/design.md +68 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/proposal.md +27 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/specs/mcp-integration-testing/spec.md +50 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/specs/mcp-server/spec.md +40 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/specs/search-pipeline/spec.md +29 -0
- package/openspec/changes/archive/2026-02-16-fix-mcp-server-bugs/tasks.md +37 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/design.md +111 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/proposal.md +30 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/specs/mcp-server/spec.md +33 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/specs/storage-limits/spec.md +90 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/specs/workspace-scoping/spec.md +66 -0
- package/openspec/changes/archive/2026-02-23-workspace-scoped-memory-and-storage-limits/tasks.md +199 -0
- package/openspec/changes/codebase-indexing/.openspec.yaml +2 -0
- package/openspec/changes/codebase-indexing/design.md +169 -0
- package/openspec/changes/codebase-indexing/proposal.md +30 -0
- package/openspec/changes/codebase-indexing/specs/codebase-collection/spec.md +187 -0
- package/openspec/changes/codebase-indexing/specs/mcp-server/spec.md +36 -0
- package/openspec/changes/codebase-indexing/tasks.md +56 -0
- package/openspec/changes/fix-session-harvest-workspace-scoping/.openspec.yaml +2 -0
- package/openspec/changes/fix-session-harvest-workspace-scoping/design.md +84 -0
- package/openspec/changes/fix-session-harvest-workspace-scoping/proposal.md +26 -0
- package/openspec/changes/fix-session-harvest-workspace-scoping/specs/workspace-scoping/spec.md +65 -0
- package/openspec/changes/fix-session-harvest-workspace-scoping/tasks.md +33 -0
- package/openspec/changes/performance-and-search-quality/.openspec.yaml +2 -0
- package/openspec/changes/performance-and-search-quality/proposal.md +37 -0
- package/openspec/specs/mcp-integration-testing/spec.md +50 -0
- package/openspec/specs/mcp-server/spec.md +75 -0
- package/openspec/specs/search-pipeline/spec.md +29 -0
- package/openspec/specs/storage-limits/spec.md +94 -0
- package/openspec/specs/workspace-scoping/spec.md +70 -0
- package/package.json +37 -0
- package/site/build.js +66 -0
- package/site/partials/_api.html +83 -0
- package/site/partials/_compare.html +100 -0
- package/site/partials/_config.html +23 -0
- package/site/partials/_features.html +43 -0
- package/site/partials/_footer.html +6 -0
- package/site/partials/_hero.html +9 -0
- package/site/partials/_how-it-works.html +26 -0
- package/site/partials/_models.html +18 -0
- package/site/partials/_quick-start.html +15 -0
- package/site/partials/_stats.html +1 -0
- package/site/partials/_tech-stack.html +13 -0
- package/site/script.js +12 -0
- package/site/shell.html +44 -0
- package/site/styles.css +548 -0
- package/src/chunker.ts +427 -0
- package/src/codebase.ts +425 -0
- package/src/collections.ts +217 -0
- package/src/embeddings.ts +325 -0
- package/src/expansion.ts +79 -0
- package/src/harvester.ts +306 -0
- package/src/index.ts +778 -0
- package/src/reranker.ts +103 -0
- package/src/search.ts +294 -0
- package/src/server.ts +876 -0
- package/src/storage.ts +221 -0
- package/src/store.ts +653 -0
- package/src/types.ts +215 -0
- package/src/watcher.ts +389 -0
- package/test/chunker.test.ts +479 -0
- package/test/cli.test.ts +309 -0
- package/test/codebase-chunker.test.ts +446 -0
- package/test/codebase.test.ts +678 -0
- package/test/collections.test.ts +571 -0
- package/test/harvester.test.ts +636 -0
- package/test/integration.test.ts +219 -0
- package/test/llm.test.ts +322 -0
- package/test/search.test.ts +572 -0
- package/test/server.test.ts +541 -0
- package/test/storage.test.ts +302 -0
- package/test/store.test.ts +530 -0
- package/test/watcher.test.ts +717 -0
- package/test/workspace.test.ts +239 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +16 -0
package/SKILL.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# nano-brain
|
|
2
|
+
|
|
3
|
+
Persistent memory for AI coding agents. Hybrid search (BM25 + semantic + LLM reranking) across past sessions, codebase, notes, and daily logs.
|
|
4
|
+
|
|
5
|
+
## Slash Commands
|
|
6
|
+
|
|
7
|
+
| Command | When to Use |
|
|
8
|
+
|---------|-------------|
|
|
9
|
+
| `/nano-brain-init` | First time in a workspace — indexes codebase and sets up memory |
|
|
10
|
+
| `/nano-brain-status` | Check health: document counts, embedding progress, server status |
|
|
11
|
+
| `/nano-brain-reindex` | After git pull, branch switch, or major code changes |
|
|
12
|
+
|
|
13
|
+
## CLI Commands
|
|
14
|
+
|
|
15
|
+
All memory operations use the `npx nano-brain` CLI via the Bash tool.
|
|
16
|
+
|
|
17
|
+
### Search
|
|
18
|
+
|
|
19
|
+
| Command | Use When | Speed |
|
|
20
|
+
|---------|----------|-------|
|
|
21
|
+
| `npx nano-brain query "search terms"` | Best quality, complex questions (BM25 + vector + reranking) | Slower |
|
|
22
|
+
| `npx nano-brain search "search terms"` | Exact keyword: error messages, function names, specific terms | Fast |
|
|
23
|
+
| `npx nano-brain vsearch "search terms"` | Conceptual: "how does auth work", "payment flow" | Medium |
|
|
24
|
+
|
|
25
|
+
**Default: Use `npx nano-brain query`** — it gives best results for most questions.
|
|
26
|
+
|
|
27
|
+
**Search options:**
|
|
28
|
+
- `-n <limit>` — Max results (default: 10)
|
|
29
|
+
- `-c <collection>` — Filter by collection (codebase, sessions, memory)
|
|
30
|
+
- `--full` — Show full content of results
|
|
31
|
+
- `--json` — Output as JSON
|
|
32
|
+
- `--files` — Show file paths only
|
|
33
|
+
- `--min-score=<n>` — Minimum score threshold
|
|
34
|
+
|
|
35
|
+
### Retrieval
|
|
36
|
+
|
|
37
|
+
| Command | Use When |
|
|
38
|
+
|---------|----------|
|
|
39
|
+
| `npx nano-brain get <docid-or-path>` | Retrieve specific document by path or docid |
|
|
40
|
+
| `npx nano-brain get <id> --full` | Full content with all metadata |
|
|
41
|
+
| `npx nano-brain get <id> --from=<line> --lines=<n>` | Specific line range |
|
|
42
|
+
|
|
43
|
+
### Management
|
|
44
|
+
|
|
45
|
+
| Command | Use When |
|
|
46
|
+
|---------|----------|
|
|
47
|
+
| `npx nano-brain status` | Check index health, embedding progress |
|
|
48
|
+
| `npx nano-brain update` | Refresh all collection indexes |
|
|
49
|
+
| `npx nano-brain harvest` | Harvest past AI sessions into searchable markdown |
|
|
50
|
+
| `npx nano-brain embed` | Generate embeddings for unembedded chunks |
|
|
51
|
+
| `npx nano-brain init --root=<path>` | Re-index a workspace |
|
|
52
|
+
|
|
53
|
+
### Writing Notes
|
|
54
|
+
|
|
55
|
+
There is no CLI write command. To save a note, create a markdown file directly:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Save a decision or insight
|
|
59
|
+
cat > ~/.nano-brain/memory/$(date +%Y-%m-%d)-topic.md << 'EOF'
|
|
60
|
+
## Summary
|
|
61
|
+
- Decision: ...
|
|
62
|
+
- Why: ...
|
|
63
|
+
- Files: ...
|
|
64
|
+
EOF
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then run `npx nano-brain update` to index the new file.
|
|
68
|
+
|
|
69
|
+
## When to Use Memory
|
|
70
|
+
|
|
71
|
+
**Before starting work:**
|
|
72
|
+
- Recall past decisions on similar features
|
|
73
|
+
- Find debugging insights from previous sessions
|
|
74
|
+
- Check existing patterns in codebase
|
|
75
|
+
|
|
76
|
+
**After completing work:**
|
|
77
|
+
- Save key architectural decisions
|
|
78
|
+
- Document non-obvious fixes
|
|
79
|
+
- Record domain knowledge for future sessions
|
|
80
|
+
|
|
81
|
+
## Collection Filtering
|
|
82
|
+
|
|
83
|
+
Add `-c <collection>` to narrow search scope:
|
|
84
|
+
|
|
85
|
+
| Collection | Contains |
|
|
86
|
+
|------------|----------|
|
|
87
|
+
| `codebase` | Source files from workspace |
|
|
88
|
+
| `sessions` | Past AI coding sessions |
|
|
89
|
+
| `memory` | Daily logs (tagged with workspace context) |
|
|
90
|
+
|
|
91
|
+
Omit `-c` to search everything (recommended for most queries).
|
|
92
|
+
|
|
93
|
+
## Memory vs Native Tools
|
|
94
|
+
|
|
95
|
+
| Task | Use |
|
|
96
|
+
|------|-----|
|
|
97
|
+
| Semantic search, past context, cross-session recall | **nano-brain** |
|
|
98
|
+
| Exact code patterns, AST structure, precise matches | **grep, ast-grep, glob** |
|
|
99
|
+
|
|
100
|
+
They complement each other. Use both.
|
|
101
|
+
|
|
102
|
+
## Troubleshooting
|
|
103
|
+
|
|
104
|
+
| Issue | Solution |
|
|
105
|
+
|-------|----------|
|
|
106
|
+
| 0 codebase docs | Run `/nano-brain-init` |
|
|
107
|
+
| Embeddings stuck | Check Ollama running: `ollama serve` |
|
|
108
|
+
| Stale results | Run `/nano-brain-reindex` |
|
|
109
|
+
| New notes not searchable | Run `npx nano-brain update` |
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const entry = join(__dirname, '..', 'src', 'index.ts');
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
let tsxBin;
|
|
15
|
+
try {
|
|
16
|
+
const require = createRequire(join(__dirname, '..', 'package.json'));
|
|
17
|
+
tsxBin = join(dirname(require.resolve('tsx/package.json')), 'dist', 'cli.mjs');
|
|
18
|
+
} catch {
|
|
19
|
+
tsxBin = join(__dirname, '..', 'node_modules', '.bin', 'tsx');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
execFileSync('node', [tsxBin, entry, ...args], { stdio: 'inherit' });
|
|
24
|
+
} catch (err) {
|
|
25
|
+
if (err.message && !err.status) {
|
|
26
|
+
console.error('nano-brain: failed to start —', err.message);
|
|
27
|
+
}
|
|
28
|
+
process.exit(err.status || 1);
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Initialize nano-brain persistent memory for the current workspace.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
nano-brain MCP server must be configured in opencode.json. If `memory_status` tool is not available, tell user to add nano-brain to their MCP config first.
|
|
8
|
+
|
|
9
|
+
## Steps
|
|
10
|
+
|
|
11
|
+
1. Call `memory_status` tool to check current state
|
|
12
|
+
- If codebase > 0 docs: already initialized, skip to step 4
|
|
13
|
+
- If error "tool not found": MCP not configured, stop and instruct user
|
|
14
|
+
|
|
15
|
+
2. Call `memory_index_codebase` with `root` = current workspace path
|
|
16
|
+
- This indexes source files (respects .gitignore)
|
|
17
|
+
|
|
18
|
+
3. Call `memory_update` to index sessions and curated notes
|
|
19
|
+
|
|
20
|
+
4. Call `memory_status` again and report:
|
|
21
|
+
- Total documents indexed
|
|
22
|
+
- Pending embeddings count
|
|
23
|
+
- Embedding server status (connected/disconnected)
|
|
24
|
+
|
|
25
|
+
## Output Format
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
nano-brain initialized:
|
|
29
|
+
- Codebase: X files
|
|
30
|
+
- Sessions: Y documents
|
|
31
|
+
- Pending embeddings: Z (processing in background)
|
|
32
|
+
- Embedding server: ✅ connected / ❌ disconnected
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If pending embeddings > 0, explain they process automatically when MCP server runs.
|
|
36
|
+
If embedding server disconnected, suggest: "Start Ollama: `ollama serve`"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Rescan codebase and refresh all nano-brain indexes after branch switch or code changes.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- After `git checkout`, `git pull`, or branch switch
|
|
8
|
+
- After major code changes (new files, deleted files, refactors)
|
|
9
|
+
- When search results seem stale or missing recent changes
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. Call `memory_index_codebase` with `root` = current workspace path
|
|
14
|
+
- Detects new, changed, and deleted files via content hash
|
|
15
|
+
- Only re-indexes what changed (incremental)
|
|
16
|
+
|
|
17
|
+
2. Call `memory_update` to refresh session and note indexes
|
|
18
|
+
|
|
19
|
+
3. Call `memory_status` and report:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Reindex complete:
|
|
23
|
+
- Codebase: X files (Y new, Z updated)
|
|
24
|
+
- Pending embeddings: N
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Notes
|
|
28
|
+
|
|
29
|
+
- Reindexing is incremental — unchanged files are skipped
|
|
30
|
+
- New/changed files need embedding — happens in background
|
|
31
|
+
- If many pending embeddings, they process automatically over time
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show nano-brain memory health and statistics.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Steps
|
|
6
|
+
|
|
7
|
+
1. Call `memory_status` tool
|
|
8
|
+
|
|
9
|
+
2. Present results in this format:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
nano-brain Status
|
|
13
|
+
─────────────────
|
|
14
|
+
Documents: X total
|
|
15
|
+
- codebase: A files
|
|
16
|
+
- sessions: B documents
|
|
17
|
+
- memory: C notes
|
|
18
|
+
|
|
19
|
+
Embeddings: Y embedded, Z pending
|
|
20
|
+
Server: ✅ connected (model) / ❌ disconnected
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Suggested Actions
|
|
24
|
+
|
|
25
|
+
Based on status, suggest ONE relevant action:
|
|
26
|
+
|
|
27
|
+
| Condition | Suggestion |
|
|
28
|
+
|-----------|------------|
|
|
29
|
+
| codebase = 0 | "Run `/nano-brain-init` to index this workspace" |
|
|
30
|
+
| pending > 100 | "Embeddings processing in background. Check again in a few minutes." |
|
|
31
|
+
| server disconnected | "Start Ollama: `ollama serve`" |
|
|
32
|
+
| all good | "Memory system healthy. Use `memory_query` to search." |
|