context-mode 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -426,7 +426,7 @@ var DECISION_OPTION_KEY = "option";
426
426
  var DECISION_LABEL_JOIN = " | ";
427
427
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
428
428
  var RELEASE_BRANCH = "release";
429
- var BUNDLE_SHA = true ? "9f1916d761e6a8e55ac43858b99dcdcd3cc53caa" : void 0;
429
+ var BUNDLE_SHA = true ? "d232ce4ddfb581a63a4c0d6ef894b64a0f8464f6" : void 0;
430
430
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
431
431
  var DOCTOR_LABEL = Object.freeze({
432
432
  D1: "version",
@@ -715,8 +715,8 @@ var UPGRADE_DATA_DELETED = "user data deleted";
715
715
  var UPGRADE_HOST_COMMAND = Object.freeze({
716
716
  "claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
717
717
  codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
718
- gemini: "gemini extensions install https://github.com/mksglu/context-mode --ref release --auto-update",
719
- qwen: "qwen extensions install https://github.com/mksglu/context-mode --ref release --auto-update"
718
+ gemini: "gemini extensions install https://github.com/mksglu/context-mode --auto-update",
719
+ qwen: "qwen extensions install https://github.com/mksglu/context-mode --auto-update"
720
720
  });
721
721
  var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
722
722
  var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
@@ -780,6 +780,9 @@ var HOOKS_KEY = "hooks";
780
780
  var STATUS_LINE_KEY = "statusLine";
781
781
  var PI_PACKAGES_KEY = "packages";
782
782
  var OPENCODE_PLUGIN_KEY = "plugin";
783
+ var OPENCODE_PLUGINS_KEY = "plugins";
784
+ var OPENCODE_PACKAGE_FIELD = "package";
785
+ var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
783
786
  var V1_DATA_DIR_NAME = "context-mode";
784
787
  var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
785
788
  var V1_SESSIONS_DIR_NAME = "sessions";
@@ -878,6 +881,7 @@ var DOCTOR_REPORT_FILE_PREFIX = "doctor-";
878
881
  var DOCTOR_REPORT_LINE = "Report file: ";
879
882
  var DOCTOR_GH_LINE = "File it: ";
880
883
  var DOCTOR_URL_LINE = "Or open: ";
884
+ var DOCTOR_RULES_LINE = "Rules: ";
881
885
  var DOCTOR_GH_NEXT = " --";
882
886
  var DOCTOR_NOTE_PREFIXES = Object.freeze([
883
887
  DOCTOR_ENV_PREFIX,
@@ -885,10 +889,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
885
889
  DOCTOR_REPORT_LINE,
886
890
  DOCTOR_GH_LINE,
887
891
  DOCTOR_GH_NEXT.trim(),
888
- DOCTOR_URL_LINE
892
+ DOCTOR_URL_LINE,
893
+ DOCTOR_RULES_LINE
889
894
  ]);
890
895
  var ISSUE_REPO_SLUG = "mksglu/context-mode";
891
896
  var ISSUE_FORM_FILE = "agent-report.yml";
897
+ var ISSUE_GUIDE_URL = `https://github.com/${ISSUE_REPO_SLUG}/blob/main/.github/AGENT_ISSUE.md`;
898
+ var ISSUE_AGENT_RULES = Object.freeze([
899
+ '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.',
900
+ "File one bug per issue.",
901
+ "Call the `ctx_doctor` tool and paste its full output unchanged in the `ctx-report` field.",
902
+ "Give the versions: context-mode, the agent, the OS and arch, and Node.",
903
+ "Write numbered repro steps that start from a fresh project (`mktemp -d`) and the agent's own install command.",
904
+ "Give the exact command and its exact output in a fenced code block.",
905
+ "Say what you expected and what happened instead.",
906
+ "Name the source file and line when you found the cause.",
907
+ "Replace every secret with `<masked>` and the home folder with `~` before you send."
908
+ ]);
892
909
  var ISSUE_URL_MAX = 8e3;
893
910
  var ISSUE_FORM_HEADINGS = Object.freeze([
894
911
  "Summary",
@@ -919,16 +936,16 @@ var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
919
936
  var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
920
937
  var DOCTOR_MASK = "<masked>";
921
938
  var NATIVE_INSTALL = Object.freeze({
922
- "claude-code": ["claude plugin marketplace add mksglu/context-mode#release", "claude plugin install context-mode@context-mode"],
923
- codex: ["codex plugin marketplace add mksglu/context-mode@release", "codex plugin add context-mode@context-mode"],
924
- gemini: ["gemini extensions install https://github.com/mksglu/context-mode --ref release"],
925
- qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode --ref release"],
926
- opencode: ["opencode plugin add context-mode@next"],
927
- pi: ["pi install npm:context-mode@next"],
928
- "copilot-cli": ["npm i -g context-mode@next", "context-mode setup --agents copilot-cli"],
929
- vscode: ["npm i -g context-mode@next", "context-mode setup --agents vscode"],
930
- kiro: ["npm i -g context-mode@next", "context-mode setup --agents kiro"],
931
- zcode: ["npm i -g context-mode@next", "context-mode setup --agents zcode"]
939
+ "claude-code": ["claude plugin marketplace add mksglu/context-mode", "claude plugin install context-mode@context-mode"],
940
+ codex: ["codex plugin marketplace add mksglu/context-mode", "codex plugin add context-mode@context-mode"],
941
+ gemini: ["gemini extensions install https://github.com/mksglu/context-mode"],
942
+ qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
943
+ opencode: ["opencode plugin add context-mode"],
944
+ pi: ["pi install npm:context-mode"],
945
+ "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
946
+ vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
947
+ kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
948
+ zcode: ["npm i -g context-mode", "context-mode setup --agents zcode"]
932
949
  });
933
950
  var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
934
951
  var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
@@ -1515,7 +1532,8 @@ function encode6(ev, d, _extra) {
1515
1532
  }
1516
1533
 
1517
1534
  // src/adapters/kiro.ts
1518
- var TOOL_NAME_PREFIX7 = "mcp_context-mode_";
1535
+ var TOOL_NAME_PREFIX7 = "mcp_context_mode_";
1536
+ var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
1519
1537
  var KIRO_EVENTS = {
1520
1538
  SessionStart: "SessionStart",
1521
1539
  agentSpawn: "SessionStart",
@@ -1527,6 +1545,7 @@ var KIRO_EVENTS = {
1527
1545
  PostToolUse: "PostToolUse",
1528
1546
  postToolUse: "PostToolUse"
1529
1547
  };
1548
+ var PROMPT_FIELD = "prompt";
1530
1549
  var PROMPT_ENV = "USER_PROMPT";
1531
1550
  var MCP_PREFIX3 = "mcp_";
1532
1551
  var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
@@ -1535,6 +1554,7 @@ var MCP_SEP3 = "_";
1535
1554
  var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
1536
1555
  function canonicalName5(name) {
1537
1556
  if (name.startsWith(TOOL_NAME_PREFIX7)) return name.slice(TOOL_NAME_PREFIX7.length);
1557
+ if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
1538
1558
  if (Object.hasOwn(NATIVE_TO_CANONICAL5, name)) return NATIVE_TO_CANONICAL5[name];
1539
1559
  if (!name.startsWith(MCP_PREFIX3)) return name;
1540
1560
  const rest = name.slice(MCP_PREFIX3.length);
@@ -1555,7 +1575,8 @@ function decode7(raw) {
1555
1575
  const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
1556
1576
  if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
1557
1577
  if (event === "UserPromptSubmit") {
1558
- const prompt = process.env[PROMPT_ENV];
1578
+ const field = p[PROMPT_FIELD];
1579
+ const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
1559
1580
  if (prompt !== void 0) ev.prompt = prompt;
1560
1581
  }
1561
1582
  if (event === "PreToolUse" || event === "PostToolUse") {
@@ -1567,7 +1588,7 @@ function decode7(raw) {
1567
1588
  return ev;
1568
1589
  }
1569
1590
  function encode7(ev, d, _extra) {
1570
- if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
1591
+ if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
1571
1592
  switch (d.kind) {
1572
1593
  case "allow":
1573
1594
  return { stdout: "", exitCode: 0 };
@@ -1926,7 +1947,7 @@ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "
1926
1947
  function dumpRunsThenReplaces(row5) {
1927
1948
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
1928
1949
  }
1929
- var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode"]);
1950
+ var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode", "kiro"]);
1930
1951
  function hasRecall(row5) {
1931
1952
  return RECALL_ROWS.has(row5.id);
1932
1953
  }
@@ -3277,14 +3298,29 @@ function copilotDirOf(env, home) {
3277
3298
  function kiroDirOf(env, home, platform = process.platform) {
3278
3299
  const p = platform === "win32" ? win32 : posix;
3279
3300
  const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
3280
- const dir = env[KIRO_HOME_ENV];
3301
+ const dir = env[KIRO_HOME_ENV]?.trim();
3281
3302
  if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
3282
3303
  if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
3283
3304
  const abs = p.resolve(dir);
3284
- if (p.dirname(abs) === abs) return fallback;
3285
- const up = p.relative(abs, p.resolve(home));
3305
+ const real2 = platform === process.platform ? realOrSelf : (x) => x;
3306
+ const target = real2(abs);
3307
+ if (p.parse(target).root === target) return fallback;
3308
+ const up = p.relative(target, real2(p.resolve(home)));
3286
3309
  if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
3287
- return dir;
3310
+ return abs;
3311
+ }
3312
+ function realOrSelf(path7) {
3313
+ const tail = [];
3314
+ for (let at2 = path7; ; ) {
3315
+ try {
3316
+ return join(realpathSync.native(at2), ...tail.reverse());
3317
+ } catch {
3318
+ const up = dirname(at2);
3319
+ if (up === at2) return path7;
3320
+ tail.push(basename(at2));
3321
+ at2 = up;
3322
+ }
3323
+ }
3288
3324
  }
3289
3325
  function claudeDirOf(env, home) {
3290
3326
  const dir = env[CLAUDE_CONFIG_DIR_ENV];
@@ -7854,7 +7890,7 @@ function cutPoint(src, start, end, scratch) {
7854
7890
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
7855
7891
  return { end: start + r.read, written: r.written };
7856
7892
  }
7857
- function merge(src, blocks, join26, cap, lineCut) {
7893
+ function merge(src, blocks, join27, cap, lineCut) {
7858
7894
  const out = [];
7859
7895
  const scratch = new Uint8Array(cap);
7860
7896
  let wide;
@@ -7864,7 +7900,7 @@ function merge(src, blocks, join26, cap, lineCut) {
7864
7900
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
7865
7901
  };
7866
7902
  for (const b of blocks) {
7867
- if (cur !== void 0 && !join26) {
7903
+ if (cur !== void 0 && !join27) {
7868
7904
  emit(cur.start, cur.end, curBytes);
7869
7905
  cur = void 0;
7870
7906
  }
@@ -20858,21 +20894,43 @@ var ctxBatch = Object.freeze({
20858
20894
  });
20859
20895
 
20860
20896
  // src/core/tools/doctor.ts
20861
- import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync13 } from "node:fs";
20862
- import { basename as basename5, dirname as dirname8, join as join16 } from "node:path";
20897
+ import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync14 } from "node:fs";
20898
+ import { basename as basename5, join as join17 } from "node:path";
20899
+
20900
+ // src/core/ops/bundle-dir.ts
20901
+ import { existsSync as existsSync3 } from "node:fs";
20902
+ import { dirname as dirname5, join as join8 } from "node:path";
20903
+ import { fileURLToPath } from "node:url";
20904
+ function bundleDirOf(argv1, moduleFile) {
20905
+ const own2 = dirname5(argv1);
20906
+ if (existsSync3(join8(own2, SERVER_ENTRY_FILE))) return own2;
20907
+ let dir = dirname5(moduleFile);
20908
+ for (; ; ) {
20909
+ if (existsSync3(join8(dir, SERVER_ENTRY_FILE))) return dir;
20910
+ const up = dirname5(dir);
20911
+ if (up === dir) return own2;
20912
+ dir = up;
20913
+ }
20914
+ }
20915
+ var memo;
20916
+ function ownBundleDir() {
20917
+ const argv1 = process.argv[1] ?? "";
20918
+ if (memo?.argv1 !== argv1) memo = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
20919
+ return memo.dir;
20920
+ }
20863
20921
 
20864
20922
  // src/core/ops/doctor-config.ts
20865
- import { existsSync as existsSync6, readdirSync as readdirSync4 } from "node:fs";
20866
- import { join as join11 } from "node:path";
20923
+ import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
20924
+ import { join as join12 } from "node:path";
20867
20925
 
20868
20926
  // src/core/ops/detect-v1.ts
20869
- import { existsSync as existsSync4, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20927
+ import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20870
20928
  import { tmpdir } from "node:os";
20871
- import { join as join9 } from "node:path";
20929
+ import { join as join10 } from "node:path";
20872
20930
 
20873
20931
  // src/core/ops/host-config.ts
20874
- import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
20875
- import { dirname as dirname5, join as join8 } from "node:path";
20932
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
20933
+ import { dirname as dirname6, join as join9 } from "node:path";
20876
20934
 
20877
20935
  // node_modules/eslint-visitor-keys/lib/visitor-keys.js
20878
20936
  var KEYS2 = {
@@ -22989,10 +23047,10 @@ function formatOf(path7) {
22989
23047
  function readHostConfig(agent, path7) {
22990
23048
  let file2 = path7;
22991
23049
  if (agent === "opencode") {
22992
- const jsonc = join8(dirname5(path7), OPENCODE_CONFIG_FILES[0]);
22993
- if (existsSync3(jsonc)) file2 = jsonc;
23050
+ const jsonc = join9(dirname6(path7), OPENCODE_CONFIG_FILES[0]);
23051
+ if (existsSync4(jsonc)) file2 = jsonc;
22994
23052
  }
22995
- const raw = existsSync3(file2) ? readFileSync6(file2, "utf8") : "";
23053
+ const raw = existsSync4(file2) ? readFileSync6(file2, "utf8") : "";
22996
23054
  return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
22997
23055
  }
22998
23056
  function stripJsonComments(text) {
@@ -23337,7 +23395,7 @@ function setText(agent, path7, text, format, key, value) {
23337
23395
  }
23338
23396
  }
23339
23397
  function serverScript() {
23340
- return join8(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23398
+ return join9(dirname6(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23341
23399
  }
23342
23400
  function isNodeCommand(command) {
23343
23401
  if (typeof command !== "string") return false;
@@ -23353,7 +23411,7 @@ function ownMcpValue(agent, node, server2) {
23353
23411
  return { ...mcp.fields, [MCP_COMMAND_FIELD]: node, [MCP_ARGS_FIELD]: [server2, AGENT_ARG, agent, ...tail] };
23354
23412
  }
23355
23413
  function opencodePluginFile() {
23356
- return dirname5(process.argv[1] ?? "");
23414
+ return ownBundleDir();
23357
23415
  }
23358
23416
  function listTarget(key, own2, v1, alt = []) {
23359
23417
  return {
@@ -23512,7 +23570,7 @@ function flatCommands(events, prefix) {
23512
23570
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
23513
23571
  var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep4) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep4) + sep4));
23514
23572
  function dataDir(dir, reason, out) {
23515
- if (existsSync4(dir)) out.push(finding(dir, "", reason));
23573
+ if (existsSync5(dir)) out.push(finding(dir, "", reason));
23516
23574
  }
23517
23575
  function mcpEntry(file2, doc, out) {
23518
23576
  if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
@@ -23520,7 +23578,7 @@ function mcpEntry(file2, doc, out) {
23520
23578
  }
23521
23579
  }
23522
23580
  function claudeShapeSettings(agentHome, out) {
23523
- const file2 = join9(agentHome, SETTINGS_FILE);
23581
+ const file2 = join10(agentHome, SETTINGS_FILE);
23524
23582
  const doc = readJson(file2);
23525
23583
  for (const c of nestedCommands(doc)) {
23526
23584
  if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
@@ -23540,49 +23598,49 @@ function v1HookFile(file2, out) {
23540
23598
  function scanClaudeCode(home, agentHome, out) {
23541
23599
  claudeShapeSettings(agentHome, out);
23542
23600
  for (const ext of V1_CACHE_HEAL_EXTS) {
23543
- const file2 = join9(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23544
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23601
+ const file2 = join10(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23602
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23545
23603
  }
23546
- const userFile = join9(home, CLAUDE_USER_CONFIG_FILE);
23604
+ const userFile = join10(home, CLAUDE_USER_CONFIG_FILE);
23547
23605
  mcpEntry(userFile, readJson(userFile), out);
23548
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23606
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23549
23607
  }
23550
23608
  function scanCodex(agentHome, out) {
23551
- const hooksFile = join9(agentHome, HOOKS_JSON_FILE);
23609
+ const hooksFile = join10(agentHome, HOOKS_JSON_FILE);
23552
23610
  for (const c of nestedCommands(readJson(hooksFile))) {
23553
23611
  if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
23554
23612
  out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
23555
23613
  }
23556
23614
  }
23557
- const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
23615
+ const tomlFile = join10(agentHome, CONFIG_TOML_FILE);
23558
23616
  const config2 = readTomlValue(tomlFile);
23559
23617
  for (const span2 of readTomlTables(tomlFile)) {
23560
23618
  if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
23561
23619
  if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config2, span2.path))) continue;
23562
23620
  out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
23563
23621
  }
23564
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23622
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23565
23623
  }
23566
23624
  function scanGemini(agentHome, out) {
23567
- const file2 = join9(agentHome, SETTINGS_FILE);
23625
+ const file2 = join10(agentHome, SETTINGS_FILE);
23568
23626
  for (const c of nestedCommands(readJson(file2))) {
23569
23627
  if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
23570
23628
  }
23571
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23629
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23572
23630
  }
23573
23631
  function scanVscode(agentHome, project, out) {
23574
23632
  if (project !== void 0) {
23575
- v1HookFile(join9(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23576
- const mcpFile2 = join9(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23633
+ v1HookFile(join10(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23634
+ const mcpFile2 = join10(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23577
23635
  const doc = readJson(mcpFile2);
23578
23636
  const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
23579
23637
  const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
23580
23638
  if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
23581
23639
  out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
23582
23640
  }
23583
- dataDir(join9(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23641
+ dataDir(join10(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23584
23642
  }
23585
- dataDir(join9(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23643
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23586
23644
  }
23587
23645
  function jsonFiles(dir) {
23588
23646
  try {
@@ -23592,10 +23650,10 @@ function jsonFiles(dir) {
23592
23650
  }
23593
23651
  }
23594
23652
  function scanKiro(agentHome, project, out) {
23595
- const agentsDir = join9(agentHome, KIRO_AGENTS_DIR);
23596
- const defaultFile = join9(agentHome, ...KIRO_AGENT_FILE);
23653
+ const agentsDir = join10(agentHome, KIRO_AGENTS_DIR);
23654
+ const defaultFile = join10(agentHome, ...KIRO_AGENT_FILE);
23597
23655
  for (const name of jsonFiles(agentsDir)) {
23598
- const file2 = join9(agentsDir, name);
23656
+ const file2 = join10(agentsDir, name);
23599
23657
  const doc = readJson(file2);
23600
23658
  if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
23601
23659
  out.push(finding(file2, "", V1_REASON.kiroAgentFile));
@@ -23606,25 +23664,25 @@ function scanKiro(agentHome, project, out) {
23606
23664
  if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
23607
23665
  }
23608
23666
  }
23609
- const steeringDocs = [join9(agentHome, ...KIRO_STEERING_FILE)];
23610
- if (project !== void 0) steeringDocs.push(join9(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23667
+ const steeringDocs = [join10(agentHome, ...KIRO_STEERING_FILE)];
23668
+ if (project !== void 0) steeringDocs.push(join10(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23611
23669
  for (const file2 of steeringDocs) {
23612
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23670
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23613
23671
  }
23614
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23672
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23615
23673
  }
23616
23674
  function scanPi(piAgentDir, agentHome, out) {
23617
- const file2 = join9(piAgentDir, SETTINGS_FILE);
23675
+ const file2 = join10(piAgentDir, SETTINGS_FILE);
23618
23676
  const doc = readJson(file2);
23619
23677
  listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
23620
23678
  const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
23621
23679
  if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
23622
23680
  });
23623
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23681
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23624
23682
  }
23625
23683
  function scanOpencode(agentHome, out) {
23626
23684
  for (const name of OPENCODE_CONFIG_FILES) {
23627
- const file2 = join9(agentHome, name);
23685
+ const file2 = join10(agentHome, name);
23628
23686
  const doc = readJson(file2);
23629
23687
  if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
23630
23688
  doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
@@ -23634,13 +23692,13 @@ function scanOpencode(agentHome, out) {
23634
23692
  }
23635
23693
  }
23636
23694
  function scanZcode(agentHome, out) {
23637
- const configFile = join9(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23695
+ const configFile = join10(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23638
23696
  const config2 = readJson(configFile);
23639
23697
  const events = isObj(config2) && isObj(config2[HOOKS_KEY]) ? config2[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
23640
23698
  for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
23641
23699
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
23642
23700
  }
23643
- const hooksFile = join9(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23701
+ const hooksFile = join10(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23644
23702
  for (const c of nestedCommands(readJson(hooksFile))) {
23645
23703
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
23646
23704
  }
@@ -23664,14 +23722,14 @@ function firstTmpMatch(dir) {
23664
23722
  }
23665
23723
  }
23666
23724
  function scanAll(home, tmp, out) {
23667
- const root = join9(home, DATA_ROOT.slice(1));
23668
- for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join9(root, name), V1_REASON.dataRoot, out);
23725
+ const root = join10(home, DATA_ROOT.slice(1));
23726
+ for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join10(root, name), V1_REASON.dataRoot, out);
23669
23727
  if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
23670
23728
  }
23671
23729
  function detectV1(agent, home, scope = {}) {
23672
23730
  const out = [];
23673
23731
  const project = scope.project;
23674
- 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]);
23732
+ 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]);
23675
23733
  switch (agent) {
23676
23734
  case "claude-code":
23677
23735
  scanClaudeCode(home, agentHome, out);
@@ -23684,11 +23742,11 @@ function detectV1(agent, home, scope = {}) {
23684
23742
  break;
23685
23743
  case "qwen":
23686
23744
  claudeShapeSettings(agentHome, out);
23687
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23745
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23688
23746
  break;
23689
23747
  case "copilot-cli":
23690
- v1HookFile(join9(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23691
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23748
+ v1HookFile(join10(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23749
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23692
23750
  break;
23693
23751
  case "vscode":
23694
23752
  scanVscode(agentHome, project, out);
@@ -23697,7 +23755,7 @@ function detectV1(agent, home, scope = {}) {
23697
23755
  scanKiro(agentHome, project, out);
23698
23756
  break;
23699
23757
  case "pi":
23700
- scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join9(agentHome, PI_AGENT_DIR), agentHome, out);
23758
+ scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join10(agentHome, PI_AGENT_DIR), agentHome, out);
23701
23759
  break;
23702
23760
  // D-WIN-PIDIR-1: empty is unset
23703
23761
  case "opencode":
@@ -23712,9 +23770,9 @@ function detectV1(agent, home, scope = {}) {
23712
23770
  }
23713
23771
 
23714
23772
  // src/core/ops/plugin-root.ts
23715
- import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23716
- import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep3 } from "node:path";
23717
- import { fileURLToPath } from "node:url";
23773
+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23774
+ import { dirname as dirname7, isAbsolute as isAbsolute2, join as join11, sep as sep3 } from "node:path";
23775
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
23718
23776
  function missing(agent, path7) {
23719
23777
  return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path7 });
23720
23778
  }
@@ -23761,8 +23819,8 @@ var readOrNull = (file2) => {
23761
23819
  };
23762
23820
  var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
23763
23821
  function enabledPlugins(claudeDir, project) {
23764
- const files = [join10(claudeDir, SETTINGS_FILE)];
23765
- if (project !== void 0) files.push(join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23822
+ const files = [join11(claudeDir, SETTINGS_FILE)];
23823
+ if (project !== void 0) files.push(join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23766
23824
  const out = {};
23767
23825
  for (const file2 of files) {
23768
23826
  const text = readOrNull(file2);
@@ -23775,13 +23833,13 @@ function enabledPlugins(claudeDir, project) {
23775
23833
  function marketplaceChoice(env, worktree) {
23776
23834
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23777
23835
  const script = process.argv[1];
23778
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23836
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23779
23837
  const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
23780
23838
  if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
23781
- const record4 = readOrNull(join10(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23839
+ const record4 = readOrNull(join11(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23782
23840
  const recorded = record4 === null ? [] : recordedInstalls(record4);
23783
23841
  if (recorded.length === 0) return { record: false };
23784
- const live = recorded.filter((r) => existsSync5(r.installPath));
23842
+ const live = recorded.filter((r) => existsSync6(r.installPath));
23785
23843
  const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
23786
23844
  if (mine !== void 0) return { root: mine.installPath };
23787
23845
  const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
@@ -23801,18 +23859,18 @@ function marketplaceChoice(env, worktree) {
23801
23859
  }
23802
23860
  function marketplaceRoot(adapter, env, worktree) {
23803
23861
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23804
- const plugins = join10(claudeDir, HOST_PLUGINS_DIR_NAME);
23805
- const cache = join10(plugins, PLUGIN_CACHE_DIR_NAME);
23862
+ const plugins = join11(claudeDir, HOST_PLUGINS_DIR_NAME);
23863
+ const cache = join11(plugins, PLUGIN_CACHE_DIR_NAME);
23806
23864
  const script = process.argv[1];
23807
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23865
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23808
23866
  const choice = marketplaceChoice(env, worktree);
23809
23867
  if ("root" in choice) return choice.root;
23810
23868
  if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
23811
23869
  const cacheReal = realOrNull(cache);
23812
- if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync5(join10(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23813
- const pattern = join10(cache, "*", PLUGIN_NAME);
23814
- if (!existsSync5(cache)) throw missing(adapter.id, pattern);
23815
- const found = readdirSync3(cache).sort().map((marketplace) => join10(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync5(dir));
23870
+ if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync6(join11(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23871
+ const pattern = join11(cache, "*", PLUGIN_NAME);
23872
+ if (!existsSync6(cache)) throw missing(adapter.id, pattern);
23873
+ const found = readdirSync3(cache).sort().map((marketplace) => join11(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
23816
23874
  if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
23817
23875
  return found[0];
23818
23876
  }
@@ -23820,13 +23878,13 @@ function configEntryRoot(adapter, env) {
23820
23878
  const spec = OWN_MCP_ENTRY[adapter.id];
23821
23879
  if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
23822
23880
  const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
23823
- if (!existsSync5(file2)) throw missing(adapter.id, file2);
23881
+ if (!existsSync6(file2)) throw missing(adapter.id, file2);
23824
23882
  const current = readHostConfig(adapter.id, file2);
23825
23883
  const value = parseHostConfig(adapter.id, file2, current.text, current.format);
23826
23884
  const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
23827
23885
  const script = Array.isArray(args) ? args[0] : void 0;
23828
23886
  if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
23829
- return dirname6(script);
23887
+ return dirname7(script);
23830
23888
  }
23831
23889
  function candidate(adapter, env, worktree) {
23832
23890
  switch (adapter.installMode) {
@@ -23837,11 +23895,11 @@ function candidate(adapter, env, worktree) {
23837
23895
  case "hooks+mcp":
23838
23896
  return configEntryRoot(adapter, env);
23839
23897
  case "extension":
23840
- return join10(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23898
+ return join11(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23841
23899
  case "plugin":
23842
- return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23900
+ return join11(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23843
23901
  case "in-process":
23844
- return dirname6(fileURLToPath(import.meta.url));
23902
+ return dirname7(fileURLToPath2(import.meta.url));
23845
23903
  }
23846
23904
  }
23847
23905
  function resolvePluginRoot(adapter, env, worktree) {
@@ -23930,11 +23988,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
23930
23988
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
23931
23989
  function mcpFile(row5, home, env) {
23932
23990
  const spec = OWN_MCP_ENTRY[row5.id];
23933
- if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
23991
+ if (row5.id === "codex") return join12(codexDirOf(env, home), CONFIG_TOML_FILE);
23934
23992
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
23935
- if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
23993
+ if (row5.id === "opencode") return join12(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
23936
23994
  if (row5.id === "pi") {
23937
- return join11(piAgentDirOf(env, home), SETTINGS_FILE);
23995
+ return join12(piAgentDirOf(env, home), SETTINGS_FILE);
23938
23996
  }
23939
23997
  return null;
23940
23998
  }
@@ -23947,27 +24005,27 @@ function codexNativeDir(env, home) {
23947
24005
  const codexDir = codexDirOf(env, home);
23948
24006
  let enabled;
23949
24007
  try {
23950
- enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24008
+ enabled = hostConfigValueAt(readParsed("codex", join12(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
23951
24009
  } catch {
23952
24010
  return null;
23953
24011
  }
23954
24012
  if (enabled !== true) return null;
23955
- const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
23956
- if (!existsSync6(cache)) return null;
24013
+ const cache = join12(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24014
+ if (!existsSync7(cache)) return null;
23957
24015
  const found = [];
23958
24016
  for (const market of readdirSync4(cache)) {
23959
- const plugin = join11(cache, market, SERVER_KEY);
23960
- if (!existsSync6(plugin)) continue;
24017
+ const plugin = join12(cache, market, SERVER_KEY);
24018
+ if (!existsSync7(plugin)) continue;
23961
24019
  for (const version2 of readdirSync4(plugin).sort()) {
23962
- const dir = join11(plugin, version2, CODEX_PLUGIN_SUBDIR);
23963
- if (existsSync6(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24020
+ const dir = join12(plugin, version2, CODEX_PLUGIN_SUBDIR);
24021
+ if (existsSync7(join12(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
23964
24022
  }
23965
24023
  }
23966
24024
  return found.length === 0 ? null : found[found.length - 1];
23967
24025
  }
23968
24026
  function nativeMcpWrong(dir, row5) {
23969
24027
  try {
23970
- const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24028
+ const entry = hostConfigValueAt(readParsed(row5.id, join12(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
23971
24029
  if (!isObject4(entry)) return true;
23972
24030
  const args = list2(entry[MCP_ARGS_FIELD]);
23973
24031
  const script = args[0];
@@ -23976,6 +24034,17 @@ function nativeMcpWrong(dir, row5) {
23976
24034
  return true;
23977
24035
  }
23978
24036
  }
24037
+ function isOwnOpencodeEntry(entry, key, own2) {
24038
+ const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
24039
+ if (typeof spec !== "string") return false;
24040
+ if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own2.includes(spec)) return true;
24041
+ return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
24042
+ }
24043
+ function opencodeListed(file2) {
24044
+ const { value } = readParsed("opencode", file2);
24045
+ const own2 = [opencodePluginFile()];
24046
+ return [OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own2)));
24047
+ }
23979
24048
  function mcpWrong(row5, home, env, worktree) {
23980
24049
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
23981
24050
  if (native !== null) return nativeMcpWrong(native, row5);
@@ -23985,6 +24054,7 @@ function mcpWrong(row5, home, env, worktree) {
23985
24054
  resolvePluginRoot(row5, env, worktree);
23986
24055
  return false;
23987
24056
  }
24057
+ if (row5.id === "opencode") return !opencodeListed(file2);
23988
24058
  const cur = readHostConfig(row5.id, file2);
23989
24059
  return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
23990
24060
  } catch {
@@ -23994,7 +24064,7 @@ function mcpWrong(row5, home, env, worktree) {
23994
24064
  function hookFile(row5, spec, home, env, worktree) {
23995
24065
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
23996
24066
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
23997
- 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);
24067
+ 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);
23998
24068
  return file2;
23999
24069
  }
24000
24070
  function hookParts(row5, home, env, worktree) {
@@ -24005,7 +24075,7 @@ function hookParts(row5, home, env, worktree) {
24005
24075
  const file2 = hookFile(row5, spec, home, env, worktree);
24006
24076
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24007
24077
  if (row5.id === "codex") {
24008
- const config2 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24078
+ const config2 = readParsed(row5.id, join12(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24009
24079
  if (hostConfigValueAt(config2, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24010
24080
  }
24011
24081
  } catch {
@@ -24063,10 +24133,10 @@ function parsedOrNull(agent, file2, jsonc) {
24063
24133
  }
24064
24134
  function checkDoubleFire(agent, worktree) {
24065
24135
  if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
24066
- const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24136
+ const claude = parsedOrNull(agent, join12(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24067
24137
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
24068
24138
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
24069
- const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24139
+ const vscode = parsedOrNull(agent, join12(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24070
24140
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
24071
24141
  return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
24072
24142
  }
@@ -24077,7 +24147,7 @@ function configPaths(row5, env, worktree) {
24077
24147
  const mcp = mcpFile(row5, home, env);
24078
24148
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
24079
24149
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24080
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
24150
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join12(native, CODEX_PLUGIN_MCP_FILE) });
24081
24151
  const spec = HOOK_HOST_FILE[row5.id];
24082
24152
  if (spec !== null) {
24083
24153
  try {
@@ -24097,7 +24167,7 @@ function configPaths(row5, env, worktree) {
24097
24167
  }
24098
24168
 
24099
24169
  // src/core/ops/doctor-db.ts
24100
- import { existsSync as existsSync7, statSync as statSync5 } from "node:fs";
24170
+ import { existsSync as existsSync8, statSync as statSync5 } from "node:fs";
24101
24171
  var unknown2 = (id2, detail) => ({ id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail });
24102
24172
  var pass2 = (id2, detail) => ({ id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail });
24103
24173
  var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
@@ -24139,15 +24209,15 @@ function orphanFiles(dbPath) {
24139
24209
  const files = [];
24140
24210
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
24141
24211
  const path7 = dbPath + suffix;
24142
- if (existsSync7(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24212
+ if (existsSync8(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24143
24213
  }
24144
- return files.length > 0 && !existsSync7(dbPath) ? files : [];
24214
+ return files.length > 0 && !existsSync8(dbPath) ? files : [];
24145
24215
  }
24146
24216
  async function checkDb(project) {
24147
24217
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
24148
24218
  const orphan = orphanFiles(project.dbPath);
24149
24219
  if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
24150
- if (!existsSync7(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24220
+ if (!existsSync8(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24151
24221
  const sqlite = await loadSqlite2();
24152
24222
  if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
24153
24223
  let raw = null;
@@ -24173,7 +24243,7 @@ async function checkDb(project) {
24173
24243
  }
24174
24244
  }
24175
24245
  async function checkIndex(project) {
24176
- if (!existsSync7(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24246
+ if (!existsSync8(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24177
24247
  const sqlite = await loadSqlite2();
24178
24248
  if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
24179
24249
  let raw = null;
@@ -24190,8 +24260,8 @@ async function checkIndex(project) {
24190
24260
  }
24191
24261
 
24192
24262
  // src/core/ops/doctor-env.ts
24193
- import { existsSync as existsSync8, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24194
- import { isAbsolute as isAbsolute3, join as join12, relative as relative2 } from "node:path";
24263
+ import { existsSync as existsSync9, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24264
+ import { isAbsolute as isAbsolute3, join as join13, relative as relative2 } from "node:path";
24195
24265
  function pass3(id2, detail = DOCTOR_PASS_DETAIL) {
24196
24266
  return { id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail };
24197
24267
  }
@@ -24203,7 +24273,7 @@ function fail4(id2, detail, fixCommand) {
24203
24273
  }
24204
24274
  function bundleVersion(bundleDir2) {
24205
24275
  try {
24206
- const v = JSON.parse(readFileSync9(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24276
+ const v = JSON.parse(readFileSync9(join13(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24207
24277
  return typeof v === "string" && v !== "" ? v : void 0;
24208
24278
  } catch {
24209
24279
  return void 0;
@@ -24353,7 +24423,7 @@ function checkMcp(ctx) {
24353
24423
  return named2 || versioned ? pass3("D6") : unknown3("D6", D6_UNKNOWN_DETAIL);
24354
24424
  }
24355
24425
  function piCwdInside(worktree, piCwd) {
24356
- if (piCwd === void 0 || !existsSync8(piCwd)) return false;
24426
+ if (piCwd === void 0 || !existsSync9(piCwd)) return false;
24357
24427
  const rel = relative2(worktree, realpathSync5.native(piCwd));
24358
24428
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
24359
24429
  }
@@ -24374,13 +24444,13 @@ function checkShell(env) {
24374
24444
  }
24375
24445
 
24376
24446
  // src/core/ops/doctor-hook.ts
24377
- import { existsSync as existsSync10, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24447
+ import { existsSync as existsSync11, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24378
24448
  import { tmpdir as tmpdir2 } from "node:os";
24379
24449
  import path6 from "node:path";
24380
24450
 
24381
24451
  // src/setup/codex-trust.ts
24382
24452
  import { createHash } from "node:crypto";
24383
- import { existsSync as existsSync9, realpathSync as realpathSync6 } from "node:fs";
24453
+ import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
24384
24454
  import path5 from "node:path";
24385
24455
  import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
24386
24456
 
@@ -24478,6 +24548,7 @@ var LIST_TIMEOUT_MS = 15e3;
24478
24548
  var EXIT_GRACE_MS = 5e3;
24479
24549
  var PLUGIN_SOURCE = "plugin";
24480
24550
  var TRUSTED = "trusted";
24551
+ var UNTRUSTED = "untrusted";
24481
24552
  function pluginHooksFromReply(m, pluginId) {
24482
24553
  const out = [];
24483
24554
  if (!isObj2(m) || !isObj2(m.result) || !Array.isArray(m.result.data)) return out;
@@ -24487,7 +24558,8 @@ function pluginHooksFromReply(m, pluginId) {
24487
24558
  if (!isObj2(h) || h.source !== PLUGIN_SOURCE || h.pluginId !== pluginId) continue;
24488
24559
  if (typeof h.key !== "string" || typeof h.currentHash !== "string") continue;
24489
24560
  if (out.some((x) => x.key === h.key)) continue;
24490
- out.push({ key: h.key, hash: h.currentHash, trusted: h.trustStatus === TRUSTED });
24561
+ const status = typeof h.trustStatus === "string" ? h.trustStatus : UNTRUSTED;
24562
+ out.push({ key: h.key, hash: h.currentHash, trusted: status === TRUSTED, status });
24491
24563
  }
24492
24564
  }
24493
24565
  return out;
@@ -24580,7 +24652,11 @@ var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
24580
24652
  function untrustedPluginHooksDetail(hooks) {
24581
24653
  const bad = hooks.filter((h) => !h.trusted);
24582
24654
  if (!bad.length) return void 0;
24583
- return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks untrusted, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24655
+ const counts = /* @__PURE__ */ new Map();
24656
+ for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
24657
+ const words = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
24658
+ const state = words.length === 1 ? words[0][0] : `${words.map(([w]) => w).join(" or ")} (${words.map(([w, n]) => `${n} ${w}`).join(", ")})`;
24659
+ return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24584
24660
  }
24585
24661
 
24586
24662
  // src/core/ops/doctor-hook.ts
@@ -24597,7 +24673,7 @@ function isObject5(v) {
24597
24673
  }
24598
24674
  function loadFixture(bundleDir2, agent) {
24599
24675
  const file2 = path6.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
24600
- if (!existsSync10(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24676
+ if (!existsSync11(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24601
24677
  let all;
24602
24678
  try {
24603
24679
  all = JSON.parse(hostText(readFileSync10(file2, "utf8")));
@@ -24736,7 +24812,7 @@ async function checkHookRoundTrip(i) {
24736
24812
  const trust = await codexPluginTrust(i);
24737
24813
  if (trust !== null) return trust;
24738
24814
  }
24739
- if (i.agent === "codex" && existsSync10(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24815
+ if (i.agent === "codex" && existsSync11(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24740
24816
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
24741
24817
  }
24742
24818
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -24775,14 +24851,14 @@ async function checkHookRoundTrip(i) {
24775
24851
  }
24776
24852
 
24777
24853
  // src/core/ops/db-heal.ts
24778
- import { existsSync as existsSync11, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
24779
- import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
24854
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
24855
+ import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
24780
24856
 
24781
24857
  // src/core/store/owners.ts
24782
24858
  import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync11, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
24783
- import { basename as basename3, join as join13 } from "node:path";
24859
+ import { basename as basename3, join as join14 } from "node:path";
24784
24860
  function ownersDir(configDir, projectKey) {
24785
- return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24861
+ return join14(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24786
24862
  }
24787
24863
  function errCode2(err) {
24788
24864
  return err.code;
@@ -24810,7 +24886,7 @@ function listLiveOwners(configDir, projectKey) {
24810
24886
  const live = [];
24811
24887
  for (const name of names) {
24812
24888
  if (!name.endsWith(OWNER_PID_EXT)) continue;
24813
- const file2 = join13(dir, name);
24889
+ const file2 = join14(dir, name);
24814
24890
  let text;
24815
24891
  try {
24816
24892
  text = readFileSync11(file2, "utf8");
@@ -24859,7 +24935,7 @@ function renameAside(dbPath) {
24859
24935
  const ts = String(Date.now());
24860
24936
  for (const suffix of DB_SIBLING_SUFFIXES) {
24861
24937
  const file2 = dbPath + suffix;
24862
- if (existsSync11(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24938
+ if (existsSync12(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24863
24939
  }
24864
24940
  return ts;
24865
24941
  }
@@ -24882,7 +24958,7 @@ function utcStamp(now) {
24882
24958
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
24883
24959
  }
24884
24960
  function makeOrphanDir(projectDir) {
24885
- const base = join14(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24961
+ const base = join15(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24886
24962
  for (let n = 1; ; n += 1) {
24887
24963
  const dir = n === 1 ? base : base + "-" + String(n);
24888
24964
  try {
@@ -24897,9 +24973,9 @@ async function healOrphan(project, files, row5) {
24897
24973
  const moved = [];
24898
24974
  let dir = "";
24899
24975
  try {
24900
- dir = makeOrphanDir(dirname7(project.dbPath));
24976
+ dir = makeOrphanDir(dirname8(project.dbPath));
24901
24977
  for (const f of files) {
24902
- const to = join14(dir, basename4(f.path));
24978
+ const to = join15(dir, basename4(f.path));
24903
24979
  renameWithRetry(f.path, to);
24904
24980
  moved.push({ path: to, bytes: f.bytes });
24905
24981
  }
@@ -24966,8 +25042,8 @@ function buildReportHead(input) {
24966
25042
 
24967
25043
  // src/core/ops/doctor-issue.ts
24968
25044
  import { spawnSync as spawnSync3 } from "node:child_process";
24969
- import { closeSync, existsSync as existsSync12, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
24970
- import { delimiter, join as join15 } from "node:path";
25045
+ import { closeSync, existsSync as existsSync13, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
25046
+ import { delimiter, join as join16 } from "node:path";
24971
25047
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
24972
25048
  function tildeOf(env) {
24973
25049
  const home = homeDirOf(env);
@@ -25008,8 +25084,8 @@ function onPath(env, tool) {
25008
25084
  const out = [];
25009
25085
  for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
25010
25086
  if (dir === "") continue;
25011
- for (const n of names) if (existsSync12(join15(dir, n))) {
25012
- out.push(join15(dir, n));
25087
+ for (const n of names) if (existsSync13(join16(dir, n))) {
25088
+ out.push(join16(dir, n));
25013
25089
  break;
25014
25090
  }
25015
25091
  }
@@ -25017,7 +25093,7 @@ function onPath(env, tool) {
25017
25093
  }
25018
25094
  function hookLogTail(env) {
25019
25095
  const file2 = hookLogPath(env);
25020
- if (file2 === "" || !existsSync12(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25096
+ if (file2 === "" || !existsSync13(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25021
25097
  try {
25022
25098
  const fd = openSync(file2, "r");
25023
25099
  try {
@@ -25037,7 +25113,7 @@ function hookLogTail(env) {
25037
25113
  }
25038
25114
  async function journalRows(ctx) {
25039
25115
  const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
25040
- if (!existsSync12(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25116
+ if (!existsSync13(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25041
25117
  try {
25042
25118
  const db = await openDb(ctx.project, { readOnly: true });
25043
25119
  try {
@@ -25055,15 +25131,15 @@ function agentConfig(adapter, env, worktree) {
25055
25131
  const home = homeDirOf(env);
25056
25132
  const files = configPaths(adapter, env, worktree);
25057
25133
  if (home !== null) {
25058
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join15(claudeDirOf(env, home), SETTINGS_FILE) });
25059
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join15(codexDirOf(env, home), CONFIG_TOML_FILE) });
25134
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join16(claudeDirOf(env, home), SETTINGS_FILE) });
25135
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join16(codexDirOf(env, home), CONFIG_TOML_FILE) });
25060
25136
  }
25061
25137
  const out = [];
25062
25138
  const seen = /* @__PURE__ */ new Set();
25063
25139
  for (const f of files) {
25064
25140
  if (seen.has(f.path)) continue;
25065
25141
  seen.add(f.path);
25066
- if (!existsSync12(f.path)) {
25142
+ if (!existsSync13(f.path)) {
25067
25143
  out.push(`${f.label}: ${f.path} (absent)`);
25068
25144
  continue;
25069
25145
  }
@@ -25139,14 +25215,14 @@ async function buildIssueBody(i) {
25139
25215
  async function writeIssueReport(i) {
25140
25216
  const tilde = tildeOf(i.env);
25141
25217
  const body = await buildIssueBody(i);
25142
- const dir = join15(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25218
+ const dir = join16(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25143
25219
  mkdirSync6(dir, { recursive: true });
25144
- const file2 = join15(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25220
+ const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25145
25221
  writeFileSync3(file2, body);
25146
25222
  const shown2 = tilde(file2);
25147
25223
  const title = issueTitle(i.adapter.id, i.rows);
25148
25224
  const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
25149
- 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))];
25225
+ 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];
25150
25226
  }
25151
25227
  function formUrl(title, summary) {
25152
25228
  const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
@@ -25168,7 +25244,7 @@ async function guard(id2, run) {
25168
25244
  }
25169
25245
  }
25170
25246
  async function codexDb(ctx, adapter) {
25171
- if (adapter.id !== "codex" || !existsSync13(ctx.project.dbPath)) return null;
25247
+ if (adapter.id !== "codex" || !existsSync14(ctx.project.dbPath)) return null;
25172
25248
  try {
25173
25249
  return await openDb(ctx.project, { readOnly: true });
25174
25250
  } catch {
@@ -25198,11 +25274,11 @@ async function hookRow(ctx, adapter, host) {
25198
25274
  }
25199
25275
  }
25200
25276
  function ownServerId(configDir, projectKey) {
25201
- const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25202
- if (!existsSync13(dir)) return "";
25277
+ const dir = join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25278
+ if (!existsSync14(dir)) return "";
25203
25279
  for (const name of readdirSync6(dir)) {
25204
25280
  if (!name.endsWith(OWNER_PID_EXT)) continue;
25205
- if (readFileSync13(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25281
+ if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25206
25282
  }
25207
25283
  return "";
25208
25284
  }
@@ -25285,7 +25361,7 @@ async function doctorReply(ctx, host) {
25285
25361
  return { text, isError: false, sandboxBytes: bytes5 };
25286
25362
  }
25287
25363
  async function handler2(_input, ctx) {
25288
- return doctorReply(ctx, { env: process.env, bundleDir: dirname8(process.argv[1]), piCwd: void 0 });
25364
+ return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: void 0 });
25289
25365
  }
25290
25366
  var ctxDoctor = Object.freeze({
25291
25367
  name: "ctx_doctor",
@@ -25297,9 +25373,9 @@ var ctxDoctor = Object.freeze({
25297
25373
  });
25298
25374
 
25299
25375
  // src/core/tools/execute.ts
25300
- import { existsSync as existsSync14, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25376
+ import { existsSync as existsSync15, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25301
25377
  import { tmpdir as tmpdir3 } from "node:os";
25302
- import { dirname as dirname9, join as join17, parse as parse3, resolve as resolve6 } from "node:path";
25378
+ import { dirname as dirname10, join as join18, parse as parse3, resolve as resolve6 } from "node:path";
25303
25379
 
25304
25380
  // src/core/sandbox/win-build.ts
25305
25381
  var SEPARATORS2 = ";&|(\n";
@@ -25383,7 +25459,7 @@ function schemaLine(issue2) {
25383
25459
  }
25384
25460
  function fileError(given, abs, root) {
25385
25461
  let dir = abs;
25386
- while (!existsSync14(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
25462
+ while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
25387
25463
  if (isInside(root, dir)) return null;
25388
25464
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
25389
25465
  }
@@ -25464,8 +25540,8 @@ async function handler3(raw, ctx) {
25464
25540
  if (takesDashC(input.language, runtime)) {
25465
25541
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
25466
25542
  } else {
25467
- tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
25468
- const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25543
+ tmpDir = mkdtempSync2(join18(tmpdir3(), TMP_PREFIX));
25544
+ const file2 = join18(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25469
25545
  writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
25470
25546
  argv = scriptArgv(input.language, runtime, file2);
25471
25547
  }
@@ -25500,12 +25576,12 @@ var ctxExecute = {
25500
25576
  };
25501
25577
 
25502
25578
  // src/core/tools/index.ts
25503
- import { existsSync as existsSync15, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25504
- import { dirname as dirname10, extname, join as join19, relative as relative3, resolve as resolve7 } from "node:path";
25579
+ import { existsSync as existsSync16, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25580
+ import { dirname as dirname11, extname, join as join20, relative as relative3, resolve as resolve7 } from "node:path";
25505
25581
 
25506
25582
  // src/core/index/walk.ts
25507
25583
  import { readdirSync as readdirSync7, readFileSync as readFileSync14, realpathSync as realpathSync9, statSync as statSync7 } from "node:fs";
25508
- import { join as join18 } from "node:path";
25584
+ import { join as join19 } from "node:path";
25509
25585
  var GITIGNORE = ".gitignore";
25510
25586
  var GIT_DIR = ".git";
25511
25587
  function walkDir(root, containmentRoot) {
@@ -25514,7 +25590,7 @@ function walkDir(root, containmentRoot) {
25514
25590
  const found = [];
25515
25591
  visit(real2, [], [], containmentRoot, /* @__PURE__ */ new Set([real2]), found);
25516
25592
  found.sort(compareFound);
25517
- return found.map((f) => ({ absPath: f.absPath, relPath: join18(...f.dir, f.name) }));
25593
+ return found.map((f) => ({ absPath: f.absPath, relPath: join19(...f.dir, f.name) }));
25518
25594
  }
25519
25595
  function visit(abs, rel, parent, contain, seen, found) {
25520
25596
  let entries;
@@ -25523,10 +25599,10 @@ function visit(abs, rel, parent, contain, seen, found) {
25523
25599
  } catch {
25524
25600
  return;
25525
25601
  }
25526
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join18(abs, GITIGNORE), rel)) : parent;
25602
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join19(abs, GITIGNORE), rel)) : parent;
25527
25603
  for (const e of entries) {
25528
25604
  if (e.name === GIT_DIR) continue;
25529
- const path7 = join18(abs, e.name);
25605
+ const path7 = join19(abs, e.name);
25530
25606
  let isDir = e.isDirectory();
25531
25607
  let isFile = e.isFile();
25532
25608
  let target = path7;
@@ -29656,7 +29732,7 @@ function readUtf8(absPath) {
29656
29732
  }
29657
29733
  function missingOrOutside(given, abs, root) {
29658
29734
  let dir = abs;
29659
- while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
29735
+ while (!existsSync16(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
29660
29736
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
29661
29737
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
29662
29738
  }
@@ -29667,7 +29743,7 @@ function pathItems(input, project) {
29667
29743
  if (statSync8(abs).isDirectory()) {
29668
29744
  return walkDir(abs, project.containmentRoot).map((f) => ({
29669
29745
  sourceKind: "path",
29670
- label: pathLabel(join19(base, f.relPath)),
29746
+ label: pathLabel(join20(base, f.relPath)),
29671
29747
  kind: kindOfPath(f.relPath),
29672
29748
  read: () => readUtf8(f.absPath)
29673
29749
  }));
@@ -30207,12 +30283,12 @@ var ctxStats = Object.freeze({
30207
30283
  });
30208
30284
 
30209
30285
  // src/core/tools/upgrade.ts
30210
- import { existsSync as existsSync21, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
30211
- import { basename as basename7, dirname as dirname12, join as join25 } from "node:path";
30286
+ import { existsSync as existsSync22, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
30287
+ import { basename as basename7, dirname as dirname13, join as join26 } from "node:path";
30212
30288
 
30213
30289
  // src/core/ops/host-write.ts
30214
- import { copyFileSync, existsSync as existsSync16, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30215
- import { dirname as dirname11, join as join20 } from "node:path";
30290
+ import { copyFileSync, existsSync as existsSync17, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30291
+ import { dirname as dirname12, join as join21 } from "node:path";
30216
30292
  function defaultWrite(file2, text) {
30217
30293
  writeFileSync5(file2, text, "utf8");
30218
30294
  }
@@ -30221,14 +30297,14 @@ function hostConfigPath(agent, home, env) {
30221
30297
  if (own2 !== void 0) return ownMcpFileOf(agent, own2.file, env, home);
30222
30298
  switch (agent) {
30223
30299
  case "opencode":
30224
- return join20(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30300
+ return join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30225
30301
  // D-WIN-OPENCODE-DIR-1
30226
30302
  case "pi":
30227
- return join20(piAgentDirOf(env, home), SETTINGS_FILE);
30303
+ return join21(piAgentDirOf(env, home), SETTINGS_FILE);
30228
30304
  case "copilot-cli":
30229
30305
  return null;
30230
30306
  default:
30231
- return join20(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30307
+ return join21(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30232
30308
  }
30233
30309
  }
30234
30310
  function cell3(value) {
@@ -30240,8 +30316,8 @@ function toRow(file2, edit) {
30240
30316
  function writeWithRollback(file2, text, write2, atomic) {
30241
30317
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
30242
30318
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
30243
- const had = existsSync16(file2);
30244
- mkdirSync7(dirname11(file2), { recursive: true });
30319
+ const had = existsSync17(file2);
30320
+ mkdirSync7(dirname12(file2), { recursive: true });
30245
30321
  if (had) copyFileSync(file2, trash);
30246
30322
  try {
30247
30323
  write2(tmp, text);
@@ -30270,7 +30346,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
30270
30346
  if (requested === null) return [];
30271
30347
  const current = readHostConfig(row5.id, requested);
30272
30348
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
30273
- const exists = existsSync16(current.path);
30349
+ const exists = existsSync17(current.path);
30274
30350
  if (exists && result.text === current.text) return [];
30275
30351
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
30276
30352
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -30278,8 +30354,8 @@ function regenerateHostConfig(row5, home, opts = {}) {
30278
30354
  }
30279
30355
 
30280
30356
  // src/core/ops/plugin-swap.ts
30281
- import { existsSync as existsSync17, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30282
- import { basename as basename6, join as join21, win32 as win322 } from "node:path";
30357
+ import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30358
+ import { basename as basename6, join as join22, win32 as win322 } from "node:path";
30283
30359
  function linkTarget(path7, win) {
30284
30360
  if (!isLink(path7)) return null;
30285
30361
  const target = readlinkSync(path7);
@@ -30298,11 +30374,11 @@ function settleLinks(link, tmp, old, opts) {
30298
30374
  else renameWithRetry(old, link, opts);
30299
30375
  }
30300
30376
  function swapPluginCurrent(agentDir, sha, opts = {}) {
30301
- const next = join21(agentDir, sha);
30302
- if (!existsSync17(next) || !lstatSync(next).isDirectory()) {
30377
+ const next = join22(agentDir, sha);
30378
+ if (!existsSync18(next) || !lstatSync(next).isDirectory()) {
30303
30379
  throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
30304
30380
  }
30305
- const link = join21(agentDir, PLUGIN_CURRENT_LINK);
30381
+ const link = join22(agentDir, PLUGIN_CURRENT_LINK);
30306
30382
  const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
30307
30383
  const old = link + PLUGIN_LINK_OLD_SUFFIX;
30308
30384
  settleLinks(link, tmp, old, opts);
@@ -30317,15 +30393,15 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
30317
30393
  if (before !== null) unlinkSync2(old);
30318
30394
  const keep = /* @__PURE__ */ new Set([sha]);
30319
30395
  if (before !== null) keep.add(before);
30320
- const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join21(agentDir, name));
30396
+ const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join22(agentDir, name));
30321
30397
  for (const dir of removed) rmSync6(dir, { recursive: true, force: true });
30322
- const previous = before !== null && existsSync17(join21(agentDir, before)) ? join21(agentDir, before) : null;
30398
+ const previous = before !== null && existsSync18(join22(agentDir, before)) ? join22(agentDir, before) : null;
30323
30399
  return { current: next, previous, removed };
30324
30400
  }
30325
30401
 
30326
30402
  // src/core/ops/release-fetch.ts
30327
- import { existsSync as existsSync18, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
30328
- import { join as join22 } from "node:path";
30403
+ import { existsSync as existsSync19, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
30404
+ import { join as join23 } from "node:path";
30329
30405
  function failed(r) {
30330
30406
  if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
30331
30407
  const status = r.killed ?? String(r.exitCode);
@@ -30337,9 +30413,9 @@ async function git2(bin, args, cwd, env, signal) {
30337
30413
  return r.stdout.toString().trim();
30338
30414
  }
30339
30415
  async function fetchRelease(agent, url2, env, signal, opts = {}) {
30340
- const agentDir = join22(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30416
+ const agentDir = join23(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30341
30417
  mkdirSync8(agentDir, { recursive: true });
30342
- const fetchDir = join22(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30418
+ const fetchDir = join23(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30343
30419
  rmSync7(fetchDir, { recursive: true, force: true });
30344
30420
  const gitBin = findRuntime(GIT_BIN, env);
30345
30421
  if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
@@ -30347,8 +30423,8 @@ async function fetchRelease(agent, url2, env, signal, opts = {}) {
30347
30423
  try {
30348
30424
  await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url2, fetchDir], agentDir, childEnv, signal);
30349
30425
  const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
30350
- const dir = join22(agentDir, sha);
30351
- if (existsSync18(dir)) rmSync7(fetchDir, { recursive: true, force: true });
30426
+ const dir = join23(agentDir, sha);
30427
+ if (existsSync19(dir)) rmSync7(fetchDir, { recursive: true, force: true });
30352
30428
  else renameWithRetry(fetchDir, dir, opts);
30353
30429
  return { sha, dir };
30354
30430
  } catch (e) {
@@ -30358,15 +30434,15 @@ async function fetchRelease(agent, url2, env, signal, opts = {}) {
30358
30434
  }
30359
30435
 
30360
30436
  // src/core/ops/uninstall.ts
30361
- import { existsSync as existsSync19, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
30362
- import { join as join23 } from "node:path";
30437
+ import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
30438
+ import { join as join24 } from "node:path";
30363
30439
  function row2(area, before, after) {
30364
30440
  return { area, before, after };
30365
30441
  }
30366
30442
  function stopServers(configDir, projectKey) {
30367
30443
  const stopped = listLiveOwners(configDir, projectKey);
30368
- const dir = join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30369
- for (const serverId of stopped) writeFileSync6(join23(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30444
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30445
+ for (const serverId of stopped) writeFileSync6(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30370
30446
  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 };
30371
30447
  }
30372
30448
  function rootOrNull(adapter, env) {
@@ -30384,15 +30460,15 @@ function removeCache(adapter, env, configDir) {
30384
30460
  const root = rootOrNull(adapter, env);
30385
30461
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30386
30462
  if (adapter.installMode === "marketplace") {
30387
- const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30463
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30388
30464
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
30389
30465
  }
30390
30466
  rmSync8(root, { recursive: true, force: true });
30391
30467
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
30392
30468
  }
30393
30469
  case "plugin": {
30394
- const agentDir = join23(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30395
- if (!existsSync19(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30470
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30471
+ if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30396
30472
  rmSync8(agentDir, { recursive: true, force: true });
30397
30473
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
30398
30474
  }
@@ -30437,7 +30513,7 @@ function ownEntries(agent, env) {
30437
30513
  }
30438
30514
  if (agent === "opencode") {
30439
30515
  return [{
30440
- file: join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30516
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30441
30517
  // D-WIN-OPENCODE-DIR-1
30442
30518
  key: OPENCODE_PLUGIN_KEY,
30443
30519
  shown: OPENCODE_PLUGIN_KEY,
@@ -30448,7 +30524,7 @@ function ownEntries(agent, env) {
30448
30524
  if (agent === "pi") {
30449
30525
  const agentDir = piAgentDirOf(env, home);
30450
30526
  return [{
30451
- file: join23(agentDir, SETTINGS_FILE),
30527
+ file: join24(agentDir, SETTINGS_FILE),
30452
30528
  key: PI_PACKAGES_KEY,
30453
30529
  shown: PI_PACKAGES_KEY,
30454
30530
  has: (v) => Array.isArray(v) && v.some((x) => piSource(x) === PI_GIT_PACKAGE),
@@ -30470,12 +30546,12 @@ function removeOwnEntries(agent, env) {
30470
30546
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
30471
30547
  }
30472
30548
  function removeProjectData(configDir, projectKey) {
30473
- const projects = join23(configDir, PROJECTS_DIR_NAME);
30474
- const dir = join23(projects, projectKey);
30475
- if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30549
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
30550
+ const dir = join24(projects, projectKey);
30551
+ if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30476
30552
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
30477
30553
  for (const name of readdirSync9(dir)) {
30478
- if (name !== OWNERS_DIR_NAME) rmSync8(join23(dir, name), { recursive: true, force: true });
30554
+ if (name !== OWNERS_DIR_NAME) rmSync8(join24(dir, name), { recursive: true, force: true });
30479
30555
  }
30480
30556
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
30481
30557
  }
@@ -30483,12 +30559,12 @@ function runUninstall(input) {
30483
30559
  const configDir = resolveConfigDir(input.env);
30484
30560
  const stop = stopServers(configDir, input.project.projectKey);
30485
30561
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
30486
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join23(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30562
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30487
30563
  return { rows, stopped: stop.stopped };
30488
30564
  }
30489
30565
 
30490
30566
  // src/core/ops/v1-remove.ts
30491
- import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30567
+ import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30492
30568
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30493
30569
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
30494
30570
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -30569,14 +30645,14 @@ function removeV1(agent, findings) {
30569
30645
  for (const f of findings) {
30570
30646
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
30571
30647
  else if (f.path === "") {
30572
- if (existsSync20(f.file)) {
30648
+ if (existsSync21(f.file)) {
30573
30649
  moveAside(f.file, undo);
30574
30650
  done.set(f, UPGRADE_REMOVED);
30575
30651
  } else done.set(f, UPGRADE_NOT_FOUND);
30576
30652
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
30577
30653
  }
30578
30654
  for (const [file2, list4] of entries) {
30579
- if (!existsSync20(file2)) {
30655
+ if (!existsSync21(file2)) {
30580
30656
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
30581
30657
  continue;
30582
30658
  }
@@ -30609,7 +30685,7 @@ function removeV1(agent, findings) {
30609
30685
  },
30610
30686
  rollback() {
30611
30687
  for (const u of undo.splice(0).reverse()) {
30612
- if (!existsSync20(u.trash)) continue;
30688
+ if (!existsSync21(u.trash)) continue;
30613
30689
  rmSync9(u.target, { recursive: true, force: true });
30614
30690
  renameWithRetry(u.trash, u.target);
30615
30691
  }
@@ -30620,7 +30696,7 @@ function removeV1(agent, findings) {
30620
30696
  // src/core/ops/verify-sums.ts
30621
30697
  import { createHash as createHash2 } from "node:crypto";
30622
30698
  import { lstatSync as lstatSync2, readdirSync as readdirSync10, readFileSync as readFileSync17 } from "node:fs";
30623
- import { join as join24 } from "node:path";
30699
+ import { join as join25 } from "node:path";
30624
30700
  function mismatch() {
30625
30701
  return new CtxError("BUNDLE_HASH_MISMATCH");
30626
30702
  }
@@ -30641,14 +30717,14 @@ function walk3(dir, prefix, out) {
30641
30717
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
30642
30718
  const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
30643
30719
  if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
30644
- const abs = join24(dir, entry.name);
30720
+ const abs = join25(dir, entry.name);
30645
30721
  if (entry.isDirectory()) walk3(abs, rel, out);
30646
30722
  else if (entry.isFile()) out.set(rel, abs);
30647
30723
  else throw mismatch();
30648
30724
  }
30649
30725
  }
30650
30726
  function verifySums(dir) {
30651
- const sumsPath = join24(dir, RELEASE_SUMS_FILE);
30727
+ const sumsPath = join25(dir, RELEASE_SUMS_FILE);
30652
30728
  const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
30653
30729
  if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
30654
30730
  const sums = parseSums(readFileSync17(sumsPath, "utf8"));
@@ -30672,7 +30748,7 @@ function row4(area, before, after) {
30672
30748
  return { area, before, after };
30673
30749
  }
30674
30750
  function bundleDir() {
30675
- return dirname12(process.argv[1] ?? "");
30751
+ return ownBundleDir();
30676
30752
  }
30677
30753
  function pluginRootRow(adapter, env) {
30678
30754
  const own2 = bundleDir();
@@ -30686,12 +30762,12 @@ function pluginRootRow(adapter, env) {
30686
30762
  return root === own2 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own2)];
30687
30763
  }
30688
30764
  function isCurrent(agentDir, dir) {
30689
- const link = join25(agentDir, PLUGIN_CURRENT_LINK);
30690
- return existsSync21(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30765
+ const link = join26(agentDir, PLUGIN_CURRENT_LINK);
30766
+ return existsSync22(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30691
30767
  }
30692
30768
  async function checkout(adapter, deps) {
30693
30769
  const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
30694
- const agentDir = dirname12(fetched.dir);
30770
+ const agentDir = dirname13(fetched.dir);
30695
30771
  try {
30696
30772
  verifySums(fetched.dir);
30697
30773
  } catch (err) {