chat-recall 0.7.38 → 0.7.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -14
- package/dist/cli.js +833 -425
- package/dist/cli.js.map +1 -1
- package/dist/install-hooks.d.ts +11 -3
- package/dist/install-hooks.d.ts.map +1 -1
- package/dist/install-hooks.js +10 -5
- package/dist/install-hooks.js.map +1 -1
- package/dist/kit-store.d.ts +5 -4
- package/dist/kit-store.d.ts.map +1 -1
- package/dist/kit-store.js +6 -6
- package/dist/kit-store.js.map +1 -1
- package/dist/mcp-host.d.ts +50 -0
- package/dist/mcp-host.d.ts.map +1 -0
- package/dist/mcp-host.js +111 -0
- package/dist/mcp-host.js.map +1 -0
- package/dist/mcp.js +1057 -993
- package/dist/mcp.js.map +1 -1
- package/dist/memory-guard.d.ts +41 -0
- package/dist/memory-guard.d.ts.map +1 -0
- package/dist/memory-guard.js +56 -0
- package/dist/memory-guard.js.map +1 -0
- package/dist/message-hook.js +1 -1
- package/dist/scan-worker.js +8 -5
- package/dist/service-installer.d.ts +13 -0
- package/dist/service-installer.d.ts.map +1 -1
- package/dist/service-installer.js +19 -7
- package/dist/service-installer.js.map +1 -1
- package/dist/session-exit.d.ts +50 -0
- package/dist/session-exit.d.ts.map +1 -0
- package/dist/session-exit.js +70 -0
- package/dist/session-exit.js.map +1 -0
- package/dist/star-nudge.js +1 -1
- package/dist/sync-client.d.ts +16 -2
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +47 -10
- package/dist/sync-client.js.map +1 -1
- package/dist/vendor/mcp-kit/VERSION +1 -0
- package/dist/vendor/mcp-kit/host-main.d.ts +2 -0
- package/dist/vendor/mcp-kit/host-main.js +3 -0
- package/dist/vendor/mcp-kit/host-plain.d.ts +56 -0
- package/dist/vendor/mcp-kit/host-plain.js +502 -0
- package/dist/vendor/mcp-kit/host.d.ts +32 -0
- package/dist/vendor/mcp-kit/host.js +43 -0
- package/dist/vendor/mcp-kit/registry.d.ts +79 -0
- package/dist/vendor/mcp-kit/registry.js +194 -0
- package/dist/watch.js +78 -26
- package/package.json +2 -2
- package/dist/mcp-relay.d.ts +0 -3
- package/dist/mcp-relay.d.ts.map +0 -1
- package/dist/mcp-relay.js +0 -472
- package/dist/mcp-relay.js.map +0 -1
- package/dist/mcp-socket.d.ts +0 -98
- package/dist/mcp-socket.d.ts.map +0 -1
- package/dist/mcp-socket.js +0 -249
- package/dist/mcp-socket.js.map +0 -1
- package/dist/relay-lifecycle.d.ts +0 -92
- package/dist/relay-lifecycle.d.ts.map +0 -1
- package/dist/relay-lifecycle.js +0 -290
- 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:
|
|
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"] ||
|
|
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:
|
|
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"] ||
|
|
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"] ||
|
|
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
|
|
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
|
|
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
|
-
|
|
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 +=
|
|
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 += `${
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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 +=
|
|
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 += `${
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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 +=
|
|
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 += `${
|
|
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
|
|
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,
|
|
3827
|
+
res += stringifyTypedArray(value, join74, maximumBreadth);
|
|
3828
3828
|
keys = keys.slice(value.length);
|
|
3829
3829
|
maximumPropertiesToStringify -= value.length;
|
|
3830
|
-
separator =
|
|
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 =
|
|
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 =
|
|
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:
|
|
9830
|
-
const { dirname:
|
|
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 =
|
|
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 =
|
|
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 (
|
|
9867
|
+
if (readFileSync59(join74(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
|
|
9868
9868
|
return basename30(f, ".jsonl");
|
|
9869
9869
|
}
|
|
9870
9870
|
} catch {
|
|
@@ -10598,15 +10598,18 @@ var init_opencode = __esm({
|
|
|
10598
10598
|
FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
|
|
10599
10599
|
WHERE p.session_id = ?
|
|
10600
10600
|
ORDER BY p.time_created ASC, p.id ASC
|
|
10601
|
-
`)
|
|
10602
|
-
const
|
|
10603
|
-
|
|
10604
|
-
|
|
10601
|
+
`);
|
|
10602
|
+
const chunks = [Buffer.from(`${JSON.stringify({ kind: "session", row: session })}
|
|
10603
|
+
`, "utf-8")];
|
|
10604
|
+
for (const r of rows.iterate(realId, realId)) {
|
|
10605
|
+
chunks.push(Buffer.from(`${JSON.stringify({ kind: "part", row: r })}
|
|
10606
|
+
`, "utf-8"));
|
|
10607
|
+
}
|
|
10605
10608
|
const mtime = session.time_updated || session.time_created || Date.now();
|
|
10606
10609
|
return {
|
|
10607
10610
|
tool: "opencode",
|
|
10608
10611
|
mtime: Number(mtime),
|
|
10609
|
-
files: [{ name: `${realId}.dump.jsonl`, bytes: Buffer.
|
|
10612
|
+
files: [{ name: `${realId}.dump.jsonl`, bytes: Buffer.concat(chunks) }]
|
|
10610
10613
|
};
|
|
10611
10614
|
} catch {
|
|
10612
10615
|
return null;
|
|
@@ -16090,10 +16093,10 @@ var init_types = __esm({
|
|
|
16090
16093
|
|
|
16091
16094
|
// ../engine/dist/transcript/opencode.js
|
|
16092
16095
|
async function parseOpenCodeSubagents(parentSessionId) {
|
|
16093
|
-
const { existsSync:
|
|
16096
|
+
const { existsSync: existsSync63 } = await import("fs");
|
|
16094
16097
|
const { opencodeBackend: opencodeBackend2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
|
|
16095
16098
|
const dbPath = opencodeBackend2.dbPath();
|
|
16096
|
-
if (!
|
|
16099
|
+
if (!existsSync63(dbPath))
|
|
16097
16100
|
return [];
|
|
16098
16101
|
const realParent = parentSessionId.replace("opencode_", "");
|
|
16099
16102
|
const db = openOpencodeDbOrThrow(dbPath);
|
|
@@ -16134,10 +16137,10 @@ async function parseOpenCodeSubagents(parentSessionId) {
|
|
|
16134
16137
|
}
|
|
16135
16138
|
}
|
|
16136
16139
|
async function parseOpenCodeTranscript(sessionId) {
|
|
16137
|
-
const { existsSync:
|
|
16140
|
+
const { existsSync: existsSync63 } = await import("fs");
|
|
16138
16141
|
const { opencodeBackend: opencodeBackend2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
|
|
16139
16142
|
const dbPath = opencodeBackend2.dbPath();
|
|
16140
|
-
if (!
|
|
16143
|
+
if (!existsSync63(dbPath))
|
|
16141
16144
|
return [];
|
|
16142
16145
|
const realId = sessionId.replace("opencode_", "");
|
|
16143
16146
|
const db = openOpencodeDbOrThrow(dbPath);
|
|
@@ -28341,7 +28344,7 @@ var init_http = __esm({
|
|
|
28341
28344
|
CLI_VERSION = JSON.parse(readFileSync36(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
|
|
28342
28345
|
} catch {
|
|
28343
28346
|
try {
|
|
28344
|
-
if (
|
|
28347
|
+
if (typeof __CLI_VERSION__ === "string") CLI_VERSION = __CLI_VERSION__;
|
|
28345
28348
|
} catch {
|
|
28346
28349
|
}
|
|
28347
28350
|
}
|
|
@@ -28839,7 +28842,7 @@ var init_telemetry = __esm({
|
|
|
28839
28842
|
init_sync_client();
|
|
28840
28843
|
cliVersion2 = () => {
|
|
28841
28844
|
try {
|
|
28842
|
-
return
|
|
28845
|
+
return typeof __CLI_VERSION__ === "string" ? __CLI_VERSION__ : "dev";
|
|
28843
28846
|
} catch {
|
|
28844
28847
|
return "dev";
|
|
28845
28848
|
}
|
|
@@ -29688,6 +29691,7 @@ __export(sync_client_exports, {
|
|
|
29688
29691
|
classedError: () => classedError,
|
|
29689
29692
|
classifyError: () => classifyError,
|
|
29690
29693
|
countsForBreaker: () => countsForBreaker,
|
|
29694
|
+
exportByteLength: () => exportByteLength,
|
|
29691
29695
|
isStandingFailure: () => isStandingFailure,
|
|
29692
29696
|
isSyncSkip: () => isSyncSkip,
|
|
29693
29697
|
lastSuccessfulWalkAt: () => lastSuccessfulWalkAt,
|
|
@@ -30625,13 +30629,10 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
30625
30629
|
try {
|
|
30626
30630
|
await reconcileFieldsForTarget(
|
|
30627
30631
|
cred,
|
|
30628
|
-
|
|
30629
|
-
|
|
30630
|
-
|
|
30631
|
-
|
|
30632
|
-
return [];
|
|
30633
|
-
}
|
|
30634
|
-
}),
|
|
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,
|
|
30635
30636
|
{ convRefs: slice }
|
|
30636
30637
|
);
|
|
30637
30638
|
} catch (e) {
|
|
@@ -31009,6 +31010,10 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
31009
31010
|
scanMs: Math.round(scanMs)
|
|
31010
31011
|
};
|
|
31011
31012
|
}
|
|
31013
|
+
function exportByteLength(exp) {
|
|
31014
|
+
if (!exp) return 0;
|
|
31015
|
+
return exp.files.reduce((n, f) => n + f.bytes.length, 0);
|
|
31016
|
+
}
|
|
31012
31017
|
async function scanTranscriptFindingsChunked(ref, tenantRules) {
|
|
31013
31018
|
const backend = getBackendForId(ref.prefixedId);
|
|
31014
31019
|
const findings = [];
|
|
@@ -31079,7 +31084,20 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31079
31084
|
const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
|
|
31080
31085
|
const exp = backend.exportRawSession(ref.prefixedId);
|
|
31081
31086
|
let built;
|
|
31082
|
-
|
|
31087
|
+
const exportBytes = exportByteLength(exp);
|
|
31088
|
+
const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
|
|
31089
|
+
if (exp && overCeiling) {
|
|
31090
|
+
console.error(`[sync] ${ref.prefixedId} export is ${(exportBytes / 1048576).toFixed(0)}MB (over the ${(FULL_BUILD_MAX_BYTES / 1048576).toFixed(0)}MB ceiling) \u2014 parsing it in place, no container copy, no shadow merge, no raw archive`);
|
|
31091
|
+
record({
|
|
31092
|
+
kind: "oversized_session",
|
|
31093
|
+
mb: Math.round(exportBytes / 1048576),
|
|
31094
|
+
tool: ref.toolId,
|
|
31095
|
+
dedupeKey: stableMark(ref.prefixedId)
|
|
31096
|
+
});
|
|
31097
|
+
includeRaw = false;
|
|
31098
|
+
includeMeta = false;
|
|
31099
|
+
}
|
|
31100
|
+
if (exp && !overCeiling) {
|
|
31083
31101
|
try {
|
|
31084
31102
|
built = buildRawContainer(exp);
|
|
31085
31103
|
srcHash = containerSrcHash(built);
|
|
@@ -31103,7 +31121,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31103
31121
|
includeMeta = false;
|
|
31104
31122
|
}
|
|
31105
31123
|
}
|
|
31106
|
-
const shadow = updateShadow(ref.rawId, exp, built);
|
|
31124
|
+
const shadow = overCeiling ? { container: null, status: "skipped", recovered: 0 } : updateShadow(ref.rawId, exp, built);
|
|
31107
31125
|
if (shadow.container) {
|
|
31108
31126
|
fullestContainer = shadow.container;
|
|
31109
31127
|
if (shadow.status === "rewrite-merged" && shadow.recovered > 0) {
|
|
@@ -31504,7 +31522,7 @@ var init_sync_client = __esm({
|
|
|
31504
31522
|
ownVersion = JSON.parse(readFileSync41(join47(dir, "../package.json"), "utf-8")).version || ownVersion;
|
|
31505
31523
|
} catch {
|
|
31506
31524
|
try {
|
|
31507
|
-
if (
|
|
31525
|
+
if (typeof __CLI_VERSION__ === "string") ownVersion = __CLI_VERSION__;
|
|
31508
31526
|
} catch {
|
|
31509
31527
|
}
|
|
31510
31528
|
}
|
|
@@ -32982,6 +33000,26 @@ function piAgentDir2(home) {
|
|
|
32982
33000
|
const override = process.env.CHAT_RECALL_PI_HOME?.trim() || loadSourceSettings().piHome || process.env.PI_CODING_AGENT_DIR?.trim();
|
|
32983
33001
|
return override ? expandTildePath(override) : join54(home, ".pi", "agent");
|
|
32984
33002
|
}
|
|
33003
|
+
function launchCommand(spec) {
|
|
33004
|
+
if (!spec.command)
|
|
33005
|
+
throw new Error("an MCP entry needs a url or a command");
|
|
33006
|
+
return spec.command;
|
|
33007
|
+
}
|
|
33008
|
+
function remoteMcpServersEntry(id, spec) {
|
|
33009
|
+
const headers = spec.authorization ? { headers: { Authorization: spec.authorization } } : {};
|
|
33010
|
+
switch (id) {
|
|
33011
|
+
// Claude Code is the one that runs a command for the header at every start,
|
|
33012
|
+
// so the token stays out of the config file it writes.
|
|
33013
|
+
case "claude":
|
|
33014
|
+
return { type: "http", url: spec.url, ...spec.headersHelper ? { headersHelper: spec.headersHelper } : headers };
|
|
33015
|
+
case "agy":
|
|
33016
|
+
return { httpUrl: spec.url, ...headers };
|
|
33017
|
+
case "cursor":
|
|
33018
|
+
return { url: spec.url, ...headers };
|
|
33019
|
+
default:
|
|
33020
|
+
return { url: spec.url };
|
|
33021
|
+
}
|
|
33022
|
+
}
|
|
32985
33023
|
function envHome(varName, fallback) {
|
|
32986
33024
|
const v = process.env[varName];
|
|
32987
33025
|
return v && v.trim() ? v.trim() : fallback;
|
|
@@ -33007,8 +33045,18 @@ function registerMcpServersJson(target, path, spec) {
|
|
|
33007
33045
|
}
|
|
33008
33046
|
const servers = cfg.mcpServers || {};
|
|
33009
33047
|
const existing = servers[MCP_SERVER_NAME];
|
|
33048
|
+
if (spec.url) {
|
|
33049
|
+
const wanted = remoteMcpServersEntry(target.id, spec);
|
|
33050
|
+
const isCurrent2 = !!existing && !existing.disabled && Object.entries(wanted).every(([k, v]) => JSON.stringify(existing[k] ?? null) === JSON.stringify(v));
|
|
33051
|
+
if (isCurrent2)
|
|
33052
|
+
return { id: target.id, label: target.label, path, state: "current" };
|
|
33053
|
+
servers[MCP_SERVER_NAME] = wanted;
|
|
33054
|
+
cfg.mcpServers = servers;
|
|
33055
|
+
writeFileMkdir(path, JSON.stringify(cfg, null, 2) + "\n");
|
|
33056
|
+
return { id: target.id, label: target.label, path, state: existing ? "repaired" : "created" };
|
|
33057
|
+
}
|
|
33010
33058
|
const entry = {
|
|
33011
|
-
command: spec
|
|
33059
|
+
command: launchCommand(spec),
|
|
33012
33060
|
...spec.args ? { args: spec.args } : {}
|
|
33013
33061
|
};
|
|
33014
33062
|
if (spec.alwaysAllow)
|
|
@@ -33038,7 +33086,17 @@ function registerOpencodeJson(path, spec) {
|
|
|
33038
33086
|
cfg.$schema = "https://opencode.ai/config.json";
|
|
33039
33087
|
const mcp = cfg.mcp || {};
|
|
33040
33088
|
const existing = mcp[MCP_SERVER_NAME];
|
|
33041
|
-
|
|
33089
|
+
if (spec.url) {
|
|
33090
|
+
const wanted = { type: "remote", url: spec.url, enabled: true };
|
|
33091
|
+
const isCurrent2 = !!existing && existing.type === "remote" && existing.enabled === true && existing.url === spec.url;
|
|
33092
|
+
if (isCurrent2)
|
|
33093
|
+
return { id, label, path, state: "current" };
|
|
33094
|
+
mcp[MCP_SERVER_NAME] = wanted;
|
|
33095
|
+
cfg.mcp = mcp;
|
|
33096
|
+
writeFileMkdir(path, JSON.stringify(cfg, null, 2) + "\n");
|
|
33097
|
+
return { id, label, path, state: existing ? "repaired" : "created" };
|
|
33098
|
+
}
|
|
33099
|
+
const argv = [launchCommand(spec), ...spec.args ?? []];
|
|
33042
33100
|
const entry = { type: "local", command: argv, enabled: true };
|
|
33043
33101
|
if (spec.env)
|
|
33044
33102
|
entry.environment = { ...existing?.environment, ...spec.env };
|
|
@@ -33051,7 +33109,9 @@ function registerOpencodeJson(path, spec) {
|
|
|
33051
33109
|
return { id, label, path, state: existing ? "repaired" : "created" };
|
|
33052
33110
|
}
|
|
33053
33111
|
function codexBlock(spec) {
|
|
33054
|
-
|
|
33112
|
+
if (spec.url)
|
|
33113
|
+
return [CODEX_HEADER, `url = ${JSON.stringify(spec.url)}`].join("\n") + "\n";
|
|
33114
|
+
const lines = [CODEX_HEADER, `command = ${JSON.stringify(launchCommand(spec))}`];
|
|
33055
33115
|
if (spec.args?.length)
|
|
33056
33116
|
lines.push(`args = [${spec.args.map((a) => JSON.stringify(a)).join(", ")}]`);
|
|
33057
33117
|
const env = Object.entries(spec.env ?? {});
|
|
@@ -33452,9 +33512,9 @@ async function signIn(server, onPrompt, o = {}) {
|
|
|
33452
33512
|
}
|
|
33453
33513
|
function relayCommand(bundleDir) {
|
|
33454
33514
|
const bin = resolveOnPath("chat-recall-mcp");
|
|
33455
|
-
return bin ? [bin] : [process.execPath, join55(bundleDir, "mcp
|
|
33515
|
+
return bin ? [bin] : [process.execPath, join55(bundleDir, "mcp.js")];
|
|
33456
33516
|
}
|
|
33457
|
-
function registerRelay(server,
|
|
33517
|
+
function registerRelay(server, _bundleDir, host, env = process.env) {
|
|
33458
33518
|
if (env.CHAT_RECALL_MCP_REGISTRATION?.trim().toLowerCase() === "own") return [];
|
|
33459
33519
|
const kit = optionalKit(env);
|
|
33460
33520
|
if (!kit) return [];
|
|
@@ -33463,8 +33523,7 @@ function registerRelay(server, bundleDir, host, env = process.env) {
|
|
|
33463
33523
|
if (clients.length === 0) return [];
|
|
33464
33524
|
return kit.addMcpServer(machine, clients, {
|
|
33465
33525
|
name: MCP_NAME,
|
|
33466
|
-
url: `${server.replace(/\/+$/, "")}/mcp
|
|
33467
|
-
command: relayCommand(bundleDir)
|
|
33526
|
+
url: `${server.replace(/\/+$/, "")}/mcp`
|
|
33468
33527
|
}).outcomes;
|
|
33469
33528
|
}
|
|
33470
33529
|
var OwnLoginError, LoginError, MCP_NAME, CLI_CLIENT_ID, RUN_TIMEOUT_MS, secretStoreOf;
|
|
@@ -33488,6 +33547,292 @@ var init_kit_store = __esm({
|
|
|
33488
33547
|
}
|
|
33489
33548
|
});
|
|
33490
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
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
|
+
|
|
33491
33836
|
// ../engine/dist/core/companions.js
|
|
33492
33837
|
var companions_exports = {};
|
|
33493
33838
|
__export(companions_exports, {
|
|
@@ -33502,9 +33847,9 @@ __export(companions_exports, {
|
|
|
33502
33847
|
uninstallCodeindex: () => uninstallCodeindex,
|
|
33503
33848
|
unregisterCodeindexMcp: () => unregisterCodeindexMcp
|
|
33504
33849
|
});
|
|
33505
|
-
import { existsSync as
|
|
33506
|
-
import { homedir as
|
|
33507
|
-
import { join as
|
|
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";
|
|
33508
33853
|
import { execSync as execSync3 } from "node:child_process";
|
|
33509
33854
|
import { createHash as createHash13 } from "node:crypto";
|
|
33510
33855
|
function expectedCodeindexSha256(artifact) {
|
|
@@ -33606,7 +33951,7 @@ async function installCodeindex(opts = {}) {
|
|
|
33606
33951
|
return status;
|
|
33607
33952
|
if (!status.prebuiltAvailable)
|
|
33608
33953
|
return status;
|
|
33609
|
-
|
|
33954
|
+
mkdirSync15(CODEINDEX_INSTALL_DIR, { recursive: true });
|
|
33610
33955
|
const tmpPath = `${CODEINDEX_BIN_PATH}.partial`;
|
|
33611
33956
|
try {
|
|
33612
33957
|
await downloadArtifact(status.artifactName, tmpPath);
|
|
@@ -33614,18 +33959,18 @@ async function installCodeindex(opts = {}) {
|
|
|
33614
33959
|
if (!expected) {
|
|
33615
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.`);
|
|
33616
33961
|
}
|
|
33617
|
-
const actual = createHash13("sha256").update(
|
|
33962
|
+
const actual = createHash13("sha256").update(readFileSync46(tmpPath)).digest("hex");
|
|
33618
33963
|
if (actual !== expected) {
|
|
33619
33964
|
throw new Error(`Checksum mismatch for ${status.artifactName}.
|
|
33620
33965
|
expected ${expected}
|
|
33621
33966
|
actual ${actual}
|
|
33622
33967
|
Refusing to install. The release may have been re-uploaded, or something is serving different bytes.`);
|
|
33623
33968
|
}
|
|
33624
|
-
|
|
33625
|
-
|
|
33969
|
+
chmodSync6(tmpPath, 493);
|
|
33970
|
+
renameSync7(tmpPath, CODEINDEX_BIN_PATH);
|
|
33626
33971
|
} catch (err) {
|
|
33627
33972
|
try {
|
|
33628
|
-
if (
|
|
33973
|
+
if (existsSync49(tmpPath))
|
|
33629
33974
|
unlinkSync3(tmpPath);
|
|
33630
33975
|
} catch {
|
|
33631
33976
|
}
|
|
@@ -33634,7 +33979,7 @@ Refusing to install. The release may have been re-uploaded, or something is serv
|
|
|
33634
33979
|
return checkCodeindexStatus();
|
|
33635
33980
|
}
|
|
33636
33981
|
function uninstallCodeindex() {
|
|
33637
|
-
if (
|
|
33982
|
+
if (existsSync49(CODEINDEX_BIN_PATH)) {
|
|
33638
33983
|
unlinkSync3(CODEINDEX_BIN_PATH);
|
|
33639
33984
|
return { removed: true, path: CODEINDEX_BIN_PATH };
|
|
33640
33985
|
}
|
|
@@ -33642,9 +33987,9 @@ function uninstallCodeindex() {
|
|
|
33642
33987
|
}
|
|
33643
33988
|
function registerCodeindexMcp(mcpJsonPath, binaryPath) {
|
|
33644
33989
|
let cfg = {};
|
|
33645
|
-
if (
|
|
33990
|
+
if (existsSync49(mcpJsonPath)) {
|
|
33646
33991
|
try {
|
|
33647
|
-
cfg = JSON.parse(
|
|
33992
|
+
cfg = JSON.parse(readFileSync46(mcpJsonPath, "utf-8"));
|
|
33648
33993
|
} catch {
|
|
33649
33994
|
cfg = {};
|
|
33650
33995
|
}
|
|
@@ -33653,22 +33998,22 @@ function registerCodeindexMcp(mcpJsonPath, binaryPath) {
|
|
|
33653
33998
|
if (cfg.mcpServers["codeindex"])
|
|
33654
33999
|
return { added: false };
|
|
33655
34000
|
cfg.mcpServers["codeindex"] = { command: binaryPath, args: ["--mcp"] };
|
|
33656
|
-
|
|
34001
|
+
writeFileSync16(mcpJsonPath, JSON.stringify(cfg, null, 2));
|
|
33657
34002
|
return { added: true };
|
|
33658
34003
|
}
|
|
33659
34004
|
function unregisterCodeindexMcp(mcpJsonPath) {
|
|
33660
|
-
if (!
|
|
34005
|
+
if (!existsSync49(mcpJsonPath))
|
|
33661
34006
|
return { removed: false };
|
|
33662
34007
|
let cfg;
|
|
33663
34008
|
try {
|
|
33664
|
-
cfg = JSON.parse(
|
|
34009
|
+
cfg = JSON.parse(readFileSync46(mcpJsonPath, "utf-8"));
|
|
33665
34010
|
} catch {
|
|
33666
34011
|
return { removed: false };
|
|
33667
34012
|
}
|
|
33668
34013
|
if (!cfg.mcpServers?.["codeindex"])
|
|
33669
34014
|
return { removed: false };
|
|
33670
34015
|
delete cfg.mcpServers["codeindex"];
|
|
33671
|
-
|
|
34016
|
+
writeFileSync16(mcpJsonPath, JSON.stringify(cfg, null, 2));
|
|
33672
34017
|
return { removed: true };
|
|
33673
34018
|
}
|
|
33674
34019
|
var CODEINDEX_REPO, CODEINDEX_VERSION, CODEINDEX_SHA256, CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME, CODEINDEX_BIN_PATH;
|
|
@@ -33686,9 +34031,9 @@ var init_companions = __esm({
|
|
|
33686
34031
|
"x86_64-windows": "a96fc8c8949bb399a44cc0615b12e458460a529c69f01e8829cc39a20f45ab29",
|
|
33687
34032
|
"aarch64-windows": "42620d56272cd9ba9d785569d8d754d6b4a3e80f36f28db3e0c483fd600ed117"
|
|
33688
34033
|
};
|
|
33689
|
-
CODEINDEX_INSTALL_DIR =
|
|
34034
|
+
CODEINDEX_INSTALL_DIR = join58(homedir21(), ".local", "bin");
|
|
33690
34035
|
CODEINDEX_BIN_NAME = process.platform === "win32" ? "codeindex.exe" : "codeindex";
|
|
33691
|
-
CODEINDEX_BIN_PATH =
|
|
34036
|
+
CODEINDEX_BIN_PATH = join58(CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME);
|
|
33692
34037
|
}
|
|
33693
34038
|
});
|
|
33694
34039
|
|
|
@@ -33703,15 +34048,15 @@ __export(install_skills_exports, {
|
|
|
33703
34048
|
skillsSourceDir: () => skillsSourceDir,
|
|
33704
34049
|
uninstallSkills: () => uninstallSkills
|
|
33705
34050
|
});
|
|
33706
|
-
import { readdirSync as readdirSync33, existsSync as
|
|
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";
|
|
33707
34052
|
import { createHash as createHash14 } from "crypto";
|
|
33708
|
-
import { join as
|
|
34053
|
+
import { join as join59, basename as basename23 } from "path";
|
|
33709
34054
|
function skillsSourceDir() {
|
|
33710
|
-
return
|
|
34055
|
+
return join59(import.meta.dirname, "..", "skills");
|
|
33711
34056
|
}
|
|
33712
34057
|
function version() {
|
|
33713
34058
|
try {
|
|
33714
|
-
return JSON.parse(
|
|
34059
|
+
return JSON.parse(readFileSync47(new URL("../package.json", import.meta.url), "utf-8")).version || "0.0.0";
|
|
33715
34060
|
} catch {
|
|
33716
34061
|
return "0.0.0";
|
|
33717
34062
|
}
|
|
@@ -33720,9 +34065,9 @@ function skillsFingerprint() {
|
|
|
33720
34065
|
const src = skillsSourceDir();
|
|
33721
34066
|
const h = createHash14("sha256");
|
|
33722
34067
|
for (const name of bundledSkillNames()) {
|
|
33723
|
-
for (const rel of filesUnder(
|
|
34068
|
+
for (const rel of filesUnder(join59(src, name)).sort()) {
|
|
33724
34069
|
h.update(name + "/" + rel);
|
|
33725
|
-
h.update(
|
|
34070
|
+
h.update(readFileSync47(join59(src, name, rel)));
|
|
33726
34071
|
}
|
|
33727
34072
|
}
|
|
33728
34073
|
return h.digest("hex").slice(0, 12);
|
|
@@ -33732,7 +34077,7 @@ function filesUnder(dir, prefix = "") {
|
|
|
33732
34077
|
for (const e of readdirSync33(dir, { withFileTypes: true })) {
|
|
33733
34078
|
if (e.name === MARKER) continue;
|
|
33734
34079
|
const rel = prefix ? `${prefix}/${e.name}` : e.name;
|
|
33735
|
-
if (e.isDirectory()) out.push(...filesUnder(
|
|
34080
|
+
if (e.isDirectory()) out.push(...filesUnder(join59(dir, e.name), rel));
|
|
33736
34081
|
else out.push(rel);
|
|
33737
34082
|
}
|
|
33738
34083
|
return out;
|
|
@@ -33742,8 +34087,8 @@ function skillStamp() {
|
|
|
33742
34087
|
}
|
|
33743
34088
|
function bundledSkillNames() {
|
|
33744
34089
|
const src = skillsSourceDir();
|
|
33745
|
-
if (!
|
|
33746
|
-
return readdirSync33(src, { withFileTypes: true }).filter((e) => e.isDirectory() &&
|
|
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();
|
|
33747
34092
|
}
|
|
33748
34093
|
function realPathOrSelf(p) {
|
|
33749
34094
|
try {
|
|
@@ -33756,7 +34101,7 @@ function claudeSkillTargets() {
|
|
|
33756
34101
|
const targets = [];
|
|
33757
34102
|
const seen = /* @__PURE__ */ new Set();
|
|
33758
34103
|
for (const home of claudeHomeDirs()) {
|
|
33759
|
-
const dir =
|
|
34104
|
+
const dir = join59(home, "skills");
|
|
33760
34105
|
const key2 = realPathOrSelf(dir);
|
|
33761
34106
|
if (seen.has(key2)) continue;
|
|
33762
34107
|
seen.add(key2);
|
|
@@ -33767,7 +34112,7 @@ function claudeSkillTargets() {
|
|
|
33767
34112
|
dir,
|
|
33768
34113
|
// Judge each profile on ITS OWN transcripts, not the primary's: a home
|
|
33769
34114
|
// with no projects/ is a directory someone made, not a Claude install.
|
|
33770
|
-
available:
|
|
34115
|
+
available: existsSync50(join59(home, "projects"))
|
|
33771
34116
|
});
|
|
33772
34117
|
}
|
|
33773
34118
|
if (targets.length === 0) {
|
|
@@ -33782,17 +34127,17 @@ function skillTargets() {
|
|
|
33782
34127
|
// both produces "skill conflict" duplicate warnings. Every tool we support
|
|
33783
34128
|
// has its own dir, so per-tool coverage is complete.
|
|
33784
34129
|
...claudeSkillTargets(),
|
|
33785
|
-
{ id: "agy", label: "Antigravity", dir:
|
|
34130
|
+
{ id: "agy", label: "Antigravity", dir: join59(agyBackend.homeDir(), "skills"), available: agyBackend.isAvailable() },
|
|
33786
34131
|
{ id: "codex", label: "Codex", dir: codexBackend.skillsDir(), available: codexBackend.isAvailable() },
|
|
33787
34132
|
{ id: "opencode", label: "OpenCode", dir: opencodeBackend.skillsDir(), available: opencodeBackend.isAvailable() },
|
|
33788
34133
|
// Cursor DOES have its own dir (~/.cursor/skills). `skills-cursor` next to
|
|
33789
34134
|
// it is Cursor's bundled set — read-only, never an install target.
|
|
33790
|
-
{ id: "cursor", label: "Cursor", dir:
|
|
34135
|
+
{ id: "cursor", label: "Cursor", dir: join59(cursorHomeDir(), "skills"), available: cursorBackend.isAvailable() },
|
|
33791
34136
|
{ id: "pi", label: "Pi", dir: piBackend.skillsDir(), available: piBackend.isAvailable() }
|
|
33792
34137
|
];
|
|
33793
34138
|
}
|
|
33794
34139
|
function isManaged(dir) {
|
|
33795
|
-
return
|
|
34140
|
+
return existsSync50(join59(dir, MARKER));
|
|
33796
34141
|
}
|
|
33797
34142
|
function installSkills(opts = {}) {
|
|
33798
34143
|
const onlyAvailable = opts.onlyAvailable ?? true;
|
|
@@ -33809,15 +34154,15 @@ function installSkills(opts = {}) {
|
|
|
33809
34154
|
continue;
|
|
33810
34155
|
}
|
|
33811
34156
|
for (const name of names) {
|
|
33812
|
-
const dest =
|
|
33813
|
-
if (
|
|
34157
|
+
const dest = join59(t.dir, name);
|
|
34158
|
+
if (existsSync50(dest) && !isManaged(dest)) {
|
|
33814
34159
|
skippedUserOwned.push(name);
|
|
33815
34160
|
continue;
|
|
33816
34161
|
}
|
|
33817
|
-
|
|
34162
|
+
mkdirSync16(t.dir, { recursive: true });
|
|
33818
34163
|
rmSync8(dest, { recursive: true, force: true });
|
|
33819
|
-
cpSync(
|
|
33820
|
-
|
|
34164
|
+
cpSync(join59(src, name), dest, { recursive: true });
|
|
34165
|
+
writeFileSync17(join59(dest, MARKER), `${stamp}
|
|
33821
34166
|
`);
|
|
33822
34167
|
installed.push(name);
|
|
33823
34168
|
}
|
|
@@ -33830,13 +34175,13 @@ function uninstallSkills() {
|
|
|
33830
34175
|
const perTarget = [];
|
|
33831
34176
|
for (const t of skillTargets()) {
|
|
33832
34177
|
const removed = [];
|
|
33833
|
-
if (!
|
|
34178
|
+
if (!existsSync50(t.dir)) {
|
|
33834
34179
|
perTarget.push({ id: t.id, label: t.label, removed });
|
|
33835
34180
|
continue;
|
|
33836
34181
|
}
|
|
33837
34182
|
for (const entry of readdirSync33(t.dir, { withFileTypes: true })) {
|
|
33838
34183
|
if (!entry.isDirectory()) continue;
|
|
33839
|
-
const dir =
|
|
34184
|
+
const dir = join59(t.dir, entry.name);
|
|
33840
34185
|
if (isManaged(dir) && (names.has(entry.name) || entry.name.startsWith("chat-recall"))) {
|
|
33841
34186
|
rmSync8(dir, { recursive: true, force: true });
|
|
33842
34187
|
removed.push(entry.name);
|
|
@@ -33853,10 +34198,10 @@ function skillsNeedRefresh() {
|
|
|
33853
34198
|
for (const t of skillTargets()) {
|
|
33854
34199
|
if (!t.available) continue;
|
|
33855
34200
|
for (const name of names) {
|
|
33856
|
-
const marker =
|
|
33857
|
-
if (!
|
|
34201
|
+
const marker = join59(t.dir, name, MARKER);
|
|
34202
|
+
if (!existsSync50(marker)) return true;
|
|
33858
34203
|
try {
|
|
33859
|
-
if (
|
|
34204
|
+
if (readFileSync47(marker, "utf-8").trim() !== cur) return true;
|
|
33860
34205
|
} catch {
|
|
33861
34206
|
return true;
|
|
33862
34207
|
}
|
|
@@ -33871,11 +34216,11 @@ function skillStatus() {
|
|
|
33871
34216
|
let installed = 0;
|
|
33872
34217
|
let ver = null;
|
|
33873
34218
|
for (const name of names) {
|
|
33874
|
-
const marker =
|
|
33875
|
-
if (
|
|
34219
|
+
const marker = join59(t.dir, name, MARKER);
|
|
34220
|
+
if (existsSync50(marker)) {
|
|
33876
34221
|
installed++;
|
|
33877
34222
|
try {
|
|
33878
|
-
ver =
|
|
34223
|
+
ver = readFileSync47(marker, "utf-8").trim();
|
|
33879
34224
|
} catch {
|
|
33880
34225
|
}
|
|
33881
34226
|
}
|
|
@@ -33900,9 +34245,9 @@ var init_install_skills = __esm({
|
|
|
33900
34245
|
});
|
|
33901
34246
|
|
|
33902
34247
|
// ../engine/dist/core/artifact-codec.js
|
|
33903
|
-
import { readFileSync as
|
|
33904
|
-
import { basename as basename24, join as
|
|
33905
|
-
import { homedir as
|
|
34248
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
34249
|
+
import { basename as basename24, join as join60 } from "path";
|
|
34250
|
+
import { homedir as homedir22 } from "os";
|
|
33906
34251
|
function parseCommandText(content, format, fallbackName) {
|
|
33907
34252
|
if (format === "toml") {
|
|
33908
34253
|
const t = parseScalarToml(content);
|
|
@@ -33924,30 +34269,30 @@ function parseAgentText(content, format, fallbackName) {
|
|
|
33924
34269
|
return { name: fm.name || fallbackName, description: fm.description || "", tools: fm.tools, body: body2.trim() };
|
|
33925
34270
|
}
|
|
33926
34271
|
function readCommand(filePath, format) {
|
|
33927
|
-
return parseCommandText(
|
|
34272
|
+
return parseCommandText(readFileSync48(filePath, "utf-8"), format, base2(filePath));
|
|
33928
34273
|
}
|
|
33929
34274
|
function readAgent(filePath, format) {
|
|
33930
|
-
return parseAgentText(
|
|
34275
|
+
return parseAgentText(readFileSync48(filePath, "utf-8"), format, base2(filePath));
|
|
33931
34276
|
}
|
|
33932
34277
|
function readInstructions(filePath, name) {
|
|
33933
|
-
const content =
|
|
34278
|
+
const content = readFileSync48(filePath, "utf-8");
|
|
33934
34279
|
return { name, description: "", body: content };
|
|
33935
34280
|
}
|
|
33936
34281
|
function commandPath(tool, name) {
|
|
33937
34282
|
switch (tool) {
|
|
33938
34283
|
case "claude":
|
|
33939
|
-
return
|
|
34284
|
+
return join60(claudeBackend.commandsDir(), `${name}.md`);
|
|
33940
34285
|
case "agy":
|
|
33941
|
-
return
|
|
34286
|
+
return join60(join60(agyBackend.homeDir(), "commands"), `${name}.toml`);
|
|
33942
34287
|
case "opencode":
|
|
33943
|
-
return
|
|
34288
|
+
return join60(opencodeBackend.commandsDir(), `${name}.md`);
|
|
33944
34289
|
case "codex":
|
|
33945
|
-
return
|
|
34290
|
+
return join60(codexBackend.promptsDir(), `${name}.md`);
|
|
33946
34291
|
case "cursor":
|
|
33947
|
-
return
|
|
34292
|
+
return join60(cursorHomeDir(), "commands", `${name}.md`);
|
|
33948
34293
|
// Pi's prompt templates are flat *.md files in the agent dir.
|
|
33949
34294
|
case "pi":
|
|
33950
|
-
return
|
|
34295
|
+
return join60(piBackend.promptsDir(), `${name}.md`);
|
|
33951
34296
|
// Hermes has no command files. copyArtifactToTool refuses this target first.
|
|
33952
34297
|
case "hermes":
|
|
33953
34298
|
throw new Error("Hermes has no command files");
|
|
@@ -33956,15 +34301,15 @@ function commandPath(tool, name) {
|
|
|
33956
34301
|
function agentPath(tool, name) {
|
|
33957
34302
|
switch (tool) {
|
|
33958
34303
|
case "claude":
|
|
33959
|
-
return
|
|
34304
|
+
return join60(claudeBackend.agentsDir(), `${name}.md`);
|
|
33960
34305
|
case "agy":
|
|
33961
|
-
return
|
|
34306
|
+
return join60(join60(agyBackend.homeDir(), "agents"), `${name}.md`);
|
|
33962
34307
|
case "opencode":
|
|
33963
|
-
return
|
|
34308
|
+
return join60(opencodeBackend.agentsDir(), `${name}.md`);
|
|
33964
34309
|
case "codex":
|
|
33965
|
-
return
|
|
34310
|
+
return join60(codexBackend.agentsDir(), `${name}.toml`);
|
|
33966
34311
|
case "cursor":
|
|
33967
|
-
return
|
|
34312
|
+
return join60(cursorHomeDir(), "agents", `${name}.md`);
|
|
33968
34313
|
// Pi has no named agent personas. copyArtifactToTool refuses this target first.
|
|
33969
34314
|
case "pi":
|
|
33970
34315
|
throw new Error("Pi has no agent files");
|
|
@@ -34001,23 +34346,23 @@ function instructionsFilename(tool) {
|
|
|
34001
34346
|
function instructionsPath(tool, projectPath) {
|
|
34002
34347
|
const file = instructionsFilename(tool);
|
|
34003
34348
|
if (projectPath)
|
|
34004
|
-
return
|
|
34349
|
+
return join60(projectPath, file);
|
|
34005
34350
|
switch (tool) {
|
|
34006
34351
|
case "claude":
|
|
34007
|
-
return
|
|
34352
|
+
return join60(claudeBackend.homeDir(), file);
|
|
34008
34353
|
case "agy":
|
|
34009
|
-
return
|
|
34354
|
+
return join60(agyBackend.homeDir(), file);
|
|
34010
34355
|
case "codex":
|
|
34011
|
-
return
|
|
34356
|
+
return join60(codexBackend.homeDir(), file);
|
|
34012
34357
|
case "opencode":
|
|
34013
|
-
return
|
|
34358
|
+
return join60(homedir22(), ".config", "opencode", file);
|
|
34014
34359
|
// Cursor has no single user-scope instructions FILE — user-level guidance
|
|
34015
34360
|
// is User Rules plus ~/.cursor/rules/*.mdc. AGENTS.md at the home root is
|
|
34016
34361
|
// the closest equivalent and is what a mirror can actually write.
|
|
34017
34362
|
case "cursor":
|
|
34018
|
-
return
|
|
34363
|
+
return join60(cursorHomeDir(), file);
|
|
34019
34364
|
case "pi":
|
|
34020
|
-
return
|
|
34365
|
+
return join60(piBackend.homeDir(), file);
|
|
34021
34366
|
case "hermes":
|
|
34022
34367
|
throw new Error("Hermes has no instruction file mapping");
|
|
34023
34368
|
}
|
|
@@ -34086,9 +34431,9 @@ __export(toolkit_sync_exports, {
|
|
|
34086
34431
|
supportedTargetsFor: () => supportedTargetsFor,
|
|
34087
34432
|
writeMcpEntry: () => writeMcpEntry
|
|
34088
34433
|
});
|
|
34089
|
-
import { existsSync as
|
|
34090
|
-
import { dirname as
|
|
34091
|
-
import { homedir as
|
|
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";
|
|
34092
34437
|
function supportedTargetsFor(type) {
|
|
34093
34438
|
return SUPPORTED_TARGETS[type];
|
|
34094
34439
|
}
|
|
@@ -34129,16 +34474,16 @@ function skillsDirFor(tool) {
|
|
|
34129
34474
|
case "claude":
|
|
34130
34475
|
return claudeBackend.skillsDir();
|
|
34131
34476
|
case "agy":
|
|
34132
|
-
return
|
|
34477
|
+
return join61(agyBackend.homeDir(), "skills");
|
|
34133
34478
|
case "opencode":
|
|
34134
34479
|
return opencodeBackend.skillsDir();
|
|
34135
34480
|
case "codex":
|
|
34136
34481
|
return codexBackend.skillsDir();
|
|
34137
34482
|
// user skills, NOT .system
|
|
34138
34483
|
case "cursor":
|
|
34139
|
-
return
|
|
34484
|
+
return join61(cursorHomeDir(), "skills");
|
|
34140
34485
|
case "hermes":
|
|
34141
|
-
return
|
|
34486
|
+
return join61(hermesBackend.homeDir(), "skills");
|
|
34142
34487
|
case "pi":
|
|
34143
34488
|
return piBackend.skillsDir();
|
|
34144
34489
|
}
|
|
@@ -34146,28 +34491,28 @@ function skillsDirFor(tool) {
|
|
|
34146
34491
|
function skillDirsNamed(tool, name) {
|
|
34147
34492
|
const root = skillsDirFor(tool);
|
|
34148
34493
|
const found = [];
|
|
34149
|
-
if (
|
|
34150
|
-
found.push(
|
|
34151
|
-
if (tool !== "hermes" || !
|
|
34494
|
+
if (existsSync51(join61(root, name)))
|
|
34495
|
+
found.push(join61(root, name));
|
|
34496
|
+
if (tool !== "hermes" || !existsSync51(root))
|
|
34152
34497
|
return found;
|
|
34153
34498
|
for (const category of readdirSync34(root)) {
|
|
34154
|
-
const candidate =
|
|
34155
|
-
if (
|
|
34499
|
+
const candidate = join61(root, category, name);
|
|
34500
|
+
if (existsSync51(join61(candidate, "SKILL.md")))
|
|
34156
34501
|
found.push(candidate);
|
|
34157
34502
|
}
|
|
34158
34503
|
return found;
|
|
34159
34504
|
}
|
|
34160
34505
|
function copySkill(row, toTool) {
|
|
34161
|
-
const skillDir = row.extra.skillDir ||
|
|
34162
|
-
if (!
|
|
34506
|
+
const skillDir = row.extra.skillDir || dirname25(row.filePath);
|
|
34507
|
+
if (!existsSync51(skillDir))
|
|
34163
34508
|
return { ok: false, status: 404, error: `Source dir missing: ${skillDir}` };
|
|
34164
34509
|
const name = row.extra.skillName || basename25(skillDir);
|
|
34165
|
-
const targetDir =
|
|
34510
|
+
const targetDir = join61(skillsDirFor(toTool), name);
|
|
34166
34511
|
const existing = skillDirsNamed(toTool, name);
|
|
34167
34512
|
if (existing.length)
|
|
34168
34513
|
return { ok: false, status: 409, error: `Already exists: ${existing[0]}` };
|
|
34169
34514
|
try {
|
|
34170
|
-
|
|
34515
|
+
mkdirSync17(dirname25(targetDir), { recursive: true });
|
|
34171
34516
|
cpSync2(skillDir, targetDir, { recursive: true });
|
|
34172
34517
|
return { ok: true, targetPath: targetDir };
|
|
34173
34518
|
} catch (e) {
|
|
@@ -34175,26 +34520,26 @@ function copySkill(row, toTool) {
|
|
|
34175
34520
|
}
|
|
34176
34521
|
}
|
|
34177
34522
|
function mcpJsonCandidates(tool) {
|
|
34178
|
-
const home =
|
|
34523
|
+
const home = homedir23();
|
|
34179
34524
|
switch (tool) {
|
|
34180
34525
|
case "claude":
|
|
34181
34526
|
return [
|
|
34182
|
-
{ path:
|
|
34183
|
-
{ path:
|
|
34527
|
+
{ path: join61(home, ".mcp.json"), key: "mcpServers" },
|
|
34528
|
+
{ path: join61(home, ".claude.json"), key: "mcpServers" }
|
|
34184
34529
|
];
|
|
34185
34530
|
case "gemini":
|
|
34186
|
-
return [{ path:
|
|
34531
|
+
return [{ path: join61(home, ".gemini", "settings.json"), key: "mcpServers" }];
|
|
34187
34532
|
case "agy":
|
|
34188
|
-
return [{ path:
|
|
34533
|
+
return [{ path: join61(home, ".gemini", "config", "mcp_config.json"), key: "mcpServers" }];
|
|
34189
34534
|
case "cursor":
|
|
34190
|
-
return [{ path:
|
|
34535
|
+
return [{ path: join61(cursorHomeDir(), "mcp.json"), key: "mcpServers" }];
|
|
34191
34536
|
case "pi":
|
|
34192
34537
|
return [{ path: piMcpConfigPath(), key: "mcpServers" }];
|
|
34193
34538
|
case "opencode":
|
|
34194
34539
|
return [
|
|
34195
|
-
{ path:
|
|
34196
|
-
{ path:
|
|
34197
|
-
{ path:
|
|
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" }
|
|
34198
34543
|
];
|
|
34199
34544
|
default:
|
|
34200
34545
|
return [];
|
|
@@ -34202,14 +34547,14 @@ function mcpJsonCandidates(tool) {
|
|
|
34202
34547
|
}
|
|
34203
34548
|
function readMcpEntry(tool, name) {
|
|
34204
34549
|
if (tool === "codex")
|
|
34205
|
-
return readCodexMcpEntry(
|
|
34550
|
+
return readCodexMcpEntry(join61(homedir23(), ".codex", "config.toml"), name);
|
|
34206
34551
|
if (tool === "hermes")
|
|
34207
34552
|
return readHermesMcpServers()?.[name] ?? null;
|
|
34208
34553
|
for (const t of mcpJsonCandidates(tool)) {
|
|
34209
|
-
if (!
|
|
34554
|
+
if (!existsSync51(t.path))
|
|
34210
34555
|
continue;
|
|
34211
34556
|
try {
|
|
34212
|
-
const cfg = JSON.parse(
|
|
34557
|
+
const cfg = JSON.parse(readFileSync49(t.path, "utf-8"));
|
|
34213
34558
|
const block = cfg[t.key] || {};
|
|
34214
34559
|
if (block[name])
|
|
34215
34560
|
return block[name];
|
|
@@ -34219,11 +34564,11 @@ function readMcpEntry(tool, name) {
|
|
|
34219
34564
|
return null;
|
|
34220
34565
|
}
|
|
34221
34566
|
function readCodexMcpEntry(path, target) {
|
|
34222
|
-
if (!
|
|
34567
|
+
if (!existsSync51(path))
|
|
34223
34568
|
return null;
|
|
34224
34569
|
let content;
|
|
34225
34570
|
try {
|
|
34226
|
-
content =
|
|
34571
|
+
content = readFileSync49(path, "utf-8");
|
|
34227
34572
|
} catch {
|
|
34228
34573
|
return null;
|
|
34229
34574
|
}
|
|
@@ -34273,8 +34618,8 @@ function readCodexMcpEntry(path, target) {
|
|
|
34273
34618
|
}
|
|
34274
34619
|
function writeCodexMcpEntry(path, name, entry) {
|
|
34275
34620
|
let content = "";
|
|
34276
|
-
if (
|
|
34277
|
-
content =
|
|
34621
|
+
if (existsSync51(path))
|
|
34622
|
+
content = readFileSync49(path, "utf-8");
|
|
34278
34623
|
const header = `[mcp_servers.${name}]`;
|
|
34279
34624
|
if (content.includes(header))
|
|
34280
34625
|
return false;
|
|
@@ -34303,16 +34648,16 @@ function writeCodexMcpEntry(path, name, entry) {
|
|
|
34303
34648
|
for (const [k, v] of Object.entries(entry.env))
|
|
34304
34649
|
lines.push(`${k} = ${escape(String(v))}`);
|
|
34305
34650
|
}
|
|
34306
|
-
|
|
34307
|
-
|
|
34651
|
+
mkdirSync17(dirname25(path), { recursive: true });
|
|
34652
|
+
writeFileSync18(path, content + lines.join("\n") + "\n");
|
|
34308
34653
|
return true;
|
|
34309
34654
|
}
|
|
34310
34655
|
function writeMcpEntry(toTool, name, entry) {
|
|
34311
34656
|
if (toTool === "hermes")
|
|
34312
34657
|
return writeHermesMcp(name, entry);
|
|
34313
|
-
const home =
|
|
34658
|
+
const home = homedir23();
|
|
34314
34659
|
if (toTool === "codex") {
|
|
34315
|
-
const path2 =
|
|
34660
|
+
const path2 = join61(home, ".codex", "config.toml");
|
|
34316
34661
|
if (!writeCodexMcpEntry(path2, name, entry))
|
|
34317
34662
|
return { ok: false, status: 409, error: `MCP "${name}" already exists in ${path2}.` };
|
|
34318
34663
|
return { ok: true, targetPath: path2 };
|
|
@@ -34320,30 +34665,30 @@ function writeMcpEntry(toTool, name, entry) {
|
|
|
34320
34665
|
let path;
|
|
34321
34666
|
let key2;
|
|
34322
34667
|
if (toTool === "claude") {
|
|
34323
|
-
path =
|
|
34668
|
+
path = join61(home, ".mcp.json");
|
|
34324
34669
|
key2 = "mcpServers";
|
|
34325
34670
|
} else if (toTool === "agy") {
|
|
34326
|
-
path =
|
|
34671
|
+
path = join61(home, ".gemini", "config", "mcp_config.json");
|
|
34327
34672
|
key2 = "mcpServers";
|
|
34328
34673
|
} else if (toTool === "cursor") {
|
|
34329
|
-
path =
|
|
34674
|
+
path = join61(cursorHomeDir(), "mcp.json");
|
|
34330
34675
|
key2 = "mcpServers";
|
|
34331
34676
|
} else if (toTool === "pi") {
|
|
34332
34677
|
path = piMcpConfigPath();
|
|
34333
34678
|
key2 = "mcpServers";
|
|
34334
34679
|
} else {
|
|
34335
|
-
path =
|
|
34680
|
+
path = join61(home, ".config", "opencode", "opencode.json");
|
|
34336
34681
|
key2 = "mcp";
|
|
34337
34682
|
}
|
|
34338
34683
|
let cfg = {};
|
|
34339
|
-
if (
|
|
34684
|
+
if (existsSync51(path)) {
|
|
34340
34685
|
try {
|
|
34341
|
-
cfg = JSON.parse(
|
|
34686
|
+
cfg = JSON.parse(readFileSync49(path, "utf-8"));
|
|
34342
34687
|
} catch {
|
|
34343
34688
|
return { ok: false, status: 500, error: `Target config is malformed: ${path}` };
|
|
34344
34689
|
}
|
|
34345
34690
|
} else {
|
|
34346
|
-
|
|
34691
|
+
mkdirSync17(dirname25(path), { recursive: true });
|
|
34347
34692
|
}
|
|
34348
34693
|
cfg[key2] = cfg[key2] || {};
|
|
34349
34694
|
if (cfg[key2][name])
|
|
@@ -34370,7 +34715,7 @@ function writeMcpEntry(toTool, name, entry) {
|
|
|
34370
34715
|
}
|
|
34371
34716
|
cfg[key2][name] = normalized;
|
|
34372
34717
|
try {
|
|
34373
|
-
|
|
34718
|
+
writeFileSync18(path, JSON.stringify(cfg, null, 2));
|
|
34374
34719
|
return { ok: true, targetPath: path };
|
|
34375
34720
|
} catch (e) {
|
|
34376
34721
|
return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
|
|
@@ -34400,11 +34745,11 @@ function copyCommandOrAgent(type, row, toTool) {
|
|
|
34400
34745
|
return { ok: false, status: 404, error: `Source unreadable: ${e instanceof Error ? e.message : "failed"}` };
|
|
34401
34746
|
}
|
|
34402
34747
|
const out = emit(type, art, toTool);
|
|
34403
|
-
if (
|
|
34748
|
+
if (existsSync51(out.path))
|
|
34404
34749
|
return { ok: false, status: 409, error: `Already exists: ${out.path}` };
|
|
34405
34750
|
try {
|
|
34406
|
-
|
|
34407
|
-
|
|
34751
|
+
mkdirSync17(dirname25(out.path), { recursive: true });
|
|
34752
|
+
writeFileSync18(out.path, out.content);
|
|
34408
34753
|
return { ok: true, targetPath: out.path };
|
|
34409
34754
|
} catch (e) {
|
|
34410
34755
|
return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
|
|
@@ -34420,11 +34765,11 @@ function copyInstructions(row, toTool) {
|
|
|
34420
34765
|
return { ok: false, status: 404, error: `Source unreadable: ${e instanceof Error ? e.message : "failed"}` };
|
|
34421
34766
|
}
|
|
34422
34767
|
const out = emit("instructions", art, toTool, row.projectPath || void 0);
|
|
34423
|
-
if (
|
|
34768
|
+
if (existsSync51(out.path))
|
|
34424
34769
|
return { ok: false, status: 409, error: `Already exists: ${out.path}` };
|
|
34425
34770
|
try {
|
|
34426
|
-
|
|
34427
|
-
|
|
34771
|
+
mkdirSync17(dirname25(out.path), { recursive: true });
|
|
34772
|
+
writeFileSync18(out.path, out.content);
|
|
34428
34773
|
return { ok: true, targetPath: out.path };
|
|
34429
34774
|
} catch (e) {
|
|
34430
34775
|
return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
|
|
@@ -34434,14 +34779,14 @@ function writeHermesMcp(name, entry) {
|
|
|
34434
34779
|
if (!entry?.command && !entry?.url)
|
|
34435
34780
|
return { ok: false, status: 400, error: `MCP "${name}" has no command or url to write.` };
|
|
34436
34781
|
const path = hermesConfigPath();
|
|
34437
|
-
if (!
|
|
34782
|
+
if (!existsSync51(path))
|
|
34438
34783
|
return { ok: false, status: 404, error: `${path} not found` };
|
|
34439
34784
|
try {
|
|
34440
|
-
const after = addHermesMcpServer(
|
|
34785
|
+
const after = addHermesMcpServer(readFileSync49(path, "utf-8"), name, hermesServerEntry(entry));
|
|
34441
34786
|
if (after === null)
|
|
34442
34787
|
return { ok: false, status: 409, error: `MCP "${name}" already exists in ${path}` };
|
|
34443
34788
|
const backupPaths = [backupToTrash(path, `mcp-hermes-${name}-config.yaml`)];
|
|
34444
|
-
|
|
34789
|
+
writeFileSync18(path, after);
|
|
34445
34790
|
return { ok: true, targetPath: path, backupPaths };
|
|
34446
34791
|
} catch (e) {
|
|
34447
34792
|
return removeFailed(e, "write failed");
|
|
@@ -34476,8 +34821,8 @@ async function removeArtifactFromTool(type, name, tool) {
|
|
|
34476
34821
|
return removeCommandOrAgent(type, name, tool);
|
|
34477
34822
|
}
|
|
34478
34823
|
function backupToTrash(src, label) {
|
|
34479
|
-
const dest =
|
|
34480
|
-
|
|
34824
|
+
const dest = join61(getDataDir(), "trash", `${Date.now()}-${label.replace(/[^A-Za-z0-9._-]/g, "_")}`);
|
|
34825
|
+
mkdirSync17(dirname25(dest), { recursive: true });
|
|
34481
34826
|
cpSync2(src, dest, { recursive: true });
|
|
34482
34827
|
return dest;
|
|
34483
34828
|
}
|
|
@@ -34487,7 +34832,7 @@ function removeFailed(e, fallback) {
|
|
|
34487
34832
|
function removeSkill(name, tool) {
|
|
34488
34833
|
const found = skillDirsNamed(tool, name);
|
|
34489
34834
|
if (found.length === 0)
|
|
34490
|
-
return { ok: false, status: 404, error: `Not found: ${
|
|
34835
|
+
return { ok: false, status: 404, error: `Not found: ${join61(skillsDirFor(tool), name)}` };
|
|
34491
34836
|
if (found.length > 1)
|
|
34492
34837
|
return { ok: false, status: 409, error: `${found.length} skills named "${name}" for ${tool}; none removed` };
|
|
34493
34838
|
const dir = found[0];
|
|
@@ -34508,7 +34853,7 @@ async function removeCommandOrAgent(type, name, tool) {
|
|
|
34508
34853
|
const [row] = rows;
|
|
34509
34854
|
if (row.readonly)
|
|
34510
34855
|
return { ok: false, status: 400, error: "Artifact is read-only (system/bundled)." };
|
|
34511
|
-
if (!row.filePath || !
|
|
34856
|
+
if (!row.filePath || !existsSync51(row.filePath))
|
|
34512
34857
|
return { ok: false, status: 404, error: "Source has no file on disk" };
|
|
34513
34858
|
try {
|
|
34514
34859
|
const backupPaths = [backupToTrash(row.filePath, `${type}-${tool}-${name}`)];
|
|
@@ -34521,30 +34866,30 @@ async function removeCommandOrAgent(type, name, tool) {
|
|
|
34521
34866
|
function removeMcp(name, tool) {
|
|
34522
34867
|
if (tool === "hermes") {
|
|
34523
34868
|
const path = hermesConfigPath();
|
|
34524
|
-
if (!
|
|
34869
|
+
if (!existsSync51(path))
|
|
34525
34870
|
return { ok: false, status: 404, error: `${path} not found` };
|
|
34526
34871
|
try {
|
|
34527
|
-
const after = deleteHermesMcpServer(
|
|
34872
|
+
const after = deleteHermesMcpServer(readFileSync49(path, "utf-8"), name);
|
|
34528
34873
|
if (after === null)
|
|
34529
34874
|
return { ok: false, status: 404, error: `MCP "${name}" not found in ${path}` };
|
|
34530
34875
|
const backupPaths2 = [backupToTrash(path, `mcp-hermes-${name}-config.yaml`)];
|
|
34531
|
-
|
|
34876
|
+
writeFileSync18(path, after);
|
|
34532
34877
|
return { ok: true, targetPath: path, backupPaths: backupPaths2 };
|
|
34533
34878
|
} catch (e) {
|
|
34534
34879
|
return removeFailed(e, "write failed");
|
|
34535
34880
|
}
|
|
34536
34881
|
}
|
|
34537
34882
|
if (tool === "codex") {
|
|
34538
|
-
const path =
|
|
34539
|
-
if (!
|
|
34883
|
+
const path = join61(homedir23(), ".codex", "config.toml");
|
|
34884
|
+
if (!existsSync51(path))
|
|
34540
34885
|
return { ok: false, status: 404, error: "config.toml not found" };
|
|
34541
|
-
const before =
|
|
34886
|
+
const before = readFileSync49(path, "utf-8");
|
|
34542
34887
|
const after = stripCodexMcpBlock(before, name);
|
|
34543
34888
|
if (before === after)
|
|
34544
34889
|
return { ok: false, status: 404, error: `MCP "${name}" not found in ${path}` };
|
|
34545
34890
|
try {
|
|
34546
34891
|
const backupPaths2 = [backupToTrash(path, `mcp-codex-${name}`)];
|
|
34547
|
-
|
|
34892
|
+
writeFileSync18(path, after);
|
|
34548
34893
|
return { ok: true, targetPath: path, backupPaths: backupPaths2 };
|
|
34549
34894
|
} catch (e) {
|
|
34550
34895
|
return removeFailed(e, "write failed");
|
|
@@ -34553,15 +34898,15 @@ function removeMcp(name, tool) {
|
|
|
34553
34898
|
let removedFrom;
|
|
34554
34899
|
const backupPaths = [];
|
|
34555
34900
|
for (const c of mcpJsonCandidates(tool)) {
|
|
34556
|
-
if (!
|
|
34901
|
+
if (!existsSync51(c.path))
|
|
34557
34902
|
continue;
|
|
34558
34903
|
try {
|
|
34559
|
-
const cfg = JSON.parse(
|
|
34904
|
+
const cfg = JSON.parse(readFileSync49(c.path, "utf-8"));
|
|
34560
34905
|
if (!cfg[c.key]?.[name])
|
|
34561
34906
|
continue;
|
|
34562
34907
|
backupPaths.push(backupToTrash(c.path, `mcp-${tool}-${name}-${basename25(c.path)}`));
|
|
34563
34908
|
delete cfg[c.key][name];
|
|
34564
|
-
|
|
34909
|
+
writeFileSync18(c.path, JSON.stringify(cfg, null, 2));
|
|
34565
34910
|
if (!removedFrom)
|
|
34566
34911
|
removedFrom = c.path;
|
|
34567
34912
|
} catch (e) {
|
|
@@ -34718,8 +35063,8 @@ __export(toolkit_pull_exports, {
|
|
|
34718
35063
|
platformRefusal: () => platformRefusal,
|
|
34719
35064
|
portableCommand: () => portableCommand
|
|
34720
35065
|
});
|
|
34721
|
-
import { existsSync as
|
|
34722
|
-
import { dirname as
|
|
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";
|
|
34723
35068
|
function isExecutableFile(p) {
|
|
34724
35069
|
try {
|
|
34725
35070
|
return statSync45(p).isFile();
|
|
@@ -34889,9 +35234,9 @@ function executePull(rows, opts = {}) {
|
|
|
34889
35234
|
const outcomes = [];
|
|
34890
35235
|
for (const { name, body: body2, truncated, redacted, tools } of skills) {
|
|
34891
35236
|
for (const tool of tools) {
|
|
34892
|
-
const dir =
|
|
34893
|
-
const file =
|
|
34894
|
-
if (
|
|
35237
|
+
const dir = join62(skillsDirFor(tool), name);
|
|
35238
|
+
const file = join62(dir, "SKILL.md");
|
|
35239
|
+
if (existsSync52(file)) {
|
|
34895
35240
|
outcomes.push({ type: "skill", name, tool, status: "present" });
|
|
34896
35241
|
continue;
|
|
34897
35242
|
}
|
|
@@ -34904,8 +35249,8 @@ function executePull(rows, opts = {}) {
|
|
|
34904
35249
|
continue;
|
|
34905
35250
|
}
|
|
34906
35251
|
try {
|
|
34907
|
-
|
|
34908
|
-
|
|
35252
|
+
mkdirSync18(dir, { recursive: true });
|
|
35253
|
+
writeFileSync19(file, body2);
|
|
34909
35254
|
outcomes.push({ type: "skill", name, tool, status: "written", path: file, redactedContent: redacted });
|
|
34910
35255
|
} catch (e) {
|
|
34911
35256
|
outcomes.push({ type: "skill", name, tool, status: "failed", reason: e instanceof Error ? e.message : "write failed" });
|
|
@@ -34936,7 +35281,7 @@ function executePull(rows, opts = {}) {
|
|
|
34936
35281
|
outcomes.push({ type, name, tool, status: "failed", reason: e instanceof Error ? e.message : "emit failed" });
|
|
34937
35282
|
continue;
|
|
34938
35283
|
}
|
|
34939
|
-
if (
|
|
35284
|
+
if (existsSync52(out.path)) {
|
|
34940
35285
|
outcomes.push({ type, name, tool, status: "present" });
|
|
34941
35286
|
continue;
|
|
34942
35287
|
}
|
|
@@ -34945,8 +35290,8 @@ function executePull(rows, opts = {}) {
|
|
|
34945
35290
|
continue;
|
|
34946
35291
|
}
|
|
34947
35292
|
try {
|
|
34948
|
-
|
|
34949
|
-
|
|
35293
|
+
mkdirSync18(dirname26(out.path), { recursive: true });
|
|
35294
|
+
writeFileSync19(out.path, out.content);
|
|
34950
35295
|
outcomes.push({ type, name, tool, status: "written", path: out.path, redactedContent: redacted });
|
|
34951
35296
|
} catch (e) {
|
|
34952
35297
|
outcomes.push({ type, name, tool, status: "failed", reason: e instanceof Error ? e.message : "write failed" });
|
|
@@ -35106,8 +35451,8 @@ __export(board_hooks_exports, {
|
|
|
35106
35451
|
resolveCliEntry: () => resolveCliEntry,
|
|
35107
35452
|
resolveMessageHookEntry: () => resolveMessageHookEntry
|
|
35108
35453
|
});
|
|
35109
|
-
import { existsSync as
|
|
35110
|
-
import { join as
|
|
35454
|
+
import { existsSync as existsSync53 } from "node:fs";
|
|
35455
|
+
import { join as join63 } from "node:path";
|
|
35111
35456
|
function entryCommand(entry) {
|
|
35112
35457
|
const cmd = entry?.hooks?.[0]?.command;
|
|
35113
35458
|
return typeof cmd === "string" ? cmd : null;
|
|
@@ -35153,12 +35498,12 @@ function messageHookEntries(execPath, hookEntry) {
|
|
|
35153
35498
|
];
|
|
35154
35499
|
}
|
|
35155
35500
|
function resolveCliEntry(distDir) {
|
|
35156
|
-
const bundled =
|
|
35157
|
-
return
|
|
35501
|
+
const bundled = join63(distDir, "cli.js");
|
|
35502
|
+
return existsSync53(bundled) ? bundled : join63(distDir, "cli.ts");
|
|
35158
35503
|
}
|
|
35159
35504
|
function resolveMessageHookEntry(distDir) {
|
|
35160
|
-
const bundled =
|
|
35161
|
-
return
|
|
35505
|
+
const bundled = join63(distDir, "message-hook.js");
|
|
35506
|
+
return existsSync53(bundled) ? bundled : join63(distDir, "message-hook.ts");
|
|
35162
35507
|
}
|
|
35163
35508
|
var HOOK_TIMEOUT_SECONDS, BOARD_HOOKS, MESSAGE_HOOK_EVENTS, MESSAGE_WAITER_EVENTS, MESSAGE_WAITER_TIMEOUT_SECONDS;
|
|
35164
35509
|
var init_board_hooks = __esm({
|
|
@@ -35190,8 +35535,8 @@ __export(install_hooks_exports, {
|
|
|
35190
35535
|
removeOurEntries: () => removeOurEntries,
|
|
35191
35536
|
uninstallHooks: () => uninstallHooks
|
|
35192
35537
|
});
|
|
35193
|
-
import { chmodSync as
|
|
35194
|
-
import { dirname as
|
|
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";
|
|
35195
35540
|
function isOurEntry(entry) {
|
|
35196
35541
|
const cmd = entry?.hooks?.[0]?.command;
|
|
35197
35542
|
if (typeof cmd !== "string") return false;
|
|
@@ -35205,8 +35550,8 @@ function claudeSettingsFiles() {
|
|
|
35205
35550
|
const out = [];
|
|
35206
35551
|
const seen = /* @__PURE__ */ new Set();
|
|
35207
35552
|
for (const home of claudeHomeDirs()) {
|
|
35208
|
-
if (!
|
|
35209
|
-
const file =
|
|
35553
|
+
if (!existsSync54(join64(home, "projects"))) continue;
|
|
35554
|
+
const file = join64(home, "settings.json");
|
|
35210
35555
|
let key2;
|
|
35211
35556
|
try {
|
|
35212
35557
|
key2 = realpathSync6(file);
|
|
@@ -35222,10 +35567,10 @@ function claudeSettingsFiles() {
|
|
|
35222
35567
|
}
|
|
35223
35568
|
function findScript(distDir, name) {
|
|
35224
35569
|
return [
|
|
35225
|
-
|
|
35226
|
-
|
|
35227
|
-
|
|
35228
|
-
].find((p) =>
|
|
35570
|
+
join64(distDir, "..", "hooks", name),
|
|
35571
|
+
join64(distDir, "..", "..", "hooks", name),
|
|
35572
|
+
join64(distDir, "..", "..", "..", "hooks", name)
|
|
35573
|
+
].find((p) => existsSync54(p));
|
|
35229
35574
|
}
|
|
35230
35575
|
function hookEntries(sel, paths) {
|
|
35231
35576
|
const cmd = (command, extra = {}) => [{ type: "command", command, timeout: HOOK_TIMEOUT_SECONDS, ...extra }];
|
|
@@ -35265,9 +35610,9 @@ function removeOurEntries(config2) {
|
|
|
35265
35610
|
return removed;
|
|
35266
35611
|
}
|
|
35267
35612
|
function readJson4(file) {
|
|
35268
|
-
if (!
|
|
35613
|
+
if (!existsSync54(file)) return {};
|
|
35269
35614
|
try {
|
|
35270
|
-
const v = JSON.parse(
|
|
35615
|
+
const v = JSON.parse(readFileSync50(file, "utf-8"));
|
|
35271
35616
|
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
35272
35617
|
} catch {
|
|
35273
35618
|
return null;
|
|
@@ -35279,34 +35624,34 @@ function writeJsonAtomic(file, value) {
|
|
|
35279
35624
|
target = realpathSync6(file);
|
|
35280
35625
|
} catch {
|
|
35281
35626
|
}
|
|
35282
|
-
|
|
35627
|
+
mkdirSync19(dirname27(target), { recursive: true });
|
|
35283
35628
|
const tmp = `${target}.chat-recall-${process.pid}.tmp`;
|
|
35284
|
-
|
|
35285
|
-
|
|
35629
|
+
writeFileSync20(tmp, JSON.stringify(value, null, 2) + "\n");
|
|
35630
|
+
renameSync8(tmp, target);
|
|
35286
35631
|
}
|
|
35287
35632
|
function statePath() {
|
|
35288
|
-
return
|
|
35633
|
+
return join64(getHooksDir(), "install.json");
|
|
35289
35634
|
}
|
|
35290
35635
|
function readState() {
|
|
35291
35636
|
try {
|
|
35292
|
-
return JSON.parse(
|
|
35637
|
+
return JSON.parse(readFileSync50(statePath(), "utf-8"));
|
|
35293
35638
|
} catch {
|
|
35294
35639
|
return null;
|
|
35295
35640
|
}
|
|
35296
35641
|
}
|
|
35297
|
-
async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
35642
|
+
async function installHooks(distDir, sel = ALL_HOOKS, deps = {}) {
|
|
35298
35643
|
const shellSkipped = process.platform === "win32";
|
|
35299
35644
|
const scriptsDir = getHooksDir();
|
|
35300
|
-
for (const name of LEGACY_SCRIPTS) rmSync10(
|
|
35645
|
+
for (const name of LEGACY_SCRIPTS) rmSync10(join64(scriptsDir, name), { force: true });
|
|
35301
35646
|
const scripts = {};
|
|
35302
35647
|
if (!shellSkipped) {
|
|
35303
35648
|
for (const key2 of Object.keys(SCRIPTS)) {
|
|
35304
35649
|
if (!sel[key2]) continue;
|
|
35305
35650
|
const source = findScript(distDir, SCRIPTS[key2]);
|
|
35306
35651
|
if (!source) continue;
|
|
35307
|
-
const target =
|
|
35308
|
-
|
|
35309
|
-
|
|
35652
|
+
const target = join64(scriptsDir, SCRIPTS[key2]);
|
|
35653
|
+
copyFileSync4(source, target);
|
|
35654
|
+
chmodSync7(target, 493);
|
|
35310
35655
|
scripts[key2] = target;
|
|
35311
35656
|
}
|
|
35312
35657
|
}
|
|
@@ -35324,7 +35669,9 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
|
35324
35669
|
scriptsDir,
|
|
35325
35670
|
selection: sel,
|
|
35326
35671
|
guardTargets: [],
|
|
35327
|
-
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)
|
|
35328
35675
|
};
|
|
35329
35676
|
for (const settingsFile of claudeSettingsFiles()) {
|
|
35330
35677
|
const config2 = readJson4(settingsFile);
|
|
@@ -35335,7 +35682,7 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
|
35335
35682
|
mergeOurEntries(config2, entries);
|
|
35336
35683
|
writeJsonAtomic(settingsFile, config2);
|
|
35337
35684
|
report.written.push(settingsFile);
|
|
35338
|
-
report.migrated += migrateHooksJson(
|
|
35685
|
+
report.migrated += migrateHooksJson(join64(dirname27(settingsFile), "hooks.json"));
|
|
35339
35686
|
}
|
|
35340
35687
|
if (sel.guard && scripts.guard) report.guardTargets = await addGuardToOtherTools(scriptsDir, scripts.guard);
|
|
35341
35688
|
if (sel.messages && !shellSkipped) {
|
|
@@ -35346,7 +35693,7 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
|
35346
35693
|
return report;
|
|
35347
35694
|
}
|
|
35348
35695
|
function migrateHooksJson(file) {
|
|
35349
|
-
if (!
|
|
35696
|
+
if (!existsSync54(file)) return 0;
|
|
35350
35697
|
const config2 = readJson4(file);
|
|
35351
35698
|
if (!config2) return 0;
|
|
35352
35699
|
const removed = removeOurEntries(config2);
|
|
@@ -35355,11 +35702,11 @@ function migrateHooksJson(file) {
|
|
|
35355
35702
|
else writeJsonAtomic(file, config2);
|
|
35356
35703
|
return removed;
|
|
35357
35704
|
}
|
|
35358
|
-
async function uninstallHooks() {
|
|
35359
|
-
const report = { removed: 0, files: [], guardRemoved: [], messagesRemoved: [] };
|
|
35705
|
+
async function uninstallHooks(deps = {}) {
|
|
35706
|
+
const report = { removed: 0, files: [], guardRemoved: [], messagesRemoved: [], hostRemoved: [] };
|
|
35360
35707
|
for (const settingsFile of claudeSettingsFiles()) {
|
|
35361
|
-
for (const file of [settingsFile,
|
|
35362
|
-
if (!
|
|
35708
|
+
for (const file of [settingsFile, join64(dirname27(settingsFile), "hooks.json")]) {
|
|
35709
|
+
if (!existsSync54(file)) continue;
|
|
35363
35710
|
const config2 = readJson4(file);
|
|
35364
35711
|
if (!config2) continue;
|
|
35365
35712
|
const removed = removeOurEntries(config2);
|
|
@@ -35371,6 +35718,7 @@ async function uninstallHooks() {
|
|
|
35371
35718
|
}
|
|
35372
35719
|
report.guardRemoved = await removeGuardFromOtherTools();
|
|
35373
35720
|
report.messagesRemoved = await removeMessagesFromOtherTools();
|
|
35721
|
+
report.hostRemoved = removeMcpHost(deps);
|
|
35374
35722
|
writeJsonAtomic(statePath(), { version: cliVersion(), selection: ALL_HOOKS, uninstalled: true });
|
|
35375
35723
|
return report;
|
|
35376
35724
|
}
|
|
@@ -35383,26 +35731,26 @@ function profileMissingHooks(settingsFile, sel) {
|
|
|
35383
35731
|
if (Object.values(config2.hooks ?? {}).some((list) => Array.isArray(list) && list.some(isLegacyEntry))) return true;
|
|
35384
35732
|
return false;
|
|
35385
35733
|
}
|
|
35386
|
-
async function ensureHooks(distDir) {
|
|
35734
|
+
async function ensureHooks(distDir, deps = {}) {
|
|
35387
35735
|
const state2 = readState();
|
|
35388
35736
|
if (state2?.uninstalled) return null;
|
|
35389
35737
|
const sel = { ...ALL_HOOKS, ...state2?.selection ?? {} };
|
|
35390
35738
|
const stale = !state2 || state2.version !== cliVersion();
|
|
35391
35739
|
if (!stale && !claudeSettingsFiles().some((f) => profileMissingHooks(f, sel))) return null;
|
|
35392
|
-
return installHooks(distDir, sel);
|
|
35740
|
+
return installHooks(distDir, sel, deps);
|
|
35393
35741
|
}
|
|
35394
35742
|
async function addGuardToOtherTools(scriptsDir, guardScript) {
|
|
35395
35743
|
const reg = await Promise.resolve().then(() => (init_guard_registration(), guard_registration_exports));
|
|
35396
35744
|
const out = [];
|
|
35397
35745
|
removeLegacyAgyGuard(reg);
|
|
35398
35746
|
for (const target of reg.guardTargets()) {
|
|
35399
|
-
if (!
|
|
35400
|
-
const wrapper =
|
|
35401
|
-
|
|
35402
|
-
|
|
35403
|
-
|
|
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 });
|
|
35404
35752
|
if (target.tool === "opencode") {
|
|
35405
|
-
|
|
35753
|
+
writeFileSync20(target.configPath, reg.opencodePluginSource(wrapper));
|
|
35406
35754
|
} else {
|
|
35407
35755
|
const merged = reg.registerGuard(target.tool, readJson4(target.configPath) ?? {}, reg.guardCommand(wrapper));
|
|
35408
35756
|
writeJsonAtomic(target.configPath, merged);
|
|
@@ -35416,9 +35764,9 @@ async function removeGuardFromOtherTools() {
|
|
|
35416
35764
|
const out = [];
|
|
35417
35765
|
removeLegacyAgyGuard(reg);
|
|
35418
35766
|
for (const target of reg.guardTargets()) {
|
|
35419
|
-
if (!
|
|
35767
|
+
if (!existsSync54(target.configPath)) continue;
|
|
35420
35768
|
if (target.tool === "opencode") {
|
|
35421
|
-
if (!
|
|
35769
|
+
if (!readFileSync50(target.configPath, "utf-8").includes("chat-recall install-hooks")) continue;
|
|
35422
35770
|
unlinkSync4(target.configPath);
|
|
35423
35771
|
} else {
|
|
35424
35772
|
const r = reg.unregisterGuard(target.tool, readJson4(target.configPath) ?? {});
|
|
@@ -35431,7 +35779,7 @@ async function removeGuardFromOtherTools() {
|
|
|
35431
35779
|
}
|
|
35432
35780
|
function removeLegacyAgyGuard(reg) {
|
|
35433
35781
|
const file = reg.legacyAgyHooksFile();
|
|
35434
|
-
if (!
|
|
35782
|
+
if (!existsSync54(file)) return;
|
|
35435
35783
|
const r = reg.unregisterGuard("agy", readJson4(file) ?? {});
|
|
35436
35784
|
if (r.removed) writeJsonAtomic(file, r.config);
|
|
35437
35785
|
}
|
|
@@ -35439,16 +35787,16 @@ async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
|
|
|
35439
35787
|
const reg = await Promise.resolve().then(() => (init_message_registration(), message_registration_exports));
|
|
35440
35788
|
const out = [];
|
|
35441
35789
|
for (const target of reg.messageTargets()) {
|
|
35442
|
-
if (!
|
|
35443
|
-
const wrapper =
|
|
35444
|
-
|
|
35445
|
-
|
|
35446
|
-
|
|
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 });
|
|
35447
35795
|
if (target.tool === "opencode") {
|
|
35448
|
-
|
|
35449
|
-
const dir =
|
|
35450
|
-
|
|
35451
|
-
for (const file of reg.opencodeTuiFiles(wrapper))
|
|
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);
|
|
35452
35800
|
const tui = registerTuiPlugin();
|
|
35453
35801
|
if (tui.status === "unparseable") {
|
|
35454
35802
|
out.push({
|
|
@@ -35458,7 +35806,7 @@ async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
|
|
|
35458
35806
|
});
|
|
35459
35807
|
}
|
|
35460
35808
|
} else if (target.tool === "pi") {
|
|
35461
|
-
|
|
35809
|
+
writeFileSync20(target.configPath, reg.piMessagesSource(wrapper));
|
|
35462
35810
|
} else {
|
|
35463
35811
|
const config2 = readJson4(target.configPath);
|
|
35464
35812
|
if (!config2) continue;
|
|
@@ -35474,14 +35822,14 @@ async function removeMessagesFromOtherTools() {
|
|
|
35474
35822
|
const tui = unregisterTuiPlugin();
|
|
35475
35823
|
if (tui.removed) out.push({ label: "OpenCode TUI", configPath: tui.path });
|
|
35476
35824
|
for (const target of reg.messageTargets()) {
|
|
35477
|
-
if (!
|
|
35825
|
+
if (!existsSync54(target.configPath)) continue;
|
|
35478
35826
|
if (target.tool === "opencode" || target.tool === "pi") {
|
|
35479
|
-
if (!reg.isOurPluginSource(
|
|
35827
|
+
if (!reg.isOurPluginSource(readFileSync50(target.configPath, "utf-8"))) continue;
|
|
35480
35828
|
unlinkSync4(target.configPath);
|
|
35481
35829
|
if (target.tool === "opencode") {
|
|
35482
|
-
const dir =
|
|
35483
|
-
const tui2 =
|
|
35484
|
-
if (
|
|
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 });
|
|
35485
35833
|
}
|
|
35486
35834
|
} else {
|
|
35487
35835
|
const config2 = readJson4(target.configPath);
|
|
@@ -35503,6 +35851,7 @@ var init_install_hooks = __esm({
|
|
|
35503
35851
|
init_tool_paths();
|
|
35504
35852
|
init_board_hooks();
|
|
35505
35853
|
init_http();
|
|
35854
|
+
init_mcp_host();
|
|
35506
35855
|
init_opencode_tui_config();
|
|
35507
35856
|
ALL_HOOKS = {
|
|
35508
35857
|
resume: true,
|
|
@@ -35966,14 +36315,14 @@ var verify_repair_exports = {};
|
|
|
35966
36315
|
__export(verify_repair_exports, {
|
|
35967
36316
|
forceFullResync: () => forceFullResync
|
|
35968
36317
|
});
|
|
35969
|
-
import { copyFileSync as
|
|
36318
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync55 } from "fs";
|
|
35970
36319
|
function forceFullResync(server, sessionIds) {
|
|
35971
36320
|
if (sessionIds.length === 0) return 0;
|
|
35972
36321
|
const path = ledgerFilePath();
|
|
35973
|
-
if (
|
|
36322
|
+
if (existsSync55(path)) {
|
|
35974
36323
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "").replace(/-/g, "");
|
|
35975
36324
|
try {
|
|
35976
|
-
|
|
36325
|
+
copyFileSync5(path, `${path}.bak-${stamp}`);
|
|
35977
36326
|
} catch {
|
|
35978
36327
|
}
|
|
35979
36328
|
}
|
|
@@ -36160,8 +36509,8 @@ __export(collector_exports, {
|
|
|
36160
36509
|
});
|
|
36161
36510
|
import { spawn as spawn4 } from "node:child_process";
|
|
36162
36511
|
import { execSync as execSync4 } from "node:child_process";
|
|
36163
|
-
import { readFileSync as
|
|
36164
|
-
import { join as
|
|
36512
|
+
import { readFileSync as readFileSync51 } from "node:fs";
|
|
36513
|
+
import { join as join65, basename as basename28 } from "node:path";
|
|
36165
36514
|
async function resolveCodeindexBin(autoInstall = true) {
|
|
36166
36515
|
let st = checkCodeindexStatus();
|
|
36167
36516
|
if (!st.installed && autoInstall)
|
|
@@ -36343,7 +36692,7 @@ async function collectCode(opts) {
|
|
|
36343
36692
|
}
|
|
36344
36693
|
const complexity = (r) => {
|
|
36345
36694
|
try {
|
|
36346
|
-
const txt =
|
|
36695
|
+
const txt = readFileSync51(join65(ws, r), "utf8");
|
|
36347
36696
|
if (txt.length > 2e6)
|
|
36348
36697
|
return 1;
|
|
36349
36698
|
const m = txt.match(CF_RE);
|
|
@@ -37127,9 +37476,9 @@ __export(project_tasks_exports, {
|
|
|
37127
37476
|
pushProjectTaskStatuses: () => pushProjectTaskStatuses,
|
|
37128
37477
|
renderTeamTasksMd: () => renderTeamTasksMd
|
|
37129
37478
|
});
|
|
37130
|
-
import { existsSync as
|
|
37131
|
-
import { join as
|
|
37132
|
-
import { homedir as
|
|
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";
|
|
37133
37482
|
function isTeamTaskStatus(v) {
|
|
37134
37483
|
return !!v && TEAM_STATUSES.has(v);
|
|
37135
37484
|
}
|
|
@@ -37179,22 +37528,22 @@ function parseTaskFile(content) {
|
|
|
37179
37528
|
return out;
|
|
37180
37529
|
}
|
|
37181
37530
|
function ledgerPath2() {
|
|
37182
|
-
return
|
|
37531
|
+
return join66(homedir24(), ".chat-recall", "project-tasks-ledger.json");
|
|
37183
37532
|
}
|
|
37184
37533
|
function readLedger() {
|
|
37185
37534
|
try {
|
|
37186
|
-
return JSON.parse(
|
|
37535
|
+
return JSON.parse(readFileSync52(ledgerPath2(), "utf8"));
|
|
37187
37536
|
} catch {
|
|
37188
37537
|
return {};
|
|
37189
37538
|
}
|
|
37190
37539
|
}
|
|
37191
37540
|
function writeLedger(l) {
|
|
37192
37541
|
try {
|
|
37193
|
-
|
|
37542
|
+
mkdirSync20(dirname28(ledgerPath2()), { recursive: true });
|
|
37194
37543
|
} catch {
|
|
37195
37544
|
}
|
|
37196
37545
|
try {
|
|
37197
|
-
|
|
37546
|
+
writeFileSync21(ledgerPath2(), JSON.stringify(l));
|
|
37198
37547
|
} catch {
|
|
37199
37548
|
}
|
|
37200
37549
|
}
|
|
@@ -37212,8 +37561,8 @@ async function pushProjectTaskStatuses(base4, authHeaders, opts = {}) {
|
|
|
37212
37561
|
continue;
|
|
37213
37562
|
}
|
|
37214
37563
|
for (const project of projects) {
|
|
37215
|
-
const file =
|
|
37216
|
-
if (!
|
|
37564
|
+
const file = join66(project, fk.filename);
|
|
37565
|
+
if (!existsSync56(file)) continue;
|
|
37217
37566
|
let mtime;
|
|
37218
37567
|
try {
|
|
37219
37568
|
mtime = statSync46(file).mtimeMs;
|
|
@@ -37223,7 +37572,7 @@ async function pushProjectTaskStatuses(base4, authHeaders, opts = {}) {
|
|
|
37223
37572
|
if (ledger[file] === mtime) continue;
|
|
37224
37573
|
let changed;
|
|
37225
37574
|
try {
|
|
37226
|
-
changed = parseTaskFile(
|
|
37575
|
+
changed = parseTaskFile(readFileSync52(file, "utf8")).filter((t) => t.kind === fk.kind);
|
|
37227
37576
|
} catch {
|
|
37228
37577
|
continue;
|
|
37229
37578
|
}
|
|
@@ -37296,10 +37645,10 @@ __export(intent_drain_exports, {
|
|
|
37296
37645
|
instructionTargets: () => instructionTargets,
|
|
37297
37646
|
runIntent: () => runIntent
|
|
37298
37647
|
});
|
|
37299
|
-
import { existsSync as
|
|
37300
|
-
import { join as
|
|
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";
|
|
37301
37650
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
37302
|
-
import { dirname as
|
|
37651
|
+
import { dirname as dirname29 } from "node:path";
|
|
37303
37652
|
function instructionTargets(rootPath, isGlobal) {
|
|
37304
37653
|
const installed = INSTRUCTION_TOOLS.filter((t) => {
|
|
37305
37654
|
try {
|
|
@@ -37311,17 +37660,17 @@ function instructionTargets(rootPath, isGlobal) {
|
|
|
37311
37660
|
const tools = installed.length ? installed : [INSTRUCTION_TOOLS[0]];
|
|
37312
37661
|
if (isGlobal) return [...new Set(tools.map((t) => instructionsPath(t.id)))];
|
|
37313
37662
|
if (!rootPath) return [];
|
|
37314
|
-
const present = INSTRUCTION_FILENAMES.map((f) =>
|
|
37663
|
+
const present = INSTRUCTION_FILENAMES.map((f) => join67(rootPath, f)).filter((p) => existsSync57(p));
|
|
37315
37664
|
if (present.length) return present;
|
|
37316
|
-
return [...new Set(tools.map((t) =>
|
|
37665
|
+
return [...new Set(tools.map((t) => join67(rootPath, instructionsFilename(t.id))))];
|
|
37317
37666
|
}
|
|
37318
37667
|
function applyCodeRecommendation(intent) {
|
|
37319
37668
|
try {
|
|
37320
37669
|
const meta = JSON.parse(intent.name || "{}");
|
|
37321
37670
|
if (intent.artifact_type === "write_tasks_file") {
|
|
37322
37671
|
if (!meta.rootPath || !meta.content) return { status: "error", result: JSON.stringify({ error: "missing rootPath or content" }) };
|
|
37323
|
-
const file =
|
|
37324
|
-
|
|
37672
|
+
const file = join67(meta.rootPath, meta.filename || "CODE_TASKS.md");
|
|
37673
|
+
writeFileSync22(file, meta.content);
|
|
37325
37674
|
return { status: "done", result: JSON.stringify({ wrote: file }) };
|
|
37326
37675
|
}
|
|
37327
37676
|
if (intent.artifact_type === "append_claude_md") {
|
|
@@ -37336,10 +37685,10 @@ function applyCodeRecommendation(intent) {
|
|
|
37336
37685
|
for (const file of targets) {
|
|
37337
37686
|
const dir = file.slice(0, file.lastIndexOf("/"));
|
|
37338
37687
|
try {
|
|
37339
|
-
|
|
37688
|
+
mkdirSync21(dir, { recursive: true });
|
|
37340
37689
|
} catch {
|
|
37341
37690
|
}
|
|
37342
|
-
const existing =
|
|
37691
|
+
const existing = existsSync57(file) ? readFileSync53(file, "utf8") : "";
|
|
37343
37692
|
if (existing.includes(text)) {
|
|
37344
37693
|
skipped.push(file);
|
|
37345
37694
|
continue;
|
|
@@ -37349,7 +37698,7 @@ function applyCodeRecommendation(intent) {
|
|
|
37349
37698
|
${text}
|
|
37350
37699
|
`;
|
|
37351
37700
|
if (existing) appendFileSync(file, block);
|
|
37352
|
-
else
|
|
37701
|
+
else writeFileSync22(file, `# ${meta.rootPath?.split("/").pop() || "Global"} instructions
|
|
37353
37702
|
${block}`);
|
|
37354
37703
|
appended.push(file);
|
|
37355
37704
|
}
|
|
@@ -37524,11 +37873,11 @@ var init_intent_drain = __esm({
|
|
|
37524
37873
|
];
|
|
37525
37874
|
ownVersion2 = "0.0.0";
|
|
37526
37875
|
try {
|
|
37527
|
-
const dir =
|
|
37528
|
-
ownVersion2 = JSON.parse(
|
|
37876
|
+
const dir = dirname29(fileURLToPath4(import.meta.url));
|
|
37877
|
+
ownVersion2 = JSON.parse(readFileSync53(join67(dir, "../package.json"), "utf-8")).version || ownVersion2;
|
|
37529
37878
|
} catch {
|
|
37530
37879
|
try {
|
|
37531
|
-
if (
|
|
37880
|
+
if (typeof __CLI_VERSION__ === "string") ownVersion2 = __CLI_VERSION__;
|
|
37532
37881
|
} catch {
|
|
37533
37882
|
}
|
|
37534
37883
|
}
|
|
@@ -37729,48 +38078,48 @@ var team_merge_exports = {};
|
|
|
37729
38078
|
__export(team_merge_exports, {
|
|
37730
38079
|
mergePullResult: () => mergePullResult
|
|
37731
38080
|
});
|
|
37732
|
-
import { existsSync as
|
|
37733
|
-
import { dirname as
|
|
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";
|
|
37734
38083
|
import { createHash as createHash17 } from "crypto";
|
|
37735
38084
|
function installPathFor(art, tool) {
|
|
37736
38085
|
switch (art.type) {
|
|
37737
38086
|
case "skill":
|
|
37738
38087
|
switch (tool) {
|
|
37739
38088
|
case "claude":
|
|
37740
|
-
return
|
|
38089
|
+
return join68(claudeBackend.skillsDir(), art.name, "SKILL.md");
|
|
37741
38090
|
// Antigravity's OWN skills dir. It used to resolve to the shared
|
|
37742
38091
|
// ~/.gemini/skills while toolkit-sync installed to
|
|
37743
38092
|
// ~/.gemini/antigravity-cli/skills, so a team skill landed in one place
|
|
37744
38093
|
// and a synced skill in the other.
|
|
37745
38094
|
case "agy":
|
|
37746
|
-
return
|
|
38095
|
+
return join68(agyBackend.homeDir(), "skills", art.name, "SKILL.md");
|
|
37747
38096
|
case "opencode":
|
|
37748
|
-
return
|
|
38097
|
+
return join68(opencodeBackend.skillsDir(), art.name, "SKILL.md");
|
|
37749
38098
|
// User skills go to ~/.codex/skills (NOT .system, which is OpenAI's bundle).
|
|
37750
38099
|
case "codex":
|
|
37751
|
-
return
|
|
38100
|
+
return join68(codexBackend.skillsDir(), art.name, "SKILL.md");
|
|
37752
38101
|
case "cursor":
|
|
37753
|
-
return
|
|
38102
|
+
return join68(cursorHomeDir(), "skills", art.name, "SKILL.md");
|
|
37754
38103
|
}
|
|
37755
38104
|
break;
|
|
37756
38105
|
case "agent":
|
|
37757
38106
|
if (tool === "claude")
|
|
37758
|
-
return
|
|
38107
|
+
return join68(claudeBackend.agentsDir(), `${art.name}.md`);
|
|
37759
38108
|
return null;
|
|
37760
38109
|
case "command":
|
|
37761
38110
|
if (tool === "claude")
|
|
37762
|
-
return
|
|
38111
|
+
return join68(claudeBackend.commandsDir(), `${art.name}.md`);
|
|
37763
38112
|
return null;
|
|
37764
38113
|
case "hook":
|
|
37765
38114
|
if (tool === "claude")
|
|
37766
|
-
return
|
|
38115
|
+
return join68(claudeBackend.homeDir(), "chat-recall-hooks", `${art.name}.json`);
|
|
37767
38116
|
return null;
|
|
37768
38117
|
case "plan":
|
|
37769
38118
|
switch (tool) {
|
|
37770
38119
|
case "claude":
|
|
37771
|
-
return
|
|
38120
|
+
return join68(claudeBackend.plansDir(), `${art.name}.md`);
|
|
37772
38121
|
case "opencode":
|
|
37773
|
-
return
|
|
38122
|
+
return join68(opencodeBackend.plansDir(), `${art.name}.md`);
|
|
37774
38123
|
case "agy":
|
|
37775
38124
|
return null;
|
|
37776
38125
|
// Antigravity plans live per-session
|
|
@@ -37781,11 +38130,11 @@ function installPathFor(art, tool) {
|
|
|
37781
38130
|
}
|
|
37782
38131
|
break;
|
|
37783
38132
|
case "instructions":
|
|
37784
|
-
return
|
|
38133
|
+
return join68(getDataDir(), "team-instructions", tool, `${art.name}.md`);
|
|
37785
38134
|
case "mcp":
|
|
37786
|
-
return
|
|
38135
|
+
return join68(getDataDir(), "team-mcps", `${art.name}.json`);
|
|
37787
38136
|
case "plugin":
|
|
37788
|
-
return
|
|
38137
|
+
return join68(getDataDir(), "team-plugins", tool, art.name, "manifest.json");
|
|
37789
38138
|
}
|
|
37790
38139
|
return null;
|
|
37791
38140
|
}
|
|
@@ -37824,8 +38173,8 @@ async function mergePullResult(opts) {
|
|
|
37824
38173
|
pending.push({ artifactId: a.id, tool, artifactType: a.type, artifactName: a.name, sha256: sha, installedAt: Date.now() });
|
|
37825
38174
|
continue;
|
|
37826
38175
|
}
|
|
37827
|
-
|
|
37828
|
-
|
|
38176
|
+
mkdirSync22(dirname30(path), { recursive: true });
|
|
38177
|
+
writeFileSync23(path, body2);
|
|
37829
38178
|
pending.push({ artifactId: a.id, tool, artifactType: a.type, artifactName: a.name, sha256: sha, installedAt: Date.now() });
|
|
37830
38179
|
report.written.push({ artifactId: a.id, path });
|
|
37831
38180
|
} catch (err) {
|
|
@@ -37846,7 +38195,7 @@ async function mergePullResult(opts) {
|
|
|
37846
38195
|
if (!path)
|
|
37847
38196
|
continue;
|
|
37848
38197
|
try {
|
|
37849
|
-
if (
|
|
38198
|
+
if (existsSync58(path))
|
|
37850
38199
|
rmSync11(path, { force: true });
|
|
37851
38200
|
await teamInstallsForget(id, row.tool);
|
|
37852
38201
|
report.removed.push({ artifactId: id, path });
|
|
@@ -37864,12 +38213,12 @@ async function mergePullResult(opts) {
|
|
|
37864
38213
|
}
|
|
37865
38214
|
function readFileIfExists(path) {
|
|
37866
38215
|
try {
|
|
37867
|
-
if (!
|
|
38216
|
+
if (!existsSync58(path))
|
|
37868
38217
|
return null;
|
|
37869
38218
|
const s = statSync47(path);
|
|
37870
38219
|
if (!s.isFile())
|
|
37871
38220
|
return null;
|
|
37872
|
-
return
|
|
38221
|
+
return readFileSync54(path);
|
|
37873
38222
|
} catch {
|
|
37874
38223
|
return null;
|
|
37875
38224
|
}
|
|
@@ -37950,8 +38299,8 @@ var init_vault_crypto = __esm({
|
|
|
37950
38299
|
});
|
|
37951
38300
|
|
|
37952
38301
|
// ../engine/dist/core/vault-source.js
|
|
37953
|
-
import { existsSync as
|
|
37954
|
-
import { extname, join as
|
|
38302
|
+
import { existsSync as existsSync59, readdirSync as readdirSync35, statSync as statSync48 } from "fs";
|
|
38303
|
+
import { extname, join as join69 } from "path";
|
|
37955
38304
|
function* walkVaultSources() {
|
|
37956
38305
|
const t = loadSettings().team.vault;
|
|
37957
38306
|
const include2 = new Set(t.syncTools);
|
|
@@ -37976,7 +38325,7 @@ function safeStat(path) {
|
|
|
37976
38325
|
}
|
|
37977
38326
|
function* walkClaude() {
|
|
37978
38327
|
const root = claudeBackend.projectsDir();
|
|
37979
|
-
if (!
|
|
38328
|
+
if (!existsSync59(root))
|
|
37980
38329
|
return;
|
|
37981
38330
|
let projectDirs = [];
|
|
37982
38331
|
try {
|
|
@@ -37988,7 +38337,7 @@ function* walkClaude() {
|
|
|
37988
38337
|
if (proj.startsWith("."))
|
|
37989
38338
|
continue;
|
|
37990
38339
|
const projectPath = resolveProjectDirName(proj);
|
|
37991
|
-
const projDir =
|
|
38340
|
+
const projDir = join69(root, proj);
|
|
37992
38341
|
let entries = [];
|
|
37993
38342
|
try {
|
|
37994
38343
|
entries = readdirSync35(projDir);
|
|
@@ -37998,7 +38347,7 @@ function* walkClaude() {
|
|
|
37998
38347
|
for (const f of entries) {
|
|
37999
38348
|
if (extname(f) !== ".jsonl")
|
|
38000
38349
|
continue;
|
|
38001
|
-
const path =
|
|
38350
|
+
const path = join69(projDir, f);
|
|
38002
38351
|
const s = safeStat(path);
|
|
38003
38352
|
if (!s)
|
|
38004
38353
|
continue;
|
|
@@ -38028,8 +38377,8 @@ function* walkCursor() {
|
|
|
38028
38377
|
}
|
|
38029
38378
|
}
|
|
38030
38379
|
function* walkCodex() {
|
|
38031
|
-
const sessionsRoot =
|
|
38032
|
-
if (!
|
|
38380
|
+
const sessionsRoot = join69(codexBackend.homeDir(), "sessions");
|
|
38381
|
+
if (!existsSync59(sessionsRoot))
|
|
38033
38382
|
return;
|
|
38034
38383
|
const stack = [sessionsRoot];
|
|
38035
38384
|
while (stack.length) {
|
|
@@ -38041,7 +38390,7 @@ function* walkCodex() {
|
|
|
38041
38390
|
continue;
|
|
38042
38391
|
}
|
|
38043
38392
|
for (const e of entries) {
|
|
38044
|
-
const path =
|
|
38393
|
+
const path = join69(dir, e.name);
|
|
38045
38394
|
if (e.isDirectory()) {
|
|
38046
38395
|
stack.push(path);
|
|
38047
38396
|
continue;
|
|
@@ -38057,8 +38406,8 @@ function* walkCodex() {
|
|
|
38057
38406
|
}
|
|
38058
38407
|
}
|
|
38059
38408
|
function* walkAgy() {
|
|
38060
|
-
const brainDir =
|
|
38061
|
-
if (!
|
|
38409
|
+
const brainDir = join69(agyBackend.homeDir(), "brain");
|
|
38410
|
+
if (!existsSync59(brainDir))
|
|
38062
38411
|
return;
|
|
38063
38412
|
let sessionDirs = [];
|
|
38064
38413
|
try {
|
|
@@ -38067,18 +38416,18 @@ function* walkAgy() {
|
|
|
38067
38416
|
return;
|
|
38068
38417
|
}
|
|
38069
38418
|
for (const rawId of sessionDirs) {
|
|
38070
|
-
const sessionPath =
|
|
38419
|
+
const sessionPath = join69(brainDir, rawId);
|
|
38071
38420
|
try {
|
|
38072
38421
|
if (!statSync48(sessionPath).isDirectory())
|
|
38073
38422
|
continue;
|
|
38074
38423
|
} catch {
|
|
38075
38424
|
continue;
|
|
38076
38425
|
}
|
|
38077
|
-
let filePath =
|
|
38078
|
-
if (!
|
|
38079
|
-
filePath =
|
|
38426
|
+
let filePath = join69(sessionPath, ".system_generated", "logs", "transcript.jsonl");
|
|
38427
|
+
if (!existsSync59(filePath)) {
|
|
38428
|
+
filePath = join69(sessionPath, ".system_generated", "logs", "transcript_full.jsonl");
|
|
38080
38429
|
}
|
|
38081
|
-
if (!
|
|
38430
|
+
if (!existsSync59(filePath))
|
|
38082
38431
|
continue;
|
|
38083
38432
|
const s = safeStat(filePath);
|
|
38084
38433
|
if (!s)
|
|
@@ -38114,8 +38463,8 @@ __export(vault_client_exports, {
|
|
|
38114
38463
|
vaultStatus: () => vaultStatus,
|
|
38115
38464
|
vaultSync: () => vaultSync
|
|
38116
38465
|
});
|
|
38117
|
-
import { mkdirSync as
|
|
38118
|
-
import { dirname as
|
|
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";
|
|
38119
38468
|
function context2() {
|
|
38120
38469
|
const s = loadSettings().team;
|
|
38121
38470
|
if (!s.enabled)
|
|
@@ -38254,7 +38603,7 @@ async function vaultSync(passphrase) {
|
|
|
38254
38603
|
continue;
|
|
38255
38604
|
}
|
|
38256
38605
|
try {
|
|
38257
|
-
const plaintext =
|
|
38606
|
+
const plaintext = readFileSync55(src.path);
|
|
38258
38607
|
const sourceSha = sha256Hex(plaintext);
|
|
38259
38608
|
const priorSha = uploaded.get(uploadKey(src.sessionId, src.tool));
|
|
38260
38609
|
if (priorSha === sourceSha) {
|
|
@@ -38306,7 +38655,7 @@ async function vaultSync(passphrase) {
|
|
|
38306
38655
|
}
|
|
38307
38656
|
function importedPathFor(tool, sessionId) {
|
|
38308
38657
|
const base4 = sessionId.replace(/^gemini_/, "").replace(/^codex_/, "").replace(/^agy_/, "").replace(/^cursor_/, "").replace(/^opencode_/, "");
|
|
38309
|
-
return
|
|
38658
|
+
return join70(IMPORTED_ROOT(), tool, `${base4}.jsonl`);
|
|
38310
38659
|
}
|
|
38311
38660
|
async function vaultRestore(passphrase, opts = {}) {
|
|
38312
38661
|
const ctx = context2();
|
|
@@ -38327,7 +38676,7 @@ async function vaultRestore(passphrase, opts = {}) {
|
|
|
38327
38676
|
}
|
|
38328
38677
|
try {
|
|
38329
38678
|
const path = importedPathFor(blob.tool, blob.sessionId);
|
|
38330
|
-
if (
|
|
38679
|
+
if (existsSync60(path)) {
|
|
38331
38680
|
const localStat = await import("fs").then((m) => m.statSync(path));
|
|
38332
38681
|
if (Math.abs(localStat.mtimeMs - blob.mtimeSourceMs) < 1) {
|
|
38333
38682
|
report.skipped.push({ sessionId: blob.sessionId, tool: blob.tool, reason: "unchanged" });
|
|
@@ -38343,8 +38692,8 @@ async function vaultRestore(passphrase, opts = {}) {
|
|
|
38343
38692
|
throw new Error("cipher integrity check failed");
|
|
38344
38693
|
}
|
|
38345
38694
|
const plaintext = decryptBlob(key2, cipher);
|
|
38346
|
-
|
|
38347
|
-
|
|
38695
|
+
mkdirSync23(dirname31(path), { recursive: true });
|
|
38696
|
+
writeFileSync24(path, Buffer.from(plaintext));
|
|
38348
38697
|
const { utimesSync } = await import("fs");
|
|
38349
38698
|
const t = blob.mtimeSourceMs / 1e3;
|
|
38350
38699
|
utimesSync(path, t, t);
|
|
@@ -38395,7 +38744,7 @@ var init_vault_client = __esm({
|
|
|
38395
38744
|
uploadKey = (sessionId, tool) => `${sessionId}\0${tool}`;
|
|
38396
38745
|
VaultPassphraseMismatchError = class extends Error {
|
|
38397
38746
|
};
|
|
38398
|
-
IMPORTED_ROOT = () =>
|
|
38747
|
+
IMPORTED_ROOT = () => join70(getDataDir(), "imported");
|
|
38399
38748
|
}
|
|
38400
38749
|
});
|
|
38401
38750
|
|
|
@@ -38947,6 +39296,7 @@ var init_task_hook = __esm({
|
|
|
38947
39296
|
var service_installer_exports = {};
|
|
38948
39297
|
__export(service_installer_exports, {
|
|
38949
39298
|
ServiceInstallError: () => ServiceInstallError,
|
|
39299
|
+
WATCH_HEAP_MB: () => WATCH_HEAP_MB,
|
|
38950
39300
|
installService: () => installService,
|
|
38951
39301
|
isServiceRunning: () => isServiceRunning,
|
|
38952
39302
|
platformName: () => platformName,
|
|
@@ -38957,15 +39307,15 @@ __export(service_installer_exports, {
|
|
|
38957
39307
|
uninstallService: () => uninstallService
|
|
38958
39308
|
});
|
|
38959
39309
|
import { execSync as execSync5 } from "child_process";
|
|
38960
|
-
import { existsSync as
|
|
38961
|
-
import { homedir as
|
|
38962
|
-
import { join as
|
|
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";
|
|
38963
39313
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
38964
39314
|
function resolveDaemonPaths() {
|
|
38965
39315
|
const watchJs = fileURLToPath5(new URL("./watch.js", import.meta.url));
|
|
38966
39316
|
const node = process.execPath;
|
|
38967
|
-
const dataDir =
|
|
38968
|
-
const logFile =
|
|
39317
|
+
const dataDir = join71(homedir25(), ".chat-recall");
|
|
39318
|
+
const logFile = join71(dataDir, "watch.log");
|
|
38969
39319
|
return { watchJs, node, logFile, dataDir };
|
|
38970
39320
|
}
|
|
38971
39321
|
function tryCmd(cmd) {
|
|
@@ -38992,13 +39342,13 @@ function refreshServiceDefinition() {
|
|
|
38992
39342
|
if (process.platform !== "linux") return false;
|
|
38993
39343
|
try {
|
|
38994
39344
|
const { watchJs, node, logFile } = resolveDaemonPaths();
|
|
38995
|
-
const unitPath =
|
|
38996
|
-
if (!
|
|
38997
|
-
const current =
|
|
39345
|
+
const unitPath = join71(homedir25(), ".config", "systemd", "user", "chat-recall-watch.service");
|
|
39346
|
+
if (!existsSync61(unitPath)) return false;
|
|
39347
|
+
const current = readFileSync56(unitPath, "utf8");
|
|
38998
39348
|
if (!current.includes(watchJs)) return false;
|
|
38999
39349
|
const wanted = renderSystemdUnit(watchJs, node, logFile);
|
|
39000
|
-
if (
|
|
39001
|
-
|
|
39350
|
+
if (readFileSync56(unitPath, "utf8") === wanted) return false;
|
|
39351
|
+
writeFileSync25(unitPath, wanted);
|
|
39002
39352
|
execSync5("systemctl --user daemon-reload", { stdio: "ignore" });
|
|
39003
39353
|
return true;
|
|
39004
39354
|
} catch {
|
|
@@ -39007,7 +39357,7 @@ function refreshServiceDefinition() {
|
|
|
39007
39357
|
}
|
|
39008
39358
|
function installService() {
|
|
39009
39359
|
const { watchJs, node, logFile, dataDir } = resolveDaemonPaths();
|
|
39010
|
-
|
|
39360
|
+
mkdirSync24(dataDir, { recursive: true });
|
|
39011
39361
|
if (process.platform === "linux") {
|
|
39012
39362
|
return installSystemd(watchJs, node, logFile);
|
|
39013
39363
|
}
|
|
@@ -39023,11 +39373,11 @@ function installService() {
|
|
|
39023
39373
|
);
|
|
39024
39374
|
}
|
|
39025
39375
|
function installSystemd(watchJs, node, logFile) {
|
|
39026
|
-
const unitDir =
|
|
39027
|
-
const unitPath =
|
|
39376
|
+
const unitDir = join71(homedir25(), ".config", "systemd", "user");
|
|
39377
|
+
const unitPath = join71(unitDir, "chat-recall-watch.service");
|
|
39028
39378
|
const unit = renderSystemdUnit(watchJs, node, logFile);
|
|
39029
|
-
|
|
39030
|
-
|
|
39379
|
+
mkdirSync24(unitDir, { recursive: true });
|
|
39380
|
+
writeFileSync25(unitPath, unit);
|
|
39031
39381
|
try {
|
|
39032
39382
|
execSync5("systemctl --user daemon-reload && systemctl --user enable chat-recall-watch.service && systemctl --user restart chat-recall-watch.service", { stdio: "inherit" });
|
|
39033
39383
|
try {
|
|
@@ -39057,9 +39407,8 @@ function renderSystemdUnit(watchJs, node, logFile) {
|
|
|
39057
39407
|
// Bounded heap: the daemon does bursty batch work (transcript parse,
|
|
39058
39408
|
// base64 payloads); V8's default old-space on a big-RAM box is ~4GB and
|
|
39059
39409
|
// GC only gets aggressive near the ceiling — observed as a multi-GB RSS
|
|
39060
|
-
// sawtooth.
|
|
39061
|
-
|
|
39062
|
-
`ExecStart=${node} --max-old-space-size=1536 ${watchJs}`,
|
|
39410
|
+
// sawtooth. The ceiling below is measured, not guessed: see WATCH_HEAP_MB.
|
|
39411
|
+
`ExecStart=${node} --max-old-space-size=${WATCH_HEAP_MB} --expose-gc ${watchJs}`,
|
|
39063
39412
|
// ALWAYS: the collector never ends its own work, so any exit systemd did
|
|
39064
39413
|
// not ask for is a fault. Under on-failure a clean exit left it dead: on
|
|
39065
39414
|
// 2026-09-16 the unit went "inactive (dead) … status=0/SUCCESS" and stayed
|
|
@@ -39110,11 +39459,11 @@ function renderSystemdUnit(watchJs, node, logFile) {
|
|
|
39110
39459
|
}
|
|
39111
39460
|
function installLaunchd(watchJs, node, logFile) {
|
|
39112
39461
|
const label = "com.chat-recall.watch";
|
|
39113
|
-
const plistDir =
|
|
39114
|
-
const plistPath =
|
|
39462
|
+
const plistDir = join71(homedir25(), "Library", "LaunchAgents");
|
|
39463
|
+
const plistPath = join71(plistDir, `${label}.plist`);
|
|
39115
39464
|
const plist = renderLaunchdPlist(watchJs, node, logFile, label);
|
|
39116
|
-
|
|
39117
|
-
|
|
39465
|
+
mkdirSync24(plistDir, { recursive: true });
|
|
39466
|
+
writeFileSync25(plistPath, plist);
|
|
39118
39467
|
try {
|
|
39119
39468
|
try {
|
|
39120
39469
|
execSync5(`launchctl unload "${plistPath}"`, { stdio: "ignore" });
|
|
@@ -39132,7 +39481,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
|
|
|
39132
39481
|
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
39133
39482
|
'<plist version="1.0"><dict>',
|
|
39134
39483
|
` <key>Label</key><string>${label}</string>`,
|
|
39135
|
-
` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size
|
|
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>`,
|
|
39136
39485
|
" <key>RunAtLoad</key><true/>",
|
|
39137
39486
|
" <key>KeepAlive</key><true/>",
|
|
39138
39487
|
` <key>StandardOutPath</key><string>${logFile}</string>`,
|
|
@@ -39143,7 +39492,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
|
|
|
39143
39492
|
}
|
|
39144
39493
|
function installWindowsTask(watchJs, node, logFile) {
|
|
39145
39494
|
const taskName = "chat-recall-watch";
|
|
39146
|
-
const tr = `cmd /c \\"\\"${node}\\" --max-old-space-size
|
|
39495
|
+
const tr = `cmd /c \\"\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"`;
|
|
39147
39496
|
try {
|
|
39148
39497
|
execSync5(`schtasks /create /tn "${taskName}" /tr "${tr}" /sc onlogon /rl LIMITED /f`, { stdio: "inherit" });
|
|
39149
39498
|
try {
|
|
@@ -39156,7 +39505,7 @@ function installWindowsTask(watchJs, node, logFile) {
|
|
|
39156
39505
|
return { definitionPath: null, logFile };
|
|
39157
39506
|
}
|
|
39158
39507
|
function renderWindowsTaskCommand(watchJs, node, taskName = "chat-recall-watch", logFile) {
|
|
39159
|
-
const tr = logFile ? `cmd /c \\"\\"${node}\\" --max-old-space-size
|
|
39508
|
+
const tr = logFile ? `cmd /c \\"\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"` : `\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\"`;
|
|
39160
39509
|
return `schtasks /create /tn "${taskName}" /tr "${tr}" /sc onlogon /rl LIMITED /f`;
|
|
39161
39510
|
}
|
|
39162
39511
|
function uninstallService() {
|
|
@@ -39167,8 +39516,8 @@ function uninstallService() {
|
|
|
39167
39516
|
removed = true;
|
|
39168
39517
|
} catch {
|
|
39169
39518
|
}
|
|
39170
|
-
const unitPath =
|
|
39171
|
-
if (
|
|
39519
|
+
const unitPath = join71(homedir25(), ".config", "systemd", "user", "chat-recall-watch.service");
|
|
39520
|
+
if (existsSync61(unitPath)) {
|
|
39172
39521
|
rmSync12(unitPath, { force: true });
|
|
39173
39522
|
removed = true;
|
|
39174
39523
|
}
|
|
@@ -39179,13 +39528,13 @@ function uninstallService() {
|
|
|
39179
39528
|
return removed;
|
|
39180
39529
|
}
|
|
39181
39530
|
if (process.platform === "darwin") {
|
|
39182
|
-
const plistPath =
|
|
39531
|
+
const plistPath = join71(homedir25(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
|
|
39183
39532
|
try {
|
|
39184
39533
|
execSync5(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
|
|
39185
39534
|
} catch {
|
|
39186
39535
|
}
|
|
39187
39536
|
let removed = false;
|
|
39188
|
-
if (
|
|
39537
|
+
if (existsSync61(plistPath)) {
|
|
39189
39538
|
rmSync12(plistPath, { force: true });
|
|
39190
39539
|
removed = true;
|
|
39191
39540
|
}
|
|
@@ -39207,10 +39556,11 @@ function platformName() {
|
|
|
39207
39556
|
if (process.platform === "win32") return "Scheduled Task";
|
|
39208
39557
|
return process.platform;
|
|
39209
39558
|
}
|
|
39210
|
-
var ServiceInstallError;
|
|
39559
|
+
var WATCH_HEAP_MB, ServiceInstallError;
|
|
39211
39560
|
var init_service_installer = __esm({
|
|
39212
39561
|
"src/service-installer.ts"() {
|
|
39213
39562
|
"use strict";
|
|
39563
|
+
WATCH_HEAP_MB = 640;
|
|
39214
39564
|
ServiceInstallError = class extends Error {
|
|
39215
39565
|
hint;
|
|
39216
39566
|
constructor(message, hint) {
|
|
@@ -39265,6 +39615,47 @@ var init_install_report = __esm({
|
|
|
39265
39615
|
}
|
|
39266
39616
|
});
|
|
39267
39617
|
|
|
39618
|
+
// ../engine/dist/core/remote-target.js
|
|
39619
|
+
var remote_target_exports = {};
|
|
39620
|
+
__export(remote_target_exports, {
|
|
39621
|
+
recallTarget: () => recallTarget
|
|
39622
|
+
});
|
|
39623
|
+
import { readFileSync as readFileSync57 } from "node:fs";
|
|
39624
|
+
import { join as join72 } from "node:path";
|
|
39625
|
+
function recallTarget() {
|
|
39626
|
+
const fromEnv = envCredentials();
|
|
39627
|
+
if (fromEnv)
|
|
39628
|
+
return { base: fromEnv.serverUrl, token: fromEnv.token };
|
|
39629
|
+
try {
|
|
39630
|
+
const raw = readFileSync57(join72(getDataDir(), "credentials.json"), "utf-8");
|
|
39631
|
+
const parsed = JSON.parse(raw);
|
|
39632
|
+
if (Array.isArray(parsed.targets) && parsed.targets.length) {
|
|
39633
|
+
const valid = parsed.targets.filter((t) => t?.serverUrl);
|
|
39634
|
+
if (!valid.length)
|
|
39635
|
+
return null;
|
|
39636
|
+
const norm = (u) => u.replace(/\/+$/, "");
|
|
39637
|
+
const isLocal = (u) => /\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/.test(u);
|
|
39638
|
+
const byUrl = (u) => u ? valid.find((t) => norm(t.serverUrl) === norm(u)) : void 0;
|
|
39639
|
+
const remotes = valid.filter((t) => !isLocal(t.serverUrl));
|
|
39640
|
+
const pick = byUrl(process.env.CHAT_RECALL_SERVER) ?? byUrl(parsed.primary) ?? remotes[0] ?? valid[0];
|
|
39641
|
+
return pick?.serverUrl ? { base: norm(pick.serverUrl), token: targetToken(pick) } : null;
|
|
39642
|
+
}
|
|
39643
|
+
if (parsed.serverUrl)
|
|
39644
|
+
return { base: parsed.serverUrl.replace(/\/+$/, ""), token: parsed.token || "" };
|
|
39645
|
+
return null;
|
|
39646
|
+
} catch {
|
|
39647
|
+
return null;
|
|
39648
|
+
}
|
|
39649
|
+
}
|
|
39650
|
+
var init_remote_target = __esm({
|
|
39651
|
+
"../engine/dist/core/remote-target.js"() {
|
|
39652
|
+
"use strict";
|
|
39653
|
+
init_credentials_env();
|
|
39654
|
+
init_data_dir();
|
|
39655
|
+
init_stored_token();
|
|
39656
|
+
}
|
|
39657
|
+
});
|
|
39658
|
+
|
|
39268
39659
|
// src/bulk-delete.ts
|
|
39269
39660
|
var bulk_delete_exports = {};
|
|
39270
39661
|
__export(bulk_delete_exports, {
|
|
@@ -39563,9 +39954,9 @@ init_project_resolver();
|
|
|
39563
39954
|
import { config } from "dotenv";
|
|
39564
39955
|
import { Command } from "commander";
|
|
39565
39956
|
import chalk2 from "chalk";
|
|
39566
|
-
import { existsSync as
|
|
39567
|
-
import { homedir as
|
|
39568
|
-
import { join as
|
|
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";
|
|
39569
39960
|
|
|
39570
39961
|
// ../engine/dist/core/score-tier.js
|
|
39571
39962
|
var STRONG_RATIO = 0.85;
|
|
@@ -39809,13 +40200,13 @@ async function serverDelete(path, body2) {
|
|
|
39809
40200
|
}
|
|
39810
40201
|
var pkgEngines = (() => {
|
|
39811
40202
|
try {
|
|
39812
|
-
return JSON.parse(
|
|
40203
|
+
return JSON.parse(readFileSync58(new URL("../package.json", import.meta.url), "utf-8")).engines?.node ?? "";
|
|
39813
40204
|
} catch {
|
|
39814
40205
|
return "";
|
|
39815
40206
|
}
|
|
39816
40207
|
})();
|
|
39817
40208
|
var pkgVersion = JSON.parse(
|
|
39818
|
-
|
|
40209
|
+
readFileSync58(new URL("../package.json", import.meta.url), "utf-8")
|
|
39819
40210
|
).version;
|
|
39820
40211
|
var DEFAULT_SERVER = (process.env.CHAT_RECALL_DEFAULT_SERVER || "https://chatrecall.dev").replace(/\/+$/, "");
|
|
39821
40212
|
var DEFAULT_ALLOW = [
|
|
@@ -39995,10 +40386,9 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
39995
40386
|
} else if (target) {
|
|
39996
40387
|
}
|
|
39997
40388
|
if (!options.skipMcp) {
|
|
39998
|
-
const projectRoot =
|
|
39999
|
-
|
|
40000
|
-
|
|
40001
|
-
const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: "node", args: [join70(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")] };
|
|
40002
40392
|
const MCP_ENV = { NODE_OPTIONS: "--max-old-space-size=1024" };
|
|
40003
40393
|
const { registerMcpEverywhere: registerMcpEverywhere2 } = await Promise.resolve().then(() => (init_mcp_clients(), mcp_clients_exports));
|
|
40004
40394
|
const MCP_CLIENT_FOR_BIN = {
|
|
@@ -40019,8 +40409,17 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
40019
40409
|
} catch (e) {
|
|
40020
40410
|
rep.warn(chalk2.yellow(`could not register chat-recall-mcp with the kit: ${e instanceof Error ? e.message : e}`));
|
|
40021
40411
|
}
|
|
40412
|
+
const hosted = options.server ?? target?.base;
|
|
40413
|
+
const hostedBase = hosted?.replace(/\/+$/, "");
|
|
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();
|
|
40022
40417
|
const results = registerMcpEverywhere2(
|
|
40023
|
-
|
|
40418
|
+
hostedBase ? {
|
|
40419
|
+
url: `${hostedBase}/mcp`,
|
|
40420
|
+
authorization: stored?.token ? `Bearer ${stored.token}` : void 0,
|
|
40421
|
+
headersHelper: stored ? "chat-recall token --header" : void 0
|
|
40422
|
+
} : localUrl ? { url: localUrl } : { ...launch, env: MCP_ENV, alwaysAllow: DEFAULT_ALLOW },
|
|
40024
40423
|
{ extraIds: detectedClients, skipIds: kitDone.has("claude") ? ["claude"] : [] }
|
|
40025
40424
|
);
|
|
40026
40425
|
const ok = results.filter((r) => r.state !== "unparseable");
|
|
@@ -40049,7 +40448,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
40049
40448
|
const detected = checkCodeindexStatus2();
|
|
40050
40449
|
if (detected.installed && !forceInstall) {
|
|
40051
40450
|
if (!options.skipMcp) {
|
|
40052
|
-
const mcpJsonPath =
|
|
40451
|
+
const mcpJsonPath = join73(homedir26(), ".mcp.json");
|
|
40053
40452
|
const reg = registerCodeindexMcp2(mcpJsonPath, detected.path);
|
|
40054
40453
|
}
|
|
40055
40454
|
} else if (forceInstall) {
|
|
@@ -40058,7 +40457,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
40058
40457
|
if (result.installed) {
|
|
40059
40458
|
const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
|
|
40060
40459
|
if (!options.skipMcp) {
|
|
40061
|
-
const mcpJsonPath =
|
|
40460
|
+
const mcpJsonPath = join73(homedir26(), ".mcp.json");
|
|
40062
40461
|
const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
|
|
40063
40462
|
}
|
|
40064
40463
|
} else if (!result.prebuiltAvailable) {
|
|
@@ -40514,8 +40913,8 @@ memory.command("wake-up").description("Generate wake-up context (high-importance
|
|
|
40514
40913
|
try {
|
|
40515
40914
|
const identityFile = getIdentityFilePath();
|
|
40516
40915
|
let identity = "AI coding assistant";
|
|
40517
|
-
if (
|
|
40518
|
-
identity =
|
|
40916
|
+
if (existsSync62(identityFile)) {
|
|
40917
|
+
identity = readFileSync58(identityFile, "utf-8").trim();
|
|
40519
40918
|
}
|
|
40520
40919
|
const lines = [
|
|
40521
40920
|
chalk2.bold("# Wake-Up Context"),
|
|
@@ -40615,7 +41014,7 @@ program.command("feedback").argument("<message...>", "what you want to say \u201
|
|
|
40615
41014
|
}
|
|
40616
41015
|
});
|
|
40617
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) => {
|
|
40618
|
-
const { existsSync:
|
|
41017
|
+
const { existsSync: existsSync63, readFileSync: readFileSync59, statSync: statSync49 } = await import("fs");
|
|
40619
41018
|
const { execSync: execSync6 } = await import("child_process");
|
|
40620
41019
|
const rows = [];
|
|
40621
41020
|
const note = (ok, label, detail) => rows.push({ ok, label, detail });
|
|
@@ -40678,8 +41077,8 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40678
41077
|
}
|
|
40679
41078
|
}
|
|
40680
41079
|
}
|
|
40681
|
-
const credFile =
|
|
40682
|
-
if (!
|
|
41080
|
+
const credFile = join73(getDataDir(), "credentials.json");
|
|
41081
|
+
if (!existsSync63(credFile)) {
|
|
40683
41082
|
note(false, "Credentials file", `missing \u2014 run \`chat-recall login <server-url>\``);
|
|
40684
41083
|
} else {
|
|
40685
41084
|
try {
|
|
@@ -40694,18 +41093,18 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40694
41093
|
const { claudeSettingsFiles: claudeSettingsFiles2, isOurEntry: isOurEntry2 } = await Promise.resolve().then(() => (init_install_hooks(), install_hooks_exports));
|
|
40695
41094
|
const { MESSAGE_HOOK_EVENTS: MESSAGE_HOOK_EVENTS2, isMessageHookEntry: isMessageHookEntry2, isBoardHookEntry: isBoardHookEntry2 } = await Promise.resolve().then(() => (init_board_hooks(), board_hooks_exports));
|
|
40696
41095
|
for (const settingsFile of claudeSettingsFiles2()) {
|
|
40697
|
-
const profile = basename29(
|
|
41096
|
+
const profile = basename29(dirname32(settingsFile));
|
|
40698
41097
|
const label = `Claude hooks (${profile})`;
|
|
40699
41098
|
let hooks;
|
|
40700
41099
|
try {
|
|
40701
|
-
hooks =
|
|
41100
|
+
hooks = existsSync63(settingsFile) ? JSON.parse(readFileSync59(settingsFile, "utf-8")).hooks || {} : {};
|
|
40702
41101
|
} catch {
|
|
40703
41102
|
note(false, label, `${settingsFile} is not valid JSON, so no hook in it runs`);
|
|
40704
41103
|
continue;
|
|
40705
41104
|
}
|
|
40706
|
-
const legacy =
|
|
41105
|
+
const legacy = join73(dirname32(settingsFile), "hooks.json");
|
|
40707
41106
|
try {
|
|
40708
|
-
const stranded =
|
|
41107
|
+
const stranded = existsSync63(legacy) ? Object.values(JSON.parse(readFileSync59(legacy, "utf-8")).hooks || {}).flat().filter(isOurEntry2).length : 0;
|
|
40709
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`);
|
|
40710
41109
|
} catch {
|
|
40711
41110
|
}
|
|
@@ -40728,9 +41127,9 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40728
41127
|
try {
|
|
40729
41128
|
const reg = await Promise.resolve().then(() => (init_guard_registration(), guard_registration_exports));
|
|
40730
41129
|
for (const target2 of reg.guardTargets()) {
|
|
40731
|
-
if (!
|
|
41130
|
+
if (!existsSync63(target2.homeDir)) continue;
|
|
40732
41131
|
const label = `Decision guard \u2014 ${target2.label}`;
|
|
40733
|
-
if (!
|
|
41132
|
+
if (!existsSync63(target2.configPath)) {
|
|
40734
41133
|
note(false, label, `not registered \u2014 run \`chat-recall install-hooks\``);
|
|
40735
41134
|
continue;
|
|
40736
41135
|
}
|
|
@@ -40740,7 +41139,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40740
41139
|
}
|
|
40741
41140
|
let registered = false;
|
|
40742
41141
|
try {
|
|
40743
|
-
const cfg = JSON.parse(
|
|
41142
|
+
const cfg = JSON.parse(readFileSync59(target2.configPath, "utf-8"));
|
|
40744
41143
|
registered = JSON.stringify(cfg).includes("chat_recall_guard");
|
|
40745
41144
|
} catch {
|
|
40746
41145
|
}
|
|
@@ -40753,12 +41152,12 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40753
41152
|
try {
|
|
40754
41153
|
const reg = await Promise.resolve().then(() => (init_message_registration(), message_registration_exports));
|
|
40755
41154
|
for (const target2 of reg.messageTargets()) {
|
|
40756
|
-
if (!
|
|
41155
|
+
if (!existsSync63(target2.homeDir)) continue;
|
|
40757
41156
|
const label = `Messages \u2014 ${target2.label}`;
|
|
40758
|
-
let registered =
|
|
41157
|
+
let registered = existsSync63(target2.configPath);
|
|
40759
41158
|
if (registered) {
|
|
40760
41159
|
try {
|
|
40761
|
-
const text =
|
|
41160
|
+
const text = readFileSync59(target2.configPath, "utf-8");
|
|
40762
41161
|
registered = text.includes("chat_recall_messages_") || reg.isOurPluginSource(text);
|
|
40763
41162
|
} catch {
|
|
40764
41163
|
registered = false;
|
|
@@ -40771,9 +41170,9 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40771
41170
|
note(false, "Messages", `check failed: ${err}`);
|
|
40772
41171
|
}
|
|
40773
41172
|
try {
|
|
40774
|
-
if (
|
|
41173
|
+
if (existsSync63(opencodeConfigDir())) {
|
|
40775
41174
|
const path = tuiConfigPath();
|
|
40776
|
-
const present =
|
|
41175
|
+
const present = existsSync63(path) && hasTuiPluginEntry(readFileSync59(path, "utf-8"), tuiPluginEntry());
|
|
40777
41176
|
note(
|
|
40778
41177
|
present,
|
|
40779
41178
|
"Messages \u2014 OpenCode TUI",
|
|
@@ -40788,7 +41187,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40788
41187
|
const want = bundledSkillNames2().length;
|
|
40789
41188
|
for (const t of skillTargets2()) {
|
|
40790
41189
|
if (!t.available) continue;
|
|
40791
|
-
const have = want === 0 ? 0 : bundledSkillNames2().filter((n) =>
|
|
41190
|
+
const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync63(join73(t.dir, n, ".chat-recall-managed"))).length;
|
|
40792
41191
|
note(
|
|
40793
41192
|
have === want,
|
|
40794
41193
|
`Skills \u2014 ${t.label}`,
|
|
@@ -40863,14 +41262,14 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40863
41262
|
note(watchRunning, "Watch daemon", watchRunning ? "running" : "not running (run `chat-recall watch --install-service` to keep collection running)");
|
|
40864
41263
|
const dataDir = getDataDir();
|
|
40865
41264
|
const legacyPaths = [
|
|
40866
|
-
|
|
40867
|
-
|
|
40868
|
-
|
|
40869
|
-
|
|
40870
|
-
|
|
40871
|
-
|
|
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")
|
|
40872
41271
|
];
|
|
40873
|
-
const legacyPresent = legacyPaths.filter((p) =>
|
|
41272
|
+
const legacyPresent = legacyPaths.filter((p) => existsSync63(p));
|
|
40874
41273
|
if (opts.purgeLocal) {
|
|
40875
41274
|
if (!target) {
|
|
40876
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");
|
|
@@ -40941,7 +41340,7 @@ companions.command("install").description("Install codeindex (downloads from mun
|
|
|
40941
41340
|
if (result.installed) {
|
|
40942
41341
|
const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
|
|
40943
41342
|
console.log(chalk2.green(`\u2713 codeindex installed (${sizeMb}) \u2192 ${result.path}`));
|
|
40944
|
-
const mcpJsonPath =
|
|
41343
|
+
const mcpJsonPath = join73(homedir26(), ".mcp.json");
|
|
40945
41344
|
const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
|
|
40946
41345
|
if (reg.added) console.log(chalk2.dim(` Registered as MCP server in ${mcpJsonPath}`));
|
|
40947
41346
|
else console.log(chalk2.dim(` Already registered as MCP server`));
|
|
@@ -40963,7 +41362,7 @@ companions.command("uninstall").description("Remove the codeindex binary chat-re
|
|
|
40963
41362
|
const r = uninstallCodeindex2();
|
|
40964
41363
|
if (r.removed) console.log(chalk2.green(`\u2713 Removed ${r.path}`));
|
|
40965
41364
|
else console.log(chalk2.dim(` Nothing to remove at ${r.path}`));
|
|
40966
|
-
const mcpJsonPath =
|
|
41365
|
+
const mcpJsonPath = join73(homedir26(), ".mcp.json");
|
|
40967
41366
|
const u = unregisterCodeindexMcp2(mcpJsonPath);
|
|
40968
41367
|
if (u.removed) console.log(chalk2.dim(` Unregistered MCP server from ${mcpJsonPath}`));
|
|
40969
41368
|
});
|
|
@@ -41515,10 +41914,10 @@ tasks.command("pull [dir]").description("Write TEAM_TASKS.md for your tasks in t
|
|
|
41515
41914
|
try {
|
|
41516
41915
|
const { resolveProjectId: resolveProjectId2 } = await Promise.resolve().then(() => (init_project_resolver(), project_resolver_exports));
|
|
41517
41916
|
const { renderTeamTasksMd: renderTeamTasksMd2, parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
|
|
41518
|
-
const { writeFileSync:
|
|
41519
|
-
const { join:
|
|
41520
|
-
const file =
|
|
41521
|
-
if (!opts.force &&
|
|
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) {
|
|
41522
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.");
|
|
41523
41922
|
process.exit(1);
|
|
41524
41923
|
}
|
|
@@ -41526,7 +41925,7 @@ tasks.command("pull [dir]").description("Write TEAM_TASKS.md for your tasks in t
|
|
|
41526
41925
|
const pid = resolved && resolved.source !== "ignored" ? resolved.id : "";
|
|
41527
41926
|
const { tasks: tasks2 } = await serverGet("/api/tasks?assignee=@me");
|
|
41528
41927
|
const mine = tasks2.filter((t) => !pid || !t.projectId || t.projectId === pid);
|
|
41529
|
-
|
|
41928
|
+
writeFileSync27(file, renderTeamTasksMd2(mine));
|
|
41530
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"));
|
|
41531
41930
|
} catch (e) {
|
|
41532
41931
|
console.error(chalk2.red(e instanceof Error ? e.message : String(e)));
|
|
@@ -41537,14 +41936,14 @@ tasks.command("push [dir]").description("Push TEAM_TASKS.md status edits back to
|
|
|
41537
41936
|
const cwd = dir || process.cwd();
|
|
41538
41937
|
try {
|
|
41539
41938
|
const { parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
|
|
41540
|
-
const { readFileSync:
|
|
41541
|
-
const { join:
|
|
41542
|
-
const file =
|
|
41543
|
-
if (!
|
|
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)) {
|
|
41544
41943
|
console.error(chalk2.red("no TEAM_TASKS.md here \u2014"), "run", chalk2.bold("chat-recall tasks pull"), "first");
|
|
41545
41944
|
process.exit(1);
|
|
41546
41945
|
}
|
|
41547
|
-
const edits = parseTeamTasksFile2(
|
|
41946
|
+
const edits = parseTeamTasksFile2(readFileSync59(file, "utf8"));
|
|
41548
41947
|
let n = 0;
|
|
41549
41948
|
for (const e of edits) {
|
|
41550
41949
|
await serverPatch(`/api/tasks/${encodeURIComponent(e.id)}`, { status: e.intent });
|
|
@@ -41650,8 +42049,8 @@ team.command("publish <type> <name> <file>").description("Publish a local file a
|
|
|
41650
42049
|
console.error(chalk2.red(`Invalid tool: ${opts.tool}. Must be one of: ${validTools.join(", ")}`));
|
|
41651
42050
|
process.exit(1);
|
|
41652
42051
|
}
|
|
41653
|
-
const { readFileSync:
|
|
41654
|
-
const body2 =
|
|
42052
|
+
const { readFileSync: readFileSync59 } = await import("fs");
|
|
42053
|
+
const body2 = readFileSync59(file);
|
|
41655
42054
|
const { teamPublish: teamPublish2 } = await Promise.resolve().then(() => (init_team_client(), team_client_exports));
|
|
41656
42055
|
const a = await teamPublish2({
|
|
41657
42056
|
type,
|
|
@@ -42077,7 +42476,7 @@ program.command("dossier <project>").description("Generate a project dossier (ov
|
|
|
42077
42476
|
);
|
|
42078
42477
|
const md = dossier.markdown;
|
|
42079
42478
|
if (options.out) {
|
|
42080
|
-
|
|
42479
|
+
writeFileSync26(options.out, md);
|
|
42081
42480
|
console.log(chalk2.green(`Wrote dossier to ${options.out} (${md.length} chars)`));
|
|
42082
42481
|
} else {
|
|
42083
42482
|
console.log(md);
|
|
@@ -42362,8 +42761,8 @@ include.command("list", { isDefault: true }).description("Show paths opted back
|
|
|
42362
42761
|
include.command("project <path>").description("Re-permit a path under a personal folder (substring match; e.g. ~/Documents/code)").action(async (path) => {
|
|
42363
42762
|
const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
|
|
42364
42763
|
const { resolve: resolve3 } = await import("node:path");
|
|
42365
|
-
const { homedir:
|
|
42366
|
-
const abs = resolve3(path.replace(/^~(?=\/|$)/,
|
|
42764
|
+
const { homedir: homedir27 } = await import("node:os");
|
|
42765
|
+
const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir27()));
|
|
42367
42766
|
const s = loadSettings2();
|
|
42368
42767
|
s.sync.includeProjects = s.sync.includeProjects || [];
|
|
42369
42768
|
if (s.sync.includeProjects.includes(abs)) {
|
|
@@ -42377,8 +42776,8 @@ include.command("project <path>").description("Re-permit a path under a personal
|
|
|
42377
42776
|
include.command("remove <path>").description("Undo an opt-in (personal folder goes back to skipped)").action(async (path) => {
|
|
42378
42777
|
const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
|
|
42379
42778
|
const { resolve: resolve3 } = await import("node:path");
|
|
42380
|
-
const { homedir:
|
|
42381
|
-
const abs = resolve3(path.replace(/^~(?=\/|$)/,
|
|
42779
|
+
const { homedir: homedir27 } = await import("node:os");
|
|
42780
|
+
const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir27()));
|
|
42382
42781
|
const s = loadSettings2();
|
|
42383
42782
|
const before = (s.sync.includeProjects || []).length;
|
|
42384
42783
|
s.sync.includeProjects = (s.sync.includeProjects || []).filter((p) => p !== path && p !== abs);
|
|
@@ -42517,8 +42916,8 @@ program.command("projects").description("List distinct project ids discovered on
|
|
|
42517
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) => {
|
|
42518
42917
|
const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
|
|
42519
42918
|
const { resolve: resolve3 } = await import("node:path");
|
|
42520
|
-
const { homedir:
|
|
42521
|
-
const abs = resolve3(path.replace(/^~(?=\/|$)/,
|
|
42919
|
+
const { homedir: homedir27 } = await import("node:os");
|
|
42920
|
+
const abs = resolve3(path.replace(/^~(?=\/|$)/, homedir27()));
|
|
42522
42921
|
const s = loadSettings2();
|
|
42523
42922
|
if (s.sync.excludeProjects.includes(abs)) {
|
|
42524
42923
|
console.log(chalk2.dim(`Already excluded: ${abs}`));
|
|
@@ -42547,8 +42946,8 @@ exclude.command("tool <tool>").description("Exclude an AI tool entirely (claude
|
|
|
42547
42946
|
exclude.command("remove <value>").description("Remove an exclusion (tool name or project path)").action(async (value) => {
|
|
42548
42947
|
const { loadSettings: loadSettings2, saveSettings: saveSettings2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
|
|
42549
42948
|
const { resolve: resolve3 } = await import("node:path");
|
|
42550
|
-
const { homedir:
|
|
42551
|
-
const abs = resolve3(value.replace(/^~(?=\/|$)/,
|
|
42949
|
+
const { homedir: homedir27 } = await import("node:os");
|
|
42950
|
+
const abs = resolve3(value.replace(/^~(?=\/|$)/, homedir27()));
|
|
42552
42951
|
const s = loadSettings2();
|
|
42553
42952
|
const beforeTools = s.sync.excludeTools.length;
|
|
42554
42953
|
const beforeProjects = s.sync.excludeProjects.length;
|
|
@@ -42562,6 +42961,15 @@ exclude.command("remove <value>").description("Remove an exclusion (tool name or
|
|
|
42562
42961
|
console.log(chalk2.green(`\u2713 Removed ${value}`));
|
|
42563
42962
|
});
|
|
42564
42963
|
program.command("login [server-url]").description(`Log in (device flow), mint a sync device token, keep it in sealkeep, the OS keyring or a file only you can read, and register chat-recall-mcp in your AI tools. Defaults to ${DEFAULT_SERVER}.`).option("--token <token>", "Self-host: skip OIDC and save this device token directly").option("--check", "Report-only: exit 0 if a working credential for this server exists, 1 otherwise (never interactive)").option("--issuer <url>", "OIDC issuer URL (default: learned from the server via /api/capabilities)").option("--client-id <id>", "OIDC client id (default: chat-recall-web)").option("--team <slug>", "Team to mint the device token for (default: your only team)").option("--device-id <id>", "Device id for this machine (default: hostname)").option("--prompt-json", "Print the device prompt as one JSON line on stdout, then wait for approval", false).option("--skip-mcp", "Do not register chat-recall-mcp in the AI tools of this machine").action((serverUrl, opts) => runLogin(serverUrl || DEFAULT_SERVER, opts));
|
|
42964
|
+
program.command("token").description("Print the credential of this machine, for a client that runs a header helper instead of a sign-in").option("--header", "Print the whole Authorization header value").action(async (opts) => {
|
|
42965
|
+
const { recallTarget: recallTarget2 } = await Promise.resolve().then(() => (init_remote_target(), remote_target_exports));
|
|
42966
|
+
const target = recallTarget2();
|
|
42967
|
+
if (!target?.token) {
|
|
42968
|
+
console.error(chalk2.red("No stored credential.") + chalk2.dim(" Run `chat-recall login` first."));
|
|
42969
|
+
process.exit(1);
|
|
42970
|
+
}
|
|
42971
|
+
console.log(opts.header ? `Bearer ${target.token}` : target.token);
|
|
42972
|
+
});
|
|
42565
42973
|
program.command("logout <server-url>").description("Remove one sync target (other targets keep syncing)").action(async (serverUrl) => {
|
|
42566
42974
|
const { removeCredentials: removeCredentials2, loadAllCredentials: loadAllCredentials2 } = await Promise.resolve().then(() => (init_sync_client(), sync_client_exports));
|
|
42567
42975
|
if (removeCredentials2(serverUrl)) {
|