context-mode 2.0.1 → 2.1.0

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/pi/index.js CHANGED
@@ -11571,7 +11571,7 @@ var DECISION_OPTION_KEY = "option";
11571
11571
  var DECISION_LABEL_JOIN = " | ";
11572
11572
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11573
11573
  var RELEASE_BRANCH = "release";
11574
- var BUNDLE_SHA = true ? "22367bce5f9db0a23a18cddba4d6e98c5250da10" : void 0;
11574
+ var BUNDLE_SHA = true ? "d232ce4ddfb581a63a4c0d6ef894b64a0f8464f6" : void 0;
11575
11575
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11576
11576
  var DOCTOR_LABEL = Object.freeze({
11577
11577
  D1: "version",
@@ -11835,6 +11835,7 @@ var REGEX_SPECIAL_CHARS = ".*+?^${}()|[]\\";
11835
11835
  var REGEX_ESCAPE = "\\";
11836
11836
  var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
11837
11837
  var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
11838
+ var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
11838
11839
  function D5_SLOW_DETAIL(ms) {
11839
11840
  return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
11840
11841
  }
@@ -11864,8 +11865,8 @@ var UPGRADE_DATA_DELETED = "user data deleted";
11864
11865
  var UPGRADE_HOST_COMMAND = Object.freeze({
11865
11866
  "claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
11866
11867
  codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
11867
- gemini: "gemini extensions install https://github.com/mksglu/context-mode --ref release --auto-update",
11868
- qwen: "qwen extensions install https://github.com/mksglu/context-mode --ref release --auto-update"
11868
+ gemini: "gemini extensions install https://github.com/mksglu/context-mode --auto-update",
11869
+ qwen: "qwen extensions install https://github.com/mksglu/context-mode --auto-update"
11869
11870
  });
11870
11871
  var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
11871
11872
  var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
@@ -11929,6 +11930,9 @@ var HOOKS_KEY = "hooks";
11929
11930
  var STATUS_LINE_KEY = "statusLine";
11930
11931
  var PI_PACKAGES_KEY = "packages";
11931
11932
  var OPENCODE_PLUGIN_KEY = "plugin";
11933
+ var OPENCODE_PLUGINS_KEY = "plugins";
11934
+ var OPENCODE_PACKAGE_FIELD = "package";
11935
+ var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
11932
11936
  var V1_DATA_DIR_NAME = "context-mode";
11933
11937
  var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
11934
11938
  var V1_SESSIONS_DIR_NAME = "sessions";
@@ -12026,6 +12030,7 @@ var DOCTOR_REPORT_FILE_PREFIX = "doctor-";
12026
12030
  var DOCTOR_REPORT_LINE = "Report file: ";
12027
12031
  var DOCTOR_GH_LINE = "File it: ";
12028
12032
  var DOCTOR_URL_LINE = "Or open: ";
12033
+ var DOCTOR_RULES_LINE = "Rules: ";
12029
12034
  var DOCTOR_GH_NEXT = " --";
12030
12035
  var DOCTOR_NOTE_PREFIXES = Object.freeze([
12031
12036
  DOCTOR_ENV_PREFIX,
@@ -12033,10 +12038,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
12033
12038
  DOCTOR_REPORT_LINE,
12034
12039
  DOCTOR_GH_LINE,
12035
12040
  DOCTOR_GH_NEXT.trim(),
12036
- DOCTOR_URL_LINE
12041
+ DOCTOR_URL_LINE,
12042
+ DOCTOR_RULES_LINE
12037
12043
  ]);
12038
12044
  var ISSUE_REPO_SLUG = "mksglu/context-mode";
12039
12045
  var ISSUE_FORM_FILE = "agent-report.yml";
12046
+ var ISSUE_GUIDE_URL = `https://github.com/${ISSUE_REPO_SLUG}/blob/main/.github/AGENT_ISSUE.md`;
12047
+ var ISSUE_AGENT_RULES = Object.freeze([
12048
+ 'Search for the same problem first: `gh issue list -R mksglu/context-mode --state all --search "<check id or error>"`. When one matches, add your facts there as a comment.',
12049
+ "File one bug per issue.",
12050
+ "Call the `ctx_doctor` tool and paste its full output unchanged in the `ctx-report` field.",
12051
+ "Give the versions: context-mode, the agent, the OS and arch, and Node.",
12052
+ "Write numbered repro steps that start from a fresh project (`mktemp -d`) and the agent's own install command.",
12053
+ "Give the exact command and its exact output in a fenced code block.",
12054
+ "Say what you expected and what happened instead.",
12055
+ "Name the source file and line when you found the cause.",
12056
+ "Replace every secret with `<masked>` and the home folder with `~` before you send."
12057
+ ]);
12040
12058
  var ISSUE_URL_MAX = 8e3;
12041
12059
  var ISSUE_FORM_HEADINGS = Object.freeze([
12042
12060
  "Summary",
@@ -12067,16 +12085,16 @@ var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
12067
12085
  var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
12068
12086
  var DOCTOR_MASK = "<masked>";
12069
12087
  var NATIVE_INSTALL = Object.freeze({
12070
- "claude-code": ["claude plugin marketplace add mksglu/context-mode#release", "claude plugin install context-mode@context-mode"],
12071
- codex: ["codex plugin marketplace add mksglu/context-mode@release", "codex plugin add context-mode@context-mode"],
12072
- gemini: ["gemini extensions install https://github.com/mksglu/context-mode --ref release"],
12073
- qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode --ref release"],
12074
- opencode: ["opencode plugin add context-mode@next"],
12075
- pi: ["pi install npm:context-mode@next"],
12076
- "copilot-cli": ["npm i -g context-mode@next", "context-mode setup --agents copilot-cli"],
12077
- vscode: ["npm i -g context-mode@next", "context-mode setup --agents vscode"],
12078
- kiro: ["npm i -g context-mode@next", "context-mode setup --agents kiro"],
12079
- zcode: ["npm i -g context-mode@next", "context-mode setup --agents zcode"]
12088
+ "claude-code": ["claude plugin marketplace add mksglu/context-mode", "claude plugin install context-mode@context-mode"],
12089
+ codex: ["codex plugin marketplace add mksglu/context-mode", "codex plugin add context-mode@context-mode"],
12090
+ gemini: ["gemini extensions install https://github.com/mksglu/context-mode"],
12091
+ qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
12092
+ opencode: ["opencode plugin add context-mode"],
12093
+ pi: ["pi install npm:context-mode"],
12094
+ "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
12095
+ vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
12096
+ kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
12097
+ zcode: ["npm i -g context-mode", "context-mode setup --agents zcode"]
12080
12098
  });
12081
12099
  var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
12082
12100
  var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
@@ -12246,9 +12264,28 @@ function outputOf(resp) {
12246
12264
  return err === "" ? out : out === "" ? err : out + "\n" + err;
12247
12265
  }
12248
12266
  }
12249
- if (typeof resp === "object" && resp !== null && isGrepContent(resp)) return resp.content;
12267
+ if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
12268
+ const slot = textSlot(resp);
12269
+ if (slot !== null) return slot.text;
12270
+ }
12250
12271
  return JSON.stringify(resp);
12251
12272
  }
12273
+ function textSlot(r) {
12274
+ const file2 = r.file;
12275
+ if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
12276
+ return { text: file2.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
12277
+ }
12278
+ if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
12279
+ if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
12280
+ return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
12281
+ }
12282
+ if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
12283
+ return null;
12284
+ }
12285
+ function isShellShape(resp) {
12286
+ const r = resp;
12287
+ return typeof r.stdout === "string" || typeof r.stderr === "string";
12288
+ }
12252
12289
  function isGrepContent(resp) {
12253
12290
  const r = resp;
12254
12291
  return r.mode === "content" && typeof r.content === "string";
@@ -12267,7 +12304,10 @@ function readResult2(resp) {
12267
12304
  const text = outputOf(resp);
12268
12305
  const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
12269
12306
  const info = { isError, bytes: Buffer.byteLength(text), text };
12270
- if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && isGrepContent(resp)) info.shape = resp;
12307
+ if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
12308
+ if (textSlot(resp) !== null) info.shape = resp;
12309
+ else info.keep = true;
12310
+ }
12271
12311
  if (Array.isArray(resp)) {
12272
12312
  info.blocks = true;
12273
12313
  if (blocksOf(resp).keep) info.keep = true;
@@ -12304,7 +12344,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
12304
12344
  }
12305
12345
  function replaceShape(ev, output) {
12306
12346
  if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
12307
- if (ev.result?.shape !== void 0) return { ...ev.result.shape, content: output };
12347
+ const shape = ev.result?.shape;
12348
+ const slot = shape === void 0 ? null : textSlot(shape);
12349
+ if (shape !== void 0 && slot !== null) return slot.put(shape, output);
12308
12350
  if (ev.result?.blocks === true) return [{ type: "text", text: output }];
12309
12351
  return output;
12310
12352
  }
@@ -12697,7 +12739,8 @@ function encode7(ev, d, _extra) {
12697
12739
  }
12698
12740
 
12699
12741
  // src/adapters/kiro.ts
