context-mode 2.0.2 → 2.1.1

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 ? "9f1916d761e6a8e55ac43858b99dcdcd3cc53caa" : void 0;
11574
+ var BUNDLE_SHA = true ? "2652fe27fc5d4e368fdc38eda49d3011d38e631e" : 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",
@@ -11865,8 +11865,8 @@ var UPGRADE_DATA_DELETED = "user data deleted";
11865
11865
  var UPGRADE_HOST_COMMAND = Object.freeze({
11866
11866
  "claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
11867
11867
  codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
11868
- gemini: "gemini extensions install https://github.com/mksglu/context-mode --ref release --auto-update",
11869
- 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"
11870
11870
  });
11871
11871
  var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
11872
11872
  var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
@@ -11930,6 +11930,9 @@ var HOOKS_KEY = "hooks";
11930
11930
  var STATUS_LINE_KEY = "statusLine";
11931
11931
  var PI_PACKAGES_KEY = "packages";
11932
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}@`;
11933
11936
  var V1_DATA_DIR_NAME = "context-mode";
11934
11937
  var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
11935
11938
  var V1_SESSIONS_DIR_NAME = "sessions";
@@ -12027,6 +12030,7 @@ var DOCTOR_REPORT_FILE_PREFIX = "doctor-";
12027
12030
  var DOCTOR_REPORT_LINE = "Report file: ";
12028
12031
  var DOCTOR_GH_LINE = "File it: ";
12029
12032
  var DOCTOR_URL_LINE = "Or open: ";
12033
+ var DOCTOR_RULES_LINE = "Rules: ";
12030
12034
  var DOCTOR_GH_NEXT = " --";
12031
12035
  var DOCTOR_NOTE_PREFIXES = Object.freeze([
12032
12036
  DOCTOR_ENV_PREFIX,
@@ -12034,10 +12038,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
12034
12038
  DOCTOR_REPORT_LINE,
12035
12039
  DOCTOR_GH_LINE,
12036
12040
  DOCTOR_GH_NEXT.trim(),
12037
- DOCTOR_URL_LINE
12041
+ DOCTOR_URL_LINE,
12042
+ DOCTOR_RULES_LINE
12038
12043
  ]);
12039
12044
  var ISSUE_REPO_SLUG = "mksglu/context-mode";
12040
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
+ ]);
12041
12058
  var ISSUE_URL_MAX = 8e3;
12042
12059
  var ISSUE_FORM_HEADINGS = Object.freeze([
12043
12060
  "Summary",
@@ -12068,16 +12085,16 @@ var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
12068
12085
  var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
12069
12086
  var DOCTOR_MASK = "<masked>";
12070
12087
  var NATIVE_INSTALL = Object.freeze({
12071
- "claude-code": ["claude plugin marketplace add mksglu/context-mode#release", "claude plugin install context-mode@context-mode"],
12072
- codex: ["codex plugin marketplace add mksglu/context-mode@release", "codex plugin add context-mode@context-mode"],
12073
- gemini: ["gemini extensions install https://github.com/mksglu/context-mode --ref release"],
12074
- qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode --ref release"],
12075
- opencode: ["opencode plugin add context-mode@next"],
12076
- pi: ["pi install npm:context-mode@next"],
12077
- "copilot-cli": ["npm i -g context-mode@next", "context-mode setup --agents copilot-cli"],
12078
- vscode: ["npm i -g context-mode@next", "context-mode setup --agents vscode"],
12079
- kiro: ["npm i -g context-mode@next", "context-mode setup --agents kiro"],
12080
- 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"]
12081
12098
  });
12082
12099
  var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
12083
12100
  var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
@@ -12256,7 +12273,7 @@ function outputOf(resp) {
12256
12273
  function textSlot(r) {
12257
12274
  const file2 = r.file;
12258
12275
  if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
12259
- return { text: file2.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
12276
+ return { text: file2.content, put: (o, output) => ({ ...o, file: readFile(o.file, output) }) };
12260
12277
  }
12261
12278
  if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
12262
12279
  if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
@@ -12265,13 +12282,35 @@ function textSlot(r) {
12265
12282
  if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
12266
12283
  return null;
12267
12284
  }
12285
+ function readFile(file2, output) {
12286
+ const start = typeof file2.startLine === "number" ? file2.startLine : 1;
12287
+ const lines = String(file2.content).split("\n");
12288
+ const read3 = typeof file2.numLines === "number" ? file2.numLines : lines.length;
12289
+ const out = output.split("\n");
12290
+ const run = firstRun(lines, out);
12291
+ if (run === null) return { ...file2, content: output, startLine: start + read3, numLines: out.length };
12292
+ const kept = out.slice(0, run.length);
12293
+ if (run.length < out.length) kept.push(out[out.length - 1]);
12294
+ return { ...file2, content: kept.join("\n"), startLine: start + run.at, numLines: kept.length };
12295
+ }
12296
+ function firstRun(lines, out) {
12297
+ let best = null;
12298
+ for (let i = 0; i < lines.length; i++) {
12299
+ if (lines[i] !== out[0]) continue;
12300
+ let n = 1;
12301
+ while (n < out.length && i + n < lines.length && lines[i + n] === out[n]) n++;
12302
+ if (best === null || n > best.length) best = { at: i, length: n };
12303
+ if (n === out.length) break;
12304
+ }
12305
+ return best;
12306
+ }
12268
12307
  function isShellShape(resp) {
12269
12308
  const r = resp;
12270
12309
  return typeof r.stdout === "string" || typeof r.stderr === "string";
12271
12310
  }
12272
12311
  function isGrepContent(resp) {
12273
12312
  const r = resp;
12274
- return r.mode === "content" && typeof r.content === "string";
12313
+ return (r.mode === "content" || r.mode === "count") && typeof r.content === "string";
12275
12314
  }
12276
12315
  function blocksOf(resp) {
12277
12316
  const parts = [];
@@ -12287,6 +12326,7 @@ function readResult2(resp) {
12287
12326
  const text = outputOf(resp);
12288
12327
  const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
12289
12328
  const info = { isError, bytes: Buffer.byteLength(text), text };
12329
+ if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && isShellShape(resp)) info.shape = resp;
12290
12330
  if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
12291
12331
  if (textSlot(resp) !== null) info.shape = resp;
12292
12332
  else info.keep = true;
@@ -12326,8 +12366,11 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
12326
12366
  return ev;
12327
12367
  }
12328
12368
  function replaceShape(ev, output) {
12329
- if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
12330
12369
  const shape = ev.result?.shape;
12370
+ if (ev.tool?.canonicalName === "Bash") {
12371
+ const { persistedOutputPath: _p, persistedOutputSize: _s, ...host } = shape ?? {};
12372
+ return { interrupted: false, ...host, stdout: output, stderr: "" };
12373
+ }
12331
12374
  const slot = shape === void 0 ? null : textSlot(shape);
12332
12375
  if (shape !== void 0 && slot !== null) return slot.put(shape, output);
12333
12376
  if (ev.result?.blocks === true) return [{ type: "text", text: output }];
@@ -12722,7 +12765,8 @@ function encode7(ev, d, _extra) {
12722
12765
  }
12723
12766
 
12724
12767
  // src/adapters/kiro.ts
12725
- var TOOL_NAME_PREFIX8 = "mcp_context-mode_";
12768
+ var TOOL_NAME_PREFIX8 = "mcp_context_mode_";
12769
+ var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
12726
12770
  var KIRO_EVENTS = {
12727
12771
  SessionStart: "SessionStart",
12728
12772
  agentSpawn: "SessionStart",
@@ -12734,6 +12778,7 @@ var KIRO_EVENTS = {
12734
12778
  PostToolUse: "PostToolUse",
12735
12779
  postToolUse: "PostToolUse"
12736
12780
  };
12781
+ var PROMPT_FIELD = "prompt";
12737
12782
  var PROMPT_ENV = "USER_PROMPT";
12738
12783
  var MCP_PREFIX3 = "mcp_";
12739
12784
  var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
@@ -12742,6 +12787,7 @@ var MCP_SEP3 = "_";
12742
12787
  var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
12743
12788
  function canonicalName5(name) {
12744
12789
  if (name.startsWith(TOOL_NAME_PREFIX8)) return name.slice(TOOL_NAME_PREFIX8.length);
12790
+ if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
12745
12791
  if (Object.hasOwn(NATIVE_TO_CANONICAL6, name)) return NATIVE_TO_CANONICAL6[name];
12746
12792
  if (!name.startsWith(MCP_PREFIX3)) return name;
12747
12793
  const rest = name.slice(MCP_PREFIX3.length);
@@ -12762,7 +12808,8 @@ function decode8(raw) {
12762
12808
  const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
12763
12809
  if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
12764
12810
  if (event === "UserPromptSubmit") {
12765
- const prompt = process.env[PROMPT_ENV];
12811
+ const field = p[PROMPT_FIELD];
12812
+ const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
12766
12813
  if (prompt !== void 0) ev.prompt = prompt;
12767
12814
  }
12768
12815
  if (event === "PreToolUse" || event === "PostToolUse") {
@@ -12774,7 +12821,7 @@ function decode8(raw) {
12774
12821
  return ev;
12775
12822
  }
12776
12823
  function encode8(ev, d, _extra) {
12777
- if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
12824
+ if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
12778
12825
  switch (d.kind) {
12779
12826
  case "allow":
12780
12827
  return { stdout: "", exitCode: 0 };
@@ -12885,8 +12932,8 @@ var ADAPTERS = Object.freeze([
12885
12932
  hookTimeoutMs: HOOK_TIMEOUT_MS,
12886
12933
  denyChannel: "deny-reason",
12887
12934
  hookChannel: { kind: "package", path: "hooks/claude-code.json" },
12888
- skillChannel: { kind: "package", path: "claude-code/skills" },
12889
- // ADR-0020, D-HQ-SKILLS-2
12935
+ skillChannel: { kind: "package", path: "skills" },
12936
+ // ADR-0020, D-R33-CC-SKILLS-1: Claude Code always loads <plugin>/skills, shared with gemini and qwen
12890
12937
  decode: decode2,
12891
12938
  encode: encode2
12892
12939
  },
@@ -13075,7 +13122,7 @@ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "
13075
13122
  function dumpRunsThenReplaces(row5) {
13076
13123
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
13077
13124
  }
13078
- var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode"]);
13125
+ var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode", "kiro"]);
13079
13126
  function hasRecall(row5) {
13080
13127
  return RECALL_ROWS.has(row5.id);
13081
13128
  }
@@ -14426,14 +14473,29 @@ function copilotDirOf(env, home) {
14426
14473
  function kiroDirOf(env, home, platform = process.platform) {
14427
14474
  const p = platform === "win32" ? win32 : posix;
14428
14475
  const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
14429
- const dir = env[KIRO_HOME_ENV];
14476
+ const dir = env[KIRO_HOME_ENV]?.trim();
14430
14477
  if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
14431
14478
  if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
14432
14479
  const abs = p.resolve(dir);
14433
- if (p.dirname(abs) === abs) return fallback;
14434
- const up = p.relative(abs, p.resolve(home));
14480
+ const real2 = platform === process.platform ? realOrSelf : (x) => x;
14481
+ const target = real2(abs);
14482
+ if (p.parse(target).root === target) return fallback;
14483
+ const up = p.relative(target, real2(p.resolve(home)));
14435
14484
  if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
14436
- return dir;
14485
+ return abs;
14486
+ }
14487
+ function realOrSelf(path7) {
14488
+ const tail = [];
14489
+ for (let at2 = path7; ; ) {
14490
+ try {
14491
+ return join(realpathSync.native(at2), ...tail.reverse());
14492
+ } catch {
14493
+ const up = dirname(at2);
14494
+ if (up === at2) return path7;
14495
+ tail.push(basename(at2));
14496
+ at2 = up;
14497
+ }
14498
+ }
14437
14499
  }
14438
14500
  function claudeDirOf(env, home) {
14439
14501
  const dir = env[CLAUDE_CONFIG_DIR_ENV];
@@ -19003,7 +19065,7 @@ function cutPoint(src, start, end, scratch) {
19003
19065
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
19004
19066
  return { end: start + r.read, written: r.written };
19005
19067
  }
19006
- function merge2(src, blocks, join28, cap, lineCut) {
19068
+ function merge2(src, blocks, join29, cap, lineCut) {
19007
19069
  const out = [];
19008
19070
  const scratch = new Uint8Array(cap);
19009
19071
  let wide;
@@ -19013,7 +19075,7 @@ function merge2(src, blocks, join28, cap, lineCut) {
19013
19075
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
19014
19076
  };
19015
19077
  for (const b of blocks) {
19016
- if (cur !== void 0 && !join28) {
19078
+ if (cur !== void 0 && !join29) {
19017
19079
  emit(cur.start, cur.end, curBytes);
19018
19080
  cur = void 0;
19019
19081
  }
@@ -20868,21 +20930,43 @@ var ctxBatch = Object.freeze({
20868
20930
  });
20869
20931
 
20870
20932
  // src/core/tools/doctor.ts
20871
- import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync13 } from "node:fs";
20872
- import { basename as basename5, dirname as dirname8, join as join16 } from "node:path";
20933
+ import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync14 } from "node:fs";
20934
+ import { basename as basename5, join as join17 } from "node:path";
20935
+
20936
+ // src/core/ops/bundle-dir.ts
20937
+ import { existsSync as existsSync3 } from "node:fs";
20938
+ import { dirname as dirname5, join as join8 } from "node:path";
20939
+ import { fileURLToPath } from "node:url";
20940
+ function bundleDirOf(argv1, moduleFile) {
20941
+ const own4 = dirname5(argv1);
20942
+ if (existsSync3(join8(own4, SERVER_ENTRY_FILE))) return own4;
20943
+ let dir = dirname5(moduleFile);
20944
+ for (; ; ) {
20945
+ if (existsSync3(join8(dir, SERVER_ENTRY_FILE))) return dir;
20946
+ const up = dirname5(dir);
20947
+ if (up === dir) return own4;
20948
+ dir = up;
20949
+ }
20950
+ }
20951
+ var memo;
20952
+ function ownBundleDir() {
20953
+ const argv1 = process.argv[1] ?? "";
20954
+ if (memo?.argv1 !== argv1) memo = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
20955
+ return memo.dir;
20956
+ }
20873
20957
 
20874
20958
  // src/core/ops/doctor-config.ts
20875
- import { existsSync as existsSync6, readdirSync as readdirSync4 } from "node:fs";
20876
- import { join as join11 } from "node:path";
20959
+ import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
20960
+ import { join as join12 } from "node:path";
20877
20961
 
20878
20962
  // src/core/ops/detect-v1.ts
20879
- import { existsSync as existsSync4, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20963
+ import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20880
20964
  import { tmpdir } from "node:os";
20881
- import { join as join9 } from "node:path";
20965
+ import { join as join10 } from "node:path";
20882
20966
 
20883
20967
  // src/core/ops/host-config.ts
20884
- import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
20885
- import { dirname as dirname5, join as join8 } from "node:path";
20968
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
20969
+ import { dirname as dirname6, join as join9 } from "node:path";
20886
20970
 
20887
20971
  // node_modules/eslint-visitor-keys/lib/visitor-keys.js
20888
20972
  var KEYS2 = {
@@ -22999,10 +23083,10 @@ function formatOf(path7) {
22999
23083
  function readHostConfig(agent, path7) {
23000
23084
  let file2 = path7;
23001
23085
  if (agent === "opencode") {
23002
- const jsonc = join8(dirname5(path7), OPENCODE_CONFIG_FILES[0]);
23003
- if (existsSync3(jsonc)) file2 = jsonc;
23086
+ const jsonc = join9(dirname6(path7), OPENCODE_CONFIG_FILES[0]);
23087
+ if (existsSync4(jsonc)) file2 = jsonc;
23004
23088
  }
23005
- const raw = existsSync3(file2) ? readFileSync6(file2, "utf8") : "";
23089
+ const raw = existsSync4(file2) ? readFileSync6(file2, "utf8") : "";
23006
23090
  return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
23007
23091
  }
23008
23092
  function stripJsonComments(text) {
@@ -23347,7 +23431,7 @@ function setText(agent, path7, text, format, key, value) {
23347
23431
  }
23348
23432
  }
23349
23433
  function serverScript() {
23350
- return join8(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23434
+ return join9(dirname6(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23351
23435
  }
23352
23436
  function isNodeCommand(command) {
23353
23437
  if (typeof command !== "string") return false;
@@ -23363,7 +23447,7 @@ function ownMcpValue(agent, node3, server) {
23363
23447
  return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
23364
23448
  }
23365
23449
  function opencodePluginFile() {
23366
- return dirname5(process.argv[1] ?? "");
23450
+ return ownBundleDir();
23367
23451
  }
23368
23452
  function listTarget(key, own4, v1, alt = []) {
23369
23453
  return {
@@ -23522,7 +23606,7 @@ function flatCommands(events, prefix) {
23522
23606
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
23523
23607
  var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep4) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep4) + sep4));
23524
23608
  function dataDir(dir, reason, out) {
23525
- if (existsSync4(dir)) out.push(finding(dir, "", reason));
23609
+ if (existsSync5(dir)) out.push(finding(dir, "", reason));
23526
23610
  }
23527
23611
  function mcpEntry(file2, doc, out) {
23528
23612
  if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
@@ -23530,7 +23614,7 @@ function mcpEntry(file2, doc, out) {
23530
23614
  }
23531
23615
  }
23532
23616
  function claudeShapeSettings(agentHome, out) {
23533
- const file2 = join9(agentHome, SETTINGS_FILE);
23617
+ const file2 = join10(agentHome, SETTINGS_FILE);
23534
23618
  const doc = readJson(file2);
23535
23619
  for (const c of nestedCommands(doc)) {
23536
23620
  if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
@@ -23550,49 +23634,49 @@ function v1HookFile(file2, out) {
23550
23634
  function scanClaudeCode(home, agentHome, out) {
23551
23635
  claudeShapeSettings(agentHome, out);
23552
23636
  for (const ext of V1_CACHE_HEAL_EXTS) {
23553
- const file2 = join9(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23554
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23637
+ const file2 = join10(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23638
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23555
23639
  }
23556
- const userFile = join9(home, CLAUDE_USER_CONFIG_FILE);
23640
+ const userFile = join10(home, CLAUDE_USER_CONFIG_FILE);
23557
23641
  mcpEntry(userFile, readJson(userFile), out);
23558
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23642
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23559
23643
  }
23560
23644
  function scanCodex(agentHome, out) {
23561
- const hooksFile = join9(agentHome, HOOKS_JSON_FILE);
23645
+ const hooksFile = join10(agentHome, HOOKS_JSON_FILE);
23562
23646
  for (const c of nestedCommands(readJson(hooksFile))) {
23563
23647
  if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
23564
23648
  out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
23565
23649
  }
23566
23650
  }
23567
- const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
23651
+ const tomlFile = join10(agentHome, CONFIG_TOML_FILE);
23568
23652
  const config4 = readTomlValue(tomlFile);
23569
23653
  for (const span2 of readTomlTables(tomlFile)) {
23570
23654
  if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
23571
23655
  if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
23572
23656
  out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
23573
23657
  }
23574
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23658
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23575
23659
  }
23576
23660
  function scanGemini(agentHome, out) {
23577
- const file2 = join9(agentHome, SETTINGS_FILE);
23661
+ const file2 = join10(agentHome, SETTINGS_FILE);
23578
23662
  for (const c of nestedCommands(readJson(file2))) {
23579
23663
  if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
23580
23664
  }
23581
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23665
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23582
23666
  }
23583
23667
  function scanVscode(agentHome, project, out) {
23584
23668
  if (project !== void 0) {
23585
- v1HookFile(join9(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23586
- const mcpFile2 = join9(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23669
+ v1HookFile(join10(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23670
+ const mcpFile2 = join10(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23587
23671
  const doc = readJson(mcpFile2);
23588
23672
  const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
23589
23673
  const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
23590
23674
  if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
23591
23675
  out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
23592
23676
  }
23593
- dataDir(join9(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23677
+ dataDir(join10(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23594
23678
  }
23595
- dataDir(join9(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23679
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23596
23680
  }
23597
23681
  function jsonFiles(dir) {
23598
23682
  try {
@@ -23602,10 +23686,10 @@ function jsonFiles(dir) {
23602
23686
  }
23603
23687
  }
23604
23688
  function scanKiro(agentHome, project, out) {
23605
- const agentsDir = join9(agentHome, KIRO_AGENTS_DIR);
23606
- const defaultFile = join9(agentHome, ...KIRO_AGENT_FILE);
23689
+ const agentsDir = join10(agentHome, KIRO_AGENTS_DIR);
23690
+ const defaultFile = join10(agentHome, ...KIRO_AGENT_FILE);
23607
23691
  for (const name of jsonFiles(agentsDir)) {
23608
- const file2 = join9(agentsDir, name);
23692
+ const file2 = join10(agentsDir, name);
23609
23693
  const doc = readJson(file2);
23610
23694
  if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
23611
23695
  out.push(finding(file2, "", V1_REASON.kiroAgentFile));
@@ -23616,25 +23700,25 @@ function scanKiro(agentHome, project, out) {
23616
23700
  if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
23617
23701
  }
23618
23702
  }
23619
- const steeringDocs = [join9(agentHome, ...KIRO_STEERING_FILE)];
23620
- if (project !== void 0) steeringDocs.push(join9(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23703
+ const steeringDocs = [join10(agentHome, ...KIRO_STEERING_FILE)];
23704
+ if (project !== void 0) steeringDocs.push(join10(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23621
23705
  for (const file2 of steeringDocs) {
23622
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23706
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23623
23707
  }
23624
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23708
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23625
23709
  }
23626
23710
  function scanPi(piAgentDir, agentHome, out) {
23627
- const file2 = join9(piAgentDir, SETTINGS_FILE);
23711
+ const file2 = join10(piAgentDir, SETTINGS_FILE);
23628
23712
  const doc = readJson(file2);
23629
23713
  listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
23630
23714
  const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
23631
23715
  if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
23632
23716
  });
23633
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23717
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23634
23718
  }
23635
23719
  function scanOpencode(agentHome, out) {
23636
23720
  for (const name of OPENCODE_CONFIG_FILES) {
23637
- const file2 = join9(agentHome, name);
23721
+ const file2 = join10(agentHome, name);
23638
23722
  const doc = readJson(file2);
23639
23723
  if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
23640
23724
  doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
@@ -23644,13 +23728,13 @@ function scanOpencode(agentHome, out) {
23644
23728
  }
23645
23729
  }
23646
23730
  function scanZcode(agentHome, out) {
23647
- const configFile = join9(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23731
+ const configFile = join10(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23648
23732
  const config4 = readJson(configFile);
23649
23733
  const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
23650
23734
  for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
23651
23735
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
23652
23736
  }
23653
- const hooksFile = join9(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23737
+ const hooksFile = join10(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23654
23738
  for (const c of nestedCommands(readJson(hooksFile))) {
23655
23739
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
23656
23740
  }
@@ -23674,14 +23758,14 @@ function firstTmpMatch(dir) {
23674
23758
  }
23675
23759
  }
23676
23760
  function scanAll(home, tmp, out) {
23677
- const root = join9(home, DATA_ROOT.slice(1));
23678
- for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join9(root, name), V1_REASON.dataRoot, out);
23761
+ const root = join10(home, DATA_ROOT.slice(1));
23762
+ for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join10(root, name), V1_REASON.dataRoot, out);
23679
23763
  if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
23680
23764
  }
23681
23765
  function detectV1(agent, home, scope = {}) {
23682
23766
  const out = [];
23683
23767
  const project = scope.project;
23684
- 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]);
23768
+ 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]);
23685
23769
  switch (agent) {
23686
23770
  case "claude-code":
23687
23771
  scanClaudeCode(home, agentHome, out);
@@ -23694,11 +23778,11 @@ function detectV1(agent, home, scope = {}) {
23694
23778
  break;
23695
23779
  case "qwen":
23696
23780
  claudeShapeSettings(agentHome, out);
23697
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23781
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23698
23782
  break;
23699
23783
  case "copilot-cli":
23700
- v1HookFile(join9(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23701
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23784
+ v1HookFile(join10(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23785
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23702
23786
  break;
23703
23787
  case "vscode":
23704
23788
  scanVscode(agentHome, project, out);
@@ -23707,7 +23791,7 @@ function detectV1(agent, home, scope = {}) {
23707
23791
  scanKiro(agentHome, project, out);
23708
23792
  break;
23709
23793
  case "pi":
23710
- scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join9(agentHome, PI_AGENT_DIR), agentHome, out);
23794
+ scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join10(agentHome, PI_AGENT_DIR), agentHome, out);
23711
23795
  break;
23712
23796
  // D-WIN-PIDIR-1: empty is unset
23713
23797
  case "opencode":
@@ -23722,9 +23806,9 @@ function detectV1(agent, home, scope = {}) {
23722
23806
  }
23723
23807
 
23724
23808
  // src/core/ops/plugin-root.ts
23725
- import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23726
- import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep3 } from "node:path";
23727
- import { fileURLToPath } from "node:url";
23809
+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23810
+ import { dirname as dirname7, isAbsolute as isAbsolute2, join as join11, sep as sep3 } from "node:path";
23811
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
23728
23812
  function missing(agent, path7) {
23729
23813
  return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path7 });
23730
23814
  }
@@ -23771,8 +23855,8 @@ var readOrNull = (file2) => {
23771
23855
  };
23772
23856
  var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
23773
23857
  function enabledPlugins(claudeDir, project) {
23774
- const files = [join10(claudeDir, SETTINGS_FILE)];
23775
- if (project !== void 0) files.push(join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23858
+ const files = [join11(claudeDir, SETTINGS_FILE)];
23859
+ if (project !== void 0) files.push(join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23776
23860
  const out = {};
23777
23861
  for (const file2 of files) {
23778
23862
  const text = readOrNull(file2);
@@ -23785,13 +23869,13 @@ function enabledPlugins(claudeDir, project) {
23785
23869
  function marketplaceChoice(env, worktree) {
23786
23870
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23787
23871
  const script = process.argv[1];
23788
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23872
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23789
23873
  const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
23790
23874
  if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
23791
- const record6 = readOrNull(join10(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23875
+ const record6 = readOrNull(join11(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23792
23876
  const recorded = record6 === null ? [] : recordedInstalls(record6);
23793
23877
  if (recorded.length === 0) return { record: false };
23794
- const live = recorded.filter((r) => existsSync5(r.installPath));
23878
+ const live = recorded.filter((r) => existsSync6(r.installPath));
23795
23879
  const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
23796
23880
  if (mine !== void 0) return { root: mine.installPath };
23797
23881
  const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
@@ -23811,18 +23895,18 @@ function marketplaceChoice(env, worktree) {
23811
23895
  }
23812
23896
  function marketplaceRoot(adapter, env, worktree) {
23813
23897
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23814
- const plugins = join10(claudeDir, HOST_PLUGINS_DIR_NAME);
23815
- const cache = join10(plugins, PLUGIN_CACHE_DIR_NAME);
23898
+ const plugins = join11(claudeDir, HOST_PLUGINS_DIR_NAME);
23899
+ const cache = join11(plugins, PLUGIN_CACHE_DIR_NAME);
23816
23900
  const script = process.argv[1];
23817
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23901
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23818
23902
  const choice = marketplaceChoice(env, worktree);
23819
23903
  if ("root" in choice) return choice.root;
23820
23904
  if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
23821
23905
  const cacheReal = realOrNull(cache);
23822
- if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync5(join10(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23823
- const pattern = join10(cache, "*", PLUGIN_NAME);
23824
- if (!existsSync5(cache)) throw missing(adapter.id, pattern);
23825
- const found = readdirSync3(cache).sort().map((marketplace) => join10(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync5(dir));
23906
+ if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync6(join11(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23907
+ const pattern = join11(cache, "*", PLUGIN_NAME);
23908
+ if (!existsSync6(cache)) throw missing(adapter.id, pattern);
23909
+ const found = readdirSync3(cache).sort().map((marketplace) => join11(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
23826
23910
  if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
23827
23911
  return found[0];
23828
23912
  }
@@ -23830,13 +23914,13 @@ function configEntryRoot(adapter, env) {
23830
23914
  const spec = OWN_MCP_ENTRY[adapter.id];
23831
23915
  if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
23832
23916
  const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
23833
- if (!existsSync5(file2)) throw missing(adapter.id, file2);
23917
+ if (!existsSync6(file2)) throw missing(adapter.id, file2);
23834
23918
  const current = readHostConfig(adapter.id, file2);
23835
23919
  const value = parseHostConfig(adapter.id, file2, current.text, current.format);
23836
23920
  const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
23837
23921
  const script = Array.isArray(args) ? args[0] : void 0;
23838
23922
  if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
23839
- return dirname6(script);
23923
+ return dirname7(script);
23840
23924
  }
23841
23925
  function candidate(adapter, env, worktree) {
23842
23926
  switch (adapter.installMode) {
@@ -23847,11 +23931,11 @@ function candidate(adapter, env, worktree) {
23847
23931
  case "hooks+mcp":
23848
23932
  return configEntryRoot(adapter, env);
23849
23933
  case "extension":
23850
- return join10(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23934
+ return join11(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23851
23935
  case "plugin":
23852
- return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23936
+ return join11(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23853
23937
  case "in-process":
23854
- return dirname6(fileURLToPath(import.meta.url));
23938
+ return dirname7(fileURLToPath2(import.meta.url));
23855
23939
  }
23856
23940
  }
23857
23941
  function resolvePluginRoot(adapter, env, worktree) {
@@ -23940,11 +24024,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
23940
24024
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
23941
24025
  function mcpFile(row5, home, env) {
23942
24026
  const spec = OWN_MCP_ENTRY[row5.id];
23943
- if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
24027
+ if (row5.id === "codex") return join12(codexDirOf(env, home), CONFIG_TOML_FILE);
23944
24028
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
23945
- if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
24029
+ if (row5.id === "opencode") return join12(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
23946
24030
  if (row5.id === "pi") {
23947
- return join11(piAgentDirOf(env, home), SETTINGS_FILE);
24031
+ return join12(piAgentDirOf(env, home), SETTINGS_FILE);
23948
24032
  }
23949
24033
  return null;
23950
24034
  }
@@ -23957,27 +24041,27 @@ function codexNativeDir(env, home) {
23957
24041
  const codexDir = codexDirOf(env, home);
23958
24042
  let enabled;
23959
24043
  try {
23960
- enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24044
+ enabled = hostConfigValueAt(readParsed("codex", join12(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
23961
24045
  } catch {
23962
24046
  return null;
23963
24047
  }
23964
24048
  if (enabled !== true) return null;
23965
- const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
23966
- if (!existsSync6(cache)) return null;
24049
+ const cache = join12(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24050
+ if (!existsSync7(cache)) return null;
23967
24051
  const found = [];
23968
24052
  for (const market of readdirSync4(cache)) {
23969
- const plugin = join11(cache, market, SERVER_KEY);
23970
- if (!existsSync6(plugin)) continue;
24053
+ const plugin = join12(cache, market, SERVER_KEY);
24054
+ if (!existsSync7(plugin)) continue;
23971
24055
  for (const version4 of readdirSync4(plugin).sort()) {
23972
- const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
23973
- if (existsSync6(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24056
+ const dir = join12(plugin, version4, CODEX_PLUGIN_SUBDIR);
24057
+ if (existsSync7(join12(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
23974
24058
  }
23975
24059
  }
23976
24060
  return found.length === 0 ? null : found[found.length - 1];
23977
24061
  }
23978
24062
  function nativeMcpWrong(dir, row5) {
23979
24063
  try {
23980
- const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24064
+ const entry = hostConfigValueAt(readParsed(row5.id, join12(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
23981
24065
  if (!isObject4(entry)) return true;
23982
24066
  const args = list2(entry[MCP_ARGS_FIELD]);
23983
24067
  const script = args[0];
@@ -23986,6 +24070,17 @@ function nativeMcpWrong(dir, row5) {
23986
24070
  return true;
23987
24071
  }
23988
24072
  }
24073
+ function isOwnOpencodeEntry(entry, key, own4) {
24074
+ const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
24075
+ if (typeof spec !== "string") return false;
24076
+ if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
24077
+ return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
24078
+ }
24079
+ function opencodeListed(file2) {
24080
+ const { value } = readParsed("opencode", file2);
24081
+ const own4 = [opencodePluginFile()];
24082
+ return [OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)));
24083
+ }
23989
24084
  function mcpWrong(row5, home, env, worktree) {
23990
24085
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
23991
24086
  if (native !== null) return nativeMcpWrong(native, row5);
@@ -23995,6 +24090,7 @@ function mcpWrong(row5, home, env, worktree) {
23995
24090
  resolvePluginRoot(row5, env, worktree);
23996
24091
  return false;
23997
24092
  }
24093
+ if (row5.id === "opencode") return !opencodeListed(file2);
23998
24094
  const cur = readHostConfig(row5.id, file2);
23999
24095
  return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
24000
24096
  } catch {
@@ -24004,7 +24100,7 @@ function mcpWrong(row5, home, env, worktree) {
24004
24100
  function hookFile(row5, spec, home, env, worktree) {
24005
24101
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
24006
24102
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24007
- 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);
24103
+ 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);
24008
24104
  return file2;
24009
24105
  }
24010
24106
  function hookParts(row5, home, env, worktree) {
@@ -24015,7 +24111,7 @@ function hookParts(row5, home, env, worktree) {
24015
24111
  const file2 = hookFile(row5, spec, home, env, worktree);
24016
24112
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24017
24113
  if (row5.id === "codex") {
24018
- const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24114
+ const config4 = readParsed(row5.id, join12(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24019
24115
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24020
24116
  }
24021
24117
  } catch {
@@ -24073,10 +24169,10 @@ function parsedOrNull(agent, file2, jsonc) {
24073
24169
  }
24074
24170
  function checkDoubleFire(agent, worktree) {
24075
24171
  if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
24076
- const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24172
+ const claude = parsedOrNull(agent, join12(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24077
24173
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
24078
24174
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
24079
- const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24175
+ const vscode = parsedOrNull(agent, join12(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24080
24176
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
24081
24177
  return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
24082
24178
  }
@@ -24087,7 +24183,7 @@ function configPaths(row5, env, worktree) {
24087
24183
  const mcp = mcpFile(row5, home, env);
24088
24184
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
24089
24185
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24090
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
24186
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join12(native, CODEX_PLUGIN_MCP_FILE) });
24091
24187
  const spec = HOOK_HOST_FILE[row5.id];
24092
24188
  if (spec !== null) {
24093
24189
  try {
@@ -24107,7 +24203,7 @@ function configPaths(row5, env, worktree) {
24107
24203
  }
24108
24204
 
24109
24205
  // src/core/ops/doctor-db.ts
24110
- import { existsSync as existsSync7, statSync as statSync5 } from "node:fs";
24206
+ import { existsSync as existsSync8, statSync as statSync5 } from "node:fs";
24111
24207
  var unknown2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
24112
24208
  var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
24113
24209
  var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
@@ -24149,15 +24245,15 @@ function orphanFiles(dbPath) {
24149
24245
  const files = [];
24150
24246
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
24151
24247
  const path7 = dbPath + suffix;
24152
- if (existsSync7(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24248
+ if (existsSync8(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24153
24249
  }
24154
- return files.length > 0 && !existsSync7(dbPath) ? files : [];
24250
+ return files.length > 0 && !existsSync8(dbPath) ? files : [];
24155
24251
  }
24156
24252
  async function checkDb(project) {
24157
24253
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
24158
24254
  const orphan = orphanFiles(project.dbPath);
24159
24255
  if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
24160
- if (!existsSync7(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24256
+ if (!existsSync8(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24161
24257
  const sqlite = await loadSqlite2();
24162
24258
  if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
24163
24259
  let raw = null;
@@ -24183,7 +24279,7 @@ async function checkDb(project) {
24183
24279
  }
24184
24280
  }
24185
24281
  async function checkIndex(project) {
24186
- if (!existsSync7(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24282
+ if (!existsSync8(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24187
24283
  const sqlite = await loadSqlite2();
24188
24284
  if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
24189
24285
  let raw = null;
@@ -24200,8 +24296,8 @@ async function checkIndex(project) {
24200
24296
  }
24201
24297
 
24202
24298
  // src/core/ops/doctor-env.ts
24203
- import { existsSync as existsSync8, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24204
- import { isAbsolute as isAbsolute3, join as join12, relative as relative2 } from "node:path";
24299
+ import { existsSync as existsSync9, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24300
+ import { isAbsolute as isAbsolute3, join as join13, relative as relative2 } from "node:path";
24205
24301
  function pass3(id, detail = DOCTOR_PASS_DETAIL) {
24206
24302
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
24207
24303
  }
@@ -24213,7 +24309,7 @@ function fail4(id, detail, fixCommand) {
24213
24309
  }
24214
24310
  function bundleVersion(bundleDir2) {
24215
24311
  try {
24216
- const v = JSON.parse(readFileSync9(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24312
+ const v = JSON.parse(readFileSync9(join13(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24217
24313
  return typeof v === "string" && v !== "" ? v : void 0;
24218
24314
  } catch {
24219
24315
  return void 0;
@@ -24363,7 +24459,7 @@ function checkMcp(ctx) {
24363
24459
  return named2 || versioned ? pass3("D6") : unknown3("D6", D6_UNKNOWN_DETAIL);
24364
24460
  }
24365
24461
  function piCwdInside(worktree, piCwd) {
24366
- if (piCwd === void 0 || !existsSync8(piCwd)) return false;
24462
+ if (piCwd === void 0 || !existsSync9(piCwd)) return false;
24367
24463
  const rel = relative2(worktree, realpathSync5.native(piCwd));
24368
24464
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
24369
24465
  }
@@ -24384,13 +24480,13 @@ function checkShell(env) {
24384
24480
  }
24385
24481
 
24386
24482
  // src/core/ops/doctor-hook.ts
24387
- import { existsSync as existsSync10, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24483
+ import { existsSync as existsSync11, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24388
24484
  import { tmpdir as tmpdir2 } from "node:os";
24389
24485
  import path6 from "node:path";
24390
24486
 
24391
24487
  // src/setup/codex-trust.ts
24392
24488
  import { createHash } from "node:crypto";
24393
- import { existsSync as existsSync9, realpathSync as realpathSync6 } from "node:fs";
24489
+ import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
24394
24490
  import path5 from "node:path";
24395
24491
  import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
24396
24492
 
@@ -24488,6 +24584,7 @@ var LIST_TIMEOUT_MS = 15e3;
24488
24584
  var EXIT_GRACE_MS = 5e3;
24489
24585
  var PLUGIN_SOURCE = "plugin";
24490
24586
  var TRUSTED = "trusted";
24587
+ var UNTRUSTED = "untrusted";
24491
24588
  function pluginHooksFromReply(m, pluginId) {
24492
24589
  const out = [];
24493
24590
  if (!isObj2(m) || !isObj2(m.result) || !Array.isArray(m.result.data)) return out;
@@ -24497,7 +24594,8 @@ function pluginHooksFromReply(m, pluginId) {
24497
24594
  if (!isObj2(h) || h.source !== PLUGIN_SOURCE || h.pluginId !== pluginId) continue;
24498
24595
  if (typeof h.key !== "string" || typeof h.currentHash !== "string") continue;
24499
24596
  if (out.some((x) => x.key === h.key)) continue;
24500
- out.push({ key: h.key, hash: h.currentHash, trusted: h.trustStatus === TRUSTED });
24597
+ const status = typeof h.trustStatus === "string" ? h.trustStatus : UNTRUSTED;
24598
+ out.push({ key: h.key, hash: h.currentHash, trusted: status === TRUSTED, status });
24501
24599
  }
24502
24600
  }
24503
24601
  return out;
@@ -24590,7 +24688,11 @@ var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
24590
24688
  function untrustedPluginHooksDetail(hooks) {
24591
24689
  const bad = hooks.filter((h) => !h.trusted);
24592
24690
  if (!bad.length) return void 0;
24593
- return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks untrusted, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24691
+ const counts = /* @__PURE__ */ new Map();
24692
+ for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
24693
+ const words = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
24694
+ const state = words.length === 1 ? words[0][0] : `${words.map(([w]) => w).join(" or ")} (${words.map(([w, n]) => `${n} ${w}`).join(", ")})`;
24695
+ return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24594
24696
  }
24595
24697
 
24596
24698
  // src/core/ops/doctor-hook.ts
@@ -24607,7 +24709,7 @@ function isObject5(v) {
24607
24709
  }
24608
24710
  function loadFixture(bundleDir2, agent) {
24609
24711
  const file2 = path6.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
24610
- if (!existsSync10(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24712
+ if (!existsSync11(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24611
24713
  let all;
24612
24714
  try {
24613
24715
  all = JSON.parse(hostText(readFileSync10(file2, "utf8")));
@@ -24746,7 +24848,7 @@ async function checkHookRoundTrip(i) {
24746
24848
  const trust = await codexPluginTrust(i);
24747
24849
  if (trust !== null) return trust;
24748
24850
  }
24749
- if (i.agent === "codex" && existsSync10(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24851
+ if (i.agent === "codex" && existsSync11(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24750
24852
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
24751
24853
  }
24752
24854
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -24785,17 +24887,17 @@ async function checkHookRoundTrip(i) {
24785
24887
  }
24786
24888
 
24787
24889
  // src/core/ops/db-heal.ts
24788
- import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
24789
- import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
24890
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
24891
+ import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
24790
24892
 
24791
24893
  // src/core/store/owners.ts
24792
24894
  import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
24793
- import { basename as basename3, join as join13 } from "node:path";
24895
+ import { basename as basename3, join as join14 } from "node:path";
24794
24896
  function ownersDir(configDir, projectKey) {
24795
- return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24897
+ return join14(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24796
24898
  }
24797
24899
  function ownerFile(configDir, projectKey, serverId) {
24798
- return join13(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
24900
+ return join14(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
24799
24901
  }
24800
24902
  function errCode2(err) {
24801
24903
  return err.code;
@@ -24830,7 +24932,7 @@ function listLiveOwners(configDir, projectKey) {
24830
24932
  const live = [];
24831
24933
  for (const name of names) {
24832
24934
  if (!name.endsWith(OWNER_PID_EXT)) continue;
24833
- const file2 = join13(dir, name);
24935
+ const file2 = join14(dir, name);
24834
24936
  let text;
24835
24937
  try {
24836
24938
  text = readFileSync11(file2, "utf8");
@@ -24879,7 +24981,7 @@ function renameAside(dbPath) {
24879
24981
  const ts = String(Date.now());
24880
24982
  for (const suffix of DB_SIBLING_SUFFIXES) {
24881
24983
  const file2 = dbPath + suffix;
24882
- if (existsSync11(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24984
+ if (existsSync12(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24883
24985
  }
24884
24986
  return ts;
24885
24987
  }
@@ -24902,7 +25004,7 @@ function utcStamp(now) {
24902
25004
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
24903
25005
  }
24904
25006
  function makeOrphanDir(projectDir) {
24905
- const base = join14(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
25007
+ const base = join15(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24906
25008
  for (let n = 1; ; n += 1) {
24907
25009
  const dir = n === 1 ? base : base + "-" + String(n);
24908
25010
  try {
@@ -24917,9 +25019,9 @@ async function healOrphan(project, files, row5) {
24917
25019
  const moved = [];
24918
25020
  let dir = "";
24919
25021
  try {
24920
- dir = makeOrphanDir(dirname7(project.dbPath));
25022
+ dir = makeOrphanDir(dirname8(project.dbPath));
24921
25023
  for (const f of files) {
24922
- const to = join14(dir, basename4(f.path));
25024
+ const to = join15(dir, basename4(f.path));
24923
25025
  renameWithRetry(f.path, to);
24924
25026
  moved.push({ path: to, bytes: f.bytes });
24925
25027
  }
@@ -24986,8 +25088,8 @@ function buildReportHead(input) {
24986
25088
 
24987
25089
  // src/core/ops/doctor-issue.ts
24988
25090
  import { spawnSync as spawnSync3 } from "node:child_process";
24989
- import { closeSync, existsSync as existsSync12, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
24990
- import { delimiter, join as join15 } from "node:path";
25091
+ import { closeSync, existsSync as existsSync13, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
25092
+ import { delimiter, join as join16 } from "node:path";
24991
25093
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
24992
25094
  function tildeOf(env) {
24993
25095
  const home = homeDirOf(env);
@@ -25028,8 +25130,8 @@ function onPath(env, tool) {
25028
25130
  const out = [];
25029
25131
  for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
25030
25132
  if (dir === "") continue;
25031
- for (const n of names) if (existsSync12(join15(dir, n))) {
25032
- out.push(join15(dir, n));
25133
+ for (const n of names) if (existsSync13(join16(dir, n))) {
25134
+ out.push(join16(dir, n));
25033
25135
  break;
25034
25136
  }
25035
25137
  }
@@ -25037,7 +25139,7 @@ function onPath(env, tool) {
25037
25139
  }
25038
25140
  function hookLogTail(env) {
25039
25141
  const file2 = hookLogPath(env);
25040
- if (file2 === "" || !existsSync12(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25142
+ if (file2 === "" || !existsSync13(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25041
25143
  try {
25042
25144
  const fd = openSync(file2, "r");
25043
25145
  try {
@@ -25057,7 +25159,7 @@ function hookLogTail(env) {
25057
25159
  }
25058
25160
  async function journalRows(ctx) {
25059
25161
  const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
25060
- if (!existsSync12(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25162
+ if (!existsSync13(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25061
25163
  try {
25062
25164
  const db = await openDb(ctx.project, { readOnly: true });
25063
25165
  try {
@@ -25075,15 +25177,15 @@ function agentConfig(adapter, env, worktree) {
25075
25177
  const home = homeDirOf(env);
25076
25178
  const files = configPaths(adapter, env, worktree);
25077
25179
  if (home !== null) {
25078
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join15(claudeDirOf(env, home), SETTINGS_FILE) });
25079
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join15(codexDirOf(env, home), CONFIG_TOML_FILE) });
25180
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join16(claudeDirOf(env, home), SETTINGS_FILE) });
25181
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join16(codexDirOf(env, home), CONFIG_TOML_FILE) });
25080
25182
  }
25081
25183
  const out = [];
25082
25184
  const seen = /* @__PURE__ */ new Set();
25083
25185
  for (const f of files) {
25084
25186
  if (seen.has(f.path)) continue;
25085
25187
  seen.add(f.path);
25086
- if (!existsSync12(f.path)) {
25188
+ if (!existsSync13(f.path)) {
25087
25189
  out.push(`${f.label}: ${f.path} (absent)`);
25088
25190
  continue;
25089
25191
  }
@@ -25159,14 +25261,14 @@ async function buildIssueBody(i) {
25159
25261
  async function writeIssueReport(i) {
25160
25262
  const tilde = tildeOf(i.env);
25161
25263
  const body = await buildIssueBody(i);
25162
- const dir = join15(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25264
+ const dir = join16(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25163
25265
  mkdirSync6(dir, { recursive: true });
25164
- const file2 = join15(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25266
+ const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25165
25267
  writeFileSync3(file2, body);
25166
25268
  const shown2 = tilde(file2);
25167
25269
  const title = issueTitle(i.adapter.id, i.rows);
25168
25270
  const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
25169
- 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))];
25271
+ 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];
25170
25272
  }
25171
25273
  function formUrl(title, summary) {
25172
25274
  const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
@@ -25188,7 +25290,7 @@ async function guard(id, run) {
25188
25290
  }
25189
25291
  }
25190
25292
  async function codexDb(ctx, adapter) {
25191
- if (adapter.id !== "codex" || !existsSync13(ctx.project.dbPath)) return null;
25293
+ if (adapter.id !== "codex" || !existsSync14(ctx.project.dbPath)) return null;
25192
25294
  try {
25193
25295
  return await openDb(ctx.project, { readOnly: true });
25194
25296
  } catch {
@@ -25218,11 +25320,11 @@ async function hookRow(ctx, adapter, host) {
25218
25320
  }
25219
25321
  }
25220
25322
  function ownServerId(configDir, projectKey) {
25221
- const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25222
- if (!existsSync13(dir)) return "";
25323
+ const dir = join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25324
+ if (!existsSync14(dir)) return "";
25223
25325
  for (const name of readdirSync6(dir)) {
25224
25326
  if (!name.endsWith(OWNER_PID_EXT)) continue;
25225
- if (readFileSync13(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25327
+ if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25226
25328
  }
25227
25329
  return "";
25228
25330
  }
@@ -25305,7 +25407,7 @@ async function doctorReply(ctx, host) {
25305
25407
  return { text, isError: false, sandboxBytes: bytes5 };
25306
25408
  }
25307
25409
  async function handler2(_input, ctx) {
25308
- return doctorReply(ctx, { env: process.env, bundleDir: dirname8(process.argv[1]), piCwd: void 0 });
25410
+ return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: void 0 });
25309
25411
  }
25310
25412
  var ctxDoctor = Object.freeze({
25311
25413
  name: "ctx_doctor",
@@ -25317,9 +25419,9 @@ var ctxDoctor = Object.freeze({
25317
25419
  });
25318
25420
 
25319
25421
  // src/core/tools/execute.ts
25320
- import { existsSync as existsSync14, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25422
+ import { existsSync as existsSync15, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25321
25423
  import { tmpdir as tmpdir3 } from "node:os";
25322
- import { dirname as dirname9, join as join17, parse as parse3, resolve as resolve6 } from "node:path";
25424
+ import { dirname as dirname10, join as join18, parse as parse3, resolve as resolve6 } from "node:path";
25323
25425
 
25324
25426
  // src/core/sandbox/win-build.ts
25325
25427
  var SEPARATORS2 = ";&|(\n";
@@ -25403,7 +25505,7 @@ function schemaLine(issue4) {
25403
25505
  }
25404
25506
  function fileError(given, abs, root) {
25405
25507
  let dir = abs;
25406
- while (!existsSync14(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
25508
+ while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
25407
25509
  if (isInside(root, dir)) return null;
25408
25510
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
25409
25511
  }
@@ -25484,8 +25586,8 @@ async function handler3(raw, ctx) {
25484
25586
  if (takesDashC(input.language, runtime)) {
25485
25587
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
25486
25588
  } else {
25487
- tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
25488
- const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25589
+ tmpDir = mkdtempSync2(join18(tmpdir3(), TMP_PREFIX));
25590
+ const file2 = join18(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25489
25591
  writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
25490
25592
  argv = scriptArgv(input.language, runtime, file2);
25491
25593
  }
@@ -25520,12 +25622,12 @@ var ctxExecute = {
25520
25622
  };
25521
25623
 
25522
25624
  // src/core/tools/index.ts
25523
- import { existsSync as existsSync15, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25524
- import { dirname as dirname10, extname, join as join19, relative as relative3, resolve as resolve7 } from "node:path";
25625
+ import { existsSync as existsSync16, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25626
+ import { dirname as dirname11, extname, join as join20, relative as relative3, resolve as resolve7 } from "node:path";
25525
25627
 
25526
25628
  // src/core/index/walk.ts
25527
25629
  import { readdirSync as readdirSync7, readFileSync as readFileSync14, realpathSync as realpathSync9, statSync as statSync7 } from "node:fs";
25528
- import { join as join18 } from "node:path";
25630
+ import { join as join19 } from "node:path";
25529
25631
  var GITIGNORE = ".gitignore";
25530
25632
  var GIT_DIR = ".git";
25531
25633
  function walkDir(root, containmentRoot) {
@@ -25534,7 +25636,7 @@ function walkDir(root, containmentRoot) {
25534
25636
  const found = [];
25535
25637
  visit(real2, [], [], containmentRoot, /* @__PURE__ */ new Set([real2]), found);
25536
25638
  found.sort(compareFound);
25537
- return found.map((f) => ({ absPath: f.absPath, relPath: join18(...f.dir, f.name) }));
25639
+ return found.map((f) => ({ absPath: f.absPath, relPath: join19(...f.dir, f.name) }));
25538
25640
  }
25539
25641
  function visit(abs, rel, parent, contain, seen, found) {
25540
25642
  let entries;
@@ -25543,10 +25645,10 @@ function visit(abs, rel, parent, contain, seen, found) {
25543
25645
  } catch {
25544
25646
  return;
25545
25647
  }
25546
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join18(abs, GITIGNORE), rel)) : parent;
25648
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join19(abs, GITIGNORE), rel)) : parent;
25547
25649
  for (const e of entries) {
25548
25650
  if (e.name === GIT_DIR) continue;
25549
- const path7 = join18(abs, e.name);
25651
+ const path7 = join19(abs, e.name);
25550
25652
  let isDir = e.isDirectory();
25551
25653
  let isFile = e.isFile();
25552
25654
  let target = path7;
@@ -29676,7 +29778,7 @@ function readUtf8(absPath) {
29676
29778
  }
29677
29779
  function missingOrOutside(given, abs, root) {
29678
29780
  let dir = abs;
29679
- while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
29781
+ while (!existsSync16(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
29680
29782
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
29681
29783
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
29682
29784
  }
@@ -29687,7 +29789,7 @@ function pathItems(input, project) {
29687
29789
  if (statSync8(abs).isDirectory()) {
29688
29790
  return walkDir(abs, project.containmentRoot).map((f) => ({
29689
29791
  sourceKind: "path",
29690
- label: pathLabel(join19(base, f.relPath)),
29792
+ label: pathLabel(join20(base, f.relPath)),
29691
29793
  kind: kindOfPath(f.relPath),
29692
29794
  read: () => readUtf8(f.absPath)
29693
29795
  }));
@@ -30227,12 +30329,12 @@ var ctxStats = Object.freeze({
30227
30329
  });
30228
30330
 
30229
30331
  // src/core/tools/upgrade.ts
30230
- import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
30231
- import { basename as basename7, dirname as dirname12, join as join25 } from "node:path";
30332
+ import { existsSync as existsSync22, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
30333
+ import { basename as basename7, dirname as dirname13, join as join26 } from "node:path";
30232
30334
 
30233
30335
  // src/core/ops/host-write.ts
30234
- import { copyFileSync, existsSync as existsSync16, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30235
- import { dirname as dirname11, join as join20 } from "node:path";
30336
+ import { copyFileSync, existsSync as existsSync17, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30337
+ import { dirname as dirname12, join as join21 } from "node:path";
30236
30338
  function defaultWrite(file2, text) {
30237
30339
  writeFileSync5(file2, text, "utf8");
30238
30340
  }
@@ -30241,14 +30343,14 @@ function hostConfigPath(agent, home, env) {
30241
30343
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
30242
30344
  switch (agent) {
30243
30345
  case "opencode":
30244
- return join20(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30346
+ return join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30245
30347
  // D-WIN-OPENCODE-DIR-1
30246
30348
  case "pi":
30247
- return join20(piAgentDirOf(env, home), SETTINGS_FILE);
30349
+ return join21(piAgentDirOf(env, home), SETTINGS_FILE);
30248
30350
  case "copilot-cli":
30249
30351
  return null;
30250
30352
  default:
30251
- return join20(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30353
+ return join21(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30252
30354
  }
30253
30355
  }
30254
30356
  function cell3(value) {
@@ -30260,8 +30362,8 @@ function toRow(file2, edit) {
30260
30362
  function writeWithRollback(file2, text, write2, atomic) {
30261
30363
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
30262
30364
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
30263
- const had = existsSync16(file2);
30264
- mkdirSync7(dirname11(file2), { recursive: true });
30365
+ const had = existsSync17(file2);
30366
+ mkdirSync7(dirname12(file2), { recursive: true });
30265
30367
  if (had) copyFileSync(file2, trash);
30266
30368
  try {
30267
30369
  write2(tmp, text);
@@ -30290,7 +30392,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
30290
30392
  if (requested === null) return [];
30291
30393
  const current = readHostConfig(row5.id, requested);
30292
30394
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
30293
- const exists = existsSync16(current.path);
30395
+ const exists = existsSync17(current.path);
30294
30396
  if (exists && result.text === current.text) return [];
30295
30397
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
30296
30398
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -30298,8 +30400,8 @@ function regenerateHostConfig(row5, home, opts = {}) {
30298
30400
  }
30299
30401
 
30300
30402
  // src/core/ops/plugin-swap.ts
30301
- import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30302
- import { basename as basename6, join as join21, win32 as win322 } from "node:path";
30403
+ import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30404
+ import { basename as basename6, join as join22, win32 as win322 } from "node:path";
30303
30405
  function linkTarget(path7, win) {
30304
30406
  if (!isLink(path7)) return null;
30305
30407
  const target = readlinkSync(path7);
@@ -30318,11 +30420,11 @@ function settleLinks(link, tmp, old, opts) {
30318
30420
  else renameWithRetry(old, link, opts);
30319
30421
  }
30320
30422
  function swapPluginCurrent(agentDir, sha, opts = {}) {
30321
- const next = join21(agentDir, sha);
30322
- if (!existsSync17(next) || !lstatSync(next).isDirectory()) {
30423
+ const next = join22(agentDir, sha);
30424
+ if (!existsSync18(next) || !lstatSync(next).isDirectory()) {
30323
30425
  throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
30324
30426
  }
30325
- const link = join21(agentDir, PLUGIN_CURRENT_LINK);
30427
+ const link = join22(agentDir, PLUGIN_CURRENT_LINK);
30326
30428
  const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
30327
30429
  const old = link + PLUGIN_LINK_OLD_SUFFIX;
30328
30430
  settleLinks(link, tmp, old, opts);
@@ -30337,15 +30439,15 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
30337
30439
  if (before !== null) unlinkSync2(old);
30338
30440
  const keep = /* @__PURE__ */ new Set([sha]);
30339
30441
  if (before !== null) keep.add(before);
30340
- const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join21(agentDir, name));
30442
+ const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join22(agentDir, name));
30341
30443
  for (const dir of removed) rmSync6(dir, { recursive: true, force: true });
30342
- const previous = before !== null && existsSync17(join21(agentDir, before)) ? join21(agentDir, before) : null;
30444
+ const previous = before !== null && existsSync18(join22(agentDir, before)) ? join22(agentDir, before) : null;
30343
30445
  return { current: next, previous, removed };
30344
30446
  }
30345
30447
 
30346
30448
  // src/core/ops/release-fetch.ts
30347
- import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
30348
- import { join as join22 } from "node:path";
30449
+ import { existsSync as existsSync19, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
30450
+ import { join as join23 } from "node:path";
30349
30451
  function failed(r) {
30350
30452
  if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
30351
30453
  const status = r.killed ?? String(r.exitCode);
@@ -30357,9 +30459,9 @@ async function git2(bin, args, cwd, env, signal) {
30357
30459
  return r.stdout.toString().trim();
30358
30460
  }
30359
30461
  async function fetchRelease(agent, url4, env, signal, opts = {}) {
30360
- const agentDir = join22(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30462
+ const agentDir = join23(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30361
30463
  mkdirSync8(agentDir, { recursive: true });
30362
- const fetchDir = join22(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30464
+ const fetchDir = join23(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30363
30465
  rmSync7(fetchDir, { recursive: true, force: true });
30364
30466
  const gitBin = findRuntime(GIT_BIN, env);
30365
30467
  if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
@@ -30367,8 +30469,8 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
30367
30469
  try {
30368
30470
  await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
30369
30471
  const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
30370
- const dir = join22(agentDir, sha);
30371
- if (existsSync18(dir)) rmSync7(fetchDir, { recursive: true, force: true });
30472
+ const dir = join23(agentDir, sha);
30473
+ if (existsSync19(dir)) rmSync7(fetchDir, { recursive: true, force: true });
30372
30474
  else renameWithRetry(fetchDir, dir, opts);
30373
30475
  return { sha, dir };
30374
30476
  } catch (e) {
@@ -30378,15 +30480,15 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
30378
30480
  }
30379
30481
 
30380
30482
  // src/core/ops/uninstall.ts
30381
- import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
30382
- import { join as join23 } from "node:path";
30483
+ import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
30484
+ import { join as join24 } from "node:path";
30383
30485
  function row2(area, before, after) {
30384
30486
  return { area, before, after };
30385
30487
  }
30386
30488
  function stopServers(configDir, projectKey) {
30387
30489
  const stopped = listLiveOwners(configDir, projectKey);
30388
- const dir = join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30389
- for (const serverId of stopped) writeFileSync6(join23(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30490
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30491
+ for (const serverId of stopped) writeFileSync6(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30390
30492
  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 };
30391
30493
  }
30392
30494
  function rootOrNull(adapter, env) {
@@ -30404,15 +30506,15 @@ function removeCache(adapter, env, configDir) {
30404
30506
  const root = rootOrNull(adapter, env);
30405
30507
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30406
30508
  if (adapter.installMode === "marketplace") {
30407
- const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30509
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30408
30510
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
30409
30511
  }
30410
30512
  rmSync8(root, { recursive: true, force: true });
30411
30513
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
30412
30514
  }
30413
30515
  case "plugin": {
30414
- const agentDir = join23(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30415
- if (!existsSync19(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30516
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30517
+ if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30416
30518
  rmSync8(agentDir, { recursive: true, force: true });
30417
30519
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
30418
30520
  }
@@ -30457,7 +30559,7 @@ function ownEntries(agent, env) {
30457
30559
  }
30458
30560
  if (agent === "opencode") {
30459
30561
  return [{
30460
- file: join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30562
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30461
30563
  // D-WIN-OPENCODE-DIR-1
30462
30564
  key: OPENCODE_PLUGIN_KEY,
30463
30565
  shown: OPENCODE_PLUGIN_KEY,
@@ -30468,7 +30570,7 @@ function ownEntries(agent, env) {
30468
30570
  if (agent === "pi") {
30469
30571
  const agentDir = piAgentDirOf(env, home);
30470
30572
  return [{
30471
- file: join23(agentDir, SETTINGS_FILE),
30573
+ file: join24(agentDir, SETTINGS_FILE),
30472
30574
  key: PI_PACKAGES_KEY,
30473
30575
  shown: PI_PACKAGES_KEY,
30474
30576
  has: (v) => Array.isArray(v) && v.some((x) => piSource(x) === PI_GIT_PACKAGE),
@@ -30490,12 +30592,12 @@ function removeOwnEntries(agent, env) {
30490
30592
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
30491
30593
  }
30492
30594
  function removeProjectData(configDir, projectKey) {
30493
- const projects = join23(configDir, PROJECTS_DIR_NAME);
30494
- const dir = join23(projects, projectKey);
30495
- if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30595
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
30596
+ const dir = join24(projects, projectKey);
30597
+ if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30496
30598
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
30497
30599
  for (const name of readdirSync9(dir)) {
30498
- if (name !== OWNERS_DIR_NAME) rmSync8(join23(dir, name), { recursive: true, force: true });
30600
+ if (name !== OWNERS_DIR_NAME) rmSync8(join24(dir, name), { recursive: true, force: true });
30499
30601
  }
30500
30602
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
30501
30603
  }
@@ -30503,12 +30605,12 @@ function runUninstall(input) {
30503
30605
  const configDir = resolveConfigDir(input.env);
30504
30606
  const stop = stopServers(configDir, input.project.projectKey);
30505
30607
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
30506
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join23(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30608
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30507
30609
  return { rows, stopped: stop.stopped };
30508
30610
  }
30509
30611
 
30510
30612
  // src/core/ops/v1-remove.ts
30511
- import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30613
+ import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30512
30614
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30513
30615
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
30514
30616
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -30589,14 +30691,14 @@ function removeV1(agent, findings) {
30589
30691
  for (const f of findings) {
30590
30692
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
30591
30693
  else if (f.path === "") {
30592
- if (existsSync20(f.file)) {
30694
+ if (existsSync21(f.file)) {
30593
30695
  moveAside(f.file, undo);
30594
30696
  done.set(f, UPGRADE_REMOVED);
30595
30697
  } else done.set(f, UPGRADE_NOT_FOUND);
30596
30698
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
30597
30699
  }
30598
30700
  for (const [file2, list4] of entries) {
30599
- if (!existsSync20(file2)) {
30701
+ if (!existsSync21(file2)) {
30600
30702
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
30601
30703
  continue;
30602
30704
  }
@@ -30629,7 +30731,7 @@ function removeV1(agent, findings) {
30629
30731
  },
30630
30732
  rollback() {
30631
30733
  for (const u of undo.splice(0).reverse()) {
30632
- if (!existsSync20(u.trash)) continue;
30734
+ if (!existsSync21(u.trash)) continue;
30633
30735
  rmSync9(u.target, { recursive: true, force: true });
30634
30736
  renameWithRetry(u.trash, u.target);
30635
30737
  }
@@ -30640,7 +30742,7 @@ function removeV1(agent, findings) {
30640
30742
  // src/core/ops/verify-sums.ts
30641
30743
  import { createHash as createHash2 } from "node:crypto";
30642
30744
  import { lstatSync as lstatSync2, readdirSync as readdirSync10, readFileSync as readFileSync17 } from "node:fs";
30643
- import { join as join24 } from "node:path";
30745
+ import { join as join25 } from "node:path";
30644
30746
  function mismatch() {
30645
30747
  return new CtxError("BUNDLE_HASH_MISMATCH");
30646
30748
  }
@@ -30661,14 +30763,14 @@ function walk3(dir, prefix, out) {
30661
30763
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
30662
30764
  const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
30663
30765
  if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
30664
- const abs = join24(dir, entry.name);
30766
+ const abs = join25(dir, entry.name);
30665
30767
  if (entry.isDirectory()) walk3(abs, rel, out);
30666
30768
  else if (entry.isFile()) out.set(rel, abs);
30667
30769
  else throw mismatch();
30668
30770
  }
30669
30771
  }
30670
30772
  function verifySums(dir) {
30671
- const sumsPath = join24(dir, RELEASE_SUMS_FILE);
30773
+ const sumsPath = join25(dir, RELEASE_SUMS_FILE);
30672
30774
  const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
30673
30775
  if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
30674
30776
  const sums = parseSums(readFileSync17(sumsPath, "utf8"));
@@ -30692,7 +30794,7 @@ function row4(area, before, after) {
30692
30794
  return { area, before, after };
30693
30795
  }
30694
30796
  function bundleDir() {
30695
- return dirname12(process.argv[1] ?? "");
30797
+ return ownBundleDir();
30696
30798
  }
30697
30799
  function pluginRootRow(adapter, env) {
30698
30800
  const own4 = bundleDir();
@@ -30706,12 +30808,12 @@ function pluginRootRow(adapter, env) {
30706
30808
  return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
30707
30809
  }
30708
30810
  function isCurrent(agentDir, dir) {
30709
- const link = join25(agentDir, PLUGIN_CURRENT_LINK);
30710
- return existsSync21(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30811
+ const link = join26(agentDir, PLUGIN_CURRENT_LINK);
30812
+ return existsSync22(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30711
30813
  }
30712
30814
  async function checkout(adapter, deps) {
30713
30815
  const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
30714
- const agentDir = dirname12(fetched.dir);
30816
+ const agentDir = dirname13(fetched.dir);
30715
30817
  try {
30716
30818
  verifySums(fetched.dir);
30717
30819
  } catch (err) {
@@ -30827,9 +30929,9 @@ function checkCall(tool, input) {
30827
30929
 
30828
30930
  // src/entries/server.ts
30829
30931
  import { randomUUID } from "node:crypto";
30830
- import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
30831
- import { dirname as dirname13, join as join27 } from "node:path";
30832
- import { fileURLToPath as fileURLToPath2 } from "node:url";
30932
+ import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
30933
+ import { dirname as dirname14, join as join28 } from "node:path";
30934
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
30833
30935
 
30834
30936
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
30835
30937
  var __create = Object.create;
@@ -33206,8 +33308,8 @@ function handleArrayResult2(result, final, index) {
33206
33308
  }
33207
33309
  var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
33208
33310
  $ZodType2.init(inst, def);
33209
- const memo4 = globalConfig2.memoizer;
33210
- memo4?.attach(inst);
33311
+ const memo5 = globalConfig2.memoizer;
33312
+ memo5?.attach(inst);
33211
33313
  inst._zod.parse = (payload, ctx) => {
33212
33314
  const input = payload.value;
33213
33315
  if (!Array.isArray(input)) {
@@ -33219,7 +33321,7 @@ var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
33219
33321
  });
33220
33322
  return payload;
33221
33323
  }
33222
- payload.value = memo4 ? memo4.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
33324
+ payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
33223
33325
  const proms = [];
33224
33326
  const abortEarly = ctx?.abortEarly;
33225
33327
  for (let i = 0; i < input.length; i++) {
@@ -33379,8 +33481,8 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33379
33481
  const isObject8 = isObject6;
33380
33482
  const catchall = def.catchall;
33381
33483
  let value;
33382
- const memo4 = globalConfig2.memoizer;
33383
- memo4?.attach(inst);
33484
+ const memo5 = globalConfig2.memoizer;
33485
+ memo5?.attach(inst);
33384
33486
  inst._zod.parse = (payload, ctx) => {
33385
33487
  value ?? (value = _normalized.value);
33386
33488
  const input = payload.value;
@@ -33393,7 +33495,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33393
33495
  });
33394
33496
  return payload;
33395
33497
  }
33396
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33498
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33397
33499
  const proms = [];
33398
33500
  const shape = value.shape;
33399
33501
  const abortEarly = ctx?.abortEarly;
@@ -33426,11 +33528,11 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33426
33528
  $ZodObject2.init(inst, def);
33427
33529
  const superParse = inst._zod.parse;
33428
33530
  const _normalized = cached2(() => normalizeDef(def));
33429
- const memo4 = globalConfig2.memoizer;
33531
+ const memo5 = globalConfig2.memoizer;
33430
33532
  const generateFastpass = (shape) => {
33431
33533
  const normalized = _normalized.value;
33432
33534
  const syms = normalized.symbolKeys;
33433
- const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo4, syms });
33535
+ const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo5, syms });
33434
33536
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
33435
33537
  const prefixStr = (id, k) => `
