@andespindola/brainlink 0.1.0-beta.8 → 0.1.0-beta.9

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.
@@ -39,9 +39,19 @@ $HOME/.brainlink/vault
39
39
 
40
40
  `blink server` follows the same rule, so it serves the default Brainlink vault instead of the current working directory.
41
41
 
42
- Use `--vault <path>` for a one-off custom vault, or set `vault` in `brainlink.config.json` / `.brainlink.json` for a workspace-level custom default. Set `BRAINLINK_HOME` when the whole Brainlink home directory should live somewhere else.
42
+ Use `--vault <path>` for a one-off custom vault, or set `vault` in config for a persistent default.
43
+ Configuration precedence is:
44
+
45
+ 1. global: `$BRAINLINK_HOME/brainlink.config.json` (or `$HOME/.brainlink/brainlink.config.json`)
46
+ 2. local: `./brainlink.config.json`
47
+ 3. local legacy: `./.brainlink.json`
48
+
49
+ Set `BRAINLINK_HOME` when the whole Brainlink home directory should live somewhere else.
50
+
51
+ Use `blink config where` and `blink config doctor` to inspect active paths and effective source.
43
52
 
44
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 `defaultContextTokens`.
45
55
 
46
56
  `autoIndexOnWrite` (default: `true`) controls whether `add` and MCP write tools index right after writing.
47
57
 
@@ -246,7 +256,7 @@ cp docs/templates/agent-note-template.md /tmp/agent-note.md
246
256
  When using MCP, use this compact sequence for the same memory discipline:
247
257
 
248
258
  1. Bootstrap context:
249
- - `brainlink_context` with `agent`, `query`, `mode: hybrid`, `limit`.
259
+ - `brainlink_bootstrap` with `agent`, optional `query`, `mode: hybrid`, `limit`.
250
260
  2. Capture durable decisions:
251
261
  - `brainlink_add_note` or `brainlink_add_file` with explicit `[[wiki links]]` and `#tags`.
252
262
  3. Run maintenance before handoff or before the next step:
@@ -343,6 +353,56 @@ $HOME/.brainlink/vault/
343
353
 
344
354
  `blink init ./vault` creates a custom vault instead. If the custom vault is empty and the default `$HOME/.brainlink/vault` already has Markdown memory, Brainlink copies that content into the custom vault and reindexes it. Use `blink init ./vault --no-migrate-existing` to intentionally start empty, or `blink init ./vault --migrate-from <old-vault>` to migrate from a specific previous vault. Existing target files are not overwritten; conflicting source files are preserved with a `.conflict-<timestamp>` suffix.
345
355
 
356
+ ### Configure Defaults
357
+
358
+ ```bash
359
+ blink config where
360
+ blink config get vault
361
+ blink config doctor
362
+ blink config doctor --fix
363
+ blink config set-vault /absolute/path/to/vault
364
+ blink config set-vault /absolute/path/to/vault --global
365
+ ```
366
+
367
+ `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.
368
+
369
+ ### Migrate Vaults Explicitly
370
+
371
+ ```bash
372
+ blink migrate-vault --from ~/.brainlink/vault --to ./team-vault --dry-run
373
+ blink migrate-vault --from ~/.brainlink/vault --to ./team-vault
374
+ blink migrate-vault --from ~/.brainlink/vault --to "s3://my-memory-bucket/brainlink"
375
+ blink migrate-vault --from ~/.brainlink/vault --to ./team-vault --report ./migration-report.json
376
+ ```
377
+
378
+ Use `--dry-run` to preview `copied`, `conflicted`, `unchanged` before writing files.
379
+
380
+ ### Install Agent Integration
381
+
382
+ ```bash
383
+ blink agent install
384
+ blink agent install --self-test
385
+ blink agent upgrade
386
+ blink agent policy --preset fully-auto
387
+ blink agent policy --preset strict
388
+ blink agent install --plugin-path ./plugins/brainlink
389
+ blink agent status
390
+ ```
391
+
392
+ `agent install` configures Brainlink MCP in `~/.codex/config.toml` so compatible agents can use Brainlink by default.
393
+ Use `agent upgrade` on legacy installations to reapply the latest defaults and run self-test diagnostics.
394
+ Use `agent policy --preset fully-auto` to keep startup/read auto-bootstrap enabled, or `agent policy --preset strict` to force explicit bootstrap calls.
395
+
396
+ ### Quickstart Plug-And-Play
397
+
398
+ ```bash
399
+ blink quickstart --json
400
+ blink quickstart --vault ./team-vault --agent coding-agent --query "architecture decisions" --json
401
+ blink quickstart --vault ./team-vault --mcp-only --json
402
+ ```
403
+
404
+ `quickstart` runs index, doctor, stats and validation, marks bootstrap readiness for MCP sessions, optionally returns context, and updates agent integration by default.
405
+
346
406
  ### Add A Note
347
407
 
348
408
  ```bash
