context-vault 2.8.10 → 2.8.12

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 CHANGED
@@ -13,6 +13,7 @@ if (nodeVersion < 20) {
13
13
  import { createInterface } from "node:readline";
14
14
  import {
15
15
  existsSync,
16
+ statSync,
16
17
  readFileSync,
17
18
  writeFileSync,
18
19
  mkdirSync,
@@ -21,7 +22,7 @@ import {
21
22
  } from "node:fs";
22
23
  import { join, resolve, dirname } from "node:path";
23
24
  import { homedir, platform } from "node:os";
24
- import { execSync, execFile } from "node:child_process";
25
+ import { execSync, execFile, execFileSync } from "node:child_process";
25
26
  import { fileURLToPath } from "node:url";
26
27
 
27
28
  const __filename = fileURLToPath(import.meta.url);
@@ -148,7 +149,11 @@ const TOOLS = [
148
149
  detect: () =>
149
150
  anyDirExists(join(HOME, ".codeium", "windsurf"), join(HOME, ".windsurf")),
150
151
  configType: "json",
151
- configPath: join(HOME, ".codeium", "windsurf", "mcp_config.json"),
152
+ get configPath() {
153
+ return existsSync(join(HOME, ".windsurf"))
154
+ ? join(HOME, ".windsurf", "mcp.json")
155
+ : join(HOME, ".codeium", "windsurf", "mcp_config.json");
156
+ },
152
157
  configKey: "mcpServers",
153
158
  },
154
159
  {
@@ -422,26 +427,34 @@ async function runSetup() {
422
427
 
423
428
  // Vault directory (content files)
424
429
  console.log(dim(` [2/5]`) + bold(" Configuring vault...\n"));
425
- const defaultVaultDir = join(HOME, "vault");
430
+ const defaultVaultDir = getFlag("--vault-dir") || join(HOME, "vault");
426
431
  const vaultDir = isNonInteractive
427
432
  ? defaultVaultDir
428
433
  : await prompt(` Vault directory:`, defaultVaultDir);
429
434
  const resolvedVaultDir = resolve(vaultDir);
430
435
 
431
- // Create vault dir if needed
432
- if (!existsSync(resolvedVaultDir)) {
433
- if (isNonInteractive) {
434
- mkdirSync(resolvedVaultDir, { recursive: true });
435
- console.log(`\n ${green("+")} Created ${resolvedVaultDir}`);
436
- } else {
437
- const create = await prompt(
438
- `\n ${resolvedVaultDir} doesn't exist. Create it? (Y/n):`,
439
- "Y",
436
+ // Guard: vault dir path must not be an existing file
437
+ if (existsSync(resolvedVaultDir)) {
438
+ if (!statSync(resolvedVaultDir).isDirectory()) {
439
+ console.error(
440
+ `\n ${red("Error:")} ${resolvedVaultDir} exists but is not a directory.`,
440
441
  );
441
- if (create.toLowerCase() !== "n") {
442
- mkdirSync(resolvedVaultDir, { recursive: true });
443
- console.log(` ${green("+")} Created ${resolvedVaultDir}`);
444
- }
442
+ console.error(
443
+ dim(` Remove or rename the file, then run setup again.\n`),
444
+ );
445
+ process.exit(1);
446
+ }
447
+ } else if (isNonInteractive) {
448
+ mkdirSync(resolvedVaultDir, { recursive: true });
449
+ console.log(`\n ${green("+")} Created ${resolvedVaultDir}`);
450
+ } else {
451
+ const create = await prompt(
452
+ `\n ${resolvedVaultDir} doesn't exist. Create it? (Y/n):`,
453
+ "Y",
454
+ );
455
+ if (create.toLowerCase() !== "n") {
456
+ mkdirSync(resolvedVaultDir, { recursive: true });
457
+ console.log(` ${green("+")} Created ${resolvedVaultDir}`);
445
458
  }
446
459
  }
447
460
 
@@ -449,6 +462,11 @@ async function runSetup() {
449
462
  const dataDir = join(HOME, ".context-mcp");
450
463
  mkdirSync(dataDir, { recursive: true });
451
464
 
465
+ // Keep server.mjs launcher up to date so it always resolves to the current installation
466
+ if (isInstalledPackage()) {
467
+ writeFileSync(join(dataDir, "server.mjs"), `import "${SERVER_PATH}";\n`);
468
+ }
469
+
452
470
  // Write config.json to data dir (persistent, survives reinstalls)
453
471
  const configPath = join(dataDir, "config.json");
454
472
  const vaultConfig = {};
@@ -627,36 +645,52 @@ async function configureClaude(tool, vaultDir) {
627
645
  const env = { ...process.env };
628
646
  delete env.CLAUDECODE;
629
647
 
630
- // Clean up old name
631
- try {
632
- execSync("claude mcp remove context-mcp -s user", { stdio: "pipe", env });
633
- } catch {}
634
-
635
- try {
636
- execSync("claude mcp remove context-vault -s user", { stdio: "pipe", env });
637
- } catch {}
648
+ // Clean up old names
649
+ for (const oldName of ["context-mcp", "context-vault"]) {
650
+ try {
651
+ execFileSync("claude", ["mcp", "remove", oldName, "-s", "user"], {
652
+ stdio: "pipe",
653
+ env,
654
+ });
655
+ } catch {}
656
+ }
638
657
 
639
658
  try {
640
659
  if (isNpx()) {
641
- const cmdArgs = ["-y", "context-vault", "serve"];
642
- if (vaultDir) cmdArgs.push("--vault-dir", `"${vaultDir}"`);
643
- execSync(
644
- `claude mcp add -s user context-vault -- npx ${cmdArgs.join(" ")}`,
645
- { stdio: "pipe", env },
646
- );
647
- } else if (isInstalledPackage()) {
648
- const launcherPath = join(HOME, ".context-mcp", "server.mjs");
649
- const cmdArgs = [`"${launcherPath}"`];
650
- if (vaultDir) cmdArgs.push("--vault-dir", `"${vaultDir}"`);
651
- execSync(
652
- `claude mcp add -s user context-vault -- ${process.execPath} ${cmdArgs.join(" ")}`,
660
+ const serverArgs = ["-y", "context-vault", "serve"];
661
+ if (vaultDir) serverArgs.push("--vault-dir", vaultDir);
662
+ execFileSync(
663
+ "claude",
664
+ [
665
+ "mcp",
666
+ "add",
667
+ "-s",
668
+ "user",
669
+ "context-vault",
670
+ "--",
671
+ "npx",
672
+ ...serverArgs,
673
+ ],
653
674
  { stdio: "pipe", env },
654
675
  );
655
676
  } else {
656
- const cmdArgs = [`"${SERVER_PATH}"`];
657
- if (vaultDir) cmdArgs.push("--vault-dir", `"${vaultDir}"`);
658
- execSync(
659
- `claude mcp add -s user context-vault -- ${process.execPath} ${cmdArgs.join(" ")}`,
677
+ const serverPath = isInstalledPackage()
678
+ ? join(HOME, ".context-mcp", "server.mjs")
679
+ : SERVER_PATH;
680
+ const nodeArgs = [serverPath];
681
+ if (vaultDir) nodeArgs.push("--vault-dir", vaultDir);
682
+ execFileSync(
683
+ "claude",
684
+ [
685
+ "mcp",
686
+ "add",
687
+ "-s",
688
+ "user",
689
+ "context-vault",
690
+ "--",
691
+ process.execPath,
692
+ ...nodeArgs,
693
+ ],
660
694
  { stdio: "pipe", env },
661
695
  );
662
696
  }
@@ -667,40 +701,32 @@ async function configureClaude(tool, vaultDir) {
667
701
  }
668
702
 
669
703
  async function configureCodex(tool, vaultDir) {
670
- // Clean up old name
671
- try {
672
- execSync("codex mcp remove context-mcp", { stdio: "pipe" });
673
- } catch {}
674
-
675
- try {
676
- execSync("codex mcp remove context-vault", { stdio: "pipe" });
677
- } catch {}
704
+ // Clean up old names
705
+ for (const oldName of ["context-mcp", "context-vault"]) {
706
+ try {
707
+ execFileSync("codex", ["mcp", "remove", oldName], { stdio: "pipe" });
708
+ } catch {}
709
+ }
678
710
 
679
711
  try {
680
712
  if (isNpx()) {
681
- const cmdArgs = ["-y", "context-vault", "serve"];
682
- if (vaultDir) cmdArgs.push("--vault-dir", `"${vaultDir}"`);
683
- execSync(`codex mcp add context-vault -- npx ${cmdArgs.join(" ")}`, {
684
- stdio: "pipe",
685
- });
686
- } else if (isInstalledPackage()) {
687
- const launcherPath = join(HOME, ".context-mcp", "server.mjs");
688
- const cmdArgs = [`"${launcherPath}"`];
689
- if (vaultDir) cmdArgs.push("--vault-dir", `"${vaultDir}"`);
690
- execSync(
691
- `codex mcp add context-vault -- ${process.execPath} ${cmdArgs.join(" ")}`,
692
- {
693
- stdio: "pipe",
694
- },
713
+ const serverArgs = ["-y", "context-vault", "serve"];
714
+ if (vaultDir) serverArgs.push("--vault-dir", vaultDir);
715
+ execFileSync(
716
+ "codex",
717
+ ["mcp", "add", "context-vault", "--", "npx", ...serverArgs],
718
+ { stdio: "pipe" },
695
719
  );
696
720
  } else {
697
- const cmdArgs = [`"${SERVER_PATH}"`];
698
- if (vaultDir) cmdArgs.push("--vault-dir", `"${vaultDir}"`);
699
- execSync(
700
- `codex mcp add context-vault -- ${process.execPath} ${cmdArgs.join(" ")}`,
701
- {
702
- stdio: "pipe",
703
- },
721
+ const serverPath = isInstalledPackage()
722
+ ? join(HOME, ".context-mcp", "server.mjs")
723
+ : SERVER_PATH;
724
+ const nodeArgs = [serverPath];
725
+ if (vaultDir) nodeArgs.push("--vault-dir", vaultDir);
726
+ execFileSync(
727
+ "codex",
728
+ ["mcp", "add", "context-vault", "--", process.execPath, ...nodeArgs],
729
+ { stdio: "pipe" },
704
730
  );
705
731
  }
706
732
  } catch (e) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@context-vault/core",
3
- "version": "2.8.10",
3
+ "version": "2.8.12",
4
4
  "type": "module",
5
5
  "description": "Shared core: capture, index, retrieve, tools, and utilities for context-vault",
6
6
  "main": "src/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-vault",
3
- "version": "2.8.10",
3
+ "version": "2.8.12",
4
4
  "type": "module",
5
5
  "description": "Persistent memory for AI agents — saves and searches knowledge across sessions",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "@context-vault/core"
56
56
  ],
57
57
  "dependencies": {
58
- "@context-vault/core": "^2.8.10",
58
+ "@context-vault/core": "^2.8.12",
59
59
  "@modelcontextprotocol/sdk": "^1.26.0",
60
60
  "better-sqlite3": "^12.6.2",
61
61
  "sqlite-vec": "^0.1.0"