chat-recall 0.7.39 → 0.7.41

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 (55) hide show
  1. package/README.md +22 -14
  2. package/dist/cli.js +698 -410
  3. package/dist/cli.js.map +1 -1
  4. package/dist/install-hooks.d.ts +11 -3
  5. package/dist/install-hooks.d.ts.map +1 -1
  6. package/dist/install-hooks.js +10 -5
  7. package/dist/install-hooks.js.map +1 -1
  8. package/dist/kit-store.d.ts +1 -1
  9. package/dist/kit-store.d.ts.map +1 -1
  10. package/dist/kit-store.js +2 -2
  11. package/dist/kit-store.js.map +1 -1
  12. package/dist/mcp-host.d.ts +50 -0
  13. package/dist/mcp-host.d.ts.map +1 -0
  14. package/dist/mcp-host.js +111 -0
  15. package/dist/mcp-host.js.map +1 -0
  16. package/dist/mcp.js +1023 -981
  17. package/dist/mcp.js.map +1 -1
  18. package/dist/memory-guard.d.ts +41 -0
  19. package/dist/memory-guard.d.ts.map +1 -0
  20. package/dist/memory-guard.js +56 -0
  21. package/dist/memory-guard.js.map +1 -0
  22. package/dist/message-hook.js +1 -1
  23. package/dist/service-installer.js +2 -2
  24. package/dist/service-installer.js.map +1 -1
  25. package/dist/session-exit.d.ts +50 -0
  26. package/dist/session-exit.d.ts.map +1 -0
  27. package/dist/session-exit.js +70 -0
  28. package/dist/session-exit.js.map +1 -0
  29. package/dist/star-nudge.js +1 -1
  30. package/dist/sync-client.d.ts.map +1 -1
  31. package/dist/sync-client.js +5 -6
  32. package/dist/sync-client.js.map +1 -1
  33. package/dist/vendor/mcp-kit/VERSION +1 -0
  34. package/dist/vendor/mcp-kit/host-main.d.ts +2 -0
  35. package/dist/vendor/mcp-kit/host-main.js +3 -0
  36. package/dist/vendor/mcp-kit/host-plain.d.ts +56 -0
  37. package/dist/vendor/mcp-kit/host-plain.js +502 -0
  38. package/dist/vendor/mcp-kit/host.d.ts +32 -0
  39. package/dist/vendor/mcp-kit/host.js +43 -0
  40. package/dist/vendor/mcp-kit/registry.d.ts +79 -0
  41. package/dist/vendor/mcp-kit/registry.js +194 -0
  42. package/dist/watch.js +47 -14
  43. package/package.json +2 -2
  44. package/dist/mcp-relay.d.ts +0 -3
  45. package/dist/mcp-relay.d.ts.map +0 -1
  46. package/dist/mcp-relay.js +0 -472
  47. package/dist/mcp-relay.js.map +0 -1
  48. package/dist/mcp-socket.d.ts +0 -98
  49. package/dist/mcp-socket.d.ts.map +0 -1
  50. package/dist/mcp-socket.js +0 -249
  51. package/dist/mcp-socket.js.map +0 -1
  52. package/dist/relay-lifecycle.d.ts +0 -92
  53. package/dist/relay-lifecycle.d.ts.map +0 -1
  54. package/dist/relay-lifecycle.js +0 -290
  55. package/dist/relay-lifecycle.js.map +0 -1
