context-mode 2.1.10 → 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.
package/pi/index.js CHANGED
@@ -11509,6 +11509,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
11509
11509
  qwen: READ_IMAGES_AND_PDF,
11510
11510
  opencode: READ_IMAGES_AND_PDF,
11511
11511
  pi: READ_IMAGES,
11512
+ omp: READ_IMAGES,
11512
11513
  vscode: READ_IMAGES,
11513
11514
  zcode: READ_IMAGES,
11514
11515
  "copilot-cli": [],
@@ -11625,7 +11626,7 @@ var DECISION_ANSWERS_KEY = "answers";
11625
11626
  var DECISION_OPTION_KEY = "option";
11626
11627
  var DECISION_LABEL_JOIN = " | ";
11627
11628
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11628
- var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
11629
+ var BUNDLE_SHA = true ? "9cb2aaa5ebb63491960b3f3e9655a5821383eae4" : void 0;
11629
11630
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11630
11631
  var DOCTOR_LABEL = Object.freeze({
11631
11632
  D1: "version",
@@ -11781,7 +11782,9 @@ var AGENT_HOME_DIR = Object.freeze({
11781
11782
  kiro: [".kiro"],
11782
11783
  zcode: [".zcode"],
11783
11784
  pi: [".pi"],
11784
- opencode: [".config", "opencode"]
11785
+ opencode: [".config", "opencode"],
11786
+ omp: [".omp"]
11787
+ // ADR-0026: OMP data and plugins live under ~/.omp
11785
11788
  });
11786
11789
  var UPGRADE_RESTART_LINE = "restart needed";
11787
11790
  var UPGRADE_HOST_AREA = "host update";
@@ -11870,16 +11873,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
11870
11873
  binaries: [],
11871
11874
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
11872
11875
  }),
