context-mode 2.1.9 → 2.2.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.
@@ -364,6 +364,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
364
364
  qwen: READ_IMAGES_AND_PDF,
365
365
  opencode: READ_IMAGES_AND_PDF,
366
366
  pi: READ_IMAGES,
367
+ omp: READ_IMAGES,
367
368
  vscode: READ_IMAGES,
368
369
  zcode: READ_IMAGES,
369
370
  "copilot-cli": [],
@@ -480,7 +481,7 @@ var DECISION_ANSWERS_KEY = "answers";
480
481
  var DECISION_OPTION_KEY = "option";
481
482
  var DECISION_LABEL_JOIN = " | ";
482
483
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
483
- var BUNDLE_SHA = true ? "9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde" : void 0;
484
+ var BUNDLE_SHA = true ? "9cb2aaa5ebb63491960b3f3e9655a5821383eae4" : void 0;
484
485
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
485
486
  var DOCTOR_LABEL = Object.freeze({
486
487
  D1: "version",
@@ -632,7 +633,9 @@ var AGENT_HOME_DIR = Object.freeze({
632
633
  kiro: [".kiro"],
633
634
  zcode: [".zcode"],
634
635
  pi: [".pi"],
635
- opencode: [".config", "opencode"]
636
+ opencode: [".config", "opencode"],
637
+ omp: [".omp"]
638
+ // ADR-0026: OMP data and plugins live under ~/.omp
636
639
  });
637
640
  var UPGRADE_RESTART_LINE = "restart needed";
638
641
  var UPGRADE_HOST_AREA = "host update";
@@ -720,16 +723,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
720
723
  binaries: [],
721
724
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
722
725
  }),
