@andespindola/brainlink 0.1.0-beta.1 → 0.1.0-beta.100
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/AGENTS.md +8 -5
- package/CHANGELOG.md +72 -2
- package/CONTRIBUTING.md +2 -2
- package/COPYRIGHT.md +5 -0
- package/README.md +374 -24
- package/SECURITY.md +1 -1
- package/dist/application/add-note.js +62 -13
- package/dist/application/analyze-vault.js +95 -8
- package/dist/application/build-context.js +56 -1
- package/dist/application/dedupe-notes.js +226 -0
- package/dist/application/frontend/client-css.js +230 -99
- package/dist/application/frontend/client-html.js +62 -44
- package/dist/application/frontend/client-js.js +3331 -163
- package/dist/application/frontend/client-worker-js.js +66 -0
- package/dist/application/get-graph-layout.js +22 -7
- package/dist/application/get-graph-node.js +12 -0
- package/dist/application/get-graph-summary.js +12 -0
- package/dist/application/get-graph.js +3 -3
- package/dist/application/import-legacy-sqlite.js +296 -0
- package/dist/application/index-vault.js +252 -19
- package/dist/application/list-agents.js +3 -3
- package/dist/application/list-links.js +5 -5
- package/dist/application/migrate-vault.js +91 -0
- package/dist/application/offline-pack-backup.js +44 -0
- package/dist/application/search-graph-node-ids.js +12 -0
- package/dist/application/search-knowledge.js +75 -5
- package/dist/application/server/routes.js +102 -1
- package/dist/application/start-server.js +75 -4
- package/dist/application/watch-vault.js +23 -2
- package/dist/benchmarks/large-vault.js +1 -1
- package/dist/cli/commands/agent-commands.js +419 -0
- package/dist/cli/commands/config-commands.js +167 -0
- package/dist/cli/commands/read-commands.js +25 -8
- package/dist/cli/commands/write-commands.js +989 -10
- package/dist/cli/main.js +4 -0
- package/dist/cli/runtime.js +5 -2
- package/dist/domain/context.js +53 -11
- package/dist/domain/embeddings.js +2 -1
- package/dist/domain/graph-layout.js +67 -16
- package/dist/domain/markdown.js +36 -4
- package/dist/domain/middle-out.js +18 -0
- package/dist/infrastructure/config.js +132 -8
- package/dist/infrastructure/file-index.js +358 -0
- package/dist/infrastructure/file-system-vault.js +30 -0
- package/dist/infrastructure/index-state.js +56 -0
- package/dist/infrastructure/paths.js +9 -1
- package/dist/infrastructure/private-pack-codec.js +134 -0
- package/dist/infrastructure/search-packs.js +452 -0
- package/dist/infrastructure/session-state.js +172 -0
- package/dist/mcp/main.js +11 -3
- package/dist/mcp/server.js +27 -2
- package/dist/mcp/startup.js +35 -0
- package/dist/mcp/tools.js +633 -19
- package/docs/AGENT_USAGE.md +180 -16
- package/docs/ARCHITECTURE.md +37 -26
- package/docs/QUICKSTART.md +111 -0
- package/docs/RELEASE.md +3 -3
- package/package.json +6 -4
- package/dist/infrastructure/sqlite/document-writer.js +0 -51
- package/dist/infrastructure/sqlite/graph-reader.js +0 -120
- package/dist/infrastructure/sqlite/schema.js +0 -111
- package/dist/infrastructure/sqlite/search-reader.js +0 -156
- package/dist/infrastructure/sqlite/types.js +0 -1
- package/dist/infrastructure/sqlite-index.js +0 -25
package/README.md
CHANGED
|
@@ -52,11 +52,15 @@ LLMs do not have infinite context. Brainlink gives agents an external memory lay
|
|
|
52
52
|
1. Durable knowledge is written as Markdown.
|
|
53
53
|
2. Notes are connected with `[[wiki links]]`.
|
|
54
54
|
3. Concepts are classified with `#tags`.
|
|
55
|
-
4. Brainlink builds a local
|
|
55
|
+
4. Brainlink builds a local JSON index (`.brainlink/index.json`) and private encrypted search packs.
|
|
56
56
|
5. Agents query the index before responding.
|
|
57
57
|
6. Brainlink returns compact, source-backed context.
|
|
58
58
|
|
|
59
|
-
Markdown is the source of truth. `.brainlink/
|
|
59
|
+
Markdown is the source of truth. `.brainlink/index.json` is a rebuildable index artifact.
|
|
60
|
+
After each index run, Brainlink also writes private encrypted search packs at `.brainlink/search-packs/*.blpk` to preserve fast retrieval and portable recovery.
|
|
61
|
+
Online retrieval always uses a single compression stage per pack; optional second-stage compression is reserved for offline backup artifacts only.
|
|
62
|
+
Pack decryption uses a Brainlink key from `$BRAINLINK_HOME/keys` or from `BRAINLINK_SEARCH_PACK_KEY` when explicitly configured.
|
|
63
|
+
Legacy `.jsonl.gz` packs are upgraded to `.blpk` automatically on first search/context access.
|
|
60
64
|
|
|
61
65
|
## Features
|
|
62
66
|
|
|
@@ -64,8 +68,12 @@ Markdown is the source of truth. `.brainlink/brainlink.db` is only a rebuildable
|
|
|
64
68
|
- Obsidian-compatible `[[wiki links]]` and `#tags`.
|
|
65
69
|
- Weighted graph edges so agents can rank relationship importance and priority.
|
|
66
70
|
- Backlinks, broken-link reports, orphan detection and validation.
|
|
67
|
-
- Full-text, semantic and hybrid retrieval
|
|
68
|
-
-
|
|
71
|
+
- Full-text, semantic and hybrid retrieval on a local file index.
|
|
72
|
+
- Middle-out context assembly around the strongest chunk per document.
|
|
73
|
+
- In-process index and context caching with automatic invalidation on index updates.
|
|
74
|
+
- Compressed-space prefiltering for `.blpk` packs before decryption and scan.
|
|
75
|
+
- Incremental indexing that reprocesses only changed markdown files and reuses existing chunks/embeddings for unchanged notes.
|
|
76
|
+
- Adaptive compressed-pack rebuild policy to keep indexing fast during small edit batches.
|
|
69
77
|
- Agent namespaces under `agents/<agent-id>/`.
|
|
70
78
|
- S3-compatible bucket vaults through `s3://bucket/prefix` URIs.
|
|
71
79
|
- CLI with machine-readable `--json` output.
|
|
@@ -73,6 +81,17 @@ Markdown is the source of truth. `.brainlink/brainlink.db` is only a rebuildable
|
|
|
73
81
|
- Built-in MCP stdio server for agent tool integration.
|
|
74
82
|
- Local HTTP API.
|
|
75
83
|
- Realtime graph UI with agent selector and colored knowledge groups.
|
|
84
|
+
- Graph renderer optimized for large datasets with viewport-driven node culling and edge lookup by visible nodes.
|
|
85
|
+
- Canvas graph rendering uses the same batched node and edge pipeline for every graph size, reducing per-frame draw calls while keeping selected and hovered items highlighted.
|
|
86
|
+
- WebGL acceleration is used when available for dense node and edge drawing, with Canvas 2D preserved as the interaction and fallback layer.
|
|
87
|
+
- Graph zoom-out renders hierarchical ecosystem subgraphs only above 1000 notes: the memory hub stays centered, 1000-note groups stay as compact sand-like points, and focused groups gradually expand into smaller graph meshes before individual notes are rendered.
|
|
88
|
+
- Large graph layout API automatically uses compact payload encoding with link-coverage-aware edge selection to reduce initial client load without hiding major relationships.
|
|
89
|
+
- Large-segment layout spacing now grows logarithmically to keep initial visual density consistent between medium and very large vaults (for example, ~1k vs ~50k notes).
|
|
90
|
+
- Graph coordinates are visually compacted across graph sizes so reset starts from a stable macro mass and zoom-in progressively expands toward local detail.
|
|
91
|
+
- Zoomed-out graph LOD renders nested subgraphs and progressively expands only the focused cluster as zoom increases, including very large vaults.
|
|
92
|
+
- Graph reset starts in macro "galaxy" overview mode and progressively reveals nearby nodes as zoom increases, including smaller vaults.
|
|
93
|
+
- Graph filtering runs in a dedicated browser worker to keep the UI thread responsive during heavy datasets.
|
|
94
|
+
- Edge rendering budgets adapt to zoom level to prevent frame spikes on large graph panoramas.
|
|
76
95
|
|
|
77
96
|
## Install
|
|
78
97
|
|
|
@@ -106,6 +125,8 @@ npx @andespindola/brainlink@latest --help
|
|
|
106
125
|
|
|
107
126
|
This section is written for agents. If you are an AI agent operating in a user workspace, use this workflow to install and use Brainlink without requiring the user to run commands manually.
|
|
108
127
|
|
|
128
|
+
For a condensed setup path, see [docs/QUICKSTART.md](./docs/QUICKSTART.md).
|
|
129
|
+
|
|
109
130
|
### 1. Check Whether Brainlink Is Installed
|
|
110
131
|
|
|
111
132
|
```bash
|
|
@@ -280,7 +301,7 @@ export BRAINLINK_S3_FORCE_PATH_STYLE=1
|
|
|
280
301
|
|
|
281
302
|
Bucket vaults mirror Markdown into a local cache under
|
|
282
303
|
`$BRAINLINK_HOME/bucket-cache`. The bucket remains canonical; the local
|
|
283
|
-
`.brainlink/
|
|
304
|
+
`.brainlink/index.json` stays a disposable index artifact. Run `index` after remote
|
|
284
305
|
bucket changes before relying on `search`, `context`, graph or validation
|
|
285
306
|
commands. Watch mode is only supported for local filesystem vaults.
|
|
286
307
|
|
|
@@ -296,7 +317,7 @@ vault/
|
|
|
296
317
|
research-agent/
|
|
297
318
|
source-review-policy.md
|
|
298
319
|
.brainlink/
|
|
299
|
-
|
|
320
|
+
index.json
|
|
300
321
|
```
|
|
301
322
|
|
|
302
323
|
Permanent data:
|
|
@@ -306,7 +327,7 @@ Permanent data:
|
|
|
306
327
|
|
|
307
328
|
Rebuildable data:
|
|
308
329
|
|
|
309
|
-
- `.brainlink/
|
|
330
|
+
- `.brainlink/index.json`
|
|
310
331
|
- full-text records
|
|
311
332
|
- local embedding vectors
|
|
312
333
|
- local embedding buckets
|
|
@@ -380,19 +401,157 @@ Example MCP client configuration:
|
|
|
380
401
|
}
|
|
381
402
|
```
|
|
382
403
|
|
|
404
|
+
### One-Command Agent Setup
|
|
405
|
+
|
|
406
|
+
If your agent runtime is Codex-compatible, run:
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
blink agent install --self-test
|
|
410
|
+
blink agent upgrade
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
This configures `~/.codex/config.toml` with Brainlink MCP (`brainlink-mcp`) so Brainlink is available by default in agent sessions.
|
|
414
|
+
`agent install` and `agent upgrade` also apply the MCP `fully-auto` bootstrap policy by default (`enforceBootstrap`, `enforceContextFirst`, `autoBootstrapOnRead`, `autoBootstrapOnStartup` all enabled).
|
|
415
|
+
|
|
416
|
+
If you are inside this repository and want plugin gallery setup too:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
blink agent install --plugin-path ./plugins/brainlink
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
To verify:
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
blink agent status
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
For fully automated first run (vault index + health + bootstrap readiness + agent integration):
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
blink quickstart --query "what should I know before this task?" --json
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
For a locked-down setup, allowlist the vaults that MCP clients may access:
|
|
435
|
+
|
|
436
|
+
```json
|
|
437
|
+
{
|
|
438
|
+
"mcpServers": {
|
|
439
|
+
"brainlink": {
|
|
440
|
+
"command": "brainlink-mcp",
|
|
441
|
+
"env": {
|
|
442
|
+
"BRAINLINK_ALLOWED_VAULTS": "/absolute/path/to/project-vault,/absolute/path/to/team-vault"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Install In MCP Client Stores
|
|
450
|
+
|
|
451
|
+
Brainlink can be exposed to MCP-compatible client stores in two ways:
|
|
452
|
+
|
|
453
|
+
1. Register the stdio server directly when the client accepts `mcpServers` configuration.
|
|
454
|
+
2. Register the local plugin from this repository when the client supports a plugin gallery or local marketplace.
|
|
455
|
+
|
|
456
|
+
Direct MCP server setup:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
npm install -g @andespindola/brainlink@latest
|
|
460
|
+
command -v brainlink-mcp
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Use this server configuration in any MCP-compatible client that reads a JSON MCP manifest:
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"mcpServers": {
|
|
468
|
+
"brainlink": {
|
|
469
|
+
"command": "brainlink-mcp"
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Local plugin gallery setup:
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
npm install -g @andespindola/brainlink@latest
|
|
479
|
+
git clone https://github.com/andersonflima/brainlink.git "$HOME/brainlink"
|
|
480
|
+
mkdir -p "$HOME/plugins"
|
|
481
|
+
ln -s "$HOME/brainlink/plugins/brainlink" "$HOME/plugins/brainlink"
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Then register the plugin in the local marketplace file used by compatible clients:
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
node <<'NODE'
|
|
488
|
+
const fs = require('node:fs')
|
|
489
|
+
const os = require('node:os')
|
|
490
|
+
const path = require('node:path')
|
|
491
|
+
|
|
492
|
+
const marketplacePath = path.join(os.homedir(), '.agents', 'plugins', 'marketplace.json')
|
|
493
|
+
const pluginEntry = {
|
|
494
|
+
name: 'brainlink',
|
|
495
|
+
source: {
|
|
496
|
+
source: 'local',
|
|
497
|
+
path: './plugins/brainlink'
|
|
498
|
+
},
|
|
499
|
+
policy: {
|
|
500
|
+
installation: 'AVAILABLE',
|
|
501
|
+
authentication: 'ON_INSTALL'
|
|
502
|
+
},
|
|
503
|
+
category: 'Productivity'
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
fs.mkdirSync(path.dirname(marketplacePath), { recursive: true })
|
|
507
|
+
|
|
508
|
+
const marketplace = fs.existsSync(marketplacePath)
|
|
509
|
+
? JSON.parse(fs.readFileSync(marketplacePath, 'utf8'))
|
|
510
|
+
: {
|
|
511
|
+
name: 'local',
|
|
512
|
+
interface: {
|
|
513
|
+
displayName: 'Local'
|
|
514
|
+
},
|
|
515
|
+
plugins: []
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const plugins = Array.isArray(marketplace.plugins) ? marketplace.plugins : []
|
|
519
|
+
marketplace.plugins = [...plugins.filter((plugin) => plugin?.name !== 'brainlink'), pluginEntry]
|
|
520
|
+
|
|
521
|
+
fs.writeFileSync(marketplacePath, `${JSON.stringify(marketplace, null, 2)}\n`)
|
|
522
|
+
NODE
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
Restart the client after changing marketplace or MCP configuration so it reloads the Brainlink entry. The plugin starts `brainlink-mcp` and exposes the same tool set listed below.
|
|
526
|
+
|
|
383
527
|
Available tools:
|
|
384
528
|
|
|
529
|
+
- `brainlink_bootstrap`: plug-and-play entrypoint that runs index + health checks and can return context in one call.
|
|
530
|
+
- `brainlink_policy`: read or update bootstrap/context-first policy, including presets (`preset: "fully-auto" | "strict"`).
|
|
531
|
+
- `brainlink_recommendations`: return an automatic action plan so agents can run Brainlink in the recommended order.
|
|
385
532
|
- `brainlink_context`: read indexed context for a task or question.
|
|
386
533
|
- `brainlink_search`: search indexed notes.
|
|
534
|
+
- `brainlink_dedupe`: detect duplicate candidates using exact hash + semantic similarity scores.
|
|
535
|
+
- `brainlink_resolve_duplicate`: resolve duplicate pairs (`merge`, `link`, `ignore`) with connectivity-safe fallback edges.
|
|
387
536
|
- `brainlink_add_note`: write durable Markdown memory and reindex.
|
|
388
537
|
- `brainlink_add_file`: ingest a local file as a note and reindex.
|
|
389
538
|
- `brainlink_index`: rebuild the vault index.
|
|
539
|
+
- `brainlink_stats`: read indexed vault statistics.
|
|
390
540
|
- `brainlink_validate`: validate broken links and orphan notes.
|
|
541
|
+
- `brainlink_sync`: run index, stats, validation, broken-link and orphan checks in one call.
|
|
391
542
|
- `brainlink_graph`: read indexed graph nodes and weighted links.
|
|
392
543
|
- `brainlink_broken_links`: list unresolved wiki links.
|
|
393
544
|
- `brainlink_orphans`: list disconnected notes.
|
|
394
545
|
|
|
395
|
-
|
|
546
|
+
For the most automatic workflow, start MCP sessions with `brainlink_bootstrap` (optionally with `query`) and then continue with `brainlink_context`/`brainlink_add_note`.
|
|
547
|
+
By default, Brainlink enforces context-first for MCP reads (`enforceContextFirst=true`): non-context read tools return preflight until `brainlink_context` is called for the vault/agent session.
|
|
548
|
+
By default, MCP startup already runs bootstrap on the configured default vault/agent (`autoBootstrapOnStartup=true`), so sessions begin warm.
|
|
549
|
+
By default, Brainlink enforces bootstrap and auto-runs it for read tools when session state is missing or stale (`autoBootstrapOnRead=true`).
|
|
550
|
+
If you disable `autoBootstrapOnRead` through `brainlink_policy`, read tools return a preflight instruction with suggested `brainlink_bootstrap` arguments.
|
|
551
|
+
`brainlink_bootstrap`, `brainlink_policy` and preflight responses include structured `nextActions` so MCP clients can continue automatically without custom parsing.
|
|
552
|
+
For one-call planning, use `brainlink_recommendations` to get the recommended tool sequence for the current vault/agent/query.
|
|
553
|
+
|
|
554
|
+
The same linking rule applies through MCP: `brainlink_context` is read-only, and real graph links require Markdown notes with explicit `[[wiki links]]`. `brainlink_add_note` and `brainlink_add_file` reindex by default and include index + `writeConnectivity` metadata. Brainlink guarantees at least one edge per new note by auto-linking when needed.
|
|
396
555
|
|
|
397
556
|
Agents can raise the importance of a relationship by putting priority markers on the same line as a wiki link:
|
|
398
557
|
|
|
@@ -412,16 +571,38 @@ blink server --host 127.0.0.1 --port 4321 --watch
|
|
|
412
571
|
```
|
|
413
572
|
|
|
414
573
|
By default, the server uses `$HOME/.brainlink/vault`. Pass `--vault ./vault` only when you want to inspect a custom vault.
|
|
574
|
+
By default, `blink server` tries to open the graph in a native desktop GUI window:
|
|
575
|
+
- macOS: Swift + WebKit
|
|
576
|
+
- Windows: PowerShell WinForms WebBrowser
|
|
577
|
+
- Linux: optional Python GTK + WebKit2 (requires `python3` + `gi` + `WebKit2`)
|
|
578
|
+
|
|
579
|
+
On Linux, native GUI is disabled by default for better startup performance. Enable it with `BRAINLINK_LINUX_NATIVE_GUI=1`.
|
|
580
|
+
If native GUI launch is unavailable on your system, it falls back to dedicated app-window mode and then to the default browser.
|
|
581
|
+
For Chromium-family browsers on Linux (`chromium`, `chromium-browser`, `google-chrome`, `microsoft-edge`, `brave-browser`), Brainlink now auto-applies compatibility flags during launch (`--ozone-platform=x11`, `--ozone-platform-hint=x11`, `--disable-gpu`, `--disable-vulkan`, `--use-gl=swiftshader`, `--disable-features=Vulkan,VaapiVideoDecoder`, `--disable-background-networking`) to avoid common Wayland/Vulkan/VAAPI startup issues.
|
|
582
|
+
On Linux, Brainlink opens the graph through the system default browser first (`xdg-open`), then `$BROWSER`/detected browsers as fallback. Chromium-family app-window mode is optional via `BRAINLINK_LINUX_APP_WINDOW=1`.
|
|
583
|
+
Use `--no-open` to keep it headless.
|
|
584
|
+
When native GUI is used, the GUI window automatically closes when the `blink server` process stops.
|
|
415
585
|
|
|
416
586
|
The graph UI shows:
|
|
417
587
|
|
|
418
588
|
- notes as nodes
|
|
419
589
|
- `[[wiki links]]` as weighted edges
|
|
420
|
-
-
|
|
421
|
-
- full Markdown content for the selected note
|
|
590
|
+
- details opened on node click (tags, outgoing links, backlinks, full Markdown content)
|
|
422
591
|
- neutral graph nodes with segment/group metadata
|
|
423
|
-
- agent selector for isolated views
|
|
592
|
+
- agent selector (id-only labels) for isolated views
|
|
593
|
+
- graph filter matches title, path, tags and note content
|
|
594
|
+
- graph filter keeps hub context nodes visible (`Memory Hub`/`MOC`/high-degree fallback) to preserve relationship readability
|
|
424
595
|
- realtime refresh while `--watch` is enabled
|
|
596
|
+
- graph controls for zoom in, zoom out, fit visible nodes and reset-to-fit-all
|
|
597
|
+
- wheel zoom (including `cmd+scroll` and `ctrl+scroll`) anchored to cursor position for faster navigation in large graphs
|
|
598
|
+
- keyboard shortcuts: `+` zoom in, `-` zoom out, `0` reset fit
|
|
599
|
+
- double-click on canvas zooms in at cursor position
|
|
600
|
+
- floating graph totals (notes, links, tags) below the Brainlink title
|
|
601
|
+
- graph rendering safeguards (batched canvas drawing across graph sizes, edge draw caps, lower redraw rate, zoom-aware interaction)
|
|
602
|
+
- WebGL node and edge acceleration when supported, falling back to Canvas 2D without changing graph behavior
|
|
603
|
+
- compact macro-to-micro density progression so reset keeps the graph mass oriented and zoom-in separates local neighborhoods progressively
|
|
604
|
+
- graph camera treats hub-centered navigation as structural only when the hub is dominant; diffuse stress graphs reset and zoom around the full graph mass
|
|
605
|
+
- graph LOD progression: graphs up to 1000 notes render directly; larger graphs use one recursive model where each visible level targets up to 999 non-hub nodes, starts from a memory-hub-centered mesh, and each supernode can expand into another same-shape subgraph level (again up to 999 children) with latent fade-in, aggregated real links and local sibling mesh links so org-heavy and stress-50k follow the same structure at different depths; for massive graphs the first expansion starts much deeper in zoom, low-size child levels use slower easing, and expansion is additionally gated by focus readiness (screen-space isolation of the focused parent) so child levels open only when that subgraph is truly centered and separated in view
|
|
425
606
|
|
|
426
607
|
The server indexes before starting by default. Use `--no-index` to skip that step:
|
|
427
608
|
|
|
@@ -440,6 +621,7 @@ Routes:
|
|
|
440
621
|
- `GET /api/agents`
|
|
441
622
|
- `GET /api/graph`
|
|
442
623
|
- `GET /api/graph-layout`
|
|
624
|
+
- `GET /api/graph-node?id=<node-id>`
|
|
443
625
|
- `GET /api/search?q=<query>&limit=10&mode=hybrid`
|
|
444
626
|
- `GET /api/context?q=<query>&limit=12&tokens=2000&mode=hybrid`
|
|
445
627
|
- `GET /api/links`
|
|
@@ -461,14 +643,89 @@ Read routes accept `agent=<agent-id>`:
|
|
|
461
643
|
|
|
462
644
|
Every command works with either `brainlink` or `blink`.
|
|
463
645
|
|
|
646
|
+
### `agent`
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
blink agent install
|
|
650
|
+
blink agent install --self-test
|
|
651
|
+
blink agent upgrade
|
|
652
|
+
blink agent policy --preset fully-auto
|
|
653
|
+
blink agent policy --preset strict
|
|
654
|
+
blink agent policy --enforce-context-first false
|
|
655
|
+
blink agent install --plugin-path ./plugins/brainlink
|
|
656
|
+
blink agent install --mcp-only --allowed-vaults "/absolute/vault,/absolute/team-vault"
|
|
657
|
+
blink agent status
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
Installs/checks agent integration. `install` writes Brainlink MCP config into `~/.codex/config.toml`.
|
|
661
|
+
When plugin files are available, it also links Brainlink plugin files into `~/plugins/brainlink` and updates `~/.agents/plugins/marketplace.json`.
|
|
662
|
+
With `--self-test`, install also validates MCP block presence, command wiring and local plugin registration signals.
|
|
663
|
+
Use `agent upgrade` on legacy installations to reapply current defaults and run the same self-test diagnostics.
|
|
664
|
+
Use `agent policy --preset fully-auto` for plug-and-play defaults, or `agent policy --preset strict` to require explicit bootstrap calls.
|
|
665
|
+
Both presets keep `enforceContextFirst=true` so Brainlink stays the primary context source for MCP sessions.
|
|
666
|
+
|
|
667
|
+
### `quickstart`
|
|
668
|
+
|
|
669
|
+
```bash
|
|
670
|
+
blink quickstart --json
|
|
671
|
+
blink quickstart --vault ./team-vault --agent coding-agent --query "architecture decisions" --json
|
|
672
|
+
blink quickstart --vault ./team-vault --mcp-only --json
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
Runs index + doctor + stats + validation, refreshes bootstrap session readiness, optionally returns context for a query, and (by default) upgrades local agent integration for plug-and-play MCP usage.
|
|
676
|
+
When `--mode`, `--limit` or `--tokens` are omitted, quickstart uses agent profile defaults when available.
|
|
677
|
+
|
|
678
|
+
### `config`
|
|
679
|
+
|
|
680
|
+
```bash
|
|
681
|
+
blink config where
|
|
682
|
+
blink config get vault
|
|
683
|
+
blink config doctor
|
|
684
|
+
blink config doctor --fix
|
|
685
|
+
blink config set-vault /absolute/path/to/existing-vault
|
|
686
|
+
blink config set-vault /absolute/path/to/existing-vault --migrate-from ~/.brainlink/vault
|
|
687
|
+
blink config set-vault "s3://my-memory-bucket/brainlink" --global
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
`config set-vault` writes configuration through CLI (no manual file edits required).
|
|
691
|
+
By default it writes local config (`./brainlink.config.json`), appends the vault to `allowedVaults`, and migrates Markdown memory from the current configured vault when the target is empty.
|
|
692
|
+
Use `--global` to write to `$BRAINLINK_HOME/brainlink.config.json`, `--no-migrate` to skip migration, and `--no-index` to skip post-migration indexing.
|
|
693
|
+
`config doctor` is dry-run by default; use `--fix` to apply safe config normalization and allowlist fixes.
|
|
694
|
+
|
|
695
|
+
### `migrate-vault`
|
|
696
|
+
|
|
697
|
+
```bash
|
|
698
|
+
blink migrate-vault --from ~/.brainlink/vault --to ./team-vault --dry-run
|
|
699
|
+
blink migrate-vault --from ~/.brainlink/vault --to ./team-vault
|
|
700
|
+
blink migrate-vault --from ~/.brainlink/vault --to "s3://my-memory-bucket/brainlink"
|
|
701
|
+
blink migrate-vault --from ~/.brainlink/vault --to ./team-vault --report ./migration-report.json
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
Runs explicit markdown migration between vaults while preserving conflicts as `.conflict-<timestamp>` files.
|
|
705
|
+
Use `--dry-run` to preview `copied`, `conflicted` and `unchanged` counts before writing.
|
|
706
|
+
|
|
707
|
+
### `db-import`
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
blink db-import --vault ./team-vault
|
|
711
|
+
blink db-import --vault ./team-vault --db ./legacy/brainlink.db
|
|
712
|
+
blink db-import --vault ./team-vault --db ./legacy/brainlink.db --table legacy_notes --dry-run
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
Imports durable memory from a legacy SQLite database into Markdown notes (`agents/<agent-id>/*.md`) and reindexes by default.
|
|
716
|
+
When `--db` is omitted, Brainlink auto-detects common legacy paths such as `<vault>/.brainlink/brainlink.db`.
|
|
717
|
+
Use `--agent <id>` to force all imported rows into one namespace, `--limit` for incremental imports, `--dry-run` to preview without writing files, and `--no-index` to defer reindexing.
|
|
718
|
+
|
|
464
719
|
### `init`
|
|
465
720
|
|
|
466
721
|
```bash
|
|
467
722
|
blink init
|
|
468
723
|
blink init ./vault
|
|
724
|
+
blink init ./team-vault --migrate-from ~/.brainlink/vault
|
|
469
725
|
```
|
|
470
726
|
|
|
471
727
|
Initializes vault metadata. Without an argument, Brainlink initializes the default vault at `$HOME/.brainlink/vault`.
|
|
728
|
+
When initializing an empty custom vault, existing Markdown content from the default vault is copied into it and reindexed so context is not left behind. Use `--no-migrate-existing` to start with an empty custom vault, or `--migrate-from <vault>` to copy from a specific source. Existing target files are never overwritten; conflicting source files are preserved with a `.conflict-<timestamp>` suffix.
|
|
472
729
|
|
|
473
730
|
### `add`
|
|
474
731
|
|
|
@@ -482,6 +739,29 @@ blink add "Note Title" --vault ./vault --content-file ./notes.md --no-auto-index
|
|
|
482
739
|
`--content` and `--content-file` are mutually exclusive. Add `--no-auto-index` when you want to defer reindexing.
|
|
483
740
|
|
|
484
741
|
Creates a Markdown note under `agents/<agent-id>/`. Common secret patterns are blocked by default; use `--allow-sensitive` only for an intentionally protected vault.
|
|
742
|
+
To avoid disconnected memory, Brainlink auto-adds a fallback wiki edge when a note is written without links, creating agent hub notes when needed.
|
|
743
|
+
`add` also returns `possibleDuplicates` (exact hash + semantic candidates) so agents can resolve duplicate memory right after writes.
|
|
744
|
+
|
|
745
|
+
### `dedupe`
|
|
746
|
+
|
|
747
|
+
```bash
|
|
748
|
+
blink dedupe --vault ./vault --json
|
|
749
|
+
blink dedupe --vault ./vault --agent coding-agent --limit 20 --min-score 0.92 --json
|
|
750
|
+
blink dedupe --vault ./vault --no-semantic --json
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
Detects `possibleDuplicate` pairs using exact content hashes and optional semantic similarity.
|
|
754
|
+
|
|
755
|
+
### `dedupe-resolve`
|
|
756
|
+
|
|
757
|
+
```bash
|
|
758
|
+
blink dedupe-resolve --vault ./vault --left agents/shared/a.md --right agents/shared/b.md --action merge --json
|
|
759
|
+
blink dedupe-resolve --vault ./vault --left agents/shared/a.md --right agents/shared/b.md --action link --json
|
|
760
|
+
blink dedupe-resolve --vault ./vault --left agents/shared/a.md --right agents/shared/b.md --action ignore --json
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
Resolves a duplicate pair with `merge`, `link` or `ignore`.
|
|
764
|
+
When action is not `merge`, Brainlink still creates a low-priority related edge (`#related-to`) so notes remain connected.
|
|
485
765
|
|
|
486
766
|
### `index`
|
|
487
767
|
|
|
@@ -492,6 +772,38 @@ blink index --vault ./vault
|
|
|
492
772
|
|
|
493
773
|
Rebuilds the local index from Markdown files.
|
|
494
774
|
|
|
775
|
+
### `bench`
|
|
776
|
+
|
|
777
|
+
```bash
|
|
778
|
+
blink bench --vault ./vault
|
|
779
|
+
blink bench --vault ./vault --watch
|
|
780
|
+
blink bench --vault ./vault --watch --debounce 500
|
|
781
|
+
blink bench --vault ./vault --json
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
Runs indexing with realtime phase telemetry (`start`, `scan`, `parse`, `embed`, `persist`, `packs`, `complete`) and prints a benchmark summary at the end of each run.
|
|
785
|
+
|
|
786
|
+
Summary includes compression behavior for `.blpk` packs when rebuild happens:
|
|
787
|
+
- pack rebuild reason
|
|
788
|
+
- pack count and pack build duration
|
|
789
|
+
- uncompressed input bytes vs compressed output bytes
|
|
790
|
+
- saved percentage
|
|
791
|
+
- objective guardrails (minimum savings and maximum latency regression thresholds)
|
|
792
|
+
|
|
793
|
+
Use `--watch` to keep benchmarking incremental reindex runs after Markdown changes (local filesystem vaults only).
|
|
794
|
+
When `.brainlink/search-packs/manifest.json` is missing but `.blpk` files exist, Brainlink repairs the manifest first and avoids unnecessary full pack rebuild on small edits.
|
|
795
|
+
|
|
796
|
+
### `pack-backup`
|
|
797
|
+
|
|
798
|
+
```bash
|
|
799
|
+
blink pack-backup --vault ./vault
|
|
800
|
+
blink pack-backup --vault ./vault --output ./vault/.brainlink/backups/custom.blpkbak.gz
|
|
801
|
+
blink pack-backup --vault ./vault --json
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
Creates an offline backup artifact of encrypted search packs with a second compression pass.
|
|
805
|
+
This is intentionally outside the online retrieval path (`index`, `search`, `context`).
|
|
806
|
+
|
|
495
807
|
### `agents`
|
|
496
808
|
|
|
497
809
|
```bash
|
|
@@ -510,13 +822,17 @@ blink search "query" --vault ./vault --mode semantic --json
|
|
|
510
822
|
```
|
|
511
823
|
|
|
512
824
|
Runs retrieval over indexed chunks.
|
|
825
|
+
If `--mode` or `--limit` is omitted, Brainlink resolves values from the current agent profile before falling back to global defaults.
|
|
513
826
|
|
|
514
827
|
Modes:
|
|
515
828
|
|
|
516
|
-
- `hybrid`: default; combines
|
|
517
|
-
- `fts`: exact lexical retrieval
|
|
829
|
+
- `hybrid`: default; combines lexical matching with local embedding similarity.
|
|
830
|
+
- `fts`: exact lexical retrieval from the file index.
|
|
518
831
|
- `semantic`: local deterministic embedding similarity only.
|
|
519
832
|
|
|
833
|
+
Hybrid results are cached in-memory for a short TTL and invalidated automatically when the local index file changes.
|
|
834
|
+
Context selection uses a middle-out strategy: it starts from the strongest chunk in a note and expands to neighboring chunks while respecting token budget.
|
|
835
|
+
|
|
520
836
|
### `context`
|
|
521
837
|
|
|
522
838
|
```bash
|
|
@@ -526,6 +842,7 @@ blink context "question" --vault ./vault --agent coding-agent --mode hybrid --js
|
|
|
526
842
|
```
|
|
527
843
|
|
|
528
844
|
Builds a compact context package for an agent.
|
|
845
|
+
Repeated calls with the same vault, agent, query, mode and token/limit settings are served from a short in-memory cache while the index is unchanged.
|
|
529
846
|
|
|
530
847
|
### `links`
|
|
531
848
|
|
|
@@ -559,9 +876,11 @@ Prints indexed graph data. Edges include `weight` and `priority` so agents can c
|
|
|
559
876
|
```bash
|
|
560
877
|
blink stats --vault ./vault
|
|
561
878
|
blink stats --vault ./vault --agent coding-agent --json
|
|
879
|
+
blink stats --vault ./vault --agent coding-agent --extended --json
|
|
562
880
|
```
|
|
563
881
|
|
|
564
882
|
Prints vault metrics.
|
|
883
|
+
Use `--extended` to include storage footprint, link quality ratios and observability probes (`index`, `search`, `context` latencies).
|
|
565
884
|
|
|
566
885
|
### `broken-links`
|
|
567
886
|
|
|
@@ -593,7 +912,7 @@ Validates graph health. The command exits non-zero when required checks fail.
|
|
|
593
912
|
blink doctor --vault ./vault
|
|
594
913
|
```
|
|
595
914
|
|
|
596
|
-
Runs environment and vault checks.
|
|
915
|
+
Runs environment and vault checks. When vault has zero markdown and zero indexed documents, `doctor` prints recommended next steps (add note, inspect config source, migrate memory).
|
|
597
916
|
|
|
598
917
|
### `watch`
|
|
599
918
|
|
|
@@ -608,9 +927,15 @@ Watches Markdown files and rebuilds the index when notes change.
|
|
|
608
927
|
```bash
|
|
609
928
|
blink server --watch
|
|
610
929
|
blink server --vault ./vault --watch
|
|
930
|
+
blink server --vault ./vault --watch --no-open
|
|
611
931
|
```
|
|
612
932
|
|
|
613
933
|
Starts the local read-only graph UI and HTTP API.
|
|
934
|
+
By default, it tries to open a native desktop GUI window for the graph URL.
|
|
935
|
+
On Linux, native GUI is disabled by default; enable it with `BRAINLINK_LINUX_NATIVE_GUI=1`.
|
|
936
|
+
If native GUI launch is unavailable, it falls back to dedicated app-window mode and then browser open.
|
|
937
|
+
When fallback opens Chromium-family browsers on Linux, Brainlink automatically uses compatibility launch flags for stable rendering on Ubuntu/Wayland setups.
|
|
938
|
+
Use `--no-open` to skip that behavior.
|
|
614
939
|
|
|
615
940
|
The HTTP server only binds to loopback hosts such as `127.0.0.1`, `localhost` or `::1`.
|
|
616
941
|
|
|
@@ -630,7 +955,13 @@ npm run --silent dev -- context "question" --vault ./vault --json
|
|
|
630
955
|
|
|
631
956
|
## Configuration
|
|
632
957
|
|
|
633
|
-
Brainlink
|
|
958
|
+
Brainlink merges configuration in this order:
|
|
959
|
+
|
|
960
|
+
1. Global: `$BRAINLINK_HOME/brainlink.config.json` (or `$HOME/.brainlink/brainlink.config.json` by default)
|
|
961
|
+
2. Local: `brainlink.config.json` in the current working directory
|
|
962
|
+
3. Local legacy compatibility: `.brainlink.json` in the current working directory
|
|
963
|
+
|
|
964
|
+
If no `vault` is configured and no `--vault` flag is passed, Brainlink uses `$HOME/.brainlink/vault`.
|
|
634
965
|
|
|
635
966
|
```json
|
|
636
967
|
{
|
|
@@ -644,13 +975,31 @@ Brainlink reads `brainlink.config.json` or `.brainlink.json` from the current wo
|
|
|
644
975
|
"defaultContextTokens": 2000,
|
|
645
976
|
"embeddingProvider": "local",
|
|
646
977
|
"defaultSearchMode": "hybrid",
|
|
647
|
-
"chunkSize": 1200
|
|
978
|
+
"chunkSize": 1200,
|
|
979
|
+
"searchPack": {
|
|
980
|
+
"rowChunkSize": 5000,
|
|
981
|
+
"compressionLevel": 5,
|
|
982
|
+
"useDictionary": true,
|
|
983
|
+
"guardrailMinSavingsPercent": 8,
|
|
984
|
+
"guardrailMaxLatencyRegressionPercent": 5
|
|
985
|
+
},
|
|
986
|
+
"agentProfiles": {
|
|
987
|
+
"coding-agent": {
|
|
988
|
+
"defaultSearchMode": "semantic",
|
|
989
|
+
"defaultSearchLimit": 8,
|
|
990
|
+
"defaultContextTokens": 2400
|
|
991
|
+
},
|
|
992
|
+
"*": {
|
|
993
|
+
"defaultSearchMode": "hybrid"
|
|
994
|
+
}
|
|
995
|
+
}
|
|
648
996
|
}
|
|
997
|
+
```
|
|
649
998
|
|
|
650
999
|
`defaultAgent` is optional. When set, CLI and MCP calls that omit `--agent`/`agent` use this value automatically. If not set, behavior remains as before.
|
|
1000
|
+
`agentProfiles` is optional. When present, CLI and MCP resolve `mode`, `limit` and `tokens` per agent automatically, then fallback to global defaults.
|
|
651
1001
|
|
|
652
1002
|
`autoIndexOnWrite` is optional and defaults to `true`. Set it to `false` to defer indexing after writes.
|
|
653
|
-
```
|
|
654
1003
|
|
|
655
1004
|
Use `"embeddingProvider": "none"` when you want FTS-only indexing.
|
|
656
1005
|
|
|
@@ -745,7 +1094,7 @@ src/
|
|
|
745
1094
|
application/ use cases
|
|
746
1095
|
cli/ command-line adapter
|
|
747
1096
|
domain/ pure knowledge rules
|
|
748
|
-
infrastructure/ filesystem and
|
|
1097
|
+
infrastructure/ filesystem and index adapters
|
|
749
1098
|
```
|
|
750
1099
|
|
|
751
1100
|
Detailed notes:
|
|
@@ -757,23 +1106,23 @@ Detailed notes:
|
|
|
757
1106
|
## Current Limits
|
|
758
1107
|
|
|
759
1108
|
- Semantic search uses deterministic local embeddings, not a remote model provider.
|
|
760
|
-
- Semantic search uses SQLite embedding buckets to narrow candidates before cosine scoring.
|
|
761
1109
|
- `embeddingProvider` currently supports `local` and `none`.
|
|
762
1110
|
- Link resolution is title-based inside each agent namespace, with `shared` as fallback.
|
|
763
1111
|
- HTTP API is local and unauthenticated.
|
|
764
1112
|
- Watch mode depends on the platform filesystem watcher.
|
|
765
1113
|
|
|
766
|
-
##
|
|
1114
|
+
## Beta Scope
|
|
767
1115
|
|
|
768
|
-
`0.1.0-
|
|
1116
|
+
The `0.1.0-beta` line is intended to stabilize the local-first memory loop:
|
|
769
1117
|
|
|
770
1118
|
- Markdown as durable memory.
|
|
771
|
-
-
|
|
1119
|
+
- Rebuildable file index plus local embeddings and encrypted pack exports.
|
|
772
1120
|
- CLI as the primary agent interface.
|
|
773
1121
|
- HTTP graph API and frontend as inspection tools.
|
|
774
1122
|
- Agent namespaces to avoid context mixing.
|
|
1123
|
+
- MCP tools for context retrieval, durable memory writes and graph maintenance.
|
|
775
1124
|
|
|
776
|
-
The
|
|
1125
|
+
The beta includes local semantic retrieval. Remote embedding providers, remote auth, advanced deduplication and graph editing are future milestones.
|
|
777
1126
|
|
|
778
1127
|
## Security
|
|
779
1128
|
|
|
@@ -783,7 +1132,7 @@ Brainlink is local-first by default.
|
|
|
783
1132
|
- Brainlink HTTP is localhost-only and refuses non-loopback hosts.
|
|
784
1133
|
- Brainlink blocks common secret patterns by default when adding notes. Use `--allow-sensitive` only for intentional, protected vaults.
|
|
785
1134
|
- Do not store secrets, credentials, API keys or regulated personal data unless the vault is protected by your own storage controls.
|
|
786
|
-
- Treat `.brainlink/
|
|
1135
|
+
- Treat `.brainlink/index.json` and `.brainlink/search-packs/` as disposable derived artifacts.
|
|
787
1136
|
|
|
788
1137
|
See [SECURITY.md](SECURITY.md).
|
|
789
1138
|
|
|
@@ -794,6 +1143,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
|
794
1143
|
## License
|
|
795
1144
|
|
|
796
1145
|
MIT. See [LICENSE](LICENSE).
|
|
1146
|
+
Copyright (c) 2026 Substructa. See [COPYRIGHT.md](COPYRIGHT.md).
|
|
797
1147
|
|
|
798
1148
|
### Memory Optimization Loop (1-7)
|
|
799
1149
|
|
package/SECURITY.md
CHANGED
|
@@ -7,7 +7,7 @@ Brainlink is local-first.
|
|
|
7
7
|
- The HTTP server binds to `127.0.0.1` by default.
|
|
8
8
|
- The HTTP server always refuses non-loopback hosts.
|
|
9
9
|
- The HTTP server is read-only and does not expose note creation, indexing or update routes.
|
|
10
|
-
-
|
|
10
|
+
- Local index artifacts (`.brainlink/index.json` and `.brainlink/search-packs/`) are derived data.
|
|
11
11
|
- Markdown files are user-owned source data.
|
|
12
12
|
- Brainlink-created Markdown files use `0600` permissions.
|
|
13
13
|
- Brainlink-created directories and `.brainlink` use `0700` permissions.
|