@andespindola/brainlink 0.1.0-beta.99 → 1.0.0
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 +6 -6
- package/CHANGELOG.md +14 -0
- package/README.md +186 -38
- package/dist/application/add-note.js +13 -44
- package/dist/application/analyze-vault.js +1 -1
- package/dist/application/auto-migrate-configured-vault.js +37 -0
- package/dist/application/build-context.js +119 -20
- package/dist/application/canonical-context-links.js +209 -0
- package/dist/application/frontend/client-css.js +212 -42
- package/dist/application/frontend/client-html.js +42 -28
- package/dist/application/frontend/client-js.js +1294 -3222
- package/dist/application/frontend/client-render-worker-js.js +676 -0
- package/dist/application/get-graph-contexts.js +33 -0
- package/dist/application/get-graph-layout.js +62 -8
- package/dist/application/get-graph-stream-chunk.js +326 -0
- package/dist/application/get-graph-view.js +246 -0
- package/dist/application/graph-view-state.js +66 -0
- package/dist/application/import-legacy-sqlite.js +3 -33
- package/dist/application/index-vault.js +35 -22
- package/dist/application/migrate-context-links.js +79 -0
- package/dist/application/search-graph-node-ids.js +63 -3
- package/dist/application/server/routes.js +197 -12
- package/dist/cli/commands/read-commands.js +39 -3
- package/dist/cli/commands/vault-commands.js +182 -0
- package/dist/cli/commands/write-commands.js +147 -12
- package/dist/cli/main.js +2 -0
- package/dist/cli/runtime.js +10 -2
- package/dist/domain/context.js +1 -0
- package/dist/domain/graph-contexts.js +180 -0
- package/dist/domain/graph-layout.js +347 -21
- package/dist/domain/markdown.js +53 -9
- package/dist/infrastructure/config.js +105 -6
- package/dist/infrastructure/context-packs.js +122 -0
- package/dist/infrastructure/file-index.js +6 -3
- package/dist/infrastructure/index-state.js +2 -0
- package/dist/infrastructure/vault-migration-state.js +69 -0
- package/dist/infrastructure/volatile-memory.js +100 -0
- package/dist/mcp/http-server.js +97 -0
- package/dist/mcp/runtime.js +20 -0
- package/dist/mcp/server.js +36 -13
- package/dist/mcp/tools.js +203 -14
- package/docs/AGENT_USAGE.md +50 -5
- package/docs/ARCHITECTURE.md +11 -0
- package/docs/QUICKSTART.md +3 -1
- package/docs/RELEASE.md +4 -3
- package/package.json +3 -1
package/docs/AGENT_USAGE.md
CHANGED
|
@@ -51,11 +51,26 @@ Set `BRAINLINK_HOME` when the whole Brainlink home directory should live somewhe
|
|
|
51
51
|
Use `blink config where` and `blink config doctor` to inspect active paths and effective source.
|
|
52
52
|
|
|
53
53
|
You can also set `defaultAgent` in `brainlink.config.json` / `.brainlink.json` (for example `"defaultAgent": "coding-agent"`). When set, CLI commands and MCP calls reuse it when `--agent`/`agent` is not passed.
|
|
54
|
-
You can set `agentProfiles` to define per-agent defaults for `defaultSearchMode`, `defaultSearchLimit` and `
|
|
54
|
+
You can set `agentProfiles` to define per-agent defaults for `defaultSearchMode`, `defaultSearchLimit`, `defaultContextTokens`, `defaultContextStrategy` and `defaultContextCacheTtlMs`.
|
|
55
55
|
You can tune search-pack compression with `searchPack.rowChunkSize`, `searchPack.compressionLevel` and `searchPack.useDictionary`.
|
|
56
56
|
Guardrails for benchmark acceptance are configured with `searchPack.guardrailMinSavingsPercent` and `searchPack.guardrailMaxLatencyRegressionPercent`.
|
|
57
57
|
|
|
58
58
|
`autoIndexOnWrite` (default: `true`) controls whether `add` and MCP write tools index right after writing.
|
|
59
|
+
`autoCanonicalContextLinks` (default: `true`) controls whether CLI/MCP write tools add canonical `## Context Links` to inferred context hubs.
|
|
60
|
+
|
|
61
|
+
## Central MCP Service
|
|
62
|
+
|
|
63
|
+
For clustered applications, run Brainlink as one central MCP service and let workloads connect to it over Streamable HTTP:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
BRAINLINK_MCP_TOKEN="change-me" brainlink mcp-server \
|
|
67
|
+
--vault /data/vault \
|
|
68
|
+
--host 0.0.0.0 \
|
|
69
|
+
--port 3333 \
|
|
70
|
+
--path /mcp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The central service exposes `/mcp` for MCP clients plus `/healthz` and `/readyz` for platform probes. Use a Kubernetes `Service` for internal discovery, mount the Markdown vault through a persistent volume, and pass `Authorization: Bearer <token>` from clients when `BRAINLINK_MCP_TOKEN` or `--token` is configured.
|
|
59
74
|
|
|
60
75
|
## Agent Namespaces
|
|
61
76
|
|
|
@@ -161,7 +176,7 @@ Brainlink only builds graph edges from Markdown `[[wiki links]]`.
|
|
|
161
176
|
|
|
162
177
|
The `context` command is read-only. It retrieves indexed notes and returns a compact package for the model, but it does not write memory, create backlinks, infer relationships or modify the graph. If an agent reads context and then learns something durable, the agent must write a note with explicit links before that knowledge becomes connected memory.
|
|
163
178
|
|
|
164
|
-
Graph edges are weighted during indexing. Repeated links increase weight. Links inside headings or task-list lines receive a small boost. Priority markers on the same line as a link raise its priority
|
|
179
|
+
Graph edges are weighted during indexing. Repeated links increase weight. Links inside headings or task-list lines receive a small boost. Priority markers on the same line as a link raise its priority. The graph relationship model indexes every non-self Markdown `[[wiki link]]` as an edge, including structural hub links such as `Memory Hub`, `Knowledge Root`, `MOC` and map notes. Older indexes without the current graph link model version are automatically rebuilt on the next index run.
|
|
165
180
|
|
|
166
181
|
```md
|
|
167
182
|
- [ ] Review [[Architecture]] priority: high
|
|
@@ -292,6 +307,8 @@ blink add "Implementation Boundary" \
|
|
|
292
307
|
blink index
|
|
293
308
|
```
|
|
294
309
|
|
|
310
|
+
Use `blink index --full` when you need to rebuild every note from Markdown source. Full reindexing builds the replacement index before persisting it, preserving the previous context until the new index is ready. Brainlink also runs this complete source reindex automatically when it detects an older stored graph link model.
|
|
311
|
+
|
|
295
312
|
### Claude Code-Style Agent
|
|
296
313
|
|
|
297
314
|
Use Brainlink as a preflight memory read before editing files:
|
|
@@ -368,6 +385,19 @@ blink config set-vault /absolute/path/to/vault --global
|
|
|
368
385
|
|
|
369
386
|
`config set-vault` updates Brainlink config through CLI. By default it writes local `brainlink.config.json`, appends the vault to `allowedVaults`, and migrates markdown when the target is empty.
|
|
370
387
|
|
|
388
|
+
### Manage Known Vaults
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
blink vaults list
|
|
392
|
+
blink vaults use /absolute/path/to/vault
|
|
393
|
+
blink vaults use /absolute/path/to/vault --global
|
|
394
|
+
blink vaults delete /absolute/path/to/vault --yes
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
`vaults list` shows the configured default vault, allowlisted vaults and the built-in default vault, including local existence and Markdown/index counts when available.
|
|
398
|
+
`vaults use` switches the default vault without migrating memory.
|
|
399
|
+
`vaults delete` deletes only local filesystem vaults, requires `--yes`, and refuses deleting the current default vault.
|
|
400
|
+
|
|
371
401
|
### Migrate Vaults Explicitly
|
|
372
402
|
|
|
373
403
|
```bash
|
|
@@ -539,9 +569,14 @@ blink context "how does authentication work?" --vault ./vault --limit 12 --token
|
|
|
539
569
|
blink context "how does authentication work?" --vault ./vault --json
|
|
540
570
|
blink context "how does authentication work?" --vault ./vault --agent coding-agent --json
|
|
541
571
|
blink context "how does authentication work?" --vault ./vault --agent coding-agent --mode hybrid --json
|
|
572
|
+
blink context "how does authentication work?" --vault ./vault --agent coding-agent --strategy cag --json
|
|
573
|
+
blink context "how does authentication work?" --vault ./vault --agent coding-agent --strategy auto --json
|
|
574
|
+
blink context-packs --vault ./vault --json
|
|
575
|
+
blink context-packs --vault ./vault --stale --clear
|
|
542
576
|
```
|
|
543
577
|
|
|
544
578
|
This returns a Markdown context package optimized for prompt injection.
|
|
579
|
+
The default strategy is configured by `defaultContextStrategy` and starts as `rag`. Use `--strategy cag` when the same agent/task context should be served from a persisted context pack when the index and volatile-memory signatures are unchanged. Use `--strategy auto` when Brainlink should use CAG on fresh pack hits and RAG otherwise. Context responses include `cache`, `metrics`, `requestedStrategy` and `recommendedStrategy` metadata. CAG packs live under `.brainlink/context-packs` and are rebuildable derived artifacts.
|
|
545
580
|
|
|
546
581
|
### Inspect Links
|
|
547
582
|
|
|
@@ -607,7 +642,7 @@ Without `--vault`, the graph UI serves `$HOME/.brainlink/vault`.
|
|
|
607
642
|
|
|
608
643
|
The frontend includes an agent selector that shows only the agent id. Selecting an agent calls the same read APIs with `agent=<agent-id>` and renders that namespace instead of merging every agent into one graph.
|
|
609
644
|
|
|
610
|
-
Graph navigation controls include zoom in, zoom out, fit visible nodes and reset-to-fit-all nodes. Mouse wheel zoom (including `cmd+scroll` and `ctrl+scroll`) is anchored to the cursor. Keyboard shortcuts are `+` (zoom in), `-` (zoom out) and `0` (reset fit). Double-click on canvas zooms in at cursor position. Totals for notes, links and tags stay visible as floating metrics under the Brainlink title, and node details open
|
|
645
|
+
Graph navigation controls include zoom in, zoom out, fit visible nodes and reset-to-fit-all nodes. Mouse wheel zoom (including `cmd+scroll` and `ctrl+scroll`) is anchored to the cursor and applied immediately without delayed focus interpolation. Keyboard shortcuts are `+` (zoom in), `-` (zoom out) and `0` (reset fit). Double-click on empty canvas zooms in at cursor position. Clicking a node opens its details panel. Totals for notes, links and tags stay visible as floating metrics under the Brainlink title, and node details open in a non-modal side panel (tags, outgoing links, backlinks and Markdown content), so zoom and pan remain available during inspection. The visual layout is a cauliflower hub layout: the primary hub stays centered, segment hubs anchor surrounding lobes, and visual edges are simplified to root hub -> segment hubs -> local context nodes. Indexed weighted wiki-link edges remain available for backlinks, ranking and context traversal outside the render layer. At high zoom-out, graph streams show segment hub clusters first; zooming in progressively reveals the individual nodes inside those lobes. Node titles appear as zoom approaches readable scale, limited to on-screen nodes in very large graphs.
|
|
611
646
|
During graph filtering, Brainlink keeps hub context nodes visible (`Memory Hub`/`MOC`/high-degree fallback) so filtered views still show relationship anchors.
|
|
612
647
|
|
|
613
648
|
The command reindexes by default, then serves:
|
|
@@ -625,12 +660,14 @@ Use `--no-index` when you need to inspect the current index without rebuilding i
|
|
|
625
660
|
blink server --vault ./vault --no-index
|
|
626
661
|
```
|
|
627
662
|
|
|
628
|
-
|
|
663
|
+
The server watches Markdown files by default and keeps the graph updated after edits:
|
|
629
664
|
|
|
630
665
|
```bash
|
|
631
|
-
blink server --vault ./vault
|
|
666
|
+
blink server --vault ./vault
|
|
632
667
|
```
|
|
633
668
|
|
|
669
|
+
Use `--no-watch` when you need to run the graph server without realtime reindexing.
|
|
670
|
+
|
|
634
671
|
### Watch A Vault
|
|
635
672
|
|
|
636
673
|
```bash
|
|
@@ -665,16 +702,21 @@ Available MCP tools:
|
|
|
665
702
|
- `brainlink_policy`
|
|
666
703
|
- `brainlink_recommendations`
|
|
667
704
|
- `brainlink_context`
|
|
705
|
+
- `brainlink_context_packs`
|
|
668
706
|
- `brainlink_search`
|
|
669
707
|
- `brainlink_dedupe`
|
|
670
708
|
- `brainlink_resolve_duplicate`
|
|
671
709
|
- `brainlink_add_note`
|
|
672
710
|
- `brainlink_add_file`
|
|
711
|
+
- `brainlink_canonicalize_context_links`
|
|
712
|
+
- `brainlink_volatile_add`
|
|
713
|
+
- `brainlink_volatile_clear`
|
|
673
714
|
- `brainlink_index`
|
|
674
715
|
- `brainlink_stats`
|
|
675
716
|
- `brainlink_validate`
|
|
676
717
|
- `brainlink_sync`
|
|
677
718
|
- `brainlink_graph`
|
|
719
|
+
- `brainlink_graph_contexts`
|
|
678
720
|
- `brainlink_broken_links`
|
|
679
721
|
- `brainlink_orphans`
|
|
680
722
|
|
|
@@ -684,11 +726,13 @@ If `autoBootstrapOnRead` or `enforceContextFirst` are disabled through `brainlin
|
|
|
684
726
|
`brainlink_bootstrap`, `brainlink_policy` and preflight responses include structured `nextActions` so clients can continue tool flows automatically.
|
|
685
727
|
`brainlink_policy` also accepts policy presets (`fully-auto`, `strict`) so MCP clients can switch behavior in one call.
|
|
686
728
|
`brainlink_recommendations` returns the suggested execution order so an agent can follow Brainlink best practices automatically.
|
|
729
|
+
MCP context is plug-and-play: agents may omit `strategy` for the configured default, pass `strategy: "rag"` for explicit fresh retrieval assembly, pass `strategy: "cag"` to reuse persisted context packs when the task context is stable or repeated, or pass `strategy: "auto"` to use CAG on fresh pack hits and RAG otherwise. `brainlink_recommendations`, policy next actions and preflight responses return executable context arguments, so clients can continue without custom parsing. `brainlink_context_packs` lists or clears persisted CAG packs.
|
|
687
730
|
|
|
688
731
|
MCP clients can pass `vault` and `agent` arguments per tool call. Set `BRAINLINK_ALLOWED_VAULTS` when exposing Brainlink to an external agent process so a tool cannot pass arbitrary vault paths:
|
|
689
732
|
|
|
690
733
|
`brainlink_graph` returns weighted edges. Agents should prefer higher `weight` and stronger `priority` when deciding which related notes matter most.
|
|
691
734
|
`brainlink_add_note` and `brainlink_add_file` return `writeConnectivity` metadata and guarantee at least one edge for new notes.
|
|
735
|
+
Agents should use `brainlink_volatile_add` for temporary task state, hypotheses, local execution details and unconfirmed findings. Volatile memory is included in `brainlink_context` with `Volatile: true`, expires by TTL and does not create durable Markdown notes or graph edges.
|
|
692
736
|
|
|
693
737
|
```bash
|
|
694
738
|
export BRAINLINK_ALLOWED_VAULTS="/absolute/path/to/project-vault"
|
|
@@ -699,6 +743,7 @@ export BRAINLINK_ALLOWED_VAULTS="/absolute/path/to/project-vault"
|
|
|
699
743
|
```txt
|
|
700
744
|
GET /api/graph
|
|
701
745
|
GET /api/graph-layout
|
|
746
|
+
GET /api/graph-view?x=<x>&y=<y>&w=<width>&h=<height>&scale=<scale>
|
|
702
747
|
GET /api/graph-node?id=<node-id>
|
|
703
748
|
GET /api/graph-filter?q=<query>&limit=<n>
|
|
704
749
|
GET /api/search?q=<query>&limit=10&mode=hybrid
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -136,6 +136,8 @@ read markdown files
|
|
|
136
136
|
|
|
137
137
|
```txt
|
|
138
138
|
question
|
|
139
|
+
-> selected strategy: rag | cag | auto
|
|
140
|
+
-> if cag/auto and fresh context pack exists, return cached Markdown package
|
|
139
141
|
-> selected mode: fts | semantic | hybrid
|
|
140
142
|
-> optional query embedding
|
|
141
143
|
-> optional compressed pack prefilter (token bloom)
|
|
@@ -145,8 +147,12 @@ question
|
|
|
145
147
|
-> ranked chunks with textScore and semanticScore
|
|
146
148
|
-> token-budget selection
|
|
147
149
|
-> Markdown context package
|
|
150
|
+
-> if cag/auto, persist derived context pack with current data signature
|
|
151
|
+
-> return cache, strategy and timing metrics
|
|
148
152
|
```
|
|
149
153
|
|
|
154
|
+
Context packs are stored under `.brainlink/context-packs/*.json`. They are derived artifacts keyed by query, agent, mode, limit and token budget, and are invalidated by the combined index and volatile-memory signature. Markdown remains the source of truth. The `auto` strategy uses CAG on fresh pack hits and falls back to RAG assembly otherwise, refreshing a pack for later calls.
|
|
155
|
+
|
|
150
156
|
## Graph Server Flow
|
|
151
157
|
|
|
152
158
|
```txt
|
|
@@ -154,11 +160,15 @@ server command
|
|
|
154
160
|
-> optional index rebuild
|
|
155
161
|
-> HTTP server
|
|
156
162
|
-> /api/agents lists indexed namespaces
|
|
163
|
+
-> /api/graph-contexts lists visual graph contexts
|
|
157
164
|
-> /api/graph reads indexed documents and links
|
|
165
|
+
-> /api/graph-layout derives a cauliflower hub layout from indexed graph data
|
|
166
|
+
-> optional context query narrows the layout to a segment-scoped cauliflower subgraph
|
|
158
167
|
-> browser renders graph canvas
|
|
159
168
|
```
|
|
160
169
|
|
|
161
170
|
The graph UI is intentionally read-only. Markdown remains the write interface and index artifacts remain derived data.
|
|
171
|
+
The cauliflower layout is a visual projection over the indexed graph. Indexed weighted wiki-link edges remain unchanged for backlinks, ranking, graph reads and context traversal. The browser layout renders a simplified hierarchy instead: primary hub -> segment hubs -> local context nodes. This avoids unstable cross-context visual edges while preserving the real relationship model outside the render layer. Zoomed-out graph streams summarize those lobes as segment clusters before revealing individual nodes on zoom-in.
|
|
162
172
|
|
|
163
173
|
## HTTP API Flow
|
|
164
174
|
|
|
@@ -171,6 +181,7 @@ HTTP request
|
|
|
171
181
|
```
|
|
172
182
|
|
|
173
183
|
The HTTP API is local-first and unauthenticated. It is meant for local agents, browser UI, and development workflows.
|
|
184
|
+
The route adapter caches generated frontend assets (`/`, `/styles.css`, `/app.js`, `/app-worker.js`) and graph-layout JSON payloads by layout signature to reduce repeated CPU and allocation pressure during navigation.
|
|
174
185
|
|
|
175
186
|
## MCP Flow
|
|
176
187
|
|
package/docs/QUICKSTART.md
CHANGED
|
@@ -50,7 +50,9 @@ Optional per-agent retrieval defaults in `brainlink.config.json`:
|
|
|
50
50
|
"coding-agent": {
|
|
51
51
|
"defaultSearchMode": "semantic",
|
|
52
52
|
"defaultSearchLimit": 8,
|
|
53
|
-
"defaultContextTokens": 2400
|
|
53
|
+
"defaultContextTokens": 2400,
|
|
54
|
+
"defaultContextStrategy": "auto",
|
|
55
|
+
"defaultContextCacheTtlMs": 120000
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
}
|
package/docs/RELEASE.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Brainlink releases are built from the CLI package. Do not publish until the package name, npm account and version are confirmed.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Release Checklist
|
|
6
6
|
|
|
7
7
|
1. Confirm `package.json` name, version, repository, license and bin entries.
|
|
8
8
|
2. Run `npm install` from a clean checkout when dependencies changed.
|
|
@@ -51,9 +51,10 @@ The preferred path is the `Publish npm` GitHub Actions workflow:
|
|
|
51
51
|
- GitHub Release `published`: runs checks, pack smoke, then publishes to npm with provenance.
|
|
52
52
|
- Manual `workflow_dispatch`: runs a dry run by default. Disable `dry_run` only for an intentional manual publish.
|
|
53
53
|
- Manual `workflow_dispatch` accepts an optional `dist_tag` override. Use `latest` only when the default npm install command should resolve to that version.
|
|
54
|
-
-
|
|
54
|
+
- Stable versions publish under the `latest` dist-tag by default.
|
|
55
|
+
- Prerelease versions publish under their prerelease dist-tag, for example `1.1.0-beta.1` publishes with `--tag beta`.
|
|
55
56
|
|
|
56
|
-
On `main`, the publish job checks npm before publishing. If the version already exists, it automatically bumps the package inside the runner to the next available version before checks, packing and publishing. For example, `0.1.0-beta.4` becomes `
|
|
57
|
+
On `main`, the publish job checks npm before publishing. If the version already exists, it automatically bumps the package inside the runner to the next available version before checks, packing and publishing. For example, `1.0.0` becomes `1.0.1`, and `1.1.0-beta.4` becomes `1.1.0-beta.5`.
|
|
57
58
|
|
|
58
59
|
The automatic bump is intentionally not pushed back to `main`. The branch stays protected, and npm remains the source of truth for the latest published package version.
|
|
59
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andespindola/brainlink",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Local-first knowledge memory for agents with Markdown, backlinks, indexing and context retrieval.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"build": "npm run clean && npx --yes snyk test && tsc -p tsconfig.json",
|
|
49
49
|
"dev": "tsx src/cli/main.ts",
|
|
50
50
|
"dev:mcp": "tsx src/mcp/main.ts",
|
|
51
|
+
"dev:mcp:http": "tsx src/cli/main.ts mcp-server",
|
|
51
52
|
"brainlink:sync": "bash scripts/brainlink-sync.sh",
|
|
52
53
|
"security": "npx --yes snyk test",
|
|
53
54
|
"test": "vitest run --config vitest.config.ts",
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
"zod": "^4.3.6"
|
|
64
65
|
},
|
|
65
66
|
"overrides": {
|
|
67
|
+
"hono": "4.12.21",
|
|
66
68
|
"qs": "6.15.2"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|