chat-recall 0.7.41 → 0.7.43

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/watch.js CHANGED
@@ -2400,7 +2400,7 @@ var require_thread_stream = __commonJS({
2400
2400
  var { version } = require_package();
2401
2401
  var { EventEmitter } = __require("events");
2402
2402
  var { Worker: Worker2 } = __require("worker_threads");
2403
- var { join: join60 } = __require("path");
2403
+ var { join: join61 } = __require("path");
2404
2404
  var { pathToFileURL } = __require("url");
2405
2405
  var { wait } = require_wait();
2406
2406
  var {
@@ -2443,7 +2443,7 @@ var require_thread_stream = __commonJS({
2443
2443
  function createWorker(stream, opts) {
2444
2444
  const { filename, workerData } = opts;
2445
2445
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2446
- const toExecute = bundlerOverrides["thread-stream-worker"] || join60(__dirname, "lib", "worker.js");
2446
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join61(__dirname, "lib", "worker.js");
2447
2447
  const worker = new Worker2(toExecute, {
2448
2448
  ...opts.workerOpts,
2449
2449
  trackUnmanagedFds: false,
@@ -2846,7 +2846,7 @@ var require_transport = __commonJS({
2846
2846
  "use strict";
2847
2847
  var { createRequire: createRequire4 } = __require("module");
2848
2848
  var getCallers = require_caller();
2849
- var { join: join60, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
2849
+ var { join: join61, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
2850
2850
  var sleep = require_atomic_sleep();
2851
2851
  var onExit = require_on_exit_leak_free();
2852
2852
  var ThreadStream = require_thread_stream();
@@ -2909,7 +2909,7 @@ var require_transport = __commonJS({
2909
2909
  throw new Error("only one of target or targets can be specified");
2910
2910
  }
2911
2911
  if (targets) {
2912
- target = bundlerOverrides["pino-worker"] || join60(__dirname, "worker.js");
2912
+ target = bundlerOverrides["pino-worker"] || join61(__dirname, "worker.js");
2913
2913
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2914
2914
  return {
2915
2915
  ...dest,
@@ -2927,7 +2927,7 @@ var require_transport = __commonJS({
2927
2927
  });
2928
2928
  });
2929
2929
  } else if (pipeline) {
2930
- target = bundlerOverrides["pino-worker"] || join60(__dirname, "worker.js");
2930
+ target = bundlerOverrides["pino-worker"] || join61(__dirname, "worker.js");
2931
2931
  options.pipelines = [pipeline.map((dest) => {
2932
2932
  return {
2933
2933
  ...dest,
@@ -2949,7 +2949,7 @@ var require_transport = __commonJS({
2949
2949
  return origin;
2950
2950
  }
2951
2951
  if (origin === "pino/file") {
2952
- return join60(__dirname, "..", "file.js");
2952
+ return join61(__dirname, "..", "file.js");
2953
2953
  }
2954
2954
  let fixTarget2;
2955
2955
  for (const filePath of callers) {
@@ -3938,7 +3938,7 @@ var require_safe_stable_stringify = __commonJS({
3938
3938
  return circularValue;
3939
3939
  }
3940
3940
  let res = "";
3941
- let join60 = ",";
3941
+ let join61 = ",";
3942
3942
  const originalIndentation = indentation;
3943
3943
  if (Array.isArray(value)) {
3944
3944
  if (value.length === 0) {
@@ -3952,7 +3952,7 @@ var require_safe_stable_stringify = __commonJS({
3952
3952
  indentation += spacer;
3953
3953
  res += `
3954
3954
  ${indentation}`;
3955
- join60 = `,
3955
+ join61 = `,
3956
3956
  ${indentation}`;
3957
3957
  }
3958
3958
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3960,13 +3960,13 @@ ${indentation}`;
3960
3960
  for (; i < maximumValuesToStringify - 1; i++) {
3961
3961
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3962
3962
  res += tmp2 !== void 0 ? tmp2 : "null";
3963
- res += join60;
3963
+ res += join61;
3964
3964
  }
3965
3965
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3966
3966
  res += tmp !== void 0 ? tmp : "null";
3967
3967
  if (value.length - 1 > maximumBreadth) {
3968
3968
  const removedKeys = value.length - maximumBreadth - 1;
3969
- res += `${join60}"... ${getItemCount(removedKeys)} not stringified"`;
3969
+ res += `${join61}"... ${getItemCount(removedKeys)} not stringified"`;
3970
3970
  }
3971
3971
  if (spacer !== "") {
3972
3972
  res += `
@@ -3987,7 +3987,7 @@ ${originalIndentation}`;
3987
3987
  let separator = "";
3988
3988
  if (spacer !== "") {
3989
3989
  indentation += spacer;
3990
- join60 = `,
3990
+ join61 = `,
3991
3991
  ${indentation}`;
3992
3992
  whitespace = " ";
3993
3993
  }
@@ -4001,13 +4001,13 @@ ${indentation}`;
4001
4001
  const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
4002
4002
  if (tmp !== void 0) {
4003
4003
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
4004
- separator = join60;
4004
+ separator = join61;
4005
4005
  }
4006
4006
  }
4007
4007
  if (keyLength > maximumBreadth) {
4008
4008
  const removedKeys = keyLength - maximumBreadth;
4009
4009
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
4010
- separator = join60;
4010
+ separator = join61;
4011
4011
  }
4012
4012
  if (spacer !== "" && separator.length > 1) {
4013
4013
  res = `
@@ -4048,7 +4048,7 @@ ${originalIndentation}`;
4048
4048
  }
4049
4049
  const originalIndentation = indentation;
4050
4050
  let res = "";
4051
- let join60 = ",";
4051
+ let join61 = ",";
4052
4052
  if (Array.isArray(value)) {
4053
4053
  if (value.length === 0) {
4054
4054
  return "[]";
@@ -4061,7 +4061,7 @@ ${originalIndentation}`;
4061
4061
  indentation += spacer;
4062
4062
  res += `
4063
4063
  ${indentation}`;
4064
- join60 = `,
4064
+ join61 = `,
4065
4065
  ${indentation}`;
4066
4066
  }
4067
4067
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -4069,13 +4069,13 @@ ${indentation}`;
4069
4069
  for (; i < maximumValuesToStringify - 1; i++) {
4070
4070
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
4071
4071
  res += tmp2 !== void 0 ? tmp2 : "null";
4072
- res += join60;
4072
+ res += join61;
4073
4073
  }
4074
4074
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
4075
4075
  res += tmp !== void 0 ? tmp : "null";
4076
4076
  if (value.length - 1 > maximumBreadth) {
4077
4077
  const removedKeys = value.length - maximumBreadth - 1;
4078
- res += `${join60}"... ${getItemCount(removedKeys)} not stringified"`;
4078
+ res += `${join61}"... ${getItemCount(removedKeys)} not stringified"`;
4079
4079
  }
4080
4080
  if (spacer !== "") {
4081
4081
  res += `
@@ -4088,7 +4088,7 @@ ${originalIndentation}`;
4088
4088
  let whitespace = "";
4089
4089
  if (spacer !== "") {
4090
4090
  indentation += spacer;
4091
- join60 = `,
4091
+ join61 = `,
4092
4092
  ${indentation}`;
4093
4093
  whitespace = " ";
4094
4094
  }
@@ -4097,7 +4097,7 @@ ${indentation}`;
4097
4097
  const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
4098
4098
  if (tmp !== void 0) {
4099
4099
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
4100
- separator = join60;
4100
+ separator = join61;
4101
4101
  }
4102
4102
  }
4103
4103
  if (spacer !== "" && separator.length > 1) {
@@ -4155,20 +4155,20 @@ ${originalIndentation}`;
4155
4155
  indentation += spacer;
4156
4156
  let res2 = `
4157
4157
  ${indentation}`;
4158
- const join61 = `,
4158
+ const join62 = `,
4159
4159
  ${indentation}`;
4160
4160
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
4161
4161
  let i = 0;
4162
4162
  for (; i < maximumValuesToStringify - 1; i++) {
4163
4163
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
4164
4164
  res2 += tmp2 !== void 0 ? tmp2 : "null";
4165
- res2 += join61;
4165
+ res2 += join62;
4166
4166
  }
4167
4167
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
4168
4168
  res2 += tmp !== void 0 ? tmp : "null";
4169
4169
  if (value.length - 1 > maximumBreadth) {
4170
4170
  const removedKeys = value.length - maximumBreadth - 1;
4171
- res2 += `${join61}"... ${getItemCount(removedKeys)} not stringified"`;
4171
+ res2 += `${join62}"... ${getItemCount(removedKeys)} not stringified"`;
4172
4172
  }
4173
4173
  res2 += `
4174
4174
  ${originalIndentation}`;
@@ -4184,16 +4184,16 @@ ${originalIndentation}`;
4184
4184
  return '"[Object]"';
4185
4185
  }
4186
4186
  indentation += spacer;
4187
- const join60 = `,
4187
+ const join61 = `,
4188
4188
  ${indentation}`;
4189
4189
  let res = "";
4190
4190
  let separator = "";
4191
4191
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
4192
4192
  if (isTypedArrayWithEntries(value)) {
4193
- res += stringifyTypedArray(value, join60, maximumBreadth);
4193
+ res += stringifyTypedArray(value, join61, maximumBreadth);
4194
4194
  keys = keys.slice(value.length);
4195
4195
  maximumPropertiesToStringify -= value.length;
4196
- separator = join60;
4196
+ separator = join61;
4197
4197
  }
4198
4198
  if (deterministic) {
4199
4199
  keys = sort(keys, comparator);
@@ -4204,13 +4204,13 @@ ${indentation}`;
4204
4204
  const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
4205
4205
  if (tmp !== void 0) {
4206
4206
  res += `${separator}${strEscape(key3)}: ${tmp}`;
4207
- separator = join60;
4207
+ separator = join61;
4208
4208
  }
4209
4209
  }
4210
4210
  if (keyLength > maximumBreadth) {
4211
4211
  const removedKeys = keyLength - maximumBreadth;
4212
4212
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
4213
- separator = join60;
4213
+ separator = join61;
4214
4214
  }
4215
4215
  if (separator !== "") {
4216
4216
  res = `
@@ -7113,11 +7113,11 @@ async function archiveRawSession(store, sessionId) {
7113
7113
  return await store.putRawSession(sessionId, exp.tool, Math.floor(exp.mtime), gz, size);
7114
7114
  }
7115
7115
  function detectForkPredecessor(sessionPath) {
7116
- const { readFileSync: readFileSync52, readdirSync: readdirSync35 } = requireFs();
7117
- const { dirname: dirname26, join: join60, basename: basename28 } = requirePath();
7116
+ const { readFileSync: readFileSync53, readdirSync: readdirSync35 } = requireFs();
7117
+ const { dirname: dirname26, join: join61, basename: basename28 } = requirePath();
7118
7118
  let text;
7119
7119
  try {
7120
- text = readFileSync52(sessionPath, "utf-8");
7120
+ text = readFileSync53(sessionPath, "utf-8");
7121
7121
  } catch {
7122
7122
  return null;
7123
7123
  }
@@ -7151,7 +7151,7 @@ function detectForkPredecessor(sessionPath) {
7151
7151
  if (!f.endsWith(".jsonl") || f === self || f === "sessions-index.json")
7152
7152
  continue;
7153
7153
  try {
7154
- if (readFileSync52(join60(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
7154
+ if (readFileSync53(join61(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
7155
7155
  return basename28(f, ".jsonl");
7156
7156
  }
7157
7157
  } catch {
@@ -30776,6 +30776,8 @@ var init_sync_client = __esm({
30776
30776
  });
30777
30777
 
30778
30778
  // src/memory-guard.ts
30779
+ import { readFileSync as readFileSync42, writeFileSync as writeFileSync11 } from "node:fs";
30780
+ import { join as join48 } from "node:path";
30779
30781
  function rssMb() {
30780
30782
  return Math.round(process.memoryUsage().rss / 1048576);
30781
30783
  }
@@ -30793,6 +30795,55 @@ function releaseMemory(gc = globalThis.gc) {
30793
30795
  gc();
30794
30796
  return true;
30795
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
+ function cgroupCurrentMb(dir = cgroupDir()) {
30836
+ if (!dir) return null;
30837
+ try {
30838
+ const n = Number(readFileSync42(join48(dir, "memory.current"), "utf8").trim());
30839
+ return Number.isFinite(n) ? Math.round(n / 1048576) : null;
30840
+ } catch {
30841
+ return null;
30842
+ }
30843
+ }
30844
+ function usedMb(rss = rssMb(), cgroup = cgroupCurrentMb()) {
30845
+ return cgroup !== null && cgroup > rss ? cgroup : rss;
30846
+ }
30796
30847
  var DEFAULT_RSS_MAX_MB;
30797
30848
  var init_memory_guard = __esm({
30798
30849
  "src/memory-guard.ts"() {
@@ -30802,8 +30853,8 @@ var init_memory_guard = __esm({
30802
30853
  });
30803
30854
 
30804
30855
  // ../engine/dist/core/artifact-codec.js
30805
- import { readFileSync as readFileSync42 } from "fs";
30806
- import { basename as basename23, join as join48 } from "path";
30856
+ import { readFileSync as readFileSync43 } from "fs";
30857
+ import { basename as basename23, join as join49 } from "path";
30807
30858
  import { homedir as homedir17 } from "os";
30808
30859
  function parseCommandText(content, format, fallbackName) {
30809
30860
  if (format === "toml") {
@@ -30826,30 +30877,30 @@ function parseAgentText(content, format, fallbackName) {
30826
30877
  return { name: fm.name || fallbackName, description: fm.description || "", tools: fm.tools, body: body.trim() };
30827
30878
  }
30828
30879
  function readCommand(filePath, format) {
30829
- return parseCommandText(readFileSync42(filePath, "utf-8"), format, base2(filePath));
30880
+ return parseCommandText(readFileSync43(filePath, "utf-8"), format, base2(filePath));
30830
30881
  }
30831
30882
  function readAgent(filePath, format) {
30832
- return parseAgentText(readFileSync42(filePath, "utf-8"), format, base2(filePath));
30883
+ return parseAgentText(readFileSync43(filePath, "utf-8"), format, base2(filePath));
30833
30884
  }
30834
30885
  function readInstructions(filePath, name) {
30835
- const content = readFileSync42(filePath, "utf-8");
30886
+ const content = readFileSync43(filePath, "utf-8");
30836
30887
  return { name, description: "", body: content };
30837
30888
  }
30838
30889
  function commandPath(tool, name) {
30839
30890
  switch (tool) {
30840
30891
  case "claude":
30841
- return join48(claudeBackend.commandsDir(), `${name}.md`);
30892
+ return join49(claudeBackend.commandsDir(), `${name}.md`);
30842
30893
  case "agy":
30843
- return join48(join48(agyBackend.homeDir(), "commands"), `${name}.toml`);
30894
+ return join49(join49(agyBackend.homeDir(), "commands"), `${name}.toml`);
30844
30895
  case "opencode":
30845
- return join48(opencodeBackend.commandsDir(), `${name}.md`);
30896
+ return join49(opencodeBackend.commandsDir(), `${name}.md`);
30846
30897
  case "codex":
30847
- return join48(codexBackend.promptsDir(), `${name}.md`);
30898
+ return join49(codexBackend.promptsDir(), `${name}.md`);
30848
30899
  case "cursor":
30849
- return join48(cursorHomeDir(), "commands", `${name}.md`);
30900
+ return join49(cursorHomeDir(), "commands", `${name}.md`);
30850
30901
  // Pi's prompt templates are flat *.md files in the agent dir.
30851
30902
  case "pi":
30852
- return join48(piBackend.promptsDir(), `${name}.md`);
30903
+ return join49(piBackend.promptsDir(), `${name}.md`);
30853
30904
  // Hermes has no command files. copyArtifactToTool refuses this target first.
30854
30905
  case "hermes":
30855
30906
  throw new Error("Hermes has no command files");
@@ -30858,15 +30909,15 @@ function commandPath(tool, name) {
30858
30909
  function agentPath(tool, name) {
30859
30910
  switch (tool) {
30860
30911
  case "claude":
30861
- return join48(claudeBackend.agentsDir(), `${name}.md`);
30912
+ return join49(claudeBackend.agentsDir(), `${name}.md`);
30862
30913
  case "agy":
30863
- return join48(join48(agyBackend.homeDir(), "agents"), `${name}.md`);
30914
+ return join49(join49(agyBackend.homeDir(), "agents"), `${name}.md`);
30864
30915
  case "opencode":
30865
- return join48(opencodeBackend.agentsDir(), `${name}.md`);
30916
+ return join49(opencodeBackend.agentsDir(), `${name}.md`);
30866
30917
  case "codex":
30867
- return join48(codexBackend.agentsDir(), `${name}.toml`);
30918
+ return join49(codexBackend.agentsDir(), `${name}.toml`);
30868
30919
  case "cursor":
30869
- return join48(cursorHomeDir(), "agents", `${name}.md`);
30920
+ return join49(cursorHomeDir(), "agents", `${name}.md`);
30870
30921
  // Pi has no named agent personas. copyArtifactToTool refuses this target first.
30871
30922
  case "pi":
30872
30923
  throw new Error("Pi has no agent files");
@@ -30903,23 +30954,23 @@ function instructionsFilename(tool) {
30903
30954
  function instructionsPath(tool, projectPath) {
30904
30955
  const file = instructionsFilename(tool);
30905
30956
  if (projectPath)
30906
- return join48(projectPath, file);
30957
+ return join49(projectPath, file);
30907
30958
  switch (tool) {
30908
30959
  case "claude":
30909
- return join48(claudeBackend.homeDir(), file);
30960
+ return join49(claudeBackend.homeDir(), file);
30910
30961
  case "agy":
30911
- return join48(agyBackend.homeDir(), file);
30962
+ return join49(agyBackend.homeDir(), file);
30912
30963
  case "codex":
30913
- return join48(codexBackend.homeDir(), file);
30964
+ return join49(codexBackend.homeDir(), file);
30914
30965
  case "opencode":
30915
- return join48(homedir17(), ".config", "opencode", file);
30966
+ return join49(homedir17(), ".config", "opencode", file);
30916
30967
  // Cursor has no single user-scope instructions FILE — user-level guidance
30917
30968
  // is User Rules plus ~/.cursor/rules/*.mdc. AGENTS.md at the home root is
30918
30969
  // the closest equivalent and is what a mirror can actually write.
30919
30970
  case "cursor":
30920
- return join48(cursorHomeDir(), file);
30971
+ return join49(cursorHomeDir(), file);
30921
30972
  case "pi":
30922
- return join48(piBackend.homeDir(), file);
30973
+ return join49(piBackend.homeDir(), file);
30923
30974
  case "hermes":
30924
30975
  throw new Error("Hermes has no instruction file mapping");
30925
30976
  }
@@ -30968,8 +31019,8 @@ var init_artifact_codec = __esm({
30968
31019
  });
30969
31020
 
30970
31021
  // ../engine/dist/core/toolkit-sync.js
30971
- import { existsSync as existsSync44, mkdirSync as mkdirSync12, readFileSync as readFileSync43, readdirSync as readdirSync33, writeFileSync as writeFileSync11, cpSync, rmSync as rmSync8 } from "fs";
30972
- import { dirname as dirname20, join as join49, basename as basename24 } from "path";
31022
+ import { existsSync as existsSync44, mkdirSync as mkdirSync12, readFileSync as readFileSync44, readdirSync as readdirSync33, writeFileSync as writeFileSync12, cpSync, rmSync as rmSync8 } from "fs";
31023
+ import { dirname as dirname20, join as join50, basename as basename24 } from "path";
30973
31024
  import { homedir as homedir18 } from "os";
30974
31025
  function rowFromMemoryItem(type, item) {
30975
31026
  const extra = item.extra || {};
@@ -30990,16 +31041,16 @@ function skillsDirFor(tool) {
30990
31041
  case "claude":
30991
31042
  return claudeBackend.skillsDir();
30992
31043
  case "agy":
30993
- return join49(agyBackend.homeDir(), "skills");
31044
+ return join50(agyBackend.homeDir(), "skills");
30994
31045
  case "opencode":
30995
31046
  return opencodeBackend.skillsDir();
30996
31047
  case "codex":
30997
31048
  return codexBackend.skillsDir();
30998
31049
  // user skills, NOT .system
30999
31050
  case "cursor":
31000
- return join49(cursorHomeDir(), "skills");
31051
+ return join50(cursorHomeDir(), "skills");
31001
31052
  case "hermes":
31002
- return join49(hermesBackend.homeDir(), "skills");
31053
+ return join50(hermesBackend.homeDir(), "skills");
31003
31054
  case "pi":
31004
31055
  return piBackend.skillsDir();
31005
31056
  }
@@ -31007,13 +31058,13 @@ function skillsDirFor(tool) {
31007
31058
  function skillDirsNamed(tool, name) {
31008
31059
  const root = skillsDirFor(tool);
31009
31060
  const found = [];
31010
- if (existsSync44(join49(root, name)))
31011
- found.push(join49(root, name));
31061
+ if (existsSync44(join50(root, name)))
31062
+ found.push(join50(root, name));
31012
31063
  if (tool !== "hermes" || !existsSync44(root))
31013
31064
  return found;
31014
31065
  for (const category of readdirSync33(root)) {
31015
- const candidate = join49(root, category, name);
31016
- if (existsSync44(join49(candidate, "SKILL.md")))
31066
+ const candidate = join50(root, category, name);
31067
+ if (existsSync44(join50(candidate, "SKILL.md")))
31017
31068
  found.push(candidate);
31018
31069
  }
31019
31070
  return found;
@@ -31023,7 +31074,7 @@ function copySkill(row, toTool) {
31023
31074
  if (!existsSync44(skillDir))
31024
31075
  return { ok: false, status: 404, error: `Source dir missing: ${skillDir}` };
31025
31076
  const name = row.extra.skillName || basename24(skillDir);
31026
- const targetDir = join49(skillsDirFor(toTool), name);
31077
+ const targetDir = join50(skillsDirFor(toTool), name);
31027
31078
  const existing = skillDirsNamed(toTool, name);
31028
31079
  if (existing.length)
31029
31080
  return { ok: false, status: 409, error: `Already exists: ${existing[0]}` };
@@ -31040,22 +31091,22 @@ function mcpJsonCandidates(tool) {
31040
31091
  switch (tool) {
31041
31092
  case "claude":
31042
31093
  return [
31043
- { path: join49(home, ".mcp.json"), key: "mcpServers" },
31044
- { path: join49(home, ".claude.json"), key: "mcpServers" }
31094
+ { path: join50(home, ".mcp.json"), key: "mcpServers" },
31095
+ { path: join50(home, ".claude.json"), key: "mcpServers" }
31045
31096
  ];
31046
31097
  case "gemini":
31047
- return [{ path: join49(home, ".gemini", "settings.json"), key: "mcpServers" }];
31098
+ return [{ path: join50(home, ".gemini", "settings.json"), key: "mcpServers" }];
31048
31099
  case "agy":
31049
- return [{ path: join49(home, ".gemini", "config", "mcp_config.json"), key: "mcpServers" }];
31100
+ return [{ path: join50(home, ".gemini", "config", "mcp_config.json"), key: "mcpServers" }];
31050
31101
  case "cursor":
31051
- return [{ path: join49(cursorHomeDir(), "mcp.json"), key: "mcpServers" }];
31102
+ return [{ path: join50(cursorHomeDir(), "mcp.json"), key: "mcpServers" }];
31052
31103
  case "pi":
31053
31104
  return [{ path: piMcpConfigPath(), key: "mcpServers" }];
31054
31105
  case "opencode":
31055
31106
  return [
31056
- { path: join49(home, ".config", "opencode", "opencode.json"), key: "mcp" },
31057
- { path: join49(home, ".config", "opencode", "config.json"), key: "mcp" },
31058
- { path: join49(home, ".opencode", "config.json"), key: "mcp" }
31107
+ { path: join50(home, ".config", "opencode", "opencode.json"), key: "mcp" },
31108
+ { path: join50(home, ".config", "opencode", "config.json"), key: "mcp" },
31109
+ { path: join50(home, ".opencode", "config.json"), key: "mcp" }
31059
31110
  ];
31060
31111
  default:
31061
31112
  return [];
@@ -31063,14 +31114,14 @@ function mcpJsonCandidates(tool) {
31063
31114
  }
31064
31115
  function readMcpEntry(tool, name) {
31065
31116
  if (tool === "codex")
31066
- return readCodexMcpEntry(join49(homedir18(), ".codex", "config.toml"), name);
31117
+ return readCodexMcpEntry(join50(homedir18(), ".codex", "config.toml"), name);
31067
31118
  if (tool === "hermes")
31068
31119
  return readHermesMcpServers()?.[name] ?? null;
31069
31120
  for (const t of mcpJsonCandidates(tool)) {
31070
31121
  if (!existsSync44(t.path))
31071
31122
  continue;
31072
31123
  try {
31073
- const cfg = JSON.parse(readFileSync43(t.path, "utf-8"));
31124
+ const cfg = JSON.parse(readFileSync44(t.path, "utf-8"));
31074
31125
  const block = cfg[t.key] || {};
31075
31126
  if (block[name])
31076
31127
  return block[name];
@@ -31084,7 +31135,7 @@ function readCodexMcpEntry(path, target) {
31084
31135
  return null;
31085
31136
  let content;
31086
31137
  try {
31087
- content = readFileSync43(path, "utf-8");
31138
+ content = readFileSync44(path, "utf-8");
31088
31139
  } catch {
31089
31140
  return null;
31090
31141
  }
@@ -31135,7 +31186,7 @@ function readCodexMcpEntry(path, target) {
31135
31186
  function writeCodexMcpEntry(path, name, entry) {
31136
31187
  let content = "";
31137
31188
  if (existsSync44(path))
31138
- content = readFileSync43(path, "utf-8");
31189
+ content = readFileSync44(path, "utf-8");
31139
31190
  const header = `[mcp_servers.${name}]`;
31140
31191
  if (content.includes(header))
31141
31192
  return false;
@@ -31165,7 +31216,7 @@ function writeCodexMcpEntry(path, name, entry) {
31165
31216
  lines.push(`${k} = ${escape(String(v))}`);
31166
31217
  }
31167
31218
  mkdirSync12(dirname20(path), { recursive: true });
31168
- writeFileSync11(path, content + lines.join("\n") + "\n");
31219
+ writeFileSync12(path, content + lines.join("\n") + "\n");
31169
31220
  return true;
31170
31221
  }
31171
31222
  function writeMcpEntry(toTool, name, entry) {
@@ -31173,7 +31224,7 @@ function writeMcpEntry(toTool, name, entry) {
31173
31224
  return writeHermesMcp(name, entry);
31174
31225
  const home = homedir18();
31175
31226
  if (toTool === "codex") {
31176
- const path2 = join49(home, ".codex", "config.toml");
31227
+ const path2 = join50(home, ".codex", "config.toml");
31177
31228
  if (!writeCodexMcpEntry(path2, name, entry))
31178
31229
  return { ok: false, status: 409, error: `MCP "${name}" already exists in ${path2}.` };
31179
31230
  return { ok: true, targetPath: path2 };
@@ -31181,25 +31232,25 @@ function writeMcpEntry(toTool, name, entry) {
31181
31232
  let path;
31182
31233
  let key2;
31183
31234
  if (toTool === "claude") {
31184
- path = join49(home, ".mcp.json");
31235
+ path = join50(home, ".mcp.json");
31185
31236
  key2 = "mcpServers";
31186
31237
  } else if (toTool === "agy") {
31187
- path = join49(home, ".gemini", "config", "mcp_config.json");
31238
+ path = join50(home, ".gemini", "config", "mcp_config.json");
31188
31239
  key2 = "mcpServers";
31189
31240
  } else if (toTool === "cursor") {
31190
- path = join49(cursorHomeDir(), "mcp.json");
31241
+ path = join50(cursorHomeDir(), "mcp.json");
31191
31242
  key2 = "mcpServers";
31192
31243
  } else if (toTool === "pi") {
31193
31244
  path = piMcpConfigPath();
31194
31245
  key2 = "mcpServers";
31195
31246
  } else {
31196
- path = join49(home, ".config", "opencode", "opencode.json");
31247
+ path = join50(home, ".config", "opencode", "opencode.json");
31197
31248
  key2 = "mcp";
31198
31249
  }
31199
31250
  let cfg = {};
31200
31251
  if (existsSync44(path)) {
31201
31252
  try {
31202
- cfg = JSON.parse(readFileSync43(path, "utf-8"));
31253
+ cfg = JSON.parse(readFileSync44(path, "utf-8"));
31203
31254
  } catch {
31204
31255
  return { ok: false, status: 500, error: `Target config is malformed: ${path}` };
31205
31256
  }
@@ -31231,7 +31282,7 @@ function writeMcpEntry(toTool, name, entry) {
31231
31282
  }
31232
31283
  cfg[key2][name] = normalized;
31233
31284
  try {
31234
- writeFileSync11(path, JSON.stringify(cfg, null, 2));
31285
+ writeFileSync12(path, JSON.stringify(cfg, null, 2));
31235
31286
  return { ok: true, targetPath: path };
31236
31287
  } catch (e) {
31237
31288
  return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
@@ -31265,7 +31316,7 @@ function copyCommandOrAgent(type, row, toTool) {
31265
31316
  return { ok: false, status: 409, error: `Already exists: ${out.path}` };
31266
31317
  try {
31267
31318
  mkdirSync12(dirname20(out.path), { recursive: true });
31268
- writeFileSync11(out.path, out.content);
31319
+ writeFileSync12(out.path, out.content);
31269
31320
  return { ok: true, targetPath: out.path };
31270
31321
  } catch (e) {
31271
31322
  return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
@@ -31285,7 +31336,7 @@ function copyInstructions(row, toTool) {
31285
31336
  return { ok: false, status: 409, error: `Already exists: ${out.path}` };
31286
31337
  try {
31287
31338
  mkdirSync12(dirname20(out.path), { recursive: true });
31288
- writeFileSync11(out.path, out.content);
31339
+ writeFileSync12(out.path, out.content);
31289
31340
  return { ok: true, targetPath: out.path };
31290
31341
  } catch (e) {
31291
31342
  return { ok: false, status: 500, error: e instanceof Error ? e.message : "write failed" };
@@ -31298,11 +31349,11 @@ function writeHermesMcp(name, entry) {
31298
31349
  if (!existsSync44(path))
31299
31350
  return { ok: false, status: 404, error: `${path} not found` };
31300
31351
  try {
31301
- const after = addHermesMcpServer(readFileSync43(path, "utf-8"), name, hermesServerEntry(entry));
31352
+ const after = addHermesMcpServer(readFileSync44(path, "utf-8"), name, hermesServerEntry(entry));
31302
31353
  if (after === null)
31303
31354
  return { ok: false, status: 409, error: `MCP "${name}" already exists in ${path}` };
31304
31355
  const backupPaths = [backupToTrash(path, `mcp-hermes-${name}-config.yaml`)];
31305
- writeFileSync11(path, after);
31356
+ writeFileSync12(path, after);
31306
31357
  return { ok: true, targetPath: path, backupPaths };
31307
31358
  } catch (e) {
31308
31359
  return removeFailed(e, "write failed");
@@ -31337,7 +31388,7 @@ async function removeArtifactFromTool(type, name, tool) {
31337
31388
  return removeCommandOrAgent(type, name, tool);
31338
31389
  }
31339
31390
  function backupToTrash(src, label) {
31340
- const dest = join49(getDataDir(), "trash", `${Date.now()}-${label.replace(/[^A-Za-z0-9._-]/g, "_")}`);
31391
+ const dest = join50(getDataDir(), "trash", `${Date.now()}-${label.replace(/[^A-Za-z0-9._-]/g, "_")}`);
31341
31392
  mkdirSync12(dirname20(dest), { recursive: true });
31342
31393
  cpSync(src, dest, { recursive: true });
31343
31394
  return dest;
@@ -31348,7 +31399,7 @@ function removeFailed(e, fallback) {
31348
31399
  function removeSkill(name, tool) {
31349
31400
  const found = skillDirsNamed(tool, name);
31350
31401
  if (found.length === 0)
31351
- return { ok: false, status: 404, error: `Not found: ${join49(skillsDirFor(tool), name)}` };
31402
+ return { ok: false, status: 404, error: `Not found: ${join50(skillsDirFor(tool), name)}` };
31352
31403
  if (found.length > 1)
31353
31404
  return { ok: false, status: 409, error: `${found.length} skills named "${name}" for ${tool}; none removed` };
31354
31405
  const dir = found[0];
@@ -31385,27 +31436,27 @@ function removeMcp(name, tool) {
31385
31436
  if (!existsSync44(path))
31386
31437
  return { ok: false, status: 404, error: `${path} not found` };
31387
31438
  try {
31388
- const after = deleteHermesMcpServer(readFileSync43(path, "utf-8"), name);
31439
+ const after = deleteHermesMcpServer(readFileSync44(path, "utf-8"), name);
31389
31440
  if (after === null)
31390
31441
  return { ok: false, status: 404, error: `MCP "${name}" not found in ${path}` };
31391
31442
  const backupPaths2 = [backupToTrash(path, `mcp-hermes-${name}-config.yaml`)];
31392
- writeFileSync11(path, after);
31443
+ writeFileSync12(path, after);
31393
31444
  return { ok: true, targetPath: path, backupPaths: backupPaths2 };
31394
31445
  } catch (e) {
31395
31446
  return removeFailed(e, "write failed");
31396
31447
  }
31397
31448
  }
31398
31449
  if (tool === "codex") {
31399
- const path = join49(homedir18(), ".codex", "config.toml");
31450
+ const path = join50(homedir18(), ".codex", "config.toml");
31400
31451
  if (!existsSync44(path))
31401
31452
  return { ok: false, status: 404, error: "config.toml not found" };
31402
- const before = readFileSync43(path, "utf-8");
31453
+ const before = readFileSync44(path, "utf-8");
31403
31454
  const after = stripCodexMcpBlock(before, name);
31404
31455
  if (before === after)
31405
31456
  return { ok: false, status: 404, error: `MCP "${name}" not found in ${path}` };
31406
31457
  try {
31407
31458
  const backupPaths2 = [backupToTrash(path, `mcp-codex-${name}`)];
31408
- writeFileSync11(path, after);
31459
+ writeFileSync12(path, after);
31409
31460
  return { ok: true, targetPath: path, backupPaths: backupPaths2 };
31410
31461
  } catch (e) {
31411
31462
  return removeFailed(e, "write failed");
@@ -31417,12 +31468,12 @@ function removeMcp(name, tool) {
31417
31468
  if (!existsSync44(c.path))
31418
31469
  continue;
31419
31470
  try {
31420
- const cfg = JSON.parse(readFileSync43(c.path, "utf-8"));
31471
+ const cfg = JSON.parse(readFileSync44(c.path, "utf-8"));
31421
31472
  if (!cfg[c.key]?.[name])
31422
31473
  continue;
31423
31474
  backupPaths.push(backupToTrash(c.path, `mcp-${tool}-${name}-${basename24(c.path)}`));
31424
31475
  delete cfg[c.key][name];
31425
- writeFileSync11(c.path, JSON.stringify(cfg, null, 2));
31476
+ writeFileSync12(c.path, JSON.stringify(cfg, null, 2));
31426
31477
  if (!removedFrom)
31427
31478
  removedFrom = c.path;
31428
31479
  } catch (e) {
@@ -31595,8 +31646,8 @@ var init_code_task_status = __esm({
31595
31646
  });
31596
31647
 
31597
31648
  // src/project-tasks.ts
31598
- import { existsSync as existsSync45, readFileSync as readFileSync44, writeFileSync as writeFileSync12, mkdirSync as mkdirSync13, statSync as statSync42 } from "node:fs";
31599
- import { join as join50, dirname as dirname21 } from "node:path";
31649
+ import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as statSync42 } from "node:fs";
31650
+ import { join as join51, dirname as dirname21 } from "node:path";
31600
31651
  import { homedir as homedir19 } from "node:os";
31601
31652
  function isTeamTaskStatus(v) {
31602
31653
  return !!v && TEAM_STATUSES.has(v);
@@ -31647,11 +31698,11 @@ function parseTaskFile(content) {
31647
31698
  return out;
31648
31699
  }
31649
31700
  function ledgerPath2() {
31650
- return join50(homedir19(), ".chat-recall", "project-tasks-ledger.json");
31701
+ return join51(homedir19(), ".chat-recall", "project-tasks-ledger.json");
31651
31702
  }
31652
31703
  function readLedger() {
31653
31704
  try {
31654
- return JSON.parse(readFileSync44(ledgerPath2(), "utf8"));
31705
+ return JSON.parse(readFileSync45(ledgerPath2(), "utf8"));
31655
31706
  } catch {
31656
31707
  return {};
31657
31708
  }
@@ -31662,7 +31713,7 @@ function writeLedger(l) {
31662
31713
  } catch {
31663
31714
  }
31664
31715
  try {
31665
- writeFileSync12(ledgerPath2(), JSON.stringify(l));
31716
+ writeFileSync13(ledgerPath2(), JSON.stringify(l));
31666
31717
  } catch {
31667
31718
  }
31668
31719
  }
@@ -31680,7 +31731,7 @@ async function pushProjectTaskStatuses(base3, authHeaders, opts = {}) {
31680
31731
  continue;
31681
31732
  }
31682
31733
  for (const project of projects) {
31683
- const file = join50(project, fk.filename);
31734
+ const file = join51(project, fk.filename);
31684
31735
  if (!existsSync45(file)) continue;
31685
31736
  let mtime;
31686
31737
  try {
@@ -31691,7 +31742,7 @@ async function pushProjectTaskStatuses(base3, authHeaders, opts = {}) {
31691
31742
  if (ledger[file] === mtime) continue;
31692
31743
  let changed;
31693
31744
  try {
31694
- changed = parseTaskFile(readFileSync44(file, "utf8")).filter((t) => t.kind === fk.kind);
31745
+ changed = parseTaskFile(readFileSync45(file, "utf8")).filter((t) => t.kind === fk.kind);
31695
31746
  } catch {
31696
31747
  continue;
31697
31748
  }
@@ -31739,7 +31790,7 @@ var init_project_tasks = __esm({
31739
31790
 
31740
31791
  // ../engine/dist/core/which.js
31741
31792
  import { existsSync as existsSync46, statSync as statSync43, accessSync, constants } from "node:fs";
31742
- import { join as join51, isAbsolute as isAbsolute3, delimiter as delimiter2, sep as sep3 } from "node:path";
31793
+ import { join as join52, isAbsolute as isAbsolute3, delimiter as delimiter2, sep as sep3 } from "node:path";
31743
31794
  function executable(p) {
31744
31795
  try {
31745
31796
  if (!statSync43(p).isFile())
@@ -31778,7 +31829,7 @@ function resolveOnPath(name) {
31778
31829
  if (!dir)
31779
31830
  continue;
31780
31831
  for (const c of candidates(name)) {
31781
- const full = join51(dir, c);
31832
+ const full = join52(dir, c);
31782
31833
  if (existsSync46(full) && executable(full))
31783
31834
  return full;
31784
31835
  }
@@ -31805,8 +31856,8 @@ __export(toolkit_pull_exports, {
31805
31856
  platformRefusal: () => platformRefusal,
31806
31857
  portableCommand: () => portableCommand
31807
31858
  });
31808
- import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync44, writeFileSync as writeFileSync13 } from "node:fs";
31809
- import { dirname as dirname22, join as join52, basename as basename25, isAbsolute as isAbsolute4 } from "node:path";
31859
+ import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync44, writeFileSync as writeFileSync14 } from "node:fs";
31860
+ import { dirname as dirname22, join as join53, basename as basename25, isAbsolute as isAbsolute4 } from "node:path";
31810
31861
  function isExecutableFile(p) {
31811
31862
  try {
31812
31863
  return statSync44(p).isFile();
@@ -31976,8 +32027,8 @@ function executePull(rows, opts = {}) {
31976
32027
  const outcomes = [];
31977
32028
  for (const { name, body, truncated, redacted, tools } of skills) {
31978
32029
  for (const tool of tools) {
31979
- const dir = join52(skillsDirFor(tool), name);
31980
- const file = join52(dir, "SKILL.md");
32030
+ const dir = join53(skillsDirFor(tool), name);
32031
+ const file = join53(dir, "SKILL.md");
31981
32032
  if (existsSync47(file)) {
31982
32033
  outcomes.push({ type: "skill", name, tool, status: "present" });
31983
32034
  continue;
@@ -31992,7 +32043,7 @@ function executePull(rows, opts = {}) {
31992
32043
  }
31993
32044
  try {
31994
32045
  mkdirSync14(dir, { recursive: true });
31995
- writeFileSync13(file, body);
32046
+ writeFileSync14(file, body);
31996
32047
  outcomes.push({ type: "skill", name, tool, status: "written", path: file, redactedContent: redacted });
31997
32048
  } catch (e) {
31998
32049
  outcomes.push({ type: "skill", name, tool, status: "failed", reason: e instanceof Error ? e.message : "write failed" });
@@ -32033,7 +32084,7 @@ function executePull(rows, opts = {}) {
32033
32084
  }
32034
32085
  try {
32035
32086
  mkdirSync14(dirname22(out.path), { recursive: true });
32036
- writeFileSync13(out.path, out.content);
32087
+ writeFileSync14(out.path, out.content);
32037
32088
  outcomes.push({ type, name, tool, status: "written", path: out.path, redactedContent: redacted });
32038
32089
  } catch (e) {
32039
32090
  outcomes.push({ type, name, tool, status: "failed", reason: e instanceof Error ? e.message : "write failed" });
@@ -32341,8 +32392,8 @@ var init_repair = __esm({
32341
32392
  });
32342
32393
 
32343
32394
  // src/intent-drain.ts
32344
- import { existsSync as existsSync48, readFileSync as readFileSync45, writeFileSync as writeFileSync14, appendFileSync, mkdirSync as mkdirSync15 } from "node:fs";
32345
- import { join as join53 } from "node:path";
32395
+ import { existsSync as existsSync48, readFileSync as readFileSync46, writeFileSync as writeFileSync15, appendFileSync, mkdirSync as mkdirSync15 } from "node:fs";
32396
+ import { join as join54 } from "node:path";
32346
32397
  import { fileURLToPath as fileURLToPath4 } from "node:url";
32347
32398
  import { dirname as dirname23 } from "node:path";
32348
32399
  function instructionTargets(rootPath, isGlobal) {
@@ -32356,17 +32407,17 @@ function instructionTargets(rootPath, isGlobal) {
32356
32407
  const tools = installed.length ? installed : [INSTRUCTION_TOOLS[0]];
32357
32408
  if (isGlobal) return [...new Set(tools.map((t) => instructionsPath(t.id)))];
32358
32409
  if (!rootPath) return [];
32359
- const present = INSTRUCTION_FILENAMES.map((f) => join53(rootPath, f)).filter((p) => existsSync48(p));
32410
+ const present = INSTRUCTION_FILENAMES.map((f) => join54(rootPath, f)).filter((p) => existsSync48(p));
32360
32411
  if (present.length) return present;
32361
- return [...new Set(tools.map((t) => join53(rootPath, instructionsFilename(t.id))))];
32412
+ return [...new Set(tools.map((t) => join54(rootPath, instructionsFilename(t.id))))];
32362
32413
  }
32363
32414
  function applyCodeRecommendation(intent) {
32364
32415
  try {
32365
32416
  const meta = JSON.parse(intent.name || "{}");
32366
32417
  if (intent.artifact_type === "write_tasks_file") {
32367
32418
  if (!meta.rootPath || !meta.content) return { status: "error", result: JSON.stringify({ error: "missing rootPath or content" }) };
32368
- const file = join53(meta.rootPath, meta.filename || "CODE_TASKS.md");
32369
- writeFileSync14(file, meta.content);
32419
+ const file = join54(meta.rootPath, meta.filename || "CODE_TASKS.md");
32420
+ writeFileSync15(file, meta.content);
32370
32421
  return { status: "done", result: JSON.stringify({ wrote: file }) };
32371
32422
  }
32372
32423
  if (intent.artifact_type === "append_claude_md") {
@@ -32384,7 +32435,7 @@ function applyCodeRecommendation(intent) {
32384
32435
  mkdirSync15(dir, { recursive: true });
32385
32436
  } catch {
32386
32437
  }
32387
- const existing = existsSync48(file) ? readFileSync45(file, "utf8") : "";
32438
+ const existing = existsSync48(file) ? readFileSync46(file, "utf8") : "";
32388
32439
  if (existing.includes(text)) {
32389
32440
  skipped.push(file);
32390
32441
  continue;
@@ -32394,7 +32445,7 @@ function applyCodeRecommendation(intent) {
32394
32445
  ${text}
32395
32446
  `;
32396
32447
  if (existing) appendFileSync(file, block);
32397
- else writeFileSync14(file, `# ${meta.rootPath?.split("/").pop() || "Global"} instructions
32448
+ else writeFileSync15(file, `# ${meta.rootPath?.split("/").pop() || "Global"} instructions
32398
32449
  ${block}`);
32399
32450
  appended.push(file);
32400
32451
  }
@@ -32570,7 +32621,7 @@ var init_intent_drain = __esm({
32570
32621
  ownVersion2 = "0.0.0";
32571
32622
  try {
32572
32623
  const dir = dirname23(fileURLToPath4(import.meta.url));
32573
- ownVersion2 = JSON.parse(readFileSync45(join53(dir, "../package.json"), "utf-8")).version || ownVersion2;
32624
+ ownVersion2 = JSON.parse(readFileSync46(join54(dir, "../package.json"), "utf-8")).version || ownVersion2;
32574
32625
  } catch {
32575
32626
  try {
32576
32627
  if (typeof __CLI_VERSION__ === "string") ownVersion2 = __CLI_VERSION__;
@@ -32581,13 +32632,13 @@ var init_intent_drain = __esm({
32581
32632
  });
32582
32633
 
32583
32634
  // src/code-index-cursor.ts
32584
- import { readFileSync as readFileSync46, writeFileSync as writeFileSync15, mkdirSync as mkdirSync16, statSync as statSync45 } from "fs";
32635
+ import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as statSync45 } from "fs";
32585
32636
  import { execFileSync as execFileSync4 } from "child_process";
32586
32637
  import { createHash as createHash12 } from "crypto";
32587
- import { join as join54, dirname as dirname24 } from "path";
32638
+ import { join as join55, dirname as dirname24 } from "path";
32588
32639
  function readCursor() {
32589
32640
  try {
32590
- const raw = JSON.parse(readFileSync46(cursorPath(), "utf-8"));
32641
+ const raw = JSON.parse(readFileSync47(cursorPath(), "utf-8"));
32591
32642
  if (raw && typeof raw === "object" && !Array.isArray(raw)) {
32592
32643
  const out = {};
32593
32644
  for (const [k, v] of Object.entries(raw)) {
@@ -32607,7 +32658,7 @@ function writeCursor(c) {
32607
32658
  try {
32608
32659
  const p = cursorPath();
32609
32660
  mkdirSync16(dirname24(p), { recursive: true });
32610
- writeFileSync15(p, JSON.stringify(c));
32661
+ writeFileSync16(p, JSON.stringify(c));
32611
32662
  } catch {
32612
32663
  }
32613
32664
  }
@@ -32631,7 +32682,7 @@ function workspaceFingerprint(workspace, collectorVersion) {
32631
32682
  const rel = entry.slice(3);
32632
32683
  let stamp2 = "gone";
32633
32684
  try {
32634
- const s = statSync45(join54(workspace, rel));
32685
+ const s = statSync45(join55(workspace, rel));
32635
32686
  stamp2 = `${s.size}:${Math.floor(s.mtimeMs)}`;
32636
32687
  } catch {
32637
32688
  }
@@ -32666,7 +32717,7 @@ var init_code_index_cursor = __esm({
32666
32717
  "src/code-index-cursor.ts"() {
32667
32718
  "use strict";
32668
32719
  init_paths();
32669
- cursorPath = () => join54(getDataDir(), "code-index-cursor.json");
32720
+ cursorPath = () => join55(getDataDir(), "code-index-cursor.json");
32670
32721
  UNCHANGED_RESEND_MS = 7 * 24 * 3600 * 1e3;
32671
32722
  }
32672
32723
  });
@@ -32784,12 +32835,12 @@ var init_daemon_log = __esm({
32784
32835
 
32785
32836
  // src/self-restart.ts
32786
32837
  import { spawn as spawn2 } from "child_process";
32787
- import { readFileSync as readFileSync47 } from "fs";
32838
+ import { readFileSync as readFileSync48 } from "fs";
32788
32839
  import { createHash as createHash13 } from "crypto";
32789
32840
  function codeFingerprint(entry = process.argv[1]) {
32790
32841
  if (!entry) return null;
32791
32842
  try {
32792
- const buf = readFileSync47(entry);
32843
+ const buf = readFileSync48(entry);
32793
32844
  return {
32794
32845
  path: entry,
32795
32846
  size: buf.byteLength,
@@ -32938,7 +32989,7 @@ __export(shadow_prune_exports, {
32938
32989
  pruneShadow: () => pruneShadow
32939
32990
  });
32940
32991
  import { readdirSync as readdirSync34, statSync as statSync47, unlinkSync as unlinkSync3 } from "fs";
32941
- import { join as join55 } from "path";
32992
+ import { join as join56 } from "path";
32942
32993
  function listShadows(isFullyAcked) {
32943
32994
  const out = [];
32944
32995
  const root = shadowRoot();
@@ -32949,7 +33000,7 @@ function listShadows(isFullyAcked) {
32949
33000
  return out;
32950
33001
  }
32951
33002
  for (const tool of tools) {
32952
- const dir = join55(root, tool);
33003
+ const dir = join56(root, tool);
32953
33004
  let names;
32954
33005
  try {
32955
33006
  names = readdirSync34(dir);
@@ -32959,7 +33010,7 @@ function listShadows(isFullyAcked) {
32959
33010
  for (const name of names) {
32960
33011
  if (!name.endsWith(".gz"))
32961
33012
  continue;
32962
- const path = join55(dir, name);
33013
+ const path = join56(dir, name);
32963
33014
  let st;
32964
33015
  try {
32965
33016
  st = statSync47(path);
@@ -33077,9 +33128,9 @@ var init_code_intel = __esm({
33077
33128
  });
33078
33129
 
33079
33130
  // ../engine/dist/core/companions.js
33080
- import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as statSync48, chmodSync as chmodSync5, unlinkSync as unlinkSync4, renameSync as renameSync5, createWriteStream as createWriteStream2, readFileSync as readFileSync48, writeFileSync as writeFileSync16 } from "node:fs";
33131
+ import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as statSync48, chmodSync as chmodSync5, unlinkSync as unlinkSync4, renameSync as renameSync5, createWriteStream as createWriteStream2, readFileSync as readFileSync49, writeFileSync as writeFileSync17 } from "node:fs";
33081
33132
  import { homedir as homedir20 } from "node:os";
33082
- import { join as join56 } from "node:path";
33133
+ import { join as join57 } from "node:path";
33083
33134
  import { execSync as execSync3 } from "node:child_process";
33084
33135
  import { createHash as createHash15 } from "node:crypto";
33085
33136
  function expectedCodeindexSha256(artifact) {
@@ -33189,7 +33240,7 @@ async function installCodeindex(opts = {}) {
33189
33240
  if (!expected) {
33190
33241
  throw new Error(`No pinned checksum for ${status.artifactName} \u2014 refusing to install an unverified binary. Add its sha256 to CODEINDEX_SHA256 in companions.ts.`);
33191
33242
  }
33192
- const actual = createHash15("sha256").update(readFileSync48(tmpPath)).digest("hex");
33243
+ const actual = createHash15("sha256").update(readFileSync49(tmpPath)).digest("hex");
33193
33244
  if (actual !== expected) {
33194
33245
  throw new Error(`Checksum mismatch for ${status.artifactName}.
33195
33246
  expected ${expected}
@@ -33223,9 +33274,9 @@ var init_companions = __esm({
33223
33274
  "x86_64-windows": "a96fc8c8949bb399a44cc0615b12e458460a529c69f01e8829cc39a20f45ab29",
33224
33275
  "aarch64-windows": "42620d56272cd9ba9d785569d8d754d6b4a3e80f36f28db3e0c483fd600ed117"
33225
33276
  };
33226
- CODEINDEX_INSTALL_DIR = join56(homedir20(), ".local", "bin");
33277
+ CODEINDEX_INSTALL_DIR = join57(homedir20(), ".local", "bin");
33227
33278
  CODEINDEX_BIN_NAME = process.platform === "win32" ? "codeindex.exe" : "codeindex";
33228
- CODEINDEX_BIN_PATH = join56(CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME);
33279
+ CODEINDEX_BIN_PATH = join57(CODEINDEX_INSTALL_DIR, CODEINDEX_BIN_NAME);
33229
33280
  }
33230
33281
  });
33231
33282
 
@@ -33340,8 +33391,8 @@ __export(collector_exports, {
33340
33391
  });
33341
33392
  import { spawn as spawn3 } from "node:child_process";
33342
33393
  import { execSync as execSync4 } from "node:child_process";
33343
- import { readFileSync as readFileSync49 } from "node:fs";
33344
- import { join as join57, basename as basename26 } from "node:path";
33394
+ import { readFileSync as readFileSync50 } from "node:fs";
33395
+ import { join as join58, basename as basename26 } from "node:path";
33345
33396
  async function resolveCodeindexBin(autoInstall = true) {
33346
33397
  let st = checkCodeindexStatus();
33347
33398
  if (!st.installed && autoInstall)
@@ -33523,7 +33574,7 @@ async function collectCode(opts) {
33523
33574
  }
33524
33575
  const complexity = (r) => {
33525
33576
  try {
33526
- const txt = readFileSync49(join57(ws, r), "utf8");
33577
+ const txt = readFileSync50(join58(ws, r), "utf8");
33527
33578
  if (txt.length > 2e6)
33528
33579
  return 1;
33529
33580
  const m = txt.match(CF_RE);
@@ -34288,15 +34339,15 @@ __export(service_installer_exports, {
34288
34339
  uninstallService: () => uninstallService
34289
34340
  });
34290
34341
  import { execSync as execSync5 } from "child_process";
34291
- import { existsSync as existsSync51, mkdirSync as mkdirSync18, readFileSync as readFileSync50, rmSync as rmSync9, writeFileSync as writeFileSync17 } from "fs";
34342
+ import { existsSync as existsSync51, mkdirSync as mkdirSync18, readFileSync as readFileSync51, rmSync as rmSync9, writeFileSync as writeFileSync18 } from "fs";
34292
34343
  import { homedir as homedir21 } from "os";
34293
- import { join as join58 } from "path";
34344
+ import { join as join59 } from "path";
34294
34345
  import { fileURLToPath as fileURLToPath5 } from "url";
34295
34346
  function resolveDaemonPaths() {
34296
34347
  const watchJs = fileURLToPath5(new URL("./watch.js", import.meta.url));
34297
34348
  const node = process.execPath;
34298
- const dataDir = join58(homedir21(), ".chat-recall");
34299
- const logFile = join58(dataDir, "watch.log");
34349
+ const dataDir = join59(homedir21(), ".chat-recall");
34350
+ const logFile = join59(dataDir, "watch.log");
34300
34351
  return { watchJs, node, logFile, dataDir };
34301
34352
  }
34302
34353
  function tryCmd(cmd) {
@@ -34323,13 +34374,13 @@ function refreshServiceDefinition() {
34323
34374
  if (process.platform !== "linux") return false;
34324
34375
  try {
34325
34376
  const { watchJs, node, logFile } = resolveDaemonPaths();
34326
- const unitPath = join58(homedir21(), ".config", "systemd", "user", "chat-recall-watch.service");
34377
+ const unitPath = join59(homedir21(), ".config", "systemd", "user", "chat-recall-watch.service");
34327
34378
  if (!existsSync51(unitPath)) return false;
34328
- const current = readFileSync50(unitPath, "utf8");
34379
+ const current = readFileSync51(unitPath, "utf8");
34329
34380
  if (!current.includes(watchJs)) return false;
34330
34381
  const wanted = renderSystemdUnit(watchJs, node, logFile);
34331
- if (readFileSync50(unitPath, "utf8") === wanted) return false;
34332
- writeFileSync17(unitPath, wanted);
34382
+ if (readFileSync51(unitPath, "utf8") === wanted) return false;
34383
+ writeFileSync18(unitPath, wanted);
34333
34384
  execSync5("systemctl --user daemon-reload", { stdio: "ignore" });
34334
34385
  return true;
34335
34386
  } catch {
@@ -34354,11 +34405,11 @@ function installService() {
34354
34405
  );
34355
34406
  }
34356
34407
  function installSystemd(watchJs, node, logFile) {
34357
- const unitDir = join58(homedir21(), ".config", "systemd", "user");
34358
- const unitPath = join58(unitDir, "chat-recall-watch.service");
34408
+ const unitDir = join59(homedir21(), ".config", "systemd", "user");
34409
+ const unitPath = join59(unitDir, "chat-recall-watch.service");
34359
34410
  const unit = renderSystemdUnit(watchJs, node, logFile);
34360
34411
  mkdirSync18(unitDir, { recursive: true });
34361
- writeFileSync17(unitPath, unit);
34412
+ writeFileSync18(unitPath, unit);
34362
34413
  try {
34363
34414
  execSync5("systemctl --user daemon-reload && systemctl --user enable chat-recall-watch.service && systemctl --user restart chat-recall-watch.service", { stdio: "inherit" });
34364
34415
  try {
@@ -34440,11 +34491,11 @@ function renderSystemdUnit(watchJs, node, logFile) {
34440
34491
  }
34441
34492
  function installLaunchd(watchJs, node, logFile) {
34442
34493
  const label = "com.chat-recall.watch";
34443
- const plistDir = join58(homedir21(), "Library", "LaunchAgents");
34444
- const plistPath = join58(plistDir, `${label}.plist`);
34494
+ const plistDir = join59(homedir21(), "Library", "LaunchAgents");
34495
+ const plistPath = join59(plistDir, `${label}.plist`);
34445
34496
  const plist = renderLaunchdPlist(watchJs, node, logFile, label);
34446
34497
  mkdirSync18(plistDir, { recursive: true });
34447
- writeFileSync17(plistPath, plist);
34498
+ writeFileSync18(plistPath, plist);
34448
34499
  try {
34449
34500
  try {
34450
34501
  execSync5(`launchctl unload "${plistPath}"`, { stdio: "ignore" });
@@ -34497,7 +34548,7 @@ function uninstallService() {
34497
34548
  removed = true;
34498
34549
  } catch {
34499
34550
  }
34500
- const unitPath = join58(homedir21(), ".config", "systemd", "user", "chat-recall-watch.service");
34551
+ const unitPath = join59(homedir21(), ".config", "systemd", "user", "chat-recall-watch.service");
34501
34552
  if (existsSync51(unitPath)) {
34502
34553
  rmSync9(unitPath, { force: true });
34503
34554
  removed = true;
@@ -34509,7 +34560,7 @@ function uninstallService() {
34509
34560
  return removed;
34510
34561
  }
34511
34562
  if (process.platform === "darwin") {
34512
- const plistPath = join58(homedir21(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
34563
+ const plistPath = join59(homedir21(), "Library", "LaunchAgents", "com.chat-recall.watch.plist");
34513
34564
  try {
34514
34565
  execSync5(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
34515
34566
  } catch {
@@ -34559,9 +34610,9 @@ __export(indexer_exports, {
34559
34610
  noteSyncOutcome: () => noteSyncOutcome
34560
34611
  });
34561
34612
  import chokidar from "chokidar";
34562
- import { dirname as dirname25, basename as basename27, join as join59, resolve as resolve2, sep as sep4 } from "path";
34613
+ import { dirname as dirname25, basename as basename27, join as join60, resolve as resolve2, sep as sep4 } from "path";
34563
34614
  import { homedir as homedir22 } from "os";
34564
- import { existsSync as existsSync52, readFileSync as readFileSync51, statSync as statSync49 } from "fs";
34615
+ import { existsSync as existsSync52, readFileSync as readFileSync52, statSync as statSync49 } from "fs";
34565
34616
  async function shipToServer(trigger) {
34566
34617
  if (syncInFlight) return;
34567
34618
  syncInFlight = true;
@@ -34592,6 +34643,7 @@ async function shipToServer(trigger) {
34592
34643
  } finally {
34593
34644
  syncInFlight = false;
34594
34645
  releaseMemory();
34646
+ reclaimCgroup();
34595
34647
  }
34596
34648
  }
34597
34649
  function scheduleSync() {
@@ -34605,7 +34657,7 @@ function scheduleSync() {
34605
34657
  }
34606
34658
  async function onResumeSignal(path) {
34607
34659
  try {
34608
- const txt = readFileSync51(path, "utf-8");
34660
+ const txt = readFileSync52(path, "utf-8");
34609
34661
  const m = /--resume\s+([0-9a-fA-F-]{36})/.exec(txt);
34610
34662
  if (!m) return;
34611
34663
  const id = m[1];
@@ -34791,7 +34843,7 @@ function isCodeWorkspace(p) {
34791
34843
  }
34792
34844
  return WORKSPACE_MARKERS.some((m) => {
34793
34845
  try {
34794
- return existsSync52(join59(p, m));
34846
+ return existsSync52(join60(p, m));
34795
34847
  } catch {
34796
34848
  return false;
34797
34849
  }
@@ -34819,10 +34871,11 @@ async function codeIndexTick() {
34819
34871
  const cursor = readCursor();
34820
34872
  const rssLimit = memoryLimitMb();
34821
34873
  for (const ws of workspaces) {
34822
- const rss = rssMb();
34823
- if (isOverMemoryLimit(rss, rssLimit)) {
34874
+ const used = usedMb(rssMb());
34875
+ if (isOverMemoryLimit(used, rssLimit)) {
34824
34876
  releaseMemory();
34825
- daemonLog.info(`code intelligence: paused at the memory bound (rss=${rss}MB \u2265 ${rssLimit}MB) \u2014 ${workspaces.length - ok - unchanged} workspace(s) wait for the next pass`);
34877
+ reclaimCgroup();
34878
+ daemonLog.info(`code intelligence: paused at the memory bound (used=${used}MB \u2265 ${rssLimit}MB) \u2014 ${workspaces.length - ok - unchanged} workspace(s) wait for the next pass`);
34826
34879
  break;
34827
34880
  }
34828
34881
  const fp = workspaceFingerprint(ws, COLLECTOR_VERSION2);
@@ -34850,8 +34903,11 @@ async function codeIndexTick() {
34850
34903
  noteIndexed(ws, Date.now(), fp);
34851
34904
  ok++;
34852
34905
  releaseMemory();
34906
+ reclaimCgroup();
34853
34907
  }
34854
34908
  if (ok > 0 || unchanged > 0) daemonLog.info(`code intelligence: indexed ${ok}/${workspaces.length} workspace(s), ${unchanged} unchanged`);
34909
+ releaseMemory();
34910
+ reclaimCgroup();
34855
34911
  } finally {
34856
34912
  codeIndexInFlight = false;
34857
34913
  }
@@ -34946,8 +35002,8 @@ var init_indexer = __esm({
34946
35002
  PI_SESSION_DIRS = piBackend.sessionDirs();
34947
35003
  OPENCODE_DB_PATH = opencodeBackend.dbPath();
34948
35004
  OPENCODE_DB_DIR = dirname25(OPENCODE_DB_PATH);
34949
- CURRENT_RESUME_PATH = join59(claudeBackend.homeDir(), "current-resume");
34950
- LAST_CLEANUP_PATH = join59(claudeBackend.homeDir(), ".last-cleanup");
35005
+ CURRENT_RESUME_PATH = join60(claudeBackend.homeDir(), "current-resume");
35006
+ LAST_CLEANUP_PATH = join60(claudeBackend.homeDir(), ".last-cleanup");
34951
35007
  debounceTimer = null;
34952
35008
  ticks = new TickQueue({
34953
35009
  onError: (kind, err) => daemonLog.error(`${kind} tick failed: ${err instanceof Error ? err.message : err}`)
@@ -35112,7 +35168,7 @@ var init_indexer = __esm({
35112
35168
  daemonLog.info(`running bundle ${BOOT_CODE.path} (${BOOT_CODE.size} bytes)`);
35113
35169
  }
35114
35170
  {
35115
- const r = rotateLogIfLarge(join59(getDataDir(), "watch.log"));
35171
+ const r = rotateLogIfLarge(join60(getDataDir(), "watch.log"));
35116
35172
  if (r.rotated) {
35117
35173
  daemonLog.info(`rotated watch.log at ${(r.sizeBefore / 1048576).toFixed(0)}MB \u2192 watch.log.1 (copy+truncate; the path is preserved)`);
35118
35174
  }