chat-recall 0.7.42 → 0.7.46
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/dist/cli.js +920 -799
- package/dist/mcp.js +509 -388
- package/dist/memory-guard.d.ts +45 -2
- package/dist/memory-guard.d.ts.map +1 -1
- package/dist/memory-guard.js +63 -2
- package/dist/memory-guard.js.map +1 -1
- package/dist/scan-worker.js +21 -2
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +20 -0
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +378 -320
- package/package.json +1 -1
package/dist/watch.js
CHANGED
|
@@ -9648,16 +9648,23 @@ var init_opencode_v2 = __esm({
|
|
|
9648
9648
|
// ../engine/dist/core/backends/opencode.js
|
|
9649
9649
|
var opencode_exports = {};
|
|
9650
9650
|
__export(opencode_exports, {
|
|
9651
|
+
DEFAULT_DUMP_MAX_BYTES: () => DEFAULT_DUMP_MAX_BYTES,
|
|
9651
9652
|
OpencodeBackend: () => OpencodeBackend,
|
|
9653
|
+
dumpMaxBytes: () => dumpMaxBytes,
|
|
9652
9654
|
opencodeBackend: () => opencodeBackend
|
|
9653
9655
|
});
|
|
9654
9656
|
import { existsSync as existsSync11 } from "fs";
|
|
9655
9657
|
import { homedir as homedir5 } from "os";
|
|
9656
9658
|
import { dirname as dirname9, join as join13 } from "path";
|
|
9659
|
+
function dumpMaxBytes(env = process.env) {
|
|
9660
|
+
const raw = env.CHAT_RECALL_OPENCODE_DUMP_MAX_BYTES;
|
|
9661
|
+
const parsed = raw === void 0 ? Number.NaN : Number(raw);
|
|
9662
|
+
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : DEFAULT_DUMP_MAX_BYTES;
|
|
9663
|
+
}
|
|
9657
9664
|
function openReadonly(path) {
|
|
9658
9665
|
return openOpencodeDb(path);
|
|
9659
9666
|
}
|
|
9660
|
-
var PREFIX, OpencodeBackend, opencodeBackend;
|
|
9667
|
+
var DEFAULT_DUMP_MAX_BYTES, PREFIX, OpencodeBackend, opencodeBackend;
|
|
9661
9668
|
var init_opencode = __esm({
|
|
9662
9669
|
"../engine/dist/core/backends/opencode.js"() {
|
|
9663
9670
|
"use strict";
|
|
@@ -9667,6 +9674,7 @@ var init_opencode = __esm({
|
|
|
9667
9674
|
init_session_git();
|
|
9668
9675
|
init_generic_engine();
|
|
9669
9676
|
init_flat_string();
|
|
9677
|
+
DEFAULT_DUMP_MAX_BYTES = 64 * 1024 * 1024;
|
|
9670
9678
|
PREFIX = "opencode_";
|
|
9671
9679
|
OpencodeBackend = class {
|
|
9672
9680
|
id = "opencode";
|
|
@@ -10181,10 +10189,23 @@ var init_opencode = __esm({
|
|
|
10181
10189
|
WHERE p.session_id = ?
|
|
10182
10190
|
ORDER BY p.time_created ASC, p.id ASC
|
|
10183
10191
|
`);
|
|
10192
|
+
const budget = dumpMaxBytes();
|
|
10184
10193
|
const chunks = [Buffer.from(`${JSON.stringify({ kind: "session", row: session })}
|
|
10185
10194
|
`, "utf-8")];
|
|
10195
|
+
let used = chunks[0].length;
|
|
10196
|
+
let skipped = 0;
|
|
10186
10197
|
for (const r of rows.iterate(realId, realId)) {
|
|
10187
|
-
|
|
10198
|
+
const encoded = Buffer.from(`${JSON.stringify({ kind: "part", row: r })}
|
|
10199
|
+
`, "utf-8");
|
|
10200
|
+
if (used + encoded.length > budget) {
|
|
10201
|
+
skipped++;
|
|
10202
|
+
continue;
|
|
10203
|
+
}
|
|
10204
|
+
used += encoded.length;
|
|
10205
|
+
chunks.push(encoded);
|
|
10206
|
+
}
|
|
10207
|
+
if (skipped > 0) {
|
|
10208
|
+
chunks.push(Buffer.from(`${JSON.stringify({ kind: "truncated", skipped_rows: skipped, limit_bytes: budget })}
|
|
10188
10209
|
`, "utf-8"));
|
|
10189
10210
|
}
|
|
10190
10211
|
const mtime = session.time_updated || session.time_created || Date.now();
|
|
@@ -13879,6 +13900,94 @@ var init_collector_health = __esm({
|
|
|
13879
13900
|
}
|
|
13880
13901
|
});
|
|
13881
13902
|
|
|
13903
|
+
// src/memory-guard.ts
|
|
13904
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync5 } from "node:fs";
|
|
13905
|
+
import { join as join21 } from "node:path";
|
|
13906
|
+
function rssMb() {
|
|
13907
|
+
return Math.round(process.memoryUsage().rss / 1048576);
|
|
13908
|
+
}
|
|
13909
|
+
function memoryLimitMb(env = process.env) {
|
|
13910
|
+
const raw = env.CHAT_RECALL_WATCH_RSS_MAX_MB;
|
|
13911
|
+
if (!raw) return DEFAULT_RSS_MAX_MB;
|
|
13912
|
+
const n = Number(raw);
|
|
13913
|
+
return Number.isFinite(n) && n > 0 ? Math.round(n) : DEFAULT_RSS_MAX_MB;
|
|
13914
|
+
}
|
|
13915
|
+
function growthLimitMb(env = process.env) {
|
|
13916
|
+
const raw = env.CHAT_RECALL_WATCH_GROWTH_MAX_MB;
|
|
13917
|
+
if (!raw) return DEFAULT_GROWTH_MAX_MB;
|
|
13918
|
+
const n = Number(raw);
|
|
13919
|
+
return Number.isFinite(n) && n > 0 ? Math.round(n) : DEFAULT_GROWTH_MAX_MB;
|
|
13920
|
+
}
|
|
13921
|
+
function releaseMemory(gc = globalThis.gc) {
|
|
13922
|
+
if (typeof gc !== "function") return false;
|
|
13923
|
+
gc();
|
|
13924
|
+
return true;
|
|
13925
|
+
}
|
|
13926
|
+
function cgroupDir(cgroupFile = "/proc/self/cgroup") {
|
|
13927
|
+
let text;
|
|
13928
|
+
try {
|
|
13929
|
+
text = readFileSync16(cgroupFile, "utf8");
|
|
13930
|
+
} catch {
|
|
13931
|
+
return null;
|
|
13932
|
+
}
|
|
13933
|
+
const line = text.split("\n").find((l) => l.startsWith("0::"));
|
|
13934
|
+
if (!line) return null;
|
|
13935
|
+
return `/sys/fs/cgroup${line.slice(3).trim()}`;
|
|
13936
|
+
}
|
|
13937
|
+
function memoryStatMb(dir, key2) {
|
|
13938
|
+
let text;
|
|
13939
|
+
try {
|
|
13940
|
+
text = readFileSync16(join21(dir, "memory.stat"), "utf8");
|
|
13941
|
+
} catch {
|
|
13942
|
+
return null;
|
|
13943
|
+
}
|
|
13944
|
+
for (const line of text.split("\n")) {
|
|
13945
|
+
const [name, value] = line.split(" ");
|
|
13946
|
+
if (name === key2 && value) return Math.round(Number(value) / 1048576);
|
|
13947
|
+
}
|
|
13948
|
+
return null;
|
|
13949
|
+
}
|
|
13950
|
+
function reclaimCgroup(keepFileMb = 64, dir = cgroupDir()) {
|
|
13951
|
+
if (!dir) return false;
|
|
13952
|
+
const fileMb = memoryStatMb(dir, "file");
|
|
13953
|
+
if (fileMb === null) return false;
|
|
13954
|
+
const reclaimMb = Math.floor(fileMb - keepFileMb);
|
|
13955
|
+
if (reclaimMb <= 0) return false;
|
|
13956
|
+
try {
|
|
13957
|
+
writeFileSync5(join21(dir, "memory.reclaim"), `${reclaimMb}M`);
|
|
13958
|
+
return true;
|
|
13959
|
+
} catch {
|
|
13960
|
+
return false;
|
|
13961
|
+
}
|
|
13962
|
+
}
|
|
13963
|
+
function cgroupCurrentMb(dir = cgroupDir()) {
|
|
13964
|
+
if (!dir) return null;
|
|
13965
|
+
try {
|
|
13966
|
+
const n = Number(readFileSync16(join21(dir, "memory.current"), "utf8").trim());
|
|
13967
|
+
return Number.isFinite(n) ? Math.round(n / 1048576) : null;
|
|
13968
|
+
} catch {
|
|
13969
|
+
return null;
|
|
13970
|
+
}
|
|
13971
|
+
}
|
|
13972
|
+
function usedMb(rss = rssMb(), cgroup = cgroupCurrentMb()) {
|
|
13973
|
+
return cgroup !== null && cgroup > rss ? cgroup : rss;
|
|
13974
|
+
}
|
|
13975
|
+
function startBudget(used = usedMb(), env = process.env) {
|
|
13976
|
+
return { baselineMb: used, growthMb: growthLimitMb(env), hardMb: memoryLimitMb(env) };
|
|
13977
|
+
}
|
|
13978
|
+
function shouldPause(used, budget, unitsDone) {
|
|
13979
|
+
if (unitsDone <= 0) return false;
|
|
13980
|
+
return used >= budget.hardMb || used - budget.baselineMb >= budget.growthMb;
|
|
13981
|
+
}
|
|
13982
|
+
var DEFAULT_RSS_MAX_MB, DEFAULT_GROWTH_MAX_MB;
|
|
13983
|
+
var init_memory_guard = __esm({
|
|
13984
|
+
"src/memory-guard.ts"() {
|
|
13985
|
+
"use strict";
|
|
13986
|
+
DEFAULT_RSS_MAX_MB = 896;
|
|
13987
|
+
DEFAULT_GROWTH_MAX_MB = 256;
|
|
13988
|
+
}
|
|
13989
|
+
});
|
|
13990
|
+
|
|
13882
13991
|
// ../engine/dist/core/secret-redactor.js
|
|
13883
13992
|
import { statSync as statSync15 } from "fs";
|
|
13884
13993
|
function secretOf(rule, m) {
|
|
@@ -14288,7 +14397,7 @@ var init_secret_redactor = __esm({
|
|
|
14288
14397
|
// ../engine/dist/core/source-discovery.js
|
|
14289
14398
|
import { createHash as createHash5 } from "crypto";
|
|
14290
14399
|
import { existsSync as existsSync17, readdirSync as readdirSync13, statSync as statSync16 } from "fs";
|
|
14291
|
-
import { join as
|
|
14400
|
+
import { join as join22 } from "path";
|
|
14292
14401
|
function sourceId(path) {
|
|
14293
14402
|
return "src_" + createHash5("sha256").update(path).digest("hex").slice(0, 12);
|
|
14294
14403
|
}
|
|
@@ -14329,7 +14438,7 @@ function countTranscripts(root, tool) {
|
|
|
14329
14438
|
return;
|
|
14330
14439
|
}
|
|
14331
14440
|
for (const e of entries) {
|
|
14332
|
-
const full =
|
|
14441
|
+
const full = join22(dir, e.name);
|
|
14333
14442
|
if (e.isDirectory()) {
|
|
14334
14443
|
walk(full, depth + 1);
|
|
14335
14444
|
continue;
|
|
@@ -14400,9 +14509,9 @@ var init_source_discovery = __esm({
|
|
|
14400
14509
|
|
|
14401
14510
|
// ../engine/dist/core/home-discovery.js
|
|
14402
14511
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
14403
|
-
import { existsSync as existsSync18, readdirSync as readdirSync14, readFileSync as
|
|
14512
|
+
import { existsSync as existsSync18, readdirSync as readdirSync14, readFileSync as readFileSync17, realpathSync as realpathSync3, statSync as statSync17 } from "fs";
|
|
14404
14513
|
import { homedir as homedir6, platform as osPlatform } from "os";
|
|
14405
|
-
import { basename as basename12, join as
|
|
14514
|
+
import { basename as basename12, join as join23 } from "path";
|
|
14406
14515
|
function candidateRoots(plat = osPlatform(), env = process.env) {
|
|
14407
14516
|
const home = homedir6();
|
|
14408
14517
|
const roots = [home];
|
|
@@ -14415,11 +14524,11 @@ function candidateRoots(plat = osPlatform(), env = process.env) {
|
|
|
14415
14524
|
add(env.LOCALAPPDATA);
|
|
14416
14525
|
add(env.USERPROFILE);
|
|
14417
14526
|
} else if (plat === "darwin") {
|
|
14418
|
-
add(
|
|
14527
|
+
add(join23(home, "Library", "Application Support"));
|
|
14419
14528
|
add(env.XDG_CONFIG_HOME);
|
|
14420
14529
|
} else {
|
|
14421
|
-
add(env.XDG_CONFIG_HOME ||
|
|
14422
|
-
add(env.XDG_DATA_HOME ||
|
|
14530
|
+
add(env.XDG_CONFIG_HOME || join23(home, ".config"));
|
|
14531
|
+
add(env.XDG_DATA_HOME || join23(home, ".local", "share"));
|
|
14423
14532
|
}
|
|
14424
14533
|
return roots.filter((r) => existsSync18(r));
|
|
14425
14534
|
}
|
|
@@ -14432,14 +14541,14 @@ function piRootOf(home) {
|
|
|
14432
14541
|
return piSessionDirForHome(home);
|
|
14433
14542
|
}
|
|
14434
14543
|
function identifyHome(dir) {
|
|
14435
|
-
const has = (...parts) => existsSync18(
|
|
14436
|
-
if (has("projects") && dirHasTranscript(
|
|
14544
|
+
const has = (...parts) => existsSync18(join23(dir, ...parts));
|
|
14545
|
+
if (has("projects") && dirHasTranscript(join23(dir, "projects"), (f) => f.endsWith(".jsonl"), 2))
|
|
14437
14546
|
return "claude";
|
|
14438
|
-
if (has("sessions") && dirHasTranscript(
|
|
14547
|
+
if (has("sessions") && dirHasTranscript(join23(dir, "sessions"), (f) => f.startsWith("rollout-") && f.endsWith(".jsonl"), 4))
|
|
14439
14548
|
return "codex";
|
|
14440
|
-
if (has("brain") && dirHasTranscript(
|
|
14549
|
+
if (has("brain") && dirHasTranscript(join23(dir, "brain"), (f) => f.endsWith(".jsonl"), 4))
|
|
14441
14550
|
return "agy";
|
|
14442
|
-
if (has("chats") && dirHasTranscript(
|
|
14551
|
+
if (has("chats") && dirHasTranscript(join23(dir, "chats"), (f) => f === "store.db", 3))
|
|
14443
14552
|
return "cursor";
|
|
14444
14553
|
if (has("opencode.db"))
|
|
14445
14554
|
return "opencode";
|
|
@@ -14464,7 +14573,7 @@ function dirHasTranscript(root, match, depth) {
|
|
|
14464
14573
|
continue;
|
|
14465
14574
|
if (e.isFile() && match(e.name))
|
|
14466
14575
|
return true;
|
|
14467
|
-
if (e.isDirectory() && dirHasTranscript(
|
|
14576
|
+
if (e.isDirectory() && dirHasTranscript(join23(root, e.name), match, depth - 1))
|
|
14468
14577
|
return true;
|
|
14469
14578
|
}
|
|
14470
14579
|
return false;
|
|
@@ -14485,7 +14594,7 @@ function countSessions(dir, tool) {
|
|
|
14485
14594
|
if (SKIP.has(e.name))
|
|
14486
14595
|
continue;
|
|
14487
14596
|
if (e.isDirectory()) {
|
|
14488
|
-
walk2(
|
|
14597
|
+
walk2(join23(d, e.name), depth - 1);
|
|
14489
14598
|
continue;
|
|
14490
14599
|
}
|
|
14491
14600
|
if (isPiTranscriptName(e.name))
|
|
@@ -14522,12 +14631,12 @@ function countSessions(dir, tool) {
|
|
|
14522
14631
|
if (SKIP.has(e.name))
|
|
14523
14632
|
continue;
|
|
14524
14633
|
if (e.isDirectory())
|
|
14525
|
-
walk(
|
|
14634
|
+
walk(join23(d, e.name), depth - 1);
|
|
14526
14635
|
else if (s.match(e.name))
|
|
14527
14636
|
n++;
|
|
14528
14637
|
}
|
|
14529
14638
|
};
|
|
14530
|
-
walk(
|
|
14639
|
+
walk(join23(dir, s.sub), s.depth);
|
|
14531
14640
|
return n;
|
|
14532
14641
|
}
|
|
14533
14642
|
function declaredHomes(env = process.env, plat = osPlatform()) {
|
|
@@ -14565,11 +14674,11 @@ function declaredHomes(env = process.env, plat = osPlatform()) {
|
|
|
14565
14674
|
return out;
|
|
14566
14675
|
}
|
|
14567
14676
|
const home = homedir6();
|
|
14568
|
-
const rcs = [".bashrc", ".bash_profile", ".zshrc", ".zprofile", ".profile"].map((f) =>
|
|
14677
|
+
const rcs = [".bashrc", ".bash_profile", ".zshrc", ".zprofile", ".profile"].map((f) => join23(home, f)).concat([join23(home, ".config", "fish", "config.fish")]);
|
|
14569
14678
|
for (const rc of rcs) {
|
|
14570
14679
|
let text;
|
|
14571
14680
|
try {
|
|
14572
|
-
text =
|
|
14681
|
+
text = readFileSync17(rc, "utf-8");
|
|
14573
14682
|
} catch {
|
|
14574
14683
|
continue;
|
|
14575
14684
|
}
|
|
@@ -14580,7 +14689,7 @@ function declaredHomes(env = process.env, plat = osPlatform()) {
|
|
|
14580
14689
|
add(d);
|
|
14581
14690
|
}
|
|
14582
14691
|
}
|
|
14583
|
-
return out.map((p) => p.startsWith("~") ?
|
|
14692
|
+
return out.map((p) => p.startsWith("~") ? join23(home, p.slice(1)) : p);
|
|
14584
14693
|
}
|
|
14585
14694
|
function runningToolHomes(plat = osPlatform()) {
|
|
14586
14695
|
const out = [];
|
|
@@ -14594,7 +14703,7 @@ function runningToolHomes(plat = osPlatform()) {
|
|
|
14594
14703
|
for (const pid of pids) {
|
|
14595
14704
|
let env;
|
|
14596
14705
|
try {
|
|
14597
|
-
env =
|
|
14706
|
+
env = readFileSync17(`/proc/${pid}/environ`, "utf-8");
|
|
14598
14707
|
} catch {
|
|
14599
14708
|
continue;
|
|
14600
14709
|
}
|
|
@@ -14651,9 +14760,9 @@ function discoverHomes(opts = {}) {
|
|
|
14651
14760
|
found.set(real, { tool, path: real, via, sessions: countSessions(real, tool) });
|
|
14652
14761
|
if (tool === "hermes") {
|
|
14653
14762
|
try {
|
|
14654
|
-
for (const e of readdirSync14(
|
|
14763
|
+
for (const e of readdirSync14(join23(real, "profiles"), { withFileTypes: true })) {
|
|
14655
14764
|
if (e.isDirectory())
|
|
14656
|
-
consider(
|
|
14765
|
+
consider(join23(real, "profiles", e.name), via);
|
|
14657
14766
|
}
|
|
14658
14767
|
} catch {
|
|
14659
14768
|
}
|
|
@@ -14683,7 +14792,7 @@ function walkForHomes(dir, depth, visit) {
|
|
|
14683
14792
|
for (const e of entries) {
|
|
14684
14793
|
if (!e.isDirectory() || SKIP.has(e.name))
|
|
14685
14794
|
continue;
|
|
14686
|
-
const child =
|
|
14795
|
+
const child = join23(dir, e.name);
|
|
14687
14796
|
visit(child);
|
|
14688
14797
|
walkForHomes(child, depth - 1, visit);
|
|
14689
14798
|
}
|
|
@@ -14726,20 +14835,20 @@ var init_home_discovery = __esm({
|
|
|
14726
14835
|
|
|
14727
14836
|
// ../engine/dist/core/detector-install.js
|
|
14728
14837
|
import { createHash as createHash6 } from "crypto";
|
|
14729
|
-
import { existsSync as existsSync19, mkdirSync as mkdirSync6, mkdtempSync, chmodSync as chmodSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as
|
|
14730
|
-
import { join as
|
|
14838
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync6, mkdtempSync, chmodSync as chmodSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync6, readFileSync as readFileSync18, statSync as statSync18, copyFileSync as copyFileSync2 } from "fs";
|
|
14839
|
+
import { join as join24 } from "path";
|
|
14731
14840
|
function managedDetectorPath(name) {
|
|
14732
|
-
return
|
|
14841
|
+
return join24(getDetectorBinDir(), name + exeSuffix());
|
|
14733
14842
|
}
|
|
14734
14843
|
function receiptPath(name) {
|
|
14735
|
-
return
|
|
14844
|
+
return join24(getDetectorBinDir(), `${name}.receipt.json`);
|
|
14736
14845
|
}
|
|
14737
14846
|
function sha256File(path) {
|
|
14738
|
-
return createHash6("sha256").update(
|
|
14847
|
+
return createHash6("sha256").update(readFileSync18(path)).digest("hex");
|
|
14739
14848
|
}
|
|
14740
14849
|
function readReceipt(name) {
|
|
14741
14850
|
try {
|
|
14742
|
-
return JSON.parse(
|
|
14851
|
+
return JSON.parse(readFileSync18(receiptPath(name), "utf-8"));
|
|
14743
14852
|
} catch {
|
|
14744
14853
|
return null;
|
|
14745
14854
|
}
|
|
@@ -14765,7 +14874,7 @@ function configuredDir() {
|
|
|
14765
14874
|
function resolveDetector(name) {
|
|
14766
14875
|
const dir = configuredDir();
|
|
14767
14876
|
if (dir) {
|
|
14768
|
-
const p2 =
|
|
14877
|
+
const p2 = join24(dir, name + exeSuffix());
|
|
14769
14878
|
if (existsSync19(p2))
|
|
14770
14879
|
return { path: p2, version: "operator-supplied", source: "configured" };
|
|
14771
14880
|
return { error: "not-installed" };
|
|
@@ -14830,9 +14939,9 @@ var init_detector_install = __esm({
|
|
|
14830
14939
|
|
|
14831
14940
|
// ../engine/dist/core/secret-scanner.js
|
|
14832
14941
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
14833
|
-
import { existsSync as existsSync20, unlinkSync, readFileSync as
|
|
14942
|
+
import { existsSync as existsSync20, unlinkSync, readFileSync as readFileSync19, mkdtempSync as mkdtempSync2, rmSync as rmSync3 } from "fs";
|
|
14834
14943
|
import { tmpdir } from "os";
|
|
14835
|
-
import { join as
|
|
14944
|
+
import { join as join25 } from "path";
|
|
14836
14945
|
function mask(s) {
|
|
14837
14946
|
if (!s)
|
|
14838
14947
|
return "";
|
|
@@ -14860,7 +14969,7 @@ function whichDetector(bin) {
|
|
|
14860
14969
|
return null;
|
|
14861
14970
|
}
|
|
14862
14971
|
function spawnScoped(binary, args, opts) {
|
|
14863
|
-
const scratch = mkdtempSync2(
|
|
14972
|
+
const scratch = mkdtempSync2(join25(tmpdir(), "cr-scan-tmp-"));
|
|
14864
14973
|
try {
|
|
14865
14974
|
return spawnSync2(binary, args, {
|
|
14866
14975
|
...opts,
|
|
@@ -14891,7 +15000,7 @@ function runGitleaks(binary, filePath) {
|
|
|
14891
15000
|
return [];
|
|
14892
15001
|
let parsed = [];
|
|
14893
15002
|
try {
|
|
14894
|
-
parsed = JSON.parse(
|
|
15003
|
+
parsed = JSON.parse(readFileSync19(reportPath, "utf-8")) || [];
|
|
14895
15004
|
} catch {
|
|
14896
15005
|
}
|
|
14897
15006
|
try {
|
|
@@ -14955,7 +15064,7 @@ function runGitleaksDir(binary, dir) {
|
|
|
14955
15064
|
}
|
|
14956
15065
|
let parsed = [];
|
|
14957
15066
|
try {
|
|
14958
|
-
parsed = JSON.parse(
|
|
15067
|
+
parsed = JSON.parse(readFileSync19(reportPath, "utf-8")) || [];
|
|
14959
15068
|
} catch {
|
|
14960
15069
|
}
|
|
14961
15070
|
try {
|
|
@@ -15046,7 +15155,7 @@ function scanFileForSecrets(filePath, opts = {}) {
|
|
|
15046
15155
|
out.push({ detector: "trufflehog", ...f });
|
|
15047
15156
|
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
15048
15157
|
try {
|
|
15049
|
-
const text =
|
|
15158
|
+
const text = readFileSync19(filePath, "utf-8");
|
|
15050
15159
|
out.push(...scanTenantRules(text, opts.tenantRules));
|
|
15051
15160
|
} catch {
|
|
15052
15161
|
}
|
|
@@ -15459,10 +15568,10 @@ var init_transcript = __esm({
|
|
|
15459
15568
|
// ../engine/dist/core/project-resolver.js
|
|
15460
15569
|
import { execSync } from "child_process";
|
|
15461
15570
|
import { createHash as createHash7 } from "crypto";
|
|
15462
|
-
import { existsSync as existsSync21, readFileSync as
|
|
15463
|
-
import { basename as basename13, dirname as dirname14, isAbsolute as isAbsolute2, join as
|
|
15571
|
+
import { existsSync as existsSync21, readFileSync as readFileSync20, realpathSync as realpathSync4, readdirSync as readdirSync15, statSync as statSync20 } from "fs";
|
|
15572
|
+
import { basename as basename13, dirname as dirname14, isAbsolute as isAbsolute2, join as join26, resolve, sep } from "path";
|
|
15464
15573
|
function getProjectsConfigPath() {
|
|
15465
|
-
return
|
|
15574
|
+
return join26(getDataDir(), "projects.json");
|
|
15466
15575
|
}
|
|
15467
15576
|
function loadProjectsConfig() {
|
|
15468
15577
|
if (cachedConfig && cachedConfig.mtime === Number.MAX_SAFE_INTEGER) {
|
|
@@ -15477,7 +15586,7 @@ function loadProjectsConfig() {
|
|
|
15477
15586
|
if (cachedConfig && cachedConfig.mtime === mtime)
|
|
15478
15587
|
return cachedConfig.cfg;
|
|
15479
15588
|
try {
|
|
15480
|
-
const raw =
|
|
15589
|
+
const raw = readFileSync20(path, "utf-8");
|
|
15481
15590
|
const cfg = JSON.parse(raw);
|
|
15482
15591
|
cachedConfig = { mtime, cfg };
|
|
15483
15592
|
return cfg;
|
|
@@ -15574,7 +15683,7 @@ function matchDeclaredProject(realPath, projects) {
|
|
|
15574
15683
|
function matchChild(realPath, parentRoot, children) {
|
|
15575
15684
|
const sorted = [...children].sort((a, b) => b.path.length - a.path.length);
|
|
15576
15685
|
for (const c of sorted) {
|
|
15577
|
-
const childRoot = safeRealpath(
|
|
15686
|
+
const childRoot = safeRealpath(join26(parentRoot, c.path));
|
|
15578
15687
|
if (isInside(realPath, childRoot))
|
|
15579
15688
|
return c;
|
|
15580
15689
|
}
|
|
@@ -15609,7 +15718,7 @@ function findGitToplevel(realPath) {
|
|
|
15609
15718
|
let cur = realPath;
|
|
15610
15719
|
let last = "";
|
|
15611
15720
|
while (cur && cur !== last) {
|
|
15612
|
-
if (existsSync21(
|
|
15721
|
+
if (existsSync21(join26(cur, ".git")))
|
|
15613
15722
|
return cur;
|
|
15614
15723
|
last = cur;
|
|
15615
15724
|
cur = dirname14(cur);
|
|
@@ -15676,7 +15785,7 @@ function resolveAutoWorkspace(realPath, minRepos) {
|
|
|
15676
15785
|
let last = "";
|
|
15677
15786
|
let depth = 0;
|
|
15678
15787
|
while (cur && cur !== last && depth < AUTO_WORKSPACE_MAX_DEPTH) {
|
|
15679
|
-
if (!existsSync21(
|
|
15788
|
+
if (!existsSync21(join26(cur, ".git"))) {
|
|
15680
15789
|
const cached = workspaceCache.get(cur);
|
|
15681
15790
|
let qualifies;
|
|
15682
15791
|
if (cached === void 0) {
|
|
@@ -15707,12 +15816,12 @@ function countGitChildren(dir) {
|
|
|
15707
15816
|
for (const name of entries) {
|
|
15708
15817
|
if (name.startsWith("."))
|
|
15709
15818
|
continue;
|
|
15710
|
-
const child =
|
|
15819
|
+
const child = join26(dir, name);
|
|
15711
15820
|
try {
|
|
15712
15821
|
const st = statSync20(child);
|
|
15713
15822
|
if (!st.isDirectory())
|
|
15714
15823
|
continue;
|
|
15715
|
-
if (existsSync21(
|
|
15824
|
+
if (existsSync21(join26(child, ".git")))
|
|
15716
15825
|
count++;
|
|
15717
15826
|
} catch {
|
|
15718
15827
|
}
|
|
@@ -16422,7 +16531,7 @@ var init_source_registry = __esm({
|
|
|
16422
16531
|
// ../engine/dist/core/utils.js
|
|
16423
16532
|
import { existsSync as existsSync22, readdirSync as readdirSync16 } from "fs";
|
|
16424
16533
|
import { homedir as homedir7 } from "os";
|
|
16425
|
-
import { join as
|
|
16534
|
+
import { join as join27 } from "path";
|
|
16426
16535
|
function splitByHeaders(markdown) {
|
|
16427
16536
|
const lines = markdown.split("\n");
|
|
16428
16537
|
const sections = [];
|
|
@@ -16465,17 +16574,17 @@ function getClaudeDirs() {
|
|
|
16465
16574
|
for (const d of process.env.CLAUDE_DIRS.split(",")) {
|
|
16466
16575
|
const trimmed = d.trim();
|
|
16467
16576
|
if (trimmed) {
|
|
16468
|
-
add(trimmed.startsWith("~/") ?
|
|
16577
|
+
add(trimmed.startsWith("~/") ? join27(home, trimmed.slice(2)) : trimmed);
|
|
16469
16578
|
}
|
|
16470
16579
|
}
|
|
16471
16580
|
}
|
|
16472
|
-
add(
|
|
16581
|
+
add(join27(home, ".claude"));
|
|
16473
16582
|
try {
|
|
16474
16583
|
const entries = readdirSync16(home, { withFileTypes: true });
|
|
16475
16584
|
for (const entry of entries) {
|
|
16476
16585
|
if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
|
|
16477
|
-
const candidate =
|
|
16478
|
-
if (existsSync22(
|
|
16586
|
+
const candidate = join27(home, entry.name);
|
|
16587
|
+
if (existsSync22(join27(candidate, "projects"))) {
|
|
16479
16588
|
add(candidate);
|
|
16480
16589
|
}
|
|
16481
16590
|
}
|
|
@@ -16487,12 +16596,12 @@ function getClaudeDirs() {
|
|
|
16487
16596
|
function discoverSubdirs(subdir) {
|
|
16488
16597
|
const result = [];
|
|
16489
16598
|
for (const claudeDir of getClaudeDirs()) {
|
|
16490
|
-
const path =
|
|
16599
|
+
const path = join27(claudeDir, subdir);
|
|
16491
16600
|
if (existsSync22(path)) {
|
|
16492
16601
|
result.push(path);
|
|
16493
16602
|
}
|
|
16494
16603
|
}
|
|
16495
|
-
return result.length > 0 ? result : [
|
|
16604
|
+
return result.length > 0 ? result : [join27(homedir7(), ".claude", subdir)];
|
|
16496
16605
|
}
|
|
16497
16606
|
var init_utils = __esm({
|
|
16498
16607
|
"../engine/dist/core/utils.js"() {
|
|
@@ -16501,9 +16610,9 @@ var init_utils = __esm({
|
|
|
16501
16610
|
});
|
|
16502
16611
|
|
|
16503
16612
|
// ../engine/dist/parsers/plan-source.js
|
|
16504
|
-
import { existsSync as existsSync23, readdirSync as readdirSync17, readFileSync as
|
|
16613
|
+
import { existsSync as existsSync23, readdirSync as readdirSync17, readFileSync as readFileSync21, statSync as statSync22 } from "fs";
|
|
16505
16614
|
import { homedir as homedir8 } from "os";
|
|
16506
|
-
import { join as
|
|
16615
|
+
import { join as join28, basename as basename14 } from "path";
|
|
16507
16616
|
function parseFrontmatter(content) {
|
|
16508
16617
|
if (!content.startsWith("---"))
|
|
16509
16618
|
return { body: content };
|
|
@@ -16598,12 +16707,12 @@ var init_plan_source = __esm({
|
|
|
16598
16707
|
if (seenClaude.has(file))
|
|
16599
16708
|
continue;
|
|
16600
16709
|
seenClaude.add(file);
|
|
16601
|
-
const filePath =
|
|
16710
|
+
const filePath = join28(plansDir, file);
|
|
16602
16711
|
try {
|
|
16603
16712
|
const stat3 = statSync22(filePath);
|
|
16604
16713
|
const planName = basename14(file, ".md");
|
|
16605
16714
|
const isAgentPlan = planName.includes("-agent-");
|
|
16606
|
-
const content =
|
|
16715
|
+
const content = readFileSync21(filePath, "utf-8");
|
|
16607
16716
|
const fm = parseFrontmatter(content);
|
|
16608
16717
|
const body = fm.body;
|
|
16609
16718
|
const firstLine = body.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || planName;
|
|
@@ -16642,10 +16751,10 @@ var init_plan_source = __esm({
|
|
|
16642
16751
|
return;
|
|
16643
16752
|
}
|
|
16644
16753
|
for (const file of files) {
|
|
16645
|
-
const filePath =
|
|
16754
|
+
const filePath = join28(plansDir, file);
|
|
16646
16755
|
try {
|
|
16647
16756
|
const stat3 = statSync22(filePath);
|
|
16648
|
-
const content =
|
|
16757
|
+
const content = readFileSync21(filePath, "utf-8");
|
|
16649
16758
|
const firstLine = content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || file;
|
|
16650
16759
|
const planName = `${opencodeBackend.idPrefix}plan_${basename14(file, ".md")}`;
|
|
16651
16760
|
const projectPath = this.extractProjectPath(content);
|
|
@@ -16673,7 +16782,7 @@ var init_plan_source = __esm({
|
|
|
16673
16782
|
for (const match of content.matchAll(fullPathPattern)) {
|
|
16674
16783
|
let path = (match[1] || "").trim();
|
|
16675
16784
|
if (path.startsWith("~/")) {
|
|
16676
|
-
path =
|
|
16785
|
+
path = join28(homedir8(), path.slice(2));
|
|
16677
16786
|
}
|
|
16678
16787
|
for (const projectDir of knownProjects) {
|
|
16679
16788
|
if (path.startsWith(projectDir)) {
|
|
@@ -16722,7 +16831,7 @@ var init_plan_source = __esm({
|
|
|
16722
16831
|
async parse(item) {
|
|
16723
16832
|
if (!existsSync23(item.filePath))
|
|
16724
16833
|
return [];
|
|
16725
|
-
const content =
|
|
16834
|
+
const content = readFileSync21(item.filePath, "utf-8");
|
|
16726
16835
|
const chunks = [];
|
|
16727
16836
|
const { body } = parseFrontmatter(content);
|
|
16728
16837
|
const sections = splitByHeaders(body);
|
|
@@ -16758,9 +16867,9 @@ var init_plan_source = __esm({
|
|
|
16758
16867
|
const map = /* @__PURE__ */ new Map();
|
|
16759
16868
|
const root = claudeBackend.projectsDir();
|
|
16760
16869
|
for (const proj of safeReaddir(root)) {
|
|
16761
|
-
const projPath =
|
|
16870
|
+
const projPath = join28(root, proj);
|
|
16762
16871
|
for (const sessionEntry of safeReaddir(projPath)) {
|
|
16763
|
-
const subDir =
|
|
16872
|
+
const subDir = join28(projPath, sessionEntry, "subagents");
|
|
16764
16873
|
if (!existsSync23(subDir))
|
|
16765
16874
|
continue;
|
|
16766
16875
|
for (const f of safeReaddir(subDir)) {
|
|
@@ -16835,7 +16944,7 @@ var init_plan_source = __esm({
|
|
|
16835
16944
|
return links;
|
|
16836
16945
|
}
|
|
16837
16946
|
async *discoverAgyPlans() {
|
|
16838
|
-
const brainDir =
|
|
16947
|
+
const brainDir = join28(agyBackend.homeDir(), "brain");
|
|
16839
16948
|
if (!existsSync23(brainDir))
|
|
16840
16949
|
return;
|
|
16841
16950
|
let sessionDirs;
|
|
@@ -16845,7 +16954,7 @@ var init_plan_source = __esm({
|
|
|
16845
16954
|
return;
|
|
16846
16955
|
}
|
|
16847
16956
|
for (const rawId of sessionDirs) {
|
|
16848
|
-
const sessionPath =
|
|
16957
|
+
const sessionPath = join28(brainDir, rawId);
|
|
16849
16958
|
try {
|
|
16850
16959
|
if (!statSync22(sessionPath).isDirectory())
|
|
16851
16960
|
continue;
|
|
@@ -16859,10 +16968,10 @@ var init_plan_source = __esm({
|
|
|
16859
16968
|
continue;
|
|
16860
16969
|
}
|
|
16861
16970
|
for (const file of files) {
|
|
16862
|
-
const filePath =
|
|
16971
|
+
const filePath = join28(sessionPath, file);
|
|
16863
16972
|
try {
|
|
16864
16973
|
const stat3 = statSync22(filePath);
|
|
16865
|
-
const content =
|
|
16974
|
+
const content = readFileSync21(filePath, "utf-8");
|
|
16866
16975
|
const firstLine = content.split("\n").find((l) => l.trim())?.replace(/^#+\s*/, "").trim() || file;
|
|
16867
16976
|
const sessionLoc = agyBackend.findSession(rawId);
|
|
16868
16977
|
const projectPath = sessionLoc?.projectPath || this.extractProjectPath(content);
|
|
@@ -16891,8 +17000,8 @@ var init_plan_source = __esm({
|
|
|
16891
17000
|
});
|
|
16892
17001
|
|
|
16893
17002
|
// ../engine/dist/parsers/task-source.js
|
|
16894
|
-
import { existsSync as existsSync24, readdirSync as readdirSync18, readFileSync as
|
|
16895
|
-
import { join as
|
|
17003
|
+
import { existsSync as existsSync24, readdirSync as readdirSync18, readFileSync as readFileSync22, statSync as statSync23 } from "fs";
|
|
17004
|
+
import { join as join29 } from "path";
|
|
16896
17005
|
var MAX_CHUNK_CHARS2, TaskSource;
|
|
16897
17006
|
var init_task_source = __esm({
|
|
16898
17007
|
"../engine/dist/parsers/task-source.js"() {
|
|
@@ -16930,7 +17039,7 @@ var init_task_source = __esm({
|
|
|
16930
17039
|
return;
|
|
16931
17040
|
}
|
|
16932
17041
|
for (const file of files) {
|
|
16933
|
-
const filePath =
|
|
17042
|
+
const filePath = join29(todosDir, file);
|
|
16934
17043
|
let stat3;
|
|
16935
17044
|
try {
|
|
16936
17045
|
stat3 = statSync23(filePath);
|
|
@@ -16941,7 +17050,7 @@ var init_task_source = __esm({
|
|
|
16941
17050
|
continue;
|
|
16942
17051
|
let parsed;
|
|
16943
17052
|
try {
|
|
16944
|
-
const raw =
|
|
17053
|
+
const raw = readFileSync22(filePath, "utf-8");
|
|
16945
17054
|
parsed = JSON.parse(raw);
|
|
16946
17055
|
if (!Array.isArray(parsed) || parsed.length === 0)
|
|
16947
17056
|
continue;
|
|
@@ -16979,7 +17088,7 @@ var init_task_source = __esm({
|
|
|
16979
17088
|
if (!entry.isDirectory())
|
|
16980
17089
|
continue;
|
|
16981
17090
|
const sessionUuid = entry.name;
|
|
16982
|
-
const taskDir =
|
|
17091
|
+
const taskDir = join29(tasksDir, sessionUuid);
|
|
16983
17092
|
try {
|
|
16984
17093
|
const stat3 = statSync23(taskDir);
|
|
16985
17094
|
const taskFiles = readdirSync18(taskDir).filter((f) => f.endsWith(".json"));
|
|
@@ -17054,7 +17163,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
|
|
|
17054
17163
|
text,
|
|
17055
17164
|
chunkType: "task_detail",
|
|
17056
17165
|
projectPath: item.projectPath,
|
|
17057
|
-
filePath:
|
|
17166
|
+
filePath: join29(taskDir, `${task.id}.json`),
|
|
17058
17167
|
mtime: item.mtime
|
|
17059
17168
|
});
|
|
17060
17169
|
}
|
|
@@ -17079,7 +17188,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
|
|
|
17079
17188
|
return [];
|
|
17080
17189
|
let parsed;
|
|
17081
17190
|
try {
|
|
17082
|
-
parsed = JSON.parse(
|
|
17191
|
+
parsed = JSON.parse(readFileSync22(item.filePath, "utf-8"));
|
|
17083
17192
|
} catch {
|
|
17084
17193
|
return [];
|
|
17085
17194
|
}
|
|
@@ -17111,7 +17220,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
|
|
|
17111
17220
|
});
|
|
17112
17221
|
for (const file of sorted) {
|
|
17113
17222
|
try {
|
|
17114
|
-
const content =
|
|
17223
|
+
const content = readFileSync22(join29(taskDir, file), "utf-8");
|
|
17115
17224
|
const task = JSON.parse(content);
|
|
17116
17225
|
if (task.subject) {
|
|
17117
17226
|
tasks.push(task);
|
|
@@ -17127,9 +17236,9 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
|
|
|
17127
17236
|
});
|
|
17128
17237
|
|
|
17129
17238
|
// ../engine/dist/parsers/claude-md-source.js
|
|
17130
|
-
import { existsSync as existsSync25, readFileSync as
|
|
17239
|
+
import { existsSync as existsSync25, readFileSync as readFileSync23, readdirSync as readdirSync19, statSync as statSync24 } from "fs";
|
|
17131
17240
|
import { homedir as homedir9 } from "os";
|
|
17132
|
-
import { join as
|
|
17241
|
+
import { join as join30, basename as basename15, dirname as dirname15 } from "path";
|
|
17133
17242
|
import { createHash as createHash8 } from "crypto";
|
|
17134
17243
|
function discoverProjectDirs(claudeDir) {
|
|
17135
17244
|
const dirs = [];
|
|
@@ -17155,7 +17264,7 @@ function discoverProjectDirs(claudeDir) {
|
|
|
17155
17264
|
}
|
|
17156
17265
|
};
|
|
17157
17266
|
if (claudeDir) {
|
|
17158
|
-
scanProjectsDir(
|
|
17267
|
+
scanProjectsDir(join30(claudeDir, "projects"));
|
|
17159
17268
|
return dirs;
|
|
17160
17269
|
}
|
|
17161
17270
|
const home = homedir9();
|
|
@@ -17163,7 +17272,7 @@ function discoverProjectDirs(claudeDir) {
|
|
|
17163
17272
|
try {
|
|
17164
17273
|
for (const entry of readdirSync19(home, { withFileTypes: true })) {
|
|
17165
17274
|
if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
|
|
17166
|
-
scanProjectsDir(
|
|
17275
|
+
scanProjectsDir(join30(home, entry.name, "projects"));
|
|
17167
17276
|
}
|
|
17168
17277
|
}
|
|
17169
17278
|
} catch {
|
|
@@ -17171,7 +17280,7 @@ function discoverProjectDirs(claudeDir) {
|
|
|
17171
17280
|
const gemProjects = agyBackend.sharedProjectsJson();
|
|
17172
17281
|
if (existsSync25(gemProjects)) {
|
|
17173
17282
|
try {
|
|
17174
|
-
const data = JSON.parse(
|
|
17283
|
+
const data = JSON.parse(readFileSync23(gemProjects, "utf-8"));
|
|
17175
17284
|
for (const path of Object.keys(data.projects || {}))
|
|
17176
17285
|
addProject(path);
|
|
17177
17286
|
} catch {
|
|
@@ -17227,7 +17336,7 @@ var init_claude_md_source = __esm({
|
|
|
17227
17336
|
const seen = /* @__PURE__ */ new Set();
|
|
17228
17337
|
const seenKey = (path, tool) => `${tool}:${path}`;
|
|
17229
17338
|
for (const note of NOTE_FILES) {
|
|
17230
|
-
const p =
|
|
17339
|
+
const p = join30(homedir9(), note.filename);
|
|
17231
17340
|
const key2 = seenKey(p, note.tool);
|
|
17232
17341
|
if (existsSync25(p) && !seen.has(key2)) {
|
|
17233
17342
|
seen.add(key2);
|
|
@@ -17239,7 +17348,7 @@ var init_claude_md_source = __esm({
|
|
|
17239
17348
|
const projectDirs = discoverProjectDirs(this.claudeDir);
|
|
17240
17349
|
for (const projectDir of projectDirs) {
|
|
17241
17350
|
for (const note of NOTE_FILES) {
|
|
17242
|
-
const p =
|
|
17351
|
+
const p = join30(projectDir, note.filename);
|
|
17243
17352
|
const key2 = seenKey(p, note.tool);
|
|
17244
17353
|
if (existsSync25(p) && !seen.has(key2)) {
|
|
17245
17354
|
seen.add(key2);
|
|
@@ -17253,7 +17362,7 @@ var init_claude_md_source = __esm({
|
|
|
17253
17362
|
if (!existsSync25(searchDir))
|
|
17254
17363
|
continue;
|
|
17255
17364
|
for (const note of NOTE_FILES) {
|
|
17256
|
-
const directPath =
|
|
17365
|
+
const directPath = join30(searchDir, note.filename);
|
|
17257
17366
|
const key2 = seenKey(directPath, note.tool);
|
|
17258
17367
|
if (existsSync25(directPath) && !seen.has(key2)) {
|
|
17259
17368
|
seen.add(key2);
|
|
@@ -17268,7 +17377,7 @@ var init_claude_md_source = __esm({
|
|
|
17268
17377
|
if (!entry.isDirectory())
|
|
17269
17378
|
continue;
|
|
17270
17379
|
for (const note of NOTE_FILES) {
|
|
17271
|
-
const p =
|
|
17380
|
+
const p = join30(searchDir, entry.name, note.filename);
|
|
17272
17381
|
const key2 = seenKey(p, note.tool);
|
|
17273
17382
|
if (existsSync25(p) && !seen.has(key2)) {
|
|
17274
17383
|
seen.add(key2);
|
|
@@ -17286,7 +17395,7 @@ var init_claude_md_source = __esm({
|
|
|
17286
17395
|
async parse(item) {
|
|
17287
17396
|
if (!existsSync25(item.filePath))
|
|
17288
17397
|
return [];
|
|
17289
|
-
const content =
|
|
17398
|
+
const content = readFileSync23(item.filePath, "utf-8");
|
|
17290
17399
|
const chunks = [];
|
|
17291
17400
|
const sections = splitByHeaders(content);
|
|
17292
17401
|
for (let i = 0; i < sections.length; i++) {
|
|
@@ -17328,7 +17437,7 @@ var init_claude_md_source = __esm({
|
|
|
17328
17437
|
const projectDir = dirname15(filePath);
|
|
17329
17438
|
const projectName = basename15(projectDir);
|
|
17330
17439
|
const projectPath = projectDir;
|
|
17331
|
-
const content =
|
|
17440
|
+
const content = readFileSync23(filePath, "utf-8");
|
|
17332
17441
|
const firstLine = content.split("\n").find((l) => l.trim() && !l.startsWith("#"))?.trim()?.slice(0, 200) || `${filename} for ${projectName}`;
|
|
17333
17442
|
const id = tool === "claude" ? projectName : `${projectName}_${tool}`;
|
|
17334
17443
|
return {
|
|
@@ -17353,9 +17462,9 @@ var init_claude_md_source = __esm({
|
|
|
17353
17462
|
});
|
|
17354
17463
|
|
|
17355
17464
|
// ../engine/dist/parsers/agent-memory-source.js
|
|
17356
|
-
import { existsSync as existsSync26, readFileSync as
|
|
17465
|
+
import { existsSync as existsSync26, readFileSync as readFileSync24, readdirSync as readdirSync20, statSync as statSync25 } from "fs";
|
|
17357
17466
|
import { homedir as homedir10 } from "os";
|
|
17358
|
-
import { join as
|
|
17467
|
+
import { join as join31, basename as basename16 } from "path";
|
|
17359
17468
|
function parseFrontmatter2(content) {
|
|
17360
17469
|
const fm = {};
|
|
17361
17470
|
let body = content;
|
|
@@ -17397,7 +17506,7 @@ function discoverMemoryDirs() {
|
|
|
17397
17506
|
try {
|
|
17398
17507
|
for (const entry of readdirSync20(home, { withFileTypes: true })) {
|
|
17399
17508
|
if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
|
|
17400
|
-
claudeRoots.push(
|
|
17509
|
+
claudeRoots.push(join31(home, entry.name, "projects"));
|
|
17401
17510
|
}
|
|
17402
17511
|
}
|
|
17403
17512
|
} catch {
|
|
@@ -17409,7 +17518,7 @@ function discoverMemoryDirs() {
|
|
|
17409
17518
|
for (const entry of readdirSync20(projectsDir, { withFileTypes: true })) {
|
|
17410
17519
|
if (!entry.isDirectory() || entry.name.startsWith("."))
|
|
17411
17520
|
continue;
|
|
17412
|
-
add(
|
|
17521
|
+
add(join31(projectsDir, entry.name, "memory"), entry.name);
|
|
17413
17522
|
}
|
|
17414
17523
|
} catch {
|
|
17415
17524
|
}
|
|
@@ -17438,7 +17547,7 @@ var init_agent_memory_source = __esm({
|
|
|
17438
17547
|
for (const entry of readdirSync20(memoryDir, { withFileTypes: true })) {
|
|
17439
17548
|
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
17440
17549
|
continue;
|
|
17441
|
-
const filePath =
|
|
17550
|
+
const filePath = join31(memoryDir, entry.name);
|
|
17442
17551
|
if (seen.has(filePath))
|
|
17443
17552
|
continue;
|
|
17444
17553
|
seen.add(filePath);
|
|
@@ -17454,7 +17563,7 @@ var init_agent_memory_source = __esm({
|
|
|
17454
17563
|
async parse(item) {
|
|
17455
17564
|
if (!existsSync26(item.filePath))
|
|
17456
17565
|
return [];
|
|
17457
|
-
const content =
|
|
17566
|
+
const content = readFileSync24(item.filePath, "utf-8");
|
|
17458
17567
|
const { body } = parseFrontmatter2(content);
|
|
17459
17568
|
const chunks = [];
|
|
17460
17569
|
const sections = splitByHeaders(body);
|
|
@@ -17507,7 +17616,7 @@ var init_agent_memory_source = __esm({
|
|
|
17507
17616
|
fileToItem(filePath, filename, projectPath, _projectHash) {
|
|
17508
17617
|
try {
|
|
17509
17618
|
const stat3 = statSync25(filePath);
|
|
17510
|
-
const content =
|
|
17619
|
+
const content = readFileSync24(filePath, "utf-8");
|
|
17511
17620
|
const { fm } = parseFrontmatter2(content);
|
|
17512
17621
|
const stem = filename.replace(/\.md$/, "");
|
|
17513
17622
|
const idBase = fm.name || stem;
|
|
@@ -17542,7 +17651,7 @@ import { existsSync as existsSync27, readdirSync as readdirSync21, statSync as s
|
|
|
17542
17651
|
import { createReadStream as createReadStream3 } from "fs";
|
|
17543
17652
|
import { createInterface as createInterface2 } from "readline";
|
|
17544
17653
|
import { homedir as homedir11 } from "os";
|
|
17545
|
-
import { join as
|
|
17654
|
+
import { join as join32 } from "path";
|
|
17546
17655
|
var MAX_CHUNK_CHARS5, HistorySource;
|
|
17547
17656
|
var init_history_source = __esm({
|
|
17548
17657
|
"../engine/dist/parsers/history-source.js"() {
|
|
@@ -17567,12 +17676,12 @@ var init_history_source = __esm({
|
|
|
17567
17676
|
try {
|
|
17568
17677
|
for (const entry of readdirSync21(home, { withFileTypes: true })) {
|
|
17569
17678
|
if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
|
|
17570
|
-
tryAdd(
|
|
17679
|
+
tryAdd(join32(home, entry.name, "history.jsonl"));
|
|
17571
17680
|
}
|
|
17572
17681
|
}
|
|
17573
17682
|
} catch {
|
|
17574
17683
|
}
|
|
17575
|
-
this.historyPaths = paths.length > 0 ? paths : [
|
|
17684
|
+
this.historyPaths = paths.length > 0 ? paths : [join32(home, ".claude", "history.jsonl")];
|
|
17576
17685
|
}
|
|
17577
17686
|
}
|
|
17578
17687
|
async *discover() {
|
|
@@ -17722,9 +17831,9 @@ var init_history_source = __esm({
|
|
|
17722
17831
|
});
|
|
17723
17832
|
|
|
17724
17833
|
// ../engine/dist/parsers/paste-source.js
|
|
17725
|
-
import { existsSync as existsSync28, readdirSync as readdirSync22, readFileSync as
|
|
17834
|
+
import { existsSync as existsSync28, readdirSync as readdirSync22, readFileSync as readFileSync25, statSync as statSync27 } from "fs";
|
|
17726
17835
|
import { homedir as homedir12 } from "os";
|
|
17727
|
-
import { join as
|
|
17836
|
+
import { join as join33, basename as basename17 } from "path";
|
|
17728
17837
|
var MAX_CHUNK_CHARS6, MAX_FILE_SIZE, PasteSource;
|
|
17729
17838
|
var init_paste_source = __esm({
|
|
17730
17839
|
"../engine/dist/parsers/paste-source.js"() {
|
|
@@ -17750,7 +17859,7 @@ var init_paste_source = __esm({
|
|
|
17750
17859
|
try {
|
|
17751
17860
|
for (const entry of readdirSync22(home, { withFileTypes: true })) {
|
|
17752
17861
|
if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-code") {
|
|
17753
|
-
tryAdd(
|
|
17862
|
+
tryAdd(join33(home, entry.name, "paste-cache"));
|
|
17754
17863
|
}
|
|
17755
17864
|
}
|
|
17756
17865
|
} catch {
|
|
@@ -17770,7 +17879,7 @@ var init_paste_source = __esm({
|
|
|
17770
17879
|
if (seen.has(file))
|
|
17771
17880
|
continue;
|
|
17772
17881
|
seen.add(file);
|
|
17773
|
-
const filePath =
|
|
17882
|
+
const filePath = join33(cacheDir, file);
|
|
17774
17883
|
try {
|
|
17775
17884
|
const stat3 = statSync27(filePath);
|
|
17776
17885
|
if (stat3.size > MAX_FILE_SIZE)
|
|
@@ -17778,7 +17887,7 @@ var init_paste_source = __esm({
|
|
|
17778
17887
|
if (stat3.size < 10)
|
|
17779
17888
|
continue;
|
|
17780
17889
|
const hash = basename17(file, ".txt");
|
|
17781
|
-
const content =
|
|
17890
|
+
const content = readFileSync25(filePath, "utf-8");
|
|
17782
17891
|
const firstLine = content.split("\n").find((l) => l.trim().length > 5)?.trim()?.slice(0, 100) || `Paste ${hash.slice(0, 8)}`;
|
|
17783
17892
|
yield {
|
|
17784
17893
|
id: hash,
|
|
@@ -17799,7 +17908,7 @@ var init_paste_source = __esm({
|
|
|
17799
17908
|
async parse(item) {
|
|
17800
17909
|
if (!existsSync28(item.filePath))
|
|
17801
17910
|
return [];
|
|
17802
|
-
const content =
|
|
17911
|
+
const content = readFileSync25(item.filePath, "utf-8");
|
|
17803
17912
|
if (content.trim().length < 20)
|
|
17804
17913
|
return [];
|
|
17805
17914
|
return [{
|
|
@@ -17822,8 +17931,8 @@ var init_paste_source = __esm({
|
|
|
17822
17931
|
});
|
|
17823
17932
|
|
|
17824
17933
|
// ../engine/dist/parsers/antigravity-brain-source.js
|
|
17825
|
-
import { existsSync as existsSync29, readdirSync as readdirSync23, readFileSync as
|
|
17826
|
-
import { join as
|
|
17934
|
+
import { existsSync as existsSync29, readdirSync as readdirSync23, readFileSync as readFileSync26, statSync as statSync28 } from "fs";
|
|
17935
|
+
import { join as join34 } from "path";
|
|
17827
17936
|
var MAX_CHUNK_CHARS7, AntigravityBrainSource;
|
|
17828
17937
|
var init_antigravity_brain_source = __esm({
|
|
17829
17938
|
"../engine/dist/parsers/antigravity-brain-source.js"() {
|
|
@@ -17847,22 +17956,22 @@ var init_antigravity_brain_source = __esm({
|
|
|
17847
17956
|
for (const entry of sessions) {
|
|
17848
17957
|
if (!entry.isDirectory())
|
|
17849
17958
|
continue;
|
|
17850
|
-
const sessionDir =
|
|
17959
|
+
const sessionDir = join34(this.brainDir, entry.name);
|
|
17851
17960
|
const files = readdirSync23(sessionDir).filter((f) => f.endsWith(".md") && !f.includes(".resolved") && !f.includes(".metadata"));
|
|
17852
17961
|
if (files.length === 0)
|
|
17853
17962
|
continue;
|
|
17854
17963
|
for (const file of files) {
|
|
17855
|
-
const filePath =
|
|
17964
|
+
const filePath = join34(sessionDir, file);
|
|
17856
17965
|
try {
|
|
17857
17966
|
const stat3 = statSync28(filePath);
|
|
17858
|
-
const content =
|
|
17967
|
+
const content = readFileSync26(filePath, "utf-8");
|
|
17859
17968
|
const firstLine = content.split("\n").find((l) => l.trim() && !l.startsWith("#"))?.trim() || "";
|
|
17860
17969
|
const heading = content.split("\n").find((l) => l.startsWith("#"))?.replace(/^#+\s*/, "").trim() || file;
|
|
17861
17970
|
const metaPath = `${filePath}.metadata.json`;
|
|
17862
17971
|
let metaSummary = "";
|
|
17863
17972
|
if (existsSync29(metaPath)) {
|
|
17864
17973
|
try {
|
|
17865
|
-
const meta = JSON.parse(
|
|
17974
|
+
const meta = JSON.parse(readFileSync26(metaPath, "utf-8"));
|
|
17866
17975
|
metaSummary = meta.summary || "";
|
|
17867
17976
|
} catch {
|
|
17868
17977
|
}
|
|
@@ -17893,7 +18002,7 @@ var init_antigravity_brain_source = __esm({
|
|
|
17893
18002
|
async parse(item) {
|
|
17894
18003
|
if (!existsSync29(item.filePath))
|
|
17895
18004
|
return [];
|
|
17896
|
-
const content =
|
|
18005
|
+
const content = readFileSync26(item.filePath, "utf-8");
|
|
17897
18006
|
const chunks = [];
|
|
17898
18007
|
const sections = splitByHeaders(content);
|
|
17899
18008
|
for (let i = 0; i < sections.length; i++) {
|
|
@@ -18236,8 +18345,8 @@ var init_opencode_todo_source = __esm({
|
|
|
18236
18345
|
});
|
|
18237
18346
|
|
|
18238
18347
|
// ../engine/dist/parsers/codex-session-source.js
|
|
18239
|
-
import { existsSync as existsSync32, readdirSync as readdirSync24, readFileSync as
|
|
18240
|
-
import { join as
|
|
18348
|
+
import { existsSync as existsSync32, readdirSync as readdirSync24, readFileSync as readFileSync27, statSync as statSync29 } from "fs";
|
|
18349
|
+
import { join as join35, basename as basename18 } from "path";
|
|
18241
18350
|
function getCodexSessionsDir() {
|
|
18242
18351
|
return codexBackend.sessionsDir();
|
|
18243
18352
|
}
|
|
@@ -18264,7 +18373,7 @@ function extractReasoningText(event) {
|
|
|
18264
18373
|
return "";
|
|
18265
18374
|
}
|
|
18266
18375
|
function readJsonlLines(filePath) {
|
|
18267
|
-
const text =
|
|
18376
|
+
const text = readFileSync27(filePath, "utf-8");
|
|
18268
18377
|
const lines = text.split("\n");
|
|
18269
18378
|
const events = [];
|
|
18270
18379
|
for (const line of lines) {
|
|
@@ -18299,7 +18408,7 @@ var init_codex_session_source = __esm({
|
|
|
18299
18408
|
for (const filePath of jsonlFiles) {
|
|
18300
18409
|
try {
|
|
18301
18410
|
const stat3 = statSync29(filePath);
|
|
18302
|
-
const lines =
|
|
18411
|
+
const lines = readFileSync27(filePath, "utf-8").split("\n");
|
|
18303
18412
|
const firstLine = lines.find((l) => l.trim());
|
|
18304
18413
|
if (!firstLine)
|
|
18305
18414
|
continue;
|
|
@@ -18458,7 +18567,7 @@ var init_codex_session_source = __esm({
|
|
|
18458
18567
|
if (!existsSync32(dir))
|
|
18459
18568
|
return results;
|
|
18460
18569
|
for (const entry of readdirSync24(dir, { withFileTypes: true })) {
|
|
18461
|
-
const fullPath =
|
|
18570
|
+
const fullPath = join35(dir, entry.name);
|
|
18462
18571
|
if (entry.isDirectory()) {
|
|
18463
18572
|
results.push(...this.collectJsonlFiles(fullPath));
|
|
18464
18573
|
} else if (entry.isFile() && entry.name.startsWith("rollout-") && entry.name.endsWith(".jsonl")) {
|
|
@@ -18472,8 +18581,8 @@ var init_codex_session_source = __esm({
|
|
|
18472
18581
|
});
|
|
18473
18582
|
|
|
18474
18583
|
// ../engine/dist/parsers/diary-source.js
|
|
18475
|
-
import { existsSync as existsSync33, mkdirSync as mkdirSync7, readdirSync as readdirSync25, readFileSync as
|
|
18476
|
-
import { join as
|
|
18584
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync7, readdirSync as readdirSync25, readFileSync as readFileSync28, writeFileSync as writeFileSync7, statSync as statSync30 } from "fs";
|
|
18585
|
+
import { join as join36, basename as basename19 } from "path";
|
|
18477
18586
|
var MAX_CHUNK_CHARS10, DiarySource;
|
|
18478
18587
|
var init_diary_source = __esm({
|
|
18479
18588
|
"../engine/dist/parsers/diary-source.js"() {
|
|
@@ -18492,13 +18601,13 @@ var init_diary_source = __esm({
|
|
|
18492
18601
|
return;
|
|
18493
18602
|
const agents = readdirSync25(this.diaryDir, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
18494
18603
|
for (const agentDir of agents) {
|
|
18495
|
-
const agentPath2 =
|
|
18604
|
+
const agentPath2 = join36(this.diaryDir, agentDir.name);
|
|
18496
18605
|
const files = readdirSync25(agentPath2).filter((f) => f.endsWith(".json"));
|
|
18497
18606
|
for (const file of files) {
|
|
18498
|
-
const filePath =
|
|
18607
|
+
const filePath = join36(agentPath2, file);
|
|
18499
18608
|
try {
|
|
18500
18609
|
const stat3 = statSync30(filePath);
|
|
18501
|
-
const raw =
|
|
18610
|
+
const raw = readFileSync28(filePath, "utf-8");
|
|
18502
18611
|
const entry = JSON.parse(raw);
|
|
18503
18612
|
const entryId = basename19(file, ".json");
|
|
18504
18613
|
const title = `[${entry.agent}] ${entry.topic}: ${entry.content.slice(0, 80)}`;
|
|
@@ -18525,7 +18634,7 @@ var init_diary_source = __esm({
|
|
|
18525
18634
|
async parse(item) {
|
|
18526
18635
|
if (!existsSync33(item.filePath))
|
|
18527
18636
|
return [];
|
|
18528
|
-
const raw =
|
|
18637
|
+
const raw = readFileSync28(item.filePath, "utf-8");
|
|
18529
18638
|
const entry = JSON.parse(raw);
|
|
18530
18639
|
if (!entry.content || entry.content.trim().length < 10)
|
|
18531
18640
|
return [];
|
|
@@ -18562,18 +18671,18 @@ var init_diary_source = __esm({
|
|
|
18562
18671
|
*/
|
|
18563
18672
|
static write(entry, diaryDir) {
|
|
18564
18673
|
const dir = diaryDir || getDiaryDir();
|
|
18565
|
-
const agentDir =
|
|
18674
|
+
const agentDir = join36(dir, entry.agent.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
|
|
18566
18675
|
if (!existsSync33(agentDir)) {
|
|
18567
18676
|
mkdirSync7(agentDir, { recursive: true });
|
|
18568
18677
|
}
|
|
18569
18678
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
18570
18679
|
const entryId = `diary_${entry.agent.toLowerCase()}_${ts}`;
|
|
18571
|
-
const filePath =
|
|
18680
|
+
const filePath = join36(agentDir, `${entryId}.json`);
|
|
18572
18681
|
const full = {
|
|
18573
18682
|
...entry,
|
|
18574
18683
|
timestamp: entry.timestamp || (/* @__PURE__ */ new Date()).toISOString()
|
|
18575
18684
|
};
|
|
18576
|
-
|
|
18685
|
+
writeFileSync7(filePath, JSON.stringify(full, null, 2), "utf-8");
|
|
18577
18686
|
return entryId;
|
|
18578
18687
|
}
|
|
18579
18688
|
/**
|
|
@@ -18581,14 +18690,14 @@ var init_diary_source = __esm({
|
|
|
18581
18690
|
*/
|
|
18582
18691
|
static read(agentName, lastN = 10, diaryDir) {
|
|
18583
18692
|
const dir = diaryDir || getDiaryDir();
|
|
18584
|
-
const agentDir =
|
|
18693
|
+
const agentDir = join36(dir, agentName.toLowerCase().replace(/[^a-z0-9_-]/g, "_"));
|
|
18585
18694
|
if (!existsSync33(agentDir))
|
|
18586
18695
|
return [];
|
|
18587
18696
|
const files = readdirSync25(agentDir).filter((f) => f.endsWith(".json")).sort().reverse().slice(0, lastN);
|
|
18588
18697
|
const entries = [];
|
|
18589
18698
|
for (const file of files) {
|
|
18590
18699
|
try {
|
|
18591
|
-
const raw =
|
|
18700
|
+
const raw = readFileSync28(join36(agentDir, file), "utf-8");
|
|
18592
18701
|
entries.push(JSON.parse(raw));
|
|
18593
18702
|
} catch {
|
|
18594
18703
|
continue;
|
|
@@ -18633,9 +18742,9 @@ var init_redact_inline = __esm({
|
|
|
18633
18742
|
});
|
|
18634
18743
|
|
|
18635
18744
|
// ../engine/dist/parsers/skills-source.js
|
|
18636
|
-
import { existsSync as existsSync34, readdirSync as readdirSync26, readFileSync as
|
|
18745
|
+
import { existsSync as existsSync34, readdirSync as readdirSync26, readFileSync as readFileSync29, statSync as statSync31 } from "fs";
|
|
18637
18746
|
import { homedir as homedir13 } from "os";
|
|
18638
|
-
import { join as
|
|
18747
|
+
import { join as join37 } from "path";
|
|
18639
18748
|
function rebuildBody(content) {
|
|
18640
18749
|
const { text, redacted } = redactInlineSecrets(content);
|
|
18641
18750
|
const out = {};
|
|
@@ -18653,31 +18762,31 @@ function resolveRoots() {
|
|
|
18653
18762
|
const home = homedir13();
|
|
18654
18763
|
const all = [];
|
|
18655
18764
|
if (isSourceEnabled("shared", "skills")) {
|
|
18656
|
-
all.push({ path:
|
|
18765
|
+
all.push({ path: join37(home, ".agents", "skills"), tool: "shared" });
|
|
18657
18766
|
}
|
|
18658
18767
|
if (isSourceEnabled("claude", "skills")) {
|
|
18659
18768
|
all.push({ path: claudeBackend.skillsDir(), tool: "claude" });
|
|
18660
18769
|
}
|
|
18661
18770
|
if (isSourceEnabled("hermes", "skills")) {
|
|
18662
|
-
all.push({ path:
|
|
18771
|
+
all.push({ path: join37(hermesBackend.homeDir(), "skills"), tool: "hermes", nested: true });
|
|
18663
18772
|
}
|
|
18664
18773
|
if (isSourceEnabled("pi", "skills")) {
|
|
18665
18774
|
all.push({ path: piBackend.skillsDir(), tool: "pi" });
|
|
18666
18775
|
}
|
|
18667
18776
|
if (isSourceEnabled("agy", "skills")) {
|
|
18668
|
-
all.push({ path:
|
|
18777
|
+
all.push({ path: join37(agyBackend.homeDir(), "skills"), tool: "agy" });
|
|
18669
18778
|
all.push({ path: agyBackend.sharedSkillsDir(), tool: "agy" });
|
|
18670
18779
|
}
|
|
18671
18780
|
if (isSourceEnabled("opencode", "skills")) {
|
|
18672
|
-
all.push({ path:
|
|
18781
|
+
all.push({ path: join37(home, ".config", "opencode", "skills"), tool: "opencode" }, { path: join37(home, ".config", "opencode", "skill"), tool: "opencode" }, { path: join37(home, ".opencode", "skill"), tool: "opencode" }, { path: join37(home, ".opencode", "skills"), tool: "opencode" });
|
|
18673
18782
|
}
|
|
18674
18783
|
if (isSourceEnabled("codex", "skills")) {
|
|
18675
18784
|
all.push({ path: codexBackend.skillsDir(), tool: "codex", skipChildren: [".system"] });
|
|
18676
18785
|
all.push({ path: codexBackend.skillsSystemDir(), tool: "codex", readonly: true });
|
|
18677
18786
|
}
|
|
18678
18787
|
if (isSourceEnabled("cursor", "skills")) {
|
|
18679
|
-
all.push({ path:
|
|
18680
|
-
all.push({ path:
|
|
18788
|
+
all.push({ path: join37(cursorHomeDir(), "skills"), tool: "cursor" });
|
|
18789
|
+
all.push({ path: join37(cursorHomeDir(), "skills-cursor"), tool: "cursor", readonly: true });
|
|
18681
18790
|
}
|
|
18682
18791
|
return all.filter((r) => existsSync34(r.path));
|
|
18683
18792
|
}
|
|
@@ -18722,7 +18831,7 @@ var init_skills_source = __esm({
|
|
|
18722
18831
|
if (!isSourceEnabled("codex", "skills"))
|
|
18723
18832
|
return;
|
|
18724
18833
|
for (const { name: pluginName, dir } of codexBackend.installedPluginDirs()) {
|
|
18725
|
-
const skillsDir =
|
|
18834
|
+
const skillsDir = join37(dir, "skills");
|
|
18726
18835
|
if (!existsSync34(skillsDir))
|
|
18727
18836
|
continue;
|
|
18728
18837
|
yield* this.fromSkillRoot({ path: skillsDir, tool: "codex" }, pluginName);
|
|
@@ -18738,7 +18847,7 @@ var init_skills_source = __esm({
|
|
|
18738
18847
|
for (const name of entries) {
|
|
18739
18848
|
if (root.skipChildren?.includes(name))
|
|
18740
18849
|
continue;
|
|
18741
|
-
const skillDir =
|
|
18850
|
+
const skillDir = join37(root.path, name);
|
|
18742
18851
|
let st;
|
|
18743
18852
|
try {
|
|
18744
18853
|
st = statSync31(skillDir);
|
|
@@ -18747,7 +18856,7 @@ var init_skills_source = __esm({
|
|
|
18747
18856
|
}
|
|
18748
18857
|
if (!st.isDirectory())
|
|
18749
18858
|
continue;
|
|
18750
|
-
const skillMd =
|
|
18859
|
+
const skillMd = join37(skillDir, "SKILL.md");
|
|
18751
18860
|
if (!existsSync34(skillMd)) {
|
|
18752
18861
|
if (root.nested)
|
|
18753
18862
|
yield* this.fromSkillRoot({ ...root, path: skillDir, nested: false });
|
|
@@ -18755,7 +18864,7 @@ var init_skills_source = __esm({
|
|
|
18755
18864
|
}
|
|
18756
18865
|
let content;
|
|
18757
18866
|
try {
|
|
18758
|
-
content =
|
|
18867
|
+
content = readFileSync29(skillMd, "utf-8");
|
|
18759
18868
|
} catch {
|
|
18760
18869
|
continue;
|
|
18761
18870
|
}
|
|
@@ -18769,7 +18878,7 @@ var init_skills_source = __esm({
|
|
|
18769
18878
|
const subdirs = {};
|
|
18770
18879
|
try {
|
|
18771
18880
|
for (const sub of readdirSync26(skillDir)) {
|
|
18772
|
-
const subPath =
|
|
18881
|
+
const subPath = join37(skillDir, sub);
|
|
18773
18882
|
try {
|
|
18774
18883
|
const ss = statSync31(subPath);
|
|
18775
18884
|
if (ss.isDirectory()) {
|
|
@@ -18818,7 +18927,7 @@ var init_skills_source = __esm({
|
|
|
18818
18927
|
async parse(item) {
|
|
18819
18928
|
if (!existsSync34(item.filePath))
|
|
18820
18929
|
return [];
|
|
18821
|
-
const content =
|
|
18930
|
+
const content = readFileSync29(item.filePath, "utf-8");
|
|
18822
18931
|
if (!content.trim())
|
|
18823
18932
|
return [];
|
|
18824
18933
|
return [{
|
|
@@ -26171,16 +26280,16 @@ var require_dist = __commonJS({
|
|
|
26171
26280
|
});
|
|
26172
26281
|
|
|
26173
26282
|
// ../engine/dist/core/hermes-config.js
|
|
26174
|
-
import { existsSync as existsSync35, readFileSync as
|
|
26175
|
-
import { join as
|
|
26283
|
+
import { existsSync as existsSync35, readFileSync as readFileSync30 } from "fs";
|
|
26284
|
+
import { join as join38 } from "path";
|
|
26176
26285
|
function hermesConfigPath() {
|
|
26177
|
-
return
|
|
26286
|
+
return join38(hermesHomeDir(), "config.yaml");
|
|
26178
26287
|
}
|
|
26179
26288
|
function readHermesMcpServers(path = hermesConfigPath()) {
|
|
26180
26289
|
if (!existsSync35(path))
|
|
26181
26290
|
return null;
|
|
26182
26291
|
try {
|
|
26183
|
-
const cfg = (0, import_yaml.parse)(
|
|
26292
|
+
const cfg = (0, import_yaml.parse)(readFileSync30(path, "utf-8"));
|
|
26184
26293
|
return cfg?.mcp_servers && typeof cfg.mcp_servers === "object" ? cfg.mcp_servers : null;
|
|
26185
26294
|
} catch {
|
|
26186
26295
|
return null;
|
|
@@ -26230,14 +26339,14 @@ var init_hermes_config = __esm({
|
|
|
26230
26339
|
});
|
|
26231
26340
|
|
|
26232
26341
|
// ../engine/dist/parsers/mcps-source.js
|
|
26233
|
-
import { existsSync as existsSync36, readFileSync as
|
|
26342
|
+
import { existsSync as existsSync36, readFileSync as readFileSync31, statSync as statSync32 } from "fs";
|
|
26234
26343
|
import { homedir as homedir14 } from "os";
|
|
26235
|
-
import { join as
|
|
26344
|
+
import { join as join39 } from "path";
|
|
26236
26345
|
function readJson(path) {
|
|
26237
26346
|
if (!existsSync36(path))
|
|
26238
26347
|
return null;
|
|
26239
26348
|
try {
|
|
26240
|
-
const raw =
|
|
26349
|
+
const raw = readFileSync31(path, "utf-8");
|
|
26241
26350
|
const stripped = path.endsWith(".jsonc") ? raw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/,(\s*[}\]])/g, "$1") : raw;
|
|
26242
26351
|
return JSON.parse(stripped);
|
|
26243
26352
|
} catch {
|
|
@@ -26299,23 +26408,23 @@ var init_mcps_source = __esm({
|
|
|
26299
26408
|
if (!isSourceEnabled("common", "mcps"))
|
|
26300
26409
|
return;
|
|
26301
26410
|
const home = homedir14();
|
|
26302
|
-
yield* this.fromObject(readJson(
|
|
26411
|
+
yield* this.fromObject(readJson(join39(home, ".mcp.json"))?.mcpServers, {
|
|
26303
26412
|
tool: "claude",
|
|
26304
|
-
filePath:
|
|
26413
|
+
filePath: join39(home, ".mcp.json"),
|
|
26305
26414
|
scope: "global"
|
|
26306
26415
|
});
|
|
26307
|
-
yield* this.fromObject(readJson(
|
|
26416
|
+
yield* this.fromObject(readJson(join39(home, ".claude.json"))?.mcpServers, {
|
|
26308
26417
|
tool: "claude",
|
|
26309
|
-
filePath:
|
|
26418
|
+
filePath: join39(home, ".claude.json"),
|
|
26310
26419
|
scope: "user"
|
|
26311
26420
|
});
|
|
26312
26421
|
for (const path of [
|
|
26313
|
-
|
|
26314
|
-
|
|
26315
|
-
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
|
|
26422
|
+
join39(home, ".config", "opencode", "opencode.json"),
|
|
26423
|
+
join39(home, ".config", "opencode", "opencode.jsonc"),
|
|
26424
|
+
join39(home, ".config", "opencode", "config.json"),
|
|
26425
|
+
join39(home, ".opencode", "opencode.json"),
|
|
26426
|
+
join39(home, ".opencode", "opencode.jsonc"),
|
|
26427
|
+
join39(home, ".opencode", "config.json")
|
|
26319
26428
|
]) {
|
|
26320
26429
|
yield* this.fromObject(readJson(path)?.mcp, {
|
|
26321
26430
|
tool: "opencode",
|
|
@@ -26330,7 +26439,7 @@ var init_mcps_source = __esm({
|
|
|
26330
26439
|
filePath: geminiSettings,
|
|
26331
26440
|
scope: "user"
|
|
26332
26441
|
});
|
|
26333
|
-
const cursorMcp =
|
|
26442
|
+
const cursorMcp = join39(cursorHomeDir(), "mcp.json");
|
|
26334
26443
|
yield* this.fromObject(readJson(cursorMcp)?.mcpServers, {
|
|
26335
26444
|
tool: "cursor",
|
|
26336
26445
|
filePath: cursorMcp,
|
|
@@ -26348,7 +26457,7 @@ var init_mcps_source = __esm({
|
|
|
26348
26457
|
filePath: piMcp,
|
|
26349
26458
|
scope: "user"
|
|
26350
26459
|
});
|
|
26351
|
-
const agyMcp =
|
|
26460
|
+
const agyMcp = join39(home, ".gemini", "config", "mcp_config.json");
|
|
26352
26461
|
yield* this.fromObject(readJson(agyMcp)?.mcpServers, {
|
|
26353
26462
|
tool: "agy",
|
|
26354
26463
|
filePath: agyMcp,
|
|
@@ -26356,7 +26465,7 @@ var init_mcps_source = __esm({
|
|
|
26356
26465
|
});
|
|
26357
26466
|
yield* this.fromCodexToml(codexBackend.configToml());
|
|
26358
26467
|
for (const { dir } of codexBackend.installedPluginDirs()) {
|
|
26359
|
-
const mcpPath =
|
|
26468
|
+
const mcpPath = join39(dir, ".mcp.json");
|
|
26360
26469
|
yield* this.fromObject(readJson(mcpPath)?.mcpServers, {
|
|
26361
26470
|
tool: "codex",
|
|
26362
26471
|
filePath: mcpPath,
|
|
@@ -26414,7 +26523,7 @@ var init_mcps_source = __esm({
|
|
|
26414
26523
|
return;
|
|
26415
26524
|
let content;
|
|
26416
26525
|
try {
|
|
26417
|
-
content =
|
|
26526
|
+
content = readFileSync31(path, "utf-8");
|
|
26418
26527
|
} catch {
|
|
26419
26528
|
return;
|
|
26420
26529
|
}
|
|
@@ -26583,8 +26692,8 @@ var init_toolkit_format = __esm({
|
|
|
26583
26692
|
});
|
|
26584
26693
|
|
|
26585
26694
|
// ../engine/dist/parsers/slash-commands-source.js
|
|
26586
|
-
import { existsSync as existsSync37, readdirSync as readdirSync27, readFileSync as
|
|
26587
|
-
import { join as
|
|
26695
|
+
import { existsSync as existsSync37, readdirSync as readdirSync27, readFileSync as readFileSync32, statSync as statSync33 } from "fs";
|
|
26696
|
+
import { join as join40, basename as basename20 } from "path";
|
|
26588
26697
|
function rebuildBody2(content) {
|
|
26589
26698
|
const { text, redacted } = redactInlineSecrets(content);
|
|
26590
26699
|
const out = {};
|
|
@@ -26643,7 +26752,7 @@ var init_slash_commands_source = __esm({
|
|
|
26643
26752
|
if (!entry.isDirectory() || entry.name.startsWith("."))
|
|
26644
26753
|
continue;
|
|
26645
26754
|
const projectPath = resolveProjectDirName(entry.name);
|
|
26646
|
-
const cmdDir =
|
|
26755
|
+
const cmdDir = join40(projectPath, ".claude", "commands");
|
|
26647
26756
|
if (existsSync37(cmdDir))
|
|
26648
26757
|
roots.push({ path: cmdDir, tool: "claude", scope: "project", projectPath, format: "md" });
|
|
26649
26758
|
}
|
|
@@ -26652,7 +26761,7 @@ var init_slash_commands_source = __esm({
|
|
|
26652
26761
|
}
|
|
26653
26762
|
}
|
|
26654
26763
|
if (isSourceEnabled("agy", "commands")) {
|
|
26655
|
-
roots.push({ path:
|
|
26764
|
+
roots.push({ path: join40(agyBackend.homeDir(), "commands"), tool: "agy", scope: "user", projectPath: "", format: "toml" });
|
|
26656
26765
|
roots.push({ path: agyBackend.sharedCommandsDir(), tool: "agy", scope: "user", projectPath: "", format: "toml" });
|
|
26657
26766
|
}
|
|
26658
26767
|
if (isSourceEnabled("opencode", "commands")) {
|
|
@@ -26662,7 +26771,7 @@ var init_slash_commands_source = __esm({
|
|
|
26662
26771
|
roots.push({ path: codexBackend.promptsDir(), tool: "codex", scope: "user", projectPath: "", format: "md" });
|
|
26663
26772
|
}
|
|
26664
26773
|
if (isSourceEnabled("cursor", "commands")) {
|
|
26665
|
-
roots.push({ path:
|
|
26774
|
+
roots.push({ path: join40(cursorHomeDir(), "commands"), tool: "cursor", scope: "user", projectPath: "", format: "md" });
|
|
26666
26775
|
}
|
|
26667
26776
|
if (isSourceEnabled("pi", "commands")) {
|
|
26668
26777
|
roots.push({ path: piBackend.promptsDir(), tool: "pi", scope: "user", projectPath: "", format: "md" });
|
|
@@ -26679,10 +26788,10 @@ var init_slash_commands_source = __esm({
|
|
|
26679
26788
|
continue;
|
|
26680
26789
|
}
|
|
26681
26790
|
for (const file of files) {
|
|
26682
|
-
const filePath =
|
|
26791
|
+
const filePath = join40(root.path, file);
|
|
26683
26792
|
try {
|
|
26684
26793
|
const stat3 = statSync33(filePath);
|
|
26685
|
-
const content =
|
|
26794
|
+
const content = readFileSync32(filePath, "utf-8");
|
|
26686
26795
|
const parsed = parseCommand(content, basename20(file, ext), root.format);
|
|
26687
26796
|
yield {
|
|
26688
26797
|
id: `${root.tool}_cmd_${root.scope}_${parsed.name}`,
|
|
@@ -26711,7 +26820,7 @@ var init_slash_commands_source = __esm({
|
|
|
26711
26820
|
async parse(item) {
|
|
26712
26821
|
if (!existsSync37(item.filePath))
|
|
26713
26822
|
return [];
|
|
26714
|
-
const content =
|
|
26823
|
+
const content = readFileSync32(item.filePath, "utf-8");
|
|
26715
26824
|
if (!content.trim())
|
|
26716
26825
|
return [];
|
|
26717
26826
|
return [{
|
|
@@ -26734,8 +26843,8 @@ var init_slash_commands_source = __esm({
|
|
|
26734
26843
|
});
|
|
26735
26844
|
|
|
26736
26845
|
// ../engine/dist/parsers/subagents-source.js
|
|
26737
|
-
import { existsSync as existsSync38, readdirSync as readdirSync28, readFileSync as
|
|
26738
|
-
import { join as
|
|
26846
|
+
import { existsSync as existsSync38, readdirSync as readdirSync28, readFileSync as readFileSync33, statSync as statSync34 } from "fs";
|
|
26847
|
+
import { join as join41, basename as basename21 } from "path";
|
|
26739
26848
|
function rebuildBody3(content) {
|
|
26740
26849
|
const { text, redacted } = redactInlineSecrets(content);
|
|
26741
26850
|
const out = {};
|
|
@@ -26795,7 +26904,7 @@ var init_subagents_source = __esm({
|
|
|
26795
26904
|
if (!entry.isDirectory() || entry.name.startsWith("."))
|
|
26796
26905
|
continue;
|
|
26797
26906
|
const projectPath = resolveProjectDirName(entry.name);
|
|
26798
|
-
const agentDir =
|
|
26907
|
+
const agentDir = join41(projectPath, ".claude", "agents");
|
|
26799
26908
|
if (existsSync38(agentDir))
|
|
26800
26909
|
roots.push({ path: agentDir, tool: "claude", scope: "project", projectPath, format: "md" });
|
|
26801
26910
|
}
|
|
@@ -26804,7 +26913,7 @@ var init_subagents_source = __esm({
|
|
|
26804
26913
|
}
|
|
26805
26914
|
}
|
|
26806
26915
|
if (isSourceEnabled("agy", "agents")) {
|
|
26807
|
-
roots.push({ path:
|
|
26916
|
+
roots.push({ path: join41(agyBackend.homeDir(), "agents"), tool: "agy", scope: "user", projectPath: "", format: "md" });
|
|
26808
26917
|
roots.push({ path: agyBackend.sharedAgentsDir(), tool: "agy", scope: "user", projectPath: "", format: "md" });
|
|
26809
26918
|
}
|
|
26810
26919
|
if (isSourceEnabled("opencode", "agents")) {
|
|
@@ -26814,7 +26923,7 @@ var init_subagents_source = __esm({
|
|
|
26814
26923
|
roots.push({ path: codexBackend.agentsDir(), tool: "codex", scope: "user", projectPath: "", format: "toml" });
|
|
26815
26924
|
}
|
|
26816
26925
|
if (isSourceEnabled("cursor", "agents")) {
|
|
26817
|
-
roots.push({ path:
|
|
26926
|
+
roots.push({ path: join41(cursorHomeDir(), "agents"), tool: "cursor", scope: "user", projectPath: "", format: "md" });
|
|
26818
26927
|
}
|
|
26819
26928
|
return roots;
|
|
26820
26929
|
}
|
|
@@ -26828,10 +26937,10 @@ var init_subagents_source = __esm({
|
|
|
26828
26937
|
continue;
|
|
26829
26938
|
}
|
|
26830
26939
|
for (const file of files) {
|
|
26831
|
-
const filePath =
|
|
26940
|
+
const filePath = join41(root.path, file);
|
|
26832
26941
|
try {
|
|
26833
26942
|
const stat3 = statSync34(filePath);
|
|
26834
|
-
const content =
|
|
26943
|
+
const content = readFileSync33(filePath, "utf-8");
|
|
26835
26944
|
const parsed = parseAgent(content, basename21(file, ext), root.format);
|
|
26836
26945
|
yield {
|
|
26837
26946
|
id: `${root.tool}_agent_${root.scope}_${parsed.name}`,
|
|
@@ -26861,7 +26970,7 @@ var init_subagents_source = __esm({
|
|
|
26861
26970
|
async parse(item) {
|
|
26862
26971
|
if (!existsSync38(item.filePath))
|
|
26863
26972
|
return [];
|
|
26864
|
-
const content =
|
|
26973
|
+
const content = readFileSync33(item.filePath, "utf-8");
|
|
26865
26974
|
if (!content.trim())
|
|
26866
26975
|
return [];
|
|
26867
26976
|
return [{
|
|
@@ -26884,13 +26993,13 @@ var init_subagents_source = __esm({
|
|
|
26884
26993
|
});
|
|
26885
26994
|
|
|
26886
26995
|
// ../engine/dist/parsers/hooks-source.js
|
|
26887
|
-
import { existsSync as existsSync39, readFileSync as
|
|
26888
|
-
import { join as
|
|
26996
|
+
import { existsSync as existsSync39, readFileSync as readFileSync34, readdirSync as readdirSync29, statSync as statSync35 } from "fs";
|
|
26997
|
+
import { join as join42 } from "path";
|
|
26889
26998
|
function readJson2(path) {
|
|
26890
26999
|
if (!existsSync39(path))
|
|
26891
27000
|
return null;
|
|
26892
27001
|
try {
|
|
26893
|
-
return JSON.parse(
|
|
27002
|
+
return JSON.parse(readFileSync34(path, "utf-8"));
|
|
26894
27003
|
} catch {
|
|
26895
27004
|
return null;
|
|
26896
27005
|
}
|
|
@@ -26915,7 +27024,7 @@ var init_hooks_source = __esm({
|
|
|
26915
27024
|
if (!entry.isDirectory() || entry.name.startsWith("."))
|
|
26916
27025
|
continue;
|
|
26917
27026
|
const projectPath = resolveProjectDirName(entry.name);
|
|
26918
|
-
const settingsPath2 =
|
|
27027
|
+
const settingsPath2 = join42(projectPath, ".claude", "settings.json");
|
|
26919
27028
|
if (existsSync39(settingsPath2)) {
|
|
26920
27029
|
yield* this.fromSettings(settingsPath2, "project", projectPath);
|
|
26921
27030
|
}
|
|
@@ -27007,14 +27116,14 @@ var init_hooks_source = __esm({
|
|
|
27007
27116
|
});
|
|
27008
27117
|
|
|
27009
27118
|
// ../engine/dist/parsers/plugins-source.js
|
|
27010
|
-
import { existsSync as existsSync40, readFileSync as
|
|
27119
|
+
import { existsSync as existsSync40, readFileSync as readFileSync35, readdirSync as readdirSync30, statSync as statSync36 } from "fs";
|
|
27011
27120
|
import { homedir as homedir15 } from "os";
|
|
27012
|
-
import { join as
|
|
27121
|
+
import { join as join43 } from "path";
|
|
27013
27122
|
function readJson3(path) {
|
|
27014
27123
|
if (!existsSync40(path))
|
|
27015
27124
|
return null;
|
|
27016
27125
|
try {
|
|
27017
|
-
return JSON.parse(
|
|
27126
|
+
return JSON.parse(readFileSync35(path, "utf-8"));
|
|
27018
27127
|
} catch {
|
|
27019
27128
|
return null;
|
|
27020
27129
|
}
|
|
@@ -27074,7 +27183,7 @@ var init_plugins_source = __esm({
|
|
|
27074
27183
|
entries = [];
|
|
27075
27184
|
}
|
|
27076
27185
|
for (const name of entries) {
|
|
27077
|
-
const dir =
|
|
27186
|
+
const dir = join43(gemRoot, name);
|
|
27078
27187
|
let st;
|
|
27079
27188
|
try {
|
|
27080
27189
|
st = statSync36(dir);
|
|
@@ -27083,7 +27192,7 @@ var init_plugins_source = __esm({
|
|
|
27083
27192
|
}
|
|
27084
27193
|
if (!st.isDirectory())
|
|
27085
27194
|
continue;
|
|
27086
|
-
const manifestPath =
|
|
27195
|
+
const manifestPath = join43(dir, "gemini-extension.json");
|
|
27087
27196
|
const manifest = readJson3(manifestPath);
|
|
27088
27197
|
if (!manifest || typeof manifest !== "object")
|
|
27089
27198
|
continue;
|
|
@@ -27123,11 +27232,11 @@ var init_plugins_source = __esm({
|
|
|
27123
27232
|
}
|
|
27124
27233
|
if (!st.isDirectory())
|
|
27125
27234
|
continue;
|
|
27126
|
-
const appJson = readJson3(
|
|
27127
|
-
const pluginJson = readJson3(
|
|
27235
|
+
const appJson = readJson3(join43(pluginDir, ".codex-plugin", ".app.json"));
|
|
27236
|
+
const pluginJson = readJson3(join43(pluginDir, ".codex-plugin", "plugin.json"));
|
|
27128
27237
|
const manifest = pluginJson || appJson || {};
|
|
27129
27238
|
let mcpServers = [];
|
|
27130
|
-
const mcpJson = readJson3(
|
|
27239
|
+
const mcpJson = readJson3(join43(pluginDir, ".mcp.json"));
|
|
27131
27240
|
if (mcpJson?.mcpServers)
|
|
27132
27241
|
mcpServers = Object.keys(mcpJson.mcpServers);
|
|
27133
27242
|
yield {
|
|
@@ -27135,7 +27244,7 @@ var init_plugins_source = __esm({
|
|
|
27135
27244
|
sourceType: "plugin",
|
|
27136
27245
|
title: manifest.name || name,
|
|
27137
27246
|
projectPath: "",
|
|
27138
|
-
filePath:
|
|
27247
|
+
filePath: join43(pluginDir, ".codex-plugin"),
|
|
27139
27248
|
mtime: st.mtimeMs,
|
|
27140
27249
|
contentPreview: (manifest.description || "").slice(0, 300),
|
|
27141
27250
|
extra: {
|
|
@@ -27307,8 +27416,8 @@ __export(sync_ledger_exports, {
|
|
|
27307
27416
|
syncMode: () => syncMode,
|
|
27308
27417
|
unackedCursorAttemptCount: () => unackedCursorAttemptCount
|
|
27309
27418
|
});
|
|
27310
|
-
import { readFileSync as
|
|
27311
|
-
import { join as
|
|
27419
|
+
import { readFileSync as readFileSync36, writeFileSync as writeFileSync8, renameSync as renameSync4, mkdirSync as mkdirSync8, statSync as statSync37 } from "node:fs";
|
|
27420
|
+
import { join as join44, dirname as dirname16 } from "node:path";
|
|
27312
27421
|
function toRow(entry) {
|
|
27313
27422
|
if (entry === void 0) return void 0;
|
|
27314
27423
|
return typeof entry === "number" ? { m: entry, v: 0 } : entry;
|
|
@@ -27326,7 +27435,7 @@ function stampOf(path) {
|
|
|
27326
27435
|
}
|
|
27327
27436
|
function readDisk(path) {
|
|
27328
27437
|
try {
|
|
27329
|
-
const parsed = JSON.parse(
|
|
27438
|
+
const parsed = JSON.parse(readFileSync36(path, "utf-8"));
|
|
27330
27439
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
27331
27440
|
} catch {
|
|
27332
27441
|
return {};
|
|
@@ -27390,7 +27499,7 @@ function persistNow() {
|
|
|
27390
27499
|
mkdirSync8(dirname16(path), { recursive: true });
|
|
27391
27500
|
load();
|
|
27392
27501
|
const tmp = `${path}.tmp-${process.pid}`;
|
|
27393
|
-
|
|
27502
|
+
writeFileSync8(tmp, JSON.stringify(cache3 ?? {}));
|
|
27394
27503
|
renameSync4(tmp, path);
|
|
27395
27504
|
base = snapshot(cache3 ?? {});
|
|
27396
27505
|
diskStamp = stampOf(path);
|
|
@@ -27427,10 +27536,10 @@ function pruneLedgerTargets(configuredServers) {
|
|
|
27427
27536
|
try {
|
|
27428
27537
|
let prior = {};
|
|
27429
27538
|
try {
|
|
27430
|
-
prior = JSON.parse(
|
|
27539
|
+
prior = JSON.parse(readFileSync36(side, "utf-8"));
|
|
27431
27540
|
} catch {
|
|
27432
27541
|
}
|
|
27433
|
-
|
|
27542
|
+
writeFileSync8(side, JSON.stringify({ ...prior, ...orphans }));
|
|
27434
27543
|
} catch {
|
|
27435
27544
|
for (const n of names) data[n] = orphans[n];
|
|
27436
27545
|
return 0;
|
|
@@ -27451,7 +27560,7 @@ function flushLedger() {
|
|
|
27451
27560
|
function loadItemVersionsAll() {
|
|
27452
27561
|
if (itemVersionsCache) return itemVersionsCache;
|
|
27453
27562
|
try {
|
|
27454
|
-
const parsed = JSON.parse(
|
|
27563
|
+
const parsed = JSON.parse(readFileSync36(itemVersionsPath(), "utf-8"));
|
|
27455
27564
|
itemVersionsCache = parsed && typeof parsed === "object" ? parsed : {};
|
|
27456
27565
|
} catch {
|
|
27457
27566
|
itemVersionsCache = {};
|
|
@@ -27467,12 +27576,12 @@ function saveItemVersions(server, versions) {
|
|
|
27467
27576
|
const path = itemVersionsPath();
|
|
27468
27577
|
mkdirSync8(dirname16(path), { recursive: true });
|
|
27469
27578
|
const tmp = `${path}.tmp`;
|
|
27470
|
-
|
|
27579
|
+
writeFileSync8(tmp, JSON.stringify(all));
|
|
27471
27580
|
renameSync4(tmp, path);
|
|
27472
27581
|
}
|
|
27473
27582
|
function loadInventoryHashes(server) {
|
|
27474
27583
|
try {
|
|
27475
|
-
const parsed = JSON.parse(
|
|
27584
|
+
const parsed = JSON.parse(readFileSync36(inventoryPath(), "utf-8"));
|
|
27476
27585
|
return { ...(parsed && typeof parsed === "object" ? parsed[server] : null) || {} };
|
|
27477
27586
|
} catch {
|
|
27478
27587
|
return {};
|
|
@@ -27481,7 +27590,7 @@ function loadInventoryHashes(server) {
|
|
|
27481
27590
|
function saveInventoryHashes(server, hashes) {
|
|
27482
27591
|
let all = {};
|
|
27483
27592
|
try {
|
|
27484
|
-
all = JSON.parse(
|
|
27593
|
+
all = JSON.parse(readFileSync36(inventoryPath(), "utf-8"));
|
|
27485
27594
|
} catch {
|
|
27486
27595
|
}
|
|
27487
27596
|
if (!all || typeof all !== "object") all = {};
|
|
@@ -27489,7 +27598,7 @@ function saveInventoryHashes(server, hashes) {
|
|
|
27489
27598
|
const path = inventoryPath();
|
|
27490
27599
|
mkdirSync8(dirname16(path), { recursive: true });
|
|
27491
27600
|
const tmp = `${path}.tmp`;
|
|
27492
|
-
|
|
27601
|
+
writeFileSync8(tmp, JSON.stringify(all));
|
|
27493
27602
|
renameSync4(tmp, path);
|
|
27494
27603
|
}
|
|
27495
27604
|
function getSyncedMtimes(server) {
|
|
@@ -27575,7 +27684,7 @@ function markFieldCoverage(server, field, rows) {
|
|
|
27575
27684
|
function loadReconcile() {
|
|
27576
27685
|
if (reconcileCache) return reconcileCache;
|
|
27577
27686
|
try {
|
|
27578
|
-
const parsed = JSON.parse(
|
|
27687
|
+
const parsed = JSON.parse(readFileSync36(reconcilePath(), "utf-8"));
|
|
27579
27688
|
reconcileCache = parsed && typeof parsed === "object" ? parsed : {};
|
|
27580
27689
|
} catch {
|
|
27581
27690
|
reconcileCache = {};
|
|
@@ -27586,7 +27695,7 @@ function persistReconcile(data) {
|
|
|
27586
27695
|
const path = reconcilePath();
|
|
27587
27696
|
mkdirSync8(dirname16(path), { recursive: true });
|
|
27588
27697
|
const tmp = `${path}.tmp`;
|
|
27589
|
-
|
|
27698
|
+
writeFileSync8(tmp, JSON.stringify(data));
|
|
27590
27699
|
renameSync4(tmp, path);
|
|
27591
27700
|
}
|
|
27592
27701
|
function stateFor(server) {
|
|
@@ -27661,7 +27770,7 @@ var init_sync_ledger = __esm({
|
|
|
27661
27770
|
"use strict";
|
|
27662
27771
|
init_paths();
|
|
27663
27772
|
init_extractor_version();
|
|
27664
|
-
ledgerPath = () =>
|
|
27773
|
+
ledgerPath = () => join44(getDataDir(), "sync-ledger.json");
|
|
27665
27774
|
cache3 = null;
|
|
27666
27775
|
base = /* @__PURE__ */ new Map();
|
|
27667
27776
|
diskStamp = null;
|
|
@@ -27669,11 +27778,11 @@ var init_sync_ledger = __esm({
|
|
|
27669
27778
|
LEDGER_FLUSH_MS = 2e3;
|
|
27670
27779
|
pendingWrite = false;
|
|
27671
27780
|
flushTimer = null;
|
|
27672
|
-
itemVersionsPath = () =>
|
|
27781
|
+
itemVersionsPath = () => join44(getDataDir(), "item-versions.json");
|
|
27673
27782
|
itemVersionsCache = null;
|
|
27674
|
-
inventoryPath = () =>
|
|
27783
|
+
inventoryPath = () => join44(getDataDir(), "toolkit-inventory.json");
|
|
27675
27784
|
unackedCursorAttempts = 0;
|
|
27676
|
-
reconcilePath = () =>
|
|
27785
|
+
reconcilePath = () => join44(getDataDir(), "sync-field-reconcile.json");
|
|
27677
27786
|
reconcileCache = null;
|
|
27678
27787
|
SETTLE_QUIET_MS = 2 * 60 * 60 * 1e3;
|
|
27679
27788
|
}
|
|
@@ -27705,8 +27814,8 @@ var init_sync_fields = __esm({
|
|
|
27705
27814
|
});
|
|
27706
27815
|
|
|
27707
27816
|
// ../engine/dist/core/index-lock.js
|
|
27708
|
-
import { existsSync as existsSync41, mkdirSync as mkdirSync9, openSync as openSync9, writeFileSync as
|
|
27709
|
-
import { dirname as dirname17, join as
|
|
27817
|
+
import { existsSync as existsSync41, mkdirSync as mkdirSync9, openSync as openSync9, writeFileSync as writeFileSync9, readFileSync as readFileSync37, rmSync as rmSync4, statSync as statSync38, closeSync as closeSync9 } from "fs";
|
|
27818
|
+
import { dirname as dirname17, join as join45 } from "path";
|
|
27710
27819
|
function acquireIndexLock(opts) {
|
|
27711
27820
|
const lockPath = lockFilePath(opts.file);
|
|
27712
27821
|
mkdirSync9(dirname17(lockPath), { recursive: true });
|
|
@@ -27725,7 +27834,7 @@ function acquireIndexLock(opts) {
|
|
|
27725
27834
|
}
|
|
27726
27835
|
const holder = { pid: process.pid, kind: opts.kind, startedAt: Date.now() };
|
|
27727
27836
|
try {
|
|
27728
|
-
|
|
27837
|
+
writeFileSync9(fd, JSON.stringify(holder));
|
|
27729
27838
|
} finally {
|
|
27730
27839
|
closeSync9(fd);
|
|
27731
27840
|
}
|
|
@@ -27737,7 +27846,7 @@ function acquireIndexLock(opts) {
|
|
|
27737
27846
|
return;
|
|
27738
27847
|
released = true;
|
|
27739
27848
|
try {
|
|
27740
|
-
const current = JSON.parse(
|
|
27849
|
+
const current = JSON.parse(readFileSync37(lockPath, "utf-8"));
|
|
27741
27850
|
if (current.pid !== holder.pid || current.startedAt !== holder.startedAt)
|
|
27742
27851
|
return;
|
|
27743
27852
|
} catch {
|
|
@@ -27751,7 +27860,7 @@ function acquireIndexLock(opts) {
|
|
|
27751
27860
|
};
|
|
27752
27861
|
}
|
|
27753
27862
|
function lockFilePath(file = ".compact.lock") {
|
|
27754
|
-
return
|
|
27863
|
+
return join45(getIndexDir(), file);
|
|
27755
27864
|
}
|
|
27756
27865
|
function stealStaleLock(lockPath, staleAfterMs) {
|
|
27757
27866
|
try {
|
|
@@ -27759,7 +27868,7 @@ function stealStaleLock(lockPath, staleAfterMs) {
|
|
|
27759
27868
|
const age = Date.now() - s.mtimeMs;
|
|
27760
27869
|
let payload;
|
|
27761
27870
|
try {
|
|
27762
|
-
payload = JSON.parse(
|
|
27871
|
+
payload = JSON.parse(readFileSync37(lockPath, "utf-8"));
|
|
27763
27872
|
} catch {
|
|
27764
27873
|
rmSync4(lockPath, { force: true });
|
|
27765
27874
|
return true;
|
|
@@ -27797,7 +27906,7 @@ var init_index_lock = __esm({
|
|
|
27797
27906
|
});
|
|
27798
27907
|
|
|
27799
27908
|
// src/http.ts
|
|
27800
|
-
import { readFileSync as
|
|
27909
|
+
import { readFileSync as readFileSync38 } from "node:fs";
|
|
27801
27910
|
function clientHeaders() {
|
|
27802
27911
|
return {
|
|
27803
27912
|
"x-chat-recall-cli": CLI_VERSION,
|
|
@@ -27815,7 +27924,7 @@ var init_http = __esm({
|
|
|
27815
27924
|
"use strict";
|
|
27816
27925
|
CLI_VERSION = "0.0.0";
|
|
27817
27926
|
try {
|
|
27818
|
-
CLI_VERSION = JSON.parse(
|
|
27927
|
+
CLI_VERSION = JSON.parse(readFileSync38(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
|
|
27819
27928
|
} catch {
|
|
27820
27929
|
try {
|
|
27821
27930
|
if (typeof __CLI_VERSION__ === "string") CLI_VERSION = __CLI_VERSION__;
|
|
@@ -28325,11 +28434,11 @@ var init_telemetry = __esm({
|
|
|
28325
28434
|
// src/raw-archive-parts.ts
|
|
28326
28435
|
import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as statSync39 } from "node:fs";
|
|
28327
28436
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
28328
|
-
import { join as
|
|
28437
|
+
import { join as join46 } from "node:path";
|
|
28329
28438
|
import { randomBytes } from "node:crypto";
|
|
28330
28439
|
import { createGzip as createGzip2 } from "node:zlib";
|
|
28331
28440
|
import { once } from "node:events";
|
|
28332
|
-
import { readFileSync as
|
|
28441
|
+
import { readFileSync as readFileSync39 } from "node:fs";
|
|
28333
28442
|
async function* fileLines(path) {
|
|
28334
28443
|
let rest = "";
|
|
28335
28444
|
const decoder = new TextDecoder("utf-8");
|
|
@@ -28355,7 +28464,7 @@ function* textLines(text) {
|
|
|
28355
28464
|
}
|
|
28356
28465
|
}
|
|
28357
28466
|
async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
|
|
28358
|
-
const path =
|
|
28467
|
+
const path = join46(dir, `cr-archive-${randomBytes(8).toString("hex")}.json.gz`);
|
|
28359
28468
|
const gzip = createGzip2({ level: 6 });
|
|
28360
28469
|
const out = createWriteStream(path, { mode: 384 });
|
|
28361
28470
|
const done = once(out, "finish");
|
|
@@ -28369,7 +28478,7 @@ async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
|
|
|
28369
28478
|
await write(`{"v":1,"tool":${JSON.stringify(meta.tool)},"mtime":${Math.floor(meta.mtime)},"files":[`);
|
|
28370
28479
|
for (const [i, f] of source.files.entries()) {
|
|
28371
28480
|
await write(`${i ? "," : ""}{"name":${JSON.stringify(f.name)},"text":"`);
|
|
28372
|
-
const whole = () => source.kind === "memory" ? f.text :
|
|
28481
|
+
const whole = () => source.kind === "memory" ? f.text : readFileSync39(f.path, "utf-8");
|
|
28373
28482
|
if (!f.name.endsWith(".jsonl")) {
|
|
28374
28483
|
await write(escapeJson(redact(whole())));
|
|
28375
28484
|
} else {
|
|
@@ -28609,7 +28718,7 @@ __export(client_events_exports, {
|
|
|
28609
28718
|
isTelemetryEnabled: () => isTelemetryEnabled,
|
|
28610
28719
|
reportClientEvent: () => reportClientEvent
|
|
28611
28720
|
});
|
|
28612
|
-
import { readFileSync as
|
|
28721
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
28613
28722
|
function scrub(msg) {
|
|
28614
28723
|
if (!msg) return "";
|
|
28615
28724
|
const noHome = msg.replace(/\/(?:home|Users)\/[^/\s]+/g, "~");
|
|
@@ -28662,7 +28771,7 @@ var init_client_events = __esm({
|
|
|
28662
28771
|
init_secret_redactor();
|
|
28663
28772
|
CLI_VERSION2 = "0.0.0";
|
|
28664
28773
|
try {
|
|
28665
|
-
CLI_VERSION2 = JSON.parse(
|
|
28774
|
+
CLI_VERSION2 = JSON.parse(readFileSync40(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION2;
|
|
28666
28775
|
} catch {
|
|
28667
28776
|
}
|
|
28668
28777
|
}
|
|
@@ -28692,10 +28801,10 @@ __export(auto_update_exports, {
|
|
|
28692
28801
|
tarballUrl: () => tarballUrl
|
|
28693
28802
|
});
|
|
28694
28803
|
import { execSync as execSync2, execFileSync as execFileSync3 } from "node:child_process";
|
|
28695
|
-
import { readFileSync as
|
|
28804
|
+
import { readFileSync as readFileSync41, existsSync as existsSync43 } from "node:fs";
|
|
28696
28805
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
28697
|
-
import { writeFileSync as
|
|
28698
|
-
import { join as
|
|
28806
|
+
import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync40, mkdirSync as mkdirSync10 } from "node:fs";
|
|
28807
|
+
import { join as join47, dirname as dirname18, sep as sep2, posix as pathPosix, win32 as pathWin32 } from "node:path";
|
|
28699
28808
|
import { tmpdir as tmpdir3, homedir as homedir16 } from "node:os";
|
|
28700
28809
|
import { createHash as createHash9 } from "node:crypto";
|
|
28701
28810
|
function compareVersions(a, b) {
|
|
@@ -28720,7 +28829,7 @@ function newerOf(a, b) {
|
|
|
28720
28829
|
function installedVersion() {
|
|
28721
28830
|
try {
|
|
28722
28831
|
const here = dirname18(fileURLToPath2(import.meta.url));
|
|
28723
|
-
const raw =
|
|
28832
|
+
const raw = readFileSync41(join47(here, "..", "package.json"), "utf-8");
|
|
28724
28833
|
return JSON.parse(raw).version || null;
|
|
28725
28834
|
} catch {
|
|
28726
28835
|
return null;
|
|
@@ -28745,7 +28854,7 @@ function sweepStaleStaging(root = tmpdir3(), now = Date.now()) {
|
|
|
28745
28854
|
}
|
|
28746
28855
|
for (const name of entries) {
|
|
28747
28856
|
if (!MKDTEMP_SUFFIX.test(name)) continue;
|
|
28748
|
-
const dir =
|
|
28857
|
+
const dir = join47(root, name);
|
|
28749
28858
|
try {
|
|
28750
28859
|
const st = statSync40(dir);
|
|
28751
28860
|
if (!st.isDirectory() || now - st.mtimeMs < COLD_MS) continue;
|
|
@@ -28774,15 +28883,15 @@ async function executeAutoUpdate(plan, deps) {
|
|
|
28774
28883
|
}
|
|
28775
28884
|
const got = createHash9("sha256").update(buf).digest("hex");
|
|
28776
28885
|
if (got !== plan.sha256) return { updated: false, reason: `checksum mismatch (expected ${plan.sha256.slice(0, 12)}\u2026, got ${got.slice(0, 12)}\u2026) \u2014 NOT installing` };
|
|
28777
|
-
const dir = mkdtempSync3(
|
|
28886
|
+
const dir = mkdtempSync3(join47(tmpdir3(), "cr-update-"));
|
|
28778
28887
|
const discardStaging = () => {
|
|
28779
28888
|
try {
|
|
28780
28889
|
rmSync6(dir, { recursive: true, force: true });
|
|
28781
28890
|
} catch {
|
|
28782
28891
|
}
|
|
28783
28892
|
};
|
|
28784
|
-
const tgz =
|
|
28785
|
-
|
|
28893
|
+
const tgz = join47(dir, "chat-recall.tgz");
|
|
28894
|
+
writeFileSync10(tgz, buf);
|
|
28786
28895
|
if (deps.stopping?.()) {
|
|
28787
28896
|
discardStaging();
|
|
28788
28897
|
return { updated: false, reason: STOPPING_REASON };
|
|
@@ -28861,7 +28970,7 @@ function realInstall(tgz) {
|
|
|
28861
28970
|
try {
|
|
28862
28971
|
npmInstall(npm, ["install", "-g", tgz]);
|
|
28863
28972
|
} catch {
|
|
28864
|
-
npmInstall(npm, ["install", "-g", "--prefix",
|
|
28973
|
+
npmInstall(npm, ["install", "-g", "--prefix", join47(homedir16(), ".local"), tgz]);
|
|
28865
28974
|
}
|
|
28866
28975
|
}
|
|
28867
28976
|
function acquireUpdateLock() {
|
|
@@ -28878,12 +28987,12 @@ function realRestart(platform2) {
|
|
|
28878
28987
|
if (c) execSync2(c.cmd, { stdio: "ignore", ...c.shell ? { shell: c.shell } : {} });
|
|
28879
28988
|
}
|
|
28880
28989
|
function updateStatePath() {
|
|
28881
|
-
const dir = process.env.CHAT_RECALL_DATA_DIR ||
|
|
28882
|
-
return
|
|
28990
|
+
const dir = process.env.CHAT_RECALL_DATA_DIR || join47(homedir16(), ".chat-recall");
|
|
28991
|
+
return join47(dir, "auto-update-state.json");
|
|
28883
28992
|
}
|
|
28884
28993
|
function readUpdateState() {
|
|
28885
28994
|
try {
|
|
28886
|
-
return JSON.parse(
|
|
28995
|
+
return JSON.parse(readFileSync41(updateStatePath(), "utf8"));
|
|
28887
28996
|
} catch {
|
|
28888
28997
|
return {};
|
|
28889
28998
|
}
|
|
@@ -28892,7 +29001,7 @@ function writeUpdateState(st) {
|
|
|
28892
29001
|
try {
|
|
28893
29002
|
const p = updateStatePath();
|
|
28894
29003
|
mkdirSync10(dirname18(p), { recursive: true });
|
|
28895
|
-
|
|
29004
|
+
writeFileSync10(p, JSON.stringify(st), "utf8");
|
|
28896
29005
|
} catch {
|
|
28897
29006
|
}
|
|
28898
29007
|
}
|
|
@@ -28990,8 +29099,8 @@ var init_auto_update = __esm({
|
|
|
28990
29099
|
});
|
|
28991
29100
|
|
|
28992
29101
|
// src/sync-client.ts
|
|
28993
|
-
import { join as
|
|
28994
|
-
import { readFileSync as
|
|
29102
|
+
import { join as join48, dirname as dirname19, basename as basename22 } from "node:path";
|
|
29103
|
+
import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as statSync41 } from "node:fs";
|
|
28995
29104
|
import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
|
|
28996
29105
|
import { createHash as createHash10 } from "node:crypto";
|
|
28997
29106
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -29032,7 +29141,7 @@ function loadAllCredentials() {
|
|
|
29032
29141
|
const fromEnv = envCredentials();
|
|
29033
29142
|
if (fromEnv) return [{ serverUrl: fromEnv.serverUrl, token: fromEnv.token }];
|
|
29034
29143
|
try {
|
|
29035
|
-
const parsed = JSON.parse(
|
|
29144
|
+
const parsed = JSON.parse(readFileSync42(credPath(), "utf-8"));
|
|
29036
29145
|
if (Array.isArray(parsed?.targets)) {
|
|
29037
29146
|
return parsed.targets.filter((t) => t?.serverUrl).map((t) => {
|
|
29038
29147
|
const secret = t.secret;
|
|
@@ -29096,11 +29205,11 @@ async function fetchTenantSecurityConfig(cred) {
|
|
|
29096
29205
|
}
|
|
29097
29206
|
}
|
|
29098
29207
|
function syncConfigCachePath() {
|
|
29099
|
-
return
|
|
29208
|
+
return join48(getDataDir(), "sync-config-cache.json");
|
|
29100
29209
|
}
|
|
29101
29210
|
function readPersistedSyncConfigs() {
|
|
29102
29211
|
try {
|
|
29103
|
-
return JSON.parse(
|
|
29212
|
+
return JSON.parse(readFileSync42(syncConfigCachePath(), "utf-8"));
|
|
29104
29213
|
} catch {
|
|
29105
29214
|
return {};
|
|
29106
29215
|
}
|
|
@@ -29110,7 +29219,7 @@ function persistSyncConfig(base3, config) {
|
|
|
29110
29219
|
const all = readPersistedSyncConfigs();
|
|
29111
29220
|
all[base3] = { fetchedAt: Date.now(), config };
|
|
29112
29221
|
mkdirSync11(dirname19(syncConfigCachePath()), { recursive: true });
|
|
29113
|
-
|
|
29222
|
+
writeFileSync11(syncConfigCachePath(), JSON.stringify(all, null, 2));
|
|
29114
29223
|
} catch {
|
|
29115
29224
|
}
|
|
29116
29225
|
}
|
|
@@ -29309,11 +29418,11 @@ async function syncSessions(opts = {}) {
|
|
|
29309
29418
|
return { ...agg, perTarget };
|
|
29310
29419
|
}
|
|
29311
29420
|
function walkStatePath() {
|
|
29312
|
-
return
|
|
29421
|
+
return join48(getDataDir(), "walk-state.json");
|
|
29313
29422
|
}
|
|
29314
29423
|
function readWalkState() {
|
|
29315
29424
|
try {
|
|
29316
|
-
const raw = JSON.parse(
|
|
29425
|
+
const raw = JSON.parse(readFileSync42(walkStatePath(), "utf-8"));
|
|
29317
29426
|
return raw && typeof raw === "object" ? raw : {};
|
|
29318
29427
|
} catch {
|
|
29319
29428
|
return {};
|
|
@@ -29324,7 +29433,7 @@ function noteWalkSuccess(serverUrl) {
|
|
|
29324
29433
|
const state2 = readWalkState();
|
|
29325
29434
|
state2[serverUrl.replace(/\/+$/, "")] = Date.now();
|
|
29326
29435
|
mkdirSync11(getDataDir(), { recursive: true });
|
|
29327
|
-
|
|
29436
|
+
writeFileSync11(walkStatePath(), JSON.stringify(state2));
|
|
29328
29437
|
} catch {
|
|
29329
29438
|
}
|
|
29330
29439
|
}
|
|
@@ -29390,7 +29499,7 @@ function reapStaleScanDirs(dir = tmpdir4(), maxAgeMs = 6 * 36e5, now = Date.now(
|
|
|
29390
29499
|
}
|
|
29391
29500
|
for (const name of names) {
|
|
29392
29501
|
if (!name.startsWith("cr-batchscan-")) continue;
|
|
29393
|
-
const p =
|
|
29502
|
+
const p = join48(dir, name);
|
|
29394
29503
|
try {
|
|
29395
29504
|
if (now - statSync41(p).mtimeMs < maxAgeMs) continue;
|
|
29396
29505
|
rmSync7(p, { recursive: true, force: true });
|
|
@@ -29407,7 +29516,7 @@ function batchScanExternal(items, opts = {}) {
|
|
|
29407
29516
|
let scanned = 0, slices = 0, scanMs = 0;
|
|
29408
29517
|
if (items.length === 0) return { findings, scanned, slices, scanMs };
|
|
29409
29518
|
reapStaleScanDirs();
|
|
29410
|
-
let scanDir = mkdtempSync4(
|
|
29519
|
+
let scanDir = mkdtempSync4(join48(tmpdir4(), "cr-batchscan-"));
|
|
29411
29520
|
let safeToId = /* @__PURE__ */ new Map();
|
|
29412
29521
|
let bytesInDir = 0;
|
|
29413
29522
|
const flushSlice = () => {
|
|
@@ -29438,13 +29547,13 @@ function batchScanExternal(items, opts = {}) {
|
|
|
29438
29547
|
if (raw === null) continue;
|
|
29439
29548
|
const safe = item.id.replace(/[^A-Za-z0-9_-]/g, "");
|
|
29440
29549
|
safeToId.set(safe, item.id);
|
|
29441
|
-
|
|
29550
|
+
writeFileSync11(join48(scanDir, `${safe}.txt`), raw);
|
|
29442
29551
|
bytesInDir += Buffer.byteLength(raw);
|
|
29443
29552
|
} catch {
|
|
29444
29553
|
}
|
|
29445
29554
|
if (bytesInDir >= maxBytes) {
|
|
29446
29555
|
flushSlice();
|
|
29447
|
-
scanDir = mkdtempSync4(
|
|
29556
|
+
scanDir = mkdtempSync4(join48(tmpdir4(), "cr-batchscan-"));
|
|
29448
29557
|
}
|
|
29449
29558
|
}
|
|
29450
29559
|
flushSlice();
|
|
@@ -29901,10 +30010,19 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
29901
30010
|
reportWalkProgress({ done: 0, total: slice.length, startedAt: walkStartedAt, complete: false, first: firstWalk });
|
|
29902
30011
|
walkProgressForUpload = { done: 0, total: slice.length, complete: false };
|
|
29903
30012
|
let traceN = 0;
|
|
30013
|
+
const memBudget = startBudget();
|
|
30014
|
+
let sessionsBuilt = 0;
|
|
29904
30015
|
let considered = 0;
|
|
29905
30016
|
for (const ref of slice) {
|
|
29906
30017
|
await new Promise((resolve3) => setImmediate(resolve3));
|
|
29907
30018
|
considered++;
|
|
30019
|
+
const usedNow = usedMb();
|
|
30020
|
+
if (shouldPause(usedNow, memBudget, sessionsBuilt)) {
|
|
30021
|
+
releaseMemory();
|
|
30022
|
+
reclaimCgroup();
|
|
30023
|
+
console.error(`[sync] walk paused at the memory bound (used=${usedNow}MB, started at ${memBudget.baselineMb}MB) after ${sessionsBuilt} build(s) and ${considered - 1} of ${slice.length} session(s) \u2014 the next tick continues`);
|
|
30024
|
+
break;
|
|
30025
|
+
}
|
|
29908
30026
|
const walkDone = considered >= slice.length;
|
|
29909
30027
|
reportWalkProgress({ done: considered, total: slice.length, startedAt: walkStartedAt, complete: walkDone, first: firstWalk });
|
|
29910
30028
|
walkProgressForUpload = { done: considered, total: slice.length, complete: walkDone };
|
|
@@ -29915,6 +30033,7 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
29915
30033
|
skipped++;
|
|
29916
30034
|
continue;
|
|
29917
30035
|
}
|
|
30036
|
+
sessionsBuilt++;
|
|
29918
30037
|
const layout = backendFor(ref)?.sourceLayout?.(ref.prefixedId) ?? "";
|
|
29919
30038
|
if (layout) shippedLayout.set(ref.prefixedId, layout);
|
|
29920
30039
|
else shippedLayout.delete(ref.prefixedId);
|
|
@@ -30036,6 +30155,7 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
30036
30155
|
} catch {
|
|
30037
30156
|
}
|
|
30038
30157
|
walked++;
|
|
30158
|
+
releaseMemory();
|
|
30039
30159
|
if (walked % 250 === 0) console.error(`[sync] ${walked}/${slice.length} sessions\u2026`);
|
|
30040
30160
|
}
|
|
30041
30161
|
const itemVersions = loadItemVersions(base3);
|
|
@@ -30459,8 +30579,8 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
30459
30579
|
} else if (opts.scanSecrets) {
|
|
30460
30580
|
let tmp = null;
|
|
30461
30581
|
try {
|
|
30462
|
-
tmp =
|
|
30463
|
-
|
|
30582
|
+
tmp = join48(tmpdir4(), `cr-scan-${ref.prefixedId.replace(/[^A-Za-z0-9_-]/g, "")}-${mtime}.txt`);
|
|
30583
|
+
writeFileSync11(tmp, rawText);
|
|
30464
30584
|
for (const f of scanFileForSecrets(tmp, { verifyOnly: opts.verifySecrets, tenantRules: opts.tenantRules })) {
|
|
30465
30585
|
const verifiedAt = f.verified ? (/* @__PURE__ */ new Date()).toISOString() : null;
|
|
30466
30586
|
findings.push({ session_id: ref.prefixedId, detector: f.detector, rule: f.rule, line: f.line, preview: f.preview, verified_at: verifiedAt });
|
|
@@ -30695,6 +30815,7 @@ var ownVersion, ERROR_CLASS, STANDING_FAILURE, walkProgressForUpload, lastServer
|
|
|
30695
30815
|
var init_sync_client = __esm({
|
|
30696
30816
|
"src/sync-client.ts"() {
|
|
30697
30817
|
"use strict";
|
|
30818
|
+
init_memory_guard();
|
|
30698
30819
|
init_claude_prompt_origin();
|
|
30699
30820
|
init_credentials_env();
|
|
30700
30821
|
init_stored_token();
|
|
@@ -30738,7 +30859,7 @@ var init_sync_client = __esm({
|
|
|
30738
30859
|
ownVersion = "0.0.0";
|
|
30739
30860
|
try {
|
|
30740
30861
|
const dir = dirname19(fileURLToPath3(import.meta.url));
|
|
30741
|
-
ownVersion = JSON.parse(
|
|
30862
|
+
ownVersion = JSON.parse(readFileSync42(join48(dir, "../package.json"), "utf-8")).version || ownVersion;
|
|
30742
30863
|
} catch {
|
|
30743
30864
|
try {
|
|
30744
30865
|
if (typeof __CLI_VERSION__ === "string") ownVersion = __CLI_VERSION__;
|
|
@@ -30753,7 +30874,7 @@ var init_sync_client = __esm({
|
|
|
30753
30874
|
]);
|
|
30754
30875
|
walkProgressForUpload = null;
|
|
30755
30876
|
lastServerPackSpec = null;
|
|
30756
|
-
credPath = () =>
|
|
30877
|
+
credPath = () => join48(getDataDir(), "credentials.json");
|
|
30757
30878
|
_securityConfigCache = /* @__PURE__ */ new Map();
|
|
30758
30879
|
SECURITY_CONFIG_TTL_MS = 5 * 60 * 1e3;
|
|
30759
30880
|
_syncConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -30775,71 +30896,6 @@ var init_sync_client = __esm({
|
|
|
30775
30896
|
}
|
|
30776
30897
|
});
|
|
30777
30898
|
|
|
30778
|
-
// src/memory-guard.ts
|
|
30779
|
-
import { readFileSync as readFileSync42, writeFileSync as writeFileSync11 } from "node:fs";
|
|
30780
|
-
import { join as join48 } from "node:path";
|
|
30781
|
-
function rssMb() {
|
|
30782
|
-
return Math.round(process.memoryUsage().rss / 1048576);
|
|
30783
|
-
}
|
|
30784
|
-
function memoryLimitMb(env = process.env) {
|
|
30785
|
-
const raw = env.CHAT_RECALL_WATCH_RSS_MAX_MB;
|
|
30786
|
-
if (!raw) return DEFAULT_RSS_MAX_MB;
|
|
30787
|
-
const n = Number(raw);
|
|
30788
|
-
return Number.isFinite(n) && n > 0 ? Math.round(n) : DEFAULT_RSS_MAX_MB;
|
|
30789
|
-
}
|
|
30790
|
-
function isOverMemoryLimit(rss, limitMb) {
|
|
30791
|
-
return rss >= limitMb;
|
|
30792
|
-
}
|
|
30793
|
-
function releaseMemory(gc = globalThis.gc) {
|
|
30794
|
-
if (typeof gc !== "function") return false;
|
|
30795
|
-
gc();
|
|
30796
|
-
return true;
|
|
30797
|
-
}
|
|
30798
|
-
function cgroupDir(cgroupFile = "/proc/self/cgroup") {
|
|
30799
|
-
let text;
|
|
30800
|
-
try {
|
|
30801
|
-
text = readFileSync42(cgroupFile, "utf8");
|
|
30802
|
-
} catch {
|
|
30803
|
-
return null;
|
|
30804
|
-
}
|
|
30805
|
-
const line = text.split("\n").find((l) => l.startsWith("0::"));
|
|
30806
|
-
if (!line) return null;
|
|
30807
|
-
return `/sys/fs/cgroup${line.slice(3).trim()}`;
|
|
30808
|
-
}
|
|
30809
|
-
function memoryStatMb(dir, key2) {
|
|
30810
|
-
let text;
|
|
30811
|
-
try {
|
|
30812
|
-
text = readFileSync42(join48(dir, "memory.stat"), "utf8");
|
|
30813
|
-
} catch {
|
|
30814
|
-
return null;
|
|
30815
|
-
}
|
|
30816
|
-
for (const line of text.split("\n")) {
|
|
30817
|
-
const [name, value] = line.split(" ");
|
|
30818
|
-
if (name === key2 && value) return Math.round(Number(value) / 1048576);
|
|
30819
|
-
}
|
|
30820
|
-
return null;
|
|
30821
|
-
}
|
|
30822
|
-
function reclaimCgroup(keepFileMb = 64, dir = cgroupDir()) {
|
|
30823
|
-
if (!dir) return false;
|
|
30824
|
-
const fileMb = memoryStatMb(dir, "file");
|
|
30825
|
-
if (fileMb === null) return false;
|
|
30826
|
-
const reclaimMb = Math.floor(fileMb - keepFileMb);
|
|
30827
|
-
if (reclaimMb <= 0) return false;
|
|
30828
|
-
try {
|
|
30829
|
-
writeFileSync11(join48(dir, "memory.reclaim"), `${reclaimMb}M`);
|
|
30830
|
-
return true;
|
|
30831
|
-
} catch {
|
|
30832
|
-
return false;
|
|
30833
|
-
}
|
|
30834
|
-
}
|
|
30835
|
-
var DEFAULT_RSS_MAX_MB;
|
|
30836
|
-
var init_memory_guard = __esm({
|
|
30837
|
-
"src/memory-guard.ts"() {
|
|
30838
|
-
"use strict";
|
|
30839
|
-
DEFAULT_RSS_MAX_MB = 512;
|
|
30840
|
-
}
|
|
30841
|
-
});
|
|
30842
|
-
|
|
30843
30899
|
// ../engine/dist/core/artifact-codec.js
|
|
30844
30900
|
import { readFileSync as readFileSync43 } from "fs";
|
|
30845
30901
|
import { basename as basename23, join as join49 } from "path";
|
|
@@ -34857,12 +34913,13 @@ async function codeIndexTick() {
|
|
|
34857
34913
|
}
|
|
34858
34914
|
let ok = 0, unchanged = 0;
|
|
34859
34915
|
const cursor = readCursor();
|
|
34860
|
-
const
|
|
34916
|
+
const memBudget = startBudget(usedMb(rssMb()));
|
|
34861
34917
|
for (const ws of workspaces) {
|
|
34862
|
-
const
|
|
34863
|
-
if (
|
|
34918
|
+
const used = usedMb(rssMb());
|
|
34919
|
+
if (shouldPause(used, memBudget, ok)) {
|
|
34864
34920
|
releaseMemory();
|
|
34865
|
-
|
|
34921
|
+
reclaimCgroup();
|
|
34922
|
+
daemonLog.info(`code intelligence: paused at the memory bound (used=${used}MB, started at ${memBudget.baselineMb}MB) \u2014 ${workspaces.length - ok - unchanged} workspace(s) wait for the next pass`);
|
|
34866
34923
|
break;
|
|
34867
34924
|
}
|
|
34868
34925
|
const fp = workspaceFingerprint(ws, COLLECTOR_VERSION2);
|
|
@@ -34890,6 +34947,7 @@ async function codeIndexTick() {
|
|
|
34890
34947
|
noteIndexed(ws, Date.now(), fp);
|
|
34891
34948
|
ok++;
|
|
34892
34949
|
releaseMemory();
|
|
34950
|
+
reclaimCgroup();
|
|
34893
34951
|
}
|
|
34894
34952
|
if (ok > 0 || unchanged > 0) daemonLog.info(`code intelligence: indexed ${ok}/${workspaces.length} workspace(s), ${unchanged} unchanged`);
|
|
34895
34953
|
releaseMemory();
|