11873
- unsupported({
11874
- id: "omp",
11875
- name: "OMP (oh-my-pi)",
11876
- clientNames: ["omp-coding-agent"],
11877
- envVars: [],
11878
- pluginPaths: [],
11879
- configDirs: [".omp"],
11880
- binaries: ["omp"],
11881
- 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)"
11882
- }),
11883
11876
  unsupported({
11884
11877
  id: "openclaw",
11885
11878
  name: "OpenClaw",
@@ -11946,7 +11939,9 @@ var HOOK_HOST_FILE = Object.freeze({
11946
11939
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
11947
11940
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
11948
11941
  pi: null,
11949
- opencode: null
11942
+ opencode: null,
11943
+ omp: null
11944
+ // ADR-0026: in-process, no hook file
11950
11945
  });
11951
11946
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
11952
11947
  var HOOK_MATCHER_FIELD = "matcher";
@@ -11997,6 +11992,12 @@ var D11_POSIX_FIX = "install sh or add it to PATH";
11997
11992
  function D11_PASS_DETAIL(shell, win) {
11998
11993
  return `${win ? "Git Bash" : "sh"}: ${shell}`;
11999
11994
  }
11995
+ function D11_RUNTIME_DETAIL(lang, unreadable) {
11996
+ return `${lang} not found, unreadable on PATH: ${unreadable.join(", ")}`;
11997
+ }
11998
+ function D11_RUNTIME_FIX(lang) {
11999
+ return `install ${lang}, or turn off its app alias and PATH entry that cannot be read`;
12000
+ }
12000
12001
  var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
12001
12002
  var HEAL_TMP_SUFFIX = ".heal";
12002
12003
  var HEAL_TS_SEP = ".";
@@ -12008,6 +12009,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
12008
12009
  gemini: "gemini extensions update context-mode",
12009
12010
  qwen: "qwen extensions update context-mode",
12010
12011
  pi: "pi update --extensions",
12012
+ omp: "omp plugin upgrade context-mode",
12013
+ // ADR-0026 decision 4: OMP native update
12011
12014
  opencode: "opencode plugin update",
12012
12015
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
12013
12016
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -12051,6 +12054,14 @@ var PI_NPM_DIR = "npm";
12051
12054
  var PI_NODE_MODULES_DIR = "node_modules";
12052
12055
  var PI_PACKAGE_JSON_FILE = "package.json";
12053
12056
  var PI_LIST_COMMAND = "pi list";
12057
+ var OMP_LIST_COMMAND = "omp plugin list";
12058
+ var OMP_ENABLE_COMMAND = "omp plugin enable context-mode";
12059
+ var OMP_MIN_VERSION = "14.7.0";
12060
+ var OMP_FLOOR_INFO = (v) => `OMP ${v} is older than the tested floor ${OMP_MIN_VERSION}. Update it with: omp update`;
12061
+ var OMP_CONTENT_INFO = "OMP keeps tool output in content; context-mode writes its notes there.";
12062
+ var OMP_PRINT_MODE_INFO = "Print mode sends no prompt event. Use omp or omp --mode rpc to keep prompts.";
12063
+ var OMP_SCRIPTS_INFO = "Add < /dev/null in scripts.";
12064
+ var OMP_IMPORT_INFO = (claude, mcp) => `OMP also imports context-mode from ${claude}. To run it once, add "context-mode" to disabledServers in ${mcp}.`;
12054
12065
  var PI_CURRENT_MAJOR = 2;
12055
12066
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
12056
12067
  var V1_TMP_PREFIX = "context-mode-";
@@ -12261,6 +12272,8 @@ var NATIVE_INSTALL = Object.freeze({
12261
12272
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
12262
12273
  opencode: ["opencode plugin add context-mode"],
12263
12274
  pi: ["pi install npm:context-mode"],
12275
+ omp: ["omp plugin install context-mode"],
12276
+ // ADR-0026 decision 4: OMP native install
12264
12277
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
12265
12278
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
12266
12279
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -12290,6 +12303,9 @@ function readResult(p) {
12290
12303
  if (p.keep === true) info.keep = true;
12291
12304
  return info;
12292
12305
  }
12306
+ function decodeOmp(raw) {
12307
+ return { ...decode(raw), agent: "omp" };
12308
+ }
12293
12309
  function decode(raw) {
12294
12310
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
12295
12311
  const p = raw;
@@ -12405,7 +12421,7 @@ var CtxError = class extends Error {
12405
12421
  import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve8, sep as sep3 } from "node:path";
12406
12422
 
12407
12423
  // src/core/contracts/agents.ts
12408
- var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
12424
+ var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode", "omp"];
12409
12425
 
12410
12426
  // src/adapters/claude-code.ts
12411
12427
  var TOOL_NAME_PREFIX2 = "mcp__plugin_context-mode_context-mode__";
@@ -13369,14 +13385,36 @@ var ADAPTERS = Object.freeze([
13369
13385
  decode: decode10,
13370
13386
  encode: encode10,
13371
13387
  toCanonicalTool
13388
+ },
13389
+ {
13390
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
13391
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
13392
+ id: "omp",
13393
+ installMode: "in-process",
13394
+ projectSource: "pi:ctx.cwd",
13395
+ toolNamePrefix: TOOL_NAME_PREFIX,
13396
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
13397
+ execReadOnlyHint: false,
13398
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
13399
+ compactDelivery: "pi-flag",
13400
+ compactSummary: "none",
13401
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
13402
+ denyChannel: "deny-reason",
13403
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
13404
+ skillChannel: { kind: "package", path: "skills" },
13405
+ // D-OMP-SKILLS-1
13406
+ decode: decodeOmp,
13407
+ encode,
13408
+ checkPermission
13409
+ // D-OMP-FIRE-1: agent omp in rows
13372
13410
  }
13373
13411
  ]);
13374
13412
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
13375
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
13413
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
13376
13414
  function hasReplace(row5) {
13377
13415
  return REPLACE_ROWS.has(row5.id);
13378
13416
  }
13379
- var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi"]);
13417
+ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi", "omp"]);
13380
13418
  function dumpRunsThenReplaces(row5) {
13381
13419
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
13382
13420
  }
@@ -14870,7 +14908,8 @@ function toolSetForAgentType(ev, src) {
14870
14908
  const type = ev.agentType ?? "";
14871
14909
  const def = findDef(type, src) ?? builtIn(ev.agent, type);
14872
14910
  if (def === null) return null;
14873
- const tools = (def.tools ?? allKnownToolNames(row5)).map((n) => norm(row5, n));
14911
+ const known = allKnownToolNames(row5);
14912
+ const tools = def.tools === null ? known : def.tools.map((n) => norm(row5, n)).flatMap((n) => [n, ...known.filter((k) => grants(n, k))]);
14874
14913
  const deny2 = def.disallowed.map((n) => norm(row5, n));
14875
14914
  return unique(tools.filter((n) => !deny2.some((d) => denies(d, n))));
14876
14915
  }
@@ -15026,6 +15065,13 @@ function geminiValid(s) {
15026
15065
  }
15027
15066
  return out;
15028
15067
  }
15068
+ function grants(entry, name) {
15069
+ if (!entry.startsWith(MCP_SERVER_TOOL_PREFIX)) return false;
15070
+ const wild = MCP_NAME_JOIN + "*";
15071
+ const server = entry.slice(MCP_SERVER_TOOL_PREFIX.length, entry.endsWith(wild) ? -wild.length : entry.length);
15072
+ if (server === "" || server.indexOf("*") >= 0 || server.indexOf(MCP_NAME_JOIN) >= 0) return false;
15073
+ return name.startsWith(MCP_SERVER_TOOL_PREFIX + server + MCP_NAME_JOIN);
15074
+ }
15029
15075
  function denies(rule, name) {
15030
15076
  if (rule.endsWith("*")) return name.startsWith(rule.slice(0, -1));
15031
15077
  if (rule === name) return true;
@@ -15956,6 +16002,7 @@ function sourceOf(agent) {
15956
16002
  case "opencode":
15957
16003
  return "spawn-cwd";
15958
16004
  case "pi":
16005
+ case "omp":
15959
16006
  return "pi:ctx.cwd";
15960
16007
  }
15961
16008
  }
@@ -19615,7 +19662,7 @@ function cutPoint(src, start, end, scratch) {
19615
19662
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
19616
19663
  return { end: start + r.read, written: r.written };
19617
19664
  }
19618
- function merge2(src, blocks, join27, cap, lineCut) {
19665
+ function merge2(src, blocks, join29, cap, lineCut) {
19619
19666
  const out = [];
19620
19667
  const scratch = new Uint8Array(cap);
19621
19668
  let wide;
@@ -19625,7 +19672,7 @@ function merge2(src, blocks, join27, cap, lineCut) {
19625
19672
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
19626
19673
  };
19627
19674
  for (const b of blocks) {
19628
- if (cur !== void 0 && !join27) {
19675
+ if (cur !== void 0 && !join29) {
19629
19676
  emit(cur.start, cur.end, curBytes);
19630
19677
  cur = void 0;
19631
19678
  }
@@ -20267,7 +20314,7 @@ async function handleHook(agent, raw, env) {
20267
20314
  try {
20268
20315
  fault(env, "project");
20269
20316
  const argv = agent === "vscode" ? [WORKSPACE_FOLDER_FLAG, ev.cwd] : process.argv;
20270
- project = resolveProject(agent, { env, argv, cwd: ev.cwd, piCwd: agent === "pi" ? ev.cwd : void 0 });
20317
+ project = resolveProject(agent, { env, argv, cwd: ev.cwd, piCwd: getAdapter(agent).projectSource === "pi:ctx.cwd" ? ev.cwd : void 0 });
20271
20318
  } catch (err) {
20272
20319
  return fail7("project", err, "hooks: no project: " + String(err.code ?? "ERROR") + " " + message(err) + "\n");
20273
20320
  }
@@ -20804,22 +20851,34 @@ function fileNames(name, pathExt) {
20804
20851
  if (!isWin() || path.extname(name) !== "") return [name];
20805
20852
  return [...pathExt.map((ext) => name + ext), name];
20806
20853
  }
20807
- function isRunnable(full) {
20808
- const st = statSync3(full, { throwIfNoEntry: false });
20809
- if (st === void 0 || !st.isFile()) return false;
20854
+ function probe(full) {
20855
+ let st;
20856
+ try {
20857
+ st = statSync3(full, { throwIfNoEntry: false });
20858
+ } catch {
20859
+ return "unreadable";
20860
+ }
20861
+ if (st === void 0 || !st.isFile()) return "absent";
20810
20862
  if (isWin()) {
20811
20863
  const ext = path.extname(full).toLowerCase();
20812
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
20864
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
20813
20865
  }
20814
20866
  try {
20815
20867
  accessSync(full, fsConstants.X_OK);
20816
- return true;
20868
+ return "runnable";
20817
20869
  } catch {
20818
- return false;
20870
+ return "absent";
20819
20871
  }
20820
20872
  }
20873
+ function isRunnable(full) {
20874
+ return probe(full) === "runnable";
20875
+ }
20821
20876
  function findRuntime(lang, env = process.env) {
20822
- if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
20877
+ return lookupRuntime(lang, env).found;
20878
+ }
20879
+ function lookupRuntime(lang, env = process.env) {
20880
+ const unreadable = [];
20881
+ if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
20823
20882
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
20824
20883
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
20825
20884
  const names = candidates(lang);
@@ -20828,13 +20887,15 @@ function findRuntime(lang, env = process.env) {
20828
20887
  for (const name of names) {
20829
20888
  for (const file2 of fileNames(name, pathExt)) {
20830
20889
  const full = path.join(dir, file2);
20831
- if (!isRunnable(full)) continue;
20832
- if (!isWin() || path.extname(full) !== "") return full;
20890
+ const state = probe(full);
20891
+ if (state === "unreadable") unreadable.push(full);
20892
+ if (state !== "runnable") continue;
20893
+ if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
20833
20894
  if (shim === null) shim = full;
20834
20895
  }
20835
20896
  }
20836
20897
  }
20837
- return shim;
20898
+ return { found: shim, unreadable };
20838
20899
  }
20839
20900
  function findGitBash(env) {
20840
20901
  const git2 = findRuntime(GIT_BIN, env);
@@ -20914,7 +20975,7 @@ function runProcess(argv, o) {
20914
20975
  let stopTimer;
20915
20976
  const kill = () => {
20916
20977
  if (child.pid !== void 0) killTree(child.pid);
20917
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
20978
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
20918
20979
  };
20919
20980
  const onAbort = () => {
20920
20981
  if (killedBy !== null || settled) return;
@@ -20943,15 +21004,21 @@ function runProcess(argv, o) {
20943
21004
  ...held ? { held: true } : {}
20944
21005
  });
20945
21006
  };
20946
- const finishHeld = () => {
21007
+ const finishHeld = (force = false) => {
20947
21008
  if (settled) return;
20948
- held = exited && killedBy === null;
20949
- child.stdout.destroy();
20950
- child.stderr.destroy();
20951
- if (child.pid !== void 0) killTree(child.pid);
20952
- settle3(child.exitCode);
21009
+ const seen = chunkCount;
21010
+ setImmediate(() => {
21011
+ if (settled || !force && chunkCount !== seen) return;
21012
+ held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
21013
+ child.stdout.destroy();
21014
+ child.stderr.destroy();
21015
+ if (child.pid !== void 0) killTree(child.pid);
21016
+ settle3(child.exitCode);
21017
+ });
20953
21018
  };
21019
+ let chunkCount = 0;
20954
21020
  const bump = () => {
21021
+ chunkCount++;
20955
21022
  if (!exited || settled) return;
20956
21023
  clearTimeout(graceTimer);
20957
21024
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -20969,7 +21036,7 @@ function runProcess(argv, o) {
20969
21036
  if (settled) return;
20970
21037
  exited = true;
20971
21038
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
20972
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
21039
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
20973
21040
  });
20974
21041
  child.on("error", () => settle3(null));
20975
21042
  child.stdin.on("error", () => {
@@ -21591,8 +21658,8 @@ var ctxBatch = Object.freeze({
21591
21658
  });
21592
21659
 
21593
21660
  // src/core/tools/doctor.ts
21594
- import { readdirSync as readdirSync8, readFileSync as readFileSync16, existsSync as existsSync16 } from "node:fs";
21595
- import { basename as basename5, join as join19 } from "node:path";
21661
+ import { readdirSync as readdirSync8, readFileSync as readFileSync17, existsSync as existsSync17 } from "node:fs";
21662
+ import { basename as basename5, join as join20 } from "node:path";
21596
21663
 
21597
21664
  // src/core/ops/bundle-dir.ts
21598
21665
  import { existsSync as existsSync4 } from "node:fs";
@@ -21617,8 +21684,8 @@ function ownBundleDir() {
21617
21684
  }
21618
21685
 
21619
21686
  // src/core/ops/doctor-config.ts
21620
- import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync11 } from "node:fs";
21621
- import { dirname as dirname8, isAbsolute as isAbsolute4, join as join14, resolve as resolve9 } from "node:path";
21687
+ import { existsSync as existsSync11, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "node:fs";
21688
+ import { dirname as dirname8, isAbsolute as isAbsolute5, join as join16, resolve as resolve9 } from "node:path";
21622
21689
 
21623
21690
  // src/core/ops/detect-v1.ts
21624
21691
  import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "node:fs";
@@ -24607,6 +24674,14 @@ function configEntryRoot(adapter, env) {
24607
24674
  if (typeof script !== "string" || !isAbsolute3(script)) throw missing(adapter.id, file2);
24608
24675
  return dirname7(script);
24609
24676
  }
24677
+ function packageDirOf(dir) {
24678
+ for (let cur = dir; ; ) {
24679
+ if (existsSync7(join13(cur, D1_PACKAGE_FILE))) return cur;
24680
+ const up = dirname7(cur);
24681
+ if (up === cur) return dir;
24682
+ cur = up;
24683
+ }
24684
+ }
24610
24685
  function candidate(adapter, env, worktree) {
24611
24686
  switch (adapter.installMode) {
24612
24687
  case "marketplace":
@@ -24620,7 +24695,7 @@ function candidate(adapter, env, worktree) {
24620
24695
  case "plugin":
24621
24696
  return join13(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
24622
24697
  case "in-process":
24623
- return dirname7(fileURLToPath2(import.meta.url));
24698
+ return packageDirOf(dirname7(fileURLToPath2(import.meta.url)));
24624
24699
  }
24625
24700
  }
24626
24701
  function resolvePluginRoot(adapter, env, worktree) {
@@ -24701,14 +24776,281 @@ function piInstalledIn(env, home, pkgDir, cwd) {
24701
24776
  return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
24702
24777
  }
24703
24778
 
24779
+ // src/core/ops/doctor-env.ts
24780
+ import { existsSync as existsSync9, readFileSync as readFileSync11, realpathSync as realpathSync6 } from "node:fs";
24781
+ import { isAbsolute as isAbsolute4, join as join14, relative as relative4 } from "node:path";
24782
+ function pass(id, detail = DOCTOR_PASS_DETAIL) {
24783
+ return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
24784
+ }
24785
+ function unknown2(id, detail, fixCommand) {
24786
+ return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
24787
+ }
24788
+ function fail2(id, detail, fixCommand) {
24789
+ return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
24790
+ }
24791
+ function warn(id, detail, fixCommand) {
24792
+ return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
24793
+ }
24794
+ function bundleVersion(bundleDir2) {
24795
+ try {
24796
+ const v = JSON.parse(readFileSync11(join14(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24797
+ return typeof v === "string" && v !== "" ? v : void 0;
24798
+ } catch {
24799
+ return void 0;
24800
+ }
24801
+ }
24802
+ function channelOf(version4) {
24803
+ const at2 = version4.indexOf(D1_PRERELEASE_SEP);
24804
+ if (at2 < 0) return D1_DEFAULT_TAG;
24805
+ const pre = version4.slice(at2 + 1);
24806
+ const dot = pre.indexOf(".");
24807
+ const tag2 = dot < 0 ? pre : pre.slice(0, dot);
24808
+ return tag2 === "" ? D1_DEFAULT_TAG : tag2;
24809
+ }
24810
+ function firstLine3(b) {
24811
+ const text = b.toString("utf8").trim();
24812
+ const nl = text.indexOf("\n");
24813
+ return (nl < 0 ? text : text.slice(0, nl)).trim();
24814
+ }
24815
+ function gitCause(r, timeoutMs) {
24816
+ if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
24817
+ if (r.killed === "cancel") return D1_GIT_CANCEL;
24818
+ if (r.exitCode === null) return D1_GIT_NO_START;
24819
+ return D1_GIT_EXIT(r.exitCode, firstLine3(r.stderr));
24820
+ }
24821
+ function fetchCause(err, timeoutMs) {
24822
+ const name = err instanceof Error ? err.name : "";
24823
+ if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
24824
+ const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
24825
+ const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
24826
+ const msg = cause instanceof Error ? cause.message : String(cause);
24827
+ const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
24828
+ return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
24829
+ }
24830
+ async function npmLatest(url4, tag2, signal, timeoutMs) {
24831
+ try {
24832
+ const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
24833
+ if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
24834
+ const body = await res.json();
24835
+ const v = typeof body === "object" && body !== null ? body[tag2] : void 0;
24836
+ return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag2) };
24837
+ } catch (err) {
24838
+ return { ok: false, cause: fetchCause(err, timeoutMs) };
24839
+ }
24840
+ }
24841
+ function digits(s) {
24842
+ if (s === "") return false;
24843
+ for (const ch of s) if (ch < "0" || ch > "9") return false;
24844
+ return true;
24845
+ }
24846
+ function parseVersion(v) {
24847
+ const at2 = v.indexOf(D1_PRERELEASE_SEP);
24848
+ const core = (at2 < 0 ? v : v.slice(0, at2)).split(NODE_VERSION_SEP);
24849
+ if (core.length !== 3 || !core.every(digits)) return null;
24850
+ const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
24851
+ if (at2 < 0) return { core: nums, pre: [] };
24852
+ const pre = v.slice(at2 + 1).split(NODE_VERSION_SEP);
24853
+ if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
24854
+ if (pre.length === 1) return { core: nums, pre: [pre[0]] };
24855
+ return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
24856
+ }
24857
+ function sign(n) {
24858
+ return n < 0 ? -1 : n > 0 ? 1 : 0;
24859
+ }
24860
+ function compareVersions(a, b) {
24861
+ const x = parseVersion(a);
24862
+ const y = parseVersion(b);
24863
+ if (x === null || y === null) return null;
24864
+ for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
24865
+ if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
24866
+ if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
24867
+ return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
24868
+ }
24869
+ function highestTag(stdout, tag2) {
24870
+ let best;
24871
+ for (const line of stdout.split("\n")) {
24872
+ const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
24873
+ if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
24874
+ const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
24875
+ if (parseVersion(v) === null || channelOf(v) !== tag2) continue;
24876
+ if (best === void 0 || compareVersions(v, best) === 1) best = v;
24877
+ }
24878
+ return best;
24879
+ }
24880
+ function versionRow(head2, installed, tag2, source, latest, tail, update) {
24881
+ const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
24882
+ if (cmp === 0) return pass("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
24883
+ if (cmp > 0) return pass("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
24884
+ return warn("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, update);
24885
+ }
24886
+ async function checkVersion(i) {
24887
+ if (i.bundleSha === void 0) return unknown2("D1", D1_DEV_BUILD_DETAIL);
24888
+ const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
24889
+ if (i.version === void 0) return unknown2("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
24890
+ const tag2 = channelOf(i.version);
24891
+ const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
24892
+ const git2 = findRuntime(GIT_BIN, i.env);
24893
+ const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
24894
+ if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "", update);
24895
+ let cause = D1_GIT_MISSING;
24896
+ if (git2 !== null) {
24897
+ const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
24898
+ cwd: i.cwd,
24899
+ env: { ...i.env, ...GIT_NO_PROMPT_ENV },
24900
+ signal: i.signal,
24901
+ timeoutMs: i.timeoutMs
24902
+ });
24903
+ if (r.exitCode === 0 && r.killed === null) {
24904
+ const latest = highestTag(r.stdout.toString("utf8"), tag2);
24905
+ if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
24906
+ cause = D1_GIT_NO_TAG(tag2);
24907
+ } else {
24908
+ cause = gitCause(r, i.timeoutMs);
24909
+ }
24910
+ }
24911
+ return unknown2("D1", head2 + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
24912
+ }
24913
+ function numbers(v) {
24914
+ const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
24915
+ return bare2.split(NODE_VERSION_SEP).map(Number);
24916
+ }
24917
+ function belowMin(version4) {
24918
+ const got = numbers(version4);
24919
+ const min = numbers(NODE_MIN);
24920
+ for (let k = 0; k < min.length; k++) {
24921
+ const g = got[k] ?? 0;
24922
+ if (g !== min[k]) return g < min[k];
24923
+ }
24924
+ return false;
24925
+ }
24926
+ async function sqliteLoads() {
24927
+ try {
24928
+ await import(SQLITE_MODULE);
24929
+ return true;
24930
+ } catch {
24931
+ return false;
24932
+ }
24933
+ }
24934
+ async function checkNode(i) {
24935
+ const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
24936
+ const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
24937
+ if (belowMin(i.nodeVersion)) return fail2("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
24938
+ if (!await sqliteLoads()) return fail2("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
24939
+ return pass("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
24940
+ }
24941
+ function checkMcp(ctx, adapter) {
24942
+ const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
24943
+ const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
24944
+ if (named2 || versioned) return pass("D6");
24945
+ return adapter?.installMode === "in-process" ? pass("D6", D6_IN_PROCESS_DETAIL) : unknown2("D6", D6_UNKNOWN_DETAIL);
24946
+ }
24947
+ function piCwdInside(worktree, piCwd) {
24948
+ if (piCwd === void 0 || !existsSync9(piCwd)) return false;
24949
+ const rel = relative4(worktree, realpathSync6.native(piCwd));
24950
+ return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
24951
+ }
24952
+ function checkProject(i) {
24953
+ const bad = fail2("D7", D7_DETAIL(i.project.source), D7_FIX);
24954
+ if (i.project.source !== i.adapter.projectSource) return bad;
24955
+ if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
24956
+ return pass("D7");
24957
+ }
24958
+ function checkMode(adapter, hostPermission) {
24959
+ if (hostPermission === "missing") return fail2("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
24960
+ if (hostPermission === "wired") return pass("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
24961
+ return pass("D10", D10_DETAIL(adapter.denyChannel));
24962
+ }
24963
+ function checkShell(env) {
24964
+ const win = process.platform === "win32";
24965
+ const shell = findRuntime("shell", env);
24966
+ if (shell !== null) return pass("D11", D11_PASS_DETAIL(shell, win));
24967
+ return win ? fail2("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail2("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
24968
+ }
24969
+ function checkRuntimes(env, shellRow) {
24970
+ if (shellRow.status !== "PASS") return shellRow;
24971
+ for (const lang of EXEC_LANGUAGES) {
24972
+ if (lang === "shell") continue;
24973
+ const r = lookupRuntime(lang, env);
24974
+ if (r.found === null && r.unreadable.length > 0) return warn("D11", D11_RUNTIME_DETAIL(lang, r.unreadable), D11_RUNTIME_FIX(lang));
24975
+ }
24976
+ return shellRow;
24977
+ }
24978
+
24979
+ // src/core/ops/omp-import.ts
24980
+ import { join as join15 } from "node:path";
24981
+ var { existsSync: existsSync10, readFileSync: readFileSync12 } = process.getBuiltinModule("node:fs");
24982
+ var OMP_DISABLED_SERVERS_KEY = "disabledServers";
24983
+ var OMP_MCP_FILE = "mcp.json";
24984
+ var OMP_CONFIG_FILE = "config.yml";
24985
+ var ENABLED_PROVIDERS = "enabledProviders";
24986
+ var DISABLED_PROVIDERS = "disabledProviders";
24987
+ var CLAUDE_PROVIDER = "claude";
24988
+ var ALL_PROVIDERS = ["*", "all"];
24989
+ function ompImportFiles(home) {
24990
+ const agentDir = join15(home, ...AGENT_HOME_DIR.omp, PI_AGENT_DIR);
24991
+ return { config: join15(agentDir, OMP_CONFIG_FILE), mcp: join15(agentDir, OMP_MCP_FILE), claude: join15(home, CLAUDE_USER_CONFIG_FILE) };
24992
+ }
24993
+ function readText2(file2) {
24994
+ try {
24995
+ return existsSync10(file2) ? hostText(readFileSync12(file2, "utf8")) : void 0;
24996
+ } catch {
24997
+ return void 0;
24998
+ }
24999
+ }
25000
+ var unquote3 = (s) => {
25001
+ const t = s.trim();
25002
+ const q = t[0];
25003
+ return (q === '"' || q === "'") && t.endsWith(q) && t.length > 1 ? t.slice(1, -1) : t;
25004
+ };
25005
+ var withoutComment = (s) => {
25006
+ const at2 = s.indexOf(" #");
25007
+ return at2 === -1 ? s : s.slice(0, at2);
25008
+ };
25009
+ function yamlTopList(text, key) {
25010
+ const lines = text.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
25011
+ const head2 = `${key}:`;
25012
+ const at2 = lines.findIndex((l) => l.startsWith(head2));
25013
+ if (at2 === -1) return [];
25014
+ const rest = withoutComment(lines[at2].slice(head2.length)).trim();
25015
+ if (rest.startsWith("[")) {
25016
+ const end = rest.indexOf("]");
25017
+ return (end === -1 ? rest.slice(1) : rest.slice(1, end)).split(",").map(unquote3).filter((x) => x !== "");
25018
+ }
25019
+ if (rest !== "") return [];
25020
+ const out = [];
25021
+ for (const line of lines.slice(at2 + 1)) {
25022
+ const t = line.trim();
25023
+ if (t === "" || t.startsWith("#")) continue;
25024
+ if (line === line.trimStart() && !t.startsWith("-")) break;
25025
+ if (!t.startsWith("-")) break;
25026
+ out.push(unquote3(withoutComment(t.slice(1))));
25027
+ }
25028
+ return out;
25029
+ }
25030
+ function ompImportsUs(files, env) {
25031
+ const config4 = readText2(files.config) ?? "";
25032
+ if (yamlTopList(config4, DISABLED_PROVIDERS).includes(CLAUDE_PROVIDER)) return false;
25033
+ const enabled = yamlTopList(config4, ENABLED_PROVIDERS);
25034
+ const dirSet = env[CLAUDE_CONFIG_DIR_ENV] !== void 0 && env[CLAUDE_CONFIG_DIR_ENV] !== "";
25035
+ if (!dirSet && !enabled.some((p) => p === CLAUDE_PROVIDER || ALL_PROVIDERS.includes(p))) return false;
25036
+ const claude = readText2(files.claude);
25037
+ if (claude === void 0) return false;
25038
+ try {
25039
+ const servers = JSON.parse(claude)[MCP_SERVERS_KEY];
25040
+ return typeof servers === "object" && servers !== null && Object.hasOwn(servers, SERVER_KEY);
25041
+ } catch {
25042
+ return false;
25043
+ }
25044
+ }
25045
+
24704
25046
  // src/core/ops/doctor-config.ts
24705
25047
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
24706
25048
  var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24707
25049
  var list2 = (v) => Array.isArray(v) ? v : [];
24708
- function pass(id) {
25050
+ function pass2(id) {
24709
25051
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail: DOCTOR_PASS_DETAIL };
24710
25052
  }
24711
- function fail2(id, detail, fixCommand) {
25053
+ function fail3(id, detail, fixCommand) {
24712
25054
  return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
24713
25055
  }
24714
25056
  function readParsed(agent, file2) {
@@ -24778,11 +25120,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
24778
25120
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
24779
25121
  function mcpFile(row5, home, env) {
24780
25122
  const spec = OWN_MCP_ENTRY[row5.id];
24781
- if (row5.id === "codex") return join14(codexDirOf(env, home), CONFIG_TOML_FILE);
25123
+ if (row5.id === "codex") return join16(codexDirOf(env, home), CONFIG_TOML_FILE);
24782
25124
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
24783
- if (row5.id === "opencode") return join14(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
25125
+ if (row5.id === "opencode") return join16(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
24784
25126
  if (row5.id === "pi") {
24785
- return join14(piAgentDirOf(env, home), SETTINGS_FILE);
25127
+ return join16(piAgentDirOf(env, home), SETTINGS_FILE);
24786
25128
  }
24787
25129
  return null;
24788
25130
  }
@@ -24795,27 +25137,27 @@ function codexNativeDir(env, home) {
24795
25137
  const codexDir = codexDirOf(env, home);
24796
25138
  let enabled;
24797
25139
  try {
24798
- enabled = hostConfigValueAt(readParsed("codex", join14(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
25140
+ enabled = hostConfigValueAt(readParsed("codex", join16(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24799
25141
  } catch {
24800
25142
  return null;
24801
25143
  }
24802
25144
  if (enabled !== true) return null;
24803
- const cache = join14(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24804
- if (!existsSync9(cache)) return null;
25145
+ const cache = join16(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
25146
+ if (!existsSync11(cache)) return null;
24805
25147
  const found = [];
24806
25148
  for (const market of readdirSync6(cache)) {
24807
- const plugin = join14(cache, market, SERVER_KEY);
24808
- if (!existsSync9(plugin)) continue;
25149
+ const plugin = join16(cache, market, SERVER_KEY);
25150
+ if (!existsSync11(plugin)) continue;
24809
25151
  for (const version4 of readdirSync6(plugin).sort()) {
24810
- const dir = join14(plugin, version4, CODEX_PLUGIN_SUBDIR);
24811
- if (existsSync9(join14(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
25152
+ const dir = join16(plugin, version4, CODEX_PLUGIN_SUBDIR);
25153
+ if (existsSync11(join16(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24812
25154
  }
24813
25155
  }
24814
25156
  return found.length === 0 ? null : found[found.length - 1];
24815
25157
  }
24816
25158
  function nativeMcpWrong(dir, row5) {
24817
25159
  try {
24818
- const entry = hostConfigValueAt(readParsed(row5.id, join14(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
25160
+ const entry = hostConfigValueAt(readParsed(row5.id, join16(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24819
25161
  if (!isObject4(entry)) return true;
24820
25162
  const args = list2(entry[MCP_ARGS_FIELD]);
24821
25163
  const script = args[0];
@@ -24886,17 +25228,17 @@ function opencodePluginDirs(configDir, worktree) {
24886
25228
  return [configDir, opencodeProjectDir(worktree)];
24887
25229
  }
24888
25230
  function opencodeProjectDir(worktree) {
24889
- return join14(worktree, OPENCODE_PROJECT_DIR);
25231
+ return join16(worktree, OPENCODE_PROJECT_DIR);
24890
25232
  }
24891
25233
  function packageResolves(fromDir) {
24892
25234
  for (let d = fromDir; ; d = dirname8(d)) {
24893
- if (existsSync9(join14(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
25235
+ if (existsSync11(join16(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
24894
25236
  if (dirname8(d) === d) return false;
24895
25237
  }
24896
25238
  }
24897
25239
  function opencodeDirPlugins(dirs) {
24898
25240
  const bundle = opencodePluginFile();
24899
- const ownFile = join14(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
25241
+ const ownFile = join16(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
24900
25242
  const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
24901
25243
  const isPath = (p) => {
24902
25244
  if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -24906,7 +25248,7 @@ function opencodeDirPlugins(dirs) {
24906
25248
  };
24907
25249
  const out = [];
24908
25250
  for (const dir of dirs) {
24909
- const pdir = join14(dir, OPENCODE_PLUGINS_DIR);
25251
+ const pdir = join16(dir, OPENCODE_PLUGINS_DIR);
24910
25252
  let names;
24911
25253
  try {
24912
25254
  names = readdirSync6(pdir);
@@ -24914,12 +25256,12 @@ function opencodeDirPlugins(dirs) {
24914
25256
  continue;
24915
25257
  }
24916
25258
  for (const name of names) {
24917
- const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join14(pdir, name)] : [];
24918
- const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join14(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
25259
+ const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join16(pdir, name)] : [];
25260
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join16(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
24919
25261
  for (const f of files) {
24920
25262
  let text;
24921
25263
  try {
24922
- const b = readFileSync11(f);
25264
+ const b = readFileSync13(f);
24923
25265
  if (b.length > OPENCODE_DIR_FILE_MAX) continue;
24924
25266
  text = b.toString("utf8");
24925
25267
  } catch {
@@ -24930,7 +25272,7 @@ function opencodeDirPlugins(dirs) {
24930
25272
  const loads = lits.some((p) => {
24931
25273
  if (isModule(p)) return packageResolves(dirname8(f));
24932
25274
  const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
24933
- return existsSync9(isAbsolute4(bare2) ? bare2 : resolve9(dirname8(f), bare2));
25275
+ return existsSync11(isAbsolute5(bare2) ? bare2 : resolve9(dirname8(f), bare2));
24934
25276
  });
24935
25277
  out.push({ file: f, loads });
24936
25278
  }
@@ -24948,19 +25290,19 @@ function opencodeMcpOwn(entry) {
24948
25290
  return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
24949
25291
  }
24950
25292
  function opencodeFileValue(file2) {
24951
- if (!existsSync9(file2)) return {};
24952
- return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
25293
+ if (!existsSync11(file2)) return {};
25294
+ return parseHostConfig("opencode", file2, hostText(readFileSync13(file2, "utf8")), "jsonc");
24953
25295
  }
24954
25296
  function opencodeValueListed(value) {
24955
25297
  const bundle = opencodePluginFile();
24956
- const own4 = [bundle, join14(bundle, ...OPENCODE_PLUGIN_PATH)];
25298
+ const own4 = [bundle, join16(bundle, ...OPENCODE_PLUGIN_PATH)];
24957
25299
  if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
24958
25300
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
24959
25301
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
24960
25302
  }
24961
25303
  function opencodeListed(file2, worktree) {
24962
25304
  const dirs = [dirname8(file2), worktree];
24963
- if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join14(dir, name)))))) return true;
25305
+ if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join16(dir, name)))))) return true;
24964
25306
  return opencodeDirPlugin(opencodePluginDirs(dirname8(file2), worktree)) !== void 0;
24965
25307
  }
24966
25308
  function mcpWrong(row5, home, env, worktree) {
@@ -24982,7 +25324,7 @@ function mcpWrong(row5, home, env, worktree) {
24982
25324
  function hookFile(row5, spec, home, env, worktree) {
24983
25325
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
24984
25326
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24985
- 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);
25327
+ 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);
24986
25328
  return file2;
24987
25329
  }
24988
25330
  function hookParts(row5, home, env, worktree) {
@@ -24993,7 +25335,7 @@ function hookParts(row5, home, env, worktree) {
24993
25335
  const file2 = hookFile(row5, spec, home, env, worktree);
24994
25336
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24995
25337
  if (row5.id === "codex") {
24996
- const config4 = readParsed(row5.id, join14(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
25338
+ const config4 = readParsed(row5.id, join16(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24997
25339
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24998
25340
  }
24999
25341
  } catch {
@@ -25022,29 +25364,67 @@ function hookParts(row5, home, env, worktree) {
25022
25364
  }
25023
25365
  function checkHostConfig(row5, env, worktree) {
25024
25366
  const home = homeDirOf(env);
25025
- if (home === null) return fail2("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
25367
+ if (home === null) return fail3("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
25026
25368
  if (row5.installMode === "marketplace") {
25027
25369
  const choice = marketplaceChoice(env, worktree);
25028
- if ("installs" in choice) return fail2("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
25370
+ if ("installs" in choice) return fail3("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
25029
25371
  }
25030
25372
  if (row5.id === "pi") return checkPiInstall(env, home, worktree);
25373
+ if (row5.id === "omp") return checkOmpInstall(home);
25031
25374
  const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
25032
- if (parts.length === 0) return pass("D3");
25375
+ if (parts.length === 0) return pass2("D3");
25033
25376
  const detail = D3_DETAIL(parts);
25034
25377
  const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
25035
- return fail2("D3", detail, fix);
25378
+ return fail3("D3", detail, fix);
25036
25379
  }
25037
25380
  function checkPiInstall(env, home, worktree) {
25038
25381
  const found = piInstalledIn(env, home, ownBundleDir(), worktree);
25039
- if (found !== void 0) return { ...pass("D3"), detail: found };
25040
- return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join14(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
25382
+ if (found !== void 0) return { ...pass2("D3"), detail: found };
25383
+ return fail3("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join16(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
25384
+ }
25385
+ var OMP_PLUGINS_DIR = "plugins";
25386
+ var OMP_LOCK_FILE = "omp-plugins.lock.json";
25387
+ function readJson2(file2) {
25388
+ try {
25389
+ const doc = JSON.parse(readFileSync13(file2, "utf8"));
25390
+ return typeof doc === "object" && doc !== null ? doc : void 0;
25391
+ } catch {
25392
+ return void 0;
25393
+ }
25394
+ }
25395
+ function ownEntry(doc, key) {
25396
+ const map2 = doc?.[key];
25397
+ return typeof map2 === "object" && map2 !== null ? map2[SERVER_KEY] : void 0;
25398
+ }
25399
+ function checkOmpInstall(home) {
25400
+ const dir = join16(home, ...AGENT_HOME_DIR.omp, OMP_PLUGINS_DIR);
25401
+ const lock = join16(dir, OMP_LOCK_FILE);
25402
+ const pkg = join16(dir, PI_PACKAGE_JSON_FILE);
25403
+ const entry = ownEntry(readJson2(lock), "plugins");
25404
+ const missing2 = (file2) => fail3("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + file2, NATIVE_INSTALL.omp[0]);
25405
+ if (typeof entry !== "object" || entry === null) return missing2(lock);
25406
+ if (ownEntry(readJson2(pkg), "dependencies") === void 0) return missing2(pkg);
25407
+ if (entry.enabled !== true) return fail3("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + lock, OMP_ENABLE_COMMAND);
25408
+ return { ...pass2("D3"), detail: lock };
25409
+ }
25410
+ function ompInfoLines(env, version4) {
25411
+ const out = [];
25412
+ if (version4 !== void 0 && compareVersions(version4, OMP_MIN_VERSION) === -1) out.push(OMP_FLOOR_INFO(version4));
25413
+ out.push(OMP_CONTENT_INFO, OMP_PRINT_MODE_INFO, OMP_SCRIPTS_INFO);
25414
+ const home = homeDirOf(env);
25415
+ if (home === null) return out;
25416
+ const files = ompImportFiles(home);
25417
+ if (!ompImportsUs(files, env)) return out;
25418
+ const listed = readJson2(files.mcp)?.[OMP_DISABLED_SERVERS_KEY];
25419
+ if (!(Array.isArray(listed) && listed.includes(SERVER_KEY))) out.push(OMP_IMPORT_INFO(files.claude, files.mcp));
25420
+ return out;
25041
25421
  }
25042
25422
  function checkV1Leftovers(agent, home, scope = {}) {
25043
25423
  const findings = detectV1(agent, home, scope);
25044
- if (findings.length === 0) return pass("D4");
25424
+ if (findings.length === 0) return pass2("D4");
25045
25425
  const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
25046
- if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
25047
- return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
25426
+ if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass2("D4"), detail };
25427
+ return { ...fail3("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
25048
25428
  }
25049
25429
  function parsedOrNull(agent, file2, jsonc) {
25050
25430
  try {
@@ -25055,13 +25435,13 @@ function parsedOrNull(agent, file2, jsonc) {
25055
25435
  }
25056
25436
  }
25057
25437
  function checkDoubleFire(agent, worktree) {
25058
- if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
25059
- const claude = parsedOrNull(agent, join14(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
25438
+ if (agent !== "claude-code" && agent !== "vscode") return pass2("D5b");
25439
+ const claude = parsedOrNull(agent, join16(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
25060
25440
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
25061
25441
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
25062
- const vscode = parsedOrNull(agent, join14(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
25442
+ const vscode = parsedOrNull(agent, join16(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
25063
25443
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
25064
- return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
25444
+ return hooksOn && useClaudeHooks ? fail3("D5b", D5B_DETAIL, D5B_FIX) : pass2("D5b");
25065
25445
  }
25066
25446
  function configPaths(row5, env, worktree) {
25067
25447
  const home = homeDirOf(env);
@@ -25070,7 +25450,7 @@ function configPaths(row5, env, worktree) {
25070
25450
  const mcp = mcpFile(row5, home, env);
25071
25451
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
25072
25452
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
25073
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join14(native, CODEX_PLUGIN_MCP_FILE) });
25453
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join16(native, CODEX_PLUGIN_MCP_FILE) });
25074
25454
  const spec = HOOK_HOST_FILE[row5.id];
25075
25455
  if (spec !== null) {
25076
25456
  try {
@@ -25090,10 +25470,10 @@ function configPaths(row5, env, worktree) {
25090
25470
  }
25091
25471
 
25092
25472
  // src/core/ops/doctor-db.ts
25093
- import { existsSync as existsSync10, statSync as statSync5 } from "node:fs";
25094
- var unknown2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
25095
- var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
25096
- var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
25473
+ import { existsSync as existsSync12, statSync as statSync5 } from "node:fs";
25474
+ var unknown3 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
25475
+ var pass3 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
25476
+ var fail4 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
25097
25477
  function isCorrupt2(err) {
25098
25478
  if (typeof err !== "object" || err === null) return false;
25099
25479
  const code = err.errcode;
@@ -25132,17 +25512,17 @@ function orphanFiles(dbPath) {
25132
25512
  const files = [];
25133
25513
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
25134
25514
  const path8 = dbPath + suffix;
25135
- if (existsSync10(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
25515
+ if (existsSync12(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
25136
25516
  }
25137
- return files.length > 0 && !existsSync10(dbPath) ? files : [];
25517
+ return files.length > 0 && !existsSync12(dbPath) ? files : [];
25138
25518
  }
25139
25519
  async function checkDb(project) {
25140
25520
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
25141
25521
  const orphan = orphanFiles(project.dbPath);
25142
- if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
25143
- if (!existsSync10(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
25522
+ if (orphan.length > 0) return { row: fail4(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
25523
+ if (!existsSync12(project.dbPath)) return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
25144
25524
  const sqlite = await loadSqlite2();
25145
- if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
25525
+ if (sqlite === null) return { row: unknown3("D8", D2_SQLITE_DETAIL), ...clean };
25146
25526
  let raw = null;
25147
25527
  try {
25148
25528
  raw = openRead(sqlite, project.dbPath);
@@ -25155,226 +25535,35 @@ async function checkDb(project) {
25155
25535
  }
25156
25536
  const schemaStale = got !== null && got !== SCHEMA_VERSION;
25157
25537
  const integrityFailed = failsOnCorrupt(() => !integrityOk(db));
25158
- if (integrityFailed) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
25159
- if (schemaStale && got !== null) return { row: fail3(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
25160
- return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
25538
+ if (integrityFailed) return { row: fail4(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
25539
+ if (schemaStale && got !== null) return { row: fail4(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
25540
+ return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
25161
25541
  } catch (err) {
25162
- if (isCorrupt2(err)) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
25163
- return { row: unknown2("D8", message2(err)), ...clean };
25542
+ if (isCorrupt2(err)) return { row: fail4(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
25543
+ return { row: unknown3("D8", message2(err)), ...clean };
25164
25544
  } finally {
25165
25545
  raw?.close();
25166
25546
  }
25167
25547
  }
25168
25548
  async function checkIndex(project) {
25169
- if (!existsSync10(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
25549
+ if (!existsSync12(project.dbPath)) return pass3("D9", D9_INDEX_DETAIL(0, 0));
25170
25550
  const sqlite = await loadSqlite2();
25171
- if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
25551
+ if (sqlite === null) return unknown3("D9", D2_SQLITE_DETAIL);
25172
25552
  let raw = null;
25173
25553
  try {
25174
25554
  raw = openRead(sqlite, project.dbPath);
25175
25555
  const sources = Number(cell(raw.prepare("SELECT count(*) FROM sources").get()));
25176
25556
  const chunks = Number(cell(raw.prepare("SELECT count(*) FROM chunks").get()));
25177
- return pass2("D9", D9_INDEX_DETAIL(sources, chunks));
25557
+ return pass3("D9", D9_INDEX_DETAIL(sources, chunks));
25178
25558
  } catch (err) {
25179
- return unknown2("D9", message2(err));
25559
+ return unknown3("D9", message2(err));
25180
25560
  } finally {
25181
25561
  raw?.close();
25182
25562
  }
25183
25563
  }
25184
25564
 
25185
- // src/core/ops/doctor-env.ts
25186
- import { existsSync as existsSync11, readFileSync as readFileSync12, realpathSync as realpathSync6 } from "node:fs";
25187
- import { isAbsolute as isAbsolute5, join as join15, relative as relative4 } from "node:path";
25188
- function pass3(id, detail = DOCTOR_PASS_DETAIL) {
25189
- return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
25190
- }
25191
- function unknown3(id, detail, fixCommand) {
25192
- return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
25193
- }
25194
- function fail4(id, detail, fixCommand) {
25195
- return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
25196
- }
25197
- function warn(id, detail, fixCommand) {
25198
- return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
25199
- }
25200
- function bundleVersion(bundleDir2) {
25201
- try {
25202
- const v = JSON.parse(readFileSync12(join15(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
25203
- return typeof v === "string" && v !== "" ? v : void 0;
25204
- } catch {
25205
- return void 0;
25206
- }
25207
- }
25208
- function channelOf(version4) {
25209
- const at2 = version4.indexOf(D1_PRERELEASE_SEP);
25210
- if (at2 < 0) return D1_DEFAULT_TAG;
25211
- const pre = version4.slice(at2 + 1);
25212
- const dot = pre.indexOf(".");
25213
- const tag2 = dot < 0 ? pre : pre.slice(0, dot);
25214
- return tag2 === "" ? D1_DEFAULT_TAG : tag2;
25215
- }
25216
- function firstLine3(b) {
25217
- const text = b.toString("utf8").trim();
25218
- const nl = text.indexOf("\n");
25219
- return (nl < 0 ? text : text.slice(0, nl)).trim();
25220
- }
25221
- function gitCause(r, timeoutMs) {
25222
- if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
25223
- if (r.killed === "cancel") return D1_GIT_CANCEL;
25224
- if (r.exitCode === null) return D1_GIT_NO_START;
25225
- return D1_GIT_EXIT(r.exitCode, firstLine3(r.stderr));
25226
- }
25227
- function fetchCause(err, timeoutMs) {
25228
- const name = err instanceof Error ? err.name : "";
25229
- if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
25230
- const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
25231
- const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
25232
- const msg = cause instanceof Error ? cause.message : String(cause);
25233
- const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
25234
- return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
25235
- }
25236
- async function npmLatest(url4, tag2, signal, timeoutMs) {
25237
- try {
25238
- const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
25239
- if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
25240
- const body = await res.json();
25241
- const v = typeof body === "object" && body !== null ? body[tag2] : void 0;
25242
- return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag2) };
25243
- } catch (err) {
25244
- return { ok: false, cause: fetchCause(err, timeoutMs) };
25245
- }
25246
- }
25247
- function digits(s) {
25248
- if (s === "") return false;
25249
- for (const ch of s) if (ch < "0" || ch > "9") return false;
25250
- return true;
25251
- }
25252
- function parseVersion(v) {
25253
- const at2 = v.indexOf(D1_PRERELEASE_SEP);
25254
- const core = (at2 < 0 ? v : v.slice(0, at2)).split(NODE_VERSION_SEP);
25255
- if (core.length !== 3 || !core.every(digits)) return null;
25256
- const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
25257
- if (at2 < 0) return { core: nums, pre: [] };
25258
- const pre = v.slice(at2 + 1).split(NODE_VERSION_SEP);
25259
- if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
25260
- if (pre.length === 1) return { core: nums, pre: [pre[0]] };
25261
- return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
25262
- }
25263
- function sign(n) {
25264
- return n < 0 ? -1 : n > 0 ? 1 : 0;
25265
- }
25266
- function compareVersions(a, b) {
25267
- const x = parseVersion(a);
25268
- const y = parseVersion(b);
25269
- if (x === null || y === null) return null;
25270
- for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
25271
- if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
25272
- if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
25273
- return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
25274
- }
25275
- function highestTag(stdout, tag2) {
25276
- let best;
25277
- for (const line of stdout.split("\n")) {
25278
- const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
25279
- if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
25280
- const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
25281
- if (parseVersion(v) === null || channelOf(v) !== tag2) continue;
25282
- if (best === void 0 || compareVersions(v, best) === 1) best = v;
25283
- }
25284
- return best;
25285
- }
25286
- function versionRow(head2, installed, tag2, source, latest, tail, update) {
25287
- const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
25288
- if (cmp === 0) return pass3("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
25289
- if (cmp > 0) return pass3("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
25290
- return warn("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, update);
25291
- }
25292
- async function checkVersion(i) {
25293
- if (i.bundleSha === void 0) return unknown3("D1", D1_DEV_BUILD_DETAIL);
25294
- const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
25295
- if (i.version === void 0) return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
25296
- const tag2 = channelOf(i.version);
25297
- const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
25298
- const git2 = findRuntime(GIT_BIN, i.env);
25299
- const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
25300
- if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "", update);
25301
- let cause = D1_GIT_MISSING;
25302
- if (git2 !== null) {
25303
- const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
25304
- cwd: i.cwd,
25305
- env: { ...i.env, ...GIT_NO_PROMPT_ENV },
25306
- signal: i.signal,
25307
- timeoutMs: i.timeoutMs
25308
- });
25309
- if (r.exitCode === 0 && r.killed === null) {
25310
- const latest = highestTag(r.stdout.toString("utf8"), tag2);
25311
- if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
25312
- cause = D1_GIT_NO_TAG(tag2);
25313
- } else {
25314
- cause = gitCause(r, i.timeoutMs);
25315
- }
25316
- }
25317
- return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
25318
- }
25319
- function numbers(v) {
25320
- const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
25321
- return bare2.split(NODE_VERSION_SEP).map(Number);
25322
- }
25323
- function belowMin(version4) {
25324
- const got = numbers(version4);
25325
- const min = numbers(NODE_MIN);
25326
- for (let k = 0; k < min.length; k++) {
25327
- const g = got[k] ?? 0;
25328
- if (g !== min[k]) return g < min[k];
25329
- }
25330
- return false;
25331
- }
25332
- async function sqliteLoads() {
25333
- try {
25334
- await import(SQLITE_MODULE);
25335
- return true;
25336
- } catch {
25337
- return false;
25338
- }
25339
- }
25340
- async function checkNode(i) {
25341
- const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
25342
- const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
25343
- if (belowMin(i.nodeVersion)) return fail4("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
25344
- if (!await sqliteLoads()) return fail4("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
25345
- return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
25346
- }
25347
- function checkMcp(ctx, adapter) {
25348
- const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
25349
- const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
25350
- if (named2 || versioned) return pass3("D6");
25351
- return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown3("D6", D6_UNKNOWN_DETAIL);
25352
- }
25353
- function piCwdInside(worktree, piCwd) {
25354
- if (piCwd === void 0 || !existsSync11(piCwd)) return false;
25355
- const rel = relative4(worktree, realpathSync6.native(piCwd));
25356
- return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
25357
- }
25358
- function checkProject(i) {
25359
- const bad = fail4("D7", D7_DETAIL(i.project.source), D7_FIX);
25360
- if (i.project.source !== i.adapter.projectSource) return bad;
25361
- if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
25362
- return pass3("D7");
25363
- }
25364
- function checkMode(adapter, hostPermission) {
25365
- if (hostPermission === "missing") return fail4("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
25366
- if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
25367
- return pass3("D10", D10_DETAIL(adapter.denyChannel));
25368
- }
25369
- function checkShell(env) {
25370
- const win = process.platform === "win32";
25371
- const shell = findRuntime("shell", env);
25372
- if (shell !== null) return pass3("D11", D11_PASS_DETAIL(shell, win));
25373
- return win ? fail4("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail4("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
25374
- }
25375
-
25376
25565
  // src/core/ops/doctor-hook.ts
25377
- import { existsSync as existsSync13, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync13, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
25566
+ import { existsSync as existsSync14, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync14, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
25378
25567
  import { tmpdir as tmpdir2 } from "node:os";
25379
25568
  import path7 from "node:path";
25380
25569
 
@@ -27118,7 +27307,9 @@ var HOST_SHAPES = {
27118
27307
  kiro: kiro_default,
27119
27308
  zcode: zcode_default,
27120
27309
  pi: pi_default,
27121
- opencode: opencode_default
27310
+ opencode: opencode_default,
27311
+ omp: pi_default
27312
+ // ADR-0026: OMP reads the Pi extension reply
27122
27313
  };
27123
27314
  var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
27124
27315
  var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
@@ -27200,7 +27391,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
27200
27391
 
27201
27392
  // src/setup/codex-trust.ts
27202
27393
  import { createHash } from "node:crypto";
27203
- import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
27394
+ import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
27204
27395
  import path6 from "node:path";
27205
27396
  import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
27206
27397
 
@@ -27423,10 +27614,10 @@ function isObject6(v) {
27423
27614
  }
27424
27615
  function loadFixture(bundleDir2, agent) {
27425
27616
  const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
27426
- if (!existsSync13(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27617
+ if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27427
27618
  let all;
27428
27619
  try {
27429
- all = JSON.parse(hostText(readFileSync13(file2, "utf8")));
27620
+ all = JSON.parse(hostText(readFileSync14(file2, "utf8")));
27430
27621
  } catch (err) {
27431
27622
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
27432
27623
  }
@@ -27448,7 +27639,8 @@ var CWD_KEY = {
27448
27639
  kiro: "cwd",
27449
27640
  zcode: "cwd",
27450
27641
  pi: "cwd",
27451
- opencode: "directory"
27642
+ opencode: "directory",
27643
+ omp: "cwd"
27452
27644
  };
27453
27645
  function payloadFor(agent, payload, worktree) {
27454
27646
  return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
@@ -27640,7 +27832,7 @@ async function codexStopDetail(i, timeoutMs) {
27640
27832
  timeoutMs,
27641
27833
  stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
27642
27834
  });
27643
- const logged = existsSync13(path7.join(home, HOOK_ERROR_LOG_FILE));
27835
+ const logged = existsSync14(path7.join(home, HOOK_ERROR_LOG_FILE));
27644
27836
  return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
27645
27837
  } finally {
27646
27838
  rmSync2(home, { recursive: true, force: true });
@@ -27651,7 +27843,7 @@ async function checkHookRoundTrip(i) {
27651
27843
  const trust = await codexPluginTrust(i);
27652
27844
  if (trust !== null) return trust;
27653
27845
  }
27654
- if (i.agent === "codex" && existsSync13(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
27846
+ if (i.agent === "codex" && existsSync14(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
27655
27847
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
27656
27848
  }
27657
27849
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -27700,17 +27892,17 @@ async function checkHookRoundTrip(i) {
27700
27892
  }
27701
27893
 
27702
27894
  // src/core/ops/db-heal.ts
27703
- import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27704
- import { basename as basename4, dirname as dirname9, join as join17 } from "node:path";
27895
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27896
+ import { basename as basename4, dirname as dirname9, join as join18 } from "node:path";
27705
27897
 
27706
27898
  // src/core/store/owners.ts
27707
- import { mkdirSync as mkdirSync5, readdirSync as readdirSync7, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27708
- import { basename as basename3, join as join16 } from "node:path";
27899
+ import { mkdirSync as mkdirSync5, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27900
+ import { basename as basename3, join as join17 } from "node:path";
27709
27901
  function ownersDir(configDir, projectKey) {
27710
- return join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27902
+ return join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27711
27903
  }
27712
27904
  function ownerFile(configDir, projectKey, serverId) {
27713
- return join16(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
27905
+ return join17(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
27714
27906
  }
27715
27907
  function errCode2(err) {
27716
27908
  return err.code;
@@ -27745,10 +27937,10 @@ function listLiveOwners(configDir, projectKey) {
27745
27937
  const live = [];
27746
27938
  for (const name of names) {
27747
27939
  if (!name.endsWith(OWNER_PID_EXT)) continue;
27748
- const file2 = join16(dir, name);
27940
+ const file2 = join17(dir, name);
27749
27941
  let text;
27750
27942
  try {
27751
- text = readFileSync14(file2, "utf8");
27943
+ text = readFileSync15(file2, "utf8");
27752
27944
  } catch (err) {
27753
27945
  if (errCode2(err) === "ENOENT") continue;
27754
27946
  throw err;
@@ -27794,7 +27986,7 @@ function renameAside(dbPath) {
27794
27986
  const ts = String(Date.now());
27795
27987
  for (const suffix of DB_SIBLING_SUFFIXES) {
27796
27988
  const file2 = dbPath + suffix;
27797
- if (existsSync14(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
27989
+ if (existsSync15(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
27798
27990
  }
27799
27991
  return ts;
27800
27992
  }
@@ -27817,7 +28009,7 @@ function utcStamp(now) {
27817
28009
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
27818
28010
  }
27819
28011
  function makeOrphanDir(projectDir) {
27820
- const base = join17(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
28012
+ const base = join18(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
27821
28013
  for (let n = 1; ; n += 1) {
27822
28014
  const dir = n === 1 ? base : base + "-" + String(n);
27823
28015
  try {
@@ -27834,7 +28026,7 @@ async function healOrphan(project, files, row5) {
27834
28026
  try {
27835
28027
  dir = makeOrphanDir(dirname9(project.dbPath));
27836
28028
  for (const f of files) {
27837
- const to = join17(dir, basename4(f.path));
28029
+ const to = join18(dir, basename4(f.path));
27838
28030
  renameWithRetry(f.path, to);
27839
28031
  moved.push({ path: to, bytes: f.bytes });
27840
28032
  }
@@ -27932,8 +28124,8 @@ function unsupportedHostOf(sig) {
27932
28124
 
27933
28125
  // src/core/ops/doctor-issue.ts
27934
28126
  import { spawnSync as spawnSync3 } from "node:child_process";
27935
- 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";
27936
- import { delimiter, dirname as dirname10, join as join18 } from "node:path";
28127
+ 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";
28128
+ import { delimiter, dirname as dirname10, join as join19 } from "node:path";
27937
28129
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27938
28130
  function tildeOf(env) {
27939
28131
  const home = homeDirOf(env);
@@ -27989,8 +28181,8 @@ function onPath(env, tool) {
27989
28181
  const out = [];
27990
28182
  for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
27991
28183
  if (dir === "") continue;
27992
- for (const n of names) if (existsSync15(join18(dir, n))) {
27993
- out.push(join18(dir, n));
28184
+ for (const n of names) if (existsSync16(join19(dir, n))) {
28185
+ out.push(join19(dir, n));
27994
28186
  break;
27995
28187
  }
27996
28188
  }
@@ -27998,7 +28190,7 @@ function onPath(env, tool) {
27998
28190
  }
27999
28191
  function hookLogTail(env) {
28000
28192
  const file2 = hookLogPath(env);
28001
- if (file2 === "" || !existsSync15(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
28193
+ if (file2 === "" || !existsSync16(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
28002
28194
  try {
28003
28195
  const fd = openSync2(file2, "r");
28004
28196
  try {
@@ -28018,7 +28210,7 @@ function hookLogTail(env) {
28018
28210
  }
28019
28211
  async function journalRows(ctx) {
28020
28212
  const head2 = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
28021
- if (!existsSync15(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
28213
+ if (!existsSync16(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
28022
28214
  try {
28023
28215
  const db = await openDb(ctx.project, { readOnly: true });
28024
28216
  try {
@@ -28036,21 +28228,21 @@ function agentConfig(adapter, env, worktree) {
28036
28228
  const home = homeDirOf(env);
28037
28229
  const files = configPaths(adapter, env, worktree);
28038
28230
  if (home !== null) {
28039
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join18(claudeDirOf(env, home), SETTINGS_FILE) });
28040
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join18(codexDirOf(env, home), CONFIG_TOML_FILE) });
28231
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join19(claudeDirOf(env, home), SETTINGS_FILE) });
28232
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join19(codexDirOf(env, home), CONFIG_TOML_FILE) });
28041
28233
  }
28042
28234
  const out = [];
28043
28235
  const seen = /* @__PURE__ */ new Set();
28044
28236
  for (const f of files) {
28045
28237
  if (seen.has(f.path)) continue;
28046
28238
  seen.add(f.path);
28047
- if (!existsSync15(f.path)) {
28239
+ if (!existsSync16(f.path)) {
28048
28240
  out.push(`${f.label}: ${f.path} (absent)`);
28049
28241
  continue;
28050
28242
  }
28051
28243
  let text = "";
28052
28244
  try {
28053
- text = readFileSync15(f.path, "utf8");
28245
+ text = readFileSync16(f.path, "utf8");
28054
28246
  } catch (err) {
28055
28247
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
28056
28248
  continue;
@@ -28121,9 +28313,9 @@ async function buildIssueBody(i) {
28121
28313
  async function writeIssueReport(i) {
28122
28314
  const tilde = tildeOf(i.env);
28123
28315
  const body = await buildIssueBody(i);
28124
- const dir = join18(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
28316
+ const dir = join19(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
28125
28317
  mkdirSync7(dir, { recursive: true });
28126
- const file2 = join18(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
28318
+ const file2 = join19(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
28127
28319
  writeFileSync4(file2, body);
28128
28320
  const shown2 = tilde(file2);
28129
28321
  const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
@@ -28150,7 +28342,7 @@ async function guard(id, run) {
28150
28342
  }
28151
28343
  }
28152
28344
  async function codexDb(ctx, adapter) {
28153
- if (adapter.id !== "codex" || !existsSync16(ctx.project.dbPath)) return null;
28345
+ if (adapter.id !== "codex" || !existsSync17(ctx.project.dbPath)) return null;
28154
28346
  try {
28155
28347
  return await openDb(ctx.project, { readOnly: true });
28156
28348
  } catch {
@@ -28186,11 +28378,11 @@ async function hookRow(ctx, adapter, host) {
28186
28378
  }
28187
28379
  }
28188
28380
  function ownServerId(configDir, projectKey) {
28189
- const dir = join19(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
28190
- if (!existsSync16(dir)) return "";
28381
+ const dir = join20(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
28382
+ if (!existsSync17(dir)) return "";
28191
28383
  for (const name of readdirSync8(dir)) {
28192
28384
  if (!name.endsWith(OWNER_PID_EXT)) continue;
28193
- if (readFileSync16(join19(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
28385
+ if (readFileSync17(join20(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
28194
28386
  }
28195
28387
  return "";
28196
28388
  }
@@ -28220,7 +28412,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
28220
28412
  D9: () => checkIndex(project),
28221
28413
  D10: () => checkMode(adapter, ctx.hostPermission),
28222
28414
  // D-1331-OC-PERM-1
28223
- D11: () => checkShell(env)
28415
+ D11: () => checkRuntimes(env, checkShell(env))
28224
28416
  };
28225
28417
  const rows = [];
28226
28418
  for (const id of DOCTOR_CHECK_ORDER) rows.push(await guard(id, checks[id]));
@@ -28250,7 +28442,7 @@ async function doctorReply(ctx, host) {
28250
28442
  const runtime = runtimeInfo(host.env, ctx.signal);
28251
28443
  const rows = await runDoctorChecks(ctx, adapter, host);
28252
28444
  const failed = rows.some((r) => r.status === "FAIL");
28253
- const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
28445
+ 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}`;
28254
28446
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
28255
28447
  const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
28256
28448
  const table3 = buildReport(input);
@@ -28264,7 +28456,8 @@ async function doctorReply(ctx, host) {
28264
28456
  }
28265
28457
  const look = rows.find((r) => r.status === "FAIL") ?? rows.find((r) => r.status !== "PASS");
28266
28458
  const docs = look === void 0 ? [] : [DOCTOR_DOCS_LABEL + DOCTOR_DOCS_LINK(look.id)];
28267
- const whole2 = [envLine2, table3, ...docs, ...notes].join("\n");
28459
+ const info = adapter.id === "omp" ? ompInfoLines(host.env, ctx.clientInfo?.version) : [];
28460
+ const whole2 = [envLine2, table3, ...docs, ...info, ...notes].join("\n");
28268
28461
  const bytes5 = Buffer.byteLength(whole2, "utf8");
28269
28462
  if (bytes5 <= REPORT_CAP) return { text: whole2, isError: false, sandboxBytes: bytes5 };
28270
28463
  const db = await openDb(ctx.project);
@@ -28273,9 +28466,14 @@ async function doctorReply(ctx, host) {
28273
28466
  } finally {
28274
28467
  closeDb(db);
28275
28468
  }
28276
- const text = [envLine2, buildReportHead(input), ...docs, ...notes].join("\n");
28469
+ const text = [envLine2, buildReportHead(input), ...docs, ...info, ...notes].join("\n");
28277
28470
  return { text, isError: false, sandboxBytes: bytes5 };
28278
28471
  }
28472
+ function ompCommand(rows, failed) {
28473
+ if (!failed) return OMP_LIST_COMMAND;
28474
+ const d3 = rows.find((r) => r.id === "D3" && r.status === "FAIL");
28475
+ return d3?.fixCommand ?? NATIVE_INSTALL.omp[0];
28476
+ }
28279
28477
  async function handler2(_input, ctx) {
28280
28478
  return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
28281
28479
  }
@@ -28289,9 +28487,9 @@ var ctxDoctor = Object.freeze({
28289
28487
  });
28290
28488
 
28291
28489
  // src/core/tools/execute.ts
28292
- import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
28490
+ import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
28293
28491
  import { tmpdir as tmpdir3 } from "node:os";
28294
- import { dirname as dirname12, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
28492
+ import { dirname as dirname12, join as join21, parse as parse3, resolve as resolve11 } from "node:path";
28295
28493
 
28296
28494
  // src/core/sandbox/win-build.ts
28297
28495
  var SEPARATORS2 = ";&|(\n";
@@ -28374,7 +28572,7 @@ function schemaLine(issue4) {
28374
28572
  }
28375
28573
  function fileError(given, abs, root) {
28376
28574
  let dir = abs;
28377
- while (!existsSync17(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
28575
+ while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
28378
28576
  if (isInside(root, dir)) return null;
28379
28577
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
28380
28578
  }
@@ -28443,7 +28641,12 @@ async function handler3(raw, ctx) {
28443
28641
  if (bad !== null) return fail5(bad);
28444
28642
  extra.CTX_FILE = abs;
28445
28643
  }
28446
- const runtime = findRuntime(input.language);
28644
+ let runtime;
28645
+ try {
28646
+ runtime = findRuntime(input.language);
28647
+ } catch {
28648
+ runtime = null;
28649
+ }
28447
28650
  if (runtime === null) return fail5(noRuntimeError(input.language).toLine());
28448
28651
  const env = buildChildEnv(process.env, extra);
28449
28652
  const timeoutMs = input.timeoutMs ?? EXEC_TIMEOUT_MS;
@@ -28455,8 +28658,8 @@ async function handler3(raw, ctx) {
28455
28658
  if (takesDashC(input.language, runtime)) {
28456
28659
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
28457
28660
  } else {
28458
- tmpDir = mkdtempSync2(join20(tmpdir3(), TMP_PREFIX));
28459
- const file2 = join20(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
28661
+ tmpDir = mkdtempSync2(join21(tmpdir3(), TMP_PREFIX));
28662
+ const file2 = join21(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
28460
28663
  writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
28461
28664
  argv = scriptArgv(input.language, runtime, file2);
28462
28665
  }
@@ -28492,12 +28695,12 @@ var ctxExecute = {
28492
28695
  };
28493
28696
 
28494
28697
  // src/core/tools/index.ts
28495
- import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
28496
- import { dirname as dirname13, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28698
+ import { existsSync as existsSync19, readFileSync as readFileSync20, statSync as statSync8 } from "node:fs";
28699
+ import { dirname as dirname13, extname as extname3, join as join24, relative as relative5, resolve as resolve12 } from "node:path";
28497
28700
 
28498
28701
  // src/core/index/walk.ts
28499
- import { readdirSync as readdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28500
- import { join as join21 } from "node:path";
28702
+ import { readdirSync as readdirSync9, readFileSync as readFileSync18, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28703
+ import { join as join22 } from "node:path";
28501
28704
  var GITIGNORE = ".gitignore";
28502
28705
  var GIT_DIR = ".git";
28503
28706
  function walkDir(root, containmentRoot) {
@@ -28506,7 +28709,7 @@ function walkDir(root, containmentRoot) {
28506
28709
  const found = [];
28507
28710
  visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
28508
28711
  found.sort(compareFound);
28509
- return found.map((f) => ({ absPath: f.absPath, relPath: join21(...f.dir, f.name) }));
28712
+ return found.map((f) => ({ absPath: f.absPath, relPath: join22(...f.dir, f.name) }));
28510
28713
  }
28511
28714
  function visit(abs, rel, parent, contain, seen, found) {
28512
28715
  let entries;
@@ -28515,10 +28718,10 @@ function visit(abs, rel, parent, contain, seen, found) {
28515
28718
  } catch {
28516
28719
  return;
28517
28720
  }
28518
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join21(abs, GITIGNORE), rel)) : parent;
28721
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join22(abs, GITIGNORE), rel)) : parent;
28519
28722
  for (const e of entries) {
28520
28723
  if (e.name === GIT_DIR) continue;
28521
- const path8 = join21(abs, e.name);
28724
+ const path8 = join22(abs, e.name);
28522
28725
  let isDir = e.isDirectory();
28523
28726
  let isFile = e.isFile();
28524
28727
  let target = path8;
@@ -28558,7 +28761,7 @@ function compareFound(a, b) {
28558
28761
  function readRules(file2, base) {
28559
28762
  let body;
28560
28763
  try {
28561
- body = readFileSync17(file2, "utf8");
28764
+ body = readFileSync18(file2, "utf8");
28562
28765
  } catch {
28563
28766
  return [];
28564
28767
  }
@@ -28641,10 +28844,12 @@ function globSeg(pat, name) {
28641
28844
  }
28642
28845
 
28643
28846
  // src/core/sandbox/fetch.ts
28847
+ import { readFileSync as readFileSync19 } from "node:fs";
28644
28848
  import { lookup } from "node:dns/promises";
28645
28849
  import http from "node:http";
28646
28850
  import https from "node:https";
28647
28851
  import { BlockList, isIP } from "node:net";
28852
+ import { join as join23 } from "node:path";
28648
28853
  import { connect as tlsConnect } from "node:tls";
28649
28854
  var PRIVATE_RANGES = [
28650
28855
  ["127.0.0.0", 8, "ipv4"],
@@ -28676,6 +28881,21 @@ for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix,
28676
28881
  var STATUS_OK_FIRST = 200;
28677
28882
  var STATUS_OK_END = 300;
28678
28883
  var STATUS_REDIRECT = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
28884
+ var UA_HOME = "https://github.com/mksglu/context-mode";
28885
+ var UA_DEV_VERSION = "dev";
28886
+ var namedHeaders;
28887
+ function baseHeaders() {
28888
+ if (namedHeaders === void 0) {
28889
+ let version4 = UA_DEV_VERSION;
28890
+ try {
28891
+ const v = JSON.parse(readFileSync19(join23(ownBundleDir(), D1_PACKAGE_FILE), "utf8")).version;
28892
+ if (typeof v === "string" && v !== "") version4 = v;
28893
+ } catch {
28894
+ }
28895
+ namedHeaders = Object.freeze({ "user-agent": "context-mode/" + version4 + " (+" + UA_HOME + ")", accept: "*/*" });
28896
+ }
28897
+ return namedHeaders;
28898
+ }
28679
28899
  function fail6(code) {
28680
28900
  return new CtxError("FETCH_FAILED", { code });
28681
28901
  }
@@ -28784,11 +29004,11 @@ function request(u, conn, proxy, signal) {
28784
29004
  const onErr = (err) => reject(fail6(causeCode(err)));
28785
29005
  if (proxy === void 0) {
28786
29006
  const mod = u.protocol === "https:" ? https : http;
28787
- const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
29007
+ const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { ...baseHeaders(), host: u.host } });
28788
29008
  req.on("response", resolve13).on("error", onErr).end();
28789
29009
  return;
28790
29010
  }
28791
- const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
29011
+ const proxyHeaders = proxy.auth === void 0 ? { ...baseHeaders() } : { ...baseHeaders(), "proxy-authorization": proxy.auth };
28792
29012
  if (u.protocol === "http:") {
28793
29013
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
28794
29014
  req.on("response", resolve13).on("error", onErr).end();
@@ -28808,7 +29028,7 @@ function request(u, conn, proxy, signal) {
28808
29028
  port,
28809
29029
  path: path8,
28810
29030
  signal,
28811
- headers: { host: u.host },
29031
+ headers: { ...baseHeaders(), host: u.host },
28812
29032
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
28813
29033
  });
28814
29034
  req.on("response", resolve13).on("error", onErr).end();
@@ -28850,7 +29070,7 @@ async function safeFetch(url4, signal) {
28850
29070
  }
28851
29071
  if (status < STATUS_OK_FIRST || status >= STATUS_OK_END) {
28852
29072
  res.resume();
28853
- throw fail6(status);
29073
+ throw fail6(status + " from " + bare(current.hostname));
28854
29074
  }
28855
29075
  const body = await readBody(res);
28856
29076
  const shown2 = new URL(current.href);
@@ -32686,14 +32906,14 @@ function kindOfType(contentType) {
32686
32906
  }
32687
32907
  function readUtf8(absPath) {
32688
32908
  try {
32689
- return utf8.decode(readFileSync18(absPath));
32909
+ return utf8.decode(readFileSync20(absPath));
32690
32910
  } catch {
32691
32911
  return void 0;
32692
32912
  }
32693
32913
  }
32694
32914
  function missingOrOutside(given, abs, root) {
32695
32915
  let dir = abs;
32696
- while (!existsSync18(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
32916
+ while (!existsSync19(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
32697
32917
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32698
32918
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32699
32919
  }
@@ -32704,7 +32924,7 @@ function pathItems(input, project) {
32704
32924
  if (statSync8(abs).isDirectory()) {
32705
32925
  return walkDir(abs, project.containmentRoot).map((f) => ({
32706
32926
  sourceKind: "path",
32707
- label: pathLabel(join22(base, f.relPath)),
32927
+ label: pathLabel(join24(base, f.relPath)),
32708
32928
  kind: kindOfPath(f.relPath),
32709
32929
  read: () => readUtf8(f.absPath)
32710
32930
  }));
@@ -33244,8 +33464,8 @@ var ctxStats = Object.freeze({
33244
33464
  });
33245
33465
 
33246
33466
  // src/core/ops/host-write.ts
33247
- import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33248
- import { dirname as dirname14, join as join23 } from "node:path";
33467
+ import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33468
+ import { dirname as dirname14, join as join25 } from "node:path";
33249
33469
  function defaultWrite(file2, text) {
33250
33470
  writeFileSync6(file2, text, "utf8");
33251
33471
  }
@@ -33254,17 +33474,20 @@ function hostConfigPath(agent, home, env) {
33254
33474
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
33255
33475
  switch (agent) {
33256
33476
  case "opencode":
33257
- return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
33477
+ return join25(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
33258
33478
  // D-WIN-OPENCODE-DIR-1
33259
33479
  case "pi":
33260
- return join23(piAgentDirOf(env, home), SETTINGS_FILE);
33480
+ return join25(piAgentDirOf(env, home), SETTINGS_FILE);
33261
33481
  case "gemini":
33262
- return join23(geminiDirOf(env, home), SETTINGS_FILE);
33482
+ return join25(geminiDirOf(env, home), SETTINGS_FILE);
33263
33483
  // D-R38-GEMINI-HOME-1
33264
33484
  case "copilot-cli":
33265
33485
  return null;
33486
+ case "omp":
33487
+ return null;
33488
+ // ADR-0026 decision 8 (D-OMP-UPGRADE-1): OMP loads the plugin from its own store; no MCP entry, nothing under ~/.pi
33266
33489
  default:
33267
- return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
33490
+ return join25(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
33268
33491
  }
33269
33492
  }
33270
33493
  function cell3(value) {
@@ -33276,7 +33499,7 @@ function toRow(file2, edit) {
33276
33499
  function writeWithRollback(file2, text, write2, atomic) {
33277
33500
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
33278
33501
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
33279
- const had = existsSync19(file2);
33502
+ const had = existsSync20(file2);
33280
33503
  mkdirSync8(dirname14(file2), { recursive: true });
33281
33504
  if (had) copyFileSync(file2, trash);
33282
33505
  try {
@@ -33306,7 +33529,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
33306
33529
  if (requested === null) return [];
33307
33530
  const current = readHostConfig(row5.id, requested);
33308
33531
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
33309
- const exists = existsSync19(current.path);
33532
+ const exists = existsSync20(current.path);
33310
33533
  if (exists && result.text === current.text) return [];
33311
33534
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
33312
33535
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -33314,15 +33537,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
33314
33537
  }
33315
33538
 
33316
33539
  // src/core/ops/uninstall.ts
33317
- import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
33318
- import { join as join24 } from "node:path";
33540
+ import { existsSync as existsSync21, readdirSync as readdirSync10, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
33541
+ import { join as join26 } from "node:path";
33319
33542
  function row2(area, before, after) {
33320
33543
  return { area, before, after };
33321
33544
  }
33322
33545
  function stopServers(configDir, projectKey) {
33323
33546
  const stopped = listLiveOwners(configDir, projectKey);
33324
- const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
33325
- for (const serverId of stopped) writeFileSync7(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
33547
+ const dir = join26(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
33548
+ for (const serverId of stopped) writeFileSync7(join26(dir, serverId + OWNER_STOP_EXT), "", "utf8");
33326
33549
  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 };
33327
33550
  }
33328
33551
  function rootOrNull(adapter, env) {
@@ -33340,15 +33563,15 @@ function removeCache(adapter, env, configDir) {
33340
33563
  const root = rootOrNull(adapter, env);
33341
33564
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33342
33565
  if (adapter.installMode === "marketplace") {
33343
- const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
33566
+ const cache = join26(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
33344
33567
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
33345
33568
  }
33346
33569
  rmSync6(root, { recursive: true, force: true });
33347
33570
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
33348
33571
  }
33349
33572
  case "plugin": {
33350
- const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
33351
- if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33573
+ const agentDir = join26(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
33574
+ if (!existsSync21(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33352
33575
  rmSync6(agentDir, { recursive: true, force: true });
33353
33576
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
33354
33577
  }
@@ -33393,7 +33616,7 @@ function ownEntries2(agent, env) {
33393
33616
  }
33394
33617
  if (agent === "opencode") {
33395
33618
  return [{
33396
- file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
33619
+ file: join26(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
33397
33620
  // D-WIN-OPENCODE-DIR-1
33398
33621
  key: OPENCODE_PLUGIN_KEY,
33399
33622
  shown: OPENCODE_PLUGIN_KEY,
@@ -33404,13 +33627,22 @@ function ownEntries2(agent, env) {
33404
33627
  if (agent === "pi") {
33405
33628
  const agentDir = piAgentDirOf(env, home);
33406
33629
  return [{
33407
- file: join24(agentDir, SETTINGS_FILE),
33630
+ file: join26(agentDir, SETTINGS_FILE),
33408
33631
  key: PI_PACKAGES_KEY,
33409
33632
  shown: PI_PACKAGES_KEY,
33410
33633
  has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
33411
33634
  drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
33412
33635
  }];
33413
33636
  }
33637
+ if (agent === "omp") {
33638
+ return [{
33639
+ file: ompImportFiles(home).mcp,
33640
+ key: OMP_DISABLED_SERVERS_KEY,
33641
+ shown: OMP_DISABLED_SERVERS_KEY,
33642
+ has: (v) => Array.isArray(v) && v.includes(SERVER_KEY),
33643
+ drop: (v) => v.filter((x) => x !== SERVER_KEY)
33644
+ }];
33645
+ }
33414
33646
  return [];
33415
33647
  }
33416
33648
  function removeOwnEntries(agent, env) {
@@ -33426,12 +33658,12 @@ function removeOwnEntries(agent, env) {
33426
33658
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
33427
33659
  }
33428
33660
  function removeProjectData(configDir, projectKey) {
33429
- const projects = join24(configDir, PROJECTS_DIR_NAME);
33430
- const dir = join24(projects, projectKey);
33431
- if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
33661
+ const projects = join26(configDir, PROJECTS_DIR_NAME);
33662
+ const dir = join26(projects, projectKey);
33663
+ if (!existsSync21(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
33432
33664
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
33433
33665
  for (const name of readdirSync10(dir)) {
33434
- if (name !== OWNERS_DIR_NAME) rmSync6(join24(dir, name), { recursive: true, force: true });
33666
+ if (name !== OWNERS_DIR_NAME) rmSync6(join26(dir, name), { recursive: true, force: true });
33435
33667
  }
33436
33668
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
33437
33669
  }
@@ -33439,12 +33671,12 @@ function runUninstall(input) {
33439
33671
  const configDir = resolveConfigDir(input.env);
33440
33672
  const stop = stopServers(configDir, input.project.projectKey);
33441
33673
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
33442
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
33674
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join26(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
33443
33675
  return { rows, stopped: stop.stopped };
33444
33676
  }
33445
33677
 
33446
33678
  // src/core/ops/v1-remove.ts
33447
- import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync19, rmSync as rmSync7 } from "node:fs";
33679
+ import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
33448
33680
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
33449
33681
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
33450
33682
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -33456,7 +33688,7 @@ function moveAside(target, undo) {
33456
33688
  }
33457
33689
  function keepAside(target, undo) {
33458
33690
  let aside = target + UPGRADE_ASIDE_SUFFIX;
33459
- for (let n = 2; existsSync21(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
33691
+ for (let n = 2; existsSync22(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
33460
33692
  renameWithRetry(target, aside);
33461
33693
  undo.push({ trash: aside, target, keep: true });
33462
33694
  return aside;
@@ -33495,8 +33727,8 @@ function locate(doc, path8) {
33495
33727
  return null;
33496
33728
  }
33497
33729
  function stripJsonEntries(agent, file2, findings, kept, undo) {
33498
- const layout = hostLayout(readFileSync19(file2, "utf8"));
33499
- const text = hostText(readFileSync19(file2, "utf8"));
33730
+ const layout = hostLayout(readFileSync21(file2, "utf8"));
33731
+ const text = hostText(readFileSync21(file2, "utf8"));
33500
33732
  const doc = parseHostConfig(agent, file2, text, "jsonc");
33501
33733
  const hit = /* @__PURE__ */ new Set();
33502
33734
  const byContainer = /* @__PURE__ */ new Map();
@@ -33533,20 +33765,20 @@ function removeV1(agent, findings, project) {
33533
33765
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
33534
33766
  else if (f.path === "") {
33535
33767
  if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
33536
- else if (existsSync21(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
33537
- else if (existsSync21(f.file)) {
33768
+ else if (existsSync22(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
33769
+ else if (existsSync22(f.file)) {
33538
33770
  moveAside(f.file, undo);
33539
33771
  done.set(f, UPGRADE_REMOVED);
33540
33772
  } else done.set(f, UPGRADE_NOT_FOUND);
33541
33773
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
33542
33774
  }
33543
33775
  for (const [file2, list4] of entries) {
33544
- if (!existsSync21(file2)) {
33776
+ if (!existsSync22(file2)) {
33545
33777
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
33546
33778
  continue;
33547
33779
  }
33548
33780
  if (file2.endsWith(TOML_EXT)) {
33549
- const rawToml = readFileSync19(file2, "utf8");
33781
+ const rawToml = readFileSync21(file2, "utf8");
33550
33782
  const tomlLayout = hostLayout(rawToml);
33551
33783
  let text = hostText(rawToml);
33552
33784
  for (const f of list4) {
@@ -33574,7 +33806,7 @@ function removeV1(agent, findings, project) {
33574
33806
  },
33575
33807
  rollback() {
33576
33808
  for (const u of undo.splice(0).reverse()) {
33577
- if (!existsSync21(u.trash)) continue;
33809
+ if (!existsSync22(u.trash)) continue;
33578
33810
  rmSync7(u.target, { recursive: true, force: true });
33579
33811
  renameWithRetry(u.trash, u.target);
33580
33812
  }
@@ -33705,8 +33937,8 @@ function checkCall(tool, input) {
33705
33937
 
33706
33938
  // src/entries/server.ts
33707
33939
  import { randomUUID } from "node:crypto";
33708
- import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33709
- import { dirname as dirname15, join as join26 } from "node:path";
33940
+ import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33941
+ import { dirname as dirname15, join as join28 } from "node:path";
33710
33942
  import { fileURLToPath as fileURLToPath3 } from "node:url";
33711
33943
 
33712
33944
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -51677,8 +51909,8 @@ function liftWireOnlyMaterial(message3, kind) {
51677
51909
  };
51678
51910
  }
51679
51911
  function codecResultValidator(codec, method) {
51680
- const probe = codec.validateResult(method, void 0);
51681
- if (!probe.ok && probe.reason === "not-in-era") return void 0;
51912
+ const probe2 = codec.validateResult(method, void 0);
51913
+ if (!probe2.ok && probe2.reason === "not-in-era") return void 0;
51682
51914
  return { "~standard": {
51683
51915
  version: 1,
51684
51916
  vendor: "mcp-wire-codec",
@@ -61771,8 +62003,8 @@ function installExitGuard(opts) {
61771
62003
  }
61772
62004
 
61773
62005
  // src/core/store/cleanup.ts
61774
- import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as rmSync8 } from "node:fs";
61775
- import { join as join25 } from "node:path";
62006
+ import { existsSync as existsSync23, readdirSync as readdirSync11, rmSync as rmSync8 } from "node:fs";
62007
+ import { join as join27 } from "node:path";
61776
62008
  function deleteSource(raw, id) {
61777
62009
  raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
61778
62010
  deleteChunkRows(raw, { sourceId: id });
@@ -61807,7 +62039,7 @@ function userVersion(raw) {
61807
62039
  return raw.prepare("PRAGMA user_version").get().user_version;
61808
62040
  }
61809
62041
  function openForSweep(dbPath, projectKey) {
61810
- if (!existsSync22(dbPath) && (existsSync22(dbPath + DB_WAL_SUFFIX) || existsSync22(dbPath + DB_SHM_SUFFIX))) {
62042
+ if (!existsSync23(dbPath) && (existsSync23(dbPath + DB_WAL_SUFFIX) || existsSync23(dbPath + DB_SHM_SUFFIX))) {
61811
62043
  throw new CtxError("DB_GONE");
61812
62044
  }
61813
62045
  const sqlite = process.getBuiltinModule("node:sqlite");
@@ -61828,8 +62060,8 @@ function lastAccess(raw) {
61828
62060
  return row5.t;
61829
62061
  }
61830
62062
  function sweepOne(configDir, projectKey, cutoff) {
61831
- const dir = join25(configDir, PROJECTS_DIR_NAME, projectKey);
61832
- const db = openForSweep(join25(dir, DB_FILE_NAME), projectKey);
62063
+ const dir = join27(configDir, PROJECTS_DIR_NAME, projectKey);
62064
+ const db = openForSweep(join27(dir, DB_FILE_NAME), projectKey);
61833
62065
  let dead;
61834
62066
  try {
61835
62067
  dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
@@ -61842,7 +62074,7 @@ function sweepOne(configDir, projectKey, cutoff) {
61842
62074
  function sweepDeadProjects(configDir) {
61843
62075
  let entries;
61844
62076
  try {
61845
- entries = readdirSync11(join25(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
62077
+ entries = readdirSync11(join27(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
61846
62078
  } catch (err) {
61847
62079
  if (err.code === "ENOENT") return [];
61848
62080
  throw err;
@@ -62007,15 +62239,15 @@ async function startServer(argv, env) {
62007
62239
  opening.catch(() => pending.delete(project.dbPath));
62008
62240
  }
62009
62241
  const db = await opening;
62010
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
62242
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
62011
62243
  return db;
62012
62244
  }
62013
62245
  function stopMarker(configDir, projectKey) {
62014
- return join26(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
62246
+ return join28(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
62015
62247
  }
62016
62248
  function stopRequested() {
62017
62249
  const configDir = resolveConfigDir(process.env);
62018
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
62250
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
62019
62251
  }
62020
62252
  async function journal(project, ctx, name, reply4) {
62021
62253
  const db = await ownDb(project);
@@ -62135,6 +62367,11 @@ if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url)))
62135
62367
  function str3(v) {
62136
62368
  return typeof v === "string" ? v : "";
62137
62369
  }
62370
+ function appendPayload(base, payload) {
62371
+ if (Array.isArray(base)) return [...base, payload];
62372
+ const text = str3(base);
62373
+ return text === "" ? payload : text + "\n\n" + payload;
62374
+ }
62138
62375
  function textOf2(content) {
62139
62376
  if (typeof content === "string") return content;
62140
62377
  if (!Array.isArray(content)) return "";
@@ -62143,15 +62380,18 @@ function textOf2(content) {
62143
62380
  function field(v, key) {
62144
62381
  return typeof v === "object" && v !== null && !Array.isArray(v) ? v[key] : void 0;
62145
62382
  }
62146
- function excludedTools(pi) {
62147
- let settings;
62383
+ function listOf2(settings) {
62384
+ const list4 = field(field(settings, "contextMode"), "excludeTools");
62385
+ return Array.isArray(list4) ? list4.filter((n) => typeof n === "string") : void 0;
62386
+ }
62387
+ function excludedTools(pi, host = "pi") {
62148
62388
  try {
62149
- settings = pi.getSettings?.();
62389
+ if (host === "pi") return listOf2(pi.getSettings?.()) ?? [];
62390
+ const settings = pi.pi?.settings;
62391
+ return listOf2(settings?.getProjectSettings?.()) ?? listOf2(settings?.getGlobalSettings?.()) ?? [];
62150
62392
  } catch {
62151
62393
  return [];
62152
62394
  }
62153
- const list4 = field(field(settings, "contextMode"), "excludeTools");
62154
- return Array.isArray(list4) ? list4.filter((n) => typeof n === "string") : [];
62155
62395
  }
62156
62396
  function errorReply2(err) {
62157
62397
  return { text: err instanceof CtxError ? err.toLine() : INTERNAL_ERROR_LINE, isError: true, sandboxBytes: 0 };
@@ -62161,6 +62401,10 @@ function toPi(reply4) {
62161
62401
  return { content: [{ type: "text", text: reply4.text }], details: {} };
62162
62402
  }
62163
62403
  function piExtension(pi) {
62404
+ hostExtension(pi, "pi");
62405
+ }
62406
+ function hostExtension(pi, host = "pi") {
62407
+ const agent = host;
62164
62408
  const env = process.env;
62165
62409
  let sessionId = "";
62166
62410
  let cwd = "";
@@ -62170,15 +62414,16 @@ function piExtension(pi) {
62170
62414
  let payload = "";
62171
62415
  const journal = ownJournal();
62172
62416
  let toolsRegistered = false;
62417
+ let openPrompt;
62173
62418
  function identify(ctx) {
62174
62419
  if (sessionId === "") sessionId = str3(ctx?.sessionManager?.getSessionId());
62175
62420
  if (cwd === "") cwd = str3(ctx?.cwd);
62176
62421
  }
62177
62422
  function hook(raw, atTurn) {
62178
- return handleHook("pi", { ...raw, sessionId, cwd, turn: atTurn }, env);
62423
+ return handleHook(agent, { ...raw, sessionId, cwd, turn: atTurn }, env);
62179
62424
  }
62180
62425
  function projectOf() {
62181
- project ??= resolveProject("pi", { env, argv: process.argv, cwd, piCwd: cwd });
62426
+ project ??= resolveProject(agent, { env, argv: process.argv, cwd, piCwd: cwd });
62182
62427
  return project;
62183
62428
  }
62184
62429
  async function runTool(tool, params, signal) {
@@ -62211,6 +62456,7 @@ function piExtension(pi) {
62211
62456
  label: tool.name,
62212
62457
  description: tool.description,
62213
62458
  parameters: external_exports.toJSONSchema(tool.schema),
62459
+ loadMode: "essential",
62214
62460
  execute: async (_toolCallId, params, signal) => toPi(await runTool(tool, params, signal))
62215
62461
  };
62216
62462
  }
@@ -62224,10 +62470,13 @@ function piExtension(pi) {
62224
62470
  }
62225
62471
  pi.on("before_agent_start", async (event, ctx) => {
62226
62472
  identify(ctx);
62227
- turn += 1;
62473
+ const prompt = typeof event.prompt === "string" ? event.prompt : void 0;
62474
+ const rerun = prompt !== void 0 && prompt === openPrompt;
62475
+ openPrompt = prompt;
62476
+ if (!rerun) turn += 1;
62228
62477
  registerTools();
62229
- const base = str3(event.systemPrompt);
62230
- const withPayload = () => ({ systemPrompt: base === "" ? payload : base + "\n\n" + payload });
62478
+ const withPayload = () => ({ systemPrompt: appendPayload(event.systemPrompt, payload) });
62479
+ if (rerun && payload !== "") return withPayload();
62231
62480
  let out;
62232
62481
  try {
62233
62482
  out = await hook({ type: compactPending ? "session_compact" : "session_start" }, turn);
@@ -62245,6 +62494,7 @@ function piExtension(pi) {
62245
62494
  });
62246
62495
  pi.on("input", async (event, ctx) => {
62247
62496
  identify(ctx);
62497
+ openPrompt = void 0;
62248
62498
  await hook({ type: "input", message: str3(event.text) }, turn + 1);
62249
62499
  return void 0;
62250
62500
  });
@@ -62262,7 +62512,7 @@ function piExtension(pi) {
62262
62512
  input: event.input,
62263
62513
  content: textOf2(event.content),
62264
62514
  isError: event.isError === true,
62265
- keep: excludedTools(pi).includes(str3(event.toolName))
62515
+ keep: excludedTools(pi, host).includes(str3(event.toolName))
62266
62516
  }, turn);
62267
62517
  if (out.stdout === "") return void 0;
62268
62518
  const patch = { content: [{ type: "text", text: out.stdout }] };
@@ -62271,11 +62521,19 @@ function piExtension(pi) {
62271
62521
  });
62272
62522
  pi.on("session_compact", () => {
62273
62523
  compactPending = true;
62524
+ openPrompt = void 0;
62525
+ return void 0;
62526
+ });
62527
+ pi.on("agent_end", () => {
62528
+ openPrompt = void 0;
62274
62529
  return void 0;
62275
62530
  });
62531
+ if (host === "omp") registerTools();
62276
62532
  }
62277
62533
  export {
62278
- piExtension as default
62534
+ piExtension as default,
62535
+ excludedTools,
62536
+ hostExtension
62279
62537
  };
62280
62538
  /*! Bundled license information:
62281
62539