context-vault 2.7.1 → 2.8.3

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 (37) hide show
  1. package/README.md +39 -375
  2. package/bin/cli.js +373 -230
  3. package/node_modules/@context-vault/core/package.json +7 -3
  4. package/node_modules/@context-vault/core/src/capture/file-ops.js +20 -2
  5. package/node_modules/@context-vault/core/src/capture/import-pipeline.js +11 -50
  6. package/node_modules/@context-vault/core/src/capture/importers.js +64 -37
  7. package/node_modules/@context-vault/core/src/capture/index.js +57 -15
  8. package/node_modules/@context-vault/core/src/capture/ingest-url.js +80 -44
  9. package/node_modules/@context-vault/core/src/constants.js +8 -0
  10. package/node_modules/@context-vault/core/src/core/config.js +65 -29
  11. package/node_modules/@context-vault/core/src/core/files.js +8 -15
  12. package/node_modules/@context-vault/core/src/core/frontmatter.js +22 -10
  13. package/node_modules/@context-vault/core/src/core/status.js +32 -15
  14. package/node_modules/@context-vault/core/src/index/db.js +47 -34
  15. package/node_modules/@context-vault/core/src/index/embed.js +15 -5
  16. package/node_modules/@context-vault/core/src/index/index.js +206 -52
  17. package/node_modules/@context-vault/core/src/index.js +39 -6
  18. package/node_modules/@context-vault/core/src/retrieve/index.js +40 -8
  19. package/node_modules/@context-vault/core/src/server/helpers.js +8 -6
  20. package/node_modules/@context-vault/core/src/server/tools/context-status.js +24 -10
  21. package/node_modules/@context-vault/core/src/server/tools/delete-context.js +8 -3
  22. package/node_modules/@context-vault/core/src/server/tools/get-context.js +117 -35
  23. package/node_modules/@context-vault/core/src/server/tools/ingest-url.js +34 -15
  24. package/node_modules/@context-vault/core/src/server/tools/list-context.js +59 -18
  25. package/node_modules/@context-vault/core/src/server/tools/save-context.js +164 -40
  26. package/node_modules/@context-vault/core/src/server/tools/submit-feedback.js +24 -18
  27. package/node_modules/@context-vault/core/src/server/tools.js +24 -28
  28. package/node_modules/@context-vault/core/src/sync/sync.js +24 -19
  29. package/package.json +2 -2
  30. package/scripts/local-server.js +334 -122
  31. package/scripts/postinstall.js +25 -10
  32. package/scripts/prepack.js +18 -15
  33. package/src/server/index.js +78 -29
  34. package/app-dist/assets/index-DjXoWapE.css +0 -1
  35. package/app-dist/assets/index-R4n9Qz4U.js +0 -380
  36. package/app-dist/index.html +0 -16
  37. package/node_modules/@context-vault/core/src/server/types.js +0 -78
