@nano-step/nano-brain 2026.5.3102 → 2026.5.3104
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/README.md +141 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,6 +121,9 @@ harvester:
|
|
|
121
121
|
watcher:
|
|
122
122
|
debounce_ms: 2000
|
|
123
123
|
reindex_interval: 300
|
|
124
|
+
# Per-collection exclude_patterns and allowed_extensions are also supported
|
|
125
|
+
# via the workspaces map. See "Global ignore patterns" section below for
|
|
126
|
+
# the cross-collection .nano-brainignore file.
|
|
124
127
|
|
|
125
128
|
storage:
|
|
126
129
|
max_file_size: 314572800 # 300MB
|
|
@@ -142,14 +145,115 @@ summarization:
|
|
|
142
145
|
concurrency: 3 # parallel map-phase LLM calls
|
|
143
146
|
```
|
|
144
147
|
|
|
148
|
+
### Authentication (VPS / remote deployment)
|
|
149
|
+
|
|
150
|
+
When binding to a non-loopback address, enable auth to protect your memory:
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
server:
|
|
154
|
+
host: 0.0.0.0
|
|
155
|
+
port: 3100
|
|
156
|
+
auth:
|
|
157
|
+
enabled: true
|
|
158
|
+
realm: nano-brain
|
|
159
|
+
users:
|
|
160
|
+
- username: admin
|
|
161
|
+
password_hash: "$2a$10$..." # from: nano-brain auth hash <password>
|
|
162
|
+
tokens:
|
|
163
|
+
- "nbt_..." # from: nano-brain auth token
|
|
164
|
+
bypass_paths:
|
|
165
|
+
- /health
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Generate credentials:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Generate bcrypt hash for Basic Auth
|
|
172
|
+
nano-brain auth hash mypassword
|
|
173
|
+
|
|
174
|
+
# Generate bearer token
|
|
175
|
+
nano-brain auth token
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Usage examples:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Basic Auth
|
|
182
|
+
curl -u admin:mypassword http://host:3100/api/v1/query -d '{"query":"test"}'
|
|
183
|
+
|
|
184
|
+
# Bearer token
|
|
185
|
+
curl -H "Authorization: Bearer nbt_..." http://host:3100/api/v1/query -d '{"query":"test"}'
|
|
186
|
+
|
|
187
|
+
# MCP client with URL-embedded credentials
|
|
188
|
+
# url: http://admin:mypassword@host:3100/mcp
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Global ignore patterns (`~/.nano-brain/.nano-brainignore`)
|
|
192
|
+
|
|
193
|
+
The watcher loads a global gitignore-style file at `~/.nano-brain/.nano-brainignore`
|
|
194
|
+
on startup. Patterns in this file apply to **all** registered collections, removing
|
|
195
|
+
the need to repeat the same exclusions in each `watcher.workspaces` block.
|
|
196
|
+
|
|
197
|
+
**Format**: standard `.gitignore` syntax (one pattern per line, supports `**`, `!negation`, blank lines, `#` comments).
|
|
198
|
+
|
|
199
|
+
**Example** `~/.nano-brain/.nano-brainignore`:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
# Skip generated files everywhere
|
|
203
|
+
*.png
|
|
204
|
+
*.jpg
|
|
205
|
+
*.pdf
|
|
206
|
+
build/
|
|
207
|
+
dist/
|
|
208
|
+
node_modules/
|
|
209
|
+
|
|
210
|
+
# But keep this one icon
|
|
211
|
+
!icons/important.png
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Order of evaluation** (most aggressive first):
|
|
215
|
+
|
|
216
|
+
1. Hardcoded default exclude dirs (`node_modules`, `.git`, `dist`, `build`, `target`, etc.)
|
|
217
|
+
2. **Global `.nano-brainignore`** (this feature)
|
|
218
|
+
3. Per-collection `.gitignore` (in collection root)
|
|
219
|
+
4. Per-collection `exclude_patterns` (config-level)
|
|
220
|
+
5. Per-collection `allowed_extensions` (whitelist)
|
|
221
|
+
|
|
222
|
+
**Restart required**: changes to `.nano-brainignore` take effect on next server start (hot-reload deferred to a follow-up). Issue #263.
|
|
223
|
+
|
|
145
224
|
### Session Summarization
|
|
146
225
|
|
|
147
226
|
When `summarization.enabled: true`, nano-brain automatically generates structured markdown summaries of each harvested session using an OpenAI-compatible LLM provider. Summaries are:
|
|
148
227
|
|
|
149
228
|
- Stored in PostgreSQL under collection `session-summary` for semantic search via the standard query/vsearch API (PG is the source of truth)
|
|
229
|
+
- Optionally written to disk as Markdown files for Obsidian-compatible access (see [Disk persistence](#disk-persistence-obsidian-compatible) below)
|
|
150
230
|
- Idempotent — unchanged sessions are skipped; re-harvested sessions overwrite old summaries
|
|
151
231
|
|
|
152
|
-
|
|
232
|
+
#### Disk persistence (Obsidian-compatible)
|
|
233
|
+
|
|
234
|
+
By default, summaries are written to disk as Markdown files at the path configured in
|
|
235
|
+
`summarization.output_dir` (default: `~/.nano-brain/summaries`). The file layout is:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
<output_dir>/<workspace_name>/<source>_<slugified-title>_<YYYY-MM-DD>.md
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Files are byte-identical to the `documents.content` field in PostgreSQL — disk is a
|
|
242
|
+
derivative view, DB is source of truth. Disk write failures (permission denied, disk
|
|
243
|
+
full) log a WARN but do not roll back the DB transaction.
|
|
244
|
+
|
|
245
|
+
To opt out (DB-only persistence):
|
|
246
|
+
|
|
247
|
+
```yaml
|
|
248
|
+
summarization:
|
|
249
|
+
write_to_disk: false
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
To backfill historical summaries already in the DB:
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
nano-brain backfill-summaries
|
|
256
|
+
```
|
|
153
257
|
|
|
154
258
|
**Quick setup with ai-proxy:**
|
|
155
259
|
|
|
@@ -175,13 +279,27 @@ Large sessions (100K+ tokens) are handled via map-reduce chunking — no session
|
|
|
175
279
|
|
|
176
280
|
| Variable | Description |
|
|
177
281
|
|----------|-------------|
|
|
282
|
+
| `NANO_BRAIN_CONFIG` | Path to YAML config file (12-factor; useful in Docker/k8s). Precedence: `--config` flag > `NANO_BRAIN_CONFIG` > `~/.nano-brain/config.yml`. Leading/trailing whitespace is stripped. If the env-pointed file does not exist, a `WARNING:` is printed to stderr and defaults are used (operator can spot typos). |
|
|
178
283
|
| `DATABASE_URL` | PostgreSQL connection string |
|
|
179
284
|
| `VOYAGE_API_KEY` | Voyage AI API key |
|
|
180
285
|
| `OPENCODE_DB_ROOT` | OpenCode per-project DB root directory (multi-DB mode) |
|
|
181
286
|
| `OPENCODE_DB_PATH` | OpenCode single SQLite database path |
|
|
182
287
|
| `OPENCODE_STORAGE_DIR` | OpenCode session directory (legacy) |
|
|
183
288
|
| `NANO_BRAIN_SUMMARIZE_API_KEY` | API key for the summarization LLM provider |
|
|
184
|
-
| `
|
|
289
|
+
| `NANO_BRAIN_AUTH_ENABLED` | Enable Basic Auth + Bearer Token (`true`/`false`) |
|
|
290
|
+
| `NANO_BRAIN_AUTH_TOKENS` | Comma-separated bearer tokens |
|
|
291
|
+
| `NANO_BRAIN_*` | Override any config field (e.g., `NANO_BRAIN_SERVER_PORT=3100`) |
|
|
292
|
+
|
|
293
|
+
**Docker example** — run the server in a container against a host PostgreSQL:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# /path/to/container-config.yml uses host.docker.internal for DB/Ollama
|
|
297
|
+
docker run -d \
|
|
298
|
+
-e NANO_BRAIN_CONFIG=/etc/nano-brain/config.yml \
|
|
299
|
+
-v /path/to/container-config.yml:/etc/nano-brain/config.yml:ro \
|
|
300
|
+
-p 3100:3100 \
|
|
301
|
+
nano-brain:latest
|
|
302
|
+
```
|
|
185
303
|
|
|
186
304
|
## REST API
|
|
187
305
|
|
|
@@ -193,6 +311,7 @@ Large sessions (100K+ tokens) are handled via map-reduce chunking — no session
|
|
|
193
311
|
| GET | `/api/status` | Server status with version, uptime, workspace stats |
|
|
194
312
|
| POST | `/api/v1/init` | Register workspace |
|
|
195
313
|
| GET | `/api/v1/workspaces` | List all workspaces (with doc counts) |
|
|
314
|
+
| DELETE | `/api/v1/workspaces/:hash` | Permanently delete a workspace + cascade docs/chunks/embeddings |
|
|
196
315
|
| GET | `/api/v1/wake-up` | Workspace briefing |
|
|
197
316
|
| POST | `/api/harvest` | Trigger session harvesting |
|
|
198
317
|
| POST | `/api/reload-config` | Hot-reload configuration |
|
|
@@ -213,6 +332,8 @@ Workspace is passed in the JSON body for POST, query param for GET.
|
|
|
213
332
|
| PUT | `/api/v1/collections/:name` | Rename collection |
|
|
214
333
|
| DELETE | `/api/v1/collections/:name` | Remove collection |
|
|
215
334
|
| GET | `/api/v1/tags` | List tags with counts |
|
|
335
|
+
| POST | `/api/v1/get` | Get single document by source_path or id |
|
|
336
|
+
| POST | `/api/v1/multi-get` | Batch fetch documents by paths or ids |
|
|
216
337
|
| POST | `/api/v1/reindex` | Queue reindex (202) |
|
|
217
338
|
| POST | `/api/v1/update` | Queue update (202) |
|
|
218
339
|
| POST | `/api/v1/summarize` | Trigger LLM summarization of harvested sessions |
|
|
@@ -231,24 +352,34 @@ Workspace is passed in the JSON body for POST, query param for GET.
|
|
|
231
352
|
|---------|-------------|
|
|
232
353
|
| `nano-brain` (no args) | Start HTTP server (default: port 3100) |
|
|
233
354
|
| `nano-brain init --root=<path>` | Register workspace |
|
|
355
|
+
| `nano-brain workspaces list` | List registered workspaces with doc counts |
|
|
356
|
+
| `nano-brain workspaces remove --workspace=<hash> [--dry-run\|--force]` | Permanently delete a workspace + all its documents/chunks/embeddings |
|
|
234
357
|
| `nano-brain write` | Write document via CLI |
|
|
235
|
-
| `nano-brain query` | Hybrid search |
|
|
236
|
-
| `nano-brain search` | BM25 keyword search |
|
|
237
|
-
| `nano-brain vsearch` | Vector similarity search |
|
|
358
|
+
| `nano-brain query [--scope=all] [--tags=t1,t2]` | Hybrid search (BM25 + vector + RRF + recency) |
|
|
359
|
+
| `nano-brain search [--scope=all] [--tags=t1,t2]` | BM25 keyword search |
|
|
360
|
+
| `nano-brain vsearch [--scope=all] [--tags=t1,t2]` | Vector similarity search |
|
|
361
|
+
| `nano-brain wake-up --workspace=<hash>` | Workspace briefing (collections, stats, recent memories) |
|
|
362
|
+
| `nano-brain get <source_path\|uuid> --workspace=<hash>` | Fetch a single document by source_path or UUID |
|
|
363
|
+
| `nano-brain tags --workspace=<hash>` | List all tags with document counts |
|
|
364
|
+
| `nano-brain multi-get --workspace=<hash> --paths=p1,p2` | Fetch multiple documents in one round-trip |
|
|
238
365
|
| `nano-brain collection add\|remove\|list` | Manage collections |
|
|
239
366
|
| `nano-brain harvest` | Trigger session harvesting |
|
|
367
|
+
| `nano-brain backfill-summaries [--dry-run] [--workspace=] [--since=]` | Export existing DB summaries to disk (.md files for Obsidian etc.) |
|
|
240
368
|
| `nano-brain cleanup-stale-raw [--dry-run]` | Delete pre-#192 raw OpenCode session docs superseded by summaries |
|
|
369
|
+
| `nano-brain cleanup-orphan-workspaces [--dry-run]` | Delete documents/chunks under workspace_hash values not registered in `workspaces`. Run BEFORE migration 00011 (issue #238). |
|
|
241
370
|
| `nano-brain bench generate\|run\|compare\|stress` | Benchmarking suite |
|
|
242
371
|
| `nano-brain db:migrate` | Run pending goose migrations |
|
|
243
372
|
| `nano-brain db:migrate --from-v1 <path>` | Import V1 SQLite data |
|
|
244
373
|
| `nano-brain logs [-n 50] [-f]` | Tail log file |
|
|
245
374
|
| `nano-brain docker start\|stop\|status` | Docker compose management |
|
|
246
375
|
| `nano-brain status [--json]` | Server status |
|
|
376
|
+
| `nano-brain auth hash <password>` | Generate bcrypt password hash for config |
|
|
377
|
+
| `nano-brain auth token` | Generate random bearer token (`nbt_`-prefixed) |
|
|
247
378
|
| `nano-brain doctor [--json]` | Check prerequisites (config, PostgreSQL, pgvector, Ollama, model) |
|
|
248
379
|
|
|
249
380
|
## MCP Tools
|
|
250
381
|
|
|
251
|
-
nano-brain exposes
|
|
382
|
+
nano-brain exposes 13 tools via MCP (Model Context Protocol):
|
|
252
383
|
|
|
253
384
|
| Tool | Description |
|
|
254
385
|
|------|-------------|
|
|
@@ -261,6 +392,10 @@ nano-brain exposes 9 tools via MCP (Model Context Protocol):
|
|
|
261
392
|
| `memory_status` | Server and embedding status |
|
|
262
393
|
| `memory_update` | Trigger re-embedding |
|
|
263
394
|
| `memory_wake_up` | Workspace briefing |
|
|
395
|
+
| `memory_graph` | Knowledge graph view (module → function → dep) |
|
|
396
|
+
| `memory_trace` | Call chain trace from entry point |
|
|
397
|
+
| `memory_impact` | Cross-file change impact analysis |
|
|
398
|
+
| `memory_symbols` | Symbol search (functions, types, constants) |
|
|
264
399
|
|
|
265
400
|
### MCP Configuration
|
|
266
401
|
|