@@ -356,6 +416,7 @@ blink add "Note Title" --vault ./vault --content-file ./notes.md --no-auto-index
356
416
  This creates a slugged Markdown file with frontmatter and a heading.
357
417
 
358
418
  The CLI blocks common secret patterns by default. Do not use `--allow-sensitive` unless the vault is intentionally protected.
419
+ Brainlink also auto-connects notes that have no `[[wiki links]]` by adding a fallback edge to an agent hub note, so new memory does not stay disconnected.
359
420
 
360
421
  For agent-private memory:
361
422
 
@@ -395,6 +456,7 @@ blink search "authentication token policy" --vault ./vault --mode semantic --jso
395
456
  ```
396
457
 
397
458
  This returns matching chunks with title, source path, score, `textScore`, `semanticScore`, `searchMode`, and content.
459
+ If `--mode`/`--limit` are omitted, Brainlink resolves those values from the active agent profile before global defaults.
398
460
 
399
461
  Search modes:
400
462
 
@@ -402,6 +464,8 @@ Search modes:
402
464
  - `fts`: lexical SQLite full-text search only.
403
465
  - `semantic`: local deterministic embedding similarity with SQLite bucket candidate narrowing.
404
466
 
467
+ Hybrid results are cached in-memory for a short TTL and invalidated when `.brainlink/brainlink.db` changes.
468
+
405
469
  ### Build Agent Context
406
470
 
407
471
  ```bash
@@ -518,6 +582,9 @@ Example MCP client configuration:
518
582
 
519
583
  Available MCP tools:
520
584
 
585
+ - `brainlink_bootstrap`
586
+ - `brainlink_policy`
587
+ - `brainlink_recommendations`
521
588
  - `brainlink_context`
522
589
  - `brainlink_search`
523
590
  - `brainlink_add_note`
@@ -530,9 +597,17 @@ Available MCP tools:
530
597
  - `brainlink_broken_links`
531
598
  - `brainlink_orphans`
532
599
 
600
+ Recommended start of every memory-dependent task: call `brainlink_bootstrap` first, then `brainlink_context` only when additional retrieval is needed. By default, Brainlink enforces bootstrap for MCP read tools and auto-runs bootstrap on reads when state is missing or stale (`autoBootstrapOnRead=true`).
601
+ MCP startup also bootstraps the configured default vault/agent automatically (`autoBootstrapOnStartup=true`), so sessions start warm without manual calls.
602
+ If `autoBootstrapOnRead` is disabled through `brainlink_policy`, read tools return preflight-required responses.
603
+ `brainlink_bootstrap`, `brainlink_policy` and preflight responses include structured `nextActions` so clients can continue tool flows automatically.
604
+ `brainlink_policy` also accepts policy presets (`fully-auto`, `strict`) so MCP clients can switch behavior in one call.
605
+ `brainlink_recommendations` returns the suggested execution order so an agent can follow Brainlink best practices automatically.
606
+
533
607
  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:
534
608
 
535
609
  `brainlink_graph` returns weighted edges. Agents should prefer higher `weight` and stronger `priority` when deciding which related notes matter most.
610
+ `brainlink_add_note` and `brainlink_add_file` return `writeConnectivity` metadata and guarantee at least one edge for new notes.
536
611
 
537
612
  ```bash
538
613
  export BRAINLINK_ALLOWED_VAULTS="/absolute/path/to/project-vault"
@@ -34,6 +34,8 @@ src/
34
34
 
35
35
  cli/
36
36
  commands/
37
+ agent-commands.ts
38
+ config-commands.ts
37
39
  read-commands.ts
38
40
  write-commands.ts
39
41
  main.ts
@@ -57,7 +59,13 @@ src/
57
59
  schema.ts
58
60
  search-reader.ts
59
61
  file-system-vault.ts
62
+ session-state.ts
60
63
  sqlite-index.ts
64
+
65
+ mcp/
66
+ main.ts
67
+ server.ts
68
+ tools.ts
61
69
  ```
62
70
 
63
71
  ## Domain
