@nano-step/nano-brain 2026.5.3101 → 2026.5.3103

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 (2) hide show
  1. package/README.md +94 -6
  2. 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,72 @@ summarization:
142
145
  concurrency: 3 # parallel map-phase LLM calls
143
146
  ```
144
147
 
148
+ ### Global ignore patterns (`~/.nano-brain/.nano-brainignore`)
149
+
150
+ The watcher loads a global gitignore-style file at `~/.nano-brain/.nano-brainignore`
151
+ on startup. Patterns in this file apply to **all** registered collections, removing
152
+ the need to repeat the same exclusions in each `watcher.workspaces` block.
153
+
154
+ **Format**: standard `.gitignore` syntax (one pattern per line, supports `**`, `!negation`, blank lines, `#` comments).
155
+
156
+ **Example** `~/.nano-brain/.nano-brainignore`:
157
+
158
+ ```
159
+ # Skip generated files everywhere
160
+ *.png
161
+ *.jpg
162
+ *.pdf
163
+ build/
164
+ dist/
165
+ node_modules/
166
+
167
+ # But keep this one icon
168
+ !icons/important.png
169
+ ```
170
+
171
+ **Order of evaluation** (most aggressive first):
172
+
173
+ 1. Hardcoded default exclude dirs (`node_modules`, `.git`, `dist`, `build`, `target`, etc.)
174
+ 2. **Global `.nano-brainignore`** (this feature)
175
+ 3. Per-collection `.gitignore` (in collection root)
176
+ 4. Per-collection `exclude_patterns` (config-level)
177
+ 5. Per-collection `allowed_extensions` (whitelist)
178
+
179
+ **Restart required**: changes to `.nano-brainignore` take effect on next server start (hot-reload deferred to a follow-up). Issue #263.
180
+
145
181
  ### Session Summarization
146
182
 
147
183
  When `summarization.enabled: true`, nano-brain automatically generates structured markdown summaries of each harvested session using an OpenAI-compatible LLM provider. Summaries are:
148
184
 
149
185
  - Stored in PostgreSQL under collection `session-summary` for semantic search via the standard query/vsearch API (PG is the source of truth)
