context-vault 3.10.0 → 3.12.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.
Files changed (32) hide show
  1. package/.claude-plugin/README.md +219 -0
  2. package/.claude-plugin/plugin.json +11 -0
  3. package/.mcp.json +9 -0
  4. package/bin/cli.js +105 -88
  5. package/commands/vault-cleanup.md +43 -0
  6. package/commands/vault-snapshot.md +43 -0
  7. package/commands/vault-status.md +35 -0
  8. package/dist/register-tools.d.ts.map +1 -1
  9. package/dist/register-tools.js +27 -3
  10. package/dist/register-tools.js.map +1 -1
  11. package/dist/server.js +18 -0
  12. package/dist/server.js.map +1 -1
  13. package/node_modules/@context-vault/core/dist/embed.d.ts.map +1 -1
  14. package/node_modules/@context-vault/core/dist/embed.js +24 -11
  15. package/node_modules/@context-vault/core/dist/embed.js.map +1 -1
  16. package/node_modules/@context-vault/core/dist/index.d.ts +1 -0
  17. package/node_modules/@context-vault/core/dist/index.d.ts.map +1 -1
  18. package/node_modules/@context-vault/core/dist/index.js +36 -31
  19. package/node_modules/@context-vault/core/dist/index.js.map +1 -1
  20. package/node_modules/@context-vault/core/dist/search.d.ts.map +1 -1
  21. package/node_modules/@context-vault/core/dist/search.js +46 -0
  22. package/node_modules/@context-vault/core/dist/search.js.map +1 -1
  23. package/node_modules/@context-vault/core/package.json +1 -1
  24. package/node_modules/@context-vault/core/src/embed.ts +29 -13
  25. package/node_modules/@context-vault/core/src/index.ts +41 -37
  26. package/node_modules/@context-vault/core/src/search.ts +50 -0
  27. package/package.json +6 -2
  28. package/skills/context-assembly/SKILL.md +308 -0
  29. package/skills/knowledge-capture/SKILL.md +303 -0
  30. package/skills/memory-management/SKILL.md +237 -0
  31. package/src/register-tools.ts +39 -2
  32. package/src/server.ts +16 -0