package/README.md CHANGED
@@ -5,11 +5,7 @@
5
5
  [![license](https://img.shields.io/npm/l/context-vault)](./LICENSE)
6
6
  [![node](https://img.shields.io/node/v/context-vault)](https://nodejs.org)
7
7
 
8
- Persistent memory for AI agents — saves and searches knowledge across sessions.
9
-
10
- <p align="center">
11
- <img src="https://github.com/fellanH/context-vault/raw/main/demo.gif" alt="context-vault demo — Claude Code and Cursor using the knowledge vault" width="800">
12
- </p>
8
+ Persistent memory for AI agents — saves and searches knowledge across sessions. Your data stays local as plain markdown files.
13
9
 
14
10
  ## Quick Start
15
11
 
@@ -18,301 +14,50 @@ npm install -g context-vault
18
14
  context-vault setup
19
15
  ```
20
16
 
21
- Setup auto-detects your tools (Claude Code, Codex, Claude Desktop, Cursor, Windsurf, Antigravity, Cline), downloads the embedding model, seeds your vault with a starter entry, and verifies everything works. Then open your AI tool and try:
22
-
23
- > "Search my vault for getting started"
17
+ Setup auto-detects your AI tools (Claude Code, Codex, Claude Desktop, Cursor, Windsurf, Cline), downloads the embedding model (~22MB), seeds your vault with a starter entry, and verifies everything works.
24
18
 
25
- For hosted MCP setup (Claude Code, Cursor, GPT Actions), see [connect-in-2-minutes](https://github.com/fellanH/context-vault/blob/main/docs/distribution/connect-in-2-minutes.md).
19
+ Then open your AI tool and try: **"Search my vault for getting started"**
26
20
 
27
- > **Note:** `context-mcp` still works as a CLI alias but `context-vault` is the primary command.
21
+ > `context-mcp` still works as a CLI alias `context-vault` is the primary command.
28
22
 
29
23
  ## What It Does
30
24
 
31
- - **Save** insights, decisions, patterns, and any custom knowledge kind from AI sessions
32
- - **Search** with hybrid full-text + semantic similarity, ranked by relevance and recency
33
- - **Own your data** — plain markdown files in folders you control, git-versioned, human-editable
34
-
35
- ## Tools
36
-
37
- The server exposes six tools. Your AI agent calls them automatically — you don't invoke them directly.
38
-
39
- | Tool | Type | Description |
40
- |------|------|-------------|
41
- | `get_context` | Read | Hybrid FTS5 + vector search across all knowledge |
42
- | `save_context` | Write | Save new knowledge or update existing entries by ID |
43
- | `list_context` | Browse | List vault entries with filtering and pagination |
44
- | `delete_context` | Delete | Remove an entry by ID (file + index) |
45
- | `submit_feedback` | Write | Submit bug reports or feature requests |
46
- | `context_status` | Diag | Show resolved config, health, and per-kind file counts |
47
-
48
- ### `get_context` — Search your vault
49
-
50
- ```js
51
- get_context({
52
- query: "react query caching", // Natural language or keywords
53
- kind: "insight", // Optional: filter by kind
54
- tags: ["react"], // Optional: filter by tags
55
- limit: 5 // Optional: max results (default 10)
56
- })
57
- ```
58
-
59
- Returns entries ranked by combined full-text and semantic similarity, with recency weighting.
60
-
61
- ### `save_context` — Save or update knowledge
62
-
63
- ```js
64
- // Create new entry
65
- save_context({
66
- kind: "insight", // Determines folder: insights/
67
- body: "React Query staleTime defaults to 0",
68
- tags: ["react", "performance"],
69
- title: "staleTime gotcha", // Optional
70
- meta: { type: "gotcha" }, // Optional: any structured data
71
- folder: "react/hooks", // Optional: subfolder organization
72
- source: "debugging-session" // Optional: provenance
73
- })
74
- // → ~/vault/knowledge/insights/react/hooks/staletime-gotcha.md
75
-
76
- // Update existing entry by ID
77
- save_context({
78
- id: "01HXYZ...", // ULID from a previous save
79
- body: "Updated content here", // Only provide fields you want to change
80
- tags: ["react", "updated"] // Omitted fields are preserved
81
- })
82
- ```
83
-
84
- The `kind` field accepts any string — `"insight"`, `"decision"`, `"pattern"`, `"reference"`, or any custom kind. The folder is auto-created from the pluralized kind name.
85
-
86
- When updating (`id` provided), omitted fields are preserved from the original. You cannot change `kind` or `identity_key` — delete and re-create instead.
87
-
88
- ### `list_context` — Browse entries
89
-
90
- ```js
91
- list_context({
92
- kind: "insight", // Optional: filter by kind
93
- category: "knowledge", // Optional: knowledge, entity, or event
94
- tags: ["react"], // Optional: filter by tags
95
- limit: 10, // Optional: max results (default 20, max 100)
96
- offset: 0 // Optional: pagination offset
97
- })
98
- ```
99
-
100
- Returns entry metadata (id, title, kind, category, tags, created_at) without body content. Use `get_context` with a search query to retrieve full entries.
101
-
102
- ### `delete_context` — Remove an entry
103
-
104
- ```js
105
- delete_context({
106
- id: "01HXYZ..." // ULID of the entry to delete
107
- })
108
- ```
109
-
110
- Removes the markdown file from disk and cleans up the database and vector index.
111
-
112
- ### `context_status` — Diagnostics
113
-
114
- Shows vault path, database size, file counts per kind, embedding coverage, and any issues.
115
-
116
- ## Quick Reference
117
-
118
- ### CLI Commands
119
-
120
- | Command | Description |
121
- |---------|-------------|
122
- | `context-vault setup` | Interactive installer — detects tools, writes configs |
123
- | `context-vault connect --key cv_...` | Connect AI tools to hosted vault |
124
- | `context-vault serve` | Start the MCP server (used by AI clients) |
125
- | `context-vault ui [--port 3141]` | Launch web dashboard |
126
- | `context-vault status` | Show vault health, paths, and entry counts |
127
- | `context-vault reindex` | Rebuild search index from vault files |
128
- | `context-vault update` | Check for and install updates |
129
- | `context-vault uninstall` | Remove MCP configs and optionally data |
130
- | `context-vault migrate` | Migrate vault between local and hosted |
131
-
132
- ### AI Tool Examples
133
-
134
- Tell your AI agent any of these:
135
-
136
- - **"Search my vault for React hooks"** → hybrid full-text + semantic search
137
- - **"Save an insight: always use useCallback for event handlers"** → creates a new entry
138
- - **"List my recent decisions"** → browse entries filtered by kind
139
- - **"Show my vault status"** → diagnostics and health check
140
- - **"Delete entry 01HXYZ..."** → remove by ID
141
-
142
- ## Common Workflows
143
-
144
- ### Save and Retrieve
145
-
146
- ```
147
- You: "Save an insight: React Query's staleTime defaults to 0"
148
- AI: ✓ Saved insight → knowledge/insights/react-querys-staletime-defaults.md
149
-
150
- You: "Search my vault for React Query"
151
- AI: [Returns the saved insight with full content]
152
- ```
153
-
154
- ### Build a Project Knowledge Base
155
-
156
- ```
157
- You: "Save a decision: we chose SQLite over Postgres for the local-first architecture"
158
- You: "Save a pattern: all API handlers follow the try/catch/respond pattern in src/api/"
159
- You: "What decisions have we made about the database?"
160
- AI: [Returns relevant decisions ranked by relevance]
161
- ```
162
-
163
- ### Track Contacts and Entities
164
-
165
- ```
166
- You: "Save a contact for Alice (alice@example.com) — lead developer on Project X"
167
- You: "Search my vault for Alice"
168
- AI: [Returns the contact entry]
169
- ```
170
-
171
- ### Session Summaries
172
-
173
- ```
174
- You: "Save a session summary: debugged auth token refresh, fixed race condition in useAuth hook"
175
- You: "What did I work on last week?"
176
- AI: [Returns recent session entries]
177
- ```
178
-
179
- ## Knowledge Organization
180
-
181
- ### Folders and Kinds
182
-
183
- Entries are organized into three categories — **knowledge** (enduring insights, decisions, patterns), **entity** (contacts, projects, tools), and **event** (sessions, conversations, logs). See [DATA_CATEGORIES](https://github.com/fellanH/context-vault/blob/main/docs/DATA_CATEGORIES.md) for the full category system, kind mappings, and write semantics.
184
-
185
- Each top-level subdirectory in the vault maps to a `kind` value. The directory name is depluralized:
186
-
187
- ```
188
- knowledge/insights/ → kind: "insight"
189
- knowledge/decisions/ → kind: "decision"
190
- knowledge/patterns/ → kind: "pattern"
191
- knowledge/references/ → kind: "reference"
192
- ```
193
-
194
- Within each kind directory, nested subfolders provide human-browsable organization. The subfolder path is stored in `meta.folder`:
195
-
196
- ```
197
- ON DISK IN DB (vault table)
198
- knowledge/insights/ kind: "insight", meta.folder: null
199
- flat-file.md
200
- knowledge/insights/react/hooks/ kind: "insight", meta.folder: "react/hooks"
201
- use-query-gotcha.md
202
- ```
203
-
204
- Tags are semantic (what the content is about). Folder structure is organizational (where it lives). These are separate concerns.
205
-
206
- ### File Format
207
-
208
- All knowledge files use YAML frontmatter:
209
-
210
- ```markdown
211
- ---
212
- id: 01HXYZ...
213
- tags: ["react", "performance"]
214
- source: claude-code
215
- created: 2026-02-17T12:00:00Z
216
- ---
217
- React Query's staleTime defaults to 0 — set it explicitly or every mount triggers a refetch.
218
- ```
219
-
220
- Standard keys: `id`, `tags`, `source`, `created`. Any extra frontmatter keys (`type`, `status`, `language`, `folder`, etc.) are stored in a `meta` JSON column automatically.
221
-
222
- ### Custom Kinds
25
+ - **Save** insights, decisions, patterns, contacts. Your AI agent writes them as you work.
26
+ - **Search** hybrid full-text + semantic search. Ask in natural language.
27
+ - **Own your data** — plain markdown in `~/vault/`, git-versioned, human-editable.
223
28
 
224
- No code changes required:
29
+ ## MCP Tools
225
30
 
226
- 1. `mkdir ~/vault/knowledge/references/`
227
- 2. Add `.md` files with YAML frontmatter
228
- 3. The next session auto-indexes them
31
+ Your AI agent uses these automatically.
229
32
 
230
- The kind name comes from the directory: `references/` → kind `reference`.
33
+ | Tool | Description |
34
+ | ---------------- | ---------------------------------- |
35
+ | `get_context` | Search vault (hybrid FTS + vector) |
36
+ | `save_context` | Save or update entries |
37
+ | `list_context` | Browse with filters |
38
+ | `delete_context` | Remove by ID |
39
+ | `ingest_url` | Fetch URL, extract, save |
40
+ | `context_status` | Health and config |
231
41
 
232
- ## Configuration
233
-
234
- Works out of the box with zero config. All paths are overridable:
235
-
236
- ```
237
- CLI args > env vars > config file > convention defaults
238
- ```
239
-
240
- ### Defaults
241
-
242
- | Setting | Default |
243
- |---------|---------|
244
- | Vault dir | `~/vault/` |
245
- | Data dir | `~/.context-mcp/` |
246
- | Database | `~/.context-mcp/vault.db` |
247
- | Dev dir | `~/dev/` |
248
-
249
- ### Config File (`~/.context-mcp/config.json`)
250
-
251
- Lives in the data directory alongside the database. Created by `setup`, or create it manually:
252
-
253
- ```json
254
- {
255
- "vaultDir": "/Users/you/vault/",
256
- "dataDir": "/Users/you/.context-mcp",
257
- "dbPath": "/Users/you/.context-mcp/vault.db",
258
- "devDir": "/Users/you/dev"
259
- }
260
- ```
261
-
262
- ### Environment Variables
263
-
264
- Both `CONTEXT_VAULT_*` and `CONTEXT_MCP_*` prefixes are supported. The `CONTEXT_VAULT_*` prefix takes priority.
265
-
266
- | Variable | Overrides |
267
- |----------|-----------|
268
- | `CONTEXT_VAULT_VAULT_DIR` / `CONTEXT_MCP_VAULT_DIR` | Vault directory (knowledge files) |
269
- | `CONTEXT_VAULT_DB_PATH` / `CONTEXT_MCP_DB_PATH` | Database path |
270
- | `CONTEXT_VAULT_DEV_DIR` / `CONTEXT_MCP_DEV_DIR` | Dev directory |
271
- | `CONTEXT_VAULT_DATA_DIR` / `CONTEXT_MCP_DATA_DIR` | Data directory (DB + config storage) |
272
-
273
- ### CLI Arguments
274
-
275
- ```bash
276
- context-vault serve --vault-dir /custom/vault --dev-dir /custom/dev
277
- context-vault serve --data-dir /custom/data --db-path /custom/data/vault.db
278
- ```
42
+ Entries are organized by `kind` (insight, decision, pattern, reference, contact, etc.) into `~/vault/knowledge/`, `~/vault/entities/`, `~/vault/events/`. Kind is derived from the subdirectory name.
279
43
 
280
44
  ## CLI
281
45
 
282
- ```bash
283
- context-vault <command> [options]
284
- ```
46
+ | Command | Description |
47
+ | -------------------------------- | --------------------------------------------------------- |
48
+ | `context-vault setup` | Interactive installer — detects tools, writes MCP configs |
49
+ | `context-vault ui [--port 3141]` | Web dashboard |
50
+ | `context-vault status` | Vault health, paths, entry counts |
51
+ | `context-vault reindex` | Rebuild search index |
52
+ | `context-vault import <path>` | Import .md, .csv, .json, .txt |
53
+ | `context-vault export` | Export to JSON or CSV |
54
+ | `context-vault sync` | Sync with hosted account |
55
+ | `context-vault update` | Check for updates |
56
+ | `context-vault uninstall` | Remove MCP configs |
285
57
 
286
- | Command | Description |
287
- |---------|-------------|
288
- | `setup` | Interactive MCP installer — detects tools, writes configs |
289
- | `connect --key cv_...` | Connect AI tools to hosted vault |
290
- | `serve` | Start the MCP server (used by AI clients in MCP configs) |
291
- | `ui [--port 3141]` | Launch the web dashboard |
292
- | `reindex` | Rebuild search index from knowledge files |
293
- | `status` | Show vault diagnostics (paths, counts, health) |
294
- | `update` | Check for and install updates |
295
- | `uninstall` | Remove MCP configs and optionally data |
296
- | `migrate --to-hosted/--to-local` | Migrate vault between local and hosted |
58
+ ## Manual MCP Config
297
59
 
298
- If running from source without a global install, use `npx context-vault` or `node packages/local/bin/cli.js` instead of `context-vault`.
299
-
300
- ## Install
301
-
302
- ### npm (Recommended)
303
-
304
- ```bash
305
- npm install -g context-vault
306
- context-vault setup
307
- ```
308
-
309
- The `setup` command auto-detects installed tools (Claude Code, Codex, Claude Desktop, Cursor, Windsurf, Antigravity, Cline), lets you pick which to configure, and writes the correct MCP config for each. Existing configs are preserved — only the `context-vault` entry is added or updated.
310
-
311
- ### Manual Configuration
312
-
313
- If you prefer manual setup, add to your tool's MCP config. Pass `--vault-dir` to point at your vault folder (omit it to use the default `~/vault/`).
314
-
315
- **npm install** (portable — survives upgrades):
60
+ If you prefer manual setup over `context-vault setup`:
316
61
 
317
62
  ```json
318
63
  {
@@ -325,114 +70,33 @@ If you prefer manual setup, add to your tool's MCP config. Pass `--vault-dir` to
325
70
  }
326
71
  ```
327
72
 
328
- You can also pass config via environment variables in the MCP config block:
73
+ ## Hosted Option
329
74
 
330
- ```json
331
- {
332
- "mcpServers": {
333
- "context-vault": {
334
- "command": "context-vault",
335
- "args": ["serve"],
336
- "env": {
337
- "CONTEXT_VAULT_VAULT_DIR": "/path/to/vault"
338
- }
339
- }
340
- }
341
- }
342
- ```
343
-
344
- ### How the Server Runs
345
-
346
- The server is an MCP (Model Context Protocol) process — you don't start or stop it manually. Your AI client (Claude Code, Codex, Cursor, Windsurf, Cline, etc.) spawns it automatically as a child process when a session begins, based on the `mcpServers` config above. The server communicates over stdio and lives for the duration of the session. When the session ends, the client terminates the process and SQLite cleans up its WAL files.
347
-
348
- This means:
349
- - **No daemon, no port, no background service.** The server only runs while your AI client is active.
350
- - **Multiple sessions** can run separate server instances concurrently — SQLite WAL mode handles concurrent access safely.
351
- - **Embedding model** is downloaded during `setup` (~22MB, all-MiniLM-L6-v2). If setup was skipped, it downloads on first use.
352
- - **Auto-reindex** on first tool call per session ensures the search index is always in sync with your files on disk. No manual reindex needed.
353
-
354
- ## Web Dashboard
355
-
356
- The `context-vault ui` command launches a web dashboard for browsing, searching, and managing your vault entries.
357
-
358
- ## How It Works
359
-
360
- ```
361
- YOUR FILES (source of truth) SEARCH INDEX (derived)
362
- ~/vault/ ~/.context-mcp/vault.db
363
- ├── knowledge/ ┌───────────────────────────────┐
364
- │ ├── insights/ │ vault table │
365
- │ │ ├── react-query-caching.md │ kind: insight │
366
- │ │ └── react/hooks/ │ meta.folder: "react/hooks" │
367
- │ │ └── use-query-gotcha.md │ kind: decision │
368
- │ ├── decisions/ │ kind: pattern │
369
- │ │ └── use-sqlite-over-pg.md │ kind: <any custom> │
370
- │ └── patterns/ │ + FTS5 full-text │
371
- │ └── api-error-handler.md │ + vec0 embeddings │
372
- ├── entities/ └───────────────────────────────┘
373
- └── events/
374
- Human-editable, git-versioned Fast hybrid search, RAG-ready
375
- You own these files Rebuilt from files anytime
376
- ```
377
-
378
- The SQLite database is stored at `~/.context-mcp/vault.db` by default (configurable via `--db-path`, `CONTEXT_VAULT_DB_PATH`, or `config.json`). It contains FTS5 full-text indexes and sqlite-vec embeddings (384-dim float32, all-MiniLM-L6-v2). The database is a derived index — delete it and the server rebuilds it automatically on next session.
379
-
380
- Requires **Node.js 20** or later.
75
+ No Node.js required — sign up at [app.context-vault.com](https://app.context-vault.com), get an API key, connect in 2 minutes.
381
76
 
382
77
  ## Troubleshooting
383
78
 
384
- ### Native module build failures
385
-
386
- `better-sqlite3` and `sqlite-vec` include native C code compiled for your platform. If install fails:
79
+ **Install fails (native modules):**
387
80
 
388
81
  ```bash
389
82
  npm rebuild better-sqlite3 sqlite-vec
390
83
  ```
391
84
 
392
- On Apple Silicon Macs, ensure you're running a native ARM Node.js (not Rosetta). Check with `node -p process.arch` — it should say `arm64`.
393
-
394
- ### Vault directory not found
395
-
396
- If `context_status` or `get_context` reports the vault directory doesn't exist:
397
-
398
- ```bash
399
- context-vault status # Shows resolved paths
400
- mkdir -p ~/vault # Create the default vault directory
401
- ```
402
-
403
- Or re-run `context-vault setup` to reconfigure.
404
-
405
- ### Embedding model download
406
-
407
- The embedding model (all-MiniLM-L6-v2, ~22MB) is normally downloaded during `context-vault setup`. If setup was skipped or the cache was cleared, it downloads automatically on first use. If it hangs, check your network or proxy settings.
408
-
409
- ### Stale search index
85
+ On Apple Silicon, ensure you're running native ARM Node.js: `node -p process.arch` should say `arm64`.
410
86
 
411
- If search results seem outdated or missing:
87
+ **Stale search results:**
412
88
 
413
89
  ```bash
414
90
  context-vault reindex
415
91
  ```
416
92
 
417
- This rebuilds the entire index from your vault files. Auto-reindex runs on every session start, but manual reindex can help diagnose issues.
418
-
419
- ### Config path debugging
93
+ **Vault not found:**
420
94
 
421
95
  ```bash
422
- context-vault status
96
+ context-vault status # shows resolved paths
97
+ mkdir -p ~/vault
423
98
  ```
424
99
 
425
- Shows all resolved paths (vault dir, data dir, DB path, config file) and where each was resolved from (defaults, config file, env, or CLI args).
426
-
427
- ## Dependencies
428
-
429
- | Package | Purpose |
430
- |---------|---------|
431
- | `@modelcontextprotocol/sdk` | MCP protocol (McpServer, StdioServerTransport) |
432
- | `better-sqlite3` | SQLite driver |
433
- | `sqlite-vec` | Vector search (384-dim float32) |
434
- | `@huggingface/transformers` | Local embeddings (all-MiniLM-L6-v2, ~22MB) |
435
-
436
100
  ## License
437
101
 
438
102
  MIT