package/dist/cli.js CHANGED
@@ -2034,7 +2034,7 @@ var require_thread_stream = __commonJS({
2034
2034
  var { version: version2 } = require_package();
2035
2035
  var { EventEmitter } = __require("events");
2036
2036
  var { Worker: Worker2 } = __require("worker_threads");
2037
- var { join: join72 } = __require("path");
2037
+ var { join: join74 } = __require("path");
2038
2038
  var { pathToFileURL } = __require("url");
2039
2039
  var { wait } = require_wait();
2040
2040
  var {
@@ -2077,7 +2077,7 @@ var require_thread_stream = __commonJS({
2077
2077
  function createWorker(stream, opts) {
2078
2078
  const { filename, workerData } = opts;
2079
2079
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2080
- const toExecute = bundlerOverrides["thread-stream-worker"] || join72(__dirname, "lib", "worker.js");
2080
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join74(__dirname, "lib", "worker.js");
2081
2081
  const worker = new Worker2(toExecute, {
2082
2082
  ...opts.workerOpts,
2083
2083
  trackUnmanagedFds: false,
@@ -2480,7 +2480,7 @@ var require_transport = __commonJS({
2480
2480
  "use strict";
2481
2481
  var { createRequire: createRequire4 } = __require("module");
2482
2482
  var getCallers = require_caller();
2483
- var { join: join72, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
2483
+ var { join: join74, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
2484
2484
  var sleep2 = require_atomic_sleep();
2485
2485
  var onExit = require_on_exit_leak_free();
2486
2486
  var ThreadStream = require_thread_stream();
@@ -2543,7 +2543,7 @@ var require_transport = __commonJS({
2543
2543
  throw new Error("only one of target or targets can be specified");
2544
2544
  }
2545
2545
  if (targets) {
2546
- target = bundlerOverrides["pino-worker"] || join72(__dirname, "worker.js");
2546
+ target = bundlerOverrides["pino-worker"] || join74(__dirname, "worker.js");
2547
2547
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2548
2548
  return {
2549
2549
  ...dest,
@@ -2561,7 +2561,7 @@ var require_transport = __commonJS({
2561
2561
  });
2562
2562
  });
2563
2563
  } else if (pipeline) {
2564
- target = bundlerOverrides["pino-worker"] || join72(__dirname, "worker.js");
2564
+ target = bundlerOverrides["pino-worker"] || join74(__dirname, "worker.js");
2565
2565
  options.pipelines = [pipeline.map((dest) => {
2566
2566
  return {
2567
2567
  ...dest,
@@ -2583,7 +2583,7 @@ var require_transport = __commonJS({
2583
2583
  return origin;
2584
2584
  }
2585
2585
  if (origin === "pino/file") {
2586
- return join72(__dirname, "..", "file.js");
2586
+ return join74(__dirname, "..", "file.js");
2587
2587
  }
2588
2588
  let fixTarget2;
2589
2589
  for (const filePath of callers) {
@@ -3572,7 +3572,7 @@ var require_safe_stable_stringify = __commonJS({
3572
3572
  return circularValue;
3573
3573
  }
3574
3574
  let res = "";
3575
- let join72 = ",";
3575
+ let join74 = ",";
3576
3576
  const originalIndentation = indentation;
3577
3577
  if (Array.isArray(value)) {
3578
3578
  if (value.length === 0) {
@@ -3586,7 +3586,7 @@ var require_safe_stable_stringify = __commonJS({
3586
3586
  indentation += spacer;
3587
3587
  res += `
3588
3588
  ${indentation}`;
3589
- join72 = `,
3589
+ join74 = `,
3590
3590
  ${indentation}`;
3591
3591
  }
3592
3592
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3594,13 +3594,13 @@ ${indentation}`;
3594
3594
  for (; i < maximumValuesToStringify - 1; i++) {
3595
3595
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3596
3596
  res += tmp2 !== void 0 ? tmp2 : "null";
3597
- res += join72;
3597
+ res += join74;
3598
3598
  }
3599
3599
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3600
3600
  res += tmp !== void 0 ? tmp : "null";
3601
3601
  if (value.length - 1 > maximumBreadth) {
3602
3602
  const removedKeys = value.length - maximumBreadth - 1;
3603
- res += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
3603
+ res += `${join74}"... ${getItemCount(removedKeys)} not stringified"`;
3604
3604
  }
3605
3605
  if (spacer !== "") {
3606
3606
  res += `
@@ -3621,7 +3621,7 @@ ${originalIndentation}`;
3621
3621
  let separator = "";
3622
3622
  if (spacer !== "") {
3623
3623
  indentation += spacer;
3624
- join72 = `,
3624
+ join74 = `,
3625
3625
  ${indentation}`;
3626
3626
  whitespace = " ";
3627
3627
  }
@@ -3635,13 +3635,13 @@ ${indentation}`;
3635
3635
  const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
3636
3636
  if (tmp !== void 0) {
3637
3637
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
3638
- separator = join72;
3638
+ separator = join74;
3639
3639
  }
3640
3640
  }
3641
3641
  if (keyLength > maximumBreadth) {
3642
3642
  const removedKeys = keyLength - maximumBreadth;
3643
3643
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3644
- separator = join72;
3644
+ separator = join74;
3645
3645
  }
3646
3646
  if (spacer !== "" && separator.length > 1) {
3647
3647
  res = `
@@ -3682,7 +3682,7 @@ ${originalIndentation}`;
3682
3682
  }
3683
3683
  const originalIndentation = indentation;
3684
3684
  let res = "";
3685
- let join72 = ",";
3685
+ let join74 = ",";
3686
3686
  if (Array.isArray(value)) {
3687
3687
  if (value.length === 0) {
3688
3688
  return "[]";
@@ -3695,7 +3695,7 @@ ${originalIndentation}`;
3695
3695
  indentation += spacer;
3696
3696
  res += `
3697
3697
  ${indentation}`;
3698
- join72 = `,
3698
+ join74 = `,
3699
3699
  ${indentation}`;
3700
3700
  }
3701
3701
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3703,13 +3703,13 @@ ${indentation}`;
3703
3703
  for (; i < maximumValuesToStringify - 1; i++) {
3704
3704
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3705
3705
  res += tmp2 !== void 0 ? tmp2 : "null";
3706
- res += join72;
3706
+ res += join74;
3707
3707
  }
3708
3708
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3709
3709
  res += tmp !== void 0 ? tmp : "null";
3710
3710
  if (value.length - 1 > maximumBreadth) {
3711
3711
  const removedKeys = value.length - maximumBreadth - 1;
3712
- res += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
3712
+ res += `${join74}"... ${getItemCount(removedKeys)} not stringified"`;
3713
3713
  }
3714
3714
  if (spacer !== "") {
3715
3715
  res += `
@@ -3722,7 +3722,7 @@ ${originalIndentation}`;
3722
3722
  let whitespace = "";
3723
3723
  if (spacer !== "") {
3724
3724
  indentation += spacer;
3725
- join72 = `,
3725
+ join74 = `,
3726
3726
  ${indentation}`;
3727
3727
  whitespace = " ";
3728
3728
  }
@@ -3731,7 +3731,7 @@ ${indentation}`;
3731
3731
  const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
3732
3732
  if (tmp !== void 0) {
3733
3733
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
3734
- separator = join72;
3734
+ separator = join74;
3735
3735
  }
3736
3736
  }
3737
3737
  if (spacer !== "" && separator.length > 1) {
@@ -3789,20 +3789,20 @@ ${originalIndentation}`;
3789
3789
  indentation += spacer;
3790
3790
  let res2 = `
3791
3791
  ${indentation}`;
3792
- const join73 = `,
3792
+ const join75 = `,
3793
3793
  ${indentation}`;
3794
3794
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3795
3795
  let i = 0;
3796
3796
  for (; i < maximumValuesToStringify - 1; i++) {
3797
3797
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3798
3798
  res2 += tmp2 !== void 0 ? tmp2 : "null";
3799
- res2 += join73;
3799
+ res2 += join75;
3800
3800
  }
3801
3801
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3802
3802
  res2 += tmp !== void 0 ? tmp : "null";
3803
3803
  if (value.length - 1 > maximumBreadth) {
3804
3804
  const removedKeys = value.length - maximumBreadth - 1;
3805
- res2 += `${join73}"... ${getItemCount(removedKeys)} not stringified"`;
3805
+ res2 += `${join75}"... ${getItemCount(removedKeys)} not stringified"`;
3806
3806
  }
3807
3807
  res2 += `
3808
3808
  ${originalIndentation}`;
@@ -3818,16 +3818,16 @@ ${originalIndentation}`;
3818
3818
  return '"[Object]"';
3819
3819
  }
3820
3820
  indentation += spacer;
3821
- const join72 = `,
3821
+ const join74 = `,
3822
3822
  ${indentation}`;
3823
3823
  let res = "";
3824
3824
  let separator = "";
3825
3825
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3826
3826
  if (isTypedArrayWithEntries(value)) {
3827
- res += stringifyTypedArray(value, join72, maximumBreadth);
3827
+ res += stringifyTypedArray(value, join74, maximumBreadth);
3828
3828
  keys = keys.slice(value.length);
3829
3829
  maximumPropertiesToStringify -= value.length;
3830
- separator = join72;
3830
+ separator = join74;
3831
3831
  }
3832
3832
  if (deterministic) {
3833
3833
  keys = sort(keys, comparator);
@@ -3838,13 +3838,13 @@ ${indentation}`;
3838
3838
  const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
3839
3839
  if (tmp !== void 0) {
3840
3840
  res += `${separator}${strEscape(key3)}: ${tmp}`;
3841
- separator = join72;
3841
+ separator = join74;
3842
3842
  }
3843
3843
  }
3844
3844
  if (keyLength > maximumBreadth) {
3845
3845
  const removedKeys = keyLength - maximumBreadth;
3846
3846
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
3847
- separator = join72;
3847
+ separator = join74;
3848
3848
  }
3849
3849
  if (separator !== "") {
3850
3850
  res = `
@@ -9826,11 +9826,11 @@ async function archiveRawSession(store, sessionId) {
9826
9826
  return await store.putRawSession(sessionId, exp.tool, Math.floor(exp.mtime), gz, size);
9827
9827
  }
9828
9828
  function detectForkPredecessor(sessionPath) {
9829
- const { readFileSync: readFileSync58, readdirSync: readdirSync36 } = requireFs();
9830
- const { dirname: dirname31, join: join72, basename: basename30 } = requirePath();
9829
+ const { readFileSync: readFileSync59, readdirSync: readdirSync36 } = requireFs();
9830
+ const { dirname: dirname33, join: join74, basename: basename30 } = requirePath();
9831
9831
  let text;
9832
9832
  try {
9833
- text = readFileSync58(sessionPath, "utf-8");
9833
+ text = readFileSync59(sessionPath, "utf-8");
9834
9834
  } catch {
9835
9835
  return null;
9836
9836
  }
@@ -9852,7 +9852,7 @@ function detectForkPredecessor(sessionPath) {
9852
9852
  return null;
9853
9853
  if (text.includes(`"uuid":"${headParent}"`))
9854
9854
  return null;
9855
- const dir = dirname31(sessionPath);
9855
+ const dir = dirname33(sessionPath);
9856
9856
  const self = basename30(sessionPath);
9857
9857
  let entries;
9858
9858
  try {
@@ -9864,7 +9864,7 @@ function detectForkPredecessor(sessionPath) {
9864
9864
  if (!f.endsWith(".jsonl") || f === self || f === "sessions-index.json")
9865
9865
  continue;
9866
9866
  try {
9867
- if (readFileSync58(join72(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
9867
+ if (readFileSync59(join74(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
9868
9868
  return basename30(f, ".jsonl");
9869
9869
  }
9870
9870
  } catch {
@@ -16093,10 +16093,10 @@ var init_types = __esm({
16093
16093
 
16094
16094
  // ../engine/dist/transcript/opencode.js
16095
16095
  async function parseOpenCodeSubagents(parentSessionId) {
16096
- const { existsSync: existsSync62 } = await import("fs");
16096
+ const { existsSync: existsSync63 } = await import("fs");
16097
16097
  const { opencodeBackend: opencodeBackend2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
16098
16098
  const dbPath = opencodeBackend2.dbPath();
16099
- if (!existsSync62(dbPath))
16099
+ if (!existsSync63(dbPath))
16100
16100
  return [];
16101
16101
  const realParent = parentSessionId.replace("opencode_", "");
16102
16102
  const db = openOpencodeDbOrThrow(dbPath);
@@ -16137,10 +16137,10 @@ async function parseOpenCodeSubagents(parentSessionId) {
16137
16137
  }
16138
16138
  }
16139
16139
  async function parseOpenCodeTranscript(sessionId) {
16140
- const { existsSync: existsSync62 } = await import("fs");
16140
+ const { existsSync: existsSync63 } = await import("fs");
16141
16141
  const { opencodeBackend: opencodeBackend2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
16142
16142
  const dbPath = opencodeBackend2.dbPath();
16143
- if (!existsSync62(dbPath))
16143
+ if (!existsSync63(dbPath))
16144
16144
  return [];
16145
16145
  const realId = sessionId.replace("opencode_", "");
16146
16146
  const db = openOpencodeDbOrThrow(dbPath);
@@ -28344,7 +28344,7 @@ var init_http = __esm({
28344
28344
  CLI_VERSION = JSON.parse(readFileSync36(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
28345
28345
  } catch {
28346
28346
  try {
28347
- if (true) CLI_VERSION = "0.7.39";
28347
+ if (typeof __CLI_VERSION__ === "string") CLI_VERSION = __CLI_VERSION__;
28348
28348
  } catch {
28349
28349
  }
28350
28350
  }
@@ -28842,7 +28842,7 @@ var init_telemetry = __esm({
28842
28842
  init_sync_client();
28843
28843
  cliVersion2 = () => {
28844
28844
  try {
28845
- return true ? "0.7.39" : "dev";
28845
+ return typeof __CLI_VERSION__ === "string" ? __CLI_VERSION__ : "dev";
28846
28846
  } catch {
28847
28847
  return "dev";
28848
28848
  }
@@ -30629,13 +30629,10 @@ async function syncToTargetInScope(cred, opts = {}) {
30629
30629
  try {
30630
30630
  await reconcileFieldsForTarget(
30631
30631
  cred,
30632
- () => listAvailableBackends().flatMap((b) => {
30633
- try {
30634
- return b.listSessions({ previews: false });
30635
- } catch {
30636
- return [];
30637
- }
30638
- }),
30632
+ // Reuse the listing this sync already made. A second full listing of
30633
+ // every backend cost about 100 MB of committed heap on every tick
30634
+ // (issue #16).
30635
+ () => refs,
30639
30636
  { convRefs: slice }
30640
30637
  );
30641
30638
  } catch (e) {
@@ -31525,7 +31522,7 @@ var init_sync_client = __esm({
31525
31522
  ownVersion = JSON.parse(readFileSync41(join47(dir, "../package.json"), "utf-8")).version || ownVersion;
31526
31523
  } catch {
31527
31524
  try {
31528
- if (true) ownVersion = "0.7.39";
31525
+ if (typeof __CLI_VERSION__ === "string") ownVersion = __CLI_VERSION__;
31529
31526
  } catch {
31530
31527
  }
31531
31528
  }
@@ -33515,7 +33512,7 @@ async function signIn(server, onPrompt, o = {}) {
33515
33512
  }
33516
33513
  function relayCommand(bundleDir) {
33517
33514
  const bin = resolveOnPath("chat-recall-mcp");
33518
- return bin ? [bin] : [process.execPath, join55(bundleDir, "mcp-relay.js")];
33515
+ return bin ? [bin] : [process.execPath, join55(bundleDir, "mcp.js")];
33519
33516
  }
33520
33517
  function registerRelay(server, _bundleDir, host, env = process.env) {
33521
33518
  if (env.CHAT_RECALL_MCP_REGISTRATION?.trim().toLowerCase() === "own") return [];
@@ -33550,6 +33547,292 @@ var init_kit_store = __esm({
33550
33547
  }
33551
33548
  });
33552
33549
 
33550
+ // src/vendor/mcp-kit/host.js
33551
+ import { spawnSync as spawnSync4 } from "node:child_process";
33552
+ import { chmodSync as chmodSync5, copyFileSync as copyFileSync3, existsSync as existsSync48, mkdirSync as mkdirSync14, readFileSync as readFileSync45, renameSync as renameSync6, writeFileSync as writeFileSync15 } from "node:fs";
33553
+ import { homedir as homedir20 } from "node:os";
33554
+ import { dirname as dirname23 } from "node:path";
33555
+ function systemHost(env = process.env) {
33556
+ return {
33557
+ home: env.HOME ?? homedir20(),
33558
+ env,
33559
+ run(bin, args, opts = {}) {
33560
+ const r = spawnSync4(bin, args, {
33561
+ input: opts.input,
33562
+ cwd: opts.cwd,
33563
+ env: opts.env ?? env,
33564
+ timeout: opts.timeoutMs,
33565
+ encoding: "utf8"
33566
+ });
33567
+ return { code: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? (r.error ? String(r.error) : "") };
33568
+ },
33569
+ read(path) {
33570
+ try {
33571
+ return readFileSync45(path, "utf8");
33572
+ } catch {
33573
+ return void 0;
33574
+ }
33575
+ },
33576
+ write(path, text, opts = {}) {
33577
+ mkdirSync14(dirname23(path), { recursive: true, ...opts.dirMode === void 0 ? {} : { mode: opts.dirMode } });
33578
+ if (opts.mode === void 0) {
33579
+ if (existsSync48(path))
33580
+ copyFileSync3(path, `${path}.munhq-bak`);
33581
+ writeFileSync15(path, text);
33582
+ return;
33583
+ }
33584
+ const tmp = `${path}.${process.pid}.tmp`;
33585
+ writeFileSync15(tmp, text, { mode: opts.mode });
33586
+ chmodSync5(tmp, opts.mode);
33587
+ renameSync6(tmp, path);
33588
+ }
33589
+ };
33590
+ }
33591
+ var init_host = __esm({
33592
+ "src/vendor/mcp-kit/host.js"() {
33593
+ "use strict";
33594
+ }
33595
+ });
33596
+
33597
+ // src/vendor/mcp-kit/registry.js
33598
+ import { dirname as dirname24, join as join56 } from "node:path";
33599
+ function configPath(home) {
33600
+ return join56(home, ".config", "mcp-kit", "host.json");
33601
+ }
33602
+ function readConfig(home, read) {
33603
+ const text = read(configPath(home));
33604
+ if (text === void 0 || text.trim() === "")
33605
+ return { port: DEFAULT_PORT, host: LOOPBACK, servers: [] };
33606
+ const parsed = JSON.parse(text);
33607
+ return {
33608
+ port: typeof parsed.port === "number" && parsed.port >= 0 ? parsed.port : DEFAULT_PORT,
33609
+ host: typeof parsed.host === "string" && parsed.host !== "" ? parsed.host : LOOPBACK,
33610
+ servers: Array.isArray(parsed.servers) ? parsed.servers.filter(usable) : []
33611
+ };
33612
+ }
33613
+ function usable(spec) {
33614
+ return typeof spec?.name === "string" && spec.name !== "" && typeof spec.command === "string" && spec.command !== "";
33615
+ }
33616
+ function addServer(h, spec) {
33617
+ if (!usable(spec))
33618
+ throw new Error(`a server needs a name and a command: ${JSON.stringify(spec)}`);
33619
+ const config2 = readConfig(h.home, h.read);
33620
+ const at = config2.servers.findIndex((s) => s.name === spec.name);
33621
+ const same = at >= 0 && JSON.stringify(config2.servers[at]) === JSON.stringify(spec);
33622
+ if (same)
33623
+ return { config: config2, changed: false };
33624
+ const servers = at >= 0 ? config2.servers.map((s, i) => i === at ? spec : s) : [...config2.servers, spec];
33625
+ const next = { ...config2, servers };
33626
+ h.write(configPath(h.home), `${JSON.stringify(next, null, 2)}
33627
+ `, { mode: 384, dirMode: 448 });
33628
+ return { config: next, changed: true };
33629
+ }
33630
+ function hostPaths(home, platform2 = process.platform) {
33631
+ if (platform2 === "darwin") {
33632
+ return {
33633
+ file: join56(home, "Library", "LaunchAgents", `${HOST_LABEL}.plist`),
33634
+ log: join56(home, "Library", "Logs", `${HOST_UNIT}.log`),
33635
+ unit: HOST_UNIT,
33636
+ label: HOST_LABEL
33637
+ };
33638
+ }
33639
+ return {
33640
+ file: join56(home, ".config", "systemd", "user", `${HOST_UNIT}.service`),
33641
+ log: join56(home, ".local", "state", HOST_UNIT, "host.log"),
33642
+ unit: HOST_UNIT,
33643
+ label: HOST_LABEL
33644
+ };
33645
+ }
33646
+ function hostArgv(args) {
33647
+ return [args.node, args.main, "--config", args.config];
33648
+ }
33649
+ function unitQuote(value) {
33650
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\$/g, "$$$$").replace(/%/g, "%%")}"`;
33651
+ }
33652
+ function xml(value) {
33653
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
33654
+ }
33655
+ function unitText(argv, log6) {
33656
+ return [
33657
+ "[Unit]",
33658
+ "Description=MCP host: the local servers of this machine on the loopback address",
33659
+ "After=network.target",
33660
+ "",
33661
+ "[Service]",
33662
+ `ExecStart=${argv.map(unitQuote).join(" ")}`,
33663
+ "Restart=always",
33664
+ "RestartSec=2",
33665
+ `StandardOutput=append:${log6}`,
33666
+ `StandardError=append:${log6}`,
33667
+ "",
33668
+ "[Install]",
33669
+ "WantedBy=default.target",
33670
+ ""
33671
+ ].join("\n");
33672
+ }
33673
+ function plistText(argv, log6, label = HOST_LABEL) {
33674
+ return [
33675
+ '<?xml version="1.0" encoding="UTF-8"?>',
33676
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
33677
+ '<plist version="1.0">',
33678
+ "<dict>",
33679
+ ` <key>Label</key><string>${xml(label)}</string>`,
33680
+ " <key>ProgramArguments</key>",
33681
+ " <array>",
33682
+ ...argv.map((a) => ` <string>${xml(a)}</string>`),
33683
+ " </array>",
33684
+ " <key>RunAtLoad</key><true/>",
33685
+ " <key>KeepAlive</key><true/>",
33686
+ ` <key>StandardOutPath</key><string>${xml(log6)}</string>`,
33687
+ ` <key>StandardErrorPath</key><string>${xml(log6)}</string>`,
33688
+ "</dict>",
33689
+ "</plist>",
33690
+ ""
33691
+ ].join("\n");
33692
+ }
33693
+ function installHost(h, args) {
33694
+ const platform2 = args.platform ?? process.platform;
33695
+ if (platform2 !== "linux" && platform2 !== "darwin")
33696
+ return { written: [] };
33697
+ const paths = hostPaths(h.home, platform2);
33698
+ h.run("mkdir", ["-p", dirname24(paths.log)]);
33699
+ const text = platform2 === "darwin" ? plistText(args.argv, paths.log, paths.label) : unitText(args.argv, paths.log);
33700
+ const written = [];
33701
+ if (h.read(paths.file) !== text) {
33702
+ h.write(paths.file, text);
33703
+ written.push(paths.file);
33704
+ }
33705
+ if (platform2 === "darwin") {
33706
+ h.run("launchctl", ["unload", paths.file]);
33707
+ h.run("launchctl", ["load", "-w", paths.file]);
33708
+ return { written, load: ["launchctl", "load", "-w", paths.file] };
33709
+ }
33710
+ if (written.length > 0)
33711
+ h.run("systemctl", ["--user", "daemon-reload"]);
33712
+ const enabled = h.run("systemctl", ["--user", "enable", "--now", `${paths.unit}.service`]);
33713
+ return { written, load: enabled.code === 0 ? void 0 : ["systemctl", "--user", "enable", "--now", `${paths.unit}.service`] };
33714
+ }
33715
+ function hostStatus(h, platform2 = process.platform) {
33716
+ if (platform2 !== "linux" && platform2 !== "darwin")
33717
+ return "disabled";
33718
+ const paths = hostPaths(h.home, platform2);
33719
+ if (h.read(paths.file) === void 0)
33720
+ return "disabled";
33721
+ const got = platform2 === "darwin" ? h.run("launchctl", ["list", paths.label]) : h.run("systemctl", ["--user", "is-active", `${paths.unit}.service`]);
33722
+ return got.code === 0 ? "running" : "stopped";
33723
+ }
33724
+ function restartHost(h, platform2 = process.platform) {
33725
+ if (hostStatus(h, platform2) !== "running")
33726
+ return false;
33727
+ const paths = hostPaths(h.home, platform2);
33728
+ if (platform2 === "darwin") {
33729
+ h.run("launchctl", ["unload", paths.file]);
33730
+ return h.run("launchctl", ["load", "-w", paths.file]).code === 0;
33731
+ }
33732
+ return h.run("systemctl", ["--user", "restart", `${paths.unit}.service`]).code === 0;
33733
+ }
33734
+ function uninstallHost(h, platform2 = process.platform) {
33735
+ if (platform2 !== "linux" && platform2 !== "darwin")
33736
+ return [];
33737
+ const paths = hostPaths(h.home, platform2);
33738
+ if (h.read(paths.file) === void 0)
33739
+ return [];
33740
+ if (platform2 === "darwin")
33741
+ h.run("launchctl", ["unload", paths.file]);
33742
+ else
33743
+ h.run("systemctl", ["--user", "disable", "--now", `${paths.unit}.service`]);
33744
+ h.write(paths.file, "");
33745
+ return [paths.file];
33746
+ }
33747
+ var DEFAULT_PORT, LOOPBACK, HOST_UNIT, HOST_LABEL;
33748
+ var init_registry = __esm({
33749
+ "src/vendor/mcp-kit/registry.js"() {
33750
+ "use strict";
33751
+ DEFAULT_PORT = 7717;
33752
+ LOOPBACK = "127.0.0.1";
33753
+ HOST_UNIT = "mcp-kit-host";
33754
+ HOST_LABEL = "com.munhq.mcp-kit-host";
33755
+ }
33756
+ });
33757
+
33758
+ // src/mcp-host.ts
33759
+ var mcp_host_exports = {};
33760
+ __export(mcp_host_exports, {
33761
+ HOST_SERVER_NAME: () => HOST_SERVER_NAME,
33762
+ hostSupported: () => hostSupported,
33763
+ installMcpHost: () => installMcpHost,
33764
+ localMcpUrl: () => localMcpUrl,
33765
+ machineConfig: () => machineConfig,
33766
+ removeMcpHost: () => removeMcpHost
33767
+ });
33768
+ import { join as join57 } from "node:path";
33769
+ function hostSupported(platform2 = process.platform) {
33770
+ return platform2 === "linux" || platform2 === "darwin";
33771
+ }
33772
+ function machineOf(deps) {
33773
+ return deps.host ?? systemHost();
33774
+ }
33775
+ function machineConfig(deps = {}) {
33776
+ const host = machineOf(deps);
33777
+ try {
33778
+ return readConfig(host.home, host.read);
33779
+ } catch {
33780
+ return { port: DEFAULT_PORT, host: LOOPBACK, servers: [] };
33781
+ }
33782
+ }
33783
+ function localMcpUrl(deps = {}) {
33784
+ const config2 = machineConfig(deps);
33785
+ return `http://${config2.host}:${config2.port}/${HOST_SERVER_NAME}`;
33786
+ }
33787
+ function installMcpHost(distDir, deps = {}) {
33788
+ const host = machineOf(deps);
33789
+ const platform2 = deps.platform ?? process.platform;
33790
+ const url = localMcpUrl(deps);
33791
+ if (!hostSupported(platform2)) {
33792
+ return { url, changed: false, written: [], problem: `the host of this machine needs Linux or macOS, not ${platform2}` };
33793
+ }
33794
+ try {
33795
+ const spec = {
33796
+ name: HOST_SERVER_NAME,
33797
+ command: deps.execPath ?? process.execPath,
33798
+ args: [join57(distDir, "mcp.js")],
33799
+ env: { ...SERVER_ENV }
33800
+ };
33801
+ const ranBefore = hostStatus(host, platform2) === "running";
33802
+ const { config: config2, changed } = addServer(host, spec);
33803
+ const argv = hostArgv({ node: spec.command, main: join57(distDir, "vendor", "mcp-kit", "host-main.js"), config: configPath(host.home) });
33804
+ const { written } = installHost(host, { argv, platform: platform2 });
33805
+ if (changed && ranBefore) restartHost(host, platform2);
33806
+ return { url: `http://${config2.host}:${config2.port}/${HOST_SERVER_NAME}`, changed, written };
33807
+ } catch (err) {
33808
+ return { url, changed: false, written: [], problem: err.message };
33809
+ }
33810
+ }
33811
+ function removeMcpHost(deps = {}) {
33812
+ const host = machineOf(deps);
33813
+ const platform2 = deps.platform ?? process.platform;
33814
+ if (!hostSupported(platform2)) return [];
33815
+ const config2 = machineConfig(deps);
33816
+ const servers = config2.servers.filter((server) => server.name !== HOST_SERVER_NAME);
33817
+ if (servers.length === config2.servers.length) return [];
33818
+ const file = configPath(host.home);
33819
+ host.write(file, `${JSON.stringify({ ...config2, servers }, null, 2)}
33820
+ `, { mode: 384, dirMode: 448 });
33821
+ if (servers.length === 0) return uninstallHost(host, platform2);
33822
+ restartHost(host, platform2);
33823
+ return [file];
33824
+ }
33825
+ var HOST_SERVER_NAME, SERVER_ENV;
33826
+ var init_mcp_host = __esm({
33827
+ "src/mcp-host.ts"() {
33828
+ "use strict";
33829
+ init_host();
33830
+ init_registry();
33831
+ HOST_SERVER_NAME = "chat-recall";
33832
+ SERVER_ENV = { NODE_OPTIONS: "--max-old-space-size=1024" };
33833
+ }
33834
+ });
33835
+
33553
33836
  // ../engine/dist/core/companions.js
33554
33837
  var companions_exports = {};
33555
33838
  __export(companions_exports, {
@@ -33564,9 +33847,9 @@ __export(companions_exports, {
33564
33847
  uninstallCodeindex: () => uninstallCodeindex,
33565
33848
  unregisterCodeindexMcp: () => unregisterCodeindexMcp
33566
33849
  });
33567
- import { existsSync as existsSync48, mkdirSync as mkdirSync14, statSync as statSync43, chmodSync as chmodSync5, unlinkSync as unlinkSync3, renameSync as renameSync6, createWriteStream as createWriteStream2, readFileSync as readFileSync45, writeFileSync as writeFileSync15 } from "node:fs";
33568
- import { homedir as homedir20 } from "node:os";
33569
- import { join as join56 } from "node:path";
33850
+ import { existsSync as existsSync49, mkdirSync as mkdirSync15, statSync as statSync43, chmodSync as chmodSync6, unlinkSync as unlinkSync3, renameSync as renameSync7, createWriteStream as createWriteStream2, readFileSync as readFileSync46, writeFileSync as writeFileSync16 } from "node:fs";
33851
+ import { homedir as homedir21 } from "node:os";
33852
+ import { join as join58 } from "node:path";
33570
33853
  import { execSync as execSync3 } from "node:child_process";
33571
33854
  import { createHash as createHash13 } from "node:crypto";
33572
33855
  function expectedCodeindexSha256(artifact) {
@@ -33668,7 +33951,7 @@ async function installCodeindex(opts = {}) {
33668
33951
  return status;
33669
33952
  if (!status.prebuiltAvailable)
33670
33953
  return status;
33671
- mkdirSync14(CODEINDEX_INSTALL_DIR, { recursive: true });
33954
+ mkdirSync15(CODEINDEX_INSTALL_DIR, { recursive: true });
33672
33955
  const tmpPath = `${CODEINDEX_BIN_PATH}.partial`;
33673
33956
  try {
33674
33957
  await downloadArtifact(status.artifactName, tmpPath);
@@ -33676,18 +33959,18 @@ async function installCodeindex(opts = {}) {
33676
33959
  if (!expected) {
33677
33960
  throw new Error(`No pinned checksum for ${status.artifactName} \u2014 refusing to install an unverified binary. Add its sha256 to CODEINDEX_SHA256 in companions.ts.`);
33678
33961
  }
33679
- const actual = createHash13("sha256").update(readFileSync45(tmpPath)).digest("hex");
33962
+ const actual = createHash13("sha256").update(readFileSync46(tmpPath)).digest("hex");
33680
33963
  if (actual !== expected) {
33681
33964
  throw new Error(`Checksum mismatch for ${status.artifactName}.
33682
33965
  expected ${expected}
33683
33966
  actual ${actual}
33684
33967
  Refusing to install. The release may have been re-uploaded, or something is serving different bytes.`);
33685
33968
  }
33686
- chmodSync5(tmpPath, 493);
33687
- renameSync6(tmpPath, CODEINDEX_BIN_PATH);
33969
+ chmodSync6(tmpPath, 493);
33970
+ renameSync7(tmpPath, CODEINDEX_BIN_PATH);
33688
33971
  } catch (err) {
33689
33972
  try {
33690
- if (existsSync48(tmpPath))
33973
+ if (existsSync49(tmpPath))
33691
33974
  unlinkSync3(tmpPath);
33692
33975
  } catch {
33693
33976
  }
@@ -33696,7 +33979,7 @@ Refusing to install. The release may have been re-uploaded, or something is serv
33696
33979
  return checkCodeindexStatus();
33697
33980
  }
33698
33981
  function uninstallCodeindex() {
33699
- if (existsSync48(CODEINDEX_BIN_PATH)) {
33982
+ if (existsSync49(CODEINDEX_BIN_PATH)) {
33700
33983
  unlinkSync3(CODEINDEX_BIN_PATH);
33701
33984
  return { removed: true, path: CODEINDEX_BIN_PATH };
33702
33985
  }
@@ -33704,9 +33987,9 @@ function uninstallCodeindex() {
33704
33987
  }
33705
33988
  function registerCodeindexMcp(mcpJsonPath, binaryPath) {
33706
33989
  let cfg = {};
33707
- if (existsSync48(mcpJsonPath)) {
33990
+ if (existsSync49(mcpJsonPath)) {
33708
33991
  try {
33709
- cfg = JSON.parse(readFileSync45(mcpJsonPath, "utf-8"));
33992
+ cfg = JSON.parse(readFileSync46(mcpJsonPath, "utf-8"));
33710
33993
  } catch {
33711
33994
  cfg = {};
33712
33995
  }
@@ -33715,22 +33998,22 @@ function registerCodeindexMcp(mcpJsonPath, binaryPath) {
33715
33998
  if (cfg.mcpServers["codeindex"])
33716
33999
  return { added: false };
33717
34000
  cfg.mcpServers["codeindex"] = { command: binaryPath, args: ["--mcp"] };
33718
- writeFileSync15(mcpJsonPath, JSON.stringify(cfg, null, 2));
34001
+ writeFileSync16(mcpJsonPath, JSON.stringify(cfg, null, 2));
33719
34002
  return { added: true };
33720
34003
  }
33721
34004
  function unregisterCodeindexMcp(mcpJsonPath) {
33722
- if (!existsSync48(mcpJsonPath))
34005
+ if (!existsSync49(mcpJsonPath))
33723
34006
  return { removed: false };
33724
34007
  let cfg;
33725
34008
  try {
33726
- cfg = JSON.parse(readFileSync45(mcpJsonPath, "utf-8"));
34009
+ cfg = JSON.parse(readFileSync46(mcpJsonPath, "utf-8"));
33727
34010
  } catch {
33728
34011
  return { removed: false };
33729
34012
  }
33730
34013
  if (!cfg.mcpServers?.["codeindex"])
33731
34014
  return { removed: false };
33732
34015
  delete cfg.mcpServers["codeindex"];
33733
- writeFileSync15(mcpJsonPath, JSON.stringify(cfg, null, 2));
34016
+ writeFileSync16(mcpJsonPath, JSON.stringify(cfg, null, 2));
33734
34017
  return { removed: true };
33735
34018
  }
33736
34019
  var CODEINDEX_REPO, CODEINDEX_VERSION, CODEINDEX_SHA256, CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME, CODEINDEX_BIN_PATH;
@@ -33748,9 +34031,9 @@ var init_companions = __esm({
33748
34031
  "x86_64-windows": "a96fc8c8949bb399a44cc0615b12e458460a529c69f01e8829cc39a20f45ab29",
33749
34032
  "aarch64-windows": "42620d56272cd9ba9d785569d8d754d6b4a3e80f36f28db3e0c483fd600ed117"
33750
34033
  };
33751
- CODEINDEX_INSTALL_DIR = join56(homedir20(), ".local", "bin");
34034
+ CODEINDEX_INSTALL_DIR = join58(homedir21(), ".local", "bin");
33752
34035
  CODEINDEX_BIN_NAME = process.platform === "win32" ? "codeindex.exe" : "codeindex";
33753
- CODEINDEX_BIN_PATH = join56(CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME);
34036
+ CODEINDEX_BIN_PATH = join58(CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME);
33754
34037
  }
33755
34038
  });
33756
34039
 
@@ -33765,15 +34048,15 @@ __export(install_skills_exports, {
33765
34048
  skillsSourceDir: () => skillsSourceDir,
33766
34049
  uninstallSkills: () => uninstallSkills
33767
34050
  });
33768
- import { readdirSync as readdirSync33, existsSync as existsSync49, mkdirSync as mkdirSync15, rmSync as rmSync8, cpSync, writeFileSync as writeFileSync16, readFileSync as readFileSync46, statSync as statSync44, realpathSync as realpathSync5 } from "fs";
34051
+ import { readdirSync as readdirSync33, existsSync as existsSync50, mkdirSync as mkdirSync16, rmSync as rmSync8, cpSync, writeFileSync as writeFileSync17, readFileSync as readFileSync47, statSync as statSync44, realpathSync as realpathSync5 } from "fs";
33769
34052
  import { createHash as createHash14 } from "crypto";
33770
- import { join as join57, basename as basename23 } from "path";
34053
+ import { join as join59, basename as basename23 } from "path";
33771
34054
  function skillsSourceDir() {
33772
- return join57(import.meta.dirname, "..", "skills");
34055
+ return join59(import.meta.dirname, "..", "skills");
33773
34056
  }
33774
34057
  function version() {
33775
34058
  try {
33776
- return JSON.parse(readFileSync46(new URL("../package.json", import.meta.url), "utf-8")).version || "0.0.0";
34059
+ return JSON.parse(readFileSync47(new URL("../package.json", import.meta.url), "utf-8")).version || "0.0.0";
33777
34060
  } catch {
33778
34061
  return "0.0.0";
33779
34062
  }
@@ -33782,9 +34065,9 @@ function skillsFingerprint() {
33782
34065
  const src = skillsSourceDir();
33783
34066
  const h = createHash14("sha256");
33784
34067
  for (const name of bundledSkillNames()) {
33785
- for (const rel of filesUnder(join57(src, name)).sort()) {
34068
+ for (const rel of filesUnder(join59(src, name)).sort()) {
33786
34069
  h.update(name + "/" + rel);
33787
- h.update(readFileSync46(join57(src, name, rel)));
34070
+ h.update(readFileSync47(join59(src, name, rel)));
33788
34071
  }
33789
34072
  }
33790
34073
  return h.digest("hex").slice(0, 12);
@@ -33794,7 +34077,7 @@ function filesUnder(dir, prefix = "") {
33794
34077
  for (const e of readdirSync33(dir, { withFileTypes: true })) {
33795
34078
  if (e.name === MARKER) continue;
33796
34079
  const rel = prefix ? `${prefix}/${e.name}` : e.name;
33797
- if (e.isDirectory()) out.push(...filesUnder(join57(dir, e.name), rel));
34080
+ if (e.isDirectory()) out.push(...filesUnder(join59(dir, e.name), rel));
33798
34081
  else out.push(rel);
33799
34082
  }
33800
34083
  return out;
@@ -33804,8 +34087,8 @@ function skillStamp() {
33804
34087
  }
33805
34088
  function bundledSkillNames() {
33806
34089
  const src = skillsSourceDir();
33807
- if (!existsSync49(src)) return [];
33808
- return readdirSync33(src, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync49(join57(src, e.name, "SKILL.md"))).map((e) => e.name).sort();
34090
+ if (!existsSync50(src)) return [];
34091
+ return readdirSync33(src, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync50(join59(src, e.name, "SKILL.md"))).map((e) => e.name).sort();
33809
34092
  }
33810
34093
  function realPathOrSelf(p) {
33811
34094
  try {
@@ -33818,7 +34101,7 @@ function claudeSkillTargets() {
33818
34101
  const targets = [];
33819
34102
  const seen = /* @__PURE__ */ new Set();
33820
34103
  for (const home of claudeHomeDirs()) {
33821
- const dir = join57(home, "skills");
34104
+ const dir = join59(home, "skills");
33822
34105
  const key2 = realPathOrSelf(dir);
33823
34106
  if (seen.has(key2)) continue;
33824
34107
  seen.add(key2);
@@ -33829,7 +34112,7 @@ function claudeSkillTargets() {
33829
34112
  dir,
33830
34113
  // Judge each profile on ITS OWN transcripts, not the primary's: a home
33831
34114
  // with no projects/ is a directory someone made, not a Claude install.
33832
- available: existsSync49(join57(home, "projects"))
34115
+ available: existsSync50(join59(home, "projects"))
33833
34116
  });
33834
34117
  }
33835
34118
  if (targets.length === 0) {
@@ -33844,17 +34127,17 @@ function skillTargets() {
33844
34127
  // both produces "skill conflict" duplicate warnings. Every tool we support
33845
34128
  // has its own dir, so per-tool coverage is complete.
33846
34129
  ...claudeSkillTargets(),
33847
- { id: "agy", label: "Antigravity", dir: join57(agyBackend.homeDir(), "skills"), available: agyBackend.isAvailable() },
34130
+ { id: "agy", label: "Antigravity", dir: join59(agyBackend.homeDir(), "skills"), available: agyBackend.isAvailable() },
33848
34131
  { id: "codex", label: "Codex", dir: codexBackend.skillsDir(), available: codexBackend.isAvailable() },
33849
34132
  { id: "opencode", label: "OpenCode", dir: opencodeBackend.skillsDir(), available: opencodeBackend.isAvailable() },
33850
34133
  // Cursor DOES have its own dir (~/.cursor/skills). `skills-cursor` next to
33851
34134
  // it is Cursor's bundled set — read-only, never an install target.
33852
- { id: "cursor", label: "Cursor", dir: join57(cursorHomeDir(), "skills"), available: cursorBackend.isAvailable() },
34135
+ { id: "cursor", label: "Cursor", dir: join59(cursorHomeDir(), "skills"), available: cursorBackend.isAvailable() },
33853
34136
  { id: "pi", label: "Pi", dir: piBackend.skillsDir(), available: piBackend.isAvailable() }
33854
34137
  ];
33855
34138
  }
33856
34139
  function isManaged(dir) {
33857
- return existsSync49(join57(dir, MARKER));
34140
+ return existsSync50(join59(dir, MARKER));
33858
34141
  }
33859
34142
  function installSkills(opts = {}) {
33860
34143
  const onlyAvailable = opts.onlyAvailable ?? true;
@@ -33871,15 +34154,15 @@ function installSkills(opts = {}) {
33871
34154
  continue;
33872
34155
  }
33873
34156
  for (const name of names) {
33874
- const dest = join57(t.dir, name);
33875
- if (existsSync49(dest) && !isManaged(dest)) {
34157
+ const dest = join59(t.dir, name);
34158
+ if (existsSync50(dest) && !isManaged(dest)) {
33876
34159
  skippedUserOwned.push(name);
33877
34160
  continue;
33878
34161
  }
33879
- mkdirSync15(t.dir, { recursive: true });
34162
+ mkdirSync16(t.dir, { recursive: true });
33880
34163
  rmSync8(dest, { recursive: true, force: true });
33881
- cpSync(join57(src, name), dest, { recursive: true });
33882
- writeFileSync16(join57(dest, MARKER), `${stamp}
34164
+ cpSync(join59(src, name), dest, { recursive: true });
34165
+ writeFileSync17(join59(dest, MARKER), `${stamp}
33883
34166
  `);
33884
34167
  installed.push(name);
33885
34168
  }
@@ -33892,13 +34175,13 @@ function uninstallSkills() {
33892
34175
  const perTarget = [];
33893
34176
  for (const t of skillTargets()) {
33894
34177
  const removed = [];
33895
- if (!existsSync49(t.dir)) {
34178
+ if (!existsSync50(t.dir)) {
33896
34179
  perTarget.push({ id: t.id, label: t.label, removed });
33897
34180
  continue;
33898
34181
  }
33899
34182
  for (const entry of readdirSync33(t.dir, { withFileTypes: true })) {
33900
34183
  if (!entry.isDirectory()) continue;
33901
- const dir = join57(t.dir, entry.name);
34184
+ const dir = join59(t.dir, entry.name);
33902
34185
  if (isManaged(dir) && (names.has(entry.name) || entry.name.startsWith("chat-recall"))) {
33903
34186
  rmSync8(dir, { recursive: true, force: true });
33904
34187
  removed.push(entry.name);
@@ -33915,10 +34198,10 @@ function skillsNeedRefresh() {
33915
34198
  for (const t of skillTargets()) {
33916
34199
  if (!t.available) continue;
33917
34200
  for (const name of names) {
33918
- const marker = join57(t.dir, name, MARKER);
33919
- if (!existsSync49(marker)) return true;
34201
+ const marker = join59(t.dir, name, MARKER);
34202
+ if (!existsSync50(marker)) return true;
33920
34203
  try {
33921
- if (readFileSync46(marker, "utf-8").trim() !== cur) return true;
34204
+ if (readFileSync47(marker, "utf-8").trim() !== cur) return true;
33922
34205
  } catch {
33923
34206
  return true;
33924
34207
  }
@@ -33933,11 +34216,11 @@ function skillStatus() {
33933
34216
  let installed = 0;
33934
34217
  let ver = null;
33935
34218
  for (const name of names) {
33936
- const marker = join57(t.dir, name, MARKER);
33937
- if (existsSync49(marker)) {
34219
+ const marker = join59(t.dir, name, MARKER);
34220
+ if (existsSync50(marker)) {
33938
34221
  installed++;
33939
34222
  try {
33940
- ver = readFileSync46(marker, "utf-8").trim();
34223
+ ver = readFileSync47(marker, "utf-8").trim();
33941
34224
  } catch {
33942
34225
  }
33943
34226
  }
@@ -33962,9 +34245,9 @@ var init_install_skills = __esm({
33962
34245
  });
33963
34246
 
33964
34247
  // ../engine/dist/core/artifact-codec.js
33965
- import { readFileSync as readFileSync47 } from "fs";
33966
- import { basename as basename24, join as join58 } from "path";
33967
- import { homedir as homedir21 } from "os";
34248
+ import { readFileSync as readFileSync48 } from "fs";
34249
+ import { basename as basename24, join as join60 } from "path";
34250
+ import { homedir as homedir22 } from "os";
33968
34251
  function parseCommandText(content, format, fallbackName) {
33969
34252
  if (format === "toml") {
33970
34253
  const t = parseScalarToml(content);
@@ -33986,30 +34269,30 @@ function parseAgentText(content, format, fallbackName) {
33986
34269
  return { name: fm.name || fallbackName, description: fm.description || "", tools: fm.tools, body: body2.trim() };
33987
34270
  }
33988
34271
  function readCommand(filePath, format) {
33989
- return parseCommandText(readFileSync47(filePath, "utf-8"), format, base2(filePath));
34272
+ return parseCommandText(readFileSync48(filePath, "utf-8"), format, base2(filePath));
33990
34273
  }
33991
34274
  function readAgent(filePath, format) {
33992
- return parseAgentText(readFileSync47(filePath, "utf-8"), format, base2(filePath));
34275
+ return parseAgentText(readFileSync48(filePath, "utf-8"), format, base2(filePath));
33993
34276
  }
33994
34277
  function readInstructions(filePath, name) {
33995
- const content = readFileSync47(filePath, "utf-8");
34278
+ const content = readFileSync48(filePath, "utf-8");
33996
34279
  return { name, description: "", body: content };
33997
34280
  }
33998
34281
  function commandPath(tool, name) {
33999
34282
  switch (tool) {
34000
34283
  case "claude":
34001
- return join58(claudeBackend.commandsDir(), `${name}.md`);
34284
+ return join60(claudeBackend.commandsDir(), `${name}.md`);
34002
34285
  case "agy":
34003
- return join58(join58(agyBackend.homeDir(), "commands"), `${name}.toml`);
34286
+ return join60(join60(agyBackend.homeDir(), "commands"), `${name}.toml`);
34004
34287
  case "opencode":
34005
- return join58(opencodeBackend.commandsDir(), `${name}.md`);
34288
+ return join60(opencodeBackend.commandsDir(), `${name}.md`);
34006
34289
  case "codex":
34007
- return join58(codexBackend.promptsDir(), `${name}.md`);
34290
+ return join60(codexBackend.promptsDir(), `${name}.md`);
34008
34291
  case "cursor":
34009
- return join58(cursorHomeDir(), "commands", `${name}.md`);
34292
+ return join60(cursorHomeDir(), "commands", `${name}.md`);
34010
34293
  // Pi's prompt templates are flat *.md files in the agent dir.
34011
34294
  case "pi":
34012
- return join58(piBackend.promptsDir(), `${name}.md`);
34295
+ return join60(piBackend.promptsDir(), `${name}.md`);
34013
34296
  // Hermes has no command files. copyArtifactToTool refuses this target first.
34014
34297
  case "hermes":
34015
34298
  throw new Error("Hermes has no command files");
@@ -34018,15 +34301,15 @@ function commandPath(tool, name) {
34018
34301
  function agentPath(tool, name) {
34019
34302
  switch (tool) {
34020
34303
  case "claude":
34021
- return join58(claudeBackend.agentsDir(), `${name}.md`);
34304
+ return join60(claudeBackend.agentsDir(), `${name}.md`);
34022
34305
  case "agy":
34023
- return join58(join58(agyBackend.homeDir(), "agents"), `${name}.md`);
34306
+ return join60(join60(agyBackend.homeDir(), "agents"), `${name}.md`);
34024
34307
  case "opencode":
34025
- return join58(opencodeBackend.agentsDir(), `${name}.md`);
34308
+ return join60(opencodeBackend.agentsDir(), `${name}.md`);
34026
34309
  case "codex":
34027
- return join58(codexBackend.agentsDir(), `${name}.toml`);
34310
+ return join60(codexBackend.agentsDir(), `${name}.toml`);
34028
34311
  case "cursor":
34029
- return join58(cursorHomeDir(), "agents", `${name}.md`);
34312
+ return join60(cursorHomeDir(), "agents", `${name}.md`);
34030
34313
  // Pi has no named agent personas. copyArtifactToTool refuses this target first.
34031
34314
  case "pi":
34032
34315
  throw new Error("Pi has no agent files");
@@ -34063,23 +34346,23 @@ function instructionsFilename(tool) {
34063
34346
  function instructionsPath(tool, projectPath) {
34064
34347
  const file = instructionsFilename(tool);
34065
34348
  if (projectPath)
34066
- return join58(projectPath, file);
34349
+ return join60(projectPath, file);
34067
34350
  switch (tool) {
34068
34351
  case "claude":
34069
- return join58(claudeBackend.homeDir(), file);
34352
+ return join60(claudeBackend.homeDir(), file);
34070
34353
  case "agy":
34071
- return join58(agyBackend.homeDir(), file);
34354
+ return join60(agyBackend.homeDir(), file);
34072
34355
  case "codex":
34073
- return join58(codexBackend.homeDir(), file);
34356
+ return join60(codexBackend.homeDir(), file);
34074
34357
  case "opencode":
34075
- return join58(homedir21(), ".config", "opencode", file);
34358
+ return join60(homedir22(), ".config", "opencode", file);
34076
34359
  // Cursor has no single user-scope instructions FILE — user-level guidance
34077
34360
  // is User Rules plus ~/.cursor/rules/*.mdc. AGENTS.md at the home root is
34078
34361
  // the closest equivalent and is what a mirror can actually write.
34079
34362
  case "cursor":
34080
- return join58(cursorHomeDir(), file);
34363
+ return join60(cursorHomeDir(), file);
34081
34364
  case "pi":
34082
- return join58(piBackend.homeDir(), file);
34365
+ return join60(piBackend.homeDir(), file);
34083
34366
  case "hermes":
34084
34367
  throw new Error("Hermes has no instruction file mapping");
34085
34368
  }
@@ -34148,9 +34431,9 @@ __export(toolkit_sync_exports, {
34148
34431
  supportedTargetsFor: () => supportedTargetsFor,
34149
34432
  writeMcpEntry: () => writeMcpEntry
34150
34433
  });
34151
- import { existsSync as existsSync50, mkdirSync as mkdirSync16, readFileSync as readFileSync48, readdirSync as readdirSync34, writeFileSync as writeFileSync17, cpSync as cpSync2, rmSync as rmSync9 } from "fs";
34152
- import { dirname as dirname23, join as join59, basename as basename25 } from "path";
34153
- import { homedir as homedir22 } from "os";
34434
+ import { existsSync as existsSync51, mkdirSync as mkdirSync17, readFileSync as readFileSync49, readdirSync as readdirSync34, writeFileSync as writeFileSync18, cpSync as cpSync2, rmSync as rmSync9 } from "fs";
34435
+ import { dirname as dirname25, join as join61, basename as basename25 } from "path";
34436
+ import { homedir as homedir23 } from "os";
34154
34437
  function supportedTargetsFor(type) {
34155
34438
  return SUPPORTED_TARGETS[type];
34156
34439
  }
@@ -34191,16 +34474,16 @@ function skillsDirFor(tool) {
34191
34474
  case "claude":
34192
34475
  return claudeBackend.skillsDir();
34193
34476
  case "agy":
34194
- return join59(agyBackend.homeDir(), "skills");
34477
+ return join61(agyBackend.homeDir(), "skills");
34195
34478
  case "opencode":
34196
34479
  return opencodeBackend.skillsDir();
34197
34480
  case "codex":
34198
34481
  return codexBackend.skillsDir();
34199
34482
  // user skills, NOT .system
34200
34483
  case "cursor":
34201
- return join59(cursorHomeDir(), "skills");
34484
+ return join61(cursorHomeDir(), "skills");
34202
34485
  case "hermes":
34203
- return join59(hermesBackend.homeDir(), "skills");
34486
+ return join61(hermesBackend.homeDir(), "skills");
34204
34487
  case "pi":
34205
34488
  return piBackend.skillsDir();
34206
34489
  }
@@ -34208,28 +34491,28 @@ function skillsDirFor(tool) {
34208
34491
  function skillDirsNamed(tool, name) {
34209
34492
  const root = skillsDirFor(tool);
34210
34493
  const found = [];
34211
- if (existsSync50(join59(root, name)))
34212
- found.push(join59(root, name));
34213
- if (tool !== "hermes" || !existsSync50(root))
34494
+ if (existsSync51(join61(root, name)))
34495
+ found.push(join61(root, name));
34496
+ if (tool !== "hermes" || !existsSync51(root))
34214
34497
  return found;
34215
34498
  for (const category of readdirSync34(root)) {
34216
- const candidate = join59(root, category, name);
34217
- if (existsSync50(join59(candidate, "SKILL.md")))
34499
+ const candidate = join61(root, category, name);
34500
+ if (existsSync51(join61(candidate, "SKILL.md")))
34218
34501
  found.push(candidate);
34219
34502
  }
34220
34503
  return found;
34221
34504
  }
34222
34505
  function copySkill(row, toTool) {
34223
- const skillDir = row.extra.skillDir || dirname23(row.filePath);
34224
- if (!existsSync50(skillDir))
34506
+ const skillDir = row.extra.skillDir || dirname25(row.filePath);
34507
+ if (!existsSync51(skillDir))
34225
34508
  return { ok: false, status: 404, error: `Source dir missing: ${skillDir}` };
34226
34509
  const name = row.extra.skillName || basename25(skillDir);
34227
- const targetDir = join59(skillsDirFor(toTool), name);
34510
+ const targetDir = join61(skillsDirFor(toTool), name);
34228
34511
  const existing = skillDirsNamed(toTool, name);
34229
34512
  if (existing.length)
34230
34513
  return { ok: false, status: 409, error: `Already exists: ${existing[0]}` };
34231
34514
  try {
34232
- mkdirSync16(dirname23(targetDir), { recursive: true });
34515
+ mkdirSync17(dirname25(targetDir), { recursive: true });
34233
34516
  cpSync2(skillDir, targetDir, { recursive: true });
34234
34517
  return { ok: true, targetPath: targetDir };
34235
34518
  } catch (e) {
@@ -34237,26 +34520,26 @@ function copySkill(row, toTool) {
34237
34520
  }
34238
34521
  }
34239
34522
  function mcpJsonCandidates(tool) {
34240
- const home = homedir22();
34523
+ const home = homedir23();
34241
34524
  switch (tool) {
34242
34525
  case "claude":
34243
34526
  return [
34244
- { path: join59(home, ".mcp.json"), key: "mcpServers" },
34245
- { path: join59(home, ".claude.json"), key: "mcpServers" }
34527
+ { path: join61(home, ".mcp.json"), key: "mcpServers" },
34528
+ { path: join61(home, ".claude.json"), key: "mcpServers" }
34246
34529
  ];
34247
34530
  case "gemini":
34248
- return [{ path: join59(home, ".gemini", "settings.json"), key: "mcpServers" }];
34531
+ return [{ path: join61(home, ".gemini", "settings.json"), key: "mcpServers" }];
34249
34532
  case "agy":
34250
- return [{ path: join59(home, ".gemini", "config", "mcp_config.json"), key: "mcpServers" }];
34533
+ return [{ path: join61(home, ".gemini", "config", "mcp_config.json"), key: "mcpServers" }];
34251
34534
  case "cursor":
34252
- return [{ path: join59(cursorHomeDir(), "mcp.json"), key: "mcpServers" }];
34535
+ return [{ path: join61(cursorHomeDir(), "mcp.json"), key: "mcpServers" }];
34253
34536
  case "pi":
34254
34537
  return [{ path: piMcpConfigPath(), key: "mcpServers" }];
34255
34538
  case "opencode":
34256
34539
  return [
34257
- { path: join59(home, ".config", "opencode", "opencode.json"), key: "mcp" },
34258
- { path: join59(home, ".config", "opencode", "config.json"), key: "mcp" },
34259
- { path: join59(home, ".opencode", "config.json"), key: "mcp" }
34540
+ { path: join61(home, ".config", "opencode", "opencode.json"), key: "mcp" },
34541
+ { path: join61(home, ".config", "opencode", "config.json"), key: "mcp" },
34542
+ { path: join61(home, ".opencode", "config.json"), key: "mcp" }
34260
34543
  ];
34261
34544
  default:
34262
34545
  return [];
@@ -34264,14 +34547,14 @@ function mcpJsonCandidates(tool) {
34264
34547
  }
34265
34548
  function readMcpEntry(tool, name) {
34266
34549
  if (tool === "codex")
34267
- return readCodexMcpEntry(join59(homedir22(), ".codex", "config.toml"), name);
34550
+ return readCodexMcpEntry(join61(homedir23(), ".codex", "config.toml"), name);
34268
34551
  if (tool === "hermes")
34269
34552
  return readHermesMcpServers()?.[name] ?? null;
34270
34553
  for (const t of mcpJsonCandidates(tool)) {
34271
- if (!existsSync50(t.path))
34554
+ if (!existsSync51(t.path))
34272
34555
  continue;
34273
34556
  try {
34274
- const cfg = JSON.parse(readFileSync48(t.path, "utf-8"));
34557
+ const cfg = JSON.parse(readFileSync49(t.path, "utf-8"));
34275
34558
  const block = cfg[t.key] || {};
34276
34559
  if (block[name])
34277
34560
  return block[name];
@@ -34281,11 +34564,11 @@ function readMcpEntry(tool, name) {
34281
34564
  return null;
34282
34565
  }
34283
34566
  function readCodexMcpEntry(path, target) {
34284
- if (!existsSync50(path))
34567
+ if (!existsSync51(path))
34285
34568
  return null;
34286
34569
  let content;
34287
34570
  try {
34288
- content = readFileSync48(path, "utf-8");
34571
+ content = readFileSync49(path, "utf-8");
34289
34572
  } catch {
34290
34573
  return null;
34291
34574
  }
@@ -34335,8 +34618,8 @@ function readCodexMcpEntry(path, target) {
34335
34618
  }
34336
34619
  function writeCodexMcpEntry(path, name, entry) {
34337
34620
  let content = "";
34338
- if (existsSync50(path))
34339
- content = readFileSync48(path, "utf-8");
34621
+ if (existsSync51(path))
34622
+ content = readFileSync49(path, "utf-8");
34340
34623
  const header = `[mcp_servers.${name}]`;
34341
34624
  if (content.includes(header))
34342
34625
  return false;
@@ -34365,16 +34648,16 @@ function writeCodexMcpEntry(path, name, entry) {
34365
34648
  for (const [k, v] of Object.entries(entry.env))
34366
34649
  lines.push(`${k} = ${escape(String(v))}`);
34367
34650
  }
34368
- mkdirSync16(dirname23(path), { recursive: true });
34369
- writeFileSync17(path, content + lines.join("\n") + "\n");
34651
+ mkdirSync17(dirname25(path), { recursive: true });
34652
+ writeFileSync18(path, content + lines.join("\n") + "\n");
34370
34653
  return true;
34371
34654
  }
34372
34655
  function writeMcpEntry(toTool, name, entry) {
34373
34656
  if (toTool === "hermes")
34374
34657
  return writeHermesMcp(name, entry);
34375
- const home = homedir22();
34658
+ const home = homedir23();
34376
34659
  if (toTool === "codex") {
34377
- const path2 = join59(home, ".codex", "config.toml");
34660
+ const path2 = join61(home, ".codex", "config.toml");
34378
34661
  if (!writeCodexMcpEntry(path2, name, entry))
34379
34662
  return { ok: false, status: 409, error: `MCP "${name}" already exists in ${path2}.` };
34380
34663
  return { ok: true, targetPath: path2 };
@@ -34382,30 +34665,30 @@ function writeMcpEntry(toTool, name, entry) {
34382
34665
  let path;
34383
34666
  let key2;
34384
34667
  if (toTool === "claude") {
34385
- path = join59(home, ".mcp.json");
34668
+ path = join61(home, ".mcp.json");
34386
34669
  key2 = "mcpServers";
34387
34670
  } else if (toTool === "agy") {
34388
- path = join59(home, ".gemini", "config", "mcp_config.json");
34671
+ path = join61(home, ".gemini", "config", "mcp_config.json");
34389
34672
  key2 = "mcpServers";
34390
34673
  } else if (toTool === "cursor") {
34391
- path = join59(cursorHomeDir(), "mcp.json");
34674
+ path = join61(cursorHomeDir(), "mcp.json");
34392
34675
  key2 = "mcpServers";
34393
34676
  } else if (toTool === "pi") {
34394
34677
  path = piMcpConfigPath();
34395
34678
  key2 = "mcpServers";
34396
34679
  } else {
34397
- path = join59(home, ".config", "opencode", "opencode.json");
34680
+ path = join61(home, ".config", "opencode", "opencode.json");
34398
34681
  key2 = "mcp";
34399
34682
  }
34400
34683
  let cfg = {};
34401
- if (existsSync50(path)) {
34684
+ if (existsSync51(path)) {
34402
34685
  try {
34403
- cfg = JSON.parse(readFileSync48(path, "utf-8"));
34686
+ cfg = JSON.parse(readFileSync49(path, "utf-8"));
34404
34687
  } catch {
34405
34688
  return { ok: false, status: 500, error: `Target config is malformed: ${path}` };
34406
34689
  }
34407
34690
  } else {
34408
- mkdirSync16(dirname23(path), { recursive: true });
34691
+ mkdirSync17(dirname25(path), { recursive: true });
34409
34692
  }
34410
34693
  cfg[key2] = cfg[key2] || {};
34411
34694
  if (cfg[key2][name])
@@ -34432,7 +34715,7 @@ function writeMcpEntry(toTool, name, entry) {
34432
34715
  }
34433
34716
  cfg[key2][name] = normalized;
34434
34717
  try {
34435
- writeFileSync17(path, JSON.stringify(cfg, null, 2));
34718
+ writeFileSync18(path, JSON.stringify(cfg, null, 2));
34436
34719
  return { ok: true, targetPath: path };
34437
34720
  } catch (e) {
34438
34721
  return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
@@ -34462,11 +34745,11 @@ function copyCommandOrAgent(type, row, toTool) {
34462
34745
  return { ok: false, status: 404, error: `Source unreadable: ${e instanceof Error ? e.message : "failed"}` };
34463
34746
  }
34464
34747
  const out = emit(type, art, toTool);
34465
- if (existsSync50(out.path))
34748
+ if (existsSync51(out.path))
34466
34749
  return { ok: false, status: 409, error: `Already exists: ${out.path}` };
34467
34750
  try {
34468
- mkdirSync16(dirname23(out.path), { recursive: true });
34469
- writeFileSync17(out.path, out.content);
34751
+ mkdirSync17(dirname25(out.path), { recursive: true });
34752
+ writeFileSync18(out.path, out.content);
34470
34753
  return { ok: true, targetPath: out.path };
34471
34754
  } catch (e) {
34472
34755
  return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
@@ -34482,11 +34765,11 @@ function copyInstructions(row, toTool) {
34482
34765
  return { ok: false, status: 404, error: `Source unreadable: ${e instanceof Error ? e.message : "failed"}` };
34483
34766
  }
34484
34767
  const out = emit("instructions", art, toTool, row.projectPath || void 0);
34485
- if (existsSync50(out.path))
34768
+ if (existsSync51(out.path))
34486
34769
  return { ok: false, status: 409, error: `Already exists: ${out.path}` };
34487
34770
  try {
34488
- mkdirSync16(dirname23(out.path), { recursive: true });
34489
- writeFileSync17(out.path, out.content);
34771
+ mkdirSync17(dirname25(out.path), { recursive: true });
34772
+ writeFileSync18(out.path, out.content);
34490
34773
  return { ok: true, targetPath: out.path };
34491
34774
  } catch (e) {
34492
34775
  return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
@@ -34496,14 +34779,14 @@ function writeHermesMcp(name, entry) {
34496
34779
  if (!entry?.command && !entry?.url)
34497
34780
  return { ok: false, status: 400, error: `MCP "${name}" has no command or url to write.` };
34498
34781
  const path = hermesConfigPath();
34499
- if (!existsSync50(path))
34782
+ if (!existsSync51(path))
34500
34783
  return { ok: false, status: 404, error: `${path} not found` };
34501
34784
  try {
34502
- const after = addHermesMcpServer(readFileSync48(path, "utf-8"), name, hermesServerEntry(entry));
34785
+ const after = addHermesMcpServer(readFileSync49(path, "utf-8"), name, hermesServerEntry(entry));
34503
34786
  if (after === null)
34504
34787
  return { ok: false, status: 409, error: `MCP "${name}" already exists in ${path}` };
34505
34788
  const backupPaths = [backupToTrash(path, `mcp-hermes-${name}-config.yaml`)];
34506
- writeFileSync17(path, after);
34789
+ writeFileSync18(path, after);
34507
34790
  return { ok: true, targetPath: path, backupPaths };
34508
34791
  } catch (e) {
34509
34792
  return removeFailed(e, "write failed");
@@ -34538,8 +34821,8 @@ async function removeArtifactFromTool(type, name, tool) {
34538
34821
  return removeCommandOrAgent(type, name, tool);
34539
34822
  }
34540
34823
  function backupToTrash(src, label) {
34541
- const dest = join59(getDataDir(), "trash", `${Date.now()}-${label.replace(/[^A-Za-z0-9._-]/g, "_")}`);
34542
- mkdirSync16(dirname23(dest), { recursive: true });
34824
+ const dest = join61(getDataDir(), "trash", `${Date.now()}-${label.replace(/[^A-Za-z0-9._-]/g, "_")}`);
34825
+ mkdirSync17(dirname25(dest), { recursive: true });
34543
34826
  cpSync2(src, dest, { recursive: true });
34544
34827
  return dest;
34545
34828
  }
@@ -34549,7 +34832,7 @@ function removeFailed(e, fallback) {
34549
34832
  function removeSkill(name, tool) {
34550
34833
  const found = skillDirsNamed(tool, name);
34551
34834
  if (found.length === 0)
34552
- return { ok: false, status: 404, error: `Not found: ${join59(skillsDirFor(tool), name)}` };
34835
+ return { ok: false, status: 404, error: `Not found: ${join61(skillsDirFor(tool), name)}` };
34553
34836
  if (found.length > 1)
34554
34837
  return { ok: false, status: 409, error: `${found.length} skills named "${name}" for ${tool}; none removed` };
34555
34838
  const dir = found[0];
@@ -34570,7 +34853,7 @@ async function removeCommandOrAgent(type, name, tool) {
34570
34853
  const [row] = rows;
34571
34854
  if (row.readonly)
34572
34855
  return { ok: false, status: 400, error: "Artifact is read-only (system/bundled)." };
34573
- if (!row.filePath || !existsSync50(row.filePath))
34856
+ if (!row.filePath || !existsSync51(row.filePath))
34574
34857
  return { ok: false, status: 404, error: "Source has no file on disk" };
34575
34858
  try {
34576
34859
  const backupPaths = [backupToTrash(row.filePath, `${type}-${tool}-${name}`)];
@@ -34583,30 +34866,30 @@ async function removeCommandOrAgent(type, name, tool) {
34583
34866
  function removeMcp(name, tool) {
34584
34867
  if (tool === "hermes") {
34585
34868
  const path = hermesConfigPath();
34586
- if (!existsSync50(path))
34869
+ if (!existsSync51(path))
34587
34870
  return { ok: false, status: 404, error: `${path} not found` };
34588
34871
  try {
34589
- const after = deleteHermesMcpServer(readFileSync48(path, "utf-8"), name);
34872
+ const after = deleteHermesMcpServer(readFileSync49(path, "utf-8"), name);
34590
34873
  if (after === null)
34591
34874
  return { ok: false, status: 404, error: `MCP "${name}" not found in ${path}` };
34592
34875
  const backupPaths2 = [backupToTrash(path, `mcp-hermes-${name}-config.yaml`)];
34593
- writeFileSync17(path, after);
34876
+ writeFileSync18(path, after);
34594
34877
  return { ok: true, targetPath: path, backupPaths: backupPaths2 };
34595
34878
  } catch (e) {
34596
34879
  return removeFailed(e, "write failed");
34597
34880
  }
34598
34881
  }
34599
34882
  if (tool === "codex") {
34600
- const path = join59(homedir22(), ".codex", "config.toml");
34601
- if (!existsSync50(path))
34883
+ const path = join61(homedir23(), ".codex", "config.toml");
34884
+ if (!existsSync51(path))
34602
34885
  return { ok: false, status: 404, error: "config.toml not found" };
34603
- const before = readFileSync48(path, "utf-8");
34886
+ const before = readFileSync49(path, "utf-8");
34604
34887
  const after = stripCodexMcpBlock(before, name);
34605
34888
  if (before === after)
34606
34889
  return { ok: false, status: 404, error: `MCP "${name}" not found in ${path}` };
34607
34890
  try {
34608
34891
  const backupPaths2 = [backupToTrash(path, `mcp-codex-${name}`)];
34609
- writeFileSync17(path, after);
34892
+ writeFileSync18(path, after);
34610
34893
  return { ok: true, targetPath: path, backupPaths: backupPaths2 };
34611
34894
  } catch (e) {
34612
34895
  return removeFailed(e, "write failed");
@@ -34615,15 +34898,15 @@ function removeMcp(name, tool) {
34615
34898
  let removedFrom;
34616
34899
  const backupPaths = [];
34617
34900
  for (const c of mcpJsonCandidates(tool)) {
34618
- if (!existsSync50(c.path))
34901
+ if (!existsSync51(c.path))
34619
34902
  continue;
34620
34903
  try {
34621
- const cfg = JSON.parse(readFileSync48(c.path, "utf-8"));
34904
+ const cfg = JSON.parse(readFileSync49(c.path, "utf-8"));
34622
34905
  if (!cfg[c.key]?.[name])
34623
34906
  continue;
34624
34907
  backupPaths.push(backupToTrash(c.path, `mcp-${tool}-${name}-${basename25(c.path)}`));
34625
34908
  delete cfg[c.key][name];
34626
- writeFileSync17(c.path, JSON.stringify(cfg, null, 2));
34909
+ writeFileSync18(c.path, JSON.stringify(cfg, null, 2));
34627
34910
  if (!removedFrom)
34628
34911
  removedFrom = c.path;
34629
34912
  } catch (e) {
@@ -34780,8 +35063,8 @@ __export(toolkit_pull_exports, {
34780
35063
  platformRefusal: () => platformRefusal,
34781
35064
  portableCommand: () => portableCommand
34782
35065
  });
34783
- import { existsSync as existsSync51, mkdirSync as mkdirSync17, statSync as statSync45, writeFileSync as writeFileSync18 } from "node:fs";
34784
- import { dirname as dirname24, join as join60, basename as basename26, isAbsolute as isAbsolute4 } from "node:path";
35066
+ import { existsSync as existsSync52, mkdirSync as mkdirSync18, statSync as statSync45, writeFileSync as writeFileSync19 } from "node:fs";
35067
+ import { dirname as dirname26, join as join62, basename as basename26, isAbsolute as isAbsolute4 } from "node:path";
34785
35068
  function isExecutableFile(p) {
34786
35069
  try {
34787
35070
  return statSync45(p).isFile();
@@ -34951,9 +35234,9 @@ function executePull(rows, opts = {}) {
34951
35234
  const outcomes = [];
34952
35235
  for (const { name, body: body2, truncated, redacted, tools } of skills) {
34953
35236
  for (const tool of tools) {
34954
- const dir = join60(skillsDirFor(tool), name);
34955
- const file = join60(dir, "SKILL.md");
34956
- if (existsSync51(file)) {
35237
+ const dir = join62(skillsDirFor(tool), name);
35238
+ const file = join62(dir, "SKILL.md");
35239
+ if (existsSync52(file)) {
34957
35240
  outcomes.push({ type: "skill", name, tool, status: "present" });
34958
35241
  continue;
34959
35242
  }
@@ -34966,8 +35249,8 @@ function executePull(rows, opts = {}) {
34966
35249
  continue;
34967
35250
  }
34968
35251
  try {
34969
- mkdirSync17(dir, { recursive: true });
34970
- writeFileSync18(file, body2);
35252
+ mkdirSync18(dir, { recursive: true });
35253
+ writeFileSync19(file, body2);
34971
35254
  outcomes.push({ type: "skill", name, tool, status: "written", path: file, redactedContent: redacted });
34972
35255
  } catch (e) {
34973
35256
  outcomes.push({ type: "skill", name, tool, status: "failed", reason: e instanceof Error ? e.message : "write failed" });
@@ -34998,7 +35281,7 @@ function executePull(rows, opts = {}) {
34998
35281
  outcomes.push({ type, name, tool, status: "failed", reason: e instanceof Error ? e.message : "emit failed" });
34999
35282
  continue;
35000
35283
  }
35001
- if (existsSync51(out.path)) {
35284
+ if (existsSync52(out.path)) {
35002
35285
  outcomes.push({ type, name, tool, status: "present" });
35003
35286
  continue;
35004
35287
  }
@@ -35007,8 +35290,8 @@ function executePull(rows, opts = {}) {
35007
35290
  continue;
35008
35291
  }
35009
35292
  try {
35010
- mkdirSync17(dirname24(out.path), { recursive: true });
35011
- writeFileSync18(out.path, out.content);
35293
+ mkdirSync18(dirname26(out.path), { recursive: true });
35294
+ writeFileSync19(out.path, out.content);
35012
35295
  outcomes.push({ type, name, tool, status: "written", path: out.path, redactedContent: redacted });
35013
35296
  } catch (e) {
35014
35297
  outcomes.push({ type, name, tool, status: "failed", reason: e instanceof Error ? e.message : "write failed" });
@@ -35168,8 +35451,8 @@ __export(board_hooks_exports, {
35168
35451
  resolveCliEntry: () => resolveCliEntry,
35169
35452
  resolveMessageHookEntry: () => resolveMessageHookEntry
35170
35453
  });
35171
- import { existsSync as existsSync52 } from "node:fs";
35172
- import { join as join61 } from "node:path";
35454
+ import { existsSync as existsSync53 } from "node:fs";
35455
+ import { join as join63 } from "node:path";
35173
35456
  function entryCommand(entry) {
35174
35457
  const cmd = entry?.hooks?.[0]?.command;
35175
35458
  return typeof cmd === "string" ? cmd : null;
@@ -35215,12 +35498,12 @@ function messageHookEntries(execPath, hookEntry) {
35215
35498
  ];
35216
35499
  }
35217
35500
  function resolveCliEntry(distDir) {
35218
- const bundled = join61(distDir, "cli.js");
35219
- return existsSync52(bundled) ? bundled : join61(distDir, "cli.ts");
35501
+ const bundled = join63(distDir, "cli.js");
35502
+ return existsSync53(bundled) ? bundled : join63(distDir, "cli.ts");
35220
35503
  }
35221
35504
  function resolveMessageHookEntry(distDir) {
35222
- const bundled = join61(distDir, "message-hook.js");
35223
- return existsSync52(bundled) ? bundled : join61(distDir, "message-hook.ts");
35505
+ const bundled = join63(distDir, "message-hook.js");
35506
+ return existsSync53(bundled) ? bundled : join63(distDir, "message-hook.ts");
35224
35507
  }
35225
35508
  var HOOK_TIMEOUT_SECONDS, BOARD_HOOKS, MESSAGE_HOOK_EVENTS, MESSAGE_WAITER_EVENTS, MESSAGE_WAITER_TIMEOUT_SECONDS;
35226
35509
  var init_board_hooks = __esm({
@@ -35252,8 +35535,8 @@ __export(install_hooks_exports, {
35252
35535
  removeOurEntries: () => removeOurEntries,
35253
35536
  uninstallHooks: () => uninstallHooks
35254
35537
  });
35255
- import { chmodSync as chmodSync6, copyFileSync as copyFileSync3, existsSync as existsSync53, mkdirSync as mkdirSync18, readFileSync as readFileSync49, realpathSync as realpathSync6, renameSync as renameSync7, rmSync as rmSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync19 } from "node:fs";
35256
- import { dirname as dirname25, join as join62 } from "node:path";
35538
+ import { chmodSync as chmodSync7, copyFileSync as copyFileSync4, existsSync as existsSync54, mkdirSync as mkdirSync19, readFileSync as readFileSync50, realpathSync as realpathSync6, renameSync as renameSync8, rmSync as rmSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync20 } from "node:fs";
35539
+ import { dirname as dirname27, join as join64 } from "node:path";
35257
35540
  function isOurEntry(entry) {
35258
35541
  const cmd = entry?.hooks?.[0]?.command;
35259
35542
  if (typeof cmd !== "string") return false;
@@ -35267,8 +35550,8 @@ function claudeSettingsFiles() {
35267
35550
  const out = [];
35268
35551
  const seen = /* @__PURE__ */ new Set();
35269
35552
  for (const home of claudeHomeDirs()) {
35270
- if (!existsSync53(join62(home, "projects"))) continue;
35271
- const file = join62(home, "settings.json");
35553
+ if (!existsSync54(join64(home, "projects"))) continue;
35554
+ const file = join64(home, "settings.json");
35272
35555
  let key2;
35273
35556
  try {
35274
35557
  key2 = realpathSync6(file);
@@ -35284,10 +35567,10 @@ function claudeSettingsFiles() {
35284
35567
  }
35285
35568
  function findScript(distDir, name) {
35286
35569
  return [
35287
- join62(distDir, "..", "hooks", name),
35288
- join62(distDir, "..", "..", "hooks", name),
35289
- join62(distDir, "..", "..", "..", "hooks", name)
35290
- ].find((p) => existsSync53(p));
35570
+ join64(distDir, "..", "hooks", name),
35571
+ join64(distDir, "..", "..", "hooks", name),
35572
+ join64(distDir, "..", "..", "..", "hooks", name)
35573
+ ].find((p) => existsSync54(p));
35291
35574
  }
35292
35575
  function hookEntries(sel, paths) {
35293
35576
  const cmd = (command, extra = {}) => [{ type: "command", command, timeout: HOOK_TIMEOUT_SECONDS, ...extra }];
@@ -35327,9 +35610,9 @@ function removeOurEntries(config2) {
35327
35610
  return removed;
35328
35611
  }
35329
35612
  function readJson4(file) {
35330
- if (!existsSync53(file)) return {};
35613
+ if (!existsSync54(file)) return {};
35331
35614
  try {
35332
- const v = JSON.parse(readFileSync49(file, "utf-8"));
35615
+ const v = JSON.parse(readFileSync50(file, "utf-8"));
35333
35616
  return v && typeof v === "object" && !Array.isArray(v) ? v : null;
35334
35617
  } catch {
35335
35618
  return null;
@@ -35341,34 +35624,34 @@ function writeJsonAtomic(file, value) {
35341
35624
  target = realpathSync6(file);
35342
35625
  } catch {
35343
35626
  }
35344
- mkdirSync18(dirname25(target), { recursive: true });
35627
+ mkdirSync19(dirname27(target), { recursive: true });
35345
35628
  const tmp = `${target}.chat-recall-${process.pid}.tmp`;
35346
- writeFileSync19(tmp, JSON.stringify(value, null, 2) + "\n");
35347
- renameSync7(tmp, target);
35629
+ writeFileSync20(tmp, JSON.stringify(value, null, 2) + "\n");
35630
+ renameSync8(tmp, target);
35348
35631
  }
35349
35632
  function statePath() {
35350
- return join62(getHooksDir(), "install.json");
35633
+ return join64(getHooksDir(), "install.json");
35351
35634
  }
35352
35635
  function readState() {
35353
35636
  try {
35354
- return JSON.parse(readFileSync49(statePath(), "utf-8"));
35637
+ return JSON.parse(readFileSync50(statePath(), "utf-8"));
35355
35638
  } catch {
35356
35639
  return null;
35357
35640
  }
35358
35641
  }
35359
- async function installHooks(distDir, sel = ALL_HOOKS) {
35642
+ async function installHooks(distDir, sel = ALL_HOOKS, deps = {}) {
35360
35643
  const shellSkipped = process.platform === "win32";
35361
35644
  const scriptsDir = getHooksDir();
35362
- for (const name of LEGACY_SCRIPTS) rmSync10(join62(scriptsDir, name), { force: true });
35645
+ for (const name of LEGACY_SCRIPTS) rmSync10(join64(scriptsDir, name), { force: true });
35363
35646
  const scripts = {};
35364
35647
  if (!shellSkipped) {
35365
35648
  for (const key2 of Object.keys(SCRIPTS)) {
35366
35649
  if (!sel[key2]) continue;
35367
35650
  const source = findScript(distDir, SCRIPTS[key2]);
35368
35651
  if (!source) continue;
35369
- const target = join62(scriptsDir, SCRIPTS[key2]);
35370
- copyFileSync3(source, target);
35371
- chmodSync6(target, 493);
35652
+ const target = join64(scriptsDir, SCRIPTS[key2]);
35653
+ copyFileSync4(source, target);
35654
+ chmodSync7(target, 493);
35372
35655
  scripts[key2] = target;
35373
35656
  }
35374
35657
  }
@@ -35386,7 +35669,9 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
35386
35669
  scriptsDir,
35387
35670
  selection: sel,
35388
35671
  guardTargets: [],
35389
- messageTargets: []
35672
+ messageTargets: [],
35673
+ // One host per machine serves chat-recall to every session, so each client holds a URL.
35674
+ host: installMcpHost(distDir, deps)
35390
35675
  };
35391
35676
  for (const settingsFile of claudeSettingsFiles()) {
35392
35677
  const config2 = readJson4(settingsFile);
@@ -35397,7 +35682,7 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
35397
35682
  mergeOurEntries(config2, entries);
35398
35683
  writeJsonAtomic(settingsFile, config2);
35399
35684
  report.written.push(settingsFile);
35400
- report.migrated += migrateHooksJson(join62(dirname25(settingsFile), "hooks.json"));
35685
+ report.migrated += migrateHooksJson(join64(dirname27(settingsFile), "hooks.json"));
35401
35686
  }
35402
35687
  if (sel.guard && scripts.guard) report.guardTargets = await addGuardToOtherTools(scriptsDir, scripts.guard);
35403
35688
  if (sel.messages && !shellSkipped) {
@@ -35408,7 +35693,7 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
35408
35693
  return report;
35409
35694
  }
35410
35695
  function migrateHooksJson(file) {
35411
- if (!existsSync53(file)) return 0;
35696
+ if (!existsSync54(file)) return 0;
35412
35697
  const config2 = readJson4(file);
35413
35698
  if (!config2) return 0;
35414
35699
  const removed = removeOurEntries(config2);
@@ -35417,11 +35702,11 @@ function migrateHooksJson(file) {
35417
35702
  else writeJsonAtomic(file, config2);
35418
35703
  return removed;
35419
35704
  }
35420
- async function uninstallHooks() {
35421
- const report = { removed: 0, files: [], guardRemoved: [], messagesRemoved: [] };
35705
+ async function uninstallHooks(deps = {}) {
35706
+ const report = { removed: 0, files: [], guardRemoved: [], messagesRemoved: [], hostRemoved: [] };
35422
35707
  for (const settingsFile of claudeSettingsFiles()) {
35423
- for (const file of [settingsFile, join62(dirname25(settingsFile), "hooks.json")]) {
35424
- if (!existsSync53(file)) continue;
35708
+ for (const file of [settingsFile, join64(dirname27(settingsFile), "hooks.json")]) {
35709
+ if (!existsSync54(file)) continue;
35425
35710
  const config2 = readJson4(file);
35426
35711
  if (!config2) continue;
35427
35712
  const removed = removeOurEntries(config2);
@@ -35433,6 +35718,7 @@ async function uninstallHooks() {
35433
35718
  }
35434
35719
  report.guardRemoved = await removeGuardFromOtherTools();
35435
35720
  report.messagesRemoved = await removeMessagesFromOtherTools();
35721
+ report.hostRemoved = removeMcpHost(deps);
35436
35722
  writeJsonAtomic(statePath(), { version: cliVersion(), selection: ALL_HOOKS, uninstalled: true });
35437
35723
  return report;
35438
35724
  }
@@ -35445,26 +35731,26 @@ function profileMissingHooks(settingsFile, sel) {
35445
35731
  if (Object.values(config2.hooks ?? {}).some((list) => Array.isArray(list) && list.some(isLegacyEntry))) return true;
35446
35732
  return false;
35447
35733
  }
35448
- async function ensureHooks(distDir) {
35734
+ async function ensureHooks(distDir, deps = {}) {
35449
35735
  const state2 = readState();
35450
35736
  if (state2?.uninstalled) return null;
35451
35737
  const sel = { ...ALL_HOOKS, ...state2?.selection ?? {} };
35452
35738
  const stale = !state2 || state2.version !== cliVersion();
35453
35739
  if (!stale && !claudeSettingsFiles().some((f) => profileMissingHooks(f, sel))) return null;
35454
- return installHooks(distDir, sel);
35740
+ return installHooks(distDir, sel, deps);
35455
35741
  }
35456
35742
  async function addGuardToOtherTools(scriptsDir, guardScript) {
35457
35743
  const reg = await Promise.resolve().then(() => (init_guard_registration(), guard_registration_exports));
35458
35744
  const out = [];
35459
35745
  removeLegacyAgyGuard(reg);
35460
35746
  for (const target of reg.guardTargets()) {
35461
- if (!existsSync53(target.homeDir)) continue;
35462
- const wrapper = join62(scriptsDir, reg.guardWrapperName(target.tool));
35463
- writeFileSync19(wrapper, reg.guardWrapperSource(target.tool, guardScript));
35464
- chmodSync6(wrapper, 493);
35465
- mkdirSync18(dirname25(target.configPath), { recursive: true });
35747
+ if (!existsSync54(target.homeDir)) continue;
35748
+ const wrapper = join64(scriptsDir, reg.guardWrapperName(target.tool));
35749
+ writeFileSync20(wrapper, reg.guardWrapperSource(target.tool, guardScript));
35750
+ chmodSync7(wrapper, 493);
35751
+ mkdirSync19(dirname27(target.configPath), { recursive: true });
35466
35752
  if (target.tool === "opencode") {
35467
- writeFileSync19(target.configPath, reg.opencodePluginSource(wrapper));
35753
+ writeFileSync20(target.configPath, reg.opencodePluginSource(wrapper));
35468
35754
  } else {
35469
35755
  const merged = reg.registerGuard(target.tool, readJson4(target.configPath) ?? {}, reg.guardCommand(wrapper));
35470
35756
  writeJsonAtomic(target.configPath, merged);
@@ -35478,9 +35764,9 @@ async function removeGuardFromOtherTools() {
35478
35764
  const out = [];
35479
35765
  removeLegacyAgyGuard(reg);
35480
35766
  for (const target of reg.guardTargets()) {
35481
- if (!existsSync53(target.configPath)) continue;
35767
+ if (!existsSync54(target.configPath)) continue;
35482
35768
  if (target.tool === "opencode") {
35483
- if (!readFileSync49(target.configPath, "utf-8").includes("chat-recall install-hooks")) continue;
35769
+ if (!readFileSync50(target.configPath, "utf-8").includes("chat-recall install-hooks")) continue;
35484
35770
  unlinkSync4(target.configPath);
35485
35771
  } else {
35486
35772
  const r = reg.unregisterGuard(target.tool, readJson4(target.configPath) ?? {});
@@ -35493,7 +35779,7 @@ async function removeGuardFromOtherTools() {
35493
35779
  }
35494
35780
  function removeLegacyAgyGuard(reg) {
35495
35781
  const file = reg.legacyAgyHooksFile();
35496
- if (!existsSync53(file)) return;
35782
+ if (!existsSync54(file)) return;
35497
35783
  const r = reg.unregisterGuard("agy", readJson4(file) ?? {});
35498
35784
  if (r.removed) writeJsonAtomic(file, r.config);
35499
35785
  }
@@ -35501,16 +35787,16 @@ async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
35501
35787
  const reg = await Promise.resolve().then(() => (init_message_registration(), message_registration_exports));
35502
35788
  const out = [];
35503
35789
  for (const target of reg.messageTargets()) {
35504
- if (!existsSync53(target.homeDir)) continue;
35505
- const wrapper = join62(scriptsDir, reg.messageWrapperName(target.tool));
35506
- writeFileSync19(wrapper, reg.messageWrapperSource(target.tool, nodePath, hookEntry));
35507
- chmodSync6(wrapper, 493);
35508
- mkdirSync18(dirname25(target.configPath), { recursive: true });
35790
+ if (!existsSync54(target.homeDir)) continue;
35791
+ const wrapper = join64(scriptsDir, reg.messageWrapperName(target.tool));
35792
+ writeFileSync20(wrapper, reg.messageWrapperSource(target.tool, nodePath, hookEntry));
35793
+ chmodSync7(wrapper, 493);
35794
+ mkdirSync19(dirname27(target.configPath), { recursive: true });
35509
35795
  if (target.tool === "opencode") {
35510
- writeFileSync19(target.configPath, reg.opencodeMessagesSource(wrapper));
35511
- const dir = join62(dirname25(target.configPath), reg.OPENCODE_TUI_PACKAGE);
35512
- mkdirSync18(dir, { recursive: true });
35513
- for (const file of reg.opencodeTuiFiles(wrapper)) writeFileSync19(join62(dir, file.name), file.source);
35796
+ writeFileSync20(target.configPath, reg.opencodeMessagesSource(wrapper));
35797
+ const dir = join64(dirname27(target.configPath), reg.OPENCODE_TUI_PACKAGE);
35798
+ mkdirSync19(dir, { recursive: true });
35799
+ for (const file of reg.opencodeTuiFiles(wrapper)) writeFileSync20(join64(dir, file.name), file.source);
35514
35800
  const tui = registerTuiPlugin();
35515
35801
  if (tui.status === "unparseable") {
35516
35802
  out.push({
@@ -35520,7 +35806,7 @@ async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
35520
35806
  });
35521
35807
  }
35522
35808
  } else if (target.tool === "pi") {
35523
- writeFileSync19(target.configPath, reg.piMessagesSource(wrapper));
35809
+ writeFileSync20(target.configPath, reg.piMessagesSource(wrapper));
35524
35810
  } else {
35525
35811
  const config2 = readJson4(target.configPath);
35526
35812
  if (!config2) continue;
@@ -35536,14 +35822,14 @@ async function removeMessagesFromOtherTools() {
35536
35822
  const tui = unregisterTuiPlugin();
35537
35823
  if (tui.removed) out.push({ label: "OpenCode TUI", configPath: tui.path });
35538
35824
  for (const target of reg.messageTargets()) {
35539
- if (!existsSync53(target.configPath)) continue;
35825
+ if (!existsSync54(target.configPath)) continue;
35540
35826
  if (target.tool === "opencode" || target.tool === "pi") {
35541
- if (!reg.isOurPluginSource(readFileSync49(target.configPath, "utf-8"))) continue;
35827
+ if (!reg.isOurPluginSource(readFileSync50(target.configPath, "utf-8"))) continue;
35542
35828
  unlinkSync4(target.configPath);
35543
35829
  if (target.tool === "opencode") {
35544
- const dir = join62(dirname25(target.configPath), reg.OPENCODE_TUI_PACKAGE);
35545
- const tui2 = join62(dir, "tui.js");
35546
- if (existsSync53(tui2) && reg.isOurTuiSource(readFileSync49(tui2, "utf-8"))) rmSync10(dir, { recursive: true, force: true });
35830
+ const dir = join64(dirname27(target.configPath), reg.OPENCODE_TUI_PACKAGE);
35831
+ const tui2 = join64(dir, "tui.js");
35832
+ if (existsSync54(tui2) && reg.isOurTuiSource(readFileSync50(tui2, "utf-8"))) rmSync10(dir, { recursive: true, force: true });
35547
35833
  }
35548
35834
  } else {
35549
35835
  const config2 = readJson4(target.configPath);
@@ -35565,6 +35851,7 @@ var init_install_hooks = __esm({
35565
35851
  init_tool_paths();
35566
35852
  init_board_hooks();
35567
35853
  init_http();
35854
+ init_mcp_host();
35568
35855
  init_opencode_tui_config();
35569
35856
  ALL_HOOKS = {
35570
35857
  resume: true,
@@ -36028,14 +36315,14 @@ var verify_repair_exports = {};
36028
36315
  __export(verify_repair_exports, {
36029
36316
  forceFullResync: () => forceFullResync
36030
36317
  });
36031
- import { copyFileSync as copyFileSync4, existsSync as existsSync54 } from "fs";
36318
+ import { copyFileSync as copyFileSync5, existsSync as existsSync55 } from "fs";
36032
36319
  function forceFullResync(server, sessionIds) {
36033
36320
  if (sessionIds.length === 0) return 0;
36034
36321
  const path = ledgerFilePath();
36035
- if (existsSync54(path)) {
36322
+ if (existsSync55(path)) {
36036
36323
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "").replace(/-/g, "");
36037
36324
  try {
36038
- copyFileSync4(path, `${path}.bak-${stamp}`);
36325
+ copyFileSync5(path, `${path}.bak-${stamp}`);
36039
36326
  } catch {
36040
36327
  }
36041
36328
  }
@@ -36222,8 +36509,8 @@ __export(collector_exports, {
36222
36509
  });
36223
36510
  import { spawn as spawn4 } from "node:child_process";
36224
36511
  import { execSync as execSync4 } from "node:child_process";
36225
- import { readFileSync as readFileSync50 } from "node:fs";
36226
- import { join as join63, basename as basename28 } from "node:path";
36512
+ import { readFileSync as readFileSync51 } from "node:fs";
36513
+ import { join as join65, basename as basename28 } from "node:path";
36227
36514
  async function resolveCodeindexBin(autoInstall = true) {
36228
36515
  let st = checkCodeindexStatus();
36229
36516
  if (!st.installed && autoInstall)
@@ -36405,7 +36692,7 @@ async function collectCode(opts) {
36405
36692
  }
36406
36693
  const complexity = (r) => {
36407
36694
  try {
36408
- const txt = readFileSync50(join63(ws, r), "utf8");
36695
+ const txt = readFileSync51(join65(ws, r), "utf8");
36409
36696
  if (txt.length > 2e6)
36410
36697
  return 1;
36411
36698
  const m = txt.match(CF_RE);
@@ -37189,9 +37476,9 @@ __export(project_tasks_exports, {
37189
37476
  pushProjectTaskStatuses: () => pushProjectTaskStatuses,
37190
37477
  renderTeamTasksMd: () => renderTeamTasksMd
37191
37478
  });
37192
- import { existsSync as existsSync55, readFileSync as readFileSync51, writeFileSync as writeFileSync20, mkdirSync as mkdirSync19, statSync as statSync46 } from "node:fs";
37193
- import { join as join64, dirname as dirname26 } from "node:path";
37194
- import { homedir as homedir23 } from "node:os";
37479
+ import { existsSync as existsSync56, readFileSync as readFileSync52, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, statSync as statSync46 } from "node:fs";
37480
+ import { join as join66, dirname as dirname28 } from "node:path";
37481
+ import { homedir as homedir24 } from "node:os";
37195
37482
  function isTeamTaskStatus(v) {
37196
37483
  return !!v && TEAM_STATUSES.has(v);
37197
37484
  }
@@ -37241,22 +37528,22 @@ function parseTaskFile(content) {
37241
37528
  return out;
37242
37529
  }
37243
37530
  function ledgerPath2() {
37244
- return join64(homedir23(), ".chat-recall", "project-tasks-ledger.json");
37531
+ return join66(homedir24(), ".chat-recall", "project-tasks-ledger.json");
37245
37532
  }
37246
37533
  function readLedger() {
37247
37534
  try {
37248
- return JSON.parse(readFileSync51(ledgerPath2(), "utf8"));
37535
+ return JSON.parse(readFileSync52(ledgerPath2(), "utf8"));
37249
37536
  } catch {
37250
37537
  return {};
37251
37538
  }
37252
37539
  }
37253
37540
  function writeLedger(l) {
37254
37541
  try {
37255
- mkdirSync19(dirname26(ledgerPath2()), { recursive: true });
37542
+ mkdirSync20(dirname28(ledgerPath2()), { recursive: true });
37256
37543
  } catch {
37257
37544
  }
37258
37545
  try {
37259
- writeFileSync20(ledgerPath2(), JSON.stringify(l));
37546
+ writeFileSync21(ledgerPath2(), JSON.stringify(l));
37260
37547
  } catch {
37261
37548
  }
37262
37549
  }
@@ -37274,8 +37561,8 @@ async function pushProjectTaskStatuses(base4, authHeaders, opts = {}) {
37274
37561
  continue;
37275
37562
  }
37276
37563
  for (const project of projects) {
37277
- const file = join64(project, fk.filename);
37278
- if (!existsSync55(file)) continue;
37564
+ const file = join66(project, fk.filename);
37565
+ if (!existsSync56(file)) continue;
37279
37566
  let mtime;
37280
37567
  try {
37281
37568
  mtime = statSync46(file).mtimeMs;
@@ -37285,7 +37572,7 @@ async function pushProjectTaskStatuses(base4, authHeaders, opts = {}) {
37285
37572
  if (ledger[file] === mtime) continue;
37286
37573
  let changed;
37287
37574
  try {
37288
- changed = parseTaskFile(readFileSync51(file, "utf8")).filter((t) => t.kind === fk.kind);
37575
+ changed = parseTaskFile(readFileSync52(file, "utf8")).filter((t) => t.kind === fk.kind);
37289
37576
  } catch {
37290
37577
  continue;
37291
37578
  }
@@ -37358,10 +37645,10 @@ __export(intent_drain_exports, {
37358
37645
  instructionTargets: () => instructionTargets,
37359
37646
  runIntent: () => runIntent
37360
37647
  });
37361
- import { existsSync as existsSync56, readFileSync as readFileSync52, writeFileSync as writeFileSync21, appendFileSync, mkdirSync as mkdirSync20 } from "node:fs";
37362
- import { join as join65 } from "node:path";
37648
+ import { existsSync as existsSync57, readFileSync as readFileSync53, writeFileSync as writeFileSync22, appendFileSync, mkdirSync as mkdirSync21 } from "node:fs";
37649
+ import { join as join67 } from "node:path";
37363
37650
  import { fileURLToPath as fileURLToPath4 } from "node:url";
37364
- import { dirname as dirname27 } from "node:path";
37651
+ import { dirname as dirname29 } from "node:path";
37365
37652
  function instructionTargets(rootPath, isGlobal) {
37366
37653
  const installed = INSTRUCTION_TOOLS.filter((t) => {
37367
37654
  try {
@@ -37373,17 +37660,17 @@ function instructionTargets(rootPath, isGlobal) {
37373
37660
  const tools = installed.length ? installed : [INSTRUCTION_TOOLS[0]];
37374
37661
  if (isGlobal) return [...new Set(tools.map((t) => instructionsPath(t.id)))];
37375
37662
  if (!rootPath) return [];
37376
- const present = INSTRUCTION_FILENAMES.map((f) => join65(rootPath, f)).filter((p) => existsSync56(p));
37663
+ const present = INSTRUCTION_FILENAMES.map((f) => join67(rootPath, f)).filter((p) => existsSync57(p));
37377
37664
  if (present.length) return present;
37378
- return [...new Set(tools.map((t) => join65(rootPath, instructionsFilename(t.id))))];
37665
+ return [...new Set(tools.map((t) => join67(rootPath, instructionsFilename(t.id))))];
37379
37666
  }
37380
37667
  function applyCodeRecommendation(intent) {
37381
37668
  try {
37382
37669
  const meta = JSON.parse(intent.name || "{}");
37383
37670
  if (intent.artifact_type === "write_tasks_file") {
37384
37671
  if (!meta.rootPath || !meta.content) return { status: "error", result: JSON.stringify({ error: "missing rootPath or content" }) };
37385
- const file = join65(meta.rootPath, meta.filename || "CODE_TASKS.md");
37386
- writeFileSync21(file, meta.content);
37672
+ const file = join67(meta.rootPath, meta.filename || "CODE_TASKS.md");
37673
+ writeFileSync22(file, meta.content);
37387
37674
  return { status: "done", result: JSON.stringify({ wrote: file }) };
37388
37675
  }
37389
37676
  if (intent.artifact_type === "append_claude_md") {
@@ -37398,10 +37685,10 @@ function applyCodeRecommendation(intent) {
37398
37685
  for (const file of targets) {
37399
37686
  const dir = file.slice(0, file.lastIndexOf("/"));
37400
37687
  try {
37401
- mkdirSync20(dir, { recursive: true });
37688
+ mkdirSync21(dir, { recursive: true });
37402
37689
  } catch {
37403
37690
  }
37404
- const existing = existsSync56(file) ? readFileSync52(file, "utf8") : "";
37691
+ const existing = existsSync57(file) ? readFileSync53(file, "utf8") : "";
37405
37692
  if (existing.includes(text)) {
37406
37693
  skipped.push(file);
37407
37694
  continue;
@@ -37411,7 +37698,7 @@ function applyCodeRecommendation(intent) {
37411
37698
  ${text}
37412
37699
  `;
37413
37700
  if (existing) appendFileSync(file, block);
37414
- else writeFileSync21(file, `# ${meta.rootPath?.split("/").pop() || "Global"} instructions
37701
+ else writeFileSync22(file, `# ${meta.rootPath?.split("/").pop() || "Global"} instructions
37415
37702
  ${block}`);
37416
37703
  appended.push(file);
37417
37704
  }
@@ -37586,11 +37873,11 @@ var init_intent_drain = __esm({
37586
37873
  ];
37587
37874
  ownVersion2 = "0.0.0";
37588
37875
  try {
37589
- const dir = dirname27(fileURLToPath4(import.meta.url));
37590
- ownVersion2 = JSON.parse(readFileSync52(join65(dir, "../package.json"), "utf-8")).version || ownVersion2;
37876
+ const dir = dirname29(fileURLToPath4(import.meta.url));
37877
+ ownVersion2 = JSON.parse(readFileSync53(join67(dir, "../package.json"), "utf-8")).version || ownVersion2;
37591
37878
  } catch {
37592
37879
  try {
37593
- if (true) ownVersion2 = "0.7.39";
37880
+ if (typeof __CLI_VERSION__ === "string") ownVersion2 = __CLI_VERSION__;
37594
37881
  } catch {
37595
37882
  }
37596
37883
  }
@@ -37791,48 +38078,48 @@ var team_merge_exports = {};
37791
38078
  __export(team_merge_exports, {
37792
38079
  mergePullResult: () => mergePullResult
37793
38080
  });
37794
- import { existsSync as existsSync57, mkdirSync as mkdirSync21, readFileSync as readFileSync53, rmSync as rmSync11, writeFileSync as writeFileSync22, statSync as statSync47 } from "fs";
37795
- import { dirname as dirname28, join as join66 } from "path";
38081
+ import { existsSync as existsSync58, mkdirSync as mkdirSync22, readFileSync as readFileSync54, rmSync as rmSync11, writeFileSync as writeFileSync23, statSync as statSync47 } from "fs";
38082
+ import { dirname as dirname30, join as join68 } from "path";
37796
38083
  import { createHash as createHash17 } from "crypto";
37797
38084
  function installPathFor(art, tool) {
37798
38085
  switch (art.type) {
37799
38086
  case "skill":
37800
38087
  switch (tool) {
37801
38088
  case "claude":
37802
- return join66(claudeBackend.skillsDir(), art.name, "SKILL.md");
38089
+ return join68(claudeBackend.skillsDir(), art.name, "SKILL.md");
37803
38090
  // Antigravity's OWN skills dir. It used to resolve to the shared
37804
38091
  // ~/.gemini/skills while toolkit-sync installed to
37805
38092
  // ~/.gemini/antigravity-cli/skills, so a team skill landed in one place
37806
38093
  // and a synced skill in the other.
37807
38094
  case "agy":
37808
- return join66(agyBackend.homeDir(), "skills", art.name, "SKILL.md");
38095
+ return join68(agyBackend.homeDir(), "skills", art.name, "SKILL.md");
37809
38096
  case "opencode":
37810
- return join66(opencodeBackend.skillsDir(), art.name, "SKILL.md");
38097
+ return join68(opencodeBackend.skillsDir(), art.name, "SKILL.md");
37811
38098
  // User skills go to ~/.codex/skills (NOT .system, which is OpenAI's bundle).
37812
38099
  case "codex":
37813
- return join66(codexBackend.skillsDir(), art.name, "SKILL.md");
38100
+ return join68(codexBackend.skillsDir(), art.name, "SKILL.md");
37814
38101
  case "cursor":
37815
- return join66(cursorHomeDir(), "skills", art.name, "SKILL.md");
38102
+ return join68(cursorHomeDir(), "skills", art.name, "SKILL.md");
37816
38103
  }
37817
38104
  break;
37818
38105
  case "agent":
37819
38106
  if (tool === "claude")
37820
- return join66(claudeBackend.agentsDir(), `${art.name}.md`);
38107
+ return join68(claudeBackend.agentsDir(), `${art.name}.md`);
37821
38108
  return null;
37822
38109
  case "command":
37823
38110
  if (tool === "claude")
37824
- return join66(claudeBackend.commandsDir(), `${art.name}.md`);
38111
+ return join68(claudeBackend.commandsDir(), `${art.name}.md`);
37825
38112
  return null;
37826
38113
  case "hook":
37827
38114
  if (tool === "claude")
37828
- return join66(claudeBackend.homeDir(), "chat-recall-hooks", `${art.name}.json`);
38115
+ return join68(claudeBackend.homeDir(), "chat-recall-hooks", `${art.name}.json`);
37829
38116
  return null;
37830
38117
  case "plan":
37831
38118
  switch (tool) {
37832
38119
  case "claude":
37833
- return join66(claudeBackend.plansDir(), `${art.name}.md`);
38120
+ return join68(claudeBackend.plansDir(), `${art.name}.md`);
37834
38121
  case "opencode":
37835
- return join66(opencodeBackend.plansDir(), `${art.name}.md`);
38122
+ return join68(opencodeBackend.plansDir(), `${art.name}.md`);
37836
38123
  case "agy":
37837
38124
  return null;
37838
38125
  // Antigravity plans live per-session
@@ -37843,11 +38130,11 @@ function installPathFor(art, tool) {
37843
38130
  }
37844
38131
  break;
37845
38132
  case "instructions":
37846
- return join66(getDataDir(), "team-instructions", tool, `${art.name}.md`);
38133
+ return join68(getDataDir(), "team-instructions", tool, `${art.name}.md`);
37847
38134
  case "mcp":
37848
- return join66(getDataDir(), "team-mcps", `${art.name}.json`);
38135
+ return join68(getDataDir(), "team-mcps", `${art.name}.json`);
37849
38136
  case "plugin":
37850
- return join66(getDataDir(), "team-plugins", tool, art.name, "manifest.json");
38137
+ return join68(getDataDir(), "team-plugins", tool, art.name, "manifest.json");
37851
38138
  }
37852
38139
  return null;
37853
38140
  }
@@ -37886,8 +38173,8 @@ async function mergePullResult(opts) {
37886
38173
  pending.push({ artifactId: a.id, tool, artifactType: a.type, artifactName: a.name, sha256: sha, installedAt: Date.now() });
37887
38174
  continue;
37888
38175
  }
37889
- mkdirSync21(dirname28(path), { recursive: true });
37890
- writeFileSync22(path, body2);
38176
+ mkdirSync22(dirname30(path), { recursive: true });
38177
+ writeFileSync23(path, body2);
37891
38178
  pending.push({ artifactId: a.id, tool, artifactType: a.type, artifactName: a.name, sha256: sha, installedAt: Date.now() });
37892
38179
  report.written.push({ artifactId: a.id, path });
37893
38180
  } catch (err) {
@@ -37908,7 +38195,7 @@ async function mergePullResult(opts) {
37908
38195
  if (!path)
37909
38196
  continue;
37910
38197
  try {
37911
- if (existsSync57(path))
38198
+ if (existsSync58(path))
37912
38199
  rmSync11(path, { force: true });
37913
38200
  await teamInstallsForget(id, row.tool);
37914
38201
  report.removed.push({ artifactId: id, path });
@@ -37926,12 +38213,12 @@ async function mergePullResult(opts) {
37926
38213
  }
37927
38214
  function readFileIfExists(path) {
37928
38215
  try {
37929
- if (!existsSync57(path))
38216
+ if (!existsSync58(path))
37930
38217
  return null;
37931
38218
  const s = statSync47(path);
37932
38219
  if (!s.isFile())
37933
38220
  return null;
37934
- return readFileSync53(path);
38221
+ return readFileSync54(path);
37935
38222
  } catch {
37936
38223
  return null;
37937
38224
  }
@@ -38012,8 +38299,8 @@ var init_vault_crypto = __esm({
38012
38299
  });
38013
38300
 
38014
38301
  // ../engine/dist/core/vault-source.js
38015
- import { existsSync as existsSync58, readdirSync as readdirSync35, statSync as statSync48 } from "fs";
38016
- import { extname, join as join67 } from "path";
38302
+ import { existsSync as existsSync59, readdirSync as readdirSync35, statSync as statSync48 } from "fs";
38303
+ import { extname, join as join69 } from "path";
38017
38304
  function* walkVaultSources() {
38018
38305
  const t = loadSettings().team.vault;
38019
38306
  const include2 = new Set(t.syncTools);
@@ -38038,7 +38325,7 @@ function safeStat(path) {
38038
38325
  }
38039
38326
  function* walkClaude() {
38040
38327
  const root = claudeBackend.projectsDir();
38041
- if (!existsSync58(root))
38328
+ if (!existsSync59(root))
38042
38329
  return;
38043
38330
  let projectDirs = [];
38044
38331
  try {
@@ -38050,7 +38337,7 @@ function* walkClaude() {
38050
38337
  if (proj.startsWith("."))
38051
38338
  continue;
38052
38339
  const projectPath = resolveProjectDirName(proj);
38053
- const projDir = join67(root, proj);
38340
+ const projDir = join69(root, proj);
38054
38341
  let entries = [];
38055
38342
  try {
38056
38343
  entries = readdirSync35(projDir);
@@ -38060,7 +38347,7 @@ function* walkClaude() {
38060
38347
  for (const f of entries) {
38061
38348
  if (extname(f) !== ".jsonl")
38062
38349
  continue;
38063
- const path = join67(projDir, f);
38350
+ const path = join69(projDir, f);
38064
38351
  const s = safeStat(path);
38065
38352
  if (!s)
38066
38353
  continue;
@@ -38090,8 +38377,8 @@ function* walkCursor() {
38090
38377
  }
38091
38378
  }
38092
38379
  function* walkCodex() {
38093
- const sessionsRoot = join67(codexBackend.homeDir(), "sessions");
38094
- if (!existsSync58(sessionsRoot))
38380
+ const sessionsRoot = join69(codexBackend.homeDir(), "sessions");
38381
+ if (!existsSync59(sessionsRoot))
38095
38382
  return;
38096
38383
  const stack = [sessionsRoot];
38097
38384
  while (stack.length) {
@@ -38103,7 +38390,7 @@ function* walkCodex() {
38103
38390
  continue;
38104
38391
  }
38105
38392
  for (const e of entries) {
38106
- const path = join67(dir, e.name);
38393
+ const path = join69(dir, e.name);
38107
38394
  if (e.isDirectory()) {
38108
38395
  stack.push(path);
38109
38396
  continue;
@@ -38119,8 +38406,8 @@ function* walkCodex() {
38119
38406
  }
38120
38407
  }
38121
38408
  function* walkAgy() {
38122
- const brainDir = join67(agyBackend.homeDir(), "brain");
38123
- if (!existsSync58(brainDir))
38409
+ const brainDir = join69(agyBackend.homeDir(), "brain");
38410
+ if (!existsSync59(brainDir))
38124
38411
  return;
38125
38412
  let sessionDirs = [];
38126
38413
  try {
@@ -38129,18 +38416,18 @@ function* walkAgy() {
38129
38416
  return;
38130
38417
  }
38131
38418
  for (const rawId of sessionDirs) {
38132
- const sessionPath = join67(brainDir, rawId);
38419
+ const sessionPath = join69(brainDir, rawId);
38133
38420
  try {
38134
38421
  if (!statSync48(sessionPath).isDirectory())
38135
38422
  continue;
38136
38423
  } catch {
38137
38424
  continue;
38138
38425
  }
38139
- let filePath = join67(sessionPath, ".system_generated", "logs", "transcript.jsonl");
38140
- if (!existsSync58(filePath)) {
38141
- filePath = join67(sessionPath, ".system_generated", "logs", "transcript_full.jsonl");
38426
+ let filePath = join69(sessionPath, ".system_generated", "logs", "transcript.jsonl");
38427
+ if (!existsSync59(filePath)) {
38428
+ filePath = join69(sessionPath, ".system_generated", "logs", "transcript_full.jsonl");
38142
38429
  }
38143
- if (!existsSync58(filePath))
38430
+ if (!existsSync59(filePath))
38144
38431
  continue;
38145
38432
  const s = safeStat(filePath);
38146
38433
  if (!s)
@@ -38176,8 +38463,8 @@ __export(vault_client_exports, {
38176
38463
  vaultStatus: () => vaultStatus,
38177
38464
  vaultSync: () => vaultSync
38178
38465
  });
38179
- import { mkdirSync as mkdirSync22, readFileSync as readFileSync54, writeFileSync as writeFileSync23, existsSync as existsSync59 } from "fs";
38180
- import { dirname as dirname29, join as join68 } from "path";
38466
+ import { mkdirSync as mkdirSync23, readFileSync as readFileSync55, writeFileSync as writeFileSync24, existsSync as existsSync60 } from "fs";
38467
+ import { dirname as dirname31, join as join70 } from "path";
38181
38468
  function context2() {
38182
38469
  const s = loadSettings().team;
38183
38470
  if (!s.enabled)
@@ -38316,7 +38603,7 @@ async function vaultSync(passphrase) {
38316
38603
  continue;
38317
38604
  }
38318
38605
  try {
38319
- const plaintext = readFileSync54(src.path);
38606
+ const plaintext = readFileSync55(src.path);
38320
38607
  const sourceSha = sha256Hex(plaintext);
38321
38608
  const priorSha = uploaded.get(uploadKey(src.sessionId, src.tool));
38322
38609
  if (priorSha === sourceSha) {
@@ -38368,7 +38655,7 @@ async function vaultSync(passphrase) {
38368
38655
  }
38369
38656
  function importedPathFor(tool, sessionId) {
38370
38657
  const base4 = sessionId.replace(/^gemini_/, "").replace(/^codex_/, "").replace(/^agy_/, "").replace(/^cursor_/, "").replace(/^opencode_/, "");
38371
- return join68(IMPORTED_ROOT(), tool, `${base4}.jsonl`);
38658
+ return join70(IMPORTED_ROOT(), tool, `${base4}.jsonl`);
38372
38659
  }
38373
38660
  async function vaultRestore(passphrase, opts = {}) {
38374
38661
  const ctx = context2();
@@ -38389,7 +38676,7 @@ async function vaultRestore(passphrase, opts = {}) {
38389
38676
  }
38390
38677
  try {
38391
38678
  const path = importedPathFor(blob.tool, blob.sessionId);
38392
- if (existsSync59(path)) {
38679
+ if (existsSync60(path)) {
38393
38680
  const localStat = await import("fs").then((m) => m.statSync(path));
38394
38681
  if (Math.abs(localStat.mtimeMs - blob.mtimeSourceMs) < 1) {
38395
38682
  report.skipped.push({ sessionId: blob.sessionId, tool: blob.tool, reason: "unchanged" });
@@ -38405,8 +38692,8 @@ async function vaultRestore(passphrase, opts = {}) {
38405
38692
  throw new Error("cipher integrity check failed");
38406
38693
  }
38407
38694
  const plaintext = decryptBlob(key2, cipher);
38408
- mkdirSync22(dirname29(path), { recursive: true });
38409
- writeFileSync23(path, Buffer.from(plaintext));
38695
+ mkdirSync23(dirname31(path), { recursive: true });
38696
+ writeFileSync24(path, Buffer.from(plaintext));
38410
38697
  const { utimesSync } = await import("fs");
38411
38698
  const t = blob.mtimeSourceMs / 1e3;
38412
38699
  utimesSync(path, t, t);
@@ -38457,7 +38744,7 @@ var init_vault_client = __esm({
38457
38744
  uploadKey = (sessionId, tool) => `${sessionId}\0${tool}`;
38458
38745
  VaultPassphraseMismatchError = class extends Error {
38459
38746
  };
38460
- IMPORTED_ROOT = () => join68(getDataDir(), "imported");
38747
+ IMPORTED_ROOT = () => join70(getDataDir(), "imported");
38461
38748
  }
38462
38749
  });
38463
38750
 
@@ -39020,15 +39307,15 @@ __export(service_installer_exports, {
39020
39307
  uninstallService: () => uninstallService
39021
39308
  });
39022
39309
  import { execSync as execSync5 } from "child_process";
39023
- import { existsSync as existsSync60, mkdirSync as mkdirSync23, readFileSync as readFileSync55, rmSync as rmSync12, writeFileSync as writeFileSync24 } from "fs";
39024
- import { homedir as homedir24 } from "os";
39025
- import { join as join69 } from "path";
39310
+ import { existsSync as existsSync61, mkdirSync as mkdirSync24, readFileSync as readFileSync56, rmSync as rmSync12, writeFileSync as writeFileSync25 } from "fs";
39311
+ import { homedir as homedir25 } from "os";
39312
+ import { join as join71 } from "path";
39026
39313
  import { fileURLToPath as fileURLToPath5 } from "url";
39027
39314
  function resolveDaemonPaths() {
39028
39315
  const watchJs = fileURLToPath5(new URL("./watch.js", import.meta.url));
39029
39316
  const node = process.execPath;
39030
- const dataDir = join69(homedir24(), ".chat-recall");
39031
- const logFile = join69(dataDir, "watch.log");
39317
+ const dataDir = join71(homedir25(), ".chat-recall");
39318
+ const logFile = join71(dataDir, "watch.log");
39032
39319
  return { watchJs, node, logFile, dataDir };
39033
39320
  }
39034
39321
  function tryCmd(cmd) {
@@ -39055,13 +39342,13 @@ function refreshServiceDefinition() {
39055
39342
  if (process.platform !== "linux") return false;
39056
39343
  try {
39057
39344
  const { watchJs, node, logFile } = resolveDaemonPaths();
39058
- const unitPath = join69(homedir24(), ".config", "systemd", "user", "chat-recall-watch.service");
39059
- if (!existsSync60(unitPath)) return false;
39060
- const current = readFileSync55(unitPath, "utf8");
39345
+ const unitPath = join71(homedir25(), ".config", "systemd", "user", "chat-recall-watch.service");
39346
+ if (!existsSync61(unitPath)) return false;
39347
+ const current = readFileSync56(unitPath, "utf8");
39061
39348
  if (!current.includes(watchJs)) return false;
39062
39349
  const wanted = renderSystemdUnit(watchJs, node, logFile);
39063
- if (readFileSync55(unitPath, "utf8") === wanted) return false;
39064
- writeFileSync24(unitPath, wanted);
39350
+ if (readFileSync56(unitPath, "utf8") === wanted) return false;
39351
+ writeFileSync25(unitPath, wanted);
39065
39352
  execSync5("systemctl --user daemon-reload", { stdio: "ignore" });
39066
39353
  return true;
39067
39354
  } catch {
@@ -39070,7 +39357,7 @@ function refreshServiceDefinition() {
39070
39357
  }
39071
39358
  function installService() {
39072
39359
  const { watchJs, node, logFile, dataDir } = resolveDaemonPaths();
39073
- mkdirSync23(dataDir, { recursive: true });
39360
+ mkdirSync24(dataDir, { recursive: true });
39074
39361
  if (process.platform === "linux") {
39075
39362
  return installSystemd(watchJs, node, logFile);
39076
39363
  }
@@ -39086,11 +39373,11 @@ function installService() {
39086
39373
  );
39087
39374
  }
39088
39375
  function installSystemd(watchJs, node, logFile) {
39089
- const unitDir = join69(homedir24(), ".config", "systemd", "user");
39090
- const unitPath = join69(unitDir, "chat-recall-watch.service");
39376
+ const unitDir = join71(homedir25(), ".config", "systemd", "user");
39377
+ const unitPath = join71(unitDir, "chat-recall-watch.service");
39091
39378
  const unit = renderSystemdUnit(watchJs, node, logFile);
39092
- mkdirSync23(unitDir, { recursive: true });
39093
- writeFileSync24(unitPath, unit);
39379
+ mkdirSync24(unitDir, { recursive: true });
39380
+ writeFileSync25(unitPath, unit);
39094
39381
  try {
39095
39382
  execSync5("systemctl --user daemon-reload && systemctl --user enable chat-recall-watch.service && systemctl --user restart chat-recall-watch.service", { stdio: "inherit" });
39096
39383
  try {
@@ -39121,7 +39408,7 @@ function renderSystemdUnit(watchJs, node, logFile) {
39121
39408
  // base64 payloads); V8's default old-space on a big-RAM box is ~4GB and
39122
39409
  // GC only gets aggressive near the ceiling — observed as a multi-GB RSS
39123
39410
  // sawtooth. The ceiling below is measured, not guessed: see WATCH_HEAP_MB.
39124
- `ExecStart=${node} --max-old-space-size=${WATCH_HEAP_MB} ${watchJs}`,
39411
+ `ExecStart=${node} --max-old-space-size=${WATCH_HEAP_MB} --expose-gc ${watchJs}`,
39125
39412
  // ALWAYS: the collector never ends its own work, so any exit systemd did
39126
39413
  // not ask for is a fault. Under on-failure a clean exit left it dead: on
39127
39414
  // 2026-09-16 the unit went "inactive (dead) … status=0/SUCCESS" and stayed
@@ -39172,11 +39459,11 @@ function renderSystemdUnit(watchJs, node, logFile) {
39172
39459
  }
39173
39460
  function installLaunchd(watchJs, node, logFile) {
39174
39461
  const label = "com.chat-recall.watch";
39175
- const plistDir = join69(homedir24(), "Library", "LaunchAgents");
39176
- const plistPath = join69(plistDir, `${label}.plist`);
39462
+ const plistDir = join71(homedir25(), "Library", "LaunchAgents");
39463
+ const plistPath = join71(plistDir, `${label}.plist`);
39177
39464
  const plist = renderLaunchdPlist(watchJs, node, logFile, label);
39178
- mkdirSync23(plistDir, { recursive: true });
39179
- writeFileSync24(plistPath, plist);
39465
+ mkdirSync24(plistDir, { recursive: true });
39466
+ writeFileSync25(plistPath, plist);
39180
39467
  try {
39181
39468
  try {
39182
39469
  execSync5(`launchctl unload "${plistPath}"`, { stdio: "ignore" });
@@ -39194,7 +39481,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
39194
39481
  '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
39195
39482
  '<plist version="1.0"><dict>',
39196
39483
  ` <key>Label</key><string>${label}</string>`,
39197
- ` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size=${WATCH_HEAP_MB}</string><string>${watchJs}</string></array>`,
39484
+ ` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size=${WATCH_HEAP_MB}</string><string>--expose-gc</string><string>${watchJs}</string></array>`,
39198
39485
  " <key>RunAtLoad</key><true/>",
39199
39486
  " <key>KeepAlive</key><true/>",
39200
39487
  ` <key>StandardOutPath</key><string>${logFile}</string>`,
@@ -39229,8 +39516,8 @@ function uninstallService() {
39229
39516
  removed = true;
39230
39517
  } catch {
39231
39518
  }
39232
- const unitPath = join69(homedir24(), ".config", "systemd", "user", "chat-recall-watch.service");
39233
- if (existsSync60(unitPath)) {
39519
+ const unitPath = join71(homedir25(), ".config", "systemd", "user", "chat-recall-watch.service");
39520
+ if (existsSync61(unitPath)) {
39234
39521
  rmSync12(unitPath, { force: true });
39235
39522
  removed = true;
39236
39523
  }
@@ -39241,13 +39528,13 @@ function uninstallService() {
39241
39528
  return removed;
39242
39529
  }
39243
39530
  if (process.platform === "darwin") {
39244
- const plistPath = join69(homedir24(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
39531
+ const plistPath = join71(homedir25(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
39245
39532
  try {
39246
39533
  execSync5(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
39247
39534
  } catch {
39248
39535
  }
39249
39536
  let removed = false;
39250
- if (existsSync60(plistPath)) {
39537
+ if (existsSync61(plistPath)) {
39251
39538
  rmSync12(plistPath, { force: true });
39252
39539
  removed = true;
39253
39540
  }
@@ -39333,14 +39620,14 @@ var remote_target_exports = {};
39333
39620
  __export(remote_target_exports, {
39334
39621
  recallTarget: () => recallTarget
39335
39622
  });
39336
- import { readFileSync as readFileSync56 } from "node:fs";
39337
- import { join as join70 } from "node:path";
39623
+ import { readFileSync as readFileSync57 } from "node:fs";
39624
+ import { join as join72 } from "node:path";
39338
39625
  function recallTarget() {
39339
39626
  const fromEnv = envCredentials();
39340
39627
  if (fromEnv)
39341
39628
  return { base: fromEnv.serverUrl, token: fromEnv.token };
39342
39629
  try {
39343
- const raw = readFileSync56(join70(getDataDir(), "credentials.json"), "utf-8");
39630
+ const raw = readFileSync57(join72(getDataDir(), "credentials.json"), "utf-8");
39344
39631
  const parsed = JSON.parse(raw);
39345
39632
  if (Array.isArray(parsed.targets) && parsed.targets.length) {
39346
39633
  const valid = parsed.targets.filter((t) => t?.serverUrl);
@@ -39667,9 +39954,9 @@ init_project_resolver();
39667
39954
  import { config } from "dotenv";
39668
39955
  import { Command } from "commander";
39669
39956
  import chalk2 from "chalk";
39670
- import { existsSync as existsSync61, readFileSync as readFileSync57, writeFileSync as writeFileSync25 } from "fs";
39671
- import { homedir as homedir25 } from "os";
39672
- import { join as join71, resolve as resolve2, dirname as dirname30, basename as basename29 } from "path";
39957
+ import { existsSync as existsSync62, readFileSync as readFileSync58, writeFileSync as writeFileSync26 } from "fs";
39958
+ import { homedir as homedir26 } from "os";
39959
+ import { join as join73, resolve as resolve2, dirname as dirname32, basename as basename29 } from "path";
39673
39960
 
39674
39961
  // ../engine/dist/core/score-tier.js
39675
39962
  var STRONG_RATIO = 0.85;
@@ -39913,13 +40200,13 @@ async function serverDelete(path, body2) {
39913
40200
  }
39914
40201
  var pkgEngines = (() => {
39915
40202
  try {
39916
- return JSON.parse(readFileSync57(new URL("../package.json", import.meta.url), "utf-8")).engines?.node ?? "";
40203
+ return JSON.parse(readFileSync58(new URL("../package.json", import.meta.url), "utf-8")).engines?.node ?? "";
39917
40204
  } catch {
39918
40205
  return "";
39919
40206
  }
39920
40207
  })();
39921
40208
  var pkgVersion = JSON.parse(
39922
- readFileSync57(new URL("../package.json", import.meta.url), "utf-8")
40209
+ readFileSync58(new URL("../package.json", import.meta.url), "utf-8")
39923
40210
  ).version;
39924
40211
  var DEFAULT_SERVER = (process.env.CHAT_RECALL_DEFAULT_SERVER || "https://chatrecall.dev").replace(/\/+$/, "");
39925
40212
  var DEFAULT_ALLOW = [
@@ -40099,10 +40386,9 @@ program.command("init").description("Set up chat-recall: connect to your server,
40099
40386
  } else if (target) {
40100
40387
  }
40101
40388
  if (!options.skipMcp) {
40102
- const projectRoot = join71(import.meta.dirname, "..");
40103
- let mcpBinOnPath = false;
40104
- mcpBinOnPath = isOnPath("chat-recall-mcp");
40105
- const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: "node", args: [join71(projectRoot, "dist", "mcp-relay.js")] };
40389
+ const projectRoot = join73(import.meta.dirname, "..");
40390
+ const mcpBinOnPath = isOnPath("chat-recall-mcp");
40391
+ const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: process.execPath, args: [join73(projectRoot, "dist", "mcp.js")] };
40106
40392
  const MCP_ENV = { NODE_OPTIONS: "--max-old-space-size=1024" };
40107
40393
  const { registerMcpEverywhere: registerMcpEverywhere2 } = await Promise.resolve().then(() => (init_mcp_clients(), mcp_clients_exports));
40108
40394
  const MCP_CLIENT_FOR_BIN = {
@@ -40126,12 +40412,14 @@ program.command("init").description("Set up chat-recall: connect to your server,
40126
40412
  const hosted = options.server ?? target?.base;
40127
40413
  const hostedBase = hosted?.replace(/\/+$/, "");
40128
40414
  const stored = target && hostedBase && hostedBase === target.base.replace(/\/+$/, "") ? target : null;
40415
+ const { localMcpUrl: localMcpUrl2 } = await Promise.resolve().then(() => (init_mcp_host(), mcp_host_exports));
40416
+ const localUrl = hostedBase ? null : localMcpUrl2();
40129
40417
  const results = registerMcpEverywhere2(
40130
40418
  hostedBase ? {
40131
40419
  url: `${hostedBase}/mcp`,
40132
40420
  authorization: stored?.token ? `Bearer ${stored.token}` : void 0,
40133
40421
  headersHelper: stored ? "chat-recall token --header" : void 0
40134
- } : { ...launch, env: MCP_ENV, alwaysAllow: DEFAULT_ALLOW },
40422
+ } : localUrl ? { url: localUrl } : { ...launch, env: MCP_ENV, alwaysAllow: DEFAULT_ALLOW },
40135
40423
  { extraIds: detectedClients, skipIds: kitDone.has("claude") ? ["claude"] : [] }
40136
40424
  );
40137
40425
  const ok = results.filter((r) => r.state !== "unparseable");
@@ -40160,7 +40448,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
40160
40448
  const detected = checkCodeindexStatus2();
40161
40449
  if (detected.installed && !forceInstall) {
40162
40450
  if (!options.skipMcp) {
40163
- const mcpJsonPath = join71(homedir25(), ".mcp.json");
40451
+ const mcpJsonPath = join73(homedir26(), ".mcp.json");
40164
40452
  const reg = registerCodeindexMcp2(mcpJsonPath, detected.path);
40165
40453
  }
40166
40454
  } else if (forceInstall) {
@@ -40169,7 +40457,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
40169
40457
  if (result.installed) {
40170
40458
  const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
40171
40459
  if (!options.skipMcp) {
40172
- const mcpJsonPath = join71(homedir25(), ".mcp.json");
40460
+ const mcpJsonPath = join73(homedir26(), ".mcp.json");
40173
40461
  const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
40174
40462
  }
40175
40463
  } else if (!result.prebuiltAvailable) {
@@ -40625,8 +40913,8 @@ memory.command("wake-up").description("Generate wake-up context (high-importance
40625
40913
  try {
40626
40914
  const identityFile = getIdentityFilePath();
40627
40915
  let identity = "AI coding assistant";
40628
- if (existsSync61(identityFile)) {
40629
- identity = readFileSync57(identityFile, "utf-8").trim();
40916
+ if (existsSync62(identityFile)) {
40917
+ identity = readFileSync58(identityFile, "utf-8").trim();
40630
40918
  }
40631
40919
  const lines = [
40632
40920
  chalk2.bold("# Wake-Up Context"),
@@ -40726,7 +41014,7 @@ program.command("feedback").argument("<message...>", "what you want to say \u201
40726
41014
  }
40727
41015
  });
40728
41016
  program.command("doctor").description("Quick health check across login, server, credentials, hooks, MCP server, and codeindex").option("--purge-local", "Remove the legacy local index (cache.db + vector/KG files) left by pre-thin-collector versions \u2014 storage is server-side now. Requires login; keeps credentials, sync ledger, identity, and the audit log.").action(async (opts) => {
40729
- const { existsSync: existsSync62, readFileSync: readFileSync58, statSync: statSync49 } = await import("fs");
41017
+ const { existsSync: existsSync63, readFileSync: readFileSync59, statSync: statSync49 } = await import("fs");
40730
41018
  const { execSync: execSync6 } = await import("child_process");
40731
41019
  const rows = [];
40732
41020
  const note = (ok, label, detail) => rows.push({ ok, label, detail });
@@ -40789,8 +41077,8 @@ program.command("doctor").description("Quick health check across login, server,
40789
41077
  }
40790
41078
  }
40791
41079
  }
40792
- const credFile = join71(getDataDir(), "credentials.json");
40793
- if (!existsSync62(credFile)) {
41080
+ const credFile = join73(getDataDir(), "credentials.json");
41081
+ if (!existsSync63(credFile)) {
40794
41082
  note(false, "Credentials file", `missing \u2014 run \`chat-recall login <server-url>\``);
40795
41083
  } else {
40796
41084
  try {
@@ -40805,18 +41093,18 @@ program.command("doctor").description("Quick health check across login, server,
40805
41093
  const { claudeSettingsFiles: claudeSettingsFiles2, isOurEntry: isOurEntry2 } = await Promise.resolve().then(() => (init_install_hooks(), install_hooks_exports));
40806
41094
  const { MESSAGE_HOOK_EVENTS: MESSAGE_HOOK_EVENTS2, isMessageHookEntry: isMessageHookEntry2, isBoardHookEntry: isBoardHookEntry2 } = await Promise.resolve().then(() => (init_board_hooks(), board_hooks_exports));
40807
41095
  for (const settingsFile of claudeSettingsFiles2()) {
40808
- const profile = basename29(dirname30(settingsFile));
41096
+ const profile = basename29(dirname32(settingsFile));
40809
41097
  const label = `Claude hooks (${profile})`;
40810
41098
  let hooks;
40811
41099
  try {
40812
- hooks = existsSync62(settingsFile) ? JSON.parse(readFileSync58(settingsFile, "utf-8")).hooks || {} : {};
41100
+ hooks = existsSync63(settingsFile) ? JSON.parse(readFileSync59(settingsFile, "utf-8")).hooks || {} : {};
40813
41101
  } catch {
40814
41102
  note(false, label, `${settingsFile} is not valid JSON, so no hook in it runs`);
40815
41103
  continue;
40816
41104
  }
40817
- const legacy = join71(dirname30(settingsFile), "hooks.json");
41105
+ const legacy = join73(dirname32(settingsFile), "hooks.json");
40818
41106
  try {
40819
- const stranded = existsSync62(legacy) ? Object.values(JSON.parse(readFileSync58(legacy, "utf-8")).hooks || {}).flat().filter(isOurEntry2).length : 0;
41107
+ const stranded = existsSync63(legacy) ? Object.values(JSON.parse(readFileSync59(legacy, "utf-8")).hooks || {}).flat().filter(isOurEntry2).length : 0;
40820
41108
  if (stranded) note(false, `Old hook file (${profile})`, `${stranded} chat-recall entr${stranded === 1 ? "y" : "ies"} in ${legacy}, which Claude Code does not read \u2014 run \`chat-recall install-hooks\` to move them`);
40821
41109
  } catch {
40822
41110
  }
@@ -40839,9 +41127,9 @@ program.command("doctor").description("Quick health check across login, server,
40839
41127
  try {
40840
41128
  const reg = await Promise.resolve().then(() => (init_guard_registration(), guard_registration_exports));
40841
41129
  for (const target2 of reg.guardTargets()) {
40842
- if (!existsSync62(target2.homeDir)) continue;
41130
+ if (!existsSync63(target2.homeDir)) continue;
40843
41131
  const label = `Decision guard \u2014 ${target2.label}`;
40844
- if (!existsSync62(target2.configPath)) {
41132
+ if (!existsSync63(target2.configPath)) {
40845
41133
  note(false, label, `not registered \u2014 run \`chat-recall install-hooks\``);
40846
41134
  continue;
40847
41135
  }
@@ -40851,7 +41139,7 @@ program.command("doctor").description("Quick health check across login, server,
40851
41139
  }
40852
41140
  let registered = false;
40853
41141
  try {
40854
- const cfg = JSON.parse(readFileSync58(target2.configPath, "utf-8"));
41142
+ const cfg = JSON.parse(readFileSync59(target2.configPath, "utf-8"));
40855
41143
  registered = JSON.stringify(cfg).includes("chat_recall_guard");
40856
41144
  } catch {
40857
41145
  }
@@ -40864,12 +41152,12 @@ program.command("doctor").description("Quick health check across login, server,
40864
41152
  try {
40865
41153
  const reg = await Promise.resolve().then(() => (init_message_registration(), message_registration_exports));
40866
41154
  for (const target2 of reg.messageTargets()) {
40867
- if (!existsSync62(target2.homeDir)) continue;
41155
+ if (!existsSync63(target2.homeDir)) continue;
40868
41156
  const label = `Messages \u2014 ${target2.label}`;
40869
- let registered = existsSync62(target2.configPath);
41157
+ let registered = existsSync63(target2.configPath);
40870
41158
  if (registered) {
40871
41159
  try {
40872
- const text = readFileSync58(target2.configPath, "utf-8");
41160
+ const text = readFileSync59(target2.configPath, "utf-8");
40873
41161
  registered = text.includes("chat_recall_messages_") || reg.isOurPluginSource(text);
40874
41162
  } catch {
40875
41163
  registered = false;
@@ -40882,9 +41170,9 @@ program.command("doctor").description("Quick health check across login, server,
40882
41170
  note(false, "Messages", `check failed: ${err}`);
40883
41171
  }
40884
41172
  try {
40885
- if (existsSync62(opencodeConfigDir())) {
41173
+ if (existsSync63(opencodeConfigDir())) {
40886
41174
  const path = tuiConfigPath();
40887
- const present = existsSync62(path) && hasTuiPluginEntry(readFileSync58(path, "utf-8"), tuiPluginEntry());
41175
+ const present = existsSync63(path) && hasTuiPluginEntry(readFileSync59(path, "utf-8"), tuiPluginEntry());
40888
41176
  note(
40889
41177
  present,
40890
41178
  "Messages \u2014 OpenCode TUI",
@@ -40899,7 +41187,7 @@ program.command("doctor").description("Quick health check across login, server,
40899
41187
  const want = bundledSkillNames2().length;
40900
41188
  for (const t of skillTargets2()) {
40901
41189
  if (!t.available) continue;
40902
- const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync62(join71(t.dir, n, ".chat-recall-managed"))).length;
41190
+ const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync63(join73(t.dir, n, ".chat-recall-managed"))).length;
40903
41191
  note(
40904
41192
  have === want,
40905
41193
  `Skills \u2014 ${t.label}`,
@@ -40974,14 +41262,14 @@ program.command("doctor").description("Quick health check across login, server,
40974
41262
  note(watchRunning, "Watch daemon", watchRunning ? "running" : "not running (run `chat-recall watch --install-service` to keep collection running)");
40975
41263
  const dataDir = getDataDir();
40976
41264
  const legacyPaths = [
40977
- join71(dataDir, "cache.db"),
40978
- join71(dataDir, "cache.db-wal"),
40979
- join71(dataDir, "cache.db-shm"),
40980
- join71(dataDir, "index", "lancedb"),
40981
- join71(dataDir, "index", "knowledge_graph.db"),
40982
- join71(dataDir, "index", "metadata.db")
41265
+ join73(dataDir, "cache.db"),
41266
+ join73(dataDir, "cache.db-wal"),
41267
+ join73(dataDir, "cache.db-shm"),
41268
+ join73(dataDir, "index", "lancedb"),
41269
+ join73(dataDir, "index", "knowledge_graph.db"),
41270
+ join73(dataDir, "index", "metadata.db")
40983
41271
  ];
40984
- const legacyPresent = legacyPaths.filter((p) => existsSync62(p));
41272
+ const legacyPresent = legacyPaths.filter((p) => existsSync63(p));
40985
41273
  if (opts.purgeLocal) {
40986
41274
  if (!target) {
40987
41275
  note(false, "Purge legacy index", "refused \u2014 log in and `chat-recall sync` first, so your history is on the server before removing local copies");
@@ -41052,7 +41340,7 @@ companions.command("install").description("Install codeindex (downloads from mun
41052
41340
  if (result.installed) {
41053
41341
  const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
41054
41342
  console.log(chalk2.green(`\u2713 codeindex installed (${sizeMb}) \u2192 ${result.path}`));
41055
- const mcpJsonPath = join71(homedir25(), ".mcp.json");
41343
+ const mcpJsonPath = join73(homedir26(), ".mcp.json");
41056
41344
  const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
41057
41345
  if (reg.added) console.log(chalk2.dim(` Registered as MCP server in ${mcpJsonPath}`));
41058
41346
  else console.log(chalk2.dim(` Already registered as MCP server`));
@@ -41074,7 +41362,7 @@ companions.command("uninstall").description("Remove the codeindex binary chat-re
41074
41362
  const r = uninstallCodeindex2();
41075
41363
  if (r.removed) console.log(chalk2.green(`\u2713 Removed ${r.path}`));
41076
41364
  else console.log(chalk2.dim(` Nothing to remove at ${r.path}`));
41077
- const mcpJsonPath = join71(homedir25(), ".mcp.json");
41365
+ const mcpJsonPath = join73(homedir26(), ".mcp.json");
41078
41366
  const u = unregisterCodeindexMcp2(mcpJsonPath);
41079
41367
  if (u.removed) console.log(chalk2.dim(` Unregistered MCP server from ${mcpJsonPath}`));
41080
41368
  });
@@ -41626,10 +41914,10 @@ tasks.command("pull [dir]").description("Write TEAM_TASKS.md for your tasks in t
41626
41914
  try {
41627
41915
  const { resolveProjectId: resolveProjectId2 } = await Promise.resolve().then(() => (init_project_resolver(), project_resolver_exports));
41628
41916
  const { renderTeamTasksMd: renderTeamTasksMd2, parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
41629
- const { writeFileSync: writeFileSync26, readFileSync: readFileSync58, existsSync: existsSync62 } = await import("node:fs");
41630
- const { join: join72 } = await import("node:path");
41631
- const file = join72(cwd, "TEAM_TASKS.md");
41632
- if (!opts.force && existsSync62(file) && parseTeamTasksFile2(readFileSync58(file, "utf8")).length > 0) {
41917
+ const { writeFileSync: writeFileSync27, readFileSync: readFileSync59, existsSync: existsSync63 } = await import("node:fs");
41918
+ const { join: join74 } = await import("node:path");
41919
+ const file = join74(cwd, "TEAM_TASKS.md");
41920
+ if (!opts.force && existsSync63(file) && parseTeamTasksFile2(readFileSync59(file, "utf8")).length > 0) {
41633
41921
  console.error(chalk2.red("TEAM_TASKS.md has unpushed edits."), "Run", chalk2.bold("chat-recall tasks push"), "first, or", chalk2.bold("tasks pull --force"), "to discard.");
41634
41922
  process.exit(1);
41635
41923
  }
@@ -41637,7 +41925,7 @@ tasks.command("pull [dir]").description("Write TEAM_TASKS.md for your tasks in t
41637
41925
  const pid = resolved && resolved.source !== "ignored" ? resolved.id : "";
41638
41926
  const { tasks: tasks2 } = await serverGet("/api/tasks?assignee=@me");
41639
41927
  const mine = tasks2.filter((t) => !pid || !t.projectId || t.projectId === pid);
41640
- writeFileSync26(file, renderTeamTasksMd2(mine));
41928
+ writeFileSync27(file, renderTeamTasksMd2(mine));
41641
41929
  console.log(chalk2.green("\u2713 wrote"), "TEAM_TASKS.md", chalk2.gray(`(${mine.length} task(s))`), "\u2014 edit, then", chalk2.bold("chat-recall tasks push"));
41642
41930
  } catch (e) {
41643
41931
  console.error(chalk2.red(e instanceof Error ? e.message : String(e)));
@@ -41648,14 +41936,14 @@ tasks.command("push [dir]").description("Push TEAM_TASKS.md status edits back to
41648
41936
  const cwd = dir || process.cwd();
41649
41937
  try {
41650
41938
  const { parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
41651
- const { readFileSync: readFileSync58, existsSync: existsSync62 } = await import("node:fs");
41652
- const { join: join72 } = await import("node:path");
41653
- const file = join72(cwd, "TEAM_TASKS.md");
41654
- if (!existsSync62(file)) {
41939
+ const { readFileSync: readFileSync59, existsSync: existsSync63 } = await import("node:fs");
41940
+ const { join: join74 } = await import("node:path");
41941
+ const file = join74(cwd, "TEAM_TASKS.md");
41942
+ if (!existsSync63(file)) {
41655
41943
  console.error(chalk2.red("no TEAM_TASKS.md here \u2014"), "run", chalk2.bold("chat-recall tasks pull"), "first");
41656
41944
  process.exit(1);
41657
41945
  }
41658
- const edits = parseTeamTasksFile2(readFileSync58(file, "utf8"));
41946
+ const edits = parseTeamTasksFile2(readFileSync59(file, "utf8"));
41659
41947
  let n = 0;
41660
41948
  for (const e of edits) {
41661
41949
  await serverPatch(`/api/tasks/${encodeURIComponent(e.id)}`, { status: e.intent });
@@ -41761,8 +42049,8 @@ team.command("publish <type> <name> <file>").description("Publish a local file a
41761
42049
  console.error(chalk2.red(`Invalid tool: ${opts.tool}. Must be one of: ${validTools.join(", ")}`));
41762
42050
  process.exit(1);
41763
42051
  }
41764
- const { readFileSync: readFileSync58 } = await import("fs");
41765
- const body2 = readFileSync58(file);
42052
+ const { readFileSync: readFileSync59 } = await import("fs");
42053
+ const body2 = readFileSync59(file);
41766
42054
  const { teamPublish: teamPublish2 } = await Promise.resolve().then(() => (init_team_client(), team_client_exports));
41767
42055
  const a = await teamPublish2({
41768
42056
  type,
@@ -42188,7 +42476,7 @@ program.command("dossier <project>").description("Generate a project dossier (ov
42188
42476
  );
42189
42477
  const md = dossier.markdown;
42190
42478
  if (options.out) {
42191
- writeFileSync25(options.out, md);
42479
+ writeFileSync26(options.out, md);
42192
42480
  console.log(chalk2.green(`Wrote dossier to ${options.out} (${md.length} chars)`));
42193
42481
  } else {
42194
42482
  console.log(md);
@@ -42473,8 +42761,8 @@ include.command("list", { isDefault: true }).description("Show paths opted back
42473
42761
  include.command("project <path>").description("Re-permit a path under a personal folder (substring match; e.g. ~/Documents/code)").action(async (path) => {
42474
42762
  const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
42475
42763
  const { resolve: resolve3 } = await import("node:path");
42476
- const { homedir: homedir26 } = await import("node:os");
42477
- const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir26()));
42764
+ const { homedir: homedir27 } = await import("node:os");
42765
+ const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir27()));
42478
42766
  const s = loadSettings2();
42479
42767
  s.sync.includeProjects = s.sync.includeProjects || [];
42480
42768
  if (s.sync.includeProjects.includes(abs)) {
@@ -42488,8 +42776,8 @@ include.command("project <path>").description("Re-permit a path under a personal
42488
42776
  include.command("remove <path>").description("Undo an opt-in (personal folder goes back to skipped)").action(async (path) => {
42489
42777
  const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
42490
42778
  const { resolve: resolve3 } = await import("node:path");
42491
- const { homedir: homedir26 } = await import("node:os");
42492
- const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir26()));
42779
+ const { homedir: homedir27 } = await import("node:os");
42780
+ const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir27()));
42493
42781
  const s = loadSettings2();
42494
42782
  const before = (s.sync.includeProjects || []).length;
42495
42783
  s.sync.includeProjects = (s.sync.includeProjects || []).filter((p) => p !== path && p !== abs);
@@ -42628,8 +42916,8 @@ program.command("projects").description("List distinct project ids discovered on
42628
42916
  exclude.command("project <path>").description("Exclude a project path from syncing (substring match on the project path; e.g. ~/.claude-pr-bot)").action(async (path) => {
42629
42917
  const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
42630
42918
  const { resolve: resolve3 } = await import("node:path");
42631
- const { homedir: homedir26 } = await import("node:os");
42632
- const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir26()));
42919
+ const { homedir: homedir27 } = await import("node:os");
42920
+ const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir27()));
42633
42921
  const s = loadSettings2();
42634
42922
  if (s.sync.excludeProjects.includes(abs)) {
42635
42923
  console.log(chalk2.dim(`Already excluded: ${abs}`));
@@ -42658,8 +42946,8 @@ exclude.command("tool <tool>").description("Exclude an AI tool entirely (claude
42658
42946
  exclude.command("remove <value>").description("Remove an exclusion (tool name or project path)").action(async (value) => {
42659
42947
  const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
42660
42948
  const { resolve: resolve3 } = await import("node:path");
42661
- const { homedir: homedir26 } = await import("node:os");
42662
- const abs = resolve3(value.replace(/^~(?=\/|$)/, homedir26()));
42949
+ const { homedir: homedir27 } = await import("node:os");
42950
+ const abs = resolve3(value.replace(/^~(?=\/|$)/, homedir27()));
42663
42951
  const s = loadSettings2();
42664
42952
  const beforeTools = s.sync.excludeTools.length;
42665
42953
  const beforeProjects = s.sync.excludeProjects.length;