33436
33538
  let ${id}_ab = false;
@@ -33450,7 +33552,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33450
33552
  for (const key of normalized.allKeys) {
33451
33553
  ids[key] = `key_${counter++}`;
33452
33554
  }
33453
- doc.write(memo4 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
33555
+ doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
33454
33556
  for (const key of normalized.allKeys) {
33455
33557
  if (key === "__proto__")
33456
33558
  continue;
@@ -33813,8 +33915,8 @@ function handleIntersectionResults2(result, left, right2) {
33813
33915
  }
33814
33916
  var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33815
33917
  $ZodType2.init(inst, def);
33816
- const memo4 = globalConfig2.memoizer;
33817
- memo4?.attach(inst);
33918
+ const memo5 = globalConfig2.memoizer;
33919
+ memo5?.attach(inst);
33818
33920
  inst._zod.parse = (payload, ctx) => {
33819
33921
  const input = payload.value;
33820
33922
  if (!isPlainObject4(input)) {
@@ -33829,7 +33931,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33829
33931
  const proms = [];
33830
33932
  const values = def.keyType._zod.values;
33831
33933
  if (values && !def.partial) {
33832
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33934
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33833
33935
  const recordKeys = /* @__PURE__ */ new Set();
33834
33936
  for (const key of values) {
33835
33937
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -33893,7 +33995,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33893
33995
  });
33894
33996
  }
33895
33997
  } else {
33896
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33998
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33897
33999
  let unrecognized;
33898
34000
  for (const key of Reflect.ownKeys(input)) {
33899
34001
  if (key === "__proto__")
@@ -34454,7 +34556,7 @@ function bucketFor(state, inst) {
34454
34556
  }
34455
34557
  var handoff;
34456
34558
  var open = [];
34457
- var memo = {
34559
+ var memo2 = {
34458
34560
  alloc(_inst, payload, empty) {
34459
34561
  const bucket = handoff;
34460
34562
  if (!bucket)
@@ -34555,7 +34657,7 @@ var memo = {
34555
34657
  }
34556
34658
  };
34557
34659
  function memoizer() {
34558
- return memo;
34660
+ return memo2;
34559
34661
  }
34560
34662
  function isBackEdge(ctx, value) {
34561
34663
  const backEdges = ctx[STATE]?.backEdges;
@@ -40735,8 +40837,8 @@ function handleArrayResult3(result, final, index) {
40735
40837
  }
40736
40838
  var $ZodArray3 = /* @__PURE__ */ $constructor3("$ZodArray", (inst, def) => {
40737
40839
  $ZodType3.init(inst, def);
40738
- const memo4 = globalConfig3.memoizer;
40739
- memo4?.attach(inst);
40840
+ const memo5 = globalConfig3.memoizer;
40841
+ memo5?.attach(inst);
40740
40842
  inst._zod.parse = (payload, ctx) => {
40741
40843
  const input = payload.value;
40742
40844
  if (!Array.isArray(input)) {
@@ -40748,7 +40850,7 @@ var $ZodArray3 = /* @__PURE__ */ $constructor3("$ZodArray", (inst, def) => {
40748
40850
  });
40749
40851
  return payload;
40750
40852
  }
40751
- payload.value = memo4 ? memo4.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
40853
+ payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
40752
40854
  const proms = [];
40753
40855
  const abortEarly = ctx?.abortEarly;
40754
40856
  for (let i = 0; i < input.length; i++) {
@@ -40908,8 +41010,8 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
40908
41010
  const isObject8 = isObject7;
40909
41011
  const catchall = def.catchall;
40910
41012
  let value;
40911
- const memo4 = globalConfig3.memoizer;
40912
- memo4?.attach(inst);
41013
+ const memo5 = globalConfig3.memoizer;
41014
+ memo5?.attach(inst);
40913
41015
  inst._zod.parse = (payload, ctx) => {
40914
41016
  value ?? (value = _normalized.value);
40915
41017
  const input = payload.value;
@@ -40922,7 +41024,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
40922
41024
  });
40923
41025
  return payload;
40924
41026
  }
40925
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41027
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
40926
41028
  const proms = [];
40927
41029
  const shape = value.shape;
40928
41030
  const abortEarly = ctx?.abortEarly;
@@ -40955,11 +41057,11 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
40955
41057
  $ZodObject3.init(inst, def);
40956
41058
  const superParse = inst._zod.parse;
40957
41059
  const _normalized = cached3(() => normalizeDef2(def));
40958
- const memo4 = globalConfig3.memoizer;
41060
+ const memo5 = globalConfig3.memoizer;
40959
41061
  const generateFastpass = (shape) => {
40960
41062
  const normalized = _normalized.value;
40961
41063
  const syms = normalized.symbolKeys;
40962
- const doc = new Doc3(["payload", "ctx"], { shape, inst, memo: memo4, syms });
41064
+ const doc = new Doc3(["payload", "ctx"], { shape, inst, memo: memo5, syms });
40963
41065
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
40964
41066
  const prefixStr = (id, k) => `
40965
41067
  let ${id}_ab = false;
@@ -40979,7 +41081,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
40979
41081
  for (const key of normalized.allKeys) {
40980
41082
  ids[key] = `key_${counter++}`;
40981
41083
  }
40982
- doc.write(memo4 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
41084
+ doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
40983
41085
  for (const key of normalized.allKeys) {
40984
41086
  if (key === "__proto__")
40985
41087
  continue;
@@ -41342,8 +41444,8 @@ function handleIntersectionResults3(result, left, right2) {
41342
41444
  }
41343
41445
  var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41344
41446
  $ZodType3.init(inst, def);
41345
- const memo4 = globalConfig3.memoizer;
41346
- memo4?.attach(inst);
41447
+ const memo5 = globalConfig3.memoizer;
41448
+ memo5?.attach(inst);
41347
41449
  inst._zod.parse = (payload, ctx) => {
41348
41450
  const input = payload.value;
41349
41451
  if (!isPlainObject5(input)) {
@@ -41358,7 +41460,7 @@ var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41358
41460
  const proms = [];
41359
41461
  const values = def.keyType._zod.values;
41360
41462
  if (values && !def.partial) {
41361
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41463
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
41362
41464
  const recordKeys = /* @__PURE__ */ new Set();
41363
41465
  for (const key of values) {
41364
41466
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -41422,7 +41524,7 @@ var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41422
41524
  });
41423
41525
  }
41424
41526
  } else {
41425
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41527
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
41426
41528
  let unrecognized;
41427
41529
  for (const key of Reflect.ownKeys(input)) {
41428
41530
  if (key === "__proto__")
@@ -41983,7 +42085,7 @@ function bucketFor2(state, inst) {
41983
42085
  }
41984
42086
  var handoff2;
41985
42087
  var open2 = [];
41986
- var memo2 = {
42088
+ var memo3 = {
41987
42089
  alloc(_inst, payload, empty) {
41988
42090
  const bucket = handoff2;
41989
42091
  if (!bucket)
@@ -42084,7 +42186,7 @@ var memo2 = {
42084
42186
  }
42085
42187
  };
42086
42188
  function memoizer2() {
42087
- return memo2;
42189
+ return memo3;
42088
42190
  }
42089
42191
  function isBackEdge2(ctx, value) {
42090
42192
  const backEdges = ctx[STATE2]?.backEdges;
@@ -47347,9 +47449,9 @@ function build() {
47347
47449
  SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
47348
47450
  };
47349
47451
  }
47350
- var memo3;
47452
+ var memo4;
47351
47453
  function buildSchemas2026() {
47352
- return memo3 ??= build();
47454
+ return memo4 ??= build();
47353
47455
  }
47354
47456
  var CACHEABLE_RESULT_METHODS = [
47355
47457
  "tools/list",
@@ -58893,8 +58995,8 @@ function installExitGuard(opts) {
58893
58995
  }
58894
58996
 
58895
58997
  // src/core/store/cleanup.ts
58896
- import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as rmSync11 } from "node:fs";
58897
- import { join as join26 } from "node:path";
58998
+ import { existsSync as existsSync23, readdirSync as readdirSync11, rmSync as rmSync11 } from "node:fs";
58999
+ import { join as join27 } from "node:path";
58898
59000
  function deleteSource(raw, id) {
58899
59001
  raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
58900
59002
  deleteChunkRows(raw, { sourceId: id });
@@ -58929,7 +59031,7 @@ function userVersion(raw) {
58929
59031
  return raw.prepare("PRAGMA user_version").get().user_version;
58930
59032
  }
58931
59033
  function openForSweep(dbPath, projectKey) {
58932
- if (!existsSync22(dbPath) && (existsSync22(dbPath + DB_WAL_SUFFIX) || existsSync22(dbPath + DB_SHM_SUFFIX))) {
59034
+ if (!existsSync23(dbPath) && (existsSync23(dbPath + DB_WAL_SUFFIX) || existsSync23(dbPath + DB_SHM_SUFFIX))) {
58933
59035
  throw new CtxError("DB_GONE");
58934
59036
  }
58935
59037
  const sqlite = process.getBuiltinModule("node:sqlite");
@@ -58950,8 +59052,8 @@ function lastAccess(raw) {
58950
59052
  return row5.t;
58951
59053
  }
58952
59054
  function sweepOne(configDir, projectKey, cutoff) {
58953
- const dir = join26(configDir, PROJECTS_DIR_NAME, projectKey);
58954
- const db = openForSweep(join26(dir, DB_FILE_NAME), projectKey);
59055
+ const dir = join27(configDir, PROJECTS_DIR_NAME, projectKey);
59056
+ const db = openForSweep(join27(dir, DB_FILE_NAME), projectKey);
58955
59057
  let dead;
58956
59058
  try {
58957
59059
  dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
@@ -58964,7 +59066,7 @@ function sweepOne(configDir, projectKey, cutoff) {
58964
59066
  function sweepDeadProjects(configDir) {
58965
59067
  let entries;
58966
59068
  try {
58967
- entries = readdirSync11(join26(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
59069
+ entries = readdirSync11(join27(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
58968
59070
  } catch (err) {
58969
59071
  if (err.code === "ENOENT") return [];
58970
59072
  throw err;
@@ -59057,7 +59159,7 @@ function workspaceFromMeta(meta3) {
59057
59159
  if (typeof cwd !== "string" || cwd === "") return void 0;
59058
59160
  if (!cwd.startsWith(FILE_URL_PREFIX)) return cwd;
59059
59161
  try {
59060
- return fileURLToPath2(cwd);
59162
+ return fileURLToPath3(cwd);
59061
59163
  } catch {
59062
59164
  return void 0;
59063
59165
  }
@@ -59073,7 +59175,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
59073
59175
  const fromHost = workspaceFromMeta(meta3);
59074
59176
  if (fromHost !== void 0) return fromHost;
59075
59177
  if (script === void 0 || script === "") return spawnCwd;
59076
- return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
59178
+ return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
59077
59179
  }
59078
59180
  function errorReply(err) {
59079
59181
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
@@ -59112,15 +59214,15 @@ async function startServer(argv, env) {
59112
59214
  opening.catch(() => pending.delete(project.dbPath));
59113
59215
  }
59114
59216
  const db = await opening;
59115
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
59217
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
59116
59218
  return db;
59117
59219
  }
59118
59220
  function stopMarker(configDir, projectKey) {
59119
- return join27(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59221
+ return join28(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59120
59222
  }
59121
59223
  function stopRequested() {
59122
59224
  const configDir = resolveConfigDir(process.env);
59123
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
59225
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
59124
59226
  }
59125
59227
  async function journal(project, ctx, name, reply4) {
59126
59228
  const db = await ownDb(project);
@@ -59229,7 +59331,7 @@ async function startServer(argv, env) {
59229
59331
  handle = serveStdio(createServer);
59230
59332
  await new Promise((resolve8) => process.once("exit", () => resolve8()));
59231
59333
  }
59232
- if (isEntry(import.meta.main, process.argv[1], fileURLToPath2(import.meta.url))) {
59334
+ if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
59233
59335
  const [, , ...cliArgs] = process.argv;
59234
59336
  await startServer(cliArgs, process.env);
59235
59337
  }