@@ -181,6 +189,9 @@ MCP client
181
189
  ```
182
190
 
183
191
  The MCP adapter stays thin. It validates tool inputs, resolves the configured vault and calls the same application use cases used by the CLI.
192
+ At server startup, Brainlink runs a bootstrap pass on the configured default vault/agent, then keeps enforcing bootstrap policy on read tools.
193
+ When `mode`/`limit`/`tokens` are omitted, MCP read tools resolve per-agent defaults from `agentProfiles` and then fallback to global config defaults.
194
+ Session bootstrap state is persisted in `$BRAINLINK_HOME/session-state.json` so read tools can enforce bootstrap policy per vault/agent and auto-bootstrap reads when configured.
184
195
 
185
196
  ## Link Resolution
186
197
 
@@ -287,10 +298,11 @@ Markdown keeps the system portable, inspectable, Git-friendly, and compatible wi
287
298
  ### SQLite As Local Index
288
299
 
289
300
  SQLite gives fast local search, local vector storage and rebuildable retrieval without forcing users to run external infrastructure.
301
+ Hybrid retrieval also uses a short-lived in-memory cache keyed by vault/query/agent and invalidated by index file mtime to reduce repeated query latency.
290
302
 
291
303
  ### CLI First
292
304
 
293
- The CLI is the smallest useful integration surface for agents. HTTP is a local inspection adapter, and MCP can be implemented outside this package by wrapping the CLI.
305
+ The CLI is the smallest useful integration surface for agents. HTTP is a local inspection adapter, and Brainlink also ships a built-in MCP server (`brainlink-mcp`) that uses the same application use cases.
294
306
 
295
307
  ### Functional Core
296
308
 
@@ -0,0 +1,103 @@
1
+ # Quickstart
2
+
3
+ Use this path when you want Brainlink running as agent memory with the smallest setup.
4
+
5
+ ## 1) Install Brainlink
6
+
7
+ ```bash
8
+ npm install -g @andespindola/brainlink@latest
9
+ ```
10
+
11
+ ## 2) Install Agent Integration
12
+
13
+ ```bash
14
+ blink agent install --self-test
15
+ blink agent upgrade
16
+ blink agent policy --preset fully-auto
17
+ blink agent status
18
+ ```
19
+
20
+ For local plugin gallery in this repository:
21
+
22
+ ```bash
23
+ blink agent install --plugin-path ./plugins/brainlink --self-test
24
+ ```
25
+
26
+ One-command setup and readiness check:
27
+
28
+ ```bash
29
+ blink quickstart --query "what should I know before this task?" --json
30
+ ```
31
+
32
+ ## 3) Initialize Or Select Vault
33
+
34
+ ```bash
35
+ blink init
36
+ blink config where
37
+ ```
38
+
39
+ To set a different default vault:
40
+
41
+ ```bash
42
+ blink config set-vault /absolute/path/to/vault
43
+ ```
44
+
45
+ Optional per-agent retrieval defaults in `brainlink.config.json`:
46
+
47
+ ```json
48
+ {
49
+ "agentProfiles": {
50
+ "coding-agent": {
51
+ "defaultSearchMode": "semantic",
52
+ "defaultSearchLimit": 8,
53
+ "defaultContextTokens": 2400
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## 4) Run Bootstrap Before Work
60
+
61
+ MCP clients should call `brainlink_bootstrap` first for each vault/agent session.
62
+ Read tools auto-bootstrap by default when state is missing/stale, and bootstrap/preflight responses include structured `nextActions` for automatic client flows.
63
+ MCP startup also runs bootstrap automatically for the configured default vault/agent.
64
+
65
+ For CLI workflows:
66
+
67
+ ```bash
68
+ blink context "what should I know before this task?" --mode hybrid --json
69
+ ```
70
+
71
+ ## 5) Write Durable Memory
72
+
73
+ ```bash
74
+ blink add "Architecture Decision" --content "Use explicit [[Bounded Context]] links and #tags. #architecture #decision"
75
+ ```
76
+
77
+ ## 6) Validate Health
78
+
79
+ ```bash
80
+ blink validate
81
+ blink doctor
82
+ blink stats --extended --json
83
+ ```
84
+
85
+ ## 7) Migrate Existing Memory (Optional)
86
+
87
+ Preview first:
88
+
89
+ ```bash
90
+ blink migrate-vault --from ~/.brainlink/vault --to ./team-vault --dry-run --report ./migration-report.json
91
+ ```
92
+
93
+ Apply:
94
+
95
+ ```bash
96
+ blink migrate-vault --from ~/.brainlink/vault --to ./team-vault --report ./migration-report.json
97
+ ```
98
+
99
+ S3 target:
100
+
101
+ ```bash
102
+ blink migrate-vault --from ~/.brainlink/vault --to "s3://my-memory-bucket/brainlink" --dry-run
103
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andespindola/brainlink",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0-beta.9",
4
4
  "description": "Local-first knowledge memory for agents with Markdown, backlinks, indexing and context retrieval.",
5
5
  "type": "module",
6
6
  "license": "MIT",