12700
- var TOOL_NAME_PREFIX8 = "mcp_context-mode_";
12742
+ var TOOL_NAME_PREFIX8 = "mcp_context_mode_";
12743
+ var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
12701
12744
  var KIRO_EVENTS = {
12702
12745
  SessionStart: "SessionStart",
12703
12746
  agentSpawn: "SessionStart",
@@ -12709,6 +12752,7 @@ var KIRO_EVENTS = {
12709
12752
  PostToolUse: "PostToolUse",
12710
12753
  postToolUse: "PostToolUse"
12711
12754
  };
12755
+ var PROMPT_FIELD = "prompt";
12712
12756
  var PROMPT_ENV = "USER_PROMPT";
12713
12757
  var MCP_PREFIX3 = "mcp_";
12714
12758
  var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
@@ -12717,6 +12761,7 @@ var MCP_SEP3 = "_";
12717
12761
  var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
12718
12762
  function canonicalName5(name) {
12719
12763
  if (name.startsWith(TOOL_NAME_PREFIX8)) return name.slice(TOOL_NAME_PREFIX8.length);
12764
+ if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
12720
12765
  if (Object.hasOwn(NATIVE_TO_CANONICAL6, name)) return NATIVE_TO_CANONICAL6[name];
12721
12766
  if (!name.startsWith(MCP_PREFIX3)) return name;
12722
12767
  const rest = name.slice(MCP_PREFIX3.length);
@@ -12737,7 +12782,8 @@ function decode8(raw) {
12737
12782
  const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
12738
12783
  if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
12739
12784
  if (event === "UserPromptSubmit") {
12740
- const prompt = process.env[PROMPT_ENV];
12785
+ const field = p[PROMPT_FIELD];
12786
+ const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
12741
12787
  if (prompt !== void 0) ev.prompt = prompt;
12742
12788
  }
12743
12789
  if (event === "PreToolUse" || event === "PostToolUse") {
@@ -12749,7 +12795,7 @@ function decode8(raw) {
12749
12795
  return ev;
12750
12796
  }
12751
12797
  function encode8(ev, d, _extra) {
12752
- if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
12798
+ if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
12753
12799
  switch (d.kind) {
12754
12800
  case "allow":
12755
12801
  return { stdout: "", exitCode: 0 };
@@ -13050,7 +13096,7 @@ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "
13050
13096
  function dumpRunsThenReplaces(row5) {
13051
13097
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
13052
13098
  }
13053
- var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode"]);
13099
+ var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode", "kiro"]);
13054
13100
  function hasRecall(row5) {
13055
13101
  return RECALL_ROWS.has(row5.id);
13056
13102
  }
@@ -14401,14 +14447,29 @@ function copilotDirOf(env, home) {
14401
14447
  function kiroDirOf(env, home, platform = process.platform) {
14402
14448
  const p = platform === "win32" ? win32 : posix;
14403
14449
  const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
14404
- const dir = env[KIRO_HOME_ENV];
14450
+ const dir = env[KIRO_HOME_ENV]?.trim();
14405
14451
  if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
14406
14452
  if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
14407
14453
  const abs = p.resolve(dir);
14408
- if (p.dirname(abs) === abs) return fallback;
14409
- const up = p.relative(abs, p.resolve(home));
14454
+ const real2 = platform === process.platform ? realOrSelf : (x) => x;
14455
+ const target = real2(abs);
14456
+ if (p.parse(target).root === target) return fallback;
14457
+ const up = p.relative(target, real2(p.resolve(home)));
14410
14458
  if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
14411
- return dir;
14459
+ return abs;
14460
+ }
14461
+ function realOrSelf(path7) {
14462
+ const tail = [];
14463
+ for (let at2 = path7; ; ) {
14464
+ try {
14465
+ return join(realpathSync.native(at2), ...tail.reverse());
14466
+ } catch {
14467
+ const up = dirname(at2);
14468
+ if (up === at2) return path7;
14469
+ tail.push(basename(at2));
14470
+ at2 = up;
14471
+ }
14472
+ }
14412
14473
  }
14413
14474
  function claudeDirOf(env, home) {
14414
14475
  const dir = env[CLAUDE_CONFIG_DIR_ENV];
@@ -18978,7 +19039,7 @@ function cutPoint(src, start, end, scratch) {
18978
19039
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
18979
19040
  return { end: start + r.read, written: r.written };
18980
19041
  }
18981
- function merge2(src, blocks, join28, cap, lineCut) {
19042
+ function merge2(src, blocks, join29, cap, lineCut) {
18982
19043
  const out = [];
18983
19044
  const scratch = new Uint8Array(cap);
18984
19045
  let wide;
@@ -18988,7 +19049,7 @@ function merge2(src, blocks, join28, cap, lineCut) {
18988
19049
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
18989
19050
  };
18990
19051
  for (const b of blocks) {
18991
- if (cur !== void 0 && !join28) {
19052
+ if (cur !== void 0 && !join29) {
18992
19053
  emit(cur.start, cur.end, curBytes);
18993
19054
  cur = void 0;
18994
19055
  }
@@ -20843,21 +20904,43 @@ var ctxBatch = Object.freeze({
20843
20904
  });
20844
20905
 
20845
20906
  // src/core/tools/doctor.ts
20846
- import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync13 } from "node:fs";
20847
- import { basename as basename5, dirname as dirname8, join as join16 } from "node:path";
20907
+ import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync14 } from "node:fs";
20908
+ import { basename as basename5, join as join17 } from "node:path";
20909
+
20910
+ // src/core/ops/bundle-dir.ts
20911
+ import { existsSync as existsSync3 } from "node:fs";
20912
+ import { dirname as dirname5, join as join8 } from "node:path";
20913
+ import { fileURLToPath } from "node:url";
20914
+ function bundleDirOf(argv1, moduleFile) {
20915
+ const own4 = dirname5(argv1);
20916
+ if (existsSync3(join8(own4, SERVER_ENTRY_FILE))) return own4;
20917
+ let dir = dirname5(moduleFile);
20918
+ for (; ; ) {
20919
+ if (existsSync3(join8(dir, SERVER_ENTRY_FILE))) return dir;
20920
+ const up = dirname5(dir);
20921
+ if (up === dir) return own4;
20922
+ dir = up;
20923
+ }
20924
+ }
20925
+ var memo;
20926
+ function ownBundleDir() {
20927
+ const argv1 = process.argv[1] ?? "";
20928
+ if (memo?.argv1 !== argv1) memo = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
20929
+ return memo.dir;
20930
+ }
20848
20931
 
20849
20932
  // src/core/ops/doctor-config.ts
20850
- import { existsSync as existsSync6, readdirSync as readdirSync4 } from "node:fs";
20851
- import { join as join11 } from "node:path";
20933
+ import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
20934
+ import { join as join12 } from "node:path";
20852
20935
 
20853
20936
  // src/core/ops/detect-v1.ts
20854
- import { existsSync as existsSync4, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20937
+ import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20855
20938
  import { tmpdir } from "node:os";
20856
- import { join as join9 } from "node:path";
20939
+ import { join as join10 } from "node:path";
20857
20940
 
20858
20941
  // src/core/ops/host-config.ts
20859
- import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
20860
- import { dirname as dirname5, join as join8 } from "node:path";
20942
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
20943
+ import { dirname as dirname6, join as join9 } from "node:path";
20861
20944
 
20862
20945
  // node_modules/eslint-visitor-keys/lib/visitor-keys.js
20863
20946
  var KEYS2 = {
@@ -22974,10 +23057,10 @@ function formatOf(path7) {
22974
23057
  function readHostConfig(agent, path7) {
22975
23058
  let file2 = path7;
22976
23059
  if (agent === "opencode") {
22977
- const jsonc = join8(dirname5(path7), OPENCODE_CONFIG_FILES[0]);
22978
- if (existsSync3(jsonc)) file2 = jsonc;
23060
+ const jsonc = join9(dirname6(path7), OPENCODE_CONFIG_FILES[0]);
23061
+ if (existsSync4(jsonc)) file2 = jsonc;
22979
23062
  }
22980
- const raw = existsSync3(file2) ? readFileSync6(file2, "utf8") : "";
23063
+ const raw = existsSync4(file2) ? readFileSync6(file2, "utf8") : "";
22981
23064
  return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
22982
23065
  }
22983
23066
  function stripJsonComments(text) {
@@ -23322,7 +23405,7 @@ function setText(agent, path7, text, format, key, value) {
23322
23405
  }
23323
23406
  }
23324
23407
  function serverScript() {
23325
- return join8(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23408
+ return join9(dirname6(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23326
23409
  }
23327
23410
  function isNodeCommand(command) {
23328
23411
  if (typeof command !== "string") return false;
@@ -23338,7 +23421,7 @@ function ownMcpValue(agent, node3, server) {
23338
23421
  return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
23339
23422
  }
23340
23423
  function opencodePluginFile() {
23341
- return dirname5(process.argv[1] ?? "");
23424
+ return ownBundleDir();
23342
23425
  }
23343
23426
  function listTarget(key, own4, v1, alt = []) {
23344
23427
  return {
@@ -23497,7 +23580,7 @@ function flatCommands(events, prefix) {
23497
23580
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
23498
23581
  var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep4) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep4) + sep4));
23499
23582
  function dataDir(dir, reason, out) {
23500
- if (existsSync4(dir)) out.push(finding(dir, "", reason));
23583
+ if (existsSync5(dir)) out.push(finding(dir, "", reason));
23501
23584
  }
23502
23585
  function mcpEntry(file2, doc, out) {
23503
23586
  if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
@@ -23505,7 +23588,7 @@ function mcpEntry(file2, doc, out) {
23505
23588
  }
23506
23589
  }
23507
23590
  function claudeShapeSettings(agentHome, out) {
23508
- const file2 = join9(agentHome, SETTINGS_FILE);
23591
+ const file2 = join10(agentHome, SETTINGS_FILE);
23509
23592
  const doc = readJson(file2);
23510
23593
  for (const c of nestedCommands(doc)) {
23511
23594
  if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
@@ -23525,49 +23608,49 @@ function v1HookFile(file2, out) {
23525
23608
  function scanClaudeCode(home, agentHome, out) {
23526
23609
  claudeShapeSettings(agentHome, out);
23527
23610
  for (const ext of V1_CACHE_HEAL_EXTS) {
23528
- const file2 = join9(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23529
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23611
+ const file2 = join10(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23612
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23530
23613
  }
23531
- const userFile = join9(home, CLAUDE_USER_CONFIG_FILE);
23614
+ const userFile = join10(home, CLAUDE_USER_CONFIG_FILE);
23532
23615
  mcpEntry(userFile, readJson(userFile), out);
23533
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23616
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23534
23617
  }
23535
23618
  function scanCodex(agentHome, out) {
23536
- const hooksFile = join9(agentHome, HOOKS_JSON_FILE);
23619
+ const hooksFile = join10(agentHome, HOOKS_JSON_FILE);
23537
23620
  for (const c of nestedCommands(readJson(hooksFile))) {
23538
23621
  if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
23539
23622
  out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
23540
23623
  }
23541
23624
  }
23542
- const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
23625
+ const tomlFile = join10(agentHome, CONFIG_TOML_FILE);
23543
23626
  const config4 = readTomlValue(tomlFile);
23544
23627
  for (const span2 of readTomlTables(tomlFile)) {
23545
23628
  if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
23546
23629
  if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
23547
23630
  out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
23548
23631
  }
23549
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23632
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23550
23633
  }
23551
23634
  function scanGemini(agentHome, out) {
23552
- const file2 = join9(agentHome, SETTINGS_FILE);
23635
+ const file2 = join10(agentHome, SETTINGS_FILE);
23553
23636
  for (const c of nestedCommands(readJson(file2))) {
23554
23637
  if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
23555
23638
  }
23556
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23639
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23557
23640
  }
23558
23641
  function scanVscode(agentHome, project, out) {
23559
23642
  if (project !== void 0) {
23560
- v1HookFile(join9(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23561
- const mcpFile2 = join9(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23643
+ v1HookFile(join10(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23644
+ const mcpFile2 = join10(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23562
23645
  const doc = readJson(mcpFile2);
23563
23646
  const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
23564
23647
  const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
23565
23648
  if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
23566
23649
  out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
23567
23650
  }
23568
- dataDir(join9(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23651
+ dataDir(join10(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23569
23652
  }
23570
- dataDir(join9(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23653
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23571
23654
  }
23572
23655
  function jsonFiles(dir) {
23573
23656
  try {
@@ -23577,10 +23660,10 @@ function jsonFiles(dir) {
23577
23660
  }
23578
23661
  }
23579
23662
  function scanKiro(agentHome, project, out) {
23580
- const agentsDir = join9(agentHome, KIRO_AGENTS_DIR);
23581
- const defaultFile = join9(agentHome, ...KIRO_AGENT_FILE);
23663
+ const agentsDir = join10(agentHome, KIRO_AGENTS_DIR);
23664
+ const defaultFile = join10(agentHome, ...KIRO_AGENT_FILE);
23582
23665
  for (const name of jsonFiles(agentsDir)) {
23583
- const file2 = join9(agentsDir, name);
23666
+ const file2 = join10(agentsDir, name);
23584
23667
  const doc = readJson(file2);
23585
23668
  if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
23586
23669
  out.push(finding(file2, "", V1_REASON.kiroAgentFile));
@@ -23591,25 +23674,25 @@ function scanKiro(agentHome, project, out) {
23591
23674
  if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
23592
23675
  }
23593
23676
  }
23594
- const steeringDocs = [join9(agentHome, ...KIRO_STEERING_FILE)];
23595
- if (project !== void 0) steeringDocs.push(join9(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23677
+ const steeringDocs = [join10(agentHome, ...KIRO_STEERING_FILE)];
23678
+ if (project !== void 0) steeringDocs.push(join10(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23596
23679
  for (const file2 of steeringDocs) {
23597
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23680
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23598
23681
  }
23599
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23682
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23600
23683
  }
23601
23684
  function scanPi(piAgentDir, agentHome, out) {
23602
- const file2 = join9(piAgentDir, SETTINGS_FILE);
23685
+ const file2 = join10(piAgentDir, SETTINGS_FILE);
23603
23686
  const doc = readJson(file2);
23604
23687
  listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
23605
23688
  const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
23606
23689
  if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
23607
23690
  });
23608
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23691
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23609
23692
  }
23610
23693
  function scanOpencode(agentHome, out) {
23611
23694
  for (const name of OPENCODE_CONFIG_FILES) {
23612
- const file2 = join9(agentHome, name);
23695
+ const file2 = join10(agentHome, name);
23613
23696
  const doc = readJson(file2);
23614
23697
  if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
23615
23698
  doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
@@ -23619,13 +23702,13 @@ function scanOpencode(agentHome, out) {
23619
23702
  }
23620
23703
  }
23621
23704
  function scanZcode(agentHome, out) {
23622
- const configFile = join9(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23705
+ const configFile = join10(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23623
23706
  const config4 = readJson(configFile);
23624
23707
  const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
23625
23708
  for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
23626
23709
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
23627
23710
  }
23628
- const hooksFile = join9(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23711
+ const hooksFile = join10(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23629
23712
  for (const c of nestedCommands(readJson(hooksFile))) {
23630
23713
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
23631
23714
  }
@@ -23649,14 +23732,14 @@ function firstTmpMatch(dir) {
23649
23732
  }
23650
23733
  }
23651
23734
  function scanAll(home, tmp, out) {
23652
- const root = join9(home, DATA_ROOT.slice(1));
23653
- for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join9(root, name), V1_REASON.dataRoot, out);
23735
+ const root = join10(home, DATA_ROOT.slice(1));
23736
+ for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join10(root, name), V1_REASON.dataRoot, out);
23654
23737
  if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
23655
23738
  }
23656
23739
  function detectV1(agent, home, scope = {}) {
23657
23740
  const out = [];
23658
23741
  const project = scope.project;
23659
- const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
23742
+ const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join10(home, ...AGENT_HOME_DIR[agent]);
23660
23743
  switch (agent) {
23661
23744
  case "claude-code":
23662
23745
  scanClaudeCode(home, agentHome, out);
@@ -23669,11 +23752,11 @@ function detectV1(agent, home, scope = {}) {
23669
23752
  break;
23670
23753
  case "qwen":
23671
23754
  claudeShapeSettings(agentHome, out);
23672
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23755
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23673
23756
  break;
23674
23757
  case "copilot-cli":
23675
- v1HookFile(join9(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23676
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23758
+ v1HookFile(join10(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23759
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23677
23760
  break;
23678
23761
  case "vscode":
23679
23762
  scanVscode(agentHome, project, out);
@@ -23682,7 +23765,7 @@ function detectV1(agent, home, scope = {}) {
23682
23765
  scanKiro(agentHome, project, out);
23683
23766
  break;
23684
23767
  case "pi":
23685
- scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join9(agentHome, PI_AGENT_DIR), agentHome, out);
23768
+ scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join10(agentHome, PI_AGENT_DIR), agentHome, out);
23686
23769
  break;
23687
23770
  // D-WIN-PIDIR-1: empty is unset
23688
23771
  case "opencode":
@@ -23697,9 +23780,9 @@ function detectV1(agent, home, scope = {}) {
23697
23780
  }
23698
23781
 
23699
23782
  // src/core/ops/plugin-root.ts
23700
- import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23701
- import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep3 } from "node:path";
23702
- import { fileURLToPath } from "node:url";
23783
+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23784
+ import { dirname as dirname7, isAbsolute as isAbsolute2, join as join11, sep as sep3 } from "node:path";
23785
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
23703
23786
  function missing(agent, path7) {
23704
23787
  return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path7 });
23705
23788
  }
@@ -23746,8 +23829,8 @@ var readOrNull = (file2) => {
23746
23829
  };
23747
23830
  var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
23748
23831
  function enabledPlugins(claudeDir, project) {
23749
- const files = [join10(claudeDir, SETTINGS_FILE)];
23750
- if (project !== void 0) files.push(join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23832
+ const files = [join11(claudeDir, SETTINGS_FILE)];
23833
+ if (project !== void 0) files.push(join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23751
23834
  const out = {};
23752
23835
  for (const file2 of files) {
23753
23836
  const text = readOrNull(file2);
@@ -23760,13 +23843,13 @@ function enabledPlugins(claudeDir, project) {
23760
23843
  function marketplaceChoice(env, worktree) {
23761
23844
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23762
23845
  const script = process.argv[1];
23763
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23846
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23764
23847
  const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
23765
23848
  if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
23766
- const record6 = readOrNull(join10(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23849
+ const record6 = readOrNull(join11(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23767
23850
  const recorded = record6 === null ? [] : recordedInstalls(record6);
23768
23851
  if (recorded.length === 0) return { record: false };
23769
- const live = recorded.filter((r) => existsSync5(r.installPath));
23852
+ const live = recorded.filter((r) => existsSync6(r.installPath));
23770
23853
  const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
23771
23854
  if (mine !== void 0) return { root: mine.installPath };
23772
23855
  const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
@@ -23786,18 +23869,18 @@ function marketplaceChoice(env, worktree) {
23786
23869
  }
23787
23870
  function marketplaceRoot(adapter, env, worktree) {
23788
23871
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23789
- const plugins = join10(claudeDir, HOST_PLUGINS_DIR_NAME);
23790
- const cache = join10(plugins, PLUGIN_CACHE_DIR_NAME);
23872
+ const plugins = join11(claudeDir, HOST_PLUGINS_DIR_NAME);
23873
+ const cache = join11(plugins, PLUGIN_CACHE_DIR_NAME);
23791
23874
  const script = process.argv[1];
23792
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23875
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23793
23876
  const choice = marketplaceChoice(env, worktree);
23794
23877
  if ("root" in choice) return choice.root;
23795
23878
  if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
23796
23879
  const cacheReal = realOrNull(cache);
23797
- if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync5(join10(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23798
- const pattern = join10(cache, "*", PLUGIN_NAME);
23799
- if (!existsSync5(cache)) throw missing(adapter.id, pattern);
23800
- const found = readdirSync3(cache).sort().map((marketplace) => join10(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync5(dir));
23880
+ if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync6(join11(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23881
+ const pattern = join11(cache, "*", PLUGIN_NAME);
23882
+ if (!existsSync6(cache)) throw missing(adapter.id, pattern);
23883
+ const found = readdirSync3(cache).sort().map((marketplace) => join11(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
23801
23884
  if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
23802
23885
  return found[0];
23803
23886
  }
@@ -23805,13 +23888,13 @@ function configEntryRoot(adapter, env) {
23805
23888
  const spec = OWN_MCP_ENTRY[adapter.id];
23806
23889
  if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
23807
23890
  const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
23808
- if (!existsSync5(file2)) throw missing(adapter.id, file2);
23891
+ if (!existsSync6(file2)) throw missing(adapter.id, file2);
23809
23892
  const current = readHostConfig(adapter.id, file2);
23810
23893
  const value = parseHostConfig(adapter.id, file2, current.text, current.format);
23811
23894
  const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
23812
23895
  const script = Array.isArray(args) ? args[0] : void 0;
23813
23896
  if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
23814
- return dirname6(script);
23897
+ return dirname7(script);
23815
23898
  }
23816
23899
  function candidate(adapter, env, worktree) {
23817
23900
  switch (adapter.installMode) {
@@ -23822,11 +23905,11 @@ function candidate(adapter, env, worktree) {
23822
23905
  case "hooks+mcp":
23823
23906
  return configEntryRoot(adapter, env);
23824
23907
  case "extension":
23825
- return join10(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23908
+ return join11(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23826
23909
  case "plugin":
23827
- return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23910
+ return join11(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23828
23911
  case "in-process":
23829
- return dirname6(fileURLToPath(import.meta.url));
23912
+ return dirname7(fileURLToPath2(import.meta.url));
23830
23913
  }
23831
23914
  }
23832
23915
  function resolvePluginRoot(adapter, env, worktree) {
@@ -23915,11 +23998,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
23915
23998
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
23916
23999
  function mcpFile(row5, home, env) {
23917
24000
  const spec = OWN_MCP_ENTRY[row5.id];
23918
- if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
24001
+ if (row5.id === "codex") return join12(codexDirOf(env, home), CONFIG_TOML_FILE);
23919
24002
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
23920
- if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
24003
+ if (row5.id === "opencode") return join12(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
23921
24004
  if (row5.id === "pi") {
23922
- return join11(piAgentDirOf(env, home), SETTINGS_FILE);
24005
+ return join12(piAgentDirOf(env, home), SETTINGS_FILE);
23923
24006
  }
23924
24007
  return null;
23925
24008
  }
@@ -23932,27 +24015,27 @@ function codexNativeDir(env, home) {
23932
24015
  const codexDir = codexDirOf(env, home);
23933
24016
  let enabled;
23934
24017
  try {
23935
- enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24018
+ enabled = hostConfigValueAt(readParsed("codex", join12(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
23936
24019
  } catch {
23937
24020
  return null;
23938
24021
  }
23939
24022
  if (enabled !== true) return null;
23940
- const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
23941
- if (!existsSync6(cache)) return null;
24023
+ const cache = join12(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24024
+ if (!existsSync7(cache)) return null;
23942
24025
  const found = [];
23943
24026
  for (const market of readdirSync4(cache)) {
23944
- const plugin = join11(cache, market, SERVER_KEY);
23945
- if (!existsSync6(plugin)) continue;
24027
+ const plugin = join12(cache, market, SERVER_KEY);
24028
+ if (!existsSync7(plugin)) continue;
23946
24029
  for (const version4 of readdirSync4(plugin).sort()) {
23947
- const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
23948
- if (existsSync6(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24030
+ const dir = join12(plugin, version4, CODEX_PLUGIN_SUBDIR);
24031
+ if (existsSync7(join12(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
23949
24032
  }
23950
24033
  }
23951
24034
  return found.length === 0 ? null : found[found.length - 1];
23952
24035
  }
23953
24036
  function nativeMcpWrong(dir, row5) {
23954
24037
  try {
23955
- const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24038
+ const entry = hostConfigValueAt(readParsed(row5.id, join12(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
23956
24039
  if (!isObject4(entry)) return true;
23957
24040
  const args = list2(entry[MCP_ARGS_FIELD]);
23958
24041
  const script = args[0];
@@ -23961,6 +24044,17 @@ function nativeMcpWrong(dir, row5) {
23961
24044
  return true;
23962
24045
  }
23963
24046
  }
24047
+ function isOwnOpencodeEntry(entry, key, own4) {
24048
+ const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
24049
+ if (typeof spec !== "string") return false;
24050
+ if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
24051
+ return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
24052
+ }
24053
+ function opencodeListed(file2) {
24054
+ const { value } = readParsed("opencode", file2);
24055
+ const own4 = [opencodePluginFile()];
24056
+ return [OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)));
24057
+ }
23964
24058
  function mcpWrong(row5, home, env, worktree) {
23965
24059
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
23966
24060
  if (native !== null) return nativeMcpWrong(native, row5);
@@ -23970,6 +24064,7 @@ function mcpWrong(row5, home, env, worktree) {
23970
24064
  resolvePluginRoot(row5, env, worktree);
23971
24065
  return false;
23972
24066
  }
24067
+ if (row5.id === "opencode") return !opencodeListed(file2);
23973
24068
  const cur = readHostConfig(row5.id, file2);
23974
24069
  return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
23975
24070
  } catch {
@@ -23979,7 +24074,7 @@ function mcpWrong(row5, home, env, worktree) {
23979
24074
  function hookFile(row5, spec, home, env, worktree) {
23980
24075
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
23981
24076
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
23982
- const file2 = native !== null ? join11(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join11(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join11(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join11(kiroDirOf(env, home), ...spec.file.slice(1)) : join11(root, ...spec.file);
24077
+ const file2 = native !== null ? join12(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join12(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join12(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join12(kiroDirOf(env, home), ...spec.file.slice(1)) : join12(root, ...spec.file);
23983
24078
  return file2;
23984
24079
  }
23985
24080
  function hookParts(row5, home, env, worktree) {
@@ -23990,7 +24085,7 @@ function hookParts(row5, home, env, worktree) {
23990
24085
  const file2 = hookFile(row5, spec, home, env, worktree);
23991
24086
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
23992
24087
  if (row5.id === "codex") {
23993
- const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24088
+ const config4 = readParsed(row5.id, join12(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
23994
24089
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
23995
24090
  }
23996
24091
  } catch {
@@ -24036,7 +24131,7 @@ function checkV1Leftovers(agent, home, scope = {}) {
24036
24131
  if (findings.length === 0) return pass("D4");
24037
24132
  const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
24038
24133
  if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
24039
- return fail2("D4", detail, DOCTOR_FIX_UPGRADE);
24134
+ return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
24040
24135
  }
24041
24136
  function parsedOrNull(agent, file2, jsonc) {
24042
24137
  try {
@@ -24048,10 +24143,10 @@ function parsedOrNull(agent, file2, jsonc) {
24048
24143
  }
24049
24144
  function checkDoubleFire(agent, worktree) {
24050
24145
  if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
24051
- const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24146
+ const claude = parsedOrNull(agent, join12(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24052
24147
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
24053
24148
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
24054
- const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24149
+ const vscode = parsedOrNull(agent, join12(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24055
24150
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
24056
24151
  return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
24057
24152
  }
@@ -24062,7 +24157,7 @@ function configPaths(row5, env, worktree) {
24062
24157
  const mcp = mcpFile(row5, home, env);
24063
24158
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
24064
24159
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24065
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
24160
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join12(native, CODEX_PLUGIN_MCP_FILE) });
24066
24161
  const spec = HOOK_HOST_FILE[row5.id];
24067
24162
  if (spec !== null) {
24068
24163
  try {
@@ -24082,7 +24177,7 @@ function configPaths(row5, env, worktree) {
24082
24177
  }
24083
24178
 
24084
24179
  // src/core/ops/doctor-db.ts
24085
- import { existsSync as existsSync7, statSync as statSync5 } from "node:fs";
24180
+ import { existsSync as existsSync8, statSync as statSync5 } from "node:fs";
24086
24181
  var unknown2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
24087
24182
  var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
24088
24183
  var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
@@ -24124,15 +24219,15 @@ function orphanFiles(dbPath) {
24124
24219
  const files = [];
24125
24220
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
24126
24221
  const path7 = dbPath + suffix;
24127
- if (existsSync7(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24222
+ if (existsSync8(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24128
24223
  }
24129
- return files.length > 0 && !existsSync7(dbPath) ? files : [];
24224
+ return files.length > 0 && !existsSync8(dbPath) ? files : [];
24130
24225
  }
24131
24226
  async function checkDb(project) {
24132
24227
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
24133
24228
  const orphan = orphanFiles(project.dbPath);
24134
24229
  if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
24135
- if (!existsSync7(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24230
+ if (!existsSync8(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24136
24231
  const sqlite = await loadSqlite2();
24137
24232
  if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
24138
24233
  let raw = null;
@@ -24158,7 +24253,7 @@ async function checkDb(project) {
24158
24253
  }
24159
24254
  }
24160
24255
  async function checkIndex(project) {
24161
- if (!existsSync7(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24256
+ if (!existsSync8(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24162
24257
  const sqlite = await loadSqlite2();
24163
24258
  if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
24164
24259
  let raw = null;
@@ -24175,8 +24270,8 @@ async function checkIndex(project) {
24175
24270
  }
24176
24271
 
24177
24272
  // src/core/ops/doctor-env.ts
24178
- import { existsSync as existsSync8, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24179
- import { isAbsolute as isAbsolute3, join as join12, relative as relative2 } from "node:path";
24273
+ import { existsSync as existsSync9, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24274
+ import { isAbsolute as isAbsolute3, join as join13, relative as relative2 } from "node:path";
24180
24275
  function pass3(id, detail = DOCTOR_PASS_DETAIL) {
24181
24276
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
24182
24277
  }
@@ -24188,7 +24283,7 @@ function fail4(id, detail, fixCommand) {
24188
24283
  }
24189
24284
  function bundleVersion(bundleDir2) {
24190
24285
  try {
24191
- const v = JSON.parse(readFileSync9(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24286
+ const v = JSON.parse(readFileSync9(join13(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24192
24287
  return typeof v === "string" && v !== "" ? v : void 0;
24193
24288
  } catch {
24194
24289
  return void 0;
@@ -24338,7 +24433,7 @@ function checkMcp(ctx) {
24338
24433
  return named2 || versioned ? pass3("D6") : unknown3("D6", D6_UNKNOWN_DETAIL);
24339
24434
  }
24340
24435
  function piCwdInside(worktree, piCwd) {
24341
- if (piCwd === void 0 || !existsSync8(piCwd)) return false;
24436
+ if (piCwd === void 0 || !existsSync9(piCwd)) return false;
24342
24437
  const rel = relative2(worktree, realpathSync5.native(piCwd));
24343
24438
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
24344
24439
  }
@@ -24359,12 +24454,13 @@ function checkShell(env) {
24359
24454
  }
24360
24455
 
24361
24456
  // src/core/ops/doctor-hook.ts
24362
- import { existsSync as existsSync10, readFileSync as readFileSync10, realpathSync as realpathSync7 } from "node:fs";
24457
+ import { existsSync as existsSync11, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24458
+ import { tmpdir as tmpdir2 } from "node:os";
24363
24459
  import path6 from "node:path";
24364
24460
 
24365
24461
  // src/setup/codex-trust.ts
24366
24462
  import { createHash } from "node:crypto";
24367
- import { existsSync as existsSync9, realpathSync as realpathSync6 } from "node:fs";
24463
+ import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
24368
24464
  import path5 from "node:path";
24369
24465
  import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
24370
24466
 
@@ -24462,6 +24558,7 @@ var LIST_TIMEOUT_MS = 15e3;
24462
24558
  var EXIT_GRACE_MS = 5e3;
24463
24559
  var PLUGIN_SOURCE = "plugin";
24464
24560
  var TRUSTED = "trusted";
24561
+ var UNTRUSTED = "untrusted";
24465
24562
  function pluginHooksFromReply(m, pluginId) {
24466
24563
  const out = [];
24467
24564
  if (!isObj2(m) || !isObj2(m.result) || !Array.isArray(m.result.data)) return out;
@@ -24471,7 +24568,8 @@ function pluginHooksFromReply(m, pluginId) {
24471
24568
  if (!isObj2(h) || h.source !== PLUGIN_SOURCE || h.pluginId !== pluginId) continue;
24472
24569
  if (typeof h.key !== "string" || typeof h.currentHash !== "string") continue;
24473
24570
  if (out.some((x) => x.key === h.key)) continue;
24474
- out.push({ key: h.key, hash: h.currentHash, trusted: h.trustStatus === TRUSTED });
24571
+ const status = typeof h.trustStatus === "string" ? h.trustStatus : UNTRUSTED;
24572
+ out.push({ key: h.key, hash: h.currentHash, trusted: status === TRUSTED, status });
24475
24573
  }
24476
24574
  }
24477
24575
  return out;
@@ -24564,7 +24662,11 @@ var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
24564
24662
  function untrustedPluginHooksDetail(hooks) {
24565
24663
  const bad = hooks.filter((h) => !h.trusted);
24566
24664
  if (!bad.length) return void 0;
24567
- return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks untrusted, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24665
+ const counts = /* @__PURE__ */ new Map();
24666
+ for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
24667
+ const words = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
24668
+ const state = words.length === 1 ? words[0][0] : `${words.map(([w]) => w).join(" or ")} (${words.map(([w, n]) => `${n} ${w}`).join(", ")})`;
24669
+ return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24568
24670
  }
24569
24671
 
24570
24672
  // src/core/ops/doctor-hook.ts
@@ -24581,7 +24683,7 @@ function isObject5(v) {
24581
24683
  }
24582
24684
  function loadFixture(bundleDir2, agent) {
24583
24685
  const file2 = path6.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
24584
- if (!existsSync10(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24686
+ if (!existsSync11(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24585
24687
  let all;
24586
24688
  try {
24587
24689
  all = JSON.parse(hostText(readFileSync10(file2, "utf8")));
@@ -24643,6 +24745,50 @@ function isNativeShape(agent, stdout, exitCode, killed, event) {
24643
24745
  return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
24644
24746
  }
24645
24747
  }
24748
+ var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
24749
+ function readProbePayload(cwd) {
24750
+ const content = Array.from({ length: READ_PROBE_LINES }, (_, n) => "d5 read probe line " + n + " ".padEnd(20, "x")).join("\n");
24751
+ const filePath = path6.join(cwd, "d5-read-probe.txt");
24752
+ return {
24753
+ session_id: "d5-read-probe",
24754
+ transcript_path: "",
24755
+ cwd,
24756
+ hook_event_name: "PostToolUse",
24757
+ tool_name: "Read",
24758
+ tool_use_id: "toolu_d5_read_probe",
24759
+ tool_input: { file_path: filePath },
24760
+ tool_response: { type: "text", file: { filePath, content, numLines: READ_PROBE_LINES, startLine: 1, totalLines: READ_PROBE_LINES } }
24761
+ };
24762
+ }
24763
+ function isReadShape(stdout) {
24764
+ if (stdout.trim() === "") return true;
24765
+ let out;
24766
+ try {
24767
+ out = JSON.parse(stdout);
24768
+ } catch {
24769
+ return false;
24770
+ }
24771
+ if (!isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
24772
+ const r = out.hookSpecificOutput.updatedToolOutput;
24773
+ if (!isObject5(r) || r.type !== "text" || !isObject5(r.file)) return false;
24774
+ const f = r.file;
24775
+ return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
24776
+ }
24777
+ async function readProbeOk(i, timeoutMs) {
24778
+ const home = mkdtempSync(path6.join(tmpdir2(), "cm-d5-read-"));
24779
+ try {
24780
+ const r = await runProcess([process.execPath, path6.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
24781
+ cwd: i.bundleDir,
24782
+ env: { ...i.env, HOME: home, USERPROFILE: home },
24783
+ signal: i.signal,
24784
+ timeoutMs,
24785
+ stdin: JSON.stringify(readProbePayload(i.worktree ?? home))
24786
+ });
24787
+ return isReadShape(r.stdout.toString("utf8"));
24788
+ } finally {
24789
+ rmSync2(home, { recursive: true, force: true });
24790
+ }
24791
+ }
24646
24792
  function codexHookJournaled(db) {
24647
24793
  if (db === null) return false;
24648
24794
  return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
@@ -24676,7 +24822,7 @@ async function checkHookRoundTrip(i) {
24676
24822
  const trust = await codexPluginTrust(i);
24677
24823
  if (trust !== null) return trust;
24678
24824
  }
24679
- if (i.agent === "codex" && existsSync10(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24825
+ if (i.agent === "codex" && existsSync11(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24680
24826
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
24681
24827
  }
24682
24828
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -24710,21 +24856,22 @@ async function checkHookRoundTrip(i) {
24710
24856
  if (n >= minPairs && ms <= HOOK_P95_MS) break;
24711
24857
  }
24712
24858
  if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
24859
+ if (i.agent === "claude-code" && !await readProbeOk(i, timeoutMs)) return row("FAIL", D5_READ_SHAPE_DETAIL, D5_FIX);
24713
24860
  return row("PASS", DOCTOR_PASS_DETAIL);
24714
24861
  }
24715
24862
 
24716
24863
  // src/core/ops/db-heal.ts
24717
- import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as rmSync3 } from "node:fs";
24718
- import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
24864
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
24865
+ import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
24719
24866
 
24720
24867
  // src/core/store/owners.ts
24721
- import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
24722
- import { basename as basename3, join as join13 } from "node:path";
24868
+ import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
24869
+ import { basename as basename3, join as join14 } from "node:path";
24723
24870
  function ownersDir(configDir, projectKey) {
24724
- return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24871
+ return join14(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24725
24872
  }
24726
24873
  function ownerFile(configDir, projectKey, serverId) {
24727
- return join13(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
24874
+ return join14(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
24728
24875
  }
24729
24876
  function errCode2(err) {
24730
24877
  return err.code;
@@ -24734,7 +24881,7 @@ function writeOwnerPid(configDir, projectKey, serverId) {
24734
24881
  writeFileSync2(ownerFile(configDir, projectKey, serverId), String(process.pid), "utf8");
24735
24882
  }
24736
24883
  function removeOwnerPid(configDir, projectKey, serverId) {
24737
- rmSync2(ownerFile(configDir, projectKey, serverId), { force: true });
24884
+ rmSync3(ownerFile(configDir, projectKey, serverId), { force: true });
24738
24885
  }
24739
24886
  function isLive(pid) {
24740
24887
  if (!Number.isSafeInteger(pid) || pid <= 0) return false;
@@ -24759,7 +24906,7 @@ function listLiveOwners(configDir, projectKey) {
24759
24906
  const live = [];
24760
24907
  for (const name of names) {
24761
24908
  if (!name.endsWith(OWNER_PID_EXT)) continue;
24762
- const file2 = join13(dir, name);
24909
+ const file2 = join14(dir, name);
24763
24910
  let text;
24764
24911
  try {
24765
24912
  text = readFileSync11(file2, "utf8");
@@ -24769,7 +24916,7 @@ function listLiveOwners(configDir, projectKey) {
24769
24916
  }
24770
24917
  const serverId = basename3(name, OWNER_PID_EXT);
24771
24918
  if (isLive(Number(text.trim()))) live.push(serverId);
24772
- else rmSync2(file2, { force: true });
24919
+ else rmSync3(file2, { force: true });
24773
24920
  }
24774
24921
  return live;
24775
24922
  }
@@ -24781,7 +24928,7 @@ function integrityOk2(rows) {
24781
24928
  async function healLossless(dbPath) {
24782
24929
  const { DatabaseSync } = await import(SQLITE_MODULE);
24783
24930
  const tmp = dbPath + HEAL_TMP_SUFFIX;
24784
- rmSync3(tmp, { force: true });
24931
+ rmSync4(tmp, { force: true });
24785
24932
  try {
24786
24933
  const src = new DatabaseSync(dbPath, { readOnly: true, timeout: DB_TIMEOUT_MS });
24787
24934
  try {
@@ -24797,18 +24944,18 @@ async function healLossless(dbPath) {
24797
24944
  } finally {
24798
24945
  copy.close();
24799
24946
  }
24800
- rmSync3(dbPath + DB_WAL_SUFFIX, { force: true });
24801
- rmSync3(dbPath + DB_SHM_SUFFIX, { force: true });
24947
+ rmSync4(dbPath + DB_WAL_SUFFIX, { force: true });
24948
+ rmSync4(dbPath + DB_SHM_SUFFIX, { force: true });
24802
24949
  renameWithRetry(tmp, dbPath);
24803
24950
  } finally {
24804
- rmSync3(tmp, { force: true });
24951
+ rmSync4(tmp, { force: true });
24805
24952
  }
24806
24953
  }
24807
24954
  function renameAside(dbPath) {
24808
24955
  const ts = String(Date.now());
24809
24956
  for (const suffix of DB_SIBLING_SUFFIXES) {
24810
24957
  const file2 = dbPath + suffix;
24811
- if (existsSync11(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24958
+ if (existsSync12(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24812
24959
  }
24813
24960
  return ts;
24814
24961
  }
@@ -24831,7 +24978,7 @@ function utcStamp(now) {
24831
24978
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
24832
24979
  }
24833
24980
  function makeOrphanDir(projectDir) {
24834
- const base = join14(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24981
+ const base = join15(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24835
24982
  for (let n = 1; ; n += 1) {
24836
24983
  const dir = n === 1 ? base : base + "-" + String(n);
24837
24984
  try {
@@ -24846,9 +24993,9 @@ async function healOrphan(project, files, row5) {
24846
24993
  const moved = [];
24847
24994
  let dir = "";
24848
24995
  try {
24849
- dir = makeOrphanDir(dirname7(project.dbPath));
24996
+ dir = makeOrphanDir(dirname8(project.dbPath));
24850
24997
  for (const f of files) {
24851
- const to = join14(dir, basename4(f.path));
24998
+ const to = join15(dir, basename4(f.path));
24852
24999
  renameWithRetry(f.path, to);
24853
25000
  moved.push({ path: to, bytes: f.bytes });
24854
25001
  }
@@ -24915,8 +25062,8 @@ function buildReportHead(input) {
24915
25062
 
24916
25063
  // src/core/ops/doctor-issue.ts
24917
25064
  import { spawnSync as spawnSync3 } from "node:child_process";
24918
- import { closeSync, existsSync as existsSync12, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
24919
- import { delimiter, join as join15 } from "node:path";
25065
+ import { closeSync, existsSync as existsSync13, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
25066
+ import { delimiter, join as join16 } from "node:path";
24920
25067
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
24921
25068
  function tildeOf(env) {
24922
25069
  const home = homeDirOf(env);
@@ -24957,8 +25104,8 @@ function onPath(env, tool) {
24957
25104
  const out = [];
24958
25105
  for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
24959
25106
  if (dir === "") continue;
24960
- for (const n of names) if (existsSync12(join15(dir, n))) {
24961
- out.push(join15(dir, n));
25107
+ for (const n of names) if (existsSync13(join16(dir, n))) {
25108
+ out.push(join16(dir, n));
24962
25109
  break;
24963
25110
  }
24964
25111
  }
@@ -24966,7 +25113,7 @@ function onPath(env, tool) {
24966
25113
  }
24967
25114
  function hookLogTail(env) {
24968
25115
  const file2 = hookLogPath(env);
24969
- if (file2 === "" || !existsSync12(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25116
+ if (file2 === "" || !existsSync13(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
24970
25117
  try {
24971
25118
  const fd = openSync(file2, "r");
24972
25119
  try {
@@ -24986,7 +25133,7 @@ function hookLogTail(env) {
24986
25133
  }
24987
25134
  async function journalRows(ctx) {
24988
25135
  const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
24989
- if (!existsSync12(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25136
+ if (!existsSync13(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
24990
25137
  try {
24991
25138
  const db = await openDb(ctx.project, { readOnly: true });
24992
25139
  try {
@@ -25004,15 +25151,15 @@ function agentConfig(adapter, env, worktree) {
25004
25151
  const home = homeDirOf(env);
25005
25152
  const files = configPaths(adapter, env, worktree);
25006
25153
  if (home !== null) {
25007
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join15(claudeDirOf(env, home), SETTINGS_FILE) });
25008
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join15(codexDirOf(env, home), CONFIG_TOML_FILE) });
25154
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join16(claudeDirOf(env, home), SETTINGS_FILE) });
25155
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join16(codexDirOf(env, home), CONFIG_TOML_FILE) });
25009
25156
  }
25010
25157
  const out = [];
25011
25158
  const seen = /* @__PURE__ */ new Set();
25012
25159
  for (const f of files) {
25013
25160
  if (seen.has(f.path)) continue;
25014
25161
  seen.add(f.path);
25015
- if (!existsSync12(f.path)) {
25162
+ if (!existsSync13(f.path)) {
25016
25163
  out.push(`${f.label}: ${f.path} (absent)`);
25017
25164
  continue;
25018
25165
  }
@@ -25088,14 +25235,14 @@ async function buildIssueBody(i) {
25088
25235
  async function writeIssueReport(i) {
25089
25236
  const tilde = tildeOf(i.env);
25090
25237
  const body = await buildIssueBody(i);
25091
- const dir = join15(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25238
+ const dir = join16(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25092
25239
  mkdirSync6(dir, { recursive: true });
25093
- const file2 = join15(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25240
+ const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25094
25241
  writeFileSync3(file2, body);
25095
25242
  const shown2 = tilde(file2);
25096
25243
  const title = issueTitle(i.adapter.id, i.rows);
25097
25244
  const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
25098
- return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows))];
25245
+ return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
25099
25246
  }
25100
25247
  function formUrl(title, summary) {
25101
25248
  const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
@@ -25117,7 +25264,7 @@ async function guard(id, run) {
25117
25264
  }
25118
25265
  }
25119
25266
  async function codexDb(ctx, adapter) {
25120
- if (adapter.id !== "codex" || !existsSync13(ctx.project.dbPath)) return null;
25267
+ if (adapter.id !== "codex" || !existsSync14(ctx.project.dbPath)) return null;
25121
25268
  try {
25122
25269
  return await openDb(ctx.project, { readOnly: true });
25123
25270
  } catch {
@@ -25147,11 +25294,11 @@ async function hookRow(ctx, adapter, host) {
25147
25294
  }
25148
25295
  }
25149
25296
  function ownServerId(configDir, projectKey) {
25150
- const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25151
- if (!existsSync13(dir)) return "";
25297
+ const dir = join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25298
+ if (!existsSync14(dir)) return "";
25152
25299
  for (const name of readdirSync6(dir)) {
25153
25300
  if (!name.endsWith(OWNER_PID_EXT)) continue;
25154
- if (readFileSync13(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25301
+ if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25155
25302
  }
25156
25303
  return "";
25157
25304
  }
@@ -25234,7 +25381,7 @@ async function doctorReply(ctx, host) {
25234
25381
  return { text, isError: false, sandboxBytes: bytes5 };
25235
25382
  }
25236
25383
  async function handler2(_input, ctx) {
25237
- return doctorReply(ctx, { env: process.env, bundleDir: dirname8(process.argv[1]), piCwd: void 0 });
25384
+ return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: void 0 });
25238
25385
  }
25239
25386
  var ctxDoctor = Object.freeze({
25240
25387
  name: "ctx_doctor",
@@ -25246,9 +25393,9 @@ var ctxDoctor = Object.freeze({
25246
25393
  });
25247
25394
 
25248
25395
  // src/core/tools/execute.ts
25249
- import { existsSync as existsSync14, mkdtempSync, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "node:fs";
25250
- import { tmpdir as tmpdir2 } from "node:os";
25251
- import { dirname as dirname9, join as join17, parse as parse3, resolve as resolve6 } from "node:path";
25396
+ import { existsSync as existsSync15, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25397
+ import { tmpdir as tmpdir3 } from "node:os";
25398
+ import { dirname as dirname10, join as join18, parse as parse3, resolve as resolve6 } from "node:path";
25252
25399
 
25253
25400
  // src/core/sandbox/win-build.ts
25254
25401
  var SEPARATORS2 = ";&|(\n";
@@ -25332,7 +25479,7 @@ function schemaLine(issue4) {
25332
25479
  }
25333
25480
  function fileError(given, abs, root) {
25334
25481
  let dir = abs;
25335
- while (!existsSync14(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
25482
+ while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
25336
25483
  if (isInside(root, dir)) return null;
25337
25484
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
25338
25485
  }
@@ -25413,8 +25560,8 @@ async function handler3(raw, ctx) {
25413
25560
  if (takesDashC(input.language, runtime)) {
25414
25561
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
25415
25562
  } else {
25416
- tmpDir = mkdtempSync(join17(tmpdir2(), TMP_PREFIX));
25417
- const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25563
+ tmpDir = mkdtempSync2(join18(tmpdir3(), TMP_PREFIX));
25564
+ const file2 = join18(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25418
25565
  writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
25419
25566
  argv = scriptArgv(input.language, runtime, file2);
25420
25567
  }
@@ -25437,7 +25584,7 @@ async function handler3(raw, ctx) {
25437
25584
  }
25438
25585
  throw err;
25439
25586
  } finally {
25440
- if (tmpDir !== null && !handedOff) rmSync4(tmpDir, { recursive: true, force: true });
25587
+ if (tmpDir !== null && !handedOff) rmSync5(tmpDir, { recursive: true, force: true });
25441
25588
  }
25442
25589
  }
25443
25590
  var ctxExecute = {
@@ -25449,12 +25596,12 @@ var ctxExecute = {
25449
25596
  };
25450
25597
 
25451
25598
  // src/core/tools/index.ts
25452
- import { existsSync as existsSync15, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25453
- import { dirname as dirname10, extname, join as join19, relative as relative3, resolve as resolve7 } from "node:path";
25599
+ import { existsSync as existsSync16, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25600
+ import { dirname as dirname11, extname, join as join20, relative as relative3, resolve as resolve7 } from "node:path";
25454
25601
 
25455
25602
  // src/core/index/walk.ts
25456
25603
  import { readdirSync as readdirSync7, readFileSync as readFileSync14, realpathSync as realpathSync9, statSync as statSync7 } from "node:fs";
25457
- import { join as join18 } from "node:path";
25604
+ import { join as join19 } from "node:path";
25458
25605
  var GITIGNORE = ".gitignore";
25459
25606
  var GIT_DIR = ".git";
25460
25607
  function walkDir(root, containmentRoot) {
@@ -25463,7 +25610,7 @@ function walkDir(root, containmentRoot) {
25463
25610
  const found = [];
25464
25611
  visit(real2, [], [], containmentRoot, /* @__PURE__ */ new Set([real2]), found);
25465
25612
  found.sort(compareFound);
25466
- return found.map((f) => ({ absPath: f.absPath, relPath: join18(...f.dir, f.name) }));
25613
+ return found.map((f) => ({ absPath: f.absPath, relPath: join19(...f.dir, f.name) }));
25467
25614
  }
25468
25615
  function visit(abs, rel, parent, contain, seen, found) {
25469
25616
  let entries;
@@ -25472,10 +25619,10 @@ function visit(abs, rel, parent, contain, seen, found) {
25472
25619
  } catch {
25473
25620
  return;
25474
25621
  }
25475
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join18(abs, GITIGNORE), rel)) : parent;
25622
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join19(abs, GITIGNORE), rel)) : parent;
25476
25623
  for (const e of entries) {
25477
25624
  if (e.name === GIT_DIR) continue;
25478
- const path7 = join18(abs, e.name);
25625
+ const path7 = join19(abs, e.name);
25479
25626
  let isDir = e.isDirectory();
25480
25627
  let isFile = e.isFile();
25481
25628
  let target = path7;
@@ -29605,7 +29752,7 @@ function readUtf8(absPath) {
29605
29752
  }
29606
29753
  function missingOrOutside(given, abs, root) {
29607
29754
  let dir = abs;
29608
- while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
29755
+ while (!existsSync16(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
29609
29756
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
29610
29757
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
29611
29758
  }
@@ -29616,7 +29763,7 @@ function pathItems(input, project) {
29616
29763
  if (statSync8(abs).isDirectory()) {
29617
29764
  return walkDir(abs, project.containmentRoot).map((f) => ({
29618
29765
  sourceKind: "path",
29619
- label: pathLabel(join19(base, f.relPath)),
29766
+ label: pathLabel(join20(base, f.relPath)),
29620
29767
  kind: kindOfPath(f.relPath),
29621
29768
  read: () => readUtf8(f.absPath)
29622
29769
  }));
@@ -30156,12 +30303,12 @@ var ctxStats = Object.freeze({
30156
30303
  });
30157
30304
 
30158
30305
  // src/core/tools/upgrade.ts
30159
- import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as rmSync9 } from "node:fs";
30160
- import { basename as basename7, dirname as dirname12, join as join25 } from "node:path";
30306
+ import { existsSync as existsSync22, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
30307
+ import { basename as basename7, dirname as dirname13, join as join26 } from "node:path";
30161
30308
 
30162
30309
  // src/core/ops/host-write.ts
30163
- import { copyFileSync, existsSync as existsSync16, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30164
- import { dirname as dirname11, join as join20 } from "node:path";
30310
+ import { copyFileSync, existsSync as existsSync17, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30311
+ import { dirname as dirname12, join as join21 } from "node:path";
30165
30312
  function defaultWrite(file2, text) {
30166
30313
  writeFileSync5(file2, text, "utf8");
30167
30314
  }
@@ -30170,14 +30317,14 @@ function hostConfigPath(agent, home, env) {
30170
30317
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
30171
30318
  switch (agent) {
30172
30319
  case "opencode":
30173
- return join20(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30320
+ return join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30174
30321
  // D-WIN-OPENCODE-DIR-1
30175
30322
  case "pi":
30176
- return join20(piAgentDirOf(env, home), SETTINGS_FILE);
30323
+ return join21(piAgentDirOf(env, home), SETTINGS_FILE);
30177
30324
  case "copilot-cli":
30178
30325
  return null;
30179
30326
  default:
30180
- return join20(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30327
+ return join21(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30181
30328
  }
30182
30329
  }
30183
30330
  function cell3(value) {
@@ -30189,8 +30336,8 @@ function toRow(file2, edit) {
30189
30336
  function writeWithRollback(file2, text, write2, atomic) {
30190
30337
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
30191
30338
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
30192
- const had = existsSync16(file2);
30193
- mkdirSync7(dirname11(file2), { recursive: true });
30339
+ const had = existsSync17(file2);
30340
+ mkdirSync7(dirname12(file2), { recursive: true });
30194
30341
  if (had) copyFileSync(file2, trash);
30195
30342
  try {
30196
30343
  write2(tmp, text);
@@ -30219,7 +30366,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
30219
30366
  if (requested === null) return [];
30220
30367
  const current = readHostConfig(row5.id, requested);
30221
30368
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
30222
- const exists = existsSync16(current.path);
30369
+ const exists = existsSync17(current.path);
30223
30370
  if (exists && result.text === current.text) return [];
30224
30371
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
30225
30372
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -30227,8 +30374,8 @@ function regenerateHostConfig(row5, home, opts = {}) {
30227
30374
  }
30228
30375
 
30229
30376
  // src/core/ops/plugin-swap.ts
30230
- import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync5, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30231
- import { basename as basename6, join as join21, win32 as win322 } from "node:path";
30377
+ import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30378
+ import { basename as basename6, join as join22, win32 as win322 } from "node:path";
30232
30379
  function linkTarget(path7, win) {
30233
30380
  if (!isLink(path7)) return null;
30234
30381
  const target = readlinkSync(path7);
@@ -30247,11 +30394,11 @@ function settleLinks(link, tmp, old, opts) {
30247
30394
  else renameWithRetry(old, link, opts);
30248
30395
  }
30249
30396
  function swapPluginCurrent(agentDir, sha, opts = {}) {
30250
- const next = join21(agentDir, sha);
30251
- if (!existsSync17(next) || !lstatSync(next).isDirectory()) {
30397
+ const next = join22(agentDir, sha);
30398
+ if (!existsSync18(next) || !lstatSync(next).isDirectory()) {
30252
30399
  throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
30253
30400
  }
30254
- const link = join21(agentDir, PLUGIN_CURRENT_LINK);
30401
+ const link = join22(agentDir, PLUGIN_CURRENT_LINK);
30255
30402
  const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
30256
30403
  const old = link + PLUGIN_LINK_OLD_SUFFIX;
30257
30404
  settleLinks(link, tmp, old, opts);
@@ -30266,15 +30413,15 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
30266
30413
  if (before !== null) unlinkSync2(old);
30267
30414
  const keep = /* @__PURE__ */ new Set([sha]);
30268
30415
  if (before !== null) keep.add(before);
30269
- const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join21(agentDir, name));
30270
- for (const dir of removed) rmSync5(dir, { recursive: true, force: true });
30271
- const previous = before !== null && existsSync17(join21(agentDir, before)) ? join21(agentDir, before) : null;
30416
+ const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join22(agentDir, name));
30417
+ for (const dir of removed) rmSync6(dir, { recursive: true, force: true });
30418
+ const previous = before !== null && existsSync18(join22(agentDir, before)) ? join22(agentDir, before) : null;
30272
30419
  return { current: next, previous, removed };
30273
30420
  }
30274
30421
 
30275
30422
  // src/core/ops/release-fetch.ts
30276
- import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as rmSync6 } from "node:fs";
30277
- import { join as join22 } from "node:path";
30423
+ import { existsSync as existsSync19, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
30424
+ import { join as join23 } from "node:path";
30278
30425
  function failed(r) {
30279
30426
  if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
30280
30427
  const status = r.killed ?? String(r.exitCode);
@@ -30286,36 +30433,36 @@ async function git2(bin, args, cwd, env, signal) {
30286
30433
  return r.stdout.toString().trim();
30287
30434
  }
30288
30435
  async function fetchRelease(agent, url4, env, signal, opts = {}) {
30289
- const agentDir = join22(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30436
+ const agentDir = join23(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30290
30437
  mkdirSync8(agentDir, { recursive: true });
30291
- const fetchDir = join22(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30292
- rmSync6(fetchDir, { recursive: true, force: true });
30438
+ const fetchDir = join23(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30439
+ rmSync7(fetchDir, { recursive: true, force: true });
30293
30440
  const gitBin = findRuntime(GIT_BIN, env);
30294
30441
  if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
30295
30442
  const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
30296
30443
  try {
30297
30444
  await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
30298
30445
  const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
30299
- const dir = join22(agentDir, sha);
30300
- if (existsSync18(dir)) rmSync6(fetchDir, { recursive: true, force: true });
30446
+ const dir = join23(agentDir, sha);
30447
+ if (existsSync19(dir)) rmSync7(fetchDir, { recursive: true, force: true });
30301
30448
  else renameWithRetry(fetchDir, dir, opts);
30302
30449
  return { sha, dir };
30303
30450
  } catch (e) {
30304
- rmSync6(fetchDir, { recursive: true, force: true });
30451
+ rmSync7(fetchDir, { recursive: true, force: true });
30305
30452
  throw e;
30306
30453
  }
30307
30454
  }
30308
30455
 
30309
30456
  // src/core/ops/uninstall.ts
30310
- import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as rmSync7, writeFileSync as writeFileSync6 } from "node:fs";
30311
- import { join as join23 } from "node:path";
30457
+ import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
30458
+ import { join as join24 } from "node:path";
30312
30459
  function row2(area, before, after) {
30313
30460
  return { area, before, after };
30314
30461
  }
30315
30462
  function stopServers(configDir, projectKey) {
30316
30463
  const stopped = listLiveOwners(configDir, projectKey);
30317
- const dir = join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30318
- for (const serverId of stopped) writeFileSync6(join23(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30464
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30465
+ for (const serverId of stopped) writeFileSync6(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30319
30466
  return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
30320
30467
  }
30321
30468
  function rootOrNull(adapter, env) {
@@ -30333,16 +30480,16 @@ function removeCache(adapter, env, configDir) {
30333
30480
  const root = rootOrNull(adapter, env);
30334
30481
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30335
30482
  if (adapter.installMode === "marketplace") {
30336
- const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30483
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30337
30484
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
30338
30485
  }
30339
- rmSync7(root, { recursive: true, force: true });
30486
+ rmSync8(root, { recursive: true, force: true });
30340
30487
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
30341
30488
  }
30342
30489
  case "plugin": {
30343
- const agentDir = join23(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30344
- if (!existsSync19(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30345
- rmSync7(agentDir, { recursive: true, force: true });
30490
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30491
+ if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30492
+ rmSync8(agentDir, { recursive: true, force: true });
30346
30493
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
30347
30494
  }
30348
30495
  case "config-mcp":
@@ -30386,7 +30533,7 @@ function ownEntries(agent, env) {
30386
30533
  }
30387
30534
  if (agent === "opencode") {
30388
30535
  return [{
30389
- file: join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30536
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30390
30537
  // D-WIN-OPENCODE-DIR-1
30391
30538
  key: OPENCODE_PLUGIN_KEY,
30392
30539
  shown: OPENCODE_PLUGIN_KEY,
@@ -30397,7 +30544,7 @@ function ownEntries(agent, env) {
30397
30544
  if (agent === "pi") {
30398
30545
  const agentDir = piAgentDirOf(env, home);
30399
30546
  return [{
30400
- file: join23(agentDir, SETTINGS_FILE),
30547
+ file: join24(agentDir, SETTINGS_FILE),
30401
30548
  key: PI_PACKAGES_KEY,
30402
30549
  shown: PI_PACKAGES_KEY,
30403
30550
  has: (v) => Array.isArray(v) && v.some((x) => piSource(x) === PI_GIT_PACKAGE),
@@ -30419,12 +30566,12 @@ function removeOwnEntries(agent, env) {
30419
30566
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
30420
30567
  }
30421
30568
  function removeProjectData(configDir, projectKey) {
30422
- const projects = join23(configDir, PROJECTS_DIR_NAME);
30423
- const dir = join23(projects, projectKey);
30424
- if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30569
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
30570
+ const dir = join24(projects, projectKey);
30571
+ if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30425
30572
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
30426
30573
  for (const name of readdirSync9(dir)) {
30427
- if (name !== OWNERS_DIR_NAME) rmSync7(join23(dir, name), { recursive: true, force: true });
30574
+ if (name !== OWNERS_DIR_NAME) rmSync8(join24(dir, name), { recursive: true, force: true });
30428
30575
  }
30429
30576
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
30430
30577
  }
@@ -30432,25 +30579,25 @@ function runUninstall(input) {
30432
30579
  const configDir = resolveConfigDir(input.env);
30433
30580
  const stop = stopServers(configDir, input.project.projectKey);
30434
30581
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
30435
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join23(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30582
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30436
30583
  return { rows, stopped: stop.stopped };
30437
30584
  }
30438
30585
 
30439
30586
  // src/core/ops/v1-remove.ts
30440
- import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as rmSync8 } from "node:fs";
30587
+ import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30441
30588
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30442
30589
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
30443
30590
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
30444
30591
  function moveAside(target, undo) {
30445
30592
  const trash = target + UPGRADE_TRASH_SUFFIX;
30446
- rmSync8(trash, { recursive: true, force: true });
30593
+ rmSync9(trash, { recursive: true, force: true });
30447
30594
  renameWithRetry(target, trash);
30448
30595
  undo.push({ trash, target });
30449
30596
  }
30450
30597
  function keepOriginal(file2, kept, undo) {
30451
30598
  if (kept.has(file2)) return;
30452
30599
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
30453
- rmSync8(trash, { recursive: true, force: true });
30600
+ rmSync9(trash, { recursive: true, force: true });
30454
30601
  copyFileSync2(file2, trash);
30455
30602
  kept.add(file2);
30456
30603
  undo.push({ trash, target: file2 });
@@ -30518,14 +30665,14 @@ function removeV1(agent, findings) {
30518
30665
  for (const f of findings) {
30519
30666
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
30520
30667
  else if (f.path === "") {
30521
- if (existsSync20(f.file)) {
30668
+ if (existsSync21(f.file)) {
30522
30669
  moveAside(f.file, undo);
30523
30670
  done.set(f, UPGRADE_REMOVED);
30524
30671
  } else done.set(f, UPGRADE_NOT_FOUND);
30525
30672
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
30526
30673
  }
30527
30674
  for (const [file2, list4] of entries) {
30528
- if (!existsSync20(file2)) {
30675
+ if (!existsSync21(file2)) {
30529
30676
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
30530
30677
  continue;
30531
30678
  }
@@ -30554,12 +30701,12 @@ function removeV1(agent, findings) {
30554
30701
  return {
30555
30702
  rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
30556
30703
  commit() {
30557
- for (const u of undo.splice(0)) rmSync8(u.trash, { recursive: true, force: true });
30704
+ for (const u of undo.splice(0)) rmSync9(u.trash, { recursive: true, force: true });
30558
30705
  },
30559
30706
  rollback() {
30560
30707
  for (const u of undo.splice(0).reverse()) {
30561
- if (!existsSync20(u.trash)) continue;
30562
- rmSync8(u.target, { recursive: true, force: true });
30708
+ if (!existsSync21(u.trash)) continue;
30709
+ rmSync9(u.target, { recursive: true, force: true });
30563
30710
  renameWithRetry(u.trash, u.target);
30564
30711
  }
30565
30712
  }
@@ -30569,7 +30716,7 @@ function removeV1(agent, findings) {
30569
30716
  // src/core/ops/verify-sums.ts
30570
30717
  import { createHash as createHash2 } from "node:crypto";
30571
30718
  import { lstatSync as lstatSync2, readdirSync as readdirSync10, readFileSync as readFileSync17 } from "node:fs";
30572
- import { join as join24 } from "node:path";
30719
+ import { join as join25 } from "node:path";
30573
30720
  function mismatch() {
30574
30721
  return new CtxError("BUNDLE_HASH_MISMATCH");
30575
30722
  }
@@ -30590,14 +30737,14 @@ function walk3(dir, prefix, out) {
30590
30737
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
30591
30738
  const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
30592
30739
  if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
30593
- const abs = join24(dir, entry.name);
30740
+ const abs = join25(dir, entry.name);
30594
30741
  if (entry.isDirectory()) walk3(abs, rel, out);
30595
30742
  else if (entry.isFile()) out.set(rel, abs);
30596
30743
  else throw mismatch();
30597
30744
  }
30598
30745
  }
30599
30746
  function verifySums(dir) {
30600
- const sumsPath = join24(dir, RELEASE_SUMS_FILE);
30747
+ const sumsPath = join25(dir, RELEASE_SUMS_FILE);
30601
30748
  const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
30602
30749
  if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
30603
30750
  const sums = parseSums(readFileSync17(sumsPath, "utf8"));
@@ -30621,7 +30768,7 @@ function row4(area, before, after) {
30621
30768
  return { area, before, after };
30622
30769
  }
30623
30770
  function bundleDir() {
30624
- return dirname12(process.argv[1] ?? "");
30771
+ return ownBundleDir();
30625
30772
  }
30626
30773
  function pluginRootRow(adapter, env) {
30627
30774
  const own4 = bundleDir();
@@ -30635,16 +30782,16 @@ function pluginRootRow(adapter, env) {
30635
30782
  return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
30636
30783
  }
30637
30784
  function isCurrent(agentDir, dir) {
30638
- const link = join25(agentDir, PLUGIN_CURRENT_LINK);
30639
- return existsSync21(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30785
+ const link = join26(agentDir, PLUGIN_CURRENT_LINK);
30786
+ return existsSync22(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30640
30787
  }
30641
30788
  async function checkout(adapter, deps) {
30642
30789
  const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
30643
- const agentDir = dirname12(fetched.dir);
30790
+ const agentDir = dirname13(fetched.dir);
30644
30791
  try {
30645
30792
  verifySums(fetched.dir);
30646
30793
  } catch (err) {
30647
- if (!isCurrent(agentDir, fetched.dir)) rmSync9(fetched.dir, { recursive: true, force: true });
30794
+ if (!isCurrent(agentDir, fetched.dir)) rmSync10(fetched.dir, { recursive: true, force: true });
30648
30795
  throw err;
30649
30796
  }
30650
30797
  const swap = swapPluginCurrent(agentDir, fetched.sha);
@@ -30756,9 +30903,9 @@ function checkCall(tool, input) {
30756
30903
 
30757
30904
  // src/entries/server.ts
30758
30905
  import { randomUUID } from "node:crypto";
30759
- import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync11 } from "node:fs";
30760
- import { dirname as dirname13, join as join27 } from "node:path";
30761
- import { fileURLToPath as fileURLToPath2 } from "node:url";
30906
+ import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
30907
+ import { dirname as dirname14, join as join28 } from "node:path";
30908
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
30762
30909
 
30763
30910
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
30764
30911
  var __create = Object.create;
@@ -33135,8 +33282,8 @@ function handleArrayResult2(result, final, index) {
33135
33282
  }
33136
33283
  var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
33137
33284
  $ZodType2.init(inst, def);
33138
- const memo4 = globalConfig2.memoizer;
33139
- memo4?.attach(inst);
33285
+ const memo5 = globalConfig2.memoizer;
33286
+ memo5?.attach(inst);
33140
33287
  inst._zod.parse = (payload, ctx) => {
33141
33288
  const input = payload.value;
33142
33289
  if (!Array.isArray(input)) {
@@ -33148,7 +33295,7 @@ var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
33148
33295
  });
33149
33296
  return payload;
33150
33297
  }
33151
- payload.value = memo4 ? memo4.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
33298
+ payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
33152
33299
  const proms = [];
33153
33300
  const abortEarly = ctx?.abortEarly;
33154
33301
  for (let i = 0; i < input.length; i++) {
@@ -33308,8 +33455,8 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33308
33455
  const isObject8 = isObject6;
33309
33456
  const catchall = def.catchall;
33310
33457
  let value;
33311
- const memo4 = globalConfig2.memoizer;
33312
- memo4?.attach(inst);
33458
+ const memo5 = globalConfig2.memoizer;
33459
+ memo5?.attach(inst);
33313
33460
  inst._zod.parse = (payload, ctx) => {
33314
33461
  value ?? (value = _normalized.value);
33315
33462
  const input = payload.value;
@@ -33322,7 +33469,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33322
33469
  });
33323
33470
  return payload;
33324
33471
  }
33325
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33472
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33326
33473
  const proms = [];
33327
33474
  const shape = value.shape;
33328
33475
  const abortEarly = ctx?.abortEarly;
@@ -33355,11 +33502,11 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33355
33502
  $ZodObject2.init(inst, def);
33356
33503
  const superParse = inst._zod.parse;
33357
33504
  const _normalized = cached2(() => normalizeDef(def));
33358
- const memo4 = globalConfig2.memoizer;
33505
+ const memo5 = globalConfig2.memoizer;
33359
33506
  const generateFastpass = (shape) => {
33360
33507
  const normalized = _normalized.value;
33361
33508
  const syms = normalized.symbolKeys;
33362
- const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo4, syms });
33509
+ const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo5, syms });
33363
33510
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
33364
33511
  const prefixStr = (id, k) => `
33365
33512
  let ${id}_ab = false;
@@ -33379,7 +33526,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33379
33526
  for (const key of normalized.allKeys) {
33380
33527
  ids[key] = `key_${counter++}`;
33381
33528
  }
33382
- doc.write(memo4 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
33529
+ doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
33383
33530
  for (const key of normalized.allKeys) {
33384
33531
  if (key === "__proto__")
33385
33532
  continue;
@@ -33742,8 +33889,8 @@ function handleIntersectionResults2(result, left, right2) {
33742
33889
  }
33743
33890
  var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33744
33891
  $ZodType2.init(inst, def);
33745
- const memo4 = globalConfig2.memoizer;
33746
- memo4?.attach(inst);
33892
+ const memo5 = globalConfig2.memoizer;
33893
+ memo5?.attach(inst);
33747
33894
  inst._zod.parse = (payload, ctx) => {
33748
33895
  const input = payload.value;
33749
33896
  if (!isPlainObject4(input)) {
@@ -33758,7 +33905,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33758
33905
  const proms = [];
33759
33906
  const values = def.keyType._zod.values;
33760
33907
  if (values && !def.partial) {
33761
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33908
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33762
33909
  const recordKeys = /* @__PURE__ */ new Set();
33763
33910
  for (const key of values) {
33764
33911
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -33822,7 +33969,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33822
33969
  });
33823
33970
  }
33824
33971
  } else {
33825
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33972
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33826
33973
  let unrecognized;
33827
33974
  for (const key of Reflect.ownKeys(input)) {
33828
33975
  if (key === "__proto__")
@@ -34383,7 +34530,7 @@ function bucketFor(state, inst) {
34383
34530
  }
34384
34531
  var handoff;
34385
34532
  var open = [];
34386
- var memo = {
34533
+ var memo2 = {
34387
34534
  alloc(_inst, payload, empty) {
34388
34535
  const bucket = handoff;
34389
34536
  if (!bucket)
@@ -34484,7 +34631,7 @@ var memo = {
34484
34631
  }
34485
34632
  };
34486
34633
  function memoizer() {
34487
- return memo;
34634
+ return memo2;
34488
34635
  }
34489
34636
  function isBackEdge(ctx, value) {
34490
34637
  const backEdges = ctx[STATE]?.backEdges;
@@ -40664,8 +40811,8 @@ function handleArrayResult3(result, final, index) {
40664
40811
  }
40665
40812
  var $ZodArray3 = /* @__PURE__ */ $constructor3("$ZodArray", (inst, def) => {
40666
40813
  $ZodType3.init(inst, def);
40667
- const memo4 = globalConfig3.memoizer;
40668
- memo4?.attach(inst);
40814
+ const memo5 = globalConfig3.memoizer;
40815
+ memo5?.attach(inst);
40669
40816
  inst._zod.parse = (payload, ctx) => {
40670
40817
  const input = payload.value;
40671
40818
  if (!Array.isArray(input)) {
@@ -40677,7 +40824,7 @@ var $ZodArray3 = /* @__PURE__ */ $constructor3("$ZodArray", (inst, def) => {
40677
40824
  });
40678
40825
  return payload;
40679
40826
  }
40680
- payload.value = memo4 ? memo4.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
40827
+ payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
40681
40828
  const proms = [];
40682
40829
  const abortEarly = ctx?.abortEarly;
40683
40830
  for (let i = 0; i < input.length; i++) {
@@ -40837,8 +40984,8 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
40837
40984
  const isObject8 = isObject7;
40838
40985
  const catchall = def.catchall;
40839
40986
  let value;
40840
- const memo4 = globalConfig3.memoizer;
40841
- memo4?.attach(inst);
40987
+ const memo5 = globalConfig3.memoizer;
40988
+ memo5?.attach(inst);
40842
40989
  inst._zod.parse = (payload, ctx) => {
40843
40990
  value ?? (value = _normalized.value);
40844
40991
  const input = payload.value;
@@ -40851,7 +40998,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
40851
40998
  });
40852
40999
  return payload;
40853
41000
  }
40854
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41001
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
40855
41002
  const proms = [];
40856
41003
  const shape = value.shape;
40857
41004
  const abortEarly = ctx?.abortEarly;
@@ -40884,11 +41031,11 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
40884
41031
  $ZodObject3.init(inst, def);
40885
41032
  const superParse = inst._zod.parse;
40886
41033
  const _normalized = cached3(() => normalizeDef2(def));
40887
- const memo4 = globalConfig3.memoizer;
41034
+ const memo5 = globalConfig3.memoizer;
40888
41035
  const generateFastpass = (shape) => {
40889
41036
  const normalized = _normalized.value;
40890
41037
  const syms = normalized.symbolKeys;
40891
- const doc = new Doc3(["payload", "ctx"], { shape, inst, memo: memo4, syms });
41038
+ const doc = new Doc3(["payload", "ctx"], { shape, inst, memo: memo5, syms });
40892
41039
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
40893
41040
  const prefixStr = (id, k) => `
40894
41041
  let ${id}_ab = false;
@@ -40908,7 +41055,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
40908
41055
  for (const key of normalized.allKeys) {
40909
41056
  ids[key] = `key_${counter++}`;
40910
41057
  }
40911
- doc.write(memo4 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
41058
+ doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
40912
41059
  for (const key of normalized.allKeys) {
40913
41060
  if (key === "__proto__")
40914
41061
  continue;
@@ -41271,8 +41418,8 @@ function handleIntersectionResults3(result, left, right2) {
41271
41418
  }
41272
41419
  var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41273
41420
  $ZodType3.init(inst, def);
41274
- const memo4 = globalConfig3.memoizer;
41275
- memo4?.attach(inst);
41421
+ const memo5 = globalConfig3.memoizer;
41422
+ memo5?.attach(inst);
41276
41423
  inst._zod.parse = (payload, ctx) => {
41277
41424
  const input = payload.value;
41278
41425
  if (!isPlainObject5(input)) {
@@ -41287,7 +41434,7 @@ var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41287
41434
  const proms = [];
41288
41435
  const values = def.keyType._zod.values;
41289
41436
  if (values && !def.partial) {
41290
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41437
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
41291
41438
  const recordKeys = /* @__PURE__ */ new Set();
41292
41439
  for (const key of values) {
41293
41440
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -41351,7 +41498,7 @@ var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41351
41498
  });
41352
41499
  }
41353
41500
  } else {
41354
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41501
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
41355
41502
  let unrecognized;
41356
41503
  for (const key of Reflect.ownKeys(input)) {
41357
41504
  if (key === "__proto__")
@@ -41912,7 +42059,7 @@ function bucketFor2(state, inst) {
41912
42059
  }
41913
42060
  var handoff2;
41914
42061
  var open2 = [];
41915
- var memo2 = {
42062
+ var memo3 = {
41916
42063
  alloc(_inst, payload, empty) {
41917
42064
  const bucket = handoff2;
41918
42065
  if (!bucket)
@@ -42013,7 +42160,7 @@ var memo2 = {
42013
42160
  }
42014
42161
  };
42015
42162
  function memoizer2() {
42016
- return memo2;
42163
+ return memo3;
42017
42164
  }
42018
42165
  function isBackEdge2(ctx, value) {
42019
42166
  const backEdges = ctx[STATE2]?.backEdges;
@@ -47276,9 +47423,9 @@ function build() {
47276
47423
  SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
47277
47424
  };
47278
47425
  }
47279
- var memo3;
47426
+ var memo4;
47280
47427
  function buildSchemas2026() {
47281
- return memo3 ??= build();
47428
+ return memo4 ??= build();
47282
47429
  }
47283
47430
  var CACHEABLE_RESULT_METHODS = [
47284
47431
  "tools/list",
@@ -58822,8 +58969,8 @@ function installExitGuard(opts) {
58822
58969
  }
58823
58970
 
58824
58971
  // src/core/store/cleanup.ts
58825
- import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as rmSync10 } from "node:fs";
58826
- import { join as join26 } from "node:path";
58972
+ import { existsSync as existsSync23, readdirSync as readdirSync11, rmSync as rmSync11 } from "node:fs";
58973
+ import { join as join27 } from "node:path";
58827
58974
  function deleteSource(raw, id) {
58828
58975
  raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
58829
58976
  deleteChunkRows(raw, { sourceId: id });
@@ -58858,7 +59005,7 @@ function userVersion(raw) {
58858
59005
  return raw.prepare("PRAGMA user_version").get().user_version;
58859
59006
  }
58860
59007
  function openForSweep(dbPath, projectKey) {
58861
- if (!existsSync22(dbPath) && (existsSync22(dbPath + DB_WAL_SUFFIX) || existsSync22(dbPath + DB_SHM_SUFFIX))) {
59008
+ if (!existsSync23(dbPath) && (existsSync23(dbPath + DB_WAL_SUFFIX) || existsSync23(dbPath + DB_SHM_SUFFIX))) {
58862
59009
  throw new CtxError("DB_GONE");
58863
59010
  }
58864
59011
  const sqlite = process.getBuiltinModule("node:sqlite");
@@ -58879,21 +59026,21 @@ function lastAccess(raw) {
58879
59026
  return row5.t;
58880
59027
  }
58881
59028
  function sweepOne(configDir, projectKey, cutoff) {
58882
- const dir = join26(configDir, PROJECTS_DIR_NAME, projectKey);
58883
- const db = openForSweep(join26(dir, DB_FILE_NAME), projectKey);
59029
+ const dir = join27(configDir, PROJECTS_DIR_NAME, projectKey);
59030
+ const db = openForSweep(join27(dir, DB_FILE_NAME), projectKey);
58884
59031
  let dead;
58885
59032
  try {
58886
59033
  dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
58887
59034
  } finally {
58888
59035
  closeDb(db);
58889
59036
  }
58890
- if (dead) rmSync10(dir, { recursive: true, force: true });
59037
+ if (dead) rmSync11(dir, { recursive: true, force: true });
58891
59038
  return dead;
58892
59039
  }
58893
59040
  function sweepDeadProjects(configDir) {
58894
59041
  let entries;
58895
59042
  try {
58896
- entries = readdirSync11(join26(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
59043
+ entries = readdirSync11(join27(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
58897
59044
  } catch (err) {
58898
59045
  if (err.code === "ENOENT") return [];
58899
59046
  throw err;
@@ -58986,7 +59133,7 @@ function workspaceFromMeta(meta3) {
58986
59133
  if (typeof cwd !== "string" || cwd === "") return void 0;
58987
59134
  if (!cwd.startsWith(FILE_URL_PREFIX)) return cwd;
58988
59135
  try {
58989
- return fileURLToPath2(cwd);
59136
+ return fileURLToPath3(cwd);
58990
59137
  } catch {
58991
59138
  return void 0;
58992
59139
  }
@@ -59002,7 +59149,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
59002
59149
  const fromHost = workspaceFromMeta(meta3);
59003
59150
  if (fromHost !== void 0) return fromHost;
59004
59151
  if (script === void 0 || script === "") return spawnCwd;
59005
- return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
59152
+ return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
59006
59153
  }
59007
59154
  function errorReply(err) {
59008
59155
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
@@ -59041,15 +59188,15 @@ async function startServer(argv, env) {
59041
59188
  opening.catch(() => pending.delete(project.dbPath));
59042
59189
  }
59043
59190
  const db = await opening;
59044
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
59191
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
59045
59192
  return db;
59046
59193
  }
59047
59194
  function stopMarker(configDir, projectKey) {
59048
- return join27(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59195
+ return join28(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59049
59196
  }
59050
59197
  function stopRequested() {
59051
59198
  const configDir = resolveConfigDir(process.env);
59052
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
59199
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
59053
59200
  }
59054
59201
  async function journal(project, ctx, name, reply4) {
59055
59202
  const db = await ownDb(project);
@@ -59142,7 +59289,7 @@ async function startServer(argv, env) {
59142
59289
  try {
59143
59290
  const configDir = resolveConfigDir(process.env);
59144
59291
  removeOwnerPid(configDir, db.projectKey, serverId);
59145
- rmSync11(stopMarker(configDir, db.projectKey), { force: true });
59292
+ rmSync12(stopMarker(configDir, db.projectKey), { force: true });
59146
59293
  } catch (err) {
59147
59294
  console.error(err);
59148
59295
  }
@@ -59158,7 +59305,7 @@ async function startServer(argv, env) {
59158
59305
  handle = serveStdio(createServer);
59159
59306
  await new Promise((resolve8) => process.once("exit", () => resolve8()));
59160
59307
  }
59161
- if (isEntry(import.meta.main, process.argv[1], fileURLToPath2(import.meta.url))) {
59308
+ if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
59162
59309
  const [, , ...cliArgs] = process.argv;
59163
59310
  await startServer(cliArgs, process.env);
59164
59311
  }