context-vault 2.2.0 → 2.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/bin/cli.js +354 -32
- package/node_modules/@context-vault/core/package.json +36 -0
- package/{src → node_modules/@context-vault/core/src}/core/categories.js +1 -0
- package/{src → node_modules/@context-vault/core/src}/core/files.js +1 -0
- package/{src → node_modules/@context-vault/core/src}/index/embed.js +10 -1
- package/node_modules/@context-vault/core/src/index.js +29 -0
- package/{src → node_modules/@context-vault/core/src}/server/tools.js +107 -26
- package/package.json +7 -14
- package/src/server/index.js +21 -4
- package/ui/serve.js +7 -6
- package/LICENSE +0 -21
- package/README.md +0 -431
- package/smithery.yaml +0 -10
- package/src/capture/README.md +0 -23
- package/src/core/README.md +0 -20
- package/src/index/README.md +0 -28
- package/src/retrieve/README.md +0 -19
- package/src/server/README.md +0 -44
- /package/{src → node_modules/@context-vault/core/src}/capture/file-ops.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/capture/formatters.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/capture/index.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/core/config.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/core/frontmatter.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/core/status.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/index/db.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/index/index.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/retrieve/index.js +0 -0
- /package/{src → node_modules/@context-vault/core/src}/server/helpers.js +0 -0
package/bin/cli.js
CHANGED
|
@@ -168,6 +168,9 @@ ${bold("Commands:")}
|
|
|
168
168
|
${cyan("ui")} [--port 3141] Launch web dashboard
|
|
169
169
|
${cyan("reindex")} Rebuild search index from knowledge files
|
|
170
170
|
${cyan("status")} Show vault diagnostics
|
|
171
|
+
${cyan("update")} Check for and install updates
|
|
172
|
+
${cyan("uninstall")} Remove MCP configs and optionally data
|
|
173
|
+
${cyan("migrate")} Migrate vault between local and hosted
|
|
171
174
|
|
|
172
175
|
${bold("Options:")}
|
|
173
176
|
--help Show this help
|
|
@@ -185,6 +188,102 @@ async function runSetup() {
|
|
|
185
188
|
console.log(dim(" Persistent memory for AI agents"));
|
|
186
189
|
console.log();
|
|
187
190
|
|
|
191
|
+
// Check for existing installation
|
|
192
|
+
const existingConfig = join(HOME, ".context-mcp", "config.json");
|
|
193
|
+
if (existsSync(existingConfig) && !isNonInteractive) {
|
|
194
|
+
let existingVault = "(unknown)";
|
|
195
|
+
try {
|
|
196
|
+
const cfg = JSON.parse(readFileSync(existingConfig, "utf-8"));
|
|
197
|
+
existingVault = cfg.vaultDir || existingVault;
|
|
198
|
+
} catch {}
|
|
199
|
+
|
|
200
|
+
console.log(yellow(` Existing installation detected`));
|
|
201
|
+
console.log(dim(` Vault: ${existingVault}`));
|
|
202
|
+
console.log(dim(` Config: ${existingConfig}`));
|
|
203
|
+
console.log();
|
|
204
|
+
console.log(` 1) Full reconfigure`);
|
|
205
|
+
console.log(` 2) Update tool configs only ${dim("(skip vault setup)")}`);
|
|
206
|
+
console.log(` 3) Cancel`);
|
|
207
|
+
console.log();
|
|
208
|
+
const choice = await prompt(" Select:", "1");
|
|
209
|
+
|
|
210
|
+
if (choice === "3") {
|
|
211
|
+
console.log(dim(" Cancelled."));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (choice === "2") {
|
|
216
|
+
// Skip vault setup, just reconfigure tools
|
|
217
|
+
console.log();
|
|
218
|
+
console.log(dim(` [1/2]`) + bold(" Detecting tools...\n"));
|
|
219
|
+
const detected = [];
|
|
220
|
+
for (const tool of TOOLS) {
|
|
221
|
+
const found = tool.detect();
|
|
222
|
+
if (found) {
|
|
223
|
+
detected.push(tool);
|
|
224
|
+
console.log(` ${green("+")} ${tool.name}`);
|
|
225
|
+
} else {
|
|
226
|
+
console.log(` ${dim("-")} ${dim(tool.name)} ${dim("(not found)")}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
console.log();
|
|
230
|
+
|
|
231
|
+
if (detected.length === 0) {
|
|
232
|
+
console.log(yellow(" No supported tools detected."));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
let selected;
|
|
237
|
+
console.log(bold(" Which tools should context-mcp connect to?\n"));
|
|
238
|
+
for (let i = 0; i < detected.length; i++) {
|
|
239
|
+
console.log(` ${i + 1}) ${detected[i].name}`);
|
|
240
|
+
}
|
|
241
|
+
console.log();
|
|
242
|
+
const answer = await prompt(
|
|
243
|
+
` Select (${dim("1,2,3")} or ${dim('"all"')}):`,
|
|
244
|
+
"all"
|
|
245
|
+
);
|
|
246
|
+
if (answer === "all" || answer === "") {
|
|
247
|
+
selected = detected;
|
|
248
|
+
} else {
|
|
249
|
+
const nums = answer.split(/[,\s]+/).map((n) => parseInt(n, 10) - 1).filter((n) => n >= 0 && n < detected.length);
|
|
250
|
+
selected = nums.map((n) => detected[n]);
|
|
251
|
+
if (selected.length === 0) selected = detected;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Read vault dir from existing config
|
|
255
|
+
let customVaultDir = null;
|
|
256
|
+
try {
|
|
257
|
+
const cfg = JSON.parse(readFileSync(existingConfig, "utf-8"));
|
|
258
|
+
const defaultVDir = join(HOME, "vault");
|
|
259
|
+
if (cfg.vaultDir && resolve(cfg.vaultDir) !== resolve(defaultVDir)) {
|
|
260
|
+
customVaultDir = cfg.vaultDir;
|
|
261
|
+
}
|
|
262
|
+
} catch {}
|
|
263
|
+
|
|
264
|
+
console.log(`\n ${dim("[2/2]")}${bold(" Configuring tools...\n")}`);
|
|
265
|
+
for (const tool of selected) {
|
|
266
|
+
try {
|
|
267
|
+
if (tool.configType === "cli") {
|
|
268
|
+
await configureClaude(tool, customVaultDir);
|
|
269
|
+
} else {
|
|
270
|
+
configureJsonTool(tool, customVaultDir);
|
|
271
|
+
}
|
|
272
|
+
console.log(` ${green("+")} ${tool.name} — configured`);
|
|
273
|
+
} catch (e) {
|
|
274
|
+
console.log(` ${red("x")} ${tool.name} — ${e.message}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
console.log();
|
|
279
|
+
console.log(green(" ✓ Tool configs updated."));
|
|
280
|
+
console.log();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
// choice === "1" falls through to full setup below
|
|
284
|
+
console.log();
|
|
285
|
+
}
|
|
286
|
+
|
|
188
287
|
// Detect tools
|
|
189
288
|
console.log(dim(` [1/5]`) + bold(" Detecting tools...\n"));
|
|
190
289
|
const detected = [];
|
|
@@ -302,7 +401,7 @@ async function runSetup() {
|
|
|
302
401
|
console.log(`\n ${dim("[3/5]")}${bold(" Downloading embedding model...")}`);
|
|
303
402
|
console.log(dim(" all-MiniLM-L6-v2 (~22MB, one-time download)\n"));
|
|
304
403
|
try {
|
|
305
|
-
const { embed } = await import("
|
|
404
|
+
const { embed } = await import("@context-vault/core/index/embed");
|
|
306
405
|
await embed("warmup");
|
|
307
406
|
console.log(` ${green("+")} Embedding model ready`);
|
|
308
407
|
} catch (e) {
|
|
@@ -340,9 +439,9 @@ async function runSetup() {
|
|
|
340
439
|
}
|
|
341
440
|
|
|
342
441
|
// Seed entry
|
|
343
|
-
const seeded =
|
|
344
|
-
if (seeded) {
|
|
345
|
-
console.log(`\n ${green("+")} Created starter entry in vault`);
|
|
442
|
+
const seeded = createSeedEntries(resolvedVaultDir);
|
|
443
|
+
if (seeded > 0) {
|
|
444
|
+
console.log(`\n ${green("+")} Created ${seeded} starter ${seeded === 1 ? "entry" : "entries"} in vault`);
|
|
346
445
|
}
|
|
347
446
|
|
|
348
447
|
// Offer to launch UI
|
|
@@ -377,8 +476,15 @@ async function runSetup() {
|
|
|
377
476
|
const boxLines = [
|
|
378
477
|
` ✓ Setup complete — ${passed}/${checks.length} checks passed`,
|
|
379
478
|
``,
|
|
380
|
-
`
|
|
479
|
+
` ${bold("AI Tools")} — open ${toolName} and try:`,
|
|
381
480
|
` "Search my vault for getting started"`,
|
|
481
|
+
` "Save an insight about [topic]"`,
|
|
482
|
+
` "Show my vault status"`,
|
|
483
|
+
``,
|
|
484
|
+
` ${bold("CLI Commands:")}`,
|
|
485
|
+
` context-mcp status Show vault health`,
|
|
486
|
+
` context-mcp ui Launch web dashboard`,
|
|
487
|
+
` context-mcp update Check for updates`,
|
|
382
488
|
];
|
|
383
489
|
const innerWidth = Math.max(...boxLines.map((l) => l.length)) + 2;
|
|
384
490
|
const pad = (s) => s + " ".repeat(Math.max(0, innerWidth - s.length));
|
|
@@ -466,18 +572,21 @@ function configureJsonTool(tool, vaultDir) {
|
|
|
466
572
|
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
467
573
|
}
|
|
468
574
|
|
|
469
|
-
// ─── Seed
|
|
470
|
-
|
|
471
|
-
function
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
575
|
+
// ─── Seed Entries ────────────────────────────────────────────────────────────
|
|
576
|
+
|
|
577
|
+
function createSeedEntries(vaultDir) {
|
|
578
|
+
let created = 0;
|
|
579
|
+
|
|
580
|
+
// Entry 1: Getting started (improved)
|
|
581
|
+
const insightDir = join(vaultDir, "knowledge", "insights");
|
|
582
|
+
const insightPath = join(insightDir, "getting-started.md");
|
|
583
|
+
if (!existsSync(insightPath)) {
|
|
584
|
+
mkdirSync(insightDir, { recursive: true });
|
|
585
|
+
const id1 = Date.now().toString(36).toUpperCase().padStart(10, "0");
|
|
586
|
+
const now = new Date().toISOString();
|
|
587
|
+
writeFileSync(insightPath, `---
|
|
588
|
+
id: ${id1}
|
|
589
|
+
tags: ["getting-started", "vault"]
|
|
481
590
|
source: context-mcp-setup
|
|
482
591
|
created: ${now}
|
|
483
592
|
---
|
|
@@ -486,16 +595,48 @@ Welcome to your context vault! This is a seed entry created during setup.
|
|
|
486
595
|
Your vault stores knowledge as plain markdown files with YAML frontmatter.
|
|
487
596
|
AI agents search it using hybrid full-text + semantic search.
|
|
488
597
|
|
|
489
|
-
|
|
490
|
-
- "Search my vault for getting started"
|
|
491
|
-
- "Save an insight
|
|
492
|
-
- "Show my vault status"
|
|
598
|
+
**Quick start:**
|
|
599
|
+
- "Search my vault for getting started" — find this entry
|
|
600
|
+
- "Save an insight about [topic]" — add knowledge
|
|
601
|
+
- "Show my vault status" — check health
|
|
602
|
+
- "List my recent entries" — browse your vault
|
|
493
603
|
|
|
494
604
|
You can edit or delete this file anytime — it lives at:
|
|
495
|
-
${
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
605
|
+
${insightPath}
|
|
606
|
+
`);
|
|
607
|
+
created++;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// Entry 2: Example decision
|
|
611
|
+
const decisionDir = join(vaultDir, "knowledge", "decisions");
|
|
612
|
+
const decisionPath = join(decisionDir, "example-local-first-data.md");
|
|
613
|
+
if (!existsSync(decisionPath)) {
|
|
614
|
+
mkdirSync(decisionDir, { recursive: true });
|
|
615
|
+
const id2 = (Date.now() + 1).toString(36).toUpperCase().padStart(10, "0");
|
|
616
|
+
const now = new Date().toISOString();
|
|
617
|
+
writeFileSync(decisionPath, `---
|
|
618
|
+
id: ${id2}
|
|
619
|
+
tags: ["example", "architecture"]
|
|
620
|
+
source: context-mcp-setup
|
|
621
|
+
created: ${now}
|
|
622
|
+
---
|
|
623
|
+
Example decision: Use local-first data storage (SQLite + files) over cloud databases.
|
|
624
|
+
|
|
625
|
+
**Context:** For personal knowledge management, local storage provides better privacy,
|
|
626
|
+
offline access, and zero ongoing cost. The vault uses plain markdown files as the
|
|
627
|
+
source of truth with a SQLite index for fast search.
|
|
628
|
+
|
|
629
|
+
**Trade-offs:**
|
|
630
|
+
- Pro: Full data ownership, git-versioned, human-editable
|
|
631
|
+
- Pro: No cloud dependency, works offline
|
|
632
|
+
- Con: No built-in sync across devices (use git or Syncthing)
|
|
633
|
+
|
|
634
|
+
This is an example entry showing the decision format. Feel free to delete it.
|
|
635
|
+
`);
|
|
636
|
+
created++;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
return created;
|
|
499
640
|
}
|
|
500
641
|
|
|
501
642
|
// ─── UI Command ──────────────────────────────────────────────────────────────
|
|
@@ -517,10 +658,10 @@ function runUi() {
|
|
|
517
658
|
async function runReindex() {
|
|
518
659
|
console.log(dim("Loading vault..."));
|
|
519
660
|
|
|
520
|
-
const { resolveConfig } = await import("
|
|
521
|
-
const { initDatabase, prepareStatements, insertVec, deleteVec } = await import("
|
|
522
|
-
const { embed } = await import("
|
|
523
|
-
const { reindex } = await import("
|
|
661
|
+
const { resolveConfig } = await import("@context-vault/core/core/config");
|
|
662
|
+
const { initDatabase, prepareStatements, insertVec, deleteVec } = await import("@context-vault/core/index/db");
|
|
663
|
+
const { embed } = await import("@context-vault/core/index/embed");
|
|
664
|
+
const { reindex } = await import("@context-vault/core/index");
|
|
524
665
|
|
|
525
666
|
const config = resolveConfig();
|
|
526
667
|
if (!config.vaultDirExists) {
|
|
@@ -555,9 +696,9 @@ async function runReindex() {
|
|
|
555
696
|
// ─── Status Command ──────────────────────────────────────────────────────────
|
|
556
697
|
|
|
557
698
|
async function runStatus() {
|
|
558
|
-
const { resolveConfig } = await import("
|
|
559
|
-
const { initDatabase } = await import("
|
|
560
|
-
const { gatherVaultStatus } = await import("
|
|
699
|
+
const { resolveConfig } = await import("@context-vault/core/core/config");
|
|
700
|
+
const { initDatabase } = await import("@context-vault/core/index/db");
|
|
701
|
+
const { gatherVaultStatus } = await import("@context-vault/core/core/status");
|
|
561
702
|
|
|
562
703
|
const config = resolveConfig();
|
|
563
704
|
const db = initDatabase(config.dbPath);
|
|
@@ -620,6 +761,178 @@ async function runStatus() {
|
|
|
620
761
|
console.log();
|
|
621
762
|
}
|
|
622
763
|
|
|
764
|
+
// ─── Update Command ─────────────────────────────────────────────────────────
|
|
765
|
+
|
|
766
|
+
async function runUpdate() {
|
|
767
|
+
console.log();
|
|
768
|
+
console.log(` ${bold("◇ context-vault")} ${dim(`v${VERSION}`)}`);
|
|
769
|
+
console.log();
|
|
770
|
+
|
|
771
|
+
let latest;
|
|
772
|
+
try {
|
|
773
|
+
latest = execSync("npm view context-vault version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
774
|
+
} catch {
|
|
775
|
+
console.error(red(" Could not check for updates. Verify your network connection."));
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
if (latest === VERSION) {
|
|
780
|
+
console.log(green(" Already up to date."));
|
|
781
|
+
console.log();
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
console.log(` Current: ${dim(VERSION)}`);
|
|
786
|
+
console.log(` Latest: ${green(latest)}`);
|
|
787
|
+
console.log();
|
|
788
|
+
|
|
789
|
+
if (!isNonInteractive) {
|
|
790
|
+
const answer = await prompt(` Update to v${latest}? (Y/n):`, "Y");
|
|
791
|
+
if (answer.toLowerCase() === "n") {
|
|
792
|
+
console.log(dim(" Cancelled."));
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
console.log(dim(" Installing..."));
|
|
798
|
+
try {
|
|
799
|
+
execSync("npm install -g context-vault@latest", { stdio: "inherit" });
|
|
800
|
+
console.log();
|
|
801
|
+
console.log(green(` ✓ Updated to v${latest}`));
|
|
802
|
+
} catch {
|
|
803
|
+
console.error(red(" Update failed. Try manually: npm install -g context-vault@latest"));
|
|
804
|
+
}
|
|
805
|
+
console.log();
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// ─── Uninstall Command ──────────────────────────────────────────────────────
|
|
809
|
+
|
|
810
|
+
async function runUninstall() {
|
|
811
|
+
console.log();
|
|
812
|
+
console.log(` ${bold("◇ context-vault")} ${dim("uninstall")}`);
|
|
813
|
+
console.log();
|
|
814
|
+
|
|
815
|
+
// Remove from Claude Code
|
|
816
|
+
try {
|
|
817
|
+
const env = { ...process.env };
|
|
818
|
+
delete env.CLAUDECODE;
|
|
819
|
+
execSync("claude mcp remove context-mcp -s user", { stdio: "pipe", env });
|
|
820
|
+
console.log(` ${green("+")} Removed from Claude Code`);
|
|
821
|
+
} catch {
|
|
822
|
+
console.log(` ${dim("-")} Claude Code — not configured or not installed`);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// Remove from JSON-configured tools
|
|
826
|
+
for (const tool of TOOLS.filter((t) => t.configType === "json")) {
|
|
827
|
+
if (!existsSync(tool.configPath)) continue;
|
|
828
|
+
try {
|
|
829
|
+
const config = JSON.parse(readFileSync(tool.configPath, "utf-8"));
|
|
830
|
+
if (config[tool.configKey]?.["context-mcp"]) {
|
|
831
|
+
delete config[tool.configKey]["context-mcp"];
|
|
832
|
+
writeFileSync(tool.configPath, JSON.stringify(config, null, 2) + "\n");
|
|
833
|
+
console.log(` ${green("+")} Removed from ${tool.name}`);
|
|
834
|
+
}
|
|
835
|
+
} catch {
|
|
836
|
+
console.log(` ${dim("-")} ${tool.name} — could not update config`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// Optionally remove data directory
|
|
841
|
+
const dataDir = join(HOME, ".context-mcp");
|
|
842
|
+
if (existsSync(dataDir)) {
|
|
843
|
+
console.log();
|
|
844
|
+
const answer = isNonInteractive
|
|
845
|
+
? "n"
|
|
846
|
+
: await prompt(` Remove data directory (${dataDir})? (y/N):`, "N");
|
|
847
|
+
if (answer.toLowerCase() === "y") {
|
|
848
|
+
const { rmSync } = await import("node:fs");
|
|
849
|
+
rmSync(dataDir, { recursive: true, force: true });
|
|
850
|
+
console.log(` ${green("+")} Removed ${dataDir}`);
|
|
851
|
+
} else {
|
|
852
|
+
console.log(` ${dim("Kept")} ${dataDir}`);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
console.log();
|
|
857
|
+
console.log(dim(" Vault directory was not touched (your knowledge files are safe)."));
|
|
858
|
+
console.log(` To fully remove: ${cyan("npm uninstall -g context-vault")}`);
|
|
859
|
+
console.log();
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// ─── Migrate Command ─────────────────────────────────────────────────────────
|
|
863
|
+
|
|
864
|
+
async function runMigrate() {
|
|
865
|
+
const direction = args.includes("--to-hosted") ? "to-hosted"
|
|
866
|
+
: args.includes("--to-local") ? "to-local"
|
|
867
|
+
: null;
|
|
868
|
+
|
|
869
|
+
if (!direction) {
|
|
870
|
+
console.log(`\n ${bold("context-mcp migrate")}\n`);
|
|
871
|
+
console.log(` Usage:`);
|
|
872
|
+
console.log(` context-mcp migrate --to-hosted Upload local vault to hosted service`);
|
|
873
|
+
console.log(` context-mcp migrate --to-local Download hosted vault to local files`);
|
|
874
|
+
console.log(`\n Options:`);
|
|
875
|
+
console.log(` --url <url> Hosted server URL (default: https://vault.contextvault.dev)`);
|
|
876
|
+
console.log(` --key <key> API key (cv_...)`);
|
|
877
|
+
console.log();
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
const hostedUrl = getFlag("--url") || "https://vault.contextvault.dev";
|
|
882
|
+
const apiKey = getFlag("--key");
|
|
883
|
+
|
|
884
|
+
if (!apiKey) {
|
|
885
|
+
console.error(red(" Error: --key <api_key> is required for migration."));
|
|
886
|
+
console.error(` Get your API key at ${cyan(hostedUrl + "/dashboard")}`);
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
const { resolveConfig } = await import("@context-vault/core/core/config");
|
|
891
|
+
const config = resolveConfig();
|
|
892
|
+
|
|
893
|
+
if (direction === "to-hosted") {
|
|
894
|
+
const { migrateToHosted } = await import("@context-vault/hosted/migration/migrate");
|
|
895
|
+
console.log(`\n ${bold("Migrating to hosted")}...`);
|
|
896
|
+
console.log(dim(` Vault: ${config.vaultDir}`));
|
|
897
|
+
console.log(dim(` Target: ${hostedUrl}\n`));
|
|
898
|
+
|
|
899
|
+
const results = await migrateToHosted({
|
|
900
|
+
vaultDir: config.vaultDir,
|
|
901
|
+
hostedUrl,
|
|
902
|
+
apiKey,
|
|
903
|
+
log: (msg) => console.log(` ${dim(msg)}`),
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
console.log(`\n ${green("+")} ${results.uploaded} entries uploaded`);
|
|
907
|
+
if (results.failed > 0) {
|
|
908
|
+
console.log(` ${red("-")} ${results.failed} failed`);
|
|
909
|
+
for (const err of results.errors.slice(0, 5)) {
|
|
910
|
+
console.log(` ${dim(err)}`);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
console.log(dim("\n Your local vault was not modified (safe backup)."));
|
|
914
|
+
} else {
|
|
915
|
+
const { migrateToLocal } = await import("@context-vault/hosted/migration/migrate");
|
|
916
|
+
console.log(`\n ${bold("Migrating to local")}...`);
|
|
917
|
+
console.log(dim(` Source: ${hostedUrl}`));
|
|
918
|
+
console.log(dim(` Target: ${config.vaultDir}\n`));
|
|
919
|
+
|
|
920
|
+
const results = await migrateToLocal({
|
|
921
|
+
vaultDir: config.vaultDir,
|
|
922
|
+
hostedUrl,
|
|
923
|
+
apiKey,
|
|
924
|
+
log: (msg) => console.log(` ${dim(msg)}`),
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
console.log(`\n ${green("+")} ${results.downloaded} entries restored`);
|
|
928
|
+
if (results.failed > 0) {
|
|
929
|
+
console.log(` ${red("-")} ${results.failed} failed`);
|
|
930
|
+
}
|
|
931
|
+
console.log(dim("\n Run `context-mcp reindex` to rebuild the search index."));
|
|
932
|
+
}
|
|
933
|
+
console.log();
|
|
934
|
+
}
|
|
935
|
+
|
|
623
936
|
// ─── Serve Command ──────────────────────────────────────────────────────────
|
|
624
937
|
|
|
625
938
|
async function runServe() {
|
|
@@ -659,6 +972,15 @@ async function main() {
|
|
|
659
972
|
case "status":
|
|
660
973
|
await runStatus();
|
|
661
974
|
break;
|
|
975
|
+
case "update":
|
|
976
|
+
await runUpdate();
|
|
977
|
+
break;
|
|
978
|
+
case "uninstall":
|
|
979
|
+
await runUninstall();
|
|
980
|
+
break;
|
|
981
|
+
case "migrate":
|
|
982
|
+
await runMigrate();
|
|
983
|
+
break;
|
|
662
984
|
default:
|
|
663
985
|
console.error(red(`Unknown command: ${command}`));
|
|
664
986
|
console.error(`Run ${cyan("context-mcp --help")} for usage.`);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@context-vault/core",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Shared core: capture, index, retrieve, tools, and utilities for context-vault",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js",
|
|
9
|
+
"./capture": "./src/capture/index.js",
|
|
10
|
+
"./capture/formatters": "./src/capture/formatters.js",
|
|
11
|
+
"./capture/file-ops": "./src/capture/file-ops.js",
|
|
12
|
+
"./index/db": "./src/index/db.js",
|
|
13
|
+
"./index/embed": "./src/index/embed.js",
|
|
14
|
+
"./index": "./src/index/index.js",
|
|
15
|
+
"./retrieve": "./src/retrieve/index.js",
|
|
16
|
+
"./server/tools": "./src/server/tools.js",
|
|
17
|
+
"./server/helpers": "./src/server/helpers.js",
|
|
18
|
+
"./core/categories": "./src/core/categories.js",
|
|
19
|
+
"./core/config": "./src/core/config.js",
|
|
20
|
+
"./core/files": "./src/core/files.js",
|
|
21
|
+
"./core/frontmatter": "./src/core/frontmatter.js",
|
|
22
|
+
"./core/status": "./src/core/status.js"
|
|
23
|
+
},
|
|
24
|
+
"files": ["src/"],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"engines": { "node": ">=20" },
|
|
27
|
+
"author": "Felix Hellstrom",
|
|
28
|
+
"repository": { "type": "git", "url": "https://github.com/fellanH/context-mcp.git", "directory": "packages/core" },
|
|
29
|
+
"homepage": "https://github.com/fellanH/context-mcp",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@huggingface/transformers": "^3.0.0",
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
33
|
+
"better-sqlite3": "^12.6.2",
|
|
34
|
+
"sqlite-vec": "^0.1.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
* embed.js — Text embedding via HuggingFace transformers
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { pipeline } from "@huggingface/transformers";
|
|
5
|
+
import { pipeline, env } from "@huggingface/transformers";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { mkdirSync } from "node:fs";
|
|
9
|
+
|
|
10
|
+
// Redirect model cache to ~/.context-mcp/models/ so it works when the
|
|
11
|
+
// package is installed globally in a root-owned directory (e.g. /usr/lib/node_modules/).
|
|
12
|
+
const modelCacheDir = join(homedir(), ".context-mcp", "models");
|
|
13
|
+
mkdirSync(modelCacheDir, { recursive: true });
|
|
14
|
+
env.cacheDir = modelCacheDir;
|
|
6
15
|
|
|
7
16
|
let extractor = null;
|
|
8
17
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @context-vault/core — Shared core for context-vault
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all public APIs from capture, index, retrieve, server, and core layers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Core utilities
|
|
8
|
+
export { categoryFor, categoryDirFor, CATEGORY_DIRS } from "./core/categories.js";
|
|
9
|
+
export { parseArgs, resolveConfig } from "./core/config.js";
|
|
10
|
+
export { ulid, slugify, kindToDir, dirToKind, normalizeKind, kindToPath, safeJoin, walkDir } from "./core/files.js";
|
|
11
|
+
export { formatFrontmatter, parseFrontmatter, extractCustomMeta, parseEntryFromMarkdown } from "./core/frontmatter.js";
|
|
12
|
+
export { gatherVaultStatus } from "./core/status.js";
|
|
13
|
+
|
|
14
|
+
// Capture layer
|
|
15
|
+
export { writeEntry, updateEntryFile, captureAndIndex } from "./capture/index.js";
|
|
16
|
+
export { writeEntryFile } from "./capture/file-ops.js";
|
|
17
|
+
export { formatBody } from "./capture/formatters.js";
|
|
18
|
+
|
|
19
|
+
// Index layer
|
|
20
|
+
export { SCHEMA_DDL, initDatabase, prepareStatements, insertVec, deleteVec } from "./index/db.js";
|
|
21
|
+
export { embed, embedBatch, resetEmbedPipeline } from "./index/embed.js";
|
|
22
|
+
export { indexEntry, reindex } from "./index/index.js";
|
|
23
|
+
|
|
24
|
+
// Retrieve layer
|
|
25
|
+
export { hybridSearch } from "./retrieve/index.js";
|
|
26
|
+
|
|
27
|
+
// Server tools & helpers
|
|
28
|
+
export { registerTools } from "./server/tools.js";
|
|
29
|
+
export { ok, err, ensureVaultExists, ensureValidKind } from "./server/helpers.js";
|