186
+ - Optionally written to disk as Markdown files for Obsidian-compatible access (see [Disk persistence](#disk-persistence-obsidian-compatible) below)
150
187
  - Idempotent — unchanged sessions are skipped; re-harvested sessions overwrite old summaries
151
188
 
152
- > **Note**: as of `harvest-summary-only` (May 2026), summaries are no longer written to disk as `.md` files. The legacy `output_dir` YAML key is silently ignored for backward compat. Any pre-existing files under `~/.nano-brain/summaries/` are stale artifacts and can be safely deleted.
189
+ #### Disk persistence (Obsidian-compatible)
190
+
191
+ By default, summaries are written to disk as Markdown files at the path configured in
192
+ `summarization.output_dir` (default: `~/.nano-brain/summaries`). The file layout is:
193
+
194
+ ```
195
+ <output_dir>/<workspace_name>/<source>_<slugified-title>_<YYYY-MM-DD>.md
196
+ ```
197
+
198
+ Files are byte-identical to the `documents.content` field in PostgreSQL — disk is a
199
+ derivative view, DB is source of truth. Disk write failures (permission denied, disk
200
+ full) log a WARN but do not roll back the DB transaction.
201
+
202
+ To opt out (DB-only persistence):
203
+
204
+ ```yaml
205
+ summarization:
206
+ write_to_disk: false
207
+ ```
208
+
209
+ To backfill historical summaries already in the DB:
210
+
211
+ ```
212
+ nano-brain backfill-summaries
213
+ ```
153
214
 
154
215
  **Quick setup with ai-proxy:**
155
216
 
@@ -175,13 +236,25 @@ Large sessions (100K+ tokens) are handled via map-reduce chunking — no session
175
236
 
176
237
  | Variable | Description |
177
238
  |----------|-------------|
239
+ | `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
240
  | `DATABASE_URL` | PostgreSQL connection string |
179
241
  | `VOYAGE_API_KEY` | Voyage AI API key |
180
242
  | `OPENCODE_DB_ROOT` | OpenCode per-project DB root directory (multi-DB mode) |
181
243
  | `OPENCODE_DB_PATH` | OpenCode single SQLite database path |
182
244
  | `OPENCODE_STORAGE_DIR` | OpenCode session directory (legacy) |
183
245
  | `NANO_BRAIN_SUMMARIZE_API_KEY` | API key for the summarization LLM provider |
184
- | `NANO_BRAIN_*` | Override any config (e.g., `NANO_BRAIN_SERVER_PORT=3100`) |
246
+ | `NANO_BRAIN_*` | Override any config field (e.g., `NANO_BRAIN_SERVER_PORT=3100`) |
247
+
248
+ **Docker example** — run the server in a container against a host PostgreSQL:
249
+
250
+ ```bash
251
+ # /path/to/container-config.yml uses host.docker.internal for DB/Ollama
252
+ docker run -d \
253
+ -e NANO_BRAIN_CONFIG=/etc/nano-brain/config.yml \
254
+ -v /path/to/container-config.yml:/etc/nano-brain/config.yml:ro \
255
+ -p 3100:3100 \
256
+ nano-brain:latest
257
+ ```
185
258
 
186
259
  ## REST API
187
260
 
@@ -193,6 +266,7 @@ Large sessions (100K+ tokens) are handled via map-reduce chunking — no session
193
266
  | GET | `/api/status` | Server status with version, uptime, workspace stats |
194
267
  | POST | `/api/v1/init` | Register workspace |
195
268
  | GET | `/api/v1/workspaces` | List all workspaces (with doc counts) |
269
+ | DELETE | `/api/v1/workspaces/:hash` | Permanently delete a workspace + cascade docs/chunks/embeddings |
196
270
  | GET | `/api/v1/wake-up` | Workspace briefing |
197
271
  | POST | `/api/harvest` | Trigger session harvesting |
198
272
  | POST | `/api/reload-config` | Hot-reload configuration |
@@ -213,6 +287,8 @@ Workspace is passed in the JSON body for POST, query param for GET.
213
287
  | PUT | `/api/v1/collections/:name` | Rename collection |
214
288
  | DELETE | `/api/v1/collections/:name` | Remove collection |
215
289
  | GET | `/api/v1/tags` | List tags with counts |
290
+ | POST | `/api/v1/get` | Get single document by source_path or id |
291
+ | POST | `/api/v1/multi-get` | Batch fetch documents by paths or ids |
216
292
  | POST | `/api/v1/reindex` | Queue reindex (202) |
217
293
  | POST | `/api/v1/update` | Queue update (202) |
218
294
  | POST | `/api/v1/summarize` | Trigger LLM summarization of harvested sessions |
@@ -231,13 +307,21 @@ Workspace is passed in the JSON body for POST, query param for GET.
231
307
  |---------|-------------|
232
308
  | `nano-brain` (no args) | Start HTTP server (default: port 3100) |
233
309
  | `nano-brain init --root=<path>` | Register workspace |
310
+ | `nano-brain workspaces list` | List registered workspaces with doc counts |
311
+ | `nano-brain workspaces remove --workspace=<hash> [--dry-run\|--force]` | Permanently delete a workspace + all its documents/chunks/embeddings |
234
312
  | `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 |
313
+ | `nano-brain query [--scope=all] [--tags=t1,t2]` | Hybrid search (BM25 + vector + RRF + recency) |
314
+ | `nano-brain search [--scope=all] [--tags=t1,t2]` | BM25 keyword search |
315
+ | `nano-brain vsearch [--scope=all] [--tags=t1,t2]` | Vector similarity search |
316
+ | `nano-brain wake-up --workspace=<hash>` | Workspace briefing (collections, stats, recent memories) |
317
+ | `nano-brain get <source_path\|uuid> --workspace=<hash>` | Fetch a single document by source_path or UUID |
318
+ | `nano-brain tags --workspace=<hash>` | List all tags with document counts |
319
+ | `nano-brain multi-get --workspace=<hash> --paths=p1,p2` | Fetch multiple documents in one round-trip |
238
320
  | `nano-brain collection add\|remove\|list` | Manage collections |
239
321
  | `nano-brain harvest` | Trigger session harvesting |
322
+ | `nano-brain backfill-summaries [--dry-run] [--workspace=] [--since=]` | Export existing DB summaries to disk (.md files for Obsidian etc.) |
240
323
  | `nano-brain cleanup-stale-raw [--dry-run]` | Delete pre-#192 raw OpenCode session docs superseded by summaries |
324
+ | `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
325
  | `nano-brain bench generate\|run\|compare\|stress` | Benchmarking suite |
242
326
  | `nano-brain db:migrate` | Run pending goose migrations |
243
327
  | `nano-brain db:migrate --from-v1 <path>` | Import V1 SQLite data |
@@ -248,7 +332,7 @@ Workspace is passed in the JSON body for POST, query param for GET.
248
332
 
249
333
  ## MCP Tools
250
334
 
251
- nano-brain exposes 9 tools via MCP (Model Context Protocol):
335
+ nano-brain exposes 13 tools via MCP (Model Context Protocol):
252
336
 
253
337
  | Tool | Description |
254
338
  |------|-------------|
@@ -261,6 +345,10 @@ nano-brain exposes 9 tools via MCP (Model Context Protocol):
261
345
  | `memory_status` | Server and embedding status |
262
346
  | `memory_update` | Trigger re-embedding |
263
347
  | `memory_wake_up` | Workspace briefing |
348
+ | `memory_graph` | Knowledge graph view (module → function → dep) |
349
+ | `memory_trace` | Call chain trace from entry point |
350
+ | `memory_impact` | Cross-file change impact analysis |
351
+ | `memory_symbols` | Symbol search (functions, types, constants) |
264
352
 
265
353
  ### MCP Configuration
266
354
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano-step/nano-brain",
3
- "version": "2026.5.3101",
3
+ "version": "2026.5.3103",
4
4
  "description": "Persistent memory and code intelligence for AI coding agents",
5
5
  "bin": {
6
6
  "nano-brain": "npm/run.js"