@andespindola/brainlink 1.2.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+
5
+ - **MCP server instructions on connect.** The server now advertises `instructions` in its initialize response, so clients that surface them (e.g. Claude Code) inject Brainlink's memory discipline into the agent's context the moment it connects — treat Brainlink as the default context source for everything, bootstrap first with a task query, use the full toolkit (both RAG and CAG via `strategy: auto`, context packs, hybrid search, the knowledge graph, explain/recommendations/validate/stats) instead of shallow retrieval, keep ephemeral facts in volatile memory, and persist durable learnings as connected notes. The field is advisory (clients that ignore it are unaffected) and no tool contract changed.
6
+
3
7
  ## 1.2.0
4
8
 
5
9
  - **Reciprocal Rank Fusion for hybrid search.** Hybrid mode now fuses the lexical (BM25) and semantic rankings by rank position (`Σ 1/(k+rank)`, k=60) instead of a fixed `0.6/0.4` min-max blend, which is robust to the two components' very different score scales. Gated by a new `hybridFusion` config (`rrf` default | `linear`); `fts`/`semantic` modes and stored data are unchanged.
@@ -0,0 +1,22 @@
1
+ // Advisory instructions sent to MCP clients in the initialize response. Clients
2
+ // that support the field (e.g. Claude Code) inject this text into the agent's
3
+ // context on connect, so every agent treats Brainlink as its default context
4
+ // source without per-agent configuration. Clients that ignore the field are
5
+ // unaffected — no tool contract depends on this text.
6
+ export const brainlinkServerInstructions = `Brainlink is your brain and canonical memory — your default context source for everything. It is the continuity of your cognition across turns and sessions, not an optional tool consulted when convenient. Keep it present in your context on every turn: operating without Brainlink context is an invalid state. Ground yourself in it before any decision, recommendation, question, or implementation, and write back to it after anything worth remembering.
7
+
8
+ Load context first — every session and whenever context is stale:
9
+ - Call brainlink_bootstrap first, passing a "query" describing the current task. This checks memory state and returns a grounding context package in the same call. Do this before acting on anything relevant.
10
+
11
+ Use the full potential, not shallow retrieval. Extract the maximum relevant context available before acting:
12
+ - Both retrieval modes: RAG (fresh on-demand assembly) AND CAG (reuse of still-fresh context packs). Prefer strategy "auto" (CAG on a fresh-pack hit, RAG otherwise); force "rag"/"cag" only with a clear reason. Inspect prebuilt packs with brainlink_context_packs.
13
+ - Hybrid search (mode "hybrid" = FTS + semantic) by default; use pure "fts"/"semantic" only when it clearly fits.
14
+ - The knowledge graph: brainlink_graph, brainlink_graph_contexts and context packs to navigate relations between notes and contexts.
15
+ - Explainability and quality: brainlink_explain (chunk/score), brainlink_recommendations, brainlink_validate, brainlink_stats, plus link/orphan/duplicate hygiene.
16
+ - Volatile turn memory: brainlink_volatile_add to stash useful within-session facts (they expire on a TTL); brainlink_volatile_clear to drop them.
17
+
18
+ Write back — after any durable learning (a preference, decision, pattern, or a change to a repo/config/doc that alters operating context):
19
+ - Persist it with brainlink_remember (or brainlink_add_note for explicit path/content). Write connected memory: include [[wiki links]], tags, and priority markers so the graph stays navigable — not loose notes.
20
+ - Reindex with brainlink_index and validate with brainlink_validate after writes when applicable.
21
+
22
+ Capture context early and proactively rather than reconstructing it later. When durability is uncertain but the reuse cost is low, capture anyway; use volatile memory for what is ephemeral. Anchoring everything you learn in Brainlink is what preserves your continuity between turns and sessions.`;
@@ -1,6 +1,7 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { addNoteInputSchema, addFileInputSchema, addFileTool, addNoteTool, addNotesInputSchema, addNotesTool, deleteNoteInputSchema, deleteNoteTool, deleteNotesInputSchema, deleteNotesTool, volatileAddInputSchema, volatileAddTool, volatileClearInputSchema, volatileClearTool, dedupeInputSchema, dedupeResolveInputSchema, dedupeResolveTool, dedupeTool, brokenLinksInputSchema, brokenLinksTool, bootstrapInputSchema, bootstrapTool, canonicalizeContextLinksInputSchema, canonicalizeContextLinksTool, contextInputSchema, contextPacksInputSchema, contextPacksTool, contextTool, doctorActionsInputSchema, doctorActionsTool, graphContextsInputSchema, graphContextsTool, graphInputSchema, graphTool, explainInputSchema, explainTool, indexInputSchema, indexTool, inboxAddInputSchema, inboxAddTool, inboxListInputSchema, inboxListTool, inboxProcessInputSchema, inboxProcessTool, orphansInputSchema, orphansTool, policyInputSchema, policyTool, projectInitInputSchema, projectInitTool, recommendationsInputSchema, recommendationsTool, rememberInputSchema, rememberTool, repairLinksInputSchema, repairLinksTool, searchInputSchema, searchTool, similarNotesInputSchema, similarNotesTool, sessionCloseInputSchema, sessionCloseTool, statsInputSchema, statsTool, suggestLinksInputSchema, suggestLinksTool, syncInputSchema, syncTool, validateInputSchema, validateTool, vaultCommitInputSchema, vaultCommitTool, vaultExportInputSchema, vaultExportTool, vaultHistoryInputSchema, vaultHistoryTool, vaultImportInputSchema, vaultImportTool, vaultInitInputSchema, vaultInitTool, vaultProvisionInputSchema, vaultProvisionTool, vaultPullInputSchema, vaultPullTool, vaultRestoreInputSchema, vaultRestoreTool, vaultStatusInputSchema, vaultStatusTool, versionInputSchema, versionTool } from './tools.js';
3
3
  import { getRuntimeVersion } from './runtime.js';