@@ -0,0 +1,219 @@
1
+ # context-vault Claude Plugin
2
+
3
+ Persistent memory and knowledge management for AI agents. Save decisions, insights, patterns, and context across sessions using semantic search and project-scoped buckets.
4
+
5
+ ## What is context-vault?
6
+
7
+ context-vault is a local-first memory system that lets Claude persistently store and retrieve knowledge. Think of it as a personal knowledge base that follows you across sessions, projects, and contexts.
8
+
9
+ ### Key Features
10
+
11
+ - **Persistent Memory** -- Save insights, decisions, patterns, and references across sessions
12
+ - **Semantic Search** -- Find entries by meaning, not just keywords
13
+ - **Project Buckets** -- Organize entries by project for easy scoping
14
+ - **Team Vaults** -- Share knowledge with your team (requires hosted API)
15
+ - **Deduplication** -- Automatic detection of similar entries
16
+ - **Encoding Context** -- Future-proof your saves with metadata for discovery months later
17
+ - **Snapshot Briefs** -- Consolidate scattered entries into a single context brief
18
+ - **Recall Tracking** -- Monitor how often your entries are actually used
19
+
20
+ ## Installation
21
+
22
+ Install via Claude Code:
23
+
24
+ ```
25
+ /plugin install context-vault
26
+ ```
27
+
28
+ For full setup with embedding model download and agent rules:
29
+
30
+ ```bash
31
+ npx context-vault setup
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ### Save Your First Insight
37
+
38
+ ```javascript
39
+ save_context({
40
+ kind: "insight",
41
+ title: "PostgreSQL connection pooling lesson",
42
+ body: "Connections without pooling exhausted at 100 concurrent users...",
43
+ tags: ["bucket:myproject", "database"],
44
+ encoding_context: { project: "myproject", arc: "scaling", task: "investigation" }
45
+ })
46
+ ```
47
+
48
+ ### Load Context for a Task
49
+
50
+ ```javascript
51
+ // At the start of a session, scope to your project and get an overview
52
+ clear_context({
53
+ preload_bucket: "myproject",
54
+ max_tokens: 4000
55
+ })
56
+
57
+ // Then search for specific context
58
+ get_context({
59
+ query: "how do we handle database scaling?",
60
+ buckets: ["myproject"]
61
+ })
62
+ ```
63
+
64
+ ### Create a Context Brief
65
+
66
+ ```javascript
67
+ create_snapshot({
68
+ topic: "API authentication decisions",
69
+ buckets: ["myproject"]
70
+ })
71
+ ```
72
+
73
+ ## Commands
74
+
75
+ Three slash commands for common vault workflows:
76
+
77
+ - **/vault-status** -- Check vault health (entry counts, recall ratio, warnings)
78
+ - **/vault-snapshot** -- Create a consolidated context brief for a topic
79
+ - **/vault-cleanup** -- Triage stale entries, consolidate duplicates, manage growth
80
+
81
+ ## Skills
82
+
83
+ Three skills teach Claude how to use the vault effectively:
84
+
85
+ ### 1. Memory Management
86
+ When to save, what kind to use, how to tag entries, and how to keep your vault healthy.
87
+
88
+ ### 2. Knowledge Capture
89
+ Session-end protocol: extract and save the insights and decisions you discovered.
90
+
91
+ ### 3. Context Assembly
92
+ Load relevant knowledge at task start. Assemble context efficiently and scope to your project.
93
+
94
+ ## Use Cases
95
+
96
+ ### Personal Memory
97
+ Save decisions and insights from your work, then access them months later.
98
+
99
+ ```javascript
100
+ save_context({
101
+ kind: "decision",
102
+ title: "Chose SQLite + embeddings for local RAG",
103
+ body: "Evaluated: PostgreSQL (setup), Pinecone (cost), local SQLite (simplicity). Chose SQLite + sqlite-vec for full control and no external dependencies.",
104
+ tags: ["bucket:rag-project", "architecture", "database"],
105
+ tier: "durable"
106
+ })
107
+ ```
108
+
109
+ ### Team Knowledge Sharing
110
+ Capture lessons learned that the team should know, then publish to a shared vault.
111
+
112
+ ```javascript
113
+ save_context({
114
+ kind: "pattern",
115
+ title: "Always test OAuth flow end-to-end on real device",
116
+ body: "Simulator behavior differs from real devices. Always test with physical phone before production.",
117
+ tags: ["bucket:mobile-team", "oauth", "testing"],
118
+ tier: "durable"
119
+ })
120
+
121
+ // Later, share to team vault
122
+ publish_to_team({ id: "entry-id" })
123
+ ```
124
+
125
+ ### Project Onboarding
126
+ Create a snapshot of all decisions and patterns for a new team member.
127
+
128
+ ```javascript
129
+ create_snapshot({
130
+ topic: "project architecture and key decisions",
131
+ buckets: ["project-x"],
132
+ kinds: ["decision", "pattern"]
133
+ })
134
+ ```
135
+
136
+ ## Tools Reference
137
+
138
+ The plugin provides 14 MCP tools:
139
+
140
+ ### Read-Only (no side effects)
141
+ - `list_context` -- Browse entries by kind, tags, date range
142
+ - `context_status` -- Vault health dashboard (entry counts, recall stats, warnings)
143
+ - `list_buckets` -- List all project buckets
144
+ - `session_start` -- Load project context at session start
145
+
146
+ ### Read with Analytics (update access counters as side effect)
147
+ - `get_context` -- Search vault by query, kind, bucket, or date. Updates `hit_count` and `recall_count` on returned entries.
148
+ - `recall` -- Proactive context surfacing. Takes a `signal` (text) and `signal_type` (prompt/error/file/task), returns relevant hints. Records co-retrieval pairs.
149
+
150
+ ### Write (create new entries)
151
+ - `save_context` -- Create or update an entry. Supports `encoding_context` for future discovery and `supersedes` to retire old entries.
152
+ - `create_snapshot` -- Consolidate scattered entries into a single brief. Returns a confirmation with the new entry's ID and identity_key.
153
+ - `ingest_url` -- Fetch a web page and save as a reference entry
154
+ - `ingest_project` -- Scan a project directory and save metadata
155
+ - `session_end` -- Capture session learnings (auto-save insights)
156
+ - `publish_to_team` -- Copy an entry to your team vault
157
+
158
+ ### Destructive (modify or delete existing data)
159
+ - `delete_context` -- Permanently remove an entry by ID
160
+ - `clear_context` -- Reset session scope. With `preload_bucket`, returns recent entries from that bucket in the response.
161
+
162
+ ## Storage
163
+
164
+ Data is stored in two locations:
165
+
166
+ ```
167
+ ~/.context-mcp/ # Data directory
168
+ ├── vault.db # SQLite database (entries, embeddings, FTS index)
169
+ ├── config.json # User configuration
170
+ └── telemetry.jsonl # Local usage telemetry
171
+
172
+ ~/vault/ (or configured path) # Vault directory (markdown source of truth)
173
+ ├── knowledge/ # Decisions, insights, patterns, references
174
+ ├── entity/ # People, projects, tools
175
+ └── event/ # Session logs, activity
176
+ ```
177
+
178
+ Markdown files are the source of truth. The SQLite database is a derived index, rebuildable via `context-vault reindex`.
179
+
180
+ ## Privacy
181
+
182
+ **Local-first:** All data stored locally on your machine. No network calls unless you explicitly enable hosted sync or team vaults.
183
+
184
+ **Hosted sync (optional):** When configured, entries sync to your personal cloud vault (per-user isolated database). Team vault entries are shared only when you call `publish_to_team`.
185
+
186
+ **Your vault is never accessed or indexed by third parties.** Full privacy policy: https://context-vault.com/privacy
187
+
188
+ ## Tips
189
+
190
+ - **Encoding context is key:** Entries without `encoding_context` are rarely discovered later. Always include project, arc, and task.
191
+ - **Check before saving:** Call `get_context` first to avoid duplicates. Duplicates hurt recall ratio.
192
+ - **Use tiers wisely:** `durable` for architecture decisions, `working` (default) for active context, `ephemeral` for temp notes.
193
+ - **Snapshot for scale:** If you have 20+ entries on a topic, create a snapshot instead of loading them individually.
194
+ - **Recall ratio:** 20-30% is healthy. Run `/vault-status` to check yours.
195
+
196
+ ## Troubleshooting
197
+
198
+ **"I can't find my entry"**
199
+ - Check the right bucket: `get_context({ query: "...", buckets: ["myproject"] })`
200
+ - Try a broader query: "authentication" instead of "OAuth 2.0 PKCE state handling"
201
+ - Browse by kind: `list_context({ kind: "decision", tags: ["bucket:myproject"] })`
202
+
203
+ **"Vault is growing too fast"**
204
+ - Run `/vault-cleanup` to identify stale or duplicate entries
205
+ - Create snapshots to consolidate large topics
206
+ - Check for session/debug noise mixed with knowledge entries
207
+
208
+ **"Embeddings not working"**
209
+ - Run `context-vault reindex` to regenerate the embedding index
210
+ - Run `context-vault doctor` for a full diagnostic
211
+
212
+ ## Support
213
+
214
+ - GitHub: https://github.com/fellanH/context-vault/issues
215
+ - Website: https://context-vault.com
216
+
217
+ ## License
218
+
219
+ MIT
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "context-vault",
3
+ "version": "3.10.0",
4
+ "description": "Persistent memory and knowledge management for AI agents. Save decisions, insights, patterns, and context across sessions. Semantic search, project-scoped buckets, team vaults, and recall tracking.",
5
+ "author": "Klarhimmel",
6
+ "homepage": "https://context-vault.com",
7
+ "repository": "https://github.com/fellanH/context-vault",
8
+ "license": "MIT",
9
+ "keywords": ["memory", "knowledge", "vault", "context", "mcp", "persistence", "recall"],
10
+ "categories": ["productivity", "knowledge-management", "developer-tools"]
11
+ }
package/.mcp.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "mcpServers": {
3
+ "context-vault": {
4
+ "command": "context-vault",
5
+ "args": ["serve"]
6
+ }
7
+ }
8
+ }
9
+
package/bin/cli.js CHANGED
@@ -85,6 +85,48 @@ function isNpx() {
85
85
  return ROOT.includes('/_npx/') || ROOT.includes('\\_npx\\');
86
86
  }
87
87
 
88
+ /** Check if a global install of context-vault exists on PATH (not npx cache) */
89
+ function hasGlobalInstall() {
90
+ try {
91
+ const cmd = platform() === 'win32' ? 'where context-vault' : 'which context-vault';
92
+ const which = execSync(cmd, { encoding: 'utf-8', stdio: 'pipe', timeout: 3000 }).trim();
93
+ return !!which && !which.includes('/_npx/') && !which.includes('\\_npx\\');
94
+ } catch { return false; }
95
+ }
96
+
97
+ /**
98
+ * Determine the best server config for tool MCP configs.
99
+ * Priority: global binary > npx fallback > local dev path.
100
+ * Even when running via npx, prefer the global binary if it exists
101
+ * (e.g., we just installed it during setup).
102
+ */
103
+ function getServerConfig(vaultDir) {
104
+ const serverArgs = ['serve'];
105
+ if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
106
+
107
+ if (hasGlobalInstall()) {
108
+ return { command: 'context-vault', args: serverArgs };
109
+ }
110
+ if (isNpx()) {
111
+ return {
112
+ command: 'npx',
113
+ args: ['-y', 'context-vault', 'serve', ...(vaultDir ? ['--vault-dir', vaultDir] : [])],
114
+ env: { NODE_OPTIONS: '--no-warnings=ExperimentalWarning' },
115
+ };
116
+ }
117
+ if (isInstalledPackage()) {
118
+ return { command: 'context-vault', args: serverArgs };
119
+ }
120
+ // Local dev clone
121
+ const nodeArgs = [SERVER_PATH];
122
+ if (vaultDir) nodeArgs.push('--vault-dir', vaultDir);
123
+ return {
124
+ command: process.execPath,
125
+ args: nodeArgs,
126
+ env: { NODE_OPTIONS: '--no-warnings=ExperimentalWarning' },
127
+ };
128
+ }
129
+
88
130
  /** Detect user experience level based on dev environment signals */
89
131
  function detectUserExperience() {
90
132
  if (isNonInteractive) return 'developer';
@@ -760,6 +802,58 @@ async function runSetup() {
760
802
  console.log();
761
803
  }
762
804
 
805
+ // Global install: when running via npx, offer to install globally so the
806
+ // MCP server binary is on PATH. This makes tool configs reliable (no npx
807
+ // cache dependency) and startup faster (no npx overhead on every spawn).
808
+ if (isNpx() && !isDryRun) {
809
+ const hasGlobal = (() => {
810
+ try {
811
+ const cmd = platform() === 'win32' ? 'where context-vault' : 'which context-vault';
812
+ const which = execSync(cmd, { encoding: 'utf-8', stdio: 'pipe', timeout: 3000 }).trim();
813
+ // Verify it's not pointing back to the npx cache
814
+ return which && !which.includes('/_npx/') && !which.includes('\\_npx\\');
815
+ } catch { return false; }
816
+ })();
817
+
818
+ if (!hasGlobal) {
819
+ if (!isNonInteractive) {
820
+ console.log(dim(' context-vault needs a permanent install to run as an MCP server.'));
821
+ console.log(dim(' Without it, AI tools must re-download the package on every launch.\n'));
822
+ const installAnswer = await prompt(' Install globally via npm? (Y/n):', 'Y');
823
+ if (installAnswer.toLowerCase() !== 'n') {
824
+ console.log();
825
+ try {
826
+ console.log(dim(' Installing context-vault globally...\n'));
827
+ execSync('npm install -g context-vault@' + VERSION, {
828
+ stdio: 'inherit',
829
+ timeout: 120000,
830
+ });
831
+ console.log(`\n ${green('✓')} Installed context-vault v${VERSION} globally\n`);
832
+ } catch (e) {
833
+ console.log(`\n ${yellow('!')} Global install failed: ${e.message}`);
834
+ console.log(dim(' Falling back to npx-based config. You can install later:'));
835
+ console.log(dim(' npm install -g context-vault\n'));
836
+ }
837
+ } else {
838
+ console.log(dim('\n Skipped. MCP configs will use npx (slower startup).\n'));
839
+ }
840
+ } else {
841
+ // Non-interactive (--yes): auto-install globally
842
+ try {
843
+ console.log(dim(' Installing context-vault globally...\n'));
844
+ execSync('npm install -g context-vault@' + VERSION, {
845
+ stdio: ['pipe', 'pipe', 'pipe'],
846
+ timeout: 120000,
847
+ });
848
+ console.log(` ${green('✓')} Installed context-vault v${VERSION} globally\n`);
849
+ } catch (e) {
850
+ console.log(` ${yellow('!')} Global install failed: ${e.message}`);
851
+ console.log(dim(' Continuing with npx-based config.\n'));
852
+ }
853
+ }
854
+ }
855
+ }
856
+
763
857
  // Detect tools
764
858
  console.log(dim(` [1/7]`) + bold(' Detecting tools...\n'));
765
859
  verbose(userLevel, 'Scanning for AI tools on this machine.');
@@ -1480,53 +1574,13 @@ async function configureClaude(tool, vaultDir) {
1480
1574
  }
1481
1575
 
1482
1576
  try {
1483
- if (isNpx()) {
1484
- const serverArgs = ['-y', 'context-vault', 'serve'];
1485
- if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
1486
- execFileSync(
1487
- 'claude',
1488
- [
1489
- 'mcp',
1490
- 'add',
1491
- '-s',
1492
- 'user',
1493
- 'context-vault',
1494
- '-e',
1495
- 'NODE_OPTIONS=--no-warnings=ExperimentalWarning',
1496
- '--',
1497
- 'npx',
1498
- ...serverArgs,
1499
- ],
1500
- { stdio: 'pipe', env }
1501
- );
1502
- } else if (isInstalledPackage()) {
1503
- const serverArgs = ['serve'];
1504
- if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
1505
- execFileSync(
1506
- 'claude',
1507
- ['mcp', 'add', '-s', 'user', 'context-vault', '--', 'context-vault', ...serverArgs],
1508
- { stdio: 'pipe', env }
1509
- );
1510
- } else {
1511
- const nodeArgs = [SERVER_PATH];
1512
- if (vaultDir) nodeArgs.push('--vault-dir', vaultDir);
1513
- execFileSync(
1514
- 'claude',
1515
- [
1516
- 'mcp',
1517
- 'add',
1518
- '-s',
1519
- 'user',
1520
- 'context-vault',
1521
- '-e',
1522
- 'NODE_OPTIONS=--no-warnings=ExperimentalWarning',
1523
- '--',
1524
- process.execPath,
1525
- ...nodeArgs,
1526
- ],
1527
- { stdio: 'pipe', env }
1528
- );
1577
+ const srvCfg = getServerConfig(vaultDir);
1578
+ const claudeArgs = ['mcp', 'add', '-s', 'user', 'context-vault'];
1579
+ if (srvCfg.env?.NODE_OPTIONS) {
1580
+ claudeArgs.push('-e', `NODE_OPTIONS=${srvCfg.env.NODE_OPTIONS}`);
1529
1581
  }
1582
+ claudeArgs.push('--', srvCfg.command, ...srvCfg.args);
1583
+ execFileSync('claude', claudeArgs, { stdio: 'pipe', env });
1530
1584
  } catch (e) {
1531
1585
  const stderr = e.stderr?.toString().trim();
1532
1586
  throw new Error(stderr || e.message);
@@ -1542,25 +1596,10 @@ async function configureCodex(tool, vaultDir) {
1542
1596
  }
1543
1597
 
1544
1598
  try {
1545
- if (isNpx()) {
1546
- const serverArgs = ['-y', 'context-vault', 'serve'];
1547
- if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
1548
- execFileSync('codex', ['mcp', 'add', 'context-vault', '--', 'npx', ...serverArgs], {
1549
- stdio: 'pipe',
1550
- });
1551
- } else if (isInstalledPackage()) {
1552
- const serverArgs = ['serve'];
1553
- if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
1554
- execFileSync('codex', ['mcp', 'add', 'context-vault', '--', 'context-vault', ...serverArgs], {
1555
- stdio: 'pipe',
1556
- });
1557
- } else {
1558
- const nodeArgs = [SERVER_PATH];
1559
- if (vaultDir) nodeArgs.push('--vault-dir', vaultDir);
1560
- execFileSync('codex', ['mcp', 'add', 'context-vault', '--', process.execPath, ...nodeArgs], {
1561
- stdio: 'pipe',
1562
- });
1563
- }
1599
+ const srvCfg = getServerConfig(vaultDir);
1600
+ execFileSync('codex', ['mcp', 'add', 'context-vault', '--', srvCfg.command, ...srvCfg.args], {
1601
+ stdio: 'pipe',
1602
+ });
1564
1603
  } catch (e) {
1565
1604
  const stderr = e.stderr?.toString().trim();
1566
1605
  throw new Error(stderr || e.message);
@@ -1664,29 +1703,7 @@ function configureJsonTool(tool, vaultDir) {
1664
1703
  // Clean up old "context-mcp" key
1665
1704
  delete config[tool.configKey]['context-mcp'];
1666
1705
 
1667
- if (isNpx()) {
1668
- const serverArgs = vaultDir ? ['--vault-dir', vaultDir] : [];
1669
- config[tool.configKey]['context-vault'] = {
1670
- command: 'npx',
1671
- args: ['-y', 'context-vault', 'serve', ...serverArgs],
1672
- env: { NODE_OPTIONS: '--no-warnings=ExperimentalWarning' },
1673
- };
1674
- } else if (isInstalledPackage()) {
1675
- const serverArgs = ['serve'];
1676
- if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
1677
- config[tool.configKey]['context-vault'] = {
1678
- command: 'context-vault',
1679
- args: serverArgs,
1680
- };
1681
- } else {
1682
- const serverArgs = [SERVER_PATH];
1683
- if (vaultDir) serverArgs.push('--vault-dir', vaultDir);
1684
- config[tool.configKey]['context-vault'] = {
1685
- command: process.execPath,
1686
- args: serverArgs,
1687
- env: { NODE_OPTIONS: '--no-warnings=ExperimentalWarning' },
1688
- };
1689
- }
1706
+ config[tool.configKey]['context-vault'] = getServerConfig(vaultDir);
1690
1707
 
1691
1708
  writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
1692
1709
  }
@@ -0,0 +1,43 @@
1
+ # /vault-cleanup — Vault Maintenance
2
+
3
+ Identify stale, duplicate, or low-value entries and help the user clean up their vault.
4
+
5
+ ## Steps
6
+
7
+ 1. **Gather vault state.** Call `context_status()` to get entry counts, kind breakdown, recall stats, and warnings.
8
+
9
+ 2. **Identify cleanup candidates.** Use `list_context` to browse entries that may need attention:
10
+ ```
11
+ list_context({ kind: "session", limit: 20 })
12
+ list_context({ kind: "feedback", tags: ["auto-captured"], limit: 20 })
13
+ list_context({ kind: "observation", limit: 20 })
14
+ ```
15
+ Review results for entries with `recall_count: 0` (never recalled) and old `created_at` dates.
16
+
17
+ 3. **Check for duplicates.** Search for topics the user likely has many entries on:
18
+ ```
19
+ get_context({ query: "<suspected duplicate topic>", buckets: ["<project>"], limit: 15 })
20
+ ```
21
+ If multiple entries cover the same insight, suggest consolidating via `create_snapshot`.
22
+
23
+ 4. **Present a triage report.** For each category, show:
24
+ - Entry title, kind, created date, recall count
25
+ - Recommended action: **delete**, **consolidate**, **expire**, or **keep**
26
+
27
+ 5. **Execute only user-approved actions.** Wait for explicit confirmation before any deletion.
28
+
29
+ ## Available Actions
30
+
31
+ | Action | How | When |
32
+ |--------|-----|------|
33
+ | **Delete** | `delete_context({ id: "<entry-id>" })` | Duplicates, noise, irrelevant entries |
34
+ | **Consolidate** | `create_snapshot({ topic: "...", buckets: ["..."] })` | Many scattered entries on one topic |
35
+ | **Set to expire** | `save_context({ id: "<entry-id>", tier: "ephemeral" })` | Stale but not worth deleting now |
36
+ | **Supersede** | `save_context({ title: "...", body: "...", supersedes: ["<old-id>"] })` | Replace outdated with current |
37
+
38
+ ## Important
39
+
40
+ - `delete_context` is **permanent and irreversible**. Always confirm with the user.
41
+ - There is no bulk delete. Each deletion requires a separate call with a specific entry ID.
42
+ - There is no "archive" or "soft delete." To deprioritize without deleting, set `tier: "ephemeral"`.
43
+ - Do not reference tools or parameters that don't exist. Only use: `context_status`, `list_context`, `get_context`, `delete_context`, `save_context`, `create_snapshot`.
@@ -0,0 +1,43 @@
1
+ # /vault-snapshot — Create a Context Brief
2
+
3
+ Consolidate scattered vault entries on a topic into a single brief.
4
+
5
+ ## Steps
6
+
7
+ 1. Ask the user what topic they want a snapshot of. Also ask which project bucket to scope to (if not obvious from context).
8
+
9
+ 2. Call `create_snapshot` with the topic as a **natural language search query** (not a slug):
10
+ ```
11
+ create_snapshot({
12
+ topic: "API authentication decisions and patterns",
13
+ buckets: ["project-name"],
14
+ kinds: ["decision", "pattern"],
15
+ tags: ["authentication"]
16
+ })
17
+ ```
18
+ All parameters except `topic` are optional. `kinds` filters by entry kind. `tags` adds tag filters. `buckets` scopes to a project.
19
+
20
+ 3. The tool returns a short confirmation (not the brief content):
21
+ ```
22
+ ✓ Snapshot created → id: <entry-id>
23
+ title: <topic> — Context Brief
24
+ identity_key: snapshot-<slugified-topic>
25
+ synthesized from: N entries
26
+ ```
27
+ The brief is saved to the vault as a `kind: brief` entry.
28
+
29
+ 4. To show the user the brief, make a follow-up call:
30
+ ```
31
+ get_context({ kind: "brief", identity_key: "snapshot-<slugified-topic>" })
32
+ ```
33
+
34
+ 5. Present the brief and offer next steps:
35
+ - "Share this with your team" via `publish_to_team({ id: "<entry-id>" })`
36
+ - "Create another snapshot on a related topic"
37
+ - "Search for more context" via `get_context`
38
+
39
+ ## Tips
40
+
41
+ - The `topic` is used as a search query (hybrid FTS + semantic). Use descriptive natural language for best results. "API authentication decisions" works better than "api-auth".
42
+ - If "no entries found," try a broader query or different bucket.
43
+ - Snapshots are idempotent on `identity_key`. Re-running with the same topic updates the existing snapshot.
@@ -0,0 +1,35 @@
1
+ # /vault-status — Vault Health Check
2
+
3
+ Check the health and metrics of your context vault.
4
+
5
+ ## Steps
6
+
7
+ 1. Call `context_status()` (no arguments needed).
8
+ 2. The tool returns a structured markdown dashboard with sections for entries by kind, recall frequency, learning rate, stale knowledge, growth warnings, and suggested actions. Present it to the user.
9
+ 3. After presenting the dashboard, add your own analysis (see below).
10
+
11
+ ## Analysis Guidelines
12
+
13
+ **Positive signals to highlight:**
14
+ - High embedding coverage (>90%)
15
+ - Active recall (recall:save ratio above 1:1)
16
+ - Regular saves per session (>1.0)
17
+ - No stale paths or startup errors
18
+
19
+ **Warning signs to flag:**
20
+ - Embedding coverage below 80%: suggest running `context-vault reindex`
21
+ - Zero saves in 30 days: knowledge may be getting lost between sessions
22
+ - Stale paths detected: auto-reindex will fix on next search
23
+ - Growth warnings present: review the kind breakdown for noise (session, feedback entries dominating)
24
+ - Stale knowledge entries: the tool flags entries not updated within their kind-specific staleness window (pattern: 180d, decision: 365d, reference: 90d)
25
+ - Startup errors in the error log: point the user to the log path
26
+
27
+ **Recall ratio (JSON block at the end of the dashboard):**
28
+ - Below 0.10: most entries are never retrieved. Suggest better tagging, encoding_context, and snapshots.
29
+ - Above 0.25: healthy.
30
+
31
+ ## Do NOT
32
+
33
+ - Fabricate metrics or example output. Only report what the tool returns.
34
+ - Suggest `npm run build` for any issue. The correct commands are `context-vault reindex`, `context-vault doctor`, or `context-vault setup`.
35
+ - Invent thresholds. Use the warnings the tool itself generates.
@@ -1 +1 @@
1
- {"version":3,"file":"register-tools.d.ts","sourceRoot":"","sources":["../src/register-tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAmDlE,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAwI9D"}
1
+ {"version":3,"file":"register-tools.d.ts","sourceRoot":"","sources":["../src/register-tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAkFlE,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CA8I9D"}
@@ -38,6 +38,27 @@ const toolModules = [
38
38
  publishToTeam,
39
39
  ];
40
40
  const TOOL_TIMEOUT_MS = 120_000;
41
+ const REINDEX_TIMEOUT_MS = 30_000;
42
+ const TOOL_ANNOTATIONS = {
43
+ // Read-only tools (4)
44
+ list_context: { readOnlyHint: true },
45
+ context_status: { readOnlyHint: true },
46
+ list_buckets: { readOnlyHint: true },
47
+ session_start: { readOnlyHint: true },
48
+ // Read with side-effect counters (2) — update hit_count/recall_count/co-retrievals
49
+ get_context: { readOnlyHint: false, destructiveHint: false },
50
+ recall: { readOnlyHint: false, destructiveHint: false },
51
+ // Additive write tools (3) — create entries, never delete/replace
52
+ create_snapshot: { readOnlyHint: false, destructiveHint: false },
53
+ ingest_url: { readOnlyHint: false, destructiveHint: false },
54
+ ingest_project: { readOnlyHint: false, destructiveHint: false },
55
+ // Destructive write tools (5) — may update/delete existing data
56
+ save_context: { readOnlyHint: false, destructiveHint: true },
57
+ delete_context: { readOnlyHint: false, destructiveHint: true },
58
+ clear_context: { readOnlyHint: false, destructiveHint: true },
59
+ session_end: { readOnlyHint: false, destructiveHint: true },
60
+ publish_to_team: { readOnlyHint: false, destructiveHint: true },
61
+ };
41
62
  // Reindex state hoisted to module scope so that in HTTP daemon mode
42
63
  // (where registerTools is called once per session), the reindex only
43
64
  // runs once for the entire process rather than once per connecting session.
@@ -132,12 +153,15 @@ export function registerTools(server, ctx) {
132
153
  return reindexPromise;
133
154
  return; // non-blocking: just ensure it's started
134
155
  }
135
- const promise = reindex(ctx, { fullSync: true })
156
+ const promise = Promise.race([
157
+ reindex(ctx, { fullSync: true, skipEmbeddings: true }),
158
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Reindex timeout (30s). FTS index may be incomplete.')), REINDEX_TIMEOUT_MS)),
159
+ ])
136
160
  .then((stats) => {
137
161
  reindexDone = true;
138
162
  const total = stats.added + stats.updated + stats.removed;
139
163
  if (total > 0) {
140
- console.error(`[context-vault] Auto-reindex: +${stats.added} ~${stats.updated} -${stats.removed} (${stats.unchanged} unchanged)`);
164
+ console.error(`[context-vault] Auto-reindex: +${stats.added} ~${stats.updated} -${stats.removed} (${stats.unchanged} unchanged, embeddings deferred)`);
141
165
  }
142
166
  })
143
167
  .catch((e) => {
@@ -163,7 +187,7 @@ export function registerTools(server, ctx) {
163
187
  },
164
188
  };
165
189
  for (const mod of toolModules) {
166
- server.tool(mod.name, mod.description, mod.inputSchema, tracked(((args) => mod.handler(args, ctx, shared)), mod.name));
190
+ server.tool(mod.name, mod.description, mod.inputSchema, TOOL_ANNOTATIONS[mod.name] ?? { readOnlyHint: false, destructiveHint: true }, tracked(((args) => mod.handler(args, ctx, shared)), mod.name));
167
191
  }
168
192
  ensureIndexed().catch(() => { });
169
193
  }