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.
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 ? "d232ce4ddfb581a63a4c0d6ef894b64a0f8464f6" : void 0;
11575
11575
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11576
11576
  var DOCTOR_LABEL = Object.freeze({
11577
11577
  D1: "version",
@@ -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;
@@ -12722,7 +12739,8 @@ function encode7(ev, d, _extra) {
12722
12739
  }
12723
12740
 
12724
12741
  // src/adapters/kiro.ts
12725
- var TOOL_NAME_PREFIX8 = "mcp_context-mode_";
12742
+ var TOOL_NAME_PREFIX8 = "mcp_context_mode_";
12743
+ var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
12726
12744
  var KIRO_EVENTS = {
12727
12745
  SessionStart: "SessionStart",
12728
12746
  agentSpawn: "SessionStart",
@@ -12734,6 +12752,7 @@ var KIRO_EVENTS = {
12734
12752
  PostToolUse: "PostToolUse",
12735
12753
  postToolUse: "PostToolUse"
12736
12754
  };
12755
+ var PROMPT_FIELD = "prompt";
12737
12756
  var PROMPT_ENV = "USER_PROMPT";
12738
12757
  var MCP_PREFIX3 = "mcp_";
12739
12758
  var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
@@ -12742,6 +12761,7 @@ var MCP_SEP3 = "_";
12742
12761
  var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
12743
12762
  function canonicalName5(name) {
12744
12763
  if (name.startsWith(TOOL_NAME_PREFIX8)) return name.slice(TOOL_NAME_PREFIX8.length);
12764
+ if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
12745
12765
  if (Object.hasOwn(NATIVE_TO_CANONICAL6, name)) return NATIVE_TO_CANONICAL6[name];
12746
12766
  if (!name.startsWith(MCP_PREFIX3)) return name;
12747
12767
  const rest = name.slice(MCP_PREFIX3.length);
@@ -12762,7 +12782,8 @@ function decode8(raw) {
12762
12782
  const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
12763
12783
  if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
12764
12784
  if (event === "UserPromptSubmit") {
12765
- const prompt = process.env[PROMPT_ENV];
12785
+ const field = p[PROMPT_FIELD];
12786
+ const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
12766
12787
  if (prompt !== void 0) ev.prompt = prompt;
12767
12788
  }
12768
12789
  if (event === "PreToolUse" || event === "PostToolUse") {
@@ -12774,7 +12795,7 @@ function decode8(raw) {
12774
12795
  return ev;
12775
12796
  }
12776
12797
  function encode8(ev, d, _extra) {
12777
- if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
12798
+ if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
12778
12799
  switch (d.kind) {
12779
12800
  case "allow":
12780
12801
  return { stdout: "", exitCode: 0 };
@@ -13075,7 +13096,7 @@ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "
13075
13096
  function dumpRunsThenReplaces(row5) {
13076
13097
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
13077
13098
  }
13078
- var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode"]);
13099
+ var RECALL_ROWS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "zcode", "kiro"]);
13079
13100
  function hasRecall(row5) {
13080
13101
  return RECALL_ROWS.has(row5.id);
13081
13102
  }
@@ -14426,14 +14447,29 @@ function copilotDirOf(env, home) {
14426
14447
  function kiroDirOf(env, home, platform = process.platform) {
14427
14448
  const p = platform === "win32" ? win32 : posix;
14428
14449
  const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
14429
- const dir = env[KIRO_HOME_ENV];
14450
+ const dir = env[KIRO_HOME_ENV]?.trim();
14430
14451
  if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
14431
14452
  if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
14432
14453
  const abs = p.resolve(dir);
14433
- if (p.dirname(abs) === abs) return fallback;
14434
- const up = p.relative(abs, p.resolve(home));
14454
+ const real2 = platform === process.platform ? realOrSelf : (x) => x;
14455
+ const target = real2(abs);
14456
+ if (p.parse(target).root === target) return fallback;
14457
+ const up = p.relative(target, real2(p.resolve(home)));
14435
14458
  if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
14436
- return dir;
14459
+ return abs;
14460
+ }
14461
+ function realOrSelf(path7) {
14462
+ const tail = [];
14463
+ for (let at2 = path7; ; ) {
14464
+ try {
14465
+ return join(realpathSync.native(at2), ...tail.reverse());
14466
+ } catch {
14467
+ const up = dirname(at2);
14468
+ if (up === at2) return path7;
14469
+ tail.push(basename(at2));
14470
+ at2 = up;
14471
+ }
14472
+ }
14437
14473
  }
14438
14474
  function claudeDirOf(env, home) {
14439
14475
  const dir = env[CLAUDE_CONFIG_DIR_ENV];
@@ -19003,7 +19039,7 @@ function cutPoint(src, start, end, scratch) {
19003
19039
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
19004
19040
  return { end: start + r.read, written: r.written };
19005
19041
  }
19006
- function merge2(src, blocks, join28, cap, lineCut) {
19042
+ function merge2(src, blocks, join29, cap, lineCut) {
19007
19043
  const out = [];
19008
19044
  const scratch = new Uint8Array(cap);
19009
19045
  let wide;
@@ -19013,7 +19049,7 @@ function merge2(src, blocks, join28, cap, lineCut) {
19013
19049
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
19014
19050
  };
19015
19051
  for (const b of blocks) {
19016
- if (cur !== void 0 && !join28) {
19052
+ if (cur !== void 0 && !join29) {
19017
19053
  emit(cur.start, cur.end, curBytes);
19018
19054
  cur = void 0;
19019
19055
  }
@@ -20868,21 +20904,43 @@ var ctxBatch = Object.freeze({
20868
20904
  });
20869
20905
 
20870
20906
  // 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";
20907
+ import { readdirSync as readdirSync6, readFileSync as readFileSync13, existsSync as existsSync14 } from "node:fs";
20908
+ import { basename as basename5, join as join17 } from "node:path";
20909
+
20910
+ // src/core/ops/bundle-dir.ts
20911
+ import { existsSync as existsSync3 } from "node:fs";
20912
+ import { dirname as dirname5, join as join8 } from "node:path";
20913
+ import { fileURLToPath } from "node:url";
20914
+ function bundleDirOf(argv1, moduleFile) {
20915
+ const own4 = dirname5(argv1);
20916
+ if (existsSync3(join8(own4, SERVER_ENTRY_FILE))) return own4;
20917
+ let dir = dirname5(moduleFile);
20918
+ for (; ; ) {
20919
+ if (existsSync3(join8(dir, SERVER_ENTRY_FILE))) return dir;
20920
+ const up = dirname5(dir);
20921
+ if (up === dir) return own4;
20922
+ dir = up;
20923
+ }
20924
+ }
20925
+ var memo;
20926
+ function ownBundleDir() {
20927
+ const argv1 = process.argv[1] ?? "";
20928
+ if (memo?.argv1 !== argv1) memo = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
20929
+ return memo.dir;
20930
+ }
20873
20931
 
20874
20932
  // 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";
20933
+ import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
20934
+ import { join as join12 } from "node:path";
20877
20935
 
20878
20936
  // src/core/ops/detect-v1.ts
20879
- import { existsSync as existsSync4, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20937
+ import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
20880
20938
  import { tmpdir } from "node:os";
20881
- import { join as join9 } from "node:path";
20939
+ import { join as join10 } from "node:path";
20882
20940
 
20883
20941
  // 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";
20942
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
20943
+ import { dirname as dirname6, join as join9 } from "node:path";
20886
20944
 
20887
20945
  // node_modules/eslint-visitor-keys/lib/visitor-keys.js
20888
20946
  var KEYS2 = {
@@ -22999,10 +23057,10 @@ function formatOf(path7) {
22999
23057
  function readHostConfig(agent, path7) {
23000
23058
  let file2 = path7;
23001
23059
  if (agent === "opencode") {
23002
- const jsonc = join8(dirname5(path7), OPENCODE_CONFIG_FILES[0]);
23003
- if (existsSync3(jsonc)) file2 = jsonc;
23060
+ const jsonc = join9(dirname6(path7), OPENCODE_CONFIG_FILES[0]);
23061
+ if (existsSync4(jsonc)) file2 = jsonc;
23004
23062
  }
23005
- const raw = existsSync3(file2) ? readFileSync6(file2, "utf8") : "";
23063
+ const raw = existsSync4(file2) ? readFileSync6(file2, "utf8") : "";
23006
23064
  return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
23007
23065
  }
23008
23066
  function stripJsonComments(text) {
@@ -23347,7 +23405,7 @@ function setText(agent, path7, text, format, key, value) {
23347
23405
  }
23348
23406
  }
23349
23407
  function serverScript() {
23350
- return join8(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23408
+ return join9(dirname6(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23351
23409
  }
23352
23410
  function isNodeCommand(command) {
23353
23411
  if (typeof command !== "string") return false;
@@ -23363,7 +23421,7 @@ function ownMcpValue(agent, node3, server) {
23363
23421
  return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
23364
23422
  }
23365
23423
  function opencodePluginFile() {
23366
- return dirname5(process.argv[1] ?? "");
23424
+ return ownBundleDir();
23367
23425
  }
23368
23426
  function listTarget(key, own4, v1, alt = []) {
23369
23427
  return {
@@ -23522,7 +23580,7 @@ function flatCommands(events, prefix) {
23522
23580
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
23523
23581
  var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep4) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep4) + sep4));
23524
23582
  function dataDir(dir, reason, out) {
23525
- if (existsSync4(dir)) out.push(finding(dir, "", reason));
23583
+ if (existsSync5(dir)) out.push(finding(dir, "", reason));
23526
23584
  }
23527
23585
  function mcpEntry(file2, doc, out) {
23528
23586
  if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
@@ -23530,7 +23588,7 @@ function mcpEntry(file2, doc, out) {
23530
23588
  }
23531
23589
  }
23532
23590
  function claudeShapeSettings(agentHome, out) {
23533
- const file2 = join9(agentHome, SETTINGS_FILE);
23591
+ const file2 = join10(agentHome, SETTINGS_FILE);
23534
23592
  const doc = readJson(file2);
23535
23593
  for (const c of nestedCommands(doc)) {
23536
23594
  if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
@@ -23550,49 +23608,49 @@ function v1HookFile(file2, out) {
23550
23608
  function scanClaudeCode(home, agentHome, out) {
23551
23609
  claudeShapeSettings(agentHome, out);
23552
23610
  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));
23611
+ const file2 = join10(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23612
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23555
23613
  }
23556
- const userFile = join9(home, CLAUDE_USER_CONFIG_FILE);
23614
+ const userFile = join10(home, CLAUDE_USER_CONFIG_FILE);
23557
23615
  mcpEntry(userFile, readJson(userFile), out);
23558
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23616
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23559
23617
  }
23560
23618
  function scanCodex(agentHome, out) {
23561
- const hooksFile = join9(agentHome, HOOKS_JSON_FILE);
23619
+ const hooksFile = join10(agentHome, HOOKS_JSON_FILE);
23562
23620
  for (const c of nestedCommands(readJson(hooksFile))) {
23563
23621
  if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
23564
23622
  out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
23565
23623
  }
23566
23624
  }
23567
- const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
23625
+ const tomlFile = join10(agentHome, CONFIG_TOML_FILE);
23568
23626
  const config4 = readTomlValue(tomlFile);
23569
23627
  for (const span2 of readTomlTables(tomlFile)) {
23570
23628
  if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
23571
23629
  if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
23572
23630
  out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
23573
23631
  }
23574
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23632
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23575
23633
  }
23576
23634
  function scanGemini(agentHome, out) {
23577
- const file2 = join9(agentHome, SETTINGS_FILE);
23635
+ const file2 = join10(agentHome, SETTINGS_FILE);
23578
23636
  for (const c of nestedCommands(readJson(file2))) {
23579
23637
  if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
23580
23638
  }
23581
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23639
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23582
23640
  }
23583
23641
  function scanVscode(agentHome, project, out) {
23584
23642
  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);
23643
+ v1HookFile(join10(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23644
+ const mcpFile2 = join10(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23587
23645
  const doc = readJson(mcpFile2);
23588
23646
  const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
23589
23647
  const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
23590
23648
  if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
23591
23649
  out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
23592
23650
  }
23593
- dataDir(join9(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23651
+ dataDir(join10(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23594
23652
  }
23595
- dataDir(join9(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23653
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23596
23654
  }
23597
23655
  function jsonFiles(dir) {
23598
23656
  try {
@@ -23602,10 +23660,10 @@ function jsonFiles(dir) {
23602
23660
  }
23603
23661
  }
23604
23662
  function scanKiro(agentHome, project, out) {
23605
- const agentsDir = join9(agentHome, KIRO_AGENTS_DIR);
23606
- const defaultFile = join9(agentHome, ...KIRO_AGENT_FILE);
23663
+ const agentsDir = join10(agentHome, KIRO_AGENTS_DIR);
23664
+ const defaultFile = join10(agentHome, ...KIRO_AGENT_FILE);
23607
23665
  for (const name of jsonFiles(agentsDir)) {
23608
- const file2 = join9(agentsDir, name);
23666
+ const file2 = join10(agentsDir, name);
23609
23667
  const doc = readJson(file2);
23610
23668
  if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
23611
23669
  out.push(finding(file2, "", V1_REASON.kiroAgentFile));
@@ -23616,25 +23674,25 @@ function scanKiro(agentHome, project, out) {
23616
23674
  if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
23617
23675
  }
23618
23676
  }
23619
- const steeringDocs = [join9(agentHome, ...KIRO_STEERING_FILE)];
23620
- if (project !== void 0) steeringDocs.push(join9(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23677
+ const steeringDocs = [join10(agentHome, ...KIRO_STEERING_FILE)];
23678
+ if (project !== void 0) steeringDocs.push(join10(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23621
23679
  for (const file2 of steeringDocs) {
23622
- if (existsSync4(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23680
+ if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
23623
23681
  }
23624
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23682
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23625
23683
  }
23626
23684
  function scanPi(piAgentDir, agentHome, out) {
23627
- const file2 = join9(piAgentDir, SETTINGS_FILE);
23685
+ const file2 = join10(piAgentDir, SETTINGS_FILE);
23628
23686
  const doc = readJson(file2);
23629
23687
  listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
23630
23688
  const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
23631
23689
  if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
23632
23690
  });
23633
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23691
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23634
23692
  }
23635
23693
  function scanOpencode(agentHome, out) {
23636
23694
  for (const name of OPENCODE_CONFIG_FILES) {
23637
- const file2 = join9(agentHome, name);
23695
+ const file2 = join10(agentHome, name);
23638
23696
  const doc = readJson(file2);
23639
23697
  if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
23640
23698
  doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
@@ -23644,13 +23702,13 @@ function scanOpencode(agentHome, out) {
23644
23702
  }
23645
23703
  }
23646
23704
  function scanZcode(agentHome, out) {
23647
- const configFile = join9(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23705
+ const configFile = join10(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
23648
23706
  const config4 = readJson(configFile);
23649
23707
  const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
23650
23708
  for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
23651
23709
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
23652
23710
  }
23653
- const hooksFile = join9(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23711
+ const hooksFile = join10(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
23654
23712
  for (const c of nestedCommands(readJson(hooksFile))) {
23655
23713
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
23656
23714
  }
@@ -23674,14 +23732,14 @@ function firstTmpMatch(dir) {
23674
23732
  }
23675
23733
  }
23676
23734
  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);
23735
+ const root = join10(home, DATA_ROOT.slice(1));
23736
+ for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join10(root, name), V1_REASON.dataRoot, out);
23679
23737
  if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
23680
23738
  }
23681
23739
  function detectV1(agent, home, scope = {}) {
23682
23740
  const out = [];
23683
23741
  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]);
23742
+ const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join10(home, ...AGENT_HOME_DIR[agent]);
23685
23743
  switch (agent) {
23686
23744
  case "claude-code":
23687
23745
  scanClaudeCode(home, agentHome, out);
@@ -23694,11 +23752,11 @@ function detectV1(agent, home, scope = {}) {
23694
23752
  break;
23695
23753
  case "qwen":
23696
23754
  claudeShapeSettings(agentHome, out);
23697
- dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23755
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23698
23756
  break;
23699
23757
  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);
23758
+ v1HookFile(join10(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23759
+ dataDir(join10(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23702
23760
  break;
23703
23761
  case "vscode":
23704
23762
  scanVscode(agentHome, project, out);
@@ -23707,7 +23765,7 @@ function detectV1(agent, home, scope = {}) {
23707
23765
  scanKiro(agentHome, project, out);
23708
23766
  break;
23709
23767
  case "pi":
23710
- scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join9(agentHome, PI_AGENT_DIR), agentHome, out);
23768
+ scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join10(agentHome, PI_AGENT_DIR), agentHome, out);
23711
23769
  break;
23712
23770
  // D-WIN-PIDIR-1: empty is unset
23713
23771
  case "opencode":
@@ -23722,9 +23780,9 @@ function detectV1(agent, home, scope = {}) {
23722
23780
  }
23723
23781
 
23724
23782
  // 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";
23783
+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
23784
+ import { dirname as dirname7, isAbsolute as isAbsolute2, join as join11, sep as sep3 } from "node:path";
23785
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
23728
23786
  function missing(agent, path7) {
23729
23787
  return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path7 });
23730
23788
  }
@@ -23771,8 +23829,8 @@ var readOrNull = (file2) => {
23771
23829
  };
23772
23830
  var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
23773
23831
  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));
23832
+ const files = [join11(claudeDir, SETTINGS_FILE)];
23833
+ if (project !== void 0) files.push(join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join11(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
23776
23834
  const out = {};
23777
23835
  for (const file2 of files) {
23778
23836
  const text = readOrNull(file2);
@@ -23785,13 +23843,13 @@ function enabledPlugins(claudeDir, project) {
23785
23843
  function marketplaceChoice(env, worktree) {
23786
23844
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23787
23845
  const script = process.argv[1];
23788
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23846
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23789
23847
  const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
23790
23848
  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));
23849
+ const record6 = readOrNull(join11(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
23792
23850
  const recorded = record6 === null ? [] : recordedInstalls(record6);
23793
23851
  if (recorded.length === 0) return { record: false };
23794
- const live = recorded.filter((r) => existsSync5(r.installPath));
23852
+ const live = recorded.filter((r) => existsSync6(r.installPath));
23795
23853
  const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
23796
23854
  if (mine !== void 0) return { root: mine.installPath };
23797
23855
  const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
@@ -23811,18 +23869,18 @@ function marketplaceChoice(env, worktree) {
23811
23869
  }
23812
23870
  function marketplaceRoot(adapter, env, worktree) {
23813
23871
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
23814
- const plugins = join10(claudeDir, HOST_PLUGINS_DIR_NAME);
23815
- const cache = join10(plugins, PLUGIN_CACHE_DIR_NAME);
23872
+ const plugins = join11(claudeDir, HOST_PLUGINS_DIR_NAME);
23873
+ const cache = join11(plugins, PLUGIN_CACHE_DIR_NAME);
23816
23874
  const script = process.argv[1];
23817
- const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
23875
+ const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
23818
23876
  const choice = marketplaceChoice(env, worktree);
23819
23877
  if ("root" in choice) return choice.root;
23820
23878
  if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
23821
23879
  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));
23880
+ if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep3) && existsSync6(join11(ownReal, SERVER_ENTRY_FILE))) return ownReal;
23881
+ const pattern = join11(cache, "*", PLUGIN_NAME);
23882
+ if (!existsSync6(cache)) throw missing(adapter.id, pattern);
23883
+ const found = readdirSync3(cache).sort().map((marketplace) => join11(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
23826
23884
  if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
23827
23885
  return found[0];
23828
23886
  }
@@ -23830,13 +23888,13 @@ function configEntryRoot(adapter, env) {
23830
23888
  const spec = OWN_MCP_ENTRY[adapter.id];
23831
23889
  if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
23832
23890
  const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
23833
- if (!existsSync5(file2)) throw missing(adapter.id, file2);
23891
+ if (!existsSync6(file2)) throw missing(adapter.id, file2);
23834
23892
  const current = readHostConfig(adapter.id, file2);
23835
23893
  const value = parseHostConfig(adapter.id, file2, current.text, current.format);
23836
23894
  const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
23837
23895
  const script = Array.isArray(args) ? args[0] : void 0;
23838
23896
  if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
23839
- return dirname6(script);
23897
+ return dirname7(script);
23840
23898
  }
23841
23899
  function candidate(adapter, env, worktree) {
23842
23900
  switch (adapter.installMode) {
@@ -23847,11 +23905,11 @@ function candidate(adapter, env, worktree) {
23847
23905
  case "hooks+mcp":
23848
23906
  return configEntryRoot(adapter, env);
23849
23907
  case "extension":
23850
- return join10(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23908
+ return join11(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
23851
23909
  case "plugin":
23852
- return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23910
+ return join11(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
23853
23911
  case "in-process":
23854
- return dirname6(fileURLToPath(import.meta.url));
23912
+ return dirname7(fileURLToPath2(import.meta.url));
23855
23913
  }
23856
23914
  }
23857
23915
  function resolvePluginRoot(adapter, env, worktree) {
@@ -23940,11 +23998,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
23940
23998
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
23941
23999
  function mcpFile(row5, home, env) {
23942
24000
  const spec = OWN_MCP_ENTRY[row5.id];
23943
- if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
24001
+ if (row5.id === "codex") return join12(codexDirOf(env, home), CONFIG_TOML_FILE);
23944
24002
  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);
24003
+ if (row5.id === "opencode") return join12(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
23946
24004
  if (row5.id === "pi") {
23947
- return join11(piAgentDirOf(env, home), SETTINGS_FILE);
24005
+ return join12(piAgentDirOf(env, home), SETTINGS_FILE);
23948
24006
  }
23949
24007
  return null;
23950
24008
  }
@@ -23957,27 +24015,27 @@ function codexNativeDir(env, home) {
23957
24015
  const codexDir = codexDirOf(env, home);
23958
24016
  let enabled;
23959
24017
  try {
23960
- enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24018
+ enabled = hostConfigValueAt(readParsed("codex", join12(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
23961
24019
  } catch {
23962
24020
  return null;
23963
24021
  }
23964
24022
  if (enabled !== true) return null;
23965
- const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
23966
- if (!existsSync6(cache)) return null;
24023
+ const cache = join12(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24024
+ if (!existsSync7(cache)) return null;
23967
24025
  const found = [];
23968
24026
  for (const market of readdirSync4(cache)) {
23969
- const plugin = join11(cache, market, SERVER_KEY);
23970
- if (!existsSync6(plugin)) continue;
24027
+ const plugin = join12(cache, market, SERVER_KEY);
24028
+ if (!existsSync7(plugin)) continue;
23971
24029
  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);
24030
+ const dir = join12(plugin, version4, CODEX_PLUGIN_SUBDIR);
24031
+ if (existsSync7(join12(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
23974
24032
  }
23975
24033
  }
23976
24034
  return found.length === 0 ? null : found[found.length - 1];
23977
24035
  }
23978
24036
  function nativeMcpWrong(dir, row5) {
23979
24037
  try {
23980
- const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24038
+ const entry = hostConfigValueAt(readParsed(row5.id, join12(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
23981
24039
  if (!isObject4(entry)) return true;
23982
24040
  const args = list2(entry[MCP_ARGS_FIELD]);
23983
24041
  const script = args[0];
@@ -23986,6 +24044,17 @@ function nativeMcpWrong(dir, row5) {
23986
24044
  return true;
23987
24045
  }
23988
24046
  }
24047
+ function isOwnOpencodeEntry(entry, key, own4) {
24048
+ const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
24049
+ if (typeof spec !== "string") return false;
24050
+ if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
24051
+ return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
24052
+ }
24053
+ function opencodeListed(file2) {
24054
+ const { value } = readParsed("opencode", file2);
24055
+ const own4 = [opencodePluginFile()];
24056
+ return [OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)));
24057
+ }
23989
24058
  function mcpWrong(row5, home, env, worktree) {
23990
24059
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
23991
24060
  if (native !== null) return nativeMcpWrong(native, row5);
@@ -23995,6 +24064,7 @@ function mcpWrong(row5, home, env, worktree) {
23995
24064
  resolvePluginRoot(row5, env, worktree);
23996
24065
  return false;
23997
24066
  }
24067
+ if (row5.id === "opencode") return !opencodeListed(file2);
23998
24068
  const cur = readHostConfig(row5.id, file2);
23999
24069
  return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
24000
24070
  } catch {
@@ -24004,7 +24074,7 @@ function mcpWrong(row5, home, env, worktree) {
24004
24074
  function hookFile(row5, spec, home, env, worktree) {
24005
24075
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
24006
24076
  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);
24077
+ const file2 = native !== null ? join12(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join12(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join12(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join12(kiroDirOf(env, home), ...spec.file.slice(1)) : join12(root, ...spec.file);
24008
24078
  return file2;
24009
24079
  }
24010
24080
  function hookParts(row5, home, env, worktree) {
@@ -24015,7 +24085,7 @@ function hookParts(row5, home, env, worktree) {
24015
24085
  const file2 = hookFile(row5, spec, home, env, worktree);
24016
24086
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24017
24087
  if (row5.id === "codex") {
24018
- const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24088
+ const config4 = readParsed(row5.id, join12(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24019
24089
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24020
24090
  }
24021
24091
  } catch {
@@ -24073,10 +24143,10 @@ function parsedOrNull(agent, file2, jsonc) {
24073
24143
  }
24074
24144
  function checkDoubleFire(agent, worktree) {
24075
24145
  if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
24076
- const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24146
+ const claude = parsedOrNull(agent, join12(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24077
24147
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
24078
24148
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
24079
- const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24149
+ const vscode = parsedOrNull(agent, join12(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24080
24150
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
24081
24151
  return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
24082
24152
  }
@@ -24087,7 +24157,7 @@ function configPaths(row5, env, worktree) {
24087
24157
  const mcp = mcpFile(row5, home, env);
24088
24158
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
24089
24159
  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) });
24160
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join12(native, CODEX_PLUGIN_MCP_FILE) });
24091
24161
  const spec = HOOK_HOST_FILE[row5.id];
24092
24162
  if (spec !== null) {
24093
24163
  try {
@@ -24107,7 +24177,7 @@ function configPaths(row5, env, worktree) {
24107
24177
  }
24108
24178
 
24109
24179
  // src/core/ops/doctor-db.ts
24110
- import { existsSync as existsSync7, statSync as statSync5 } from "node:fs";
24180
+ import { existsSync as existsSync8, statSync as statSync5 } from "node:fs";
24111
24181
  var unknown2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
24112
24182
  var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
24113
24183
  var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
@@ -24149,15 +24219,15 @@ function orphanFiles(dbPath) {
24149
24219
  const files = [];
24150
24220
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
24151
24221
  const path7 = dbPath + suffix;
24152
- if (existsSync7(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24222
+ if (existsSync8(path7)) files.push({ path: path7, bytes: statSync5(path7).size });
24153
24223
  }
24154
- return files.length > 0 && !existsSync7(dbPath) ? files : [];
24224
+ return files.length > 0 && !existsSync8(dbPath) ? files : [];
24155
24225
  }
24156
24226
  async function checkDb(project) {
24157
24227
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
24158
24228
  const orphan = orphanFiles(project.dbPath);
24159
24229
  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 };
24230
+ if (!existsSync8(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24161
24231
  const sqlite = await loadSqlite2();
24162
24232
  if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
24163
24233
  let raw = null;
@@ -24183,7 +24253,7 @@ async function checkDb(project) {
24183
24253
  }
24184
24254
  }
24185
24255
  async function checkIndex(project) {
24186
- if (!existsSync7(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24256
+ if (!existsSync8(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24187
24257
  const sqlite = await loadSqlite2();
24188
24258
  if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
24189
24259
  let raw = null;
@@ -24200,8 +24270,8 @@ async function checkIndex(project) {
24200
24270
  }
24201
24271
 
24202
24272
  // 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";
24273
+ import { existsSync as existsSync9, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24274
+ import { isAbsolute as isAbsolute3, join as join13, relative as relative2 } from "node:path";
24205
24275
  function pass3(id, detail = DOCTOR_PASS_DETAIL) {
24206
24276
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
24207
24277
  }
@@ -24213,7 +24283,7 @@ function fail4(id, detail, fixCommand) {
24213
24283
  }
24214
24284
  function bundleVersion(bundleDir2) {
24215
24285
  try {
24216
- const v = JSON.parse(readFileSync9(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24286
+ const v = JSON.parse(readFileSync9(join13(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24217
24287
  return typeof v === "string" && v !== "" ? v : void 0;
24218
24288
  } catch {
24219
24289
  return void 0;
@@ -24363,7 +24433,7 @@ function checkMcp(ctx) {
24363
24433
  return named2 || versioned ? pass3("D6") : unknown3("D6", D6_UNKNOWN_DETAIL);
24364
24434
  }
24365
24435
  function piCwdInside(worktree, piCwd) {
24366
- if (piCwd === void 0 || !existsSync8(piCwd)) return false;
24436
+ if (piCwd === void 0 || !existsSync9(piCwd)) return false;
24367
24437
  const rel = relative2(worktree, realpathSync5.native(piCwd));
24368
24438
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
24369
24439
  }
@@ -24384,13 +24454,13 @@ function checkShell(env) {
24384
24454
  }
24385
24455
 
24386
24456
  // src/core/ops/doctor-hook.ts
24387
- import { existsSync as existsSync10, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24457
+ import { existsSync as existsSync11, mkdtempSync, readFileSync as readFileSync10, realpathSync as realpathSync7, rmSync as rmSync2 } from "node:fs";
24388
24458
  import { tmpdir as tmpdir2 } from "node:os";
24389
24459
  import path6 from "node:path";
24390
24460
 
24391
24461
  // src/setup/codex-trust.ts
24392
24462
  import { createHash } from "node:crypto";
24393
- import { existsSync as existsSync9, realpathSync as realpathSync6 } from "node:fs";
24463
+ import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
24394
24464
  import path5 from "node:path";
24395
24465
  import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
24396
24466
 
@@ -24488,6 +24558,7 @@ var LIST_TIMEOUT_MS = 15e3;
24488
24558
  var EXIT_GRACE_MS = 5e3;
24489
24559
  var PLUGIN_SOURCE = "plugin";
24490
24560
  var TRUSTED = "trusted";
24561
+ var UNTRUSTED = "untrusted";
24491
24562
  function pluginHooksFromReply(m, pluginId) {
24492
24563
  const out = [];
24493
24564
  if (!isObj2(m) || !isObj2(m.result) || !Array.isArray(m.result.data)) return out;
@@ -24497,7 +24568,8 @@ function pluginHooksFromReply(m, pluginId) {
24497
24568
  if (!isObj2(h) || h.source !== PLUGIN_SOURCE || h.pluginId !== pluginId) continue;
24498
24569
  if (typeof h.key !== "string" || typeof h.currentHash !== "string") continue;
24499
24570
  if (out.some((x) => x.key === h.key)) continue;
24500
- out.push({ key: h.key, hash: h.currentHash, trusted: h.trustStatus === TRUSTED });
24571
+ const status = typeof h.trustStatus === "string" ? h.trustStatus : UNTRUSTED;
24572
+ out.push({ key: h.key, hash: h.currentHash, trusted: status === TRUSTED, status });
24501
24573
  }
24502
24574
  }
24503
24575
  return out;
@@ -24590,7 +24662,11 @@ var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
24590
24662
  function untrustedPluginHooksDetail(hooks) {
24591
24663
  const bad = hooks.filter((h) => !h.trusted);
24592
24664
  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}`;
24665
+ const counts = /* @__PURE__ */ new Map();
24666
+ for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
24667
+ const words = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
24668
+ const state = words.length === 1 ? words[0][0] : `${words.map(([w]) => w).join(" or ")} (${words.map(([w, n]) => `${n} ${w}`).join(", ")})`;
24669
+ return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
24594
24670
  }
24595
24671
 
24596
24672
  // src/core/ops/doctor-hook.ts
@@ -24607,7 +24683,7 @@ function isObject5(v) {
24607
24683
  }
24608
24684
  function loadFixture(bundleDir2, agent) {
24609
24685
  const file2 = path6.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
24610
- if (!existsSync10(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24686
+ if (!existsSync11(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
24611
24687
  let all;
24612
24688
  try {
24613
24689
  all = JSON.parse(hostText(readFileSync10(file2, "utf8")));
@@ -24746,7 +24822,7 @@ async function checkHookRoundTrip(i) {
24746
24822
  const trust = await codexPluginTrust(i);
24747
24823
  if (trust !== null) return trust;
24748
24824
  }
24749
- if (i.agent === "codex" && existsSync10(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24825
+ if (i.agent === "codex" && existsSync11(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
24750
24826
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
24751
24827
  }
24752
24828
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -24785,17 +24861,17 @@ async function checkHookRoundTrip(i) {
24785
24861
  }
24786
24862
 
24787
24863
  // 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";
24864
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
24865
+ import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
24790
24866
 
24791
24867
  // src/core/store/owners.ts
24792
24868
  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";
24869
+ import { basename as basename3, join as join14 } from "node:path";
24794
24870
  function ownersDir(configDir, projectKey) {
24795
- return join13(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24871
+ return join14(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
24796
24872
  }
24797
24873
  function ownerFile(configDir, projectKey, serverId) {
24798
- return join13(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
24874
+ return join14(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
24799
24875
  }
24800
24876
  function errCode2(err) {
24801
24877
  return err.code;
@@ -24830,7 +24906,7 @@ function listLiveOwners(configDir, projectKey) {
24830
24906
  const live = [];
24831
24907
  for (const name of names) {
24832
24908
  if (!name.endsWith(OWNER_PID_EXT)) continue;
24833
- const file2 = join13(dir, name);
24909
+ const file2 = join14(dir, name);
24834
24910
  let text;
24835
24911
  try {
24836
24912
  text = readFileSync11(file2, "utf8");
@@ -24879,7 +24955,7 @@ function renameAside(dbPath) {
24879
24955
  const ts = String(Date.now());
24880
24956
  for (const suffix of DB_SIBLING_SUFFIXES) {
24881
24957
  const file2 = dbPath + suffix;
24882
- if (existsSync11(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24958
+ if (existsSync12(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
24883
24959
  }
24884
24960
  return ts;
24885
24961
  }
@@ -24902,7 +24978,7 @@ function utcStamp(now) {
24902
24978
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
24903
24979
  }
24904
24980
  function makeOrphanDir(projectDir) {
24905
- const base = join14(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24981
+ const base = join15(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
24906
24982
  for (let n = 1; ; n += 1) {
24907
24983
  const dir = n === 1 ? base : base + "-" + String(n);
24908
24984
  try {
@@ -24917,9 +24993,9 @@ async function healOrphan(project, files, row5) {
24917
24993
  const moved = [];
24918
24994
  let dir = "";
24919
24995
  try {
24920
- dir = makeOrphanDir(dirname7(project.dbPath));
24996
+ dir = makeOrphanDir(dirname8(project.dbPath));
24921
24997
  for (const f of files) {
24922
- const to = join14(dir, basename4(f.path));
24998
+ const to = join15(dir, basename4(f.path));
24923
24999
  renameWithRetry(f.path, to);
24924
25000
  moved.push({ path: to, bytes: f.bytes });
24925
25001
  }
@@ -24986,8 +25062,8 @@ function buildReportHead(input) {
24986
25062
 
24987
25063
  // src/core/ops/doctor-issue.ts
24988
25064
  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";
25065
+ import { closeSync, existsSync as existsSync13, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync12, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
25066
+ import { delimiter, join as join16 } from "node:path";
24991
25067
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
24992
25068
  function tildeOf(env) {
24993
25069
  const home = homeDirOf(env);
@@ -25028,8 +25104,8 @@ function onPath(env, tool) {
25028
25104
  const out = [];
25029
25105
  for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
25030
25106
  if (dir === "") continue;
25031
- for (const n of names) if (existsSync12(join15(dir, n))) {
25032
- out.push(join15(dir, n));
25107
+ for (const n of names) if (existsSync13(join16(dir, n))) {
25108
+ out.push(join16(dir, n));
25033
25109
  break;
25034
25110
  }
25035
25111
  }
@@ -25037,7 +25113,7 @@ function onPath(env, tool) {
25037
25113
  }
25038
25114
  function hookLogTail(env) {
25039
25115
  const file2 = hookLogPath(env);
25040
- if (file2 === "" || !existsSync12(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25116
+ if (file2 === "" || !existsSync13(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25041
25117
  try {
25042
25118
  const fd = openSync(file2, "r");
25043
25119
  try {
@@ -25057,7 +25133,7 @@ function hookLogTail(env) {
25057
25133
  }
25058
25134
  async function journalRows(ctx) {
25059
25135
  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})`];
25136
+ if (!existsSync13(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25061
25137
  try {
25062
25138
  const db = await openDb(ctx.project, { readOnly: true });
25063
25139
  try {
@@ -25075,15 +25151,15 @@ function agentConfig(adapter, env, worktree) {
25075
25151
  const home = homeDirOf(env);
25076
25152
  const files = configPaths(adapter, env, worktree);
25077
25153
  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) });
25154
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join16(claudeDirOf(env, home), SETTINGS_FILE) });
25155
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join16(codexDirOf(env, home), CONFIG_TOML_FILE) });
25080
25156
  }
25081
25157
  const out = [];
25082
25158
  const seen = /* @__PURE__ */ new Set();
25083
25159
  for (const f of files) {
25084
25160
  if (seen.has(f.path)) continue;
25085
25161
  seen.add(f.path);
25086
- if (!existsSync12(f.path)) {
25162
+ if (!existsSync13(f.path)) {
25087
25163
  out.push(`${f.label}: ${f.path} (absent)`);
25088
25164
  continue;
25089
25165
  }
@@ -25159,14 +25235,14 @@ async function buildIssueBody(i) {
25159
25235
  async function writeIssueReport(i) {
25160
25236
  const tilde = tildeOf(i.env);
25161
25237
  const body = await buildIssueBody(i);
25162
- const dir = join15(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25238
+ const dir = join16(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25163
25239
  mkdirSync6(dir, { recursive: true });
25164
- const file2 = join15(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25240
+ const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25165
25241
  writeFileSync3(file2, body);
25166
25242
  const shown2 = tilde(file2);
25167
25243
  const title = issueTitle(i.adapter.id, i.rows);
25168
25244
  const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
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))];
25245
+ return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
25170
25246
  }
25171
25247
  function formUrl(title, summary) {
25172
25248
  const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
@@ -25188,7 +25264,7 @@ async function guard(id, run) {
25188
25264
  }
25189
25265
  }
25190
25266
  async function codexDb(ctx, adapter) {
25191
- if (adapter.id !== "codex" || !existsSync13(ctx.project.dbPath)) return null;
25267
+ if (adapter.id !== "codex" || !existsSync14(ctx.project.dbPath)) return null;
25192
25268
  try {
25193
25269
  return await openDb(ctx.project, { readOnly: true });
25194
25270
  } catch {
@@ -25218,11 +25294,11 @@ async function hookRow(ctx, adapter, host) {
25218
25294
  }
25219
25295
  }
25220
25296
  function ownServerId(configDir, projectKey) {
25221
- const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25222
- if (!existsSync13(dir)) return "";
25297
+ const dir = join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
25298
+ if (!existsSync14(dir)) return "";
25223
25299
  for (const name of readdirSync6(dir)) {
25224
25300
  if (!name.endsWith(OWNER_PID_EXT)) continue;
25225
- if (readFileSync13(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25301
+ if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
25226
25302
  }
25227
25303
  return "";
25228
25304
  }
@@ -25305,7 +25381,7 @@ async function doctorReply(ctx, host) {
25305
25381
  return { text, isError: false, sandboxBytes: bytes5 };
25306
25382
  }
25307
25383
  async function handler2(_input, ctx) {
25308
- return doctorReply(ctx, { env: process.env, bundleDir: dirname8(process.argv[1]), piCwd: void 0 });
25384
+ return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: void 0 });
25309
25385
  }
25310
25386
  var ctxDoctor = Object.freeze({
25311
25387
  name: "ctx_doctor",
@@ -25317,9 +25393,9 @@ var ctxDoctor = Object.freeze({
25317
25393
  });
25318
25394
 
25319
25395
  // src/core/tools/execute.ts
25320
- import { existsSync as existsSync14, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25396
+ import { existsSync as existsSync15, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
25321
25397
  import { tmpdir as tmpdir3 } from "node:os";
25322
- import { dirname as dirname9, join as join17, parse as parse3, resolve as resolve6 } from "node:path";
25398
+ import { dirname as dirname10, join as join18, parse as parse3, resolve as resolve6 } from "node:path";
25323
25399
 
25324
25400
  // src/core/sandbox/win-build.ts
25325
25401
  var SEPARATORS2 = ";&|(\n";
@@ -25403,7 +25479,7 @@ function schemaLine(issue4) {
25403
25479
  }
25404
25480
  function fileError(given, abs, root) {
25405
25481
  let dir = abs;
25406
- while (!existsSync14(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
25482
+ while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
25407
25483
  if (isInside(root, dir)) return null;
25408
25484
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
25409
25485
  }
@@ -25484,8 +25560,8 @@ async function handler3(raw, ctx) {
25484
25560
  if (takesDashC(input.language, runtime)) {
25485
25561
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
25486
25562
  } else {
25487
- tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
25488
- const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25563
+ tmpDir = mkdtempSync2(join18(tmpdir3(), TMP_PREFIX));
25564
+ const file2 = join18(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25489
25565
  writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
25490
25566
  argv = scriptArgv(input.language, runtime, file2);
25491
25567
  }
@@ -25520,12 +25596,12 @@ var ctxExecute = {
25520
25596
  };
25521
25597
 
25522
25598
  // 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";
25599
+ import { existsSync as existsSync16, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
25600
+ import { dirname as dirname11, extname, join as join20, relative as relative3, resolve as resolve7 } from "node:path";
25525
25601
 
25526
25602
  // src/core/index/walk.ts
25527
25603
  import { readdirSync as readdirSync7, readFileSync as readFileSync14, realpathSync as realpathSync9, statSync as statSync7 } from "node:fs";
25528
- import { join as join18 } from "node:path";
25604
+ import { join as join19 } from "node:path";
25529
25605
  var GITIGNORE = ".gitignore";
25530
25606
  var GIT_DIR = ".git";
25531
25607
  function walkDir(root, containmentRoot) {
@@ -25534,7 +25610,7 @@ function walkDir(root, containmentRoot) {
25534
25610
  const found = [];
25535
25611
  visit(real2, [], [], containmentRoot, /* @__PURE__ */ new Set([real2]), found);
25536
25612
  found.sort(compareFound);
25537
- return found.map((f) => ({ absPath: f.absPath, relPath: join18(...f.dir, f.name) }));
25613
+ return found.map((f) => ({ absPath: f.absPath, relPath: join19(...f.dir, f.name) }));
25538
25614
  }
25539
25615
  function visit(abs, rel, parent, contain, seen, found) {
25540
25616
  let entries;
@@ -25543,10 +25619,10 @@ function visit(abs, rel, parent, contain, seen, found) {
25543
25619
  } catch {
25544
25620
  return;
25545
25621
  }
25546
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join18(abs, GITIGNORE), rel)) : parent;
25622
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join19(abs, GITIGNORE), rel)) : parent;
25547
25623
  for (const e of entries) {
25548
25624
  if (e.name === GIT_DIR) continue;
25549
- const path7 = join18(abs, e.name);
25625
+ const path7 = join19(abs, e.name);
25550
25626
  let isDir = e.isDirectory();
25551
25627
  let isFile = e.isFile();
25552
25628
  let target = path7;
@@ -29676,7 +29752,7 @@ function readUtf8(absPath) {
29676
29752
  }
29677
29753
  function missingOrOutside(given, abs, root) {
29678
29754
  let dir = abs;
29679
- while (!existsSync15(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
29755
+ while (!existsSync16(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
29680
29756
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
29681
29757
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
29682
29758
  }
@@ -29687,7 +29763,7 @@ function pathItems(input, project) {
29687
29763
  if (statSync8(abs).isDirectory()) {
29688
29764
  return walkDir(abs, project.containmentRoot).map((f) => ({
29689
29765
  sourceKind: "path",
29690
- label: pathLabel(join19(base, f.relPath)),
29766
+ label: pathLabel(join20(base, f.relPath)),
29691
29767
  kind: kindOfPath(f.relPath),
29692
29768
  read: () => readUtf8(f.absPath)
29693
29769
  }));
@@ -30227,12 +30303,12 @@ var ctxStats = Object.freeze({
30227
30303
  });
30228
30304
 
30229
30305
  // 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";
30306
+ import { existsSync as existsSync22, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
30307
+ import { basename as basename7, dirname as dirname13, join as join26 } from "node:path";
30232
30308
 
30233
30309
  // 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";
30310
+ import { copyFileSync, existsSync as existsSync17, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
30311
+ import { dirname as dirname12, join as join21 } from "node:path";
30236
30312
  function defaultWrite(file2, text) {
30237
30313
  writeFileSync5(file2, text, "utf8");
30238
30314
  }
@@ -30241,14 +30317,14 @@ function hostConfigPath(agent, home, env) {
30241
30317
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
30242
30318
  switch (agent) {
30243
30319
  case "opencode":
30244
- return join20(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30320
+ return join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
30245
30321
  // D-WIN-OPENCODE-DIR-1
30246
30322
  case "pi":
30247
- return join20(piAgentDirOf(env, home), SETTINGS_FILE);
30323
+ return join21(piAgentDirOf(env, home), SETTINGS_FILE);
30248
30324
  case "copilot-cli":
30249
30325
  return null;
30250
30326
  default:
30251
- return join20(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30327
+ return join21(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
30252
30328
  }
30253
30329
  }
30254
30330
  function cell3(value) {
@@ -30260,8 +30336,8 @@ function toRow(file2, edit) {
30260
30336
  function writeWithRollback(file2, text, write2, atomic) {
30261
30337
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
30262
30338
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
30263
- const had = existsSync16(file2);
30264
- mkdirSync7(dirname11(file2), { recursive: true });
30339
+ const had = existsSync17(file2);
30340
+ mkdirSync7(dirname12(file2), { recursive: true });
30265
30341
  if (had) copyFileSync(file2, trash);
30266
30342
  try {
30267
30343
  write2(tmp, text);
@@ -30290,7 +30366,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
30290
30366
  if (requested === null) return [];
30291
30367
  const current = readHostConfig(row5.id, requested);
30292
30368
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
30293
- const exists = existsSync16(current.path);
30369
+ const exists = existsSync17(current.path);
30294
30370
  if (exists && result.text === current.text) return [];
30295
30371
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
30296
30372
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -30298,8 +30374,8 @@ function regenerateHostConfig(row5, home, opts = {}) {
30298
30374
  }
30299
30375
 
30300
30376
  // 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";
30377
+ import { existsSync as existsSync18, lstatSync, readdirSync as readdirSync8, readlinkSync, rmSync as rmSync6, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
30378
+ import { basename as basename6, join as join22, win32 as win322 } from "node:path";
30303
30379
  function linkTarget(path7, win) {
30304
30380
  if (!isLink(path7)) return null;
30305
30381
  const target = readlinkSync(path7);
@@ -30318,11 +30394,11 @@ function settleLinks(link, tmp, old, opts) {
30318
30394
  else renameWithRetry(old, link, opts);
30319
30395
  }
30320
30396
  function swapPluginCurrent(agentDir, sha, opts = {}) {
30321
- const next = join21(agentDir, sha);
30322
- if (!existsSync17(next) || !lstatSync(next).isDirectory()) {
30397
+ const next = join22(agentDir, sha);
30398
+ if (!existsSync18(next) || !lstatSync(next).isDirectory()) {
30323
30399
  throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
30324
30400
  }
30325
- const link = join21(agentDir, PLUGIN_CURRENT_LINK);
30401
+ const link = join22(agentDir, PLUGIN_CURRENT_LINK);
30326
30402
  const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
30327
30403
  const old = link + PLUGIN_LINK_OLD_SUFFIX;
30328
30404
  settleLinks(link, tmp, old, opts);
@@ -30337,15 +30413,15 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
30337
30413
  if (before !== null) unlinkSync2(old);
30338
30414
  const keep = /* @__PURE__ */ new Set([sha]);
30339
30415
  if (before !== null) keep.add(before);
30340
- const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join21(agentDir, name));
30416
+ const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join22(agentDir, name));
30341
30417
  for (const dir of removed) rmSync6(dir, { recursive: true, force: true });
30342
- const previous = before !== null && existsSync17(join21(agentDir, before)) ? join21(agentDir, before) : null;
30418
+ const previous = before !== null && existsSync18(join22(agentDir, before)) ? join22(agentDir, before) : null;
30343
30419
  return { current: next, previous, removed };
30344
30420
  }
30345
30421
 
30346
30422
  // 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";
30423
+ import { existsSync as existsSync19, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
30424
+ import { join as join23 } from "node:path";
30349
30425
  function failed(r) {
30350
30426
  if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
30351
30427
  const status = r.killed ?? String(r.exitCode);
@@ -30357,9 +30433,9 @@ async function git2(bin, args, cwd, env, signal) {
30357
30433
  return r.stdout.toString().trim();
30358
30434
  }
30359
30435
  async function fetchRelease(agent, url4, env, signal, opts = {}) {
30360
- const agentDir = join22(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30436
+ const agentDir = join23(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
30361
30437
  mkdirSync8(agentDir, { recursive: true });
30362
- const fetchDir = join22(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30438
+ const fetchDir = join23(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
30363
30439
  rmSync7(fetchDir, { recursive: true, force: true });
30364
30440
  const gitBin = findRuntime(GIT_BIN, env);
30365
30441
  if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
@@ -30367,8 +30443,8 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
30367
30443
  try {
30368
30444
  await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
30369
30445
  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 });
30446
+ const dir = join23(agentDir, sha);
30447
+ if (existsSync19(dir)) rmSync7(fetchDir, { recursive: true, force: true });
30372
30448
  else renameWithRetry(fetchDir, dir, opts);
30373
30449
  return { sha, dir };
30374
30450
  } catch (e) {
@@ -30378,15 +30454,15 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
30378
30454
  }
30379
30455
 
30380
30456
  // 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";
30457
+ import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
30458
+ import { join as join24 } from "node:path";
30383
30459
  function row2(area, before, after) {
30384
30460
  return { area, before, after };
30385
30461
  }
30386
30462
  function stopServers(configDir, projectKey) {
30387
30463
  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");
30464
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30465
+ for (const serverId of stopped) writeFileSync6(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30390
30466
  return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
30391
30467
  }
30392
30468
  function rootOrNull(adapter, env) {
@@ -30404,15 +30480,15 @@ function removeCache(adapter, env, configDir) {
30404
30480
  const root = rootOrNull(adapter, env);
30405
30481
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30406
30482
  if (adapter.installMode === "marketplace") {
30407
- const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30483
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
30408
30484
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
30409
30485
  }
30410
30486
  rmSync8(root, { recursive: true, force: true });
30411
30487
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
30412
30488
  }
30413
30489
  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);
30490
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
30491
+ if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
30416
30492
  rmSync8(agentDir, { recursive: true, force: true });
30417
30493
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
30418
30494
  }
@@ -30457,7 +30533,7 @@ function ownEntries(agent, env) {
30457
30533
  }
30458
30534
  if (agent === "opencode") {
30459
30535
  return [{
30460
- file: join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30536
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
30461
30537
  // D-WIN-OPENCODE-DIR-1
30462
30538
  key: OPENCODE_PLUGIN_KEY,
30463
30539
  shown: OPENCODE_PLUGIN_KEY,
@@ -30468,7 +30544,7 @@ function ownEntries(agent, env) {
30468
30544
  if (agent === "pi") {
30469
30545
  const agentDir = piAgentDirOf(env, home);
30470
30546
  return [{
30471
- file: join23(agentDir, SETTINGS_FILE),
30547
+ file: join24(agentDir, SETTINGS_FILE),
30472
30548
  key: PI_PACKAGES_KEY,
30473
30549
  shown: PI_PACKAGES_KEY,
30474
30550
  has: (v) => Array.isArray(v) && v.some((x) => piSource(x) === PI_GIT_PACKAGE),
@@ -30490,12 +30566,12 @@ function removeOwnEntries(agent, env) {
30490
30566
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
30491
30567
  }
30492
30568
  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);
30569
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
30570
+ const dir = join24(projects, projectKey);
30571
+ if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
30496
30572
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
30497
30573
  for (const name of readdirSync9(dir)) {
30498
- if (name !== OWNERS_DIR_NAME) rmSync8(join23(dir, name), { recursive: true, force: true });
30574
+ if (name !== OWNERS_DIR_NAME) rmSync8(join24(dir, name), { recursive: true, force: true });
30499
30575
  }
30500
30576
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
30501
30577
  }
@@ -30503,12 +30579,12 @@ function runUninstall(input) {
30503
30579
  const configDir = resolveConfigDir(input.env);
30504
30580
  const stop = stopServers(configDir, input.project.projectKey);
30505
30581
  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));
30582
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
30507
30583
  return { rows, stopped: stop.stopped };
30508
30584
  }
30509
30585
 
30510
30586
  // src/core/ops/v1-remove.ts
30511
- import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30587
+ import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync16, rmSync as rmSync9 } from "node:fs";
30512
30588
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30513
30589
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
30514
30590
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -30589,14 +30665,14 @@ function removeV1(agent, findings) {
30589
30665
  for (const f of findings) {
30590
30666
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
30591
30667
  else if (f.path === "") {
30592
- if (existsSync20(f.file)) {
30668
+ if (existsSync21(f.file)) {
30593
30669
  moveAside(f.file, undo);
30594
30670
  done.set(f, UPGRADE_REMOVED);
30595
30671
  } else done.set(f, UPGRADE_NOT_FOUND);
30596
30672
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
30597
30673
  }
30598
30674
  for (const [file2, list4] of entries) {
30599
- if (!existsSync20(file2)) {
30675
+ if (!existsSync21(file2)) {
30600
30676
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
30601
30677
  continue;
30602
30678
  }
@@ -30629,7 +30705,7 @@ function removeV1(agent, findings) {
30629
30705
  },
30630
30706
  rollback() {
30631
30707
  for (const u of undo.splice(0).reverse()) {
30632
- if (!existsSync20(u.trash)) continue;
30708
+ if (!existsSync21(u.trash)) continue;
30633
30709
  rmSync9(u.target, { recursive: true, force: true });
30634
30710
  renameWithRetry(u.trash, u.target);
30635
30711
  }
@@ -30640,7 +30716,7 @@ function removeV1(agent, findings) {
30640
30716
  // src/core/ops/verify-sums.ts
30641
30717
  import { createHash as createHash2 } from "node:crypto";
30642
30718
  import { lstatSync as lstatSync2, readdirSync as readdirSync10, readFileSync as readFileSync17 } from "node:fs";
30643
- import { join as join24 } from "node:path";
30719
+ import { join as join25 } from "node:path";
30644
30720
  function mismatch() {
30645
30721
  return new CtxError("BUNDLE_HASH_MISMATCH");
30646
30722
  }
@@ -30661,14 +30737,14 @@ function walk3(dir, prefix, out) {
30661
30737
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
30662
30738
  const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
30663
30739
  if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
30664
- const abs = join24(dir, entry.name);
30740
+ const abs = join25(dir, entry.name);
30665
30741
  if (entry.isDirectory()) walk3(abs, rel, out);
30666
30742
  else if (entry.isFile()) out.set(rel, abs);
30667
30743
  else throw mismatch();
30668
30744
  }
30669
30745
  }
30670
30746
  function verifySums(dir) {
30671
- const sumsPath = join24(dir, RELEASE_SUMS_FILE);
30747
+ const sumsPath = join25(dir, RELEASE_SUMS_FILE);
30672
30748
  const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
30673
30749
  if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
30674
30750
  const sums = parseSums(readFileSync17(sumsPath, "utf8"));
@@ -30692,7 +30768,7 @@ function row4(area, before, after) {
30692
30768
  return { area, before, after };
30693
30769
  }
30694
30770
  function bundleDir() {
30695
- return dirname12(process.argv[1] ?? "");
30771
+ return ownBundleDir();
30696
30772
  }
30697
30773
  function pluginRootRow(adapter, env) {
30698
30774
  const own4 = bundleDir();
@@ -30706,12 +30782,12 @@ function pluginRootRow(adapter, env) {
30706
30782
  return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
30707
30783
  }
30708
30784
  function isCurrent(agentDir, dir) {
30709
- const link = join25(agentDir, PLUGIN_CURRENT_LINK);
30710
- return existsSync21(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30785
+ const link = join26(agentDir, PLUGIN_CURRENT_LINK);
30786
+ return existsSync22(link) && realpathSync10.native(link) === realpathSync10.native(dir);
30711
30787
  }
30712
30788
  async function checkout(adapter, deps) {
30713
30789
  const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
30714
- const agentDir = dirname12(fetched.dir);
30790
+ const agentDir = dirname13(fetched.dir);
30715
30791
  try {
30716
30792
  verifySums(fetched.dir);
30717
30793
  } catch (err) {
@@ -30827,9 +30903,9 @@ function checkCall(tool, input) {
30827
30903
 
30828
30904
  // src/entries/server.ts
30829
30905
  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";
30906
+ import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
30907
+ import { dirname as dirname14, join as join28 } from "node:path";
30908
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
30833
30909
 
30834
30910
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
30835
30911
  var __create = Object.create;
@@ -33206,8 +33282,8 @@ function handleArrayResult2(result, final, index) {
33206
33282
  }
33207
33283
  var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
33208
33284
  $ZodType2.init(inst, def);
33209
- const memo4 = globalConfig2.memoizer;
33210
- memo4?.attach(inst);
33285
+ const memo5 = globalConfig2.memoizer;
33286
+ memo5?.attach(inst);
33211
33287
  inst._zod.parse = (payload, ctx) => {
33212
33288
  const input = payload.value;
33213
33289
  if (!Array.isArray(input)) {
@@ -33219,7 +33295,7 @@ var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
33219
33295
  });
33220
33296
  return payload;
33221
33297
  }
33222
- payload.value = memo4 ? memo4.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
33298
+ payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
33223
33299
  const proms = [];
33224
33300
  const abortEarly = ctx?.abortEarly;
33225
33301
  for (let i = 0; i < input.length; i++) {
@@ -33379,8 +33455,8 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33379
33455
  const isObject8 = isObject6;
33380
33456
  const catchall = def.catchall;
33381
33457
  let value;
33382
- const memo4 = globalConfig2.memoizer;
33383
- memo4?.attach(inst);
33458
+ const memo5 = globalConfig2.memoizer;
33459
+ memo5?.attach(inst);
33384
33460
  inst._zod.parse = (payload, ctx) => {
33385
33461
  value ?? (value = _normalized.value);
33386
33462
  const input = payload.value;
@@ -33393,7 +33469,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33393
33469
  });
33394
33470
  return payload;
33395
33471
  }
33396
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33472
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33397
33473
  const proms = [];
33398
33474
  const shape = value.shape;
33399
33475
  const abortEarly = ctx?.abortEarly;
@@ -33426,11 +33502,11 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33426
33502
  $ZodObject2.init(inst, def);
33427
33503
  const superParse = inst._zod.parse;
33428
33504
  const _normalized = cached2(() => normalizeDef(def));
33429
- const memo4 = globalConfig2.memoizer;
33505
+ const memo5 = globalConfig2.memoizer;
33430
33506
  const generateFastpass = (shape) => {
33431
33507
  const normalized = _normalized.value;
33432
33508
  const syms = normalized.symbolKeys;
33433
- const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo4, syms });
33509
+ const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo5, syms });
33434
33510
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
33435
33511
  const prefixStr = (id, k) => `
33436
33512
  let ${id}_ab = false;
@@ -33450,7 +33526,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33450
33526
  for (const key of normalized.allKeys) {
33451
33527
  ids[key] = `key_${counter++}`;
33452
33528
  }
33453
- doc.write(memo4 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
33529
+ doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
33454
33530
  for (const key of normalized.allKeys) {
33455
33531
  if (key === "__proto__")
33456
33532
  continue;
@@ -33813,8 +33889,8 @@ function handleIntersectionResults2(result, left, right2) {
33813
33889
  }
33814
33890
  var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33815
33891
  $ZodType2.init(inst, def);
33816
- const memo4 = globalConfig2.memoizer;
33817
- memo4?.attach(inst);
33892
+ const memo5 = globalConfig2.memoizer;
33893
+ memo5?.attach(inst);
33818
33894
  inst._zod.parse = (payload, ctx) => {
33819
33895
  const input = payload.value;
33820
33896
  if (!isPlainObject4(input)) {
@@ -33829,7 +33905,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33829
33905
  const proms = [];
33830
33906
  const values = def.keyType._zod.values;
33831
33907
  if (values && !def.partial) {
33832
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33908
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33833
33909
  const recordKeys = /* @__PURE__ */ new Set();
33834
33910
  for (const key of values) {
33835
33911
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -33893,7 +33969,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
33893
33969
  });
33894
33970
  }
33895
33971
  } else {
33896
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
33972
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
33897
33973
  let unrecognized;
33898
33974
  for (const key of Reflect.ownKeys(input)) {
33899
33975
  if (key === "__proto__")
@@ -34454,7 +34530,7 @@ function bucketFor(state, inst) {
34454
34530
  }
34455
34531
  var handoff;
34456
34532
  var open = [];
34457
- var memo = {
34533
+ var memo2 = {
34458
34534
  alloc(_inst, payload, empty) {
34459
34535
  const bucket = handoff;
34460
34536
  if (!bucket)
@@ -34555,7 +34631,7 @@ var memo = {
34555
34631
  }
34556
34632
  };
34557
34633
  function memoizer() {
34558
- return memo;
34634
+ return memo2;
34559
34635
  }
34560
34636
  function isBackEdge(ctx, value) {
34561
34637
  const backEdges = ctx[STATE]?.backEdges;
@@ -40735,8 +40811,8 @@ function handleArrayResult3(result, final, index) {
40735
40811
  }
40736
40812
  var $ZodArray3 = /* @__PURE__ */ $constructor3("$ZodArray", (inst, def) => {
40737
40813
  $ZodType3.init(inst, def);
40738
- const memo4 = globalConfig3.memoizer;
40739
- memo4?.attach(inst);
40814
+ const memo5 = globalConfig3.memoizer;
40815
+ memo5?.attach(inst);
40740
40816
  inst._zod.parse = (payload, ctx) => {
40741
40817
  const input = payload.value;
40742
40818
  if (!Array.isArray(input)) {
@@ -40748,7 +40824,7 @@ var $ZodArray3 = /* @__PURE__ */ $constructor3("$ZodArray", (inst, def) => {
40748
40824
  });
40749
40825
  return payload;
40750
40826
  }
40751
- payload.value = memo4 ? memo4.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
40827
+ payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
40752
40828
  const proms = [];
40753
40829
  const abortEarly = ctx?.abortEarly;
40754
40830
  for (let i = 0; i < input.length; i++) {
@@ -40908,8 +40984,8 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
40908
40984
  const isObject8 = isObject7;
40909
40985
  const catchall = def.catchall;
40910
40986
  let value;
40911
- const memo4 = globalConfig3.memoizer;
40912
- memo4?.attach(inst);
40987
+ const memo5 = globalConfig3.memoizer;
40988
+ memo5?.attach(inst);
40913
40989
  inst._zod.parse = (payload, ctx) => {
40914
40990
  value ?? (value = _normalized.value);
40915
40991
  const input = payload.value;
@@ -40922,7 +40998,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
40922
40998
  });
40923
40999
  return payload;
40924
41000
  }
40925
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41001
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
40926
41002
  const proms = [];
40927
41003
  const shape = value.shape;
40928
41004
  const abortEarly = ctx?.abortEarly;
@@ -40955,11 +41031,11 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
40955
41031
  $ZodObject3.init(inst, def);
40956
41032
  const superParse = inst._zod.parse;
40957
41033
  const _normalized = cached3(() => normalizeDef2(def));
40958
- const memo4 = globalConfig3.memoizer;
41034
+ const memo5 = globalConfig3.memoizer;
40959
41035
  const generateFastpass = (shape) => {
40960
41036
  const normalized = _normalized.value;
40961
41037
  const syms = normalized.symbolKeys;
40962
- const doc = new Doc3(["payload", "ctx"], { shape, inst, memo: memo4, syms });
41038
+ const doc = new Doc3(["payload", "ctx"], { shape, inst, memo: memo5, syms });
40963
41039
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
40964
41040
  const prefixStr = (id, k) => `
40965
41041
  let ${id}_ab = false;
@@ -40979,7 +41055,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
40979
41055
  for (const key of normalized.allKeys) {
40980
41056
  ids[key] = `key_${counter++}`;
40981
41057
  }
40982
- doc.write(memo4 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
41058
+ doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
40983
41059
  for (const key of normalized.allKeys) {
40984
41060
  if (key === "__proto__")
40985
41061
  continue;
@@ -41342,8 +41418,8 @@ function handleIntersectionResults3(result, left, right2) {
41342
41418
  }
41343
41419
  var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41344
41420
  $ZodType3.init(inst, def);
41345
- const memo4 = globalConfig3.memoizer;
41346
- memo4?.attach(inst);
41421
+ const memo5 = globalConfig3.memoizer;
41422
+ memo5?.attach(inst);
41347
41423
  inst._zod.parse = (payload, ctx) => {
41348
41424
  const input = payload.value;
41349
41425
  if (!isPlainObject5(input)) {
@@ -41358,7 +41434,7 @@ var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41358
41434
  const proms = [];
41359
41435
  const values = def.keyType._zod.values;
41360
41436
  if (values && !def.partial) {
41361
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41437
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
41362
41438
  const recordKeys = /* @__PURE__ */ new Set();
41363
41439
  for (const key of values) {
41364
41440
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -41422,7 +41498,7 @@ var $ZodRecord3 = /* @__PURE__ */ $constructor3("$ZodRecord", (inst, def) => {
41422
41498
  });
41423
41499
  }
41424
41500
  } else {
41425
- payload.value = memo4 ? memo4.alloc(inst, payload, {}, ctx) : {};
41501
+ payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
41426
41502
  let unrecognized;
41427
41503
  for (const key of Reflect.ownKeys(input)) {
41428
41504
  if (key === "__proto__")
@@ -41983,7 +42059,7 @@ function bucketFor2(state, inst) {
41983
42059
  }
41984
42060
  var handoff2;
41985
42061
  var open2 = [];
41986
- var memo2 = {
42062
+ var memo3 = {
41987
42063
  alloc(_inst, payload, empty) {
41988
42064
  const bucket = handoff2;
41989
42065
  if (!bucket)
@@ -42084,7 +42160,7 @@ var memo2 = {
42084
42160
  }
42085
42161
  };
42086
42162
  function memoizer2() {
42087
- return memo2;
42163
+ return memo3;
42088
42164
  }
42089
42165
  function isBackEdge2(ctx, value) {
42090
42166
  const backEdges = ctx[STATE2]?.backEdges;
@@ -47347,9 +47423,9 @@ function build() {
47347
47423
  SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
47348
47424
  };
47349
47425
  }
47350
- var memo3;
47426
+ var memo4;
47351
47427
  function buildSchemas2026() {
47352
- return memo3 ??= build();
47428
+ return memo4 ??= build();
47353
47429
  }
47354
47430
  var CACHEABLE_RESULT_METHODS = [
47355
47431
  "tools/list",
@@ -58893,8 +58969,8 @@ function installExitGuard(opts) {
58893
58969
  }
58894
58970
 
58895
58971
  // 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";
58972
+ import { existsSync as existsSync23, readdirSync as readdirSync11, rmSync as rmSync11 } from "node:fs";
58973
+ import { join as join27 } from "node:path";
58898
58974
  function deleteSource(raw, id) {
58899
58975
  raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
58900
58976
  deleteChunkRows(raw, { sourceId: id });
@@ -58929,7 +59005,7 @@ function userVersion(raw) {
58929
59005
  return raw.prepare("PRAGMA user_version").get().user_version;
58930
59006
  }
58931
59007
  function openForSweep(dbPath, projectKey) {
58932
- if (!existsSync22(dbPath) && (existsSync22(dbPath + DB_WAL_SUFFIX) || existsSync22(dbPath + DB_SHM_SUFFIX))) {
59008
+ if (!existsSync23(dbPath) && (existsSync23(dbPath + DB_WAL_SUFFIX) || existsSync23(dbPath + DB_SHM_SUFFIX))) {
58933
59009
  throw new CtxError("DB_GONE");
58934
59010
  }
58935
59011
  const sqlite = process.getBuiltinModule("node:sqlite");
@@ -58950,8 +59026,8 @@ function lastAccess(raw) {
58950
59026
  return row5.t;
58951
59027
  }
58952
59028
  function sweepOne(configDir, projectKey, cutoff) {
58953
- const dir = join26(configDir, PROJECTS_DIR_NAME, projectKey);
58954
- const db = openForSweep(join26(dir, DB_FILE_NAME), projectKey);
59029
+ const dir = join27(configDir, PROJECTS_DIR_NAME, projectKey);
59030
+ const db = openForSweep(join27(dir, DB_FILE_NAME), projectKey);
58955
59031
  let dead;
58956
59032
  try {
58957
59033
  dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
@@ -58964,7 +59040,7 @@ function sweepOne(configDir, projectKey, cutoff) {
58964
59040
  function sweepDeadProjects(configDir) {
58965
59041
  let entries;
58966
59042
  try {
58967
- entries = readdirSync11(join26(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
59043
+ entries = readdirSync11(join27(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
58968
59044
  } catch (err) {
58969
59045
  if (err.code === "ENOENT") return [];
58970
59046
  throw err;
@@ -59057,7 +59133,7 @@ function workspaceFromMeta(meta3) {
59057
59133
  if (typeof cwd !== "string" || cwd === "") return void 0;
59058
59134
  if (!cwd.startsWith(FILE_URL_PREFIX)) return cwd;
59059
59135
  try {
59060
- return fileURLToPath2(cwd);
59136
+ return fileURLToPath3(cwd);
59061
59137
  } catch {
59062
59138
  return void 0;
59063
59139
  }
@@ -59073,7 +59149,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
59073
59149
  const fromHost = workspaceFromMeta(meta3);
59074
59150
  if (fromHost !== void 0) return fromHost;
59075
59151
  if (script === void 0 || script === "") return spawnCwd;
59076
- return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
59152
+ return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
59077
59153
  }
59078
59154
  function errorReply(err) {
59079
59155
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
@@ -59112,15 +59188,15 @@ async function startServer(argv, env) {
59112
59188
  opening.catch(() => pending.delete(project.dbPath));
59113
59189
  }
59114
59190
  const db = await opening;
59115
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
59191
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
59116
59192
  return db;
59117
59193
  }
59118
59194
  function stopMarker(configDir, projectKey) {
59119
- return join27(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59195
+ return join28(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59120
59196
  }
59121
59197
  function stopRequested() {
59122
59198
  const configDir = resolveConfigDir(process.env);
59123
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
59199
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
59124
59200
  }
59125
59201
  async function journal(project, ctx, name, reply4) {
59126
59202
  const db = await ownDb(project);
@@ -59229,7 +59305,7 @@ async function startServer(argv, env) {
59229
59305
  handle = serveStdio(createServer);
59230
59306
  await new Promise((resolve8) => process.once("exit", () => resolve8()));
59231
59307
  }
59232
- if (isEntry(import.meta.main, process.argv[1], fileURLToPath2(import.meta.url))) {
59308
+ if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
59233
59309
  const [, , ...cliArgs] = process.argv;
59234
59310
  await startServer(cliArgs, process.env);
59235
59311
  }