4
+ import { brainlinkServerInstructions } from './server-instructions.js';
4
5
  import { guardToolHandler } from './tool-guard.js';
5
6
  export const createBrainlinkMcpServer = () => {
6
7
  const server = new McpServer({
@@ -8,7 +9,7 @@ export const createBrainlinkMcpServer = () => {
8
9
  title: 'Brainlink',
9
10
  version: getRuntimeVersion(),
10
11
  description: 'Local-first Markdown memory tools for AI agents.'
11
- });
12
+ }, { instructions: brainlinkServerInstructions });
12
13
  // Route every tool registration through the error guard so a thrown handler
13
14
  // returns a structured isError result instead of propagating to the client.
14
15
  // Wrapping registerTool once keeps the call sites below unchanged and also
@@ -72,6 +72,10 @@ BRAINLINK_MCP_TOKEN="change-me" brainlink mcp-server \
72
72
 
73
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.
74
74
 
75
+ ## Server Instructions On Connect
76
+
77
+ The MCP server advertises `instructions` in its initialize response, so any client that surfaces them (for example Claude Code) injects Brainlink's memory discipline into the agent's context on connect — no per-agent prompt configuration required. The instructions tell the agent to treat Brainlink as its default context source: call `brainlink_bootstrap` first with a task `query`, prefer `strategy: auto` and `mode: hybrid`, stash within-session facts with `brainlink_volatile_add`, and persist durable learnings with `brainlink_remember` / `brainlink_add_note` (connected with `[[wiki links]]` and tags), reindexing afterwards. The field is advisory: clients that ignore `instructions` are unaffected and no tool contract depends on it.
78
+
75
79
  ## Agent Namespaces
76
80
 
77
81
  Each agent writes into a dedicated namespace under `agents/<agent-id>/`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andespindola/brainlink",
3
- "version": "1.2.0",
3
+ "version": "1.3.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",