723
- unsupported({
724
- id: "omp",
725
- name: "OMP (oh-my-pi)",
726
- clientNames: ["omp-coding-agent"],
727
- envVars: [],
728
- pluginPaths: [],
729
- configDirs: [".omp"],
730
- binaries: ["omp"],
731
- source: "v1.0.169:src/adapters/client-map.ts:37; detect.ts:543 (PI_CODING_AGENT_DIR is not a signal: supported Pi reads it too)"
732
- }),
733
726
  unsupported({
734
727
  id: "openclaw",
735
728
  name: "OpenClaw",
@@ -796,7 +789,9 @@ var HOOK_HOST_FILE = Object.freeze({
796
789
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
797
790
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
798
791
  pi: null,
799
- opencode: null
792
+ opencode: null,
793
+ omp: null
794
+ // ADR-0026: in-process, no hook file
800
795
  });
801
796
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
802
797
  var HOOK_MATCHER_FIELD = "matcher";
@@ -821,9 +816,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
821
816
  var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
822
817
  var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
823
818
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
824
- function D5_SLOW_DETAIL(ms) {
825
- return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
819
+ var D5_BARE_SHARE = 0.5;
820
+ function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
821
+ return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
822
+ }
823
+ function D5_SLOW_START_DETAIL(ms, bare2, bound) {
824
+ return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
826
825
  }
826
+ var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
827
827
  var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
828
828
  var D5_FIX = "run ctx_upgrade";
829
829
  var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
@@ -847,6 +847,12 @@ var D11_POSIX_FIX = "install sh or add it to PATH";
847
847
  function D11_PASS_DETAIL(shell, win) {
848
848
  return `${win ? "Git Bash" : "sh"}: ${shell}`;
849
849
  }
850
+ function D11_RUNTIME_DETAIL(lang, unreadable) {
851
+ return `${lang} not found, unreadable on PATH: ${unreadable.join(", ")}`;
852
+ }
853
+ function D11_RUNTIME_FIX(lang) {
854
+ return `install ${lang}, or turn off its app alias and PATH entry that cannot be read`;
855
+ }
850
856
  var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
851
857
  var HEAL_TMP_SUFFIX = ".heal";
852
858
  var HEAL_TS_SEP = ".";
@@ -858,6 +864,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
858
864
  gemini: "gemini extensions update context-mode",
859
865
  qwen: "qwen extensions update context-mode",
860
866
  pi: "pi update --extensions",
867
+ omp: "omp plugin upgrade context-mode",
868
+ // ADR-0026 decision 4: OMP native update
861
869
  opencode: "opencode plugin update",
862
870
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
863
871
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -901,6 +909,14 @@ var PI_NPM_DIR = "npm";
901
909
  var PI_NODE_MODULES_DIR = "node_modules";
902
910
  var PI_PACKAGE_JSON_FILE = "package.json";
903
911
  var PI_LIST_COMMAND = "pi list";
912
+ var OMP_LIST_COMMAND = "omp plugin list";
913
+ var OMP_ENABLE_COMMAND = "omp plugin enable context-mode";
914
+ var OMP_MIN_VERSION = "14.7.0";
915
+ var OMP_FLOOR_INFO = (v) => `OMP ${v} is older than the tested floor ${OMP_MIN_VERSION}. Update it with: omp update`;
916
+ var OMP_CONTENT_INFO = "OMP keeps tool output in content; context-mode writes its notes there.";
917
+ var OMP_PRINT_MODE_INFO = "Print mode sends no prompt event. Use omp or omp --mode rpc to keep prompts.";
918
+ var OMP_SCRIPTS_INFO = "Add < /dev/null in scripts.";
919
+ var OMP_IMPORT_INFO = (claude, mcp) => `OMP also imports context-mode from ${claude}. To run it once, add "context-mode" to disabledServers in ${mcp}.`;
904
920
  var PI_CURRENT_MAJOR = 2;
905
921
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
906
922
  var V1_TMP_PREFIX = "context-mode-";
@@ -1110,6 +1126,8 @@ var NATIVE_INSTALL = Object.freeze({
1110
1126
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
1111
1127
  opencode: ["opencode plugin add context-mode"],
1112
1128
  pi: ["pi install npm:context-mode"],
1129
+ omp: ["omp plugin install context-mode"],
1130
+ // ADR-0026 decision 4: OMP native install
1113
1131
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
1114
1132
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
1115
1133
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -1259,7 +1277,7 @@ var CtxError = class extends Error {
1259
1277
  import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve8, sep as sep3 } from "node:path";
1260
1278
 
1261
1279
  // src/core/contracts/agents.ts
1262
- var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
1280
+ var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode", "omp"];
1263
1281
 
1264
1282
  // src/adapters/claude-code.ts
1265
1283
  var TOOL_NAME_PREFIX2 = "mcp__plugin_context-mode_context-mode__";
@@ -1981,6 +1999,9 @@ function readResult7(p) {
1981
1999
  if (p.keep === true) info.keep = true;
1982
2000
  return info;
1983
2001
  }
2002
+ function decodeOmp(raw) {
2003
+ return { ...decode10(raw), agent: "omp" };
2004
+ }
1984
2005
  function decode10(raw) {
1985
2006
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
1986
2007
  const p = raw;
@@ -2218,14 +2239,36 @@ var ADAPTERS = Object.freeze([
2218
2239
  decode,
2219
2240
  encode,
2220
2241
  toCanonicalTool
2242
+ },
2243
+ {
2244
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
2245
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
2246
+ id: "omp",
2247
+ installMode: "in-process",
2248
+ projectSource: "pi:ctx.cwd",
2249
+ toolNamePrefix: TOOL_NAME_PREFIX10,
2250
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
2251
+ execReadOnlyHint: false,
2252
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
2253
+ compactDelivery: "pi-flag",
2254
+ compactSummary: "none",
2255
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
2256
+ denyChannel: "deny-reason",
2257
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
2258
+ skillChannel: { kind: "package", path: "skills" },
2259
+ // D-OMP-SKILLS-1
2260
+ decode: decodeOmp,
2261
+ encode: encode10,
2262
+ checkPermission
2263
+ // D-OMP-FIRE-1: agent omp in rows
2221
2264
  }
2222
2265
  ]);
2223
2266
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
2224
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
2267
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
2225
2268
  function hasReplace(row5) {
2226
2269
  return REPLACE_ROWS.has(row5.id);
2227
2270
  }
2228
- var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi"]);
2271
+ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi", "omp"]);
2229
2272
  function dumpRunsThenReplaces(row5) {
2230
2273
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
2231
2274
  }
@@ -3719,7 +3762,8 @@ function toolSetForAgentType(ev, src) {
3719
3762
  const type = ev.agentType ?? "";
3720
3763
  const def = findDef(type, src) ?? builtIn(ev.agent, type);
3721
3764
  if (def === null) return null;
3722
- const tools = (def.tools ?? allKnownToolNames(row5)).map((n) => norm(row5, n));
3765
+ const known = allKnownToolNames(row5);
3766
+ const tools = def.tools === null ? known : def.tools.map((n) => norm(row5, n)).flatMap((n) => [n, ...known.filter((k) => grants(n, k))]);
3723
3767
  const deny2 = def.disallowed.map((n) => norm(row5, n));
3724
3768
  return unique(tools.filter((n) => !deny2.some((d) => denies(d, n))));
3725
3769
  }
@@ -3875,6 +3919,13 @@ function geminiValid(s) {
3875
3919
  }
3876
3920
  return out;
3877
3921
  }
3922
+ function grants(entry, name) {
3923
+ if (!entry.startsWith(MCP_SERVER_TOOL_PREFIX)) return false;
3924
+ const wild = MCP_NAME_JOIN + "*";
3925
+ const server2 = entry.slice(MCP_SERVER_TOOL_PREFIX.length, entry.endsWith(wild) ? -wild.length : entry.length);
3926
+ if (server2 === "" || server2.indexOf("*") >= 0 || server2.indexOf(MCP_NAME_JOIN) >= 0) return false;
3927
+ return name.startsWith(MCP_SERVER_TOOL_PREFIX + server2 + MCP_NAME_JOIN);
3928
+ }
3878
3929
  function denies(rule, name) {
3879
3930
  if (rule.endsWith("*")) return name.startsWith(rule.slice(0, -1));
3880
3931
  if (rule === name) return true;
@@ -4805,6 +4856,7 @@ function sourceOf(agent) {
4805
4856
  case "opencode":
4806
4857
  return "spawn-cwd";
4807
4858
  case "pi":
4859
+ case "omp":
4808
4860
  return "pi:ctx.cwd";
4809
4861
  }
4810
4862
  }
@@ -8464,7 +8516,7 @@ function cutPoint(src, start, end, scratch) {
8464
8516
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
8465
8517
  return { end: start + r.read, written: r.written };
8466
8518
  }
8467
- function merge(src, blocks, join25, cap, lineCut) {
8519
+ function merge(src, blocks, join27, cap, lineCut) {
8468
8520
  const out = [];
8469
8521
  const scratch = new Uint8Array(cap);
8470
8522
  let wide;
@@ -8474,7 +8526,7 @@ function merge(src, blocks, join25, cap, lineCut) {
8474
8526
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
8475
8527
  };
8476
8528
  for (const b of blocks) {
8477
- if (cur !== void 0 && !join25) {
8529
+ if (cur !== void 0 && !join27) {
8478
8530
  emit(cur.start, cur.end, curBytes);
8479
8531
  cur = void 0;
8480
8532
  }
@@ -9116,7 +9168,7 @@ async function handleHook(agent, raw, env) {
9116
9168
  try {
9117
9169
  fault(env, "project");
9118
9170
  const argv = agent === "vscode" ? [WORKSPACE_FOLDER_FLAG, ev.cwd] : process.argv;
9119
- project = resolveProject(agent, { env, argv, cwd: ev.cwd, piCwd: agent === "pi" ? ev.cwd : void 0 });
9171
+ project = resolveProject(agent, { env, argv, cwd: ev.cwd, piCwd: getAdapter(agent).projectSource === "pi:ctx.cwd" ? ev.cwd : void 0 });
9120
9172
  } catch (err) {
9121
9173
  return fail7("project", err, "hooks: no project: " + String(err.code ?? "ERROR") + " " + message(err) + "\n");
9122
9174
  }
@@ -20792,22 +20844,34 @@ function fileNames(name, pathExt) {
20792
20844
  if (!isWin() || path.extname(name) !== "") return [name];
20793
20845
  return [...pathExt.map((ext) => name + ext), name];
20794
20846
  }
20795
- function isRunnable(full) {
20796
- const st = statSync3(full, { throwIfNoEntry: false });
20797
- if (st === void 0 || !st.isFile()) return false;
20847
+ function probe(full) {
20848
+ let st;
20849
+ try {
20850
+ st = statSync3(full, { throwIfNoEntry: false });
20851
+ } catch {
20852
+ return "unreadable";
20853
+ }
20854
+ if (st === void 0 || !st.isFile()) return "absent";
20798
20855
  if (isWin()) {
20799
20856
  const ext = path.extname(full).toLowerCase();
20800
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
20857
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
20801
20858
  }
20802
20859
  try {
20803
20860
  accessSync(full, fsConstants.X_OK);
20804
- return true;
20861
+ return "runnable";
20805
20862
  } catch {
20806
- return false;
20863
+ return "absent";
20807
20864
  }
20808
20865
  }
20866
+ function isRunnable(full) {
20867
+ return probe(full) === "runnable";
20868
+ }
20809
20869
  function findRuntime(lang, env = process.env) {
20810
- if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
20870
+ return lookupRuntime(lang, env).found;
20871
+ }
20872
+ function lookupRuntime(lang, env = process.env) {
20873
+ const unreadable = [];
20874
+ if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
20811
20875
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
20812
20876
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
20813
20877
  const names = candidates(lang);
@@ -20816,13 +20880,15 @@ function findRuntime(lang, env = process.env) {
20816
20880
  for (const name of names) {
20817
20881
  for (const file2 of fileNames(name, pathExt)) {
20818
20882
  const full = path.join(dir, file2);
20819
- if (!isRunnable(full)) continue;
20820
- if (!isWin() || path.extname(full) !== "") return full;
20883
+ const state = probe(full);
20884
+ if (state === "unreadable") unreadable.push(full);
20885
+ if (state !== "runnable") continue;
20886
+ if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
20821
20887
  if (shim === null) shim = full;
20822
20888
  }
20823
20889
  }
20824
20890
  }
20825
- return shim;
20891
+ return { found: shim, unreadable };
20826
20892
  }
20827
20893
  function findGitBash(env) {
20828
20894
  const git2 = findRuntime(GIT_BIN, env);
@@ -20902,7 +20968,7 @@ function runProcess(argv, o) {
20902
20968
  let stopTimer;
20903
20969
  const kill = () => {
20904
20970
  if (child.pid !== void 0) killTree(child.pid);
20905
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
20971
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
20906
20972
  };
20907
20973
  const onAbort = () => {
20908
20974
  if (killedBy !== null || settled) return;
@@ -20931,15 +20997,21 @@ function runProcess(argv, o) {
20931
20997
  ...held ? { held: true } : {}
20932
20998
  });
20933
20999
  };
20934
- const finishHeld = () => {
21000
+ const finishHeld = (force = false) => {
20935
21001
  if (settled) return;
20936
- held = exited && killedBy === null;
20937
- child.stdout.destroy();
20938
- child.stderr.destroy();
20939
- if (child.pid !== void 0) killTree(child.pid);
20940
- settle(child.exitCode);
21002
+ const seen = chunkCount;
21003
+ setImmediate(() => {
21004
+ if (settled || !force && chunkCount !== seen) return;
21005
+ held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
21006
+ child.stdout.destroy();
21007
+ child.stderr.destroy();
21008
+ if (child.pid !== void 0) killTree(child.pid);
21009
+ settle(child.exitCode);
21010
+ });
20941
21011
  };
21012
+ let chunkCount = 0;
20942
21013
  const bump = () => {
21014
+ chunkCount++;
20943
21015
  if (!exited || settled) return;
20944
21016
  clearTimeout(graceTimer);
20945
21017
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -20957,7 +21029,7 @@ function runProcess(argv, o) {
20957
21029
  if (settled) return;
20958
21030
  exited = true;
20959
21031
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
20960
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
21032
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
20961
21033
  });
20962
21034
  child.on("error", () => settle(null));
20963
21035
  child.stdin.on("error", () => {
@@ -21579,8 +21651,8 @@ var ctxBatch = Object.freeze({
21579
21651
  });
21580
21652
 
21581
21653
  // src/core/tools/doctor.ts
21582
- import { readdirSync as readdirSync8, readFileSync as readFileSync16, existsSync as existsSync16 } from "node:fs";
21583
- import { basename as basename5, join as join19 } from "node:path";
21654
+ import { readdirSync as readdirSync8, readFileSync as readFileSync17, existsSync as existsSync17 } from "node:fs";
21655
+ import { basename as basename5, join as join20 } from "node:path";
21584
21656
 
21585
21657
  // src/core/ops/bundle-dir.ts
21586
21658
  import { existsSync as existsSync4 } from "node:fs";
@@ -21605,8 +21677,8 @@ function ownBundleDir() {
21605
21677
  }
21606
21678
 
21607
21679
  // src/core/ops/doctor-config.ts
21608
- import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync11 } from "node:fs";
21609
- import { dirname as dirname8, isAbsolute as isAbsolute4, join as join14, resolve as resolve9 } from "node:path";
21680
+ import { existsSync as existsSync11, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "node:fs";
21681
+ import { dirname as dirname8, isAbsolute as isAbsolute5, join as join16, resolve as resolve9 } from "node:path";
21610
21682
 
21611
21683
  // src/core/ops/detect-v1.ts
21612
21684
  import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "node:fs";
@@ -24595,6 +24667,14 @@ function configEntryRoot(adapter, env) {
24595
24667
  if (typeof script !== "string" || !isAbsolute3(script)) throw missing(adapter.id, file2);
24596
24668
  return dirname7(script);
24597
24669
  }
24670
+ function packageDirOf(dir) {
24671
+ for (let cur = dir; ; ) {
24672
+ if (existsSync7(join13(cur, D1_PACKAGE_FILE))) return cur;
24673
+ const up = dirname7(cur);
24674
+ if (up === cur) return dir;
24675
+ cur = up;
24676
+ }
24677
+ }
24598
24678
  function candidate(adapter, env, worktree) {
24599
24679
  switch (adapter.installMode) {
24600
24680
  case "marketplace":
@@ -24608,7 +24688,7 @@ function candidate(adapter, env, worktree) {
24608
24688
  case "plugin":
24609
24689
  return join13(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
24610
24690
  case "in-process":
24611
- return dirname7(fileURLToPath2(import.meta.url));
24691
+ return packageDirOf(dirname7(fileURLToPath2(import.meta.url)));
24612
24692
  }
24613
24693
  }
24614
24694
  function resolvePluginRoot(adapter, env, worktree) {
@@ -24689,14 +24769,281 @@ function piInstalledIn(env, home, pkgDir, cwd) {
24689
24769
  return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
24690
24770
  }
24691
24771
 
24772
+ // src/core/ops/doctor-env.ts
24773
+ import { existsSync as existsSync9, readFileSync as readFileSync11, realpathSync as realpathSync6 } from "node:fs";
24774
+ import { isAbsolute as isAbsolute4, join as join14, relative as relative4 } from "node:path";
24775
+ function pass(id2, detail = DOCTOR_PASS_DETAIL) {
24776
+ return { id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail };
24777
+ }
24778
+ function unknown2(id2, detail, fixCommand) {
24779
+ return fixCommand === void 0 ? { id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail } : { id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail, fixCommand };
24780
+ }
24781
+ function fail2(id2, detail, fixCommand) {
24782
+ return { id: id2, label: DOCTOR_LABEL[id2], status: "FAIL", detail, fixCommand };
24783
+ }
24784
+ function warn(id2, detail, fixCommand) {
24785
+ return { id: id2, label: DOCTOR_LABEL[id2], status: "WARN", detail, fixCommand };
24786
+ }
24787
+ function bundleVersion(bundleDir2) {
24788
+ try {
24789
+ const v = JSON.parse(readFileSync11(join14(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24790
+ return typeof v === "string" && v !== "" ? v : void 0;
24791
+ } catch {
24792
+ return void 0;
24793
+ }
24794
+ }
24795
+ function channelOf(version2) {
24796
+ const at2 = version2.indexOf(D1_PRERELEASE_SEP);
24797
+ if (at2 < 0) return D1_DEFAULT_TAG;
24798
+ const pre = version2.slice(at2 + 1);
24799
+ const dot = pre.indexOf(".");
24800
+ const tag2 = dot < 0 ? pre : pre.slice(0, dot);
24801
+ return tag2 === "" ? D1_DEFAULT_TAG : tag2;
24802
+ }
24803
+ function firstLine3(b) {
24804
+ const text = b.toString("utf8").trim();
24805
+ const nl = text.indexOf("\n");
24806
+ return (nl < 0 ? text : text.slice(0, nl)).trim();
24807
+ }
24808
+ function gitCause(r, timeoutMs) {
24809
+ if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
24810
+ if (r.killed === "cancel") return D1_GIT_CANCEL;
24811
+ if (r.exitCode === null) return D1_GIT_NO_START;
24812
+ return D1_GIT_EXIT(r.exitCode, firstLine3(r.stderr));
24813
+ }
24814
+ function fetchCause(err, timeoutMs) {
24815
+ const name = err instanceof Error ? err.name : "";
24816
+ if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
24817
+ const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
24818
+ const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
24819
+ const msg = cause instanceof Error ? cause.message : String(cause);
24820
+ const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
24821
+ return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
24822
+ }
24823
+ async function npmLatest(url2, tag2, signal, timeoutMs) {
24824
+ try {
24825
+ const res = await fetch(url2, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
24826
+ if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
24827
+ const body = await res.json();
24828
+ const v = typeof body === "object" && body !== null ? body[tag2] : void 0;
24829
+ return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag2) };
24830
+ } catch (err) {
24831
+ return { ok: false, cause: fetchCause(err, timeoutMs) };
24832
+ }
24833
+ }
24834
+ function digits(s) {
24835
+ if (s === "") return false;
24836
+ for (const ch of s) if (ch < "0" || ch > "9") return false;
24837
+ return true;
24838
+ }
24839
+ function parseVersion(v) {
24840
+ const at2 = v.indexOf(D1_PRERELEASE_SEP);
24841
+ const core = (at2 < 0 ? v : v.slice(0, at2)).split(NODE_VERSION_SEP);
24842
+ if (core.length !== 3 || !core.every(digits)) return null;
24843
+ const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
24844
+ if (at2 < 0) return { core: nums, pre: [] };
24845
+ const pre = v.slice(at2 + 1).split(NODE_VERSION_SEP);
24846
+ if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
24847
+ if (pre.length === 1) return { core: nums, pre: [pre[0]] };
24848
+ return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
24849
+ }
24850
+ function sign(n) {
24851
+ return n < 0 ? -1 : n > 0 ? 1 : 0;
24852
+ }
24853
+ function compareVersions(a, b) {
24854
+ const x = parseVersion(a);
24855
+ const y = parseVersion(b);
24856
+ if (x === null || y === null) return null;
24857
+ for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
24858
+ if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
24859
+ if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
24860
+ return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
24861
+ }
24862
+ function highestTag(stdout, tag2) {
24863
+ let best;
24864
+ for (const line of stdout.split("\n")) {
24865
+ const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
24866
+ if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
24867
+ const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
24868
+ if (parseVersion(v) === null || channelOf(v) !== tag2) continue;
24869
+ if (best === void 0 || compareVersions(v, best) === 1) best = v;
24870
+ }
24871
+ return best;
24872
+ }
24873
+ function versionRow(head2, installed, tag2, source, latest, tail, update) {
24874
+ const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
24875
+ if (cmp === 0) return pass("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
24876
+ if (cmp > 0) return pass("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
24877
+ return warn("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, update);
24878
+ }
24879
+ async function checkVersion(i) {
24880
+ if (i.bundleSha === void 0) return unknown2("D1", D1_DEV_BUILD_DETAIL);
24881
+ const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
24882
+ if (i.version === void 0) return unknown2("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
24883
+ const tag2 = channelOf(i.version);
24884
+ const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
24885
+ const git2 = findRuntime(GIT_BIN, i.env);
24886
+ const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
24887
+ if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "", update);
24888
+ let cause = D1_GIT_MISSING;
24889
+ if (git2 !== null) {
24890
+ const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
24891
+ cwd: i.cwd,
24892
+ env: { ...i.env, ...GIT_NO_PROMPT_ENV },
24893
+ signal: i.signal,
24894
+ timeoutMs: i.timeoutMs
24895
+ });
24896
+ if (r.exitCode === 0 && r.killed === null) {
24897
+ const latest = highestTag(r.stdout.toString("utf8"), tag2);
24898
+ if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
24899
+ cause = D1_GIT_NO_TAG(tag2);
24900
+ } else {
24901
+ cause = gitCause(r, i.timeoutMs);
24902
+ }
24903
+ }
24904
+ return unknown2("D1", head2 + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
24905
+ }
24906
+ function numbers(v) {
24907
+ const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
24908
+ return bare2.split(NODE_VERSION_SEP).map(Number);
24909
+ }
24910
+ function belowMin(version2) {
24911
+ const got = numbers(version2);
24912
+ const min = numbers(NODE_MIN);
24913
+ for (let k = 0; k < min.length; k++) {
24914
+ const g = got[k] ?? 0;
24915
+ if (g !== min[k]) return g < min[k];
24916
+ }
24917
+ return false;
24918
+ }
24919
+ async function sqliteLoads() {
24920
+ try {
24921
+ await import(SQLITE_MODULE);
24922
+ return true;
24923
+ } catch {
24924
+ return false;
24925
+ }
24926
+ }
24927
+ async function checkNode(i) {
24928
+ const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
24929
+ const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
24930
+ if (belowMin(i.nodeVersion)) return fail2("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
24931
+ if (!await sqliteLoads()) return fail2("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
24932
+ return pass("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
24933
+ }
24934
+ function checkMcp(ctx, adapter) {
24935
+ const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
24936
+ const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
24937
+ if (named2 || versioned) return pass("D6");
24938
+ return adapter?.installMode === "in-process" ? pass("D6", D6_IN_PROCESS_DETAIL) : unknown2("D6", D6_UNKNOWN_DETAIL);
24939
+ }
24940
+ function piCwdInside(worktree, piCwd) {
24941
+ if (piCwd === void 0 || !existsSync9(piCwd)) return false;
24942
+ const rel = relative4(worktree, realpathSync6.native(piCwd));
24943
+ return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
24944
+ }
24945
+ function checkProject(i) {
24946
+ const bad = fail2("D7", D7_DETAIL(i.project.source), D7_FIX);
24947
+ if (i.project.source !== i.adapter.projectSource) return bad;
24948
+ if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
24949
+ return pass("D7");
24950
+ }
24951
+ function checkMode(adapter, hostPermission) {
24952
+ if (hostPermission === "missing") return fail2("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
24953
+ if (hostPermission === "wired") return pass("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
24954
+ return pass("D10", D10_DETAIL(adapter.denyChannel));
24955
+ }
24956
+ function checkShell(env) {
24957
+ const win = process.platform === "win32";
24958
+ const shell = findRuntime("shell", env);
24959
+ if (shell !== null) return pass("D11", D11_PASS_DETAIL(shell, win));
24960
+ return win ? fail2("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail2("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
24961
+ }
24962
+ function checkRuntimes(env, shellRow) {
24963
+ if (shellRow.status !== "PASS") return shellRow;
24964
+ for (const lang of EXEC_LANGUAGES) {
24965
+ if (lang === "shell") continue;
24966
+ const r = lookupRuntime(lang, env);
24967
+ if (r.found === null && r.unreadable.length > 0) return warn("D11", D11_RUNTIME_DETAIL(lang, r.unreadable), D11_RUNTIME_FIX(lang));
24968
+ }
24969
+ return shellRow;
24970
+ }
24971
+
24972
+ // src/core/ops/omp-import.ts
24973
+ import { join as join15 } from "node:path";
24974
+ var { existsSync: existsSync10, readFileSync: readFileSync12 } = process.getBuiltinModule("node:fs");
24975
+ var OMP_DISABLED_SERVERS_KEY = "disabledServers";
24976
+ var OMP_MCP_FILE = "mcp.json";
24977
+ var OMP_CONFIG_FILE = "config.yml";
24978
+ var ENABLED_PROVIDERS = "enabledProviders";
24979
+ var DISABLED_PROVIDERS = "disabledProviders";
24980
+ var CLAUDE_PROVIDER = "claude";
24981
+ var ALL_PROVIDERS = ["*", "all"];
24982
+ function ompImportFiles(home) {
24983
+ const agentDir = join15(home, ...AGENT_HOME_DIR.omp, PI_AGENT_DIR);
24984
+ return { config: join15(agentDir, OMP_CONFIG_FILE), mcp: join15(agentDir, OMP_MCP_FILE), claude: join15(home, CLAUDE_USER_CONFIG_FILE) };
24985
+ }
24986
+ function readText2(file2) {
24987
+ try {
24988
+ return existsSync10(file2) ? hostText(readFileSync12(file2, "utf8")) : void 0;
24989
+ } catch {
24990
+ return void 0;
24991
+ }
24992
+ }
24993
+ var unquote3 = (s) => {
24994
+ const t = s.trim();
24995
+ const q = t[0];
24996
+ return (q === '"' || q === "'") && t.endsWith(q) && t.length > 1 ? t.slice(1, -1) : t;
24997
+ };
24998
+ var withoutComment = (s) => {
24999
+ const at2 = s.indexOf(" #");
25000
+ return at2 === -1 ? s : s.slice(0, at2);
25001
+ };
25002
+ function yamlTopList(text, key) {
25003
+ const lines = text.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
25004
+ const head2 = `${key}:`;
25005
+ const at2 = lines.findIndex((l) => l.startsWith(head2));
25006
+ if (at2 === -1) return [];
25007
+ const rest = withoutComment(lines[at2].slice(head2.length)).trim();
25008
+ if (rest.startsWith("[")) {
25009
+ const end = rest.indexOf("]");
25010
+ return (end === -1 ? rest.slice(1) : rest.slice(1, end)).split(",").map(unquote3).filter((x) => x !== "");
25011
+ }
25012
+ if (rest !== "") return [];
25013
+ const out = [];
25014
+ for (const line of lines.slice(at2 + 1)) {
25015
+ const t = line.trim();
25016
+ if (t === "" || t.startsWith("#")) continue;
25017
+ if (line === line.trimStart() && !t.startsWith("-")) break;
25018
+ if (!t.startsWith("-")) break;
25019
+ out.push(unquote3(withoutComment(t.slice(1))));
25020
+ }
25021
+ return out;
25022
+ }
25023
+ function ompImportsUs(files, env) {
25024
+ const config2 = readText2(files.config) ?? "";
25025
+ if (yamlTopList(config2, DISABLED_PROVIDERS).includes(CLAUDE_PROVIDER)) return false;
25026
+ const enabled = yamlTopList(config2, ENABLED_PROVIDERS);
25027
+ const dirSet = env[CLAUDE_CONFIG_DIR_ENV] !== void 0 && env[CLAUDE_CONFIG_DIR_ENV] !== "";
25028
+ if (!dirSet && !enabled.some((p) => p === CLAUDE_PROVIDER || ALL_PROVIDERS.includes(p))) return false;
25029
+ const claude = readText2(files.claude);
25030
+ if (claude === void 0) return false;
25031
+ try {
25032
+ const servers = JSON.parse(claude)[MCP_SERVERS_KEY];
25033
+ return typeof servers === "object" && servers !== null && Object.hasOwn(servers, SERVER_KEY);
25034
+ } catch {
25035
+ return false;
25036
+ }
25037
+ }
25038
+
24692
25039
  // src/core/ops/doctor-config.ts
24693
25040
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
24694
25041
  var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24695
25042
  var list2 = (v) => Array.isArray(v) ? v : [];
24696
- function pass(id2) {
25043
+ function pass2(id2) {
24697
25044
  return { id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail: DOCTOR_PASS_DETAIL };
24698
25045
  }
24699
- function fail2(id2, detail, fixCommand) {
25046
+ function fail3(id2, detail, fixCommand) {
24700
25047
  return { id: id2, label: DOCTOR_LABEL[id2], status: "FAIL", detail, fixCommand };
24701
25048
  }
24702
25049
  function readParsed(agent, file2) {
@@ -24766,11 +25113,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
24766
25113
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
24767
25114
  function mcpFile(row5, home, env) {
24768
25115
  const spec = OWN_MCP_ENTRY[row5.id];
24769
- if (row5.id === "codex") return join14(codexDirOf(env, home), CONFIG_TOML_FILE);
25116
+ if (row5.id === "codex") return join16(codexDirOf(env, home), CONFIG_TOML_FILE);
24770
25117
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
24771
- if (row5.id === "opencode") return join14(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
25118
+ if (row5.id === "opencode") return join16(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
24772
25119
  if (row5.id === "pi") {
24773
- return join14(piAgentDirOf(env, home), SETTINGS_FILE);
25120
+ return join16(piAgentDirOf(env, home), SETTINGS_FILE);
24774
25121
  }
24775
25122
  return null;
24776
25123
  }
@@ -24783,27 +25130,27 @@ function codexNativeDir(env, home) {
24783
25130
  const codexDir = codexDirOf(env, home);
24784
25131
  let enabled;
24785
25132
  try {
24786
- enabled = hostConfigValueAt(readParsed("codex", join14(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
25133
+ enabled = hostConfigValueAt(readParsed("codex", join16(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24787
25134
  } catch {
24788
25135
  return null;
24789
25136
  }
24790
25137
  if (enabled !== true) return null;
24791
- const cache = join14(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24792
- if (!existsSync9(cache)) return null;
25138
+ const cache = join16(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
25139
+ if (!existsSync11(cache)) return null;
24793
25140
  const found = [];
24794
25141
  for (const market of readdirSync6(cache)) {
24795
- const plugin = join14(cache, market, SERVER_KEY);
24796
- if (!existsSync9(plugin)) continue;
25142
+ const plugin = join16(cache, market, SERVER_KEY);
25143
+ if (!existsSync11(plugin)) continue;
24797
25144
  for (const version2 of readdirSync6(plugin).sort()) {
24798
- const dir = join14(plugin, version2, CODEX_PLUGIN_SUBDIR);
24799
- if (existsSync9(join14(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
25145
+ const dir = join16(plugin, version2, CODEX_PLUGIN_SUBDIR);
25146
+ if (existsSync11(join16(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24800
25147
  }
24801
25148
  }
24802
25149
  return found.length === 0 ? null : found[found.length - 1];
24803
25150
  }
24804
25151
  function nativeMcpWrong(dir, row5) {
24805
25152
  try {
24806
- const entry = hostConfigValueAt(readParsed(row5.id, join14(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
25153
+ const entry = hostConfigValueAt(readParsed(row5.id, join16(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24807
25154
  if (!isObject4(entry)) return true;
24808
25155
  const args = list2(entry[MCP_ARGS_FIELD]);
24809
25156
  const script = args[0];
@@ -24874,17 +25221,17 @@ function opencodePluginDirs(configDir, worktree) {
24874
25221
  return [configDir, opencodeProjectDir(worktree)];
24875
25222
  }
24876
25223
  function opencodeProjectDir(worktree) {
24877
- return join14(worktree, OPENCODE_PROJECT_DIR);
25224
+ return join16(worktree, OPENCODE_PROJECT_DIR);
24878
25225
  }
24879
25226
  function packageResolves(fromDir) {
24880
25227
  for (let d = fromDir; ; d = dirname8(d)) {
24881
- if (existsSync9(join14(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
25228
+ if (existsSync11(join16(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
24882
25229
  if (dirname8(d) === d) return false;
24883
25230
  }
24884
25231
  }
24885
25232
  function opencodeDirPlugins(dirs) {
24886
25233
  const bundle = opencodePluginFile();
24887
- const ownFile = join14(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
25234
+ const ownFile = join16(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
24888
25235
  const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
24889
25236
  const isPath = (p) => {
24890
25237
  if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -24894,7 +25241,7 @@ function opencodeDirPlugins(dirs) {
24894
25241
  };
24895
25242
  const out = [];
24896
25243
  for (const dir of dirs) {
24897
- const pdir = join14(dir, OPENCODE_PLUGINS_DIR);
25244
+ const pdir = join16(dir, OPENCODE_PLUGINS_DIR);
24898
25245
  let names;
24899
25246
  try {
24900
25247
  names = readdirSync6(pdir);
@@ -24902,12 +25249,12 @@ function opencodeDirPlugins(dirs) {
24902
25249
  continue;
24903
25250
  }
24904
25251
  for (const name of names) {
24905
- const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join14(pdir, name)] : [];
24906
- const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join14(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
25252
+ const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join16(pdir, name)] : [];
25253
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join16(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
24907
25254
  for (const f of files) {
24908
25255
  let text;
24909
25256
  try {
24910
- const b = readFileSync11(f);
25257
+ const b = readFileSync13(f);
24911
25258
  if (b.length > OPENCODE_DIR_FILE_MAX) continue;
24912
25259
  text = b.toString("utf8");
24913
25260
  } catch {
@@ -24918,7 +25265,7 @@ function opencodeDirPlugins(dirs) {
24918
25265
  const loads = lits.some((p) => {
24919
25266
  if (isModule(p)) return packageResolves(dirname8(f));
24920
25267
  const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
24921
- return existsSync9(isAbsolute4(bare2) ? bare2 : resolve9(dirname8(f), bare2));
25268
+ return existsSync11(isAbsolute5(bare2) ? bare2 : resolve9(dirname8(f), bare2));
24922
25269
  });
24923
25270
  out.push({ file: f, loads });
24924
25271
  }
@@ -24936,19 +25283,19 @@ function opencodeMcpOwn(entry) {
24936
25283
  return isNodeCommand(node) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
24937
25284
  }
24938
25285
  function opencodeFileValue(file2) {
24939
- if (!existsSync9(file2)) return {};
24940
- return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
25286
+ if (!existsSync11(file2)) return {};
25287
+ return parseHostConfig("opencode", file2, hostText(readFileSync13(file2, "utf8")), "jsonc");
24941
25288
  }
24942
25289
  function opencodeValueListed(value) {
24943
25290
  const bundle = opencodePluginFile();
24944
- const own2 = [bundle, join14(bundle, ...OPENCODE_PLUGIN_PATH)];
25291
+ const own2 = [bundle, join16(bundle, ...OPENCODE_PLUGIN_PATH)];
24945
25292
  if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own2)))) return true;
24946
25293
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
24947
25294
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
24948
25295
  }
24949
25296
  function opencodeListed(file2, worktree) {
24950
25297
  const dirs = [dirname8(file2), worktree];
24951
- if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join14(dir, name)))))) return true;
25298
+ if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join16(dir, name)))))) return true;
24952
25299
  return opencodeDirPlugin(opencodePluginDirs(dirname8(file2), worktree)) !== void 0;
24953
25300
  }
24954
25301
  function mcpWrong(row5, home, env, worktree) {
@@ -24970,7 +25317,7 @@ function mcpWrong(row5, home, env, worktree) {
24970
25317
  function hookFile(row5, spec, home, env, worktree) {
24971
25318
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
24972
25319
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24973
- const file2 = native !== null ? join14(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join14(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join14(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join14(kiroDirOf(env, home), ...spec.file.slice(1)) : join14(root, ...spec.file);
25320
+ const file2 = native !== null ? join16(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join16(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join16(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join16(kiroDirOf(env, home), ...spec.file.slice(1)) : join16(root, ...spec.file);
24974
25321
  return file2;
24975
25322
  }
24976
25323
  function hookParts(row5, home, env, worktree) {
@@ -24981,7 +25328,7 @@ function hookParts(row5, home, env, worktree) {
24981
25328
  const file2 = hookFile(row5, spec, home, env, worktree);
24982
25329
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24983
25330
  if (row5.id === "codex") {
24984
- const config2 = readParsed(row5.id, join14(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
25331
+ const config2 = readParsed(row5.id, join16(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24985
25332
  if (hostConfigValueAt(config2, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24986
25333
  }
24987
25334
  } catch {
@@ -25010,29 +25357,67 @@ function hookParts(row5, home, env, worktree) {
25010
25357
  }
25011
25358
  function checkHostConfig(row5, env, worktree) {
25012
25359
  const home = homeDirOf(env);
25013
- if (home === null) return fail2("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
25360
+ if (home === null) return fail3("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
25014
25361
  if (row5.installMode === "marketplace") {
25015
25362
  const choice = marketplaceChoice(env, worktree);
25016
- if ("installs" in choice) return fail2("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
25363
+ if ("installs" in choice) return fail3("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
25017
25364
  }
25018
25365
  if (row5.id === "pi") return checkPiInstall(env, home, worktree);
25366
+ if (row5.id === "omp") return checkOmpInstall(home);
25019
25367
  const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
25020
- if (parts.length === 0) return pass("D3");
25368
+ if (parts.length === 0) return pass2("D3");
25021
25369
  const detail = D3_DETAIL(parts);
25022
25370
  const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
25023
- return fail2("D3", detail, fix);
25371
+ return fail3("D3", detail, fix);
25024
25372
  }
25025
25373
  function checkPiInstall(env, home, worktree) {
25026
25374
  const found = piInstalledIn(env, home, ownBundleDir(), worktree);
25027
- if (found !== void 0) return { ...pass("D3"), detail: found };
25028
- return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join14(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
25375
+ if (found !== void 0) return { ...pass2("D3"), detail: found };
25376
+ return fail3("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join16(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
25377
+ }
25378
+ var OMP_PLUGINS_DIR = "plugins";
25379
+ var OMP_LOCK_FILE = "omp-plugins.lock.json";
25380
+ function readJson2(file2) {
25381
+ try {
25382
+ const doc = JSON.parse(readFileSync13(file2, "utf8"));
25383
+ return typeof doc === "object" && doc !== null ? doc : void 0;
25384
+ } catch {
25385
+ return void 0;
25386
+ }
25387
+ }
25388
+ function ownEntry(doc, key) {
25389
+ const map2 = doc?.[key];
25390
+ return typeof map2 === "object" && map2 !== null ? map2[SERVER_KEY] : void 0;
25391
+ }
25392
+ function checkOmpInstall(home) {
25393
+ const dir = join16(home, ...AGENT_HOME_DIR.omp, OMP_PLUGINS_DIR);
25394
+ const lock = join16(dir, OMP_LOCK_FILE);
25395
+ const pkg = join16(dir, PI_PACKAGE_JSON_FILE);
25396
+ const entry = ownEntry(readJson2(lock), "plugins");
25397
+ const missing2 = (file2) => fail3("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + file2, NATIVE_INSTALL.omp[0]);
25398
+ if (typeof entry !== "object" || entry === null) return missing2(lock);
25399
+ if (ownEntry(readJson2(pkg), "dependencies") === void 0) return missing2(pkg);
25400
+ if (entry.enabled !== true) return fail3("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + lock, OMP_ENABLE_COMMAND);
25401
+ return { ...pass2("D3"), detail: lock };
25402
+ }
25403
+ function ompInfoLines(env, version2) {
25404
+ const out = [];
25405
+ if (version2 !== void 0 && compareVersions(version2, OMP_MIN_VERSION) === -1) out.push(OMP_FLOOR_INFO(version2));
25406
+ out.push(OMP_CONTENT_INFO, OMP_PRINT_MODE_INFO, OMP_SCRIPTS_INFO);
25407
+ const home = homeDirOf(env);
25408
+ if (home === null) return out;
25409
+ const files = ompImportFiles(home);
25410
+ if (!ompImportsUs(files, env)) return out;
25411
+ const listed = readJson2(files.mcp)?.[OMP_DISABLED_SERVERS_KEY];
25412
+ if (!(Array.isArray(listed) && listed.includes(SERVER_KEY))) out.push(OMP_IMPORT_INFO(files.claude, files.mcp));
25413
+ return out;
25029
25414
  }
25030
25415
  function checkV1Leftovers(agent, home, scope = {}) {
25031
25416
  const findings = detectV1(agent, home, scope);
25032
- if (findings.length === 0) return pass("D4");
25417
+ if (findings.length === 0) return pass2("D4");
25033
25418
  const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
25034
- if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
25035
- return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
25419
+ if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass2("D4"), detail };
25420
+ return { ...fail3("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
25036
25421
  }
25037
25422
  function parsedOrNull(agent, file2, jsonc) {
25038
25423
  try {
@@ -25043,13 +25428,13 @@ function parsedOrNull(agent, file2, jsonc) {
25043
25428
  }
25044
25429
  }
25045
25430
  function checkDoubleFire(agent, worktree) {
25046
- if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
25047
- const claude = parsedOrNull(agent, join14(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
25431
+ if (agent !== "claude-code" && agent !== "vscode") return pass2("D5b");
25432
+ const claude = parsedOrNull(agent, join16(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
25048
25433
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
25049
25434
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
25050
- const vscode = parsedOrNull(agent, join14(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
25435
+ const vscode = parsedOrNull(agent, join16(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
25051
25436
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
25052
- return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
25437
+ return hooksOn && useClaudeHooks ? fail3("D5b", D5B_DETAIL, D5B_FIX) : pass2("D5b");
25053
25438
  }
25054
25439
  function configPaths(row5, env, worktree) {
25055
25440
  const home = homeDirOf(env);
@@ -25058,7 +25443,7 @@ function configPaths(row5, env, worktree) {
25058
25443
  const mcp = mcpFile(row5, home, env);
25059
25444
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
25060
25445
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
25061
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join14(native, CODEX_PLUGIN_MCP_FILE) });
25446
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join16(native, CODEX_PLUGIN_MCP_FILE) });
25062
25447
  const spec = HOOK_HOST_FILE[row5.id];
25063
25448
  if (spec !== null) {
25064
25449
  try {
@@ -25078,10 +25463,10 @@ function configPaths(row5, env, worktree) {
25078
25463
  }
25079
25464
 
25080
25465
  // src/core/ops/doctor-db.ts
25081
- import { existsSync as existsSync10, statSync as statSync5 } from "node:fs";
25082
- var unknown2 = (id2, detail) => ({ id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail });
25083
- var pass2 = (id2, detail) => ({ id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail });
25084
- var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
25466
+ import { existsSync as existsSync12, statSync as statSync5 } from "node:fs";
25467
+ var unknown3 = (id2, detail) => ({ id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail });
25468
+ var pass3 = (id2, detail) => ({ id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail });
25469
+ var fail4 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
25085
25470
  function isCorrupt2(err) {
25086
25471
  if (typeof err !== "object" || err === null) return false;
25087
25472
  const code = err.errcode;
@@ -25120,17 +25505,17 @@ function orphanFiles(dbPath) {
25120
25505
  const files = [];
25121
25506
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
25122
25507
  const path8 = dbPath + suffix;
25123
- if (existsSync10(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
25508
+ if (existsSync12(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
25124
25509
  }
25125
- return files.length > 0 && !existsSync10(dbPath) ? files : [];
25510
+ return files.length > 0 && !existsSync12(dbPath) ? files : [];
25126
25511
  }
25127
25512
  async function checkDb(project) {
25128
25513
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
25129
25514
  const orphan = orphanFiles(project.dbPath);
25130
- if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
25131
- if (!existsSync10(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
25515
+ if (orphan.length > 0) return { row: fail4(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
25516
+ if (!existsSync12(project.dbPath)) return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
25132
25517
  const sqlite = await loadSqlite2();
25133
- if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
25518
+ if (sqlite === null) return { row: unknown3("D8", D2_SQLITE_DETAIL), ...clean };
25134
25519
  let raw = null;
25135
25520
  try {
25136
25521
  raw = openRead(sqlite, project.dbPath);
@@ -25143,226 +25528,35 @@ async function checkDb(project) {
25143
25528
  }
25144
25529
  const schemaStale = got !== null && got !== SCHEMA_VERSION;
25145
25530
  const integrityFailed = failsOnCorrupt(() => !integrityOk(db));
25146
- if (integrityFailed) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
25147
- if (schemaStale && got !== null) return { row: fail3(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
25148
- return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
25531
+ if (integrityFailed) return { row: fail4(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
25532
+ if (schemaStale && got !== null) return { row: fail4(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
25533
+ return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
25149
25534
  } catch (err) {
25150
- if (isCorrupt2(err)) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
25151
- return { row: unknown2("D8", message2(err)), ...clean };
25535
+ if (isCorrupt2(err)) return { row: fail4(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
25536
+ return { row: unknown3("D8", message2(err)), ...clean };
25152
25537
  } finally {
25153
25538
  raw?.close();
25154
25539
  }
25155
25540
  }
25156
25541
  async function checkIndex(project) {
25157
- if (!existsSync10(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
25542
+ if (!existsSync12(project.dbPath)) return pass3("D9", D9_INDEX_DETAIL(0, 0));
25158
25543
  const sqlite = await loadSqlite2();
25159
- if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
25544
+ if (sqlite === null) return unknown3("D9", D2_SQLITE_DETAIL);
25160
25545
  let raw = null;
25161
25546
  try {
25162
25547
  raw = openRead(sqlite, project.dbPath);
25163
25548
  const sources = Number(cell(raw.prepare("SELECT count(*) FROM sources").get()));
25164
25549
  const chunks = Number(cell(raw.prepare("SELECT count(*) FROM chunks").get()));
25165
- return pass2("D9", D9_INDEX_DETAIL(sources, chunks));
25550
+ return pass3("D9", D9_INDEX_DETAIL(sources, chunks));
25166
25551
  } catch (err) {
25167
- return unknown2("D9", message2(err));
25552
+ return unknown3("D9", message2(err));
25168
25553
  } finally {
25169
25554
  raw?.close();
25170
25555
  }
25171
25556
  }
25172
25557
 
25173
- // src/core/ops/doctor-env.ts
25174
- import { existsSync as existsSync11, readFileSync as readFileSync12, realpathSync as realpathSync6 } from "node:fs";
25175
- import { isAbsolute as isAbsolute5, join as join15, relative as relative4 } from "node:path";
25176
- function pass3(id2, detail = DOCTOR_PASS_DETAIL) {
25177
- return { id: id2, label: DOCTOR_LABEL[id2], status: "PASS", detail };
25178
- }
25179
- function unknown3(id2, detail, fixCommand) {
25180
- return fixCommand === void 0 ? { id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail } : { id: id2, label: DOCTOR_LABEL[id2], status: "UNKNOWN", detail, fixCommand };
25181
- }
25182
- function fail4(id2, detail, fixCommand) {
25183
- return { id: id2, label: DOCTOR_LABEL[id2], status: "FAIL", detail, fixCommand };
25184
- }
25185
- function warn(id2, detail, fixCommand) {
25186
- return { id: id2, label: DOCTOR_LABEL[id2], status: "WARN", detail, fixCommand };
25187
- }
25188
- function bundleVersion(bundleDir2) {
25189
- try {
25190
- const v = JSON.parse(readFileSync12(join15(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
25191
- return typeof v === "string" && v !== "" ? v : void 0;
25192
- } catch {
25193
- return void 0;
25194
- }
25195
- }
25196
- function channelOf(version2) {
25197
- const at2 = version2.indexOf(D1_PRERELEASE_SEP);
25198
- if (at2 < 0) return D1_DEFAULT_TAG;
25199
- const pre = version2.slice(at2 + 1);
25200
- const dot = pre.indexOf(".");
25201
- const tag2 = dot < 0 ? pre : pre.slice(0, dot);
25202
- return tag2 === "" ? D1_DEFAULT_TAG : tag2;
25203
- }
25204
- function firstLine3(b) {
25205
- const text = b.toString("utf8").trim();
25206
- const nl = text.indexOf("\n");
25207
- return (nl < 0 ? text : text.slice(0, nl)).trim();
25208
- }
25209
- function gitCause(r, timeoutMs) {
25210
- if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
25211
- if (r.killed === "cancel") return D1_GIT_CANCEL;
25212
- if (r.exitCode === null) return D1_GIT_NO_START;
25213
- return D1_GIT_EXIT(r.exitCode, firstLine3(r.stderr));
25214
- }
25215
- function fetchCause(err, timeoutMs) {
25216
- const name = err instanceof Error ? err.name : "";
25217
- if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
25218
- const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
25219
- const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
25220
- const msg = cause instanceof Error ? cause.message : String(cause);
25221
- const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
25222
- return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
25223
- }
25224
- async function npmLatest(url2, tag2, signal, timeoutMs) {
25225
- try {
25226
- const res = await fetch(url2, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
25227
- if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
25228
- const body = await res.json();
25229
- const v = typeof body === "object" && body !== null ? body[tag2] : void 0;
25230
- return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag2) };
25231
- } catch (err) {
25232
- return { ok: false, cause: fetchCause(err, timeoutMs) };
25233
- }
25234
- }
25235
- function digits(s) {
25236
- if (s === "") return false;
25237
- for (const ch of s) if (ch < "0" || ch > "9") return false;
25238
- return true;
25239
- }
25240
- function parseVersion(v) {
25241
- const at2 = v.indexOf(D1_PRERELEASE_SEP);
25242
- const core = (at2 < 0 ? v : v.slice(0, at2)).split(NODE_VERSION_SEP);
25243
- if (core.length !== 3 || !core.every(digits)) return null;
25244
- const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
25245
- if (at2 < 0) return { core: nums, pre: [] };
25246
- const pre = v.slice(at2 + 1).split(NODE_VERSION_SEP);
25247
- if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
25248
- if (pre.length === 1) return { core: nums, pre: [pre[0]] };
25249
- return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
25250
- }
25251
- function sign(n) {
25252
- return n < 0 ? -1 : n > 0 ? 1 : 0;
25253
- }
25254
- function compareVersions(a, b) {
25255
- const x = parseVersion(a);
25256
- const y = parseVersion(b);
25257
- if (x === null || y === null) return null;
25258
- for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
25259
- if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
25260
- if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
25261
- return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
25262
- }
25263
- function highestTag(stdout, tag2) {
25264
- let best;
25265
- for (const line of stdout.split("\n")) {
25266
- const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
25267
- if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
25268
- const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
25269
- if (parseVersion(v) === null || channelOf(v) !== tag2) continue;
25270
- if (best === void 0 || compareVersions(v, best) === 1) best = v;
25271
- }
25272
- return best;
25273
- }
25274
- function versionRow(head2, installed, tag2, source, latest, tail, update) {
25275
- const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
25276
- if (cmp === 0) return pass3("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
25277
- if (cmp > 0) return pass3("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
25278
- return warn("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, update);
25279
- }
25280
- async function checkVersion(i) {
25281
- if (i.bundleSha === void 0) return unknown3("D1", D1_DEV_BUILD_DETAIL);
25282
- const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
25283
- if (i.version === void 0) return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
25284
- const tag2 = channelOf(i.version);
25285
- const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
25286
- const git2 = findRuntime(GIT_BIN, i.env);
25287
- const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
25288
- if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "", update);
25289
- let cause = D1_GIT_MISSING;
25290
- if (git2 !== null) {
25291
- const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
25292
- cwd: i.cwd,
25293
- env: { ...i.env, ...GIT_NO_PROMPT_ENV },
25294
- signal: i.signal,
25295
- timeoutMs: i.timeoutMs
25296
- });
25297
- if (r.exitCode === 0 && r.killed === null) {
25298
- const latest = highestTag(r.stdout.toString("utf8"), tag2);
25299
- if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
25300
- cause = D1_GIT_NO_TAG(tag2);
25301
- } else {
25302
- cause = gitCause(r, i.timeoutMs);
25303
- }
25304
- }
25305
- return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
25306
- }
25307
- function numbers(v) {
25308
- const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
25309
- return bare2.split(NODE_VERSION_SEP).map(Number);
25310
- }
25311
- function belowMin(version2) {
25312
- const got = numbers(version2);
25313
- const min = numbers(NODE_MIN);
25314
- for (let k = 0; k < min.length; k++) {
25315
- const g = got[k] ?? 0;
25316
- if (g !== min[k]) return g < min[k];
25317
- }
25318
- return false;
25319
- }
25320
- async function sqliteLoads() {
25321
- try {
25322
- await import(SQLITE_MODULE);
25323
- return true;
25324
- } catch {
25325
- return false;
25326
- }
25327
- }
25328
- async function checkNode(i) {
25329
- const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
25330
- const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
25331
- if (belowMin(i.nodeVersion)) return fail4("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
25332
- if (!await sqliteLoads()) return fail4("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
25333
- return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
25334
- }
25335
- function checkMcp(ctx, adapter) {
25336
- const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
25337
- const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
25338
- if (named2 || versioned) return pass3("D6");
25339
- return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown3("D6", D6_UNKNOWN_DETAIL);
25340
- }
25341
- function piCwdInside(worktree, piCwd) {
25342
- if (piCwd === void 0 || !existsSync11(piCwd)) return false;
25343
- const rel = relative4(worktree, realpathSync6.native(piCwd));
25344
- return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
25345
- }
25346
- function checkProject(i) {
25347
- const bad = fail4("D7", D7_DETAIL(i.project.source), D7_FIX);
25348
- if (i.project.source !== i.adapter.projectSource) return bad;
25349
- if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
25350
- return pass3("D7");
25351
- }
25352
- function checkMode(adapter, hostPermission) {
25353
- if (hostPermission === "missing") return fail4("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
25354
- if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
25355
- return pass3("D10", D10_DETAIL(adapter.denyChannel));
25356
- }
25357
- function checkShell(env) {
25358
- const win = process.platform === "win32";
25359
- const shell = findRuntime("shell", env);
25360
- if (shell !== null) return pass3("D11", D11_PASS_DETAIL(shell, win));
25361
- return win ? fail4("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail4("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
25362
- }
25363
-
25364
25558
  // src/core/ops/doctor-hook.ts
25365
- import { existsSync as existsSync13, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync13, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
25559
+ import { existsSync as existsSync14, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync14, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
25366
25560
  import { tmpdir as tmpdir2 } from "node:os";
25367
25561
  import path7 from "node:path";
25368
25562
 
@@ -27106,7 +27300,9 @@ var HOST_SHAPES = {
27106
27300
  kiro: kiro_default,
27107
27301
  zcode: zcode_default,
27108
27302
  pi: pi_default,
27109
- opencode: opencode_default
27303
+ opencode: opencode_default,
27304
+ omp: pi_default
27305
+ // ADR-0026: OMP reads the Pi extension reply
27110
27306
  };
27111
27307
  var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
27112
27308
  var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
@@ -27188,7 +27384,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
27188
27384
 
27189
27385
  // src/setup/codex-trust.ts
27190
27386
  import { createHash } from "node:crypto";
27191
- import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
27387
+ import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
27192
27388
  import path6 from "node:path";
27193
27389
  import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
27194
27390
 
@@ -27411,10 +27607,10 @@ function isObject6(v) {
27411
27607
  }
27412
27608
  function loadFixture(bundleDir2, agent) {
27413
27609
  const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
27414
- if (!existsSync13(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27610
+ if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27415
27611
  let all;
27416
27612
  try {
27417
- all = JSON.parse(hostText(readFileSync13(file2, "utf8")));
27613
+ all = JSON.parse(hostText(readFileSync14(file2, "utf8")));
27418
27614
  } catch (err) {
27419
27615
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
27420
27616
  }
@@ -27436,7 +27632,8 @@ var CWD_KEY = {
27436
27632
  kiro: "cwd",
27437
27633
  zcode: "cwd",
27438
27634
  pi: "cwd",
27439
- opencode: "directory"
27635
+ opencode: "directory",
27636
+ omp: "cwd"
27440
27637
  };
27441
27638
  function payloadFor(agent, payload, worktree) {
27442
27639
  return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
@@ -27628,7 +27825,7 @@ async function codexStopDetail(i, timeoutMs) {
27628
27825
  timeoutMs,
27629
27826
  stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
27630
27827
  });
27631
- const logged = existsSync13(path7.join(home, HOOK_ERROR_LOG_FILE));
27828
+ const logged = existsSync14(path7.join(home, HOOK_ERROR_LOG_FILE));
27632
27829
  return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
27633
27830
  } finally {
27634
27831
  rmSync2(home, { recursive: true, force: true });
@@ -27639,7 +27836,7 @@ async function checkHookRoundTrip(i) {
27639
27836
  const trust = await codexPluginTrust(i);
27640
27837
  if (trust !== null) return trust;
27641
27838
  }
27642
- if (i.agent === "codex" && existsSync13(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
27839
+ if (i.agent === "codex" && existsSync14(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
27643
27840
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
27644
27841
  }
27645
27842
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -27655,10 +27852,13 @@ async function checkHookRoundTrip(i) {
27655
27852
  await runProcess([node.file, "-e", ""], { cwd: i.bundleDir, env: node.env, signal: i.signal, timeoutMs });
27656
27853
  return performance.now() - t;
27657
27854
  });
27855
+ const inProcess = getAdapter(i.agent).installMode === "in-process";
27658
27856
  const hookWalls = [];
27659
27857
  const bareWalls = [];
27660
27858
  let ms = 0;
27661
- for (let n = 1; n <= maxPairs; n++) {
27859
+ let fastBare = 0;
27860
+ let bound = HOOK_P95_MS;
27861
+ for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
27662
27862
  const start = now();
27663
27863
  const node = nodeLaunch(i.env);
27664
27864
  const r = await runProcess([node.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
@@ -27670,25 +27870,29 @@ async function checkHookRoundTrip(i) {
27670
27870
  });
27671
27871
  hookWalls.push(now() - start);
27672
27872
  if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
27873
+ if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
27673
27874
  bareWalls.push(await bareMs());
27674
- ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
27675
- if (n >= minPairs && ms <= HOOK_P95_MS) break;
27875
+ fastBare = Math.round(Math.min(...bareWalls));
27876
+ ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
27877
+ bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
27878
+ if (n >= minPairs && ms <= bound) break;
27676
27879
  }
27677
- if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
27880
+ if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
27678
27881
  const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
27679
27882
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
27883
+ if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
27680
27884
  return row("PASS", DOCTOR_PASS_DETAIL);
27681
27885
  }
27682
27886
 
27683
27887
  // src/core/ops/db-heal.ts
27684
- import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27685
- import { basename as basename4, dirname as dirname9, join as join17 } from "node:path";
27888
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27889
+ import { basename as basename4, dirname as dirname9, join as join18 } from "node:path";
27686
27890
 
27687
27891
  // src/core/store/owners.ts
27688
- import { mkdirSync as mkdirSync5, readdirSync as readdirSync7, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27689
- import { basename as basename3, join as join16 } from "node:path";
27892
+ import { mkdirSync as mkdirSync5, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27893
+ import { basename as basename3, join as join17 } from "node:path";
27690
27894
  function ownersDir(configDir, projectKey) {
27691
- return join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27895
+ return join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27692
27896
  }
27693
27897
  function errCode2(err) {
27694
27898
  return err.code;
@@ -27716,10 +27920,10 @@ function listLiveOwners(configDir, projectKey) {
27716
27920
  const live = [];
27717
27921
  for (const name of names) {
27718
27922
  if (!name.endsWith(OWNER_PID_EXT)) continue;
27719
- const file2 = join16(dir, name);
27923
+ const file2 = join17(dir, name);
27720
27924
  let text;
27721
27925
  try {
27722
- text = readFileSync14(file2, "utf8");
27926
+ text = readFileSync15(file2, "utf8");
27723
27927
  } catch (err) {
27724
27928
  if (errCode2(err) === "ENOENT") continue;
27725
27929
  throw err;
@@ -27765,7 +27969,7 @@ function renameAside(dbPath) {
27765
27969
  const ts = String(Date.now());
27766
27970
  for (const suffix of DB_SIBLING_SUFFIXES) {
27767
27971
  const file2 = dbPath + suffix;
27768
- if (existsSync14(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
27972
+ if (existsSync15(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
27769
27973
  }
27770
27974
  return ts;
27771
27975
  }
@@ -27788,7 +27992,7 @@ function utcStamp(now) {
27788
27992
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
27789
27993
  }
27790
27994
  function makeOrphanDir(projectDir) {
27791
- const base = join17(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
27995
+ const base = join18(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
27792
27996
  for (let n = 1; ; n += 1) {
27793
27997
  const dir = n === 1 ? base : base + "-" + String(n);
27794
27998
  try {
@@ -27805,7 +28009,7 @@ async function healOrphan(project, files, row5) {
27805
28009
  try {
27806
28010
  dir = makeOrphanDir(dirname9(project.dbPath));
27807
28011
  for (const f of files) {
27808
- const to = join17(dir, basename4(f.path));
28012
+ const to = join18(dir, basename4(f.path));
27809
28013
  renameWithRetry(f.path, to);
27810
28014
  moved.push({ path: to, bytes: f.bytes });
27811
28015
  }
@@ -27903,8 +28107,8 @@ function unsupportedHostOf(sig) {
27903
28107
 
27904
28108
  // src/core/ops/doctor-issue.ts
27905
28109
  import { spawnSync as spawnSync3 } from "node:child_process";
27906
- import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync15, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27907
- import { delimiter, join as join18 } from "node:path";
28110
+ import { closeSync as closeSync2, existsSync as existsSync16, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync16, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
28111
+ import { delimiter, dirname as dirname10, join as join19 } from "node:path";
27908
28112
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27909
28113
  function tildeOf(env) {
27910
28114
  const home = homeDirOf(env);
@@ -27927,13 +28131,28 @@ function maskLine(line) {
27927
28131
  const at2 = Math.max(line.indexOf(":"), line.indexOf("="));
27928
28132
  return at2 === -1 ? DOCTOR_MASK : line.slice(0, at2 + 1) + " " + DOCTOR_MASK;
27929
28133
  }
27930
- function environmentLine(ctx, adapter, env, version2) {
28134
+ async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
28135
+ if (host.bun === void 0) return { node: host.node };
28136
+ const node = findRuntime("javascript", env);
28137
+ if (node === null) return { node: host.node, bun: host.bun, pathNode: null };
28138
+ const childEnv = {};
28139
+ for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
28140
+ const r = await runProcess([node, "--version"], { cwd: dirname10(node), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
28141
+ const out = r.stdout.toString("utf8").trim();
28142
+ return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
28143
+ }
28144
+ function environmentLine(ctx, adapter, env, version2, rt) {
27931
28145
  const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
27932
28146
  const client = ctx.clientInfo;
27933
28147
  const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
27934
28148
  const shell = env.SHELL ?? env.ComSpec ?? "sh";
27935
- return `${DOCTOR_ENV_PREFIX}context-mode ${version2 ?? "source checkout"} (${sha}), agent ${agent}
27936
- ${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}, Node ${process.version}, shell ${shell}`;
28149
+ const what = `${DOCTOR_ENV_PREFIX}context-mode ${version2 ?? "source checkout"} (${sha}), agent ${agent}
28150
+ `;
28151
+ const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
28152
+ if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
28153
+ const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
28154
+ return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
28155
+ ${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
27937
28156
  }
27938
28157
  function gitVersion(env) {
27939
28158
  const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
@@ -27945,8 +28164,8 @@ function onPath(env, tool) {
27945
28164
  const out = [];
27946
28165
  for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
27947
28166
  if (dir === "") continue;
27948
- for (const n of names) if (existsSync15(join18(dir, n))) {
27949
- out.push(join18(dir, n));
28167
+ for (const n of names) if (existsSync16(join19(dir, n))) {
28168
+ out.push(join19(dir, n));
27950
28169
  break;
27951
28170
  }
27952
28171
  }
@@ -27954,7 +28173,7 @@ function onPath(env, tool) {
27954
28173
  }
27955
28174
  function hookLogTail(env) {
27956
28175
  const file2 = hookLogPath(env);
27957
- if (file2 === "" || !existsSync15(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
28176
+ if (file2 === "" || !existsSync16(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
27958
28177
  try {
27959
28178
  const fd = openSync2(file2, "r");
27960
28179
  try {
@@ -27974,7 +28193,7 @@ function hookLogTail(env) {
27974
28193
  }
27975
28194
  async function journalRows(ctx) {
27976
28195
  const head2 = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
27977
- if (!existsSync15(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
28196
+ if (!existsSync16(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
27978
28197
  try {
27979
28198
  const db = await openDb(ctx.project, { readOnly: true });
27980
28199
  try {
@@ -27992,21 +28211,21 @@ function agentConfig(adapter, env, worktree) {
27992
28211
  const home = homeDirOf(env);
27993
28212
  const files = configPaths(adapter, env, worktree);
27994
28213
  if (home !== null) {
27995
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join18(claudeDirOf(env, home), SETTINGS_FILE) });
27996
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join18(codexDirOf(env, home), CONFIG_TOML_FILE) });
28214
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join19(claudeDirOf(env, home), SETTINGS_FILE) });
28215
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join19(codexDirOf(env, home), CONFIG_TOML_FILE) });
27997
28216
  }
27998
28217
  const out = [];
27999
28218
  const seen = /* @__PURE__ */ new Set();
28000
28219
  for (const f of files) {
28001
28220
  if (seen.has(f.path)) continue;
28002
28221
  seen.add(f.path);
28003
- if (!existsSync15(f.path)) {
28222
+ if (!existsSync16(f.path)) {
28004
28223
  out.push(`${f.label}: ${f.path} (absent)`);
28005
28224
  continue;
28006
28225
  }
28007
28226
  let text = "";
28008
28227
  try {
28009
- text = readFileSync15(f.path, "utf8");
28228
+ text = readFileSync16(f.path, "utf8");
28010
28229
  } catch (err) {
28011
28230
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
28012
28231
  continue;
@@ -28077,9 +28296,9 @@ async function buildIssueBody(i) {
28077
28296
  async function writeIssueReport(i) {
28078
28297
  const tilde = tildeOf(i.env);
28079
28298
  const body = await buildIssueBody(i);
28080
- const dir = join18(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
28299
+ const dir = join19(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
28081
28300
  mkdirSync7(dir, { recursive: true });
28082
- const file2 = join18(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
28301
+ const file2 = join19(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
28083
28302
  writeFileSync4(file2, body);
28084
28303
  const shown2 = tilde(file2);
28085
28304
  const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
@@ -28106,7 +28325,7 @@ async function guard(id2, run) {
28106
28325
  }
28107
28326
  }
28108
28327
  async function codexDb(ctx, adapter) {
28109
- if (adapter.id !== "codex" || !existsSync16(ctx.project.dbPath)) return null;
28328
+ if (adapter.id !== "codex" || !existsSync17(ctx.project.dbPath)) return null;
28110
28329
  try {
28111
28330
  return await openDb(ctx.project, { readOnly: true });
28112
28331
  } catch {
@@ -28142,11 +28361,11 @@ async function hookRow(ctx, adapter, host) {
28142
28361
  }
28143
28362
  }
28144
28363
  function ownServerId(configDir, projectKey) {
28145
- const dir = join19(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
28146
- if (!existsSync16(dir)) return "";
28364
+ const dir = join20(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
28365
+ if (!existsSync17(dir)) return "";
28147
28366
  for (const name of readdirSync8(dir)) {
28148
28367
  if (!name.endsWith(OWNER_PID_EXT)) continue;
28149
- if (readFileSync16(join19(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
28368
+ if (readFileSync17(join20(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
28150
28369
  }
28151
28370
  return "";
28152
28371
  }
@@ -28176,7 +28395,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
28176
28395
  D9: () => checkIndex(project),
28177
28396
  D10: () => checkMode(adapter, ctx.hostPermission),
28178
28397
  // D-1331-OC-PERM-1
28179
- D11: () => checkShell(env)
28398
+ D11: () => checkRuntimes(env, checkShell(env))
28180
28399
  };
28181
28400
  const rows = [];
28182
28401
  for (const id2 of DOCTOR_CHECK_ORDER) rows.push(await guard(id2, checks[id2]));
@@ -28203,11 +28422,12 @@ function reportEnv(env) {
28203
28422
  }
28204
28423
  async function doctorReply(ctx, host) {
28205
28424
  const adapter = getAdapter(ctx.project.agent);
28425
+ const runtime = runtimeInfo(host.env, ctx.signal);
28206
28426
  const rows = await runDoctorChecks(ctx, adapter, host);
28207
28427
  const failed = rows.some((r) => r.status === "FAIL");
28208
- const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
28428
+ const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : adapter.id === "omp" ? ompCommand(rows, failed) : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
28209
28429
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
28210
- const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
28430
+ const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
28211
28431
  const table3 = buildReport(input);
28212
28432
  let notes = [];
28213
28433
  if (failed) {
@@ -28219,7 +28439,8 @@ async function doctorReply(ctx, host) {
28219
28439
  }
28220
28440
  const look = rows.find((r) => r.status === "FAIL") ?? rows.find((r) => r.status !== "PASS");
28221
28441
  const docs = look === void 0 ? [] : [DOCTOR_DOCS_LABEL + DOCTOR_DOCS_LINK(look.id)];
28222
- const whole2 = [envLine2, table3, ...docs, ...notes].join("\n");
28442
+ const info = adapter.id === "omp" ? ompInfoLines(host.env, ctx.clientInfo?.version) : [];
28443
+ const whole2 = [envLine2, table3, ...docs, ...info, ...notes].join("\n");
28223
28444
  const bytes5 = Buffer.byteLength(whole2, "utf8");
28224
28445
  if (bytes5 <= REPORT_CAP) return { text: whole2, isError: false, sandboxBytes: bytes5 };
28225
28446
  const db = await openDb(ctx.project);
@@ -28228,9 +28449,14 @@ async function doctorReply(ctx, host) {
28228
28449
  } finally {
28229
28450
  closeDb(db);
28230
28451
  }
28231
- const text = [envLine2, buildReportHead(input), ...docs, ...notes].join("\n");
28452
+ const text = [envLine2, buildReportHead(input), ...docs, ...info, ...notes].join("\n");
28232
28453
  return { text, isError: false, sandboxBytes: bytes5 };
28233
28454
  }
28455
+ function ompCommand(rows, failed) {
28456
+ if (!failed) return OMP_LIST_COMMAND;
28457
+ const d3 = rows.find((r) => r.id === "D3" && r.status === "FAIL");
28458
+ return d3?.fixCommand ?? NATIVE_INSTALL.omp[0];
28459
+ }
28234
28460
  async function handler2(_input, ctx) {
28235
28461
  return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
28236
28462
  }
@@ -28244,9 +28470,9 @@ var ctxDoctor = Object.freeze({
28244
28470
  });
28245
28471
 
28246
28472
  // src/core/tools/execute.ts
28247
- import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
28473
+ import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
28248
28474
  import { tmpdir as tmpdir3 } from "node:os";
28249
- import { dirname as dirname11, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
28475
+ import { dirname as dirname12, join as join21, parse as parse3, resolve as resolve11 } from "node:path";
28250
28476
 
28251
28477
  // src/core/sandbox/win-build.ts
28252
28478
  var SEPARATORS2 = ";&|(\n";
@@ -28329,7 +28555,7 @@ function schemaLine(issue2) {
28329
28555
  }
28330
28556
  function fileError(given, abs, root) {
28331
28557
  let dir = abs;
28332
- while (!existsSync17(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
28558
+ while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
28333
28559
  if (isInside(root, dir)) return null;
28334
28560
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
28335
28561
  }
@@ -28398,7 +28624,12 @@ async function handler3(raw, ctx) {
28398
28624
  if (bad !== null) return fail5(bad);
28399
28625
  extra.CTX_FILE = abs;
28400
28626
  }
28401
- const runtime = findRuntime(input.language);
28627
+ let runtime;
28628
+ try {
28629
+ runtime = findRuntime(input.language);
28630
+ } catch {
28631
+ runtime = null;
28632
+ }
28402
28633
  if (runtime === null) return fail5(noRuntimeError(input.language).toLine());
28403
28634
  const env = buildChildEnv(process.env, extra);
28404
28635
  const timeoutMs = input.timeoutMs ?? EXEC_TIMEOUT_MS;
@@ -28410,8 +28641,8 @@ async function handler3(raw, ctx) {
28410
28641
  if (takesDashC(input.language, runtime)) {
28411
28642
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
28412
28643
  } else {
28413
- tmpDir = mkdtempSync2(join20(tmpdir3(), TMP_PREFIX));
28414
- const file2 = join20(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
28644
+ tmpDir = mkdtempSync2(join21(tmpdir3(), TMP_PREFIX));
28645
+ const file2 = join21(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
28415
28646
  writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
28416
28647
  argv = scriptArgv(input.language, runtime, file2);
28417
28648
  }
@@ -28447,12 +28678,12 @@ var ctxExecute = {
28447
28678
  };
28448
28679
 
28449
28680
  // src/core/tools/index.ts
28450
- import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
28451
- import { dirname as dirname12, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28681
+ import { existsSync as existsSync19, readFileSync as readFileSync20, statSync as statSync8 } from "node:fs";
28682
+ import { dirname as dirname13, extname as extname3, join as join24, relative as relative5, resolve as resolve12 } from "node:path";
28452
28683
 
28453
28684
  // src/core/index/walk.ts
28454
- import { readdirSync as readdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28455
- import { join as join21 } from "node:path";
28685
+ import { readdirSync as readdirSync9, readFileSync as readFileSync18, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28686
+ import { join as join22 } from "node:path";
28456
28687
  var GITIGNORE = ".gitignore";
28457
28688
  var GIT_DIR = ".git";
28458
28689
  function walkDir(root, containmentRoot) {
@@ -28461,7 +28692,7 @@ function walkDir(root, containmentRoot) {
28461
28692
  const found = [];
28462
28693
  visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
28463
28694
  found.sort(compareFound);
28464
- return found.map((f) => ({ absPath: f.absPath, relPath: join21(...f.dir, f.name) }));
28695
+ return found.map((f) => ({ absPath: f.absPath, relPath: join22(...f.dir, f.name) }));
28465
28696
  }
28466
28697
  function visit(abs, rel, parent, contain, seen, found) {
28467
28698
  let entries;
@@ -28470,10 +28701,10 @@ function visit(abs, rel, parent, contain, seen, found) {
28470
28701
  } catch {
28471
28702
  return;
28472
28703
  }
28473
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join21(abs, GITIGNORE), rel)) : parent;
28704
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join22(abs, GITIGNORE), rel)) : parent;
28474
28705
  for (const e of entries) {
28475
28706
  if (e.name === GIT_DIR) continue;
28476
- const path8 = join21(abs, e.name);
28707
+ const path8 = join22(abs, e.name);
28477
28708
  let isDir = e.isDirectory();
28478
28709
  let isFile = e.isFile();
28479
28710
  let target = path8;
@@ -28513,7 +28744,7 @@ function compareFound(a, b) {
28513
28744
  function readRules(file2, base) {
28514
28745
  let body;
28515
28746
  try {
28516
- body = readFileSync17(file2, "utf8");
28747
+ body = readFileSync18(file2, "utf8");
28517
28748
  } catch {
28518
28749
  return [];
28519
28750
  }
@@ -28596,10 +28827,12 @@ function globSeg(pat, name) {
28596
28827
  }
28597
28828
 
28598
28829
  // src/core/sandbox/fetch.ts
28830
+ import { readFileSync as readFileSync19 } from "node:fs";
28599
28831
  import { lookup } from "node:dns/promises";
28600
28832
  import http from "node:http";
28601
28833
  import https from "node:https";
28602
28834
  import { BlockList, isIP } from "node:net";
28835
+ import { join as join23 } from "node:path";
28603
28836
  import { connect as tlsConnect } from "node:tls";
28604
28837
  var PRIVATE_RANGES = [
28605
28838
  ["127.0.0.0", 8, "ipv4"],
@@ -28631,6 +28864,21 @@ for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix,
28631
28864
  var STATUS_OK_FIRST = 200;
28632
28865
  var STATUS_OK_END = 300;
28633
28866
  var STATUS_REDIRECT = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
28867
+ var UA_HOME = "https://github.com/mksglu/context-mode";
28868
+ var UA_DEV_VERSION = "dev";
28869
+ var namedHeaders;
28870
+ function baseHeaders() {
28871
+ if (namedHeaders === void 0) {
28872
+ let version2 = UA_DEV_VERSION;
28873
+ try {
28874
+ const v = JSON.parse(readFileSync19(join23(ownBundleDir(), D1_PACKAGE_FILE), "utf8")).version;
28875
+ if (typeof v === "string" && v !== "") version2 = v;
28876
+ } catch {
28877
+ }
28878
+ namedHeaders = Object.freeze({ "user-agent": "context-mode/" + version2 + " (+" + UA_HOME + ")", accept: "*/*" });
28879
+ }
28880
+ return namedHeaders;
28881
+ }
28634
28882
  function fail6(code) {
28635
28883
  return new CtxError("FETCH_FAILED", { code });
28636
28884
  }
@@ -28739,11 +28987,11 @@ function request(u, conn, proxy, signal) {
28739
28987
  const onErr = (err) => reject(fail6(causeCode(err)));
28740
28988
  if (proxy === void 0) {
28741
28989
  const mod = u.protocol === "https:" ? https : http;
28742
- const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
28990
+ const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { ...baseHeaders(), host: u.host } });
28743
28991
  req.on("response", resolve14).on("error", onErr).end();
28744
28992
  return;
28745
28993
  }
28746
- const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
28994
+ const proxyHeaders = proxy.auth === void 0 ? { ...baseHeaders() } : { ...baseHeaders(), "proxy-authorization": proxy.auth };
28747
28995
  if (u.protocol === "http:") {
28748
28996
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
28749
28997
  req.on("response", resolve14).on("error", onErr).end();
@@ -28763,7 +29011,7 @@ function request(u, conn, proxy, signal) {
28763
29011
  port,
28764
29012
  path: path8,
28765
29013
  signal,
28766
- headers: { host: u.host },
29014
+ headers: { ...baseHeaders(), host: u.host },
28767
29015
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
28768
29016
  });
28769
29017
  req.on("response", resolve14).on("error", onErr).end();
@@ -28805,7 +29053,7 @@ async function safeFetch(url2, signal) {
28805
29053
  }
28806
29054
  if (status < STATUS_OK_FIRST || status >= STATUS_OK_END) {
28807
29055
  res.resume();
28808
- throw fail6(status);
29056
+ throw fail6(status + " from " + bare(current.hostname));
28809
29057
  }
28810
29058
  const body = await readBody(res);
28811
29059
  const shown2 = new URL(current.href);
@@ -32641,14 +32889,14 @@ function kindOfType(contentType) {
32641
32889
  }
32642
32890
  function readUtf8(absPath) {
32643
32891
  try {
32644
- return utf8.decode(readFileSync18(absPath));
32892
+ return utf8.decode(readFileSync20(absPath));
32645
32893
  } catch {
32646
32894
  return void 0;
32647
32895
  }
32648
32896
  }
32649
32897
  function missingOrOutside(given, abs, root) {
32650
32898
  let dir = abs;
32651
- while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
32899
+ while (!existsSync19(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
32652
32900
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32653
32901
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32654
32902
  }
@@ -32659,7 +32907,7 @@ function pathItems(input, project) {
32659
32907
  if (statSync8(abs).isDirectory()) {
32660
32908
  return walkDir(abs, project.containmentRoot).map((f) => ({
32661
32909
  sourceKind: "path",
32662
- label: pathLabel(join22(base, f.relPath)),
32910
+ label: pathLabel(join24(base, f.relPath)),
32663
32911
  kind: kindOfPath(f.relPath),
32664
32912
  read: () => readUtf8(f.absPath)
32665
32913
  }));
@@ -33199,8 +33447,8 @@ var ctxStats = Object.freeze({
33199
33447
  });
33200
33448
 
33201
33449
  // src/core/ops/host-write.ts
33202
- import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33203
- import { dirname as dirname13, join as join23 } from "node:path";
33450
+ import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33451
+ import { dirname as dirname14, join as join25 } from "node:path";
33204
33452
  function defaultWrite(file2, text) {
33205
33453
  writeFileSync6(file2, text, "utf8");
33206
33454
  }
@@ -33209,17 +33457,20 @@ function hostConfigPath(agent, home, env) {
33209
33457
  if (own2 !== void 0) return ownMcpFileOf(agent, own2.file, env, home);
33210
33458
  switch (agent) {
33211
33459
  case "opencode":
33212
- return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
33460
+ return join25(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
33213
33461
  // D-WIN-OPENCODE-DIR-1
33214
33462
  case "pi":
33215
- return join23(piAgentDirOf(env, home), SETTINGS_FILE);
33463
+ return join25(piAgentDirOf(env, home), SETTINGS_FILE);
33216
33464
  case "gemini":
33217
- return join23(geminiDirOf(env, home), SETTINGS_FILE);
33465
+ return join25(geminiDirOf(env, home), SETTINGS_FILE);
33218
33466
  // D-R38-GEMINI-HOME-1
33219
33467
  case "copilot-cli":
33220
33468
  return null;
33469
+ case "omp":
33470
+ return null;
33471
+ // ADR-0026 decision 8 (D-OMP-UPGRADE-1): OMP loads the plugin from its own store; no MCP entry, nothing under ~/.pi
33221
33472
  default:
33222
- return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
33473
+ return join25(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
33223
33474
  }
33224
33475
  }
33225
33476
  function cell3(value) {
@@ -33231,8 +33482,8 @@ function toRow(file2, edit) {
33231
33482
  function writeWithRollback(file2, text, write2, atomic) {
33232
33483
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
33233
33484
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
33234
- const had = existsSync19(file2);
33235
- mkdirSync8(dirname13(file2), { recursive: true });
33485
+ const had = existsSync20(file2);
33486
+ mkdirSync8(dirname14(file2), { recursive: true });
33236
33487
  if (had) copyFileSync(file2, trash);
33237
33488
  try {
33238
33489
  write2(tmp, text);
@@ -33261,7 +33512,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
33261
33512
  if (requested === null) return [];
33262
33513
  const current = readHostConfig(row5.id, requested);
33263
33514
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
33264
- const exists = existsSync19(current.path);
33515
+ const exists = existsSync20(current.path);
33265
33516
  if (exists && result.text === current.text) return [];
33266
33517
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
33267
33518
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -33269,15 +33520,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
33269
33520
  }
33270
33521
 
33271
33522
  // src/core/ops/uninstall.ts
33272
- import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
33273
- import { join as join24 } from "node:path";
33523
+ import { existsSync as existsSync21, readdirSync as readdirSync10, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
33524
+ import { join as join26 } from "node:path";
33274
33525
  function row2(area, before, after) {
33275
33526
  return { area, before, after };
33276
33527
  }
33277
33528
  function stopServers(configDir, projectKey) {
33278
33529
  const stopped = listLiveOwners(configDir, projectKey);
33279
- const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
33280
- for (const serverId of stopped) writeFileSync7(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
33530
+ const dir = join26(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
33531
+ for (const serverId of stopped) writeFileSync7(join26(dir, serverId + OWNER_STOP_EXT), "", "utf8");
33281
33532
  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 };
33282
33533
  }
33283
33534
  function rootOrNull(adapter, env) {
@@ -33295,15 +33546,15 @@ function removeCache(adapter, env, configDir) {
33295
33546
  const root = rootOrNull(adapter, env);
33296
33547
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33297
33548
  if (adapter.installMode === "marketplace") {
33298
- const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
33549
+ const cache = join26(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
33299
33550
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
33300
33551
  }
33301
33552
  rmSync6(root, { recursive: true, force: true });
33302
33553
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
33303
33554
  }
33304
33555
  case "plugin": {
33305
- const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
33306
- if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33556
+ const agentDir = join26(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
33557
+ if (!existsSync21(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33307
33558
  rmSync6(agentDir, { recursive: true, force: true });
33308
33559
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
33309
33560
  }
@@ -33348,7 +33599,7 @@ function ownEntries2(agent, env) {
33348
33599
  }
33349
33600
  if (agent === "opencode") {
33350
33601
  return [{
33351
- file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
33602
+ file: join26(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
33352
33603
  // D-WIN-OPENCODE-DIR-1
33353
33604
  key: OPENCODE_PLUGIN_KEY,
33354
33605
  shown: OPENCODE_PLUGIN_KEY,
@@ -33359,13 +33610,22 @@ function ownEntries2(agent, env) {
33359
33610
  if (agent === "pi") {
33360
33611
  const agentDir = piAgentDirOf(env, home);
33361
33612
  return [{
33362
- file: join24(agentDir, SETTINGS_FILE),
33613
+ file: join26(agentDir, SETTINGS_FILE),
33363
33614
  key: PI_PACKAGES_KEY,
33364
33615
  shown: PI_PACKAGES_KEY,
33365
33616
  has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
33366
33617
  drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
33367
33618
  }];
33368
33619
  }
33620
+ if (agent === "omp") {
33621
+ return [{
33622
+ file: ompImportFiles(home).mcp,
33623
+ key: OMP_DISABLED_SERVERS_KEY,
33624
+ shown: OMP_DISABLED_SERVERS_KEY,
33625
+ has: (v) => Array.isArray(v) && v.includes(SERVER_KEY),
33626
+ drop: (v) => v.filter((x) => x !== SERVER_KEY)
33627
+ }];
33628
+ }
33369
33629
  return [];
33370
33630
  }
33371
33631
  function removeOwnEntries(agent, env) {
@@ -33381,12 +33641,12 @@ function removeOwnEntries(agent, env) {
33381
33641
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
33382
33642
  }
33383
33643
  function removeProjectData(configDir, projectKey) {
33384
- const projects = join24(configDir, PROJECTS_DIR_NAME);
33385
- const dir = join24(projects, projectKey);
33386
- if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
33644
+ const projects = join26(configDir, PROJECTS_DIR_NAME);
33645
+ const dir = join26(projects, projectKey);
33646
+ if (!existsSync21(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
33387
33647
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
33388
33648
  for (const name of readdirSync10(dir)) {
33389
- if (name !== OWNERS_DIR_NAME) rmSync6(join24(dir, name), { recursive: true, force: true });
33649
+ if (name !== OWNERS_DIR_NAME) rmSync6(join26(dir, name), { recursive: true, force: true });
33390
33650
  }
33391
33651
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
33392
33652
  }
@@ -33394,12 +33654,12 @@ function runUninstall(input) {
33394
33654
  const configDir = resolveConfigDir(input.env);
33395
33655
  const stop = stopServers(configDir, input.project.projectKey);
33396
33656
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
33397
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
33657
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join26(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
33398
33658
  return { rows, stopped: stop.stopped };
33399
33659
  }
33400
33660
 
33401
33661
  // src/core/ops/v1-remove.ts
33402
- import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync19, rmSync as rmSync7 } from "node:fs";
33662
+ import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
33403
33663
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
33404
33664
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
33405
33665
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -33411,7 +33671,7 @@ function moveAside(target, undo) {
33411
33671
  }
33412
33672
  function keepAside(target, undo) {
33413
33673
  let aside = target + UPGRADE_ASIDE_SUFFIX;
33414
- for (let n = 2; existsSync21(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
33674
+ for (let n = 2; existsSync22(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
33415
33675
  renameWithRetry(target, aside);
33416
33676
  undo.push({ trash: aside, target, keep: true });
33417
33677
  return aside;
@@ -33450,8 +33710,8 @@ function locate(doc, path8) {
33450
33710
  return null;
33451
33711
  }
33452
33712
  function stripJsonEntries(agent, file2, findings, kept, undo) {
33453
- const layout = hostLayout(readFileSync19(file2, "utf8"));
33454
- const text = hostText(readFileSync19(file2, "utf8"));
33713
+ const layout = hostLayout(readFileSync21(file2, "utf8"));
33714
+ const text = hostText(readFileSync21(file2, "utf8"));
33455
33715
  const doc = parseHostConfig(agent, file2, text, "jsonc");
33456
33716
  const hit = /* @__PURE__ */ new Set();
33457
33717
  const byContainer = /* @__PURE__ */ new Map();
@@ -33488,20 +33748,20 @@ function removeV1(agent, findings, project) {
33488
33748
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
33489
33749
  else if (f.path === "") {
33490
33750
  if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
33491
- else if (existsSync21(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
33492
- else if (existsSync21(f.file)) {
33751
+ else if (existsSync22(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
33752
+ else if (existsSync22(f.file)) {
33493
33753
  moveAside(f.file, undo);
33494
33754
  done.set(f, UPGRADE_REMOVED);
33495
33755
  } else done.set(f, UPGRADE_NOT_FOUND);
33496
33756
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
33497
33757
  }
33498
33758
  for (const [file2, list4] of entries) {
33499
- if (!existsSync21(file2)) {
33759
+ if (!existsSync22(file2)) {
33500
33760
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
33501
33761
  continue;
33502
33762
  }
33503
33763
  if (file2.endsWith(TOML_EXT)) {
33504
- const rawToml = readFileSync19(file2, "utf8");
33764
+ const rawToml = readFileSync21(file2, "utf8");
33505
33765
  const tomlLayout = hostLayout(rawToml);
33506
33766
  let text = hostText(rawToml);
33507
33767
  for (const f of list4) {
@@ -33529,7 +33789,7 @@ function removeV1(agent, findings, project) {
33529
33789
  },
33530
33790
  rollback() {
33531
33791
  for (const u of undo.splice(0).reverse()) {
33532
- if (!existsSync21(u.trash)) continue;
33792
+ if (!existsSync22(u.trash)) continue;
33533
33793
  rmSync7(u.target, { recursive: true, force: true });
33534
33794
  renameWithRetry(u.trash, u.target);
33535
33795
  }