context-mode 2.1.9 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 ? "9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde" : 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";
@@ -11971,9 +11966,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
11971
11966
  var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
11972
11967
  var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
11973
11968
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
11974
- function D5_SLOW_DETAIL(ms) {
11975
- return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
11969
+ var D5_BARE_SHARE = 0.5;
11970
+ function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
11971
+ return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
11972
+ }
11973
+ function D5_SLOW_START_DETAIL(ms, bare2, bound) {
11974
+ return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
11976
11975
  }
11976
+ var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
11977
11977
  var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
11978
11978
  var D5_FIX = "run ctx_upgrade";
11979
11979
  var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
@@ -11992,6 +11992,12 @@ var D11_POSIX_FIX = "install sh or add it to PATH";
11992
11992
  function D11_PASS_DETAIL(shell, win) {
11993
11993
  return `${win ? "Git Bash" : "sh"}: ${shell}`;
11994
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
+ }
11995
12001
  var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
11996
12002
  var HEAL_TMP_SUFFIX = ".heal";
11997
12003
  var HEAL_TS_SEP = ".";
@@ -12003,6 +12009,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
12003
12009
  gemini: "gemini extensions update context-mode",
12004
12010
  qwen: "qwen extensions update context-mode",
12005
12011
  pi: "pi update --extensions",
12012
+ omp: "omp plugin upgrade context-mode",
12013
+ // ADR-0026 decision 4: OMP native update
12006
12014
  opencode: "opencode plugin update",
12007
12015
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
12008
12016
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -12046,6 +12054,14 @@ var PI_NPM_DIR = "npm";
12046
12054
  var PI_NODE_MODULES_DIR = "node_modules";
12047
12055
  var PI_PACKAGE_JSON_FILE = "package.json";
12048
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}.`;
12049
12065
  var PI_CURRENT_MAJOR = 2;
12050
12066
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
12051
12067
  var V1_TMP_PREFIX = "context-mode-";
@@ -12256,6 +12272,8 @@ var NATIVE_INSTALL = Object.freeze({
12256
12272
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
12257
12273
  opencode: ["opencode plugin add context-mode"],
12258
12274
  pi: ["pi install npm:context-mode"],
12275
+ omp: ["omp plugin install context-mode"],
12276
+ // ADR-0026 decision 4: OMP native install
12259
12277
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
12260
12278
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
12261
12279
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -12285,6 +12303,9 @@ function readResult(p) {
12285
12303
  if (p.keep === true) info.keep = true;
12286
12304
  return info;
12287
12305
  }
12306
+ function decodeOmp(raw) {
12307
+ return { ...decode(raw), agent: "omp" };
12308
+ }
12288
12309
  function decode(raw) {
12289
12310
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
12290
12311
  const p = raw;
@@ -12400,7 +12421,7 @@ var CtxError = class extends Error {
12400
12421
  import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve8, sep as sep3 } from "node:path";
12401
12422
 
12402
12423
  // src/core/contracts/agents.ts
12403
- 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"];
12404
12425
 
12405
12426
  // src/adapters/claude-code.ts
12406
12427
  var TOOL_NAME_PREFIX2 = "mcp__plugin_context-mode_context-mode__";
@@ -13364,14 +13385,36 @@ var ADAPTERS = Object.freeze([
13364
13385
  decode: decode10,
13365
13386
  encode: encode10,
13366
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
13367
13410
  }
13368
13411
  ]);
13369
13412
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
13370
- 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"]);
13371
13414
  function hasReplace(row5) {
13372
13415
  return REPLACE_ROWS.has(row5.id);
13373
13416
  }
13374
- 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"]);
13375
13418
  function dumpRunsThenReplaces(row5) {
13376
13419
  return DUMP_REPLACE_ROWS.has(row5.id) && hasReplace(row5);
13377
13420
  }
@@ -14865,7 +14908,8 @@ function toolSetForAgentType(ev, src) {
14865
14908
  const type = ev.agentType ?? "";
14866
14909
  const def = findDef(type, src) ?? builtIn(ev.agent, type);
14867
14910
  if (def === null) return null;
14868
- 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))]);
14869
14913
  const deny2 = def.disallowed.map((n) => norm(row5, n));
14870
14914
  return unique(tools.filter((n) => !deny2.some((d) => denies(d, n))));
14871
14915
  }
@@ -15021,6 +15065,13 @@ function geminiValid(s) {
15021
15065
  }
15022
15066
  return out;
15023
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
+ }
15024
15075
  function denies(rule, name) {
15025
15076
  if (rule.endsWith("*")) return name.startsWith(rule.slice(0, -1));
15026
15077
  if (rule === name) return true;
@@ -15951,6 +16002,7 @@ function sourceOf(agent) {
15951
16002
  case "opencode":
15952
16003
  return "spawn-cwd";
15953
16004
  case "pi":
16005
+ case "omp":
15954
16006
  return "pi:ctx.cwd";
15955
16007
  }
15956
16008
  }
@@ -19610,7 +19662,7 @@ function cutPoint(src, start, end, scratch) {
19610
19662
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
19611
19663
  return { end: start + r.read, written: r.written };
19612
19664
  }
19613
- function merge2(src, blocks, join27, cap, lineCut) {
19665
+ function merge2(src, blocks, join29, cap, lineCut) {
19614
19666
  const out = [];
19615
19667
  const scratch = new Uint8Array(cap);
19616
19668
  let wide;
@@ -19620,7 +19672,7 @@ function merge2(src, blocks, join27, cap, lineCut) {
19620
19672
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
19621
19673
  };
19622
19674
  for (const b of blocks) {
19623
- if (cur !== void 0 && !join27) {
19675
+ if (cur !== void 0 && !join29) {
19624
19676
  emit(cur.start, cur.end, curBytes);
19625
19677
  cur = void 0;
19626
19678
  }
@@ -20262,7 +20314,7 @@ async function handleHook(agent, raw, env) {
20262
20314
  try {
20263
20315
  fault(env, "project");
20264
20316
  const argv = agent === "vscode" ? [WORKSPACE_FOLDER_FLAG, ev.cwd] : process.argv;
20265
- 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 });
20266
20318
  } catch (err) {
20267
20319
  return fail7("project", err, "hooks: no project: " + String(err.code ?? "ERROR") + " " + message(err) + "\n");
20268
20320
  }
@@ -20799,22 +20851,34 @@ function fileNames(name, pathExt) {
20799
20851
  if (!isWin() || path.extname(name) !== "") return [name];
20800
20852
  return [...pathExt.map((ext) => name + ext), name];
20801
20853
  }
20802
- function isRunnable(full) {
20803
- const st = statSync3(full, { throwIfNoEntry: false });
20804
- 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";
20805
20862
  if (isWin()) {
20806
20863
  const ext = path.extname(full).toLowerCase();
20807
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
20864
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
20808
20865
  }
20809
20866
  try {
20810
20867
  accessSync(full, fsConstants.X_OK);
20811
- return true;
20868
+ return "runnable";
20812
20869
  } catch {
20813
- return false;
20870
+ return "absent";
20814
20871
  }
20815
20872
  }
20873
+ function isRunnable(full) {
20874
+ return probe(full) === "runnable";
20875
+ }
20816
20876
  function findRuntime(lang, env = process.env) {
20817
- 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 };
20818
20882
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
20819
20883
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
20820
20884
  const names = candidates(lang);
@@ -20823,13 +20887,15 @@ function findRuntime(lang, env = process.env) {
20823
20887
  for (const name of names) {
20824
20888
  for (const file2 of fileNames(name, pathExt)) {
20825
20889
  const full = path.join(dir, file2);
20826
- if (!isRunnable(full)) continue;
20827
- 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 };
20828
20894
  if (shim === null) shim = full;
20829
20895
  }
20830
20896
  }
20831
20897
  }
20832
- return shim;
20898
+ return { found: shim, unreadable };
20833
20899
  }
20834
20900
  function findGitBash(env) {
20835
20901
  const git2 = findRuntime(GIT_BIN, env);
@@ -20909,7 +20975,7 @@ function runProcess(argv, o) {
20909
20975
  let stopTimer;
20910
20976
  const kill = () => {
20911
20977
  if (child.pid !== void 0) killTree(child.pid);
20912
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
20978
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
20913
20979
  };
20914
20980
  const onAbort = () => {
20915
20981
  if (killedBy !== null || settled) return;
@@ -20938,15 +21004,21 @@ function runProcess(argv, o) {
20938
21004
  ...held ? { held: true } : {}
20939
21005
  });
20940
21006
  };
20941
- const finishHeld = () => {
21007
+ const finishHeld = (force = false) => {
20942
21008
  if (settled) return;
20943
- held = exited && killedBy === null;
20944
- child.stdout.destroy();
20945
- child.stderr.destroy();
20946
- if (child.pid !== void 0) killTree(child.pid);
20947
- 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
+ });
20948
21018
  };
21019
+ let chunkCount = 0;
20949
21020
  const bump = () => {
21021
+ chunkCount++;
20950
21022
  if (!exited || settled) return;
20951
21023
  clearTimeout(graceTimer);
20952
21024
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -20964,7 +21036,7 @@ function runProcess(argv, o) {
20964
21036
  if (settled) return;
20965
21037
  exited = true;
20966
21038
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
20967
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
21039
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
20968
21040
  });
20969
21041
  child.on("error", () => settle3(null));
20970
21042
  child.stdin.on("error", () => {
@@ -21586,8 +21658,8 @@ var ctxBatch = Object.freeze({
21586
21658
  });
21587
21659
 
21588
21660
  // src/core/tools/doctor.ts
21589
- import { readdirSync as readdirSync8, readFileSync as readFileSync16, existsSync as existsSync16 } from "node:fs";
21590
- 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";
21591
21663
 
21592
21664
  // src/core/ops/bundle-dir.ts
21593
21665
  import { existsSync as existsSync4 } from "node:fs";
@@ -21612,8 +21684,8 @@ function ownBundleDir() {
21612
21684
  }
21613
21685
 
21614
21686
  // src/core/ops/doctor-config.ts
21615
- import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync11 } from "node:fs";
21616
- 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";
21617
21689
 
21618
21690
  // src/core/ops/detect-v1.ts
21619
21691
  import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "node:fs";
@@ -24602,6 +24674,14 @@ function configEntryRoot(adapter, env) {
24602
24674
  if (typeof script !== "string" || !isAbsolute3(script)) throw missing(adapter.id, file2);
24603
24675
  return dirname7(script);
24604
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
+ }
24605
24685
  function candidate(adapter, env, worktree) {
24606
24686
  switch (adapter.installMode) {
24607
24687
  case "marketplace":
@@ -24615,7 +24695,7 @@ function candidate(adapter, env, worktree) {
24615
24695
  case "plugin":
24616
24696
  return join13(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
24617
24697
  case "in-process":
24618
- return dirname7(fileURLToPath2(import.meta.url));
24698
+ return packageDirOf(dirname7(fileURLToPath2(import.meta.url)));
24619
24699
  }
24620
24700
  }
24621
24701
  function resolvePluginRoot(adapter, env, worktree) {
@@ -24696,14 +24776,281 @@ function piInstalledIn(env, home, pkgDir, cwd) {
24696
24776
  return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
24697
24777
  }
24698
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
+
24699
25046
  // src/core/ops/doctor-config.ts
24700
25047
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
24701
25048
  var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24702
25049
  var list2 = (v) => Array.isArray(v) ? v : [];
24703
- function pass(id) {
25050
+ function pass2(id) {
24704
25051
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail: DOCTOR_PASS_DETAIL };
24705
25052
  }
24706
- function fail2(id, detail, fixCommand) {
25053
+ function fail3(id, detail, fixCommand) {
24707
25054
  return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
24708
25055
  }
24709
25056
  function readParsed(agent, file2) {
@@ -24773,11 +25120,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
24773
25120
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
24774
25121
  function mcpFile(row5, home, env) {
24775
25122
  const spec = OWN_MCP_ENTRY[row5.id];
24776
- 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);
24777
25124
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
24778
- 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);
24779
25126
  if (row5.id === "pi") {
24780
- return join14(piAgentDirOf(env, home), SETTINGS_FILE);
25127
+ return join16(piAgentDirOf(env, home), SETTINGS_FILE);
24781
25128
  }
24782
25129
  return null;
24783
25130
  }
@@ -24790,27 +25137,27 @@ function codexNativeDir(env, home) {
24790
25137
  const codexDir = codexDirOf(env, home);
24791
25138
  let enabled;
24792
25139
  try {
24793
- 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"]);
24794
25141
  } catch {
24795
25142
  return null;
24796
25143
  }
24797
25144
  if (enabled !== true) return null;
24798
- const cache = join14(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24799
- if (!existsSync9(cache)) return null;
25145
+ const cache = join16(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
25146
+ if (!existsSync11(cache)) return null;
24800
25147
  const found = [];
24801
25148
  for (const market of readdirSync6(cache)) {
24802
- const plugin = join14(cache, market, SERVER_KEY);
24803
- if (!existsSync9(plugin)) continue;
25149
+ const plugin = join16(cache, market, SERVER_KEY);
25150
+ if (!existsSync11(plugin)) continue;
24804
25151
  for (const version4 of readdirSync6(plugin).sort()) {
24805
- const dir = join14(plugin, version4, CODEX_PLUGIN_SUBDIR);
24806
- 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);
24807
25154
  }
24808
25155
  }
24809
25156
  return found.length === 0 ? null : found[found.length - 1];
24810
25157
  }
24811
25158
  function nativeMcpWrong(dir, row5) {
24812
25159
  try {
24813
- 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]);
24814
25161
  if (!isObject4(entry)) return true;
24815
25162
  const args = list2(entry[MCP_ARGS_FIELD]);
24816
25163
  const script = args[0];
@@ -24881,17 +25228,17 @@ function opencodePluginDirs(configDir, worktree) {
24881
25228
  return [configDir, opencodeProjectDir(worktree)];
24882
25229
  }
24883
25230
  function opencodeProjectDir(worktree) {
24884
- return join14(worktree, OPENCODE_PROJECT_DIR);
25231
+ return join16(worktree, OPENCODE_PROJECT_DIR);
24885
25232
  }
24886
25233
  function packageResolves(fromDir) {
24887
25234
  for (let d = fromDir; ; d = dirname8(d)) {
24888
- 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;
24889
25236
  if (dirname8(d) === d) return false;
24890
25237
  }
24891
25238
  }
24892
25239
  function opencodeDirPlugins(dirs) {
24893
25240
  const bundle = opencodePluginFile();
24894
- const ownFile = join14(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
25241
+ const ownFile = join16(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
24895
25242
  const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
24896
25243
  const isPath = (p) => {
24897
25244
  if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -24901,7 +25248,7 @@ function opencodeDirPlugins(dirs) {
24901
25248
  };
24902
25249
  const out = [];
24903
25250
  for (const dir of dirs) {
24904
- const pdir = join14(dir, OPENCODE_PLUGINS_DIR);
25251
+ const pdir = join16(dir, OPENCODE_PLUGINS_DIR);
24905
25252
  let names;
24906
25253
  try {
24907
25254
  names = readdirSync6(pdir);
@@ -24909,12 +25256,12 @@ function opencodeDirPlugins(dirs) {
24909
25256
  continue;
24910
25257
  }
24911
25258
  for (const name of names) {
24912
- const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join14(pdir, name)] : [];
24913
- 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}`))];
24914
25261
  for (const f of files) {
24915
25262
  let text;
24916
25263
  try {
24917
- const b = readFileSync11(f);
25264
+ const b = readFileSync13(f);
24918
25265
  if (b.length > OPENCODE_DIR_FILE_MAX) continue;
24919
25266
  text = b.toString("utf8");
24920
25267
  } catch {
@@ -24925,7 +25272,7 @@ function opencodeDirPlugins(dirs) {
24925
25272
  const loads = lits.some((p) => {
24926
25273
  if (isModule(p)) return packageResolves(dirname8(f));
24927
25274
  const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
24928
- return existsSync9(isAbsolute4(bare2) ? bare2 : resolve9(dirname8(f), bare2));
25275
+ return existsSync11(isAbsolute5(bare2) ? bare2 : resolve9(dirname8(f), bare2));
24929
25276
  });
24930
25277
  out.push({ file: f, loads });
24931
25278
  }
@@ -24943,19 +25290,19 @@ function opencodeMcpOwn(entry) {
24943
25290
  return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
24944
25291
  }
24945
25292
  function opencodeFileValue(file2) {
24946
- if (!existsSync9(file2)) return {};
24947
- return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
25293
+ if (!existsSync11(file2)) return {};
25294
+ return parseHostConfig("opencode", file2, hostText(readFileSync13(file2, "utf8")), "jsonc");
24948
25295
  }
24949
25296
  function opencodeValueListed(value) {
24950
25297
  const bundle = opencodePluginFile();
24951
- const own4 = [bundle, join14(bundle, ...OPENCODE_PLUGIN_PATH)];
25298
+ const own4 = [bundle, join16(bundle, ...OPENCODE_PLUGIN_PATH)];
24952
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;
24953
25300
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
24954
25301
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
24955
25302
  }
24956
25303
  function opencodeListed(file2, worktree) {
24957
25304
  const dirs = [dirname8(file2), worktree];
24958
- 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;
24959
25306
  return opencodeDirPlugin(opencodePluginDirs(dirname8(file2), worktree)) !== void 0;
24960
25307
  }
24961
25308
  function mcpWrong(row5, home, env, worktree) {
@@ -24977,7 +25324,7 @@ function mcpWrong(row5, home, env, worktree) {
24977
25324
  function hookFile(row5, spec, home, env, worktree) {
24978
25325
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
24979
25326
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24980
- 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);
24981
25328
  return file2;
24982
25329
  }
24983
25330
  function hookParts(row5, home, env, worktree) {
@@ -24988,7 +25335,7 @@ function hookParts(row5, home, env, worktree) {
24988
25335
  const file2 = hookFile(row5, spec, home, env, worktree);
24989
25336
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24990
25337
  if (row5.id === "codex") {
24991
- 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;
24992
25339
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24993
25340
  }
24994
25341
  } catch {
@@ -25017,29 +25364,67 @@ function hookParts(row5, home, env, worktree) {
25017
25364
  }
25018
25365
  function checkHostConfig(row5, env, worktree) {
25019
25366
  const home = homeDirOf(env);
25020
- 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);
25021
25368
  if (row5.installMode === "marketplace") {
25022
25369
  const choice = marketplaceChoice(env, worktree);
25023
- 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));
25024
25371
  }
25025
25372
  if (row5.id === "pi") return checkPiInstall(env, home, worktree);
25373
+ if (row5.id === "omp") return checkOmpInstall(home);
25026
25374
  const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
25027
- if (parts.length === 0) return pass("D3");
25375
+ if (parts.length === 0) return pass2("D3");
25028
25376
  const detail = D3_DETAIL(parts);
25029
25377
  const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
25030
- return fail2("D3", detail, fix);
25378
+ return fail3("D3", detail, fix);
25031
25379
  }
25032
25380
  function checkPiInstall(env, home, worktree) {
25033
25381
  const found = piInstalledIn(env, home, ownBundleDir(), worktree);
25034
- if (found !== void 0) return { ...pass("D3"), detail: found };
25035
- 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;
25036
25421
  }
25037
25422
  function checkV1Leftovers(agent, home, scope = {}) {
25038
25423
  const findings = detectV1(agent, home, scope);
25039
- if (findings.length === 0) return pass("D4");
25424
+ if (findings.length === 0) return pass2("D4");
25040
25425
  const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
25041
- if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
25042
- 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" };
25043
25428
  }
25044
25429
  function parsedOrNull(agent, file2, jsonc) {
25045
25430
  try {
@@ -25050,13 +25435,13 @@ function parsedOrNull(agent, file2, jsonc) {
25050
25435
  }
25051
25436
  }
25052
25437
  function checkDoubleFire(agent, worktree) {
25053
- if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
25054
- 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);
25055
25440
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
25056
25441
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
25057
- 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);
25058
25443
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
25059
- return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
25444
+ return hooksOn && useClaudeHooks ? fail3("D5b", D5B_DETAIL, D5B_FIX) : pass2("D5b");
25060
25445
  }
25061
25446
  function configPaths(row5, env, worktree) {
25062
25447
  const home = homeDirOf(env);
@@ -25065,7 +25450,7 @@ function configPaths(row5, env, worktree) {
25065
25450
  const mcp = mcpFile(row5, home, env);
25066
25451
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
25067
25452
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
25068
- 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) });
25069
25454
  const spec = HOOK_HOST_FILE[row5.id];
25070
25455
  if (spec !== null) {
25071
25456
  try {
@@ -25085,10 +25470,10 @@ function configPaths(row5, env, worktree) {
25085
25470
  }
25086
25471
 
25087
25472
  // src/core/ops/doctor-db.ts
25088
- import { existsSync as existsSync10, statSync as statSync5 } from "node:fs";
25089
- var unknown2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
25090
- var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
25091
- 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 });
25092
25477
  function isCorrupt2(err) {
25093
25478
  if (typeof err !== "object" || err === null) return false;
25094
25479
  const code = err.errcode;
@@ -25127,17 +25512,17 @@ function orphanFiles(dbPath) {
25127
25512
  const files = [];
25128
25513
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
25129
25514
  const path8 = dbPath + suffix;
25130
- if (existsSync10(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
25515
+ if (existsSync12(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
25131
25516
  }
25132
- return files.length > 0 && !existsSync10(dbPath) ? files : [];
25517
+ return files.length > 0 && !existsSync12(dbPath) ? files : [];
25133
25518
  }
25134
25519
  async function checkDb(project) {
25135
25520
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
25136
25521
  const orphan = orphanFiles(project.dbPath);
25137
- if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
25138
- 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 };
25139
25524
  const sqlite = await loadSqlite2();
25140
- if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
25525
+ if (sqlite === null) return { row: unknown3("D8", D2_SQLITE_DETAIL), ...clean };
25141
25526
  let raw = null;
25142
25527
  try {
25143
25528
  raw = openRead(sqlite, project.dbPath);
@@ -25150,226 +25535,35 @@ async function checkDb(project) {
25150
25535
  }
25151
25536
  const schemaStale = got !== null && got !== SCHEMA_VERSION;
25152
25537
  const integrityFailed = failsOnCorrupt(() => !integrityOk(db));
25153
- if (integrityFailed) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
25154
- if (schemaStale && got !== null) return { row: fail3(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
25155
- 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 };
25156
25541
  } catch (err) {
25157
- if (isCorrupt2(err)) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
25158
- 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 };
25159
25544
  } finally {
25160
25545
  raw?.close();
25161
25546
  }
25162
25547
  }
25163
25548
  async function checkIndex(project) {
25164
- 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));
25165
25550
  const sqlite = await loadSqlite2();
25166
- if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
25551
+ if (sqlite === null) return unknown3("D9", D2_SQLITE_DETAIL);
25167
25552
  let raw = null;
25168
25553
  try {
25169
25554
  raw = openRead(sqlite, project.dbPath);
25170
25555
  const sources = Number(cell(raw.prepare("SELECT count(*) FROM sources").get()));
25171
25556
  const chunks = Number(cell(raw.prepare("SELECT count(*) FROM chunks").get()));
25172
- return pass2("D9", D9_INDEX_DETAIL(sources, chunks));
25557
+ return pass3("D9", D9_INDEX_DETAIL(sources, chunks));
25173
25558
  } catch (err) {
25174
- return unknown2("D9", message2(err));
25559
+ return unknown3("D9", message2(err));
25175
25560
  } finally {
25176
25561
  raw?.close();
25177
25562
  }
25178
25563
  }
25179
25564
 
25180
- // src/core/ops/doctor-env.ts
25181
- import { existsSync as existsSync11, readFileSync as readFileSync12, realpathSync as realpathSync6 } from "node:fs";
25182
- import { isAbsolute as isAbsolute5, join as join15, relative as relative4 } from "node:path";
25183
- function pass3(id, detail = DOCTOR_PASS_DETAIL) {
25184
- return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
25185
- }
25186
- function unknown3(id, detail, fixCommand) {
25187
- return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
25188
- }
25189
- function fail4(id, detail, fixCommand) {
25190
- return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
25191
- }
25192
- function warn(id, detail, fixCommand) {
25193
- return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
25194
- }
25195
- function bundleVersion(bundleDir2) {
25196
- try {
25197
- const v = JSON.parse(readFileSync12(join15(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
25198
- return typeof v === "string" && v !== "" ? v : void 0;
25199
- } catch {
25200
- return void 0;
25201
- }
25202
- }
25203
- function channelOf(version4) {
25204
- const at2 = version4.indexOf(D1_PRERELEASE_SEP);
25205
- if (at2 < 0) return D1_DEFAULT_TAG;
25206
- const pre = version4.slice(at2 + 1);
25207
- const dot = pre.indexOf(".");
25208
- const tag2 = dot < 0 ? pre : pre.slice(0, dot);
25209
- return tag2 === "" ? D1_DEFAULT_TAG : tag2;
25210
- }
25211
- function firstLine3(b) {
25212
- const text = b.toString("utf8").trim();
25213
- const nl = text.indexOf("\n");
25214
- return (nl < 0 ? text : text.slice(0, nl)).trim();
25215
- }
25216
- function gitCause(r, timeoutMs) {
25217
- if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
25218
- if (r.killed === "cancel") return D1_GIT_CANCEL;
25219
- if (r.exitCode === null) return D1_GIT_NO_START;
25220
- return D1_GIT_EXIT(r.exitCode, firstLine3(r.stderr));
25221
- }
25222
- function fetchCause(err, timeoutMs) {
25223
- const name = err instanceof Error ? err.name : "";
25224
- if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
25225
- const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
25226
- const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
25227
- const msg = cause instanceof Error ? cause.message : String(cause);
25228
- const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
25229
- return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
25230
- }
25231
- async function npmLatest(url4, tag2, signal, timeoutMs) {
25232
- try {
25233
- const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
25234
- if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
25235
- const body = await res.json();
25236
- const v = typeof body === "object" && body !== null ? body[tag2] : void 0;
25237
- return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag2) };
25238
- } catch (err) {
25239
- return { ok: false, cause: fetchCause(err, timeoutMs) };
25240
- }
25241
- }
25242
- function digits(s) {
25243
- if (s === "") return false;
25244
- for (const ch of s) if (ch < "0" || ch > "9") return false;
25245
- return true;
25246
- }
25247
- function parseVersion(v) {
25248
- const at2 = v.indexOf(D1_PRERELEASE_SEP);
25249
- const core = (at2 < 0 ? v : v.slice(0, at2)).split(NODE_VERSION_SEP);
25250
- if (core.length !== 3 || !core.every(digits)) return null;
25251
- const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
25252
- if (at2 < 0) return { core: nums, pre: [] };
25253
- const pre = v.slice(at2 + 1).split(NODE_VERSION_SEP);
25254
- if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
25255
- if (pre.length === 1) return { core: nums, pre: [pre[0]] };
25256
- return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
25257
- }
25258
- function sign(n) {
25259
- return n < 0 ? -1 : n > 0 ? 1 : 0;
25260
- }
25261
- function compareVersions(a, b) {
25262
- const x = parseVersion(a);
25263
- const y = parseVersion(b);
25264
- if (x === null || y === null) return null;
25265
- for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
25266
- if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
25267
- if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
25268
- return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
25269
- }
25270
- function highestTag(stdout, tag2) {
25271
- let best;
25272
- for (const line of stdout.split("\n")) {
25273
- const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
25274
- if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
25275
- const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
25276
- if (parseVersion(v) === null || channelOf(v) !== tag2) continue;
25277
- if (best === void 0 || compareVersions(v, best) === 1) best = v;
25278
- }
25279
- return best;
25280
- }
25281
- function versionRow(head2, installed, tag2, source, latest, tail, update) {
25282
- const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
25283
- if (cmp === 0) return pass3("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
25284
- if (cmp > 0) return pass3("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
25285
- return warn("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, update);
25286
- }
25287
- async function checkVersion(i) {
25288
- if (i.bundleSha === void 0) return unknown3("D1", D1_DEV_BUILD_DETAIL);
25289
- const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
25290
- if (i.version === void 0) return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
25291
- const tag2 = channelOf(i.version);
25292
- const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
25293
- const git2 = findRuntime(GIT_BIN, i.env);
25294
- const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
25295
- if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "", update);
25296
- let cause = D1_GIT_MISSING;
25297
- if (git2 !== null) {
25298
- const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
25299
- cwd: i.cwd,
25300
- env: { ...i.env, ...GIT_NO_PROMPT_ENV },
25301
- signal: i.signal,
25302
- timeoutMs: i.timeoutMs
25303
- });
25304
- if (r.exitCode === 0 && r.killed === null) {
25305
- const latest = highestTag(r.stdout.toString("utf8"), tag2);
25306
- if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
25307
- cause = D1_GIT_NO_TAG(tag2);
25308
- } else {
25309
- cause = gitCause(r, i.timeoutMs);
25310
- }
25311
- }
25312
- return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
25313
- }
25314
- function numbers(v) {
25315
- const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
25316
- return bare2.split(NODE_VERSION_SEP).map(Number);
25317
- }
25318
- function belowMin(version4) {
25319
- const got = numbers(version4);
25320
- const min = numbers(NODE_MIN);
25321
- for (let k = 0; k < min.length; k++) {
25322
- const g = got[k] ?? 0;
25323
- if (g !== min[k]) return g < min[k];
25324
- }
25325
- return false;
25326
- }
25327
- async function sqliteLoads() {
25328
- try {
25329
- await import(SQLITE_MODULE);
25330
- return true;
25331
- } catch {
25332
- return false;
25333
- }
25334
- }
25335
- async function checkNode(i) {
25336
- const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
25337
- const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
25338
- if (belowMin(i.nodeVersion)) return fail4("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
25339
- if (!await sqliteLoads()) return fail4("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
25340
- return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
25341
- }
25342
- function checkMcp(ctx, adapter) {
25343
- const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
25344
- const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
25345
- if (named2 || versioned) return pass3("D6");
25346
- return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown3("D6", D6_UNKNOWN_DETAIL);
25347
- }
25348
- function piCwdInside(worktree, piCwd) {
25349
- if (piCwd === void 0 || !existsSync11(piCwd)) return false;
25350
- const rel = relative4(worktree, realpathSync6.native(piCwd));
25351
- return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
25352
- }
25353
- function checkProject(i) {
25354
- const bad = fail4("D7", D7_DETAIL(i.project.source), D7_FIX);
25355
- if (i.project.source !== i.adapter.projectSource) return bad;
25356
- if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
25357
- return pass3("D7");
25358
- }
25359
- function checkMode(adapter, hostPermission) {
25360
- if (hostPermission === "missing") return fail4("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
25361
- if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
25362
- return pass3("D10", D10_DETAIL(adapter.denyChannel));
25363
- }
25364
- function checkShell(env) {
25365
- const win = process.platform === "win32";
25366
- const shell = findRuntime("shell", env);
25367
- if (shell !== null) return pass3("D11", D11_PASS_DETAIL(shell, win));
25368
- return win ? fail4("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail4("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
25369
- }
25370
-
25371
25565
  // src/core/ops/doctor-hook.ts
25372
- 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";
25373
25567
  import { tmpdir as tmpdir2 } from "node:os";
25374
25568
  import path7 from "node:path";
25375
25569
 
@@ -27113,7 +27307,9 @@ var HOST_SHAPES = {
27113
27307
  kiro: kiro_default,
27114
27308
  zcode: zcode_default,
27115
27309
  pi: pi_default,
27116
- opencode: opencode_default
27310
+ opencode: opencode_default,
27311
+ omp: pi_default
27312
+ // ADR-0026: OMP reads the Pi extension reply
27117
27313
  };
27118
27314
  var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
27119
27315
  var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
@@ -27195,7 +27391,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
27195
27391
 
27196
27392
  // src/setup/codex-trust.ts
27197
27393
  import { createHash } from "node:crypto";
27198
- import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
27394
+ import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
27199
27395
  import path6 from "node:path";
27200
27396
  import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
27201
27397
 
@@ -27418,10 +27614,10 @@ function isObject6(v) {
27418
27614
  }
27419
27615
  function loadFixture(bundleDir2, agent) {
27420
27616
  const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
27421
- if (!existsSync13(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27617
+ if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27422
27618
  let all;
27423
27619
  try {
27424
- all = JSON.parse(hostText(readFileSync13(file2, "utf8")));
27620
+ all = JSON.parse(hostText(readFileSync14(file2, "utf8")));
27425
27621
  } catch (err) {
27426
27622
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
27427
27623
  }
@@ -27443,7 +27639,8 @@ var CWD_KEY = {
27443
27639
  kiro: "cwd",
27444
27640
  zcode: "cwd",
27445
27641
  pi: "cwd",
27446
- opencode: "directory"
27642
+ opencode: "directory",
27643
+ omp: "cwd"
27447
27644
  };
27448
27645
  function payloadFor(agent, payload, worktree) {
27449
27646
  return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
@@ -27635,7 +27832,7 @@ async function codexStopDetail(i, timeoutMs) {
27635
27832
  timeoutMs,
27636
27833
  stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
27637
27834
  });
27638
- const logged = existsSync13(path7.join(home, HOOK_ERROR_LOG_FILE));
27835
+ const logged = existsSync14(path7.join(home, HOOK_ERROR_LOG_FILE));
27639
27836
  return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
27640
27837
  } finally {
27641
27838
  rmSync2(home, { recursive: true, force: true });
@@ -27646,7 +27843,7 @@ async function checkHookRoundTrip(i) {
27646
27843
  const trust = await codexPluginTrust(i);
27647
27844
  if (trust !== null) return trust;
27648
27845
  }
27649
- 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)) {
27650
27847
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
27651
27848
  }
27652
27849
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -27662,10 +27859,13 @@ async function checkHookRoundTrip(i) {
27662
27859
  await runProcess([node3.file, "-e", ""], { cwd: i.bundleDir, env: node3.env, signal: i.signal, timeoutMs });
27663
27860
  return performance.now() - t;
27664
27861
  });
27862
+ const inProcess = getAdapter(i.agent).installMode === "in-process";
27665
27863
  const hookWalls = [];
27666
27864
  const bareWalls = [];
27667
27865
  let ms = 0;
27668
- for (let n = 1; n <= maxPairs; n++) {
27866
+ let fastBare = 0;
27867
+ let bound = HOOK_P95_MS;
27868
+ for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
27669
27869
  const start = now();
27670
27870
  const node3 = nodeLaunch(i.env);
27671
27871
  const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
@@ -27677,28 +27877,32 @@ async function checkHookRoundTrip(i) {
27677
27877
  });
27678
27878
  hookWalls.push(now() - start);
27679
27879
  if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
27880
+ if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
27680
27881
  bareWalls.push(await bareMs());
27681
- ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
27682
- if (n >= minPairs && ms <= HOOK_P95_MS) break;
27882
+ fastBare = Math.round(Math.min(...bareWalls));
27883
+ ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
27884
+ bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
27885
+ if (n >= minPairs && ms <= bound) break;
27683
27886
  }
27684
- if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
27887
+ if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
27685
27888
  const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
27686
27889
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
27890
+ if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
27687
27891
  return row("PASS", DOCTOR_PASS_DETAIL);
27688
27892
  }
27689
27893
 
27690
27894
  // src/core/ops/db-heal.ts
27691
- import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27692
- 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";
27693
27897
 
27694
27898
  // src/core/store/owners.ts
27695
- import { mkdirSync as mkdirSync5, readdirSync as readdirSync7, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27696
- 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";
27697
27901
  function ownersDir(configDir, projectKey) {
27698
- return join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27902
+ return join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27699
27903
  }
27700
27904
  function ownerFile(configDir, projectKey, serverId) {
27701
- return join16(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
27905
+ return join17(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
27702
27906
  }
27703
27907
  function errCode2(err) {
27704
27908
  return err.code;
@@ -27733,10 +27937,10 @@ function listLiveOwners(configDir, projectKey) {
27733
27937
  const live = [];
27734
27938
  for (const name of names) {
27735
27939
  if (!name.endsWith(OWNER_PID_EXT)) continue;
27736
- const file2 = join16(dir, name);
27940
+ const file2 = join17(dir, name);
27737
27941
  let text;
27738
27942
  try {
27739
- text = readFileSync14(file2, "utf8");
27943
+ text = readFileSync15(file2, "utf8");
27740
27944
  } catch (err) {
27741
27945
  if (errCode2(err) === "ENOENT") continue;
27742
27946
  throw err;
@@ -27782,7 +27986,7 @@ function renameAside(dbPath) {
27782
27986
  const ts = String(Date.now());
27783
27987
  for (const suffix of DB_SIBLING_SUFFIXES) {
27784
27988
  const file2 = dbPath + suffix;
27785
- 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);
27786
27990
  }
27787
27991
  return ts;
27788
27992
  }
@@ -27805,7 +28009,7 @@ function utcStamp(now) {
27805
28009
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
27806
28010
  }
27807
28011
  function makeOrphanDir(projectDir) {
27808
- const base = join17(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
28012
+ const base = join18(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
27809
28013
  for (let n = 1; ; n += 1) {
27810
28014
  const dir = n === 1 ? base : base + "-" + String(n);
27811
28015
  try {
@@ -27822,7 +28026,7 @@ async function healOrphan(project, files, row5) {
27822
28026
  try {
27823
28027
  dir = makeOrphanDir(dirname9(project.dbPath));
27824
28028
  for (const f of files) {
27825
- const to = join17(dir, basename4(f.path));
28029
+ const to = join18(dir, basename4(f.path));
27826
28030
  renameWithRetry(f.path, to);
27827
28031
  moved.push({ path: to, bytes: f.bytes });
27828
28032
  }
@@ -27920,8 +28124,8 @@ function unsupportedHostOf(sig) {
27920
28124
 
27921
28125
  // src/core/ops/doctor-issue.ts
27922
28126
  import { spawnSync as spawnSync3 } from "node:child_process";
27923
- 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";
27924
- import { delimiter, 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";
27925
28129
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27926
28130
  function tildeOf(env) {
27927
28131
  const home = homeDirOf(env);
@@ -27944,13 +28148,28 @@ function maskLine(line) {
27944
28148
  const at2 = Math.max(line.indexOf(":"), line.indexOf("="));
27945
28149
  return at2 === -1 ? DOCTOR_MASK : line.slice(0, at2 + 1) + " " + DOCTOR_MASK;
27946
28150
  }
27947
- function environmentLine(ctx, adapter, env, version4) {
28151
+ async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
28152
+ if (host.bun === void 0) return { node: host.node };
28153
+ const node3 = findRuntime("javascript", env);
28154
+ if (node3 === null) return { node: host.node, bun: host.bun, pathNode: null };
28155
+ const childEnv = {};
28156
+ for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
28157
+ const r = await runProcess([node3, "--version"], { cwd: dirname10(node3), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
28158
+ const out = r.stdout.toString("utf8").trim();
28159
+ return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
28160
+ }
28161
+ function environmentLine(ctx, adapter, env, version4, rt) {
27948
28162
  const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
27949
28163
  const client = ctx.clientInfo;
27950
28164
  const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
27951
28165
  const shell = env.SHELL ?? env.ComSpec ?? "sh";
27952
- return `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
27953
- ${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}, Node ${process.version}, shell ${shell}`;
28166
+ const what = `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
28167
+ `;
28168
+ const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
28169
+ if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
28170
+ const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
28171
+ return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
28172
+ ${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
27954
28173
  }
27955
28174
  function gitVersion(env) {
27956
28175
  const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
@@ -27962,8 +28181,8 @@ function onPath(env, tool) {
27962
28181
  const out = [];
27963
28182
  for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
27964
28183
  if (dir === "") continue;
27965
- for (const n of names) if (existsSync15(join18(dir, n))) {
27966
- out.push(join18(dir, n));
28184
+ for (const n of names) if (existsSync16(join19(dir, n))) {
28185
+ out.push(join19(dir, n));
27967
28186
  break;
27968
28187
  }
27969
28188
  }
@@ -27971,7 +28190,7 @@ function onPath(env, tool) {
27971
28190
  }
27972
28191
  function hookLogTail(env) {
27973
28192
  const file2 = hookLogPath(env);
27974
- 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)`];
27975
28194
  try {
27976
28195
  const fd = openSync2(file2, "r");
27977
28196
  try {
@@ -27991,7 +28210,7 @@ function hookLogTail(env) {
27991
28210
  }
27992
28211
  async function journalRows(ctx) {
27993
28212
  const head2 = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
27994
- 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})`];
27995
28214
  try {
27996
28215
  const db = await openDb(ctx.project, { readOnly: true });
27997
28216
  try {
@@ -28009,21 +28228,21 @@ function agentConfig(adapter, env, worktree) {
28009
28228
  const home = homeDirOf(env);
28010
28229
  const files = configPaths(adapter, env, worktree);
28011
28230
  if (home !== null) {
28012
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join18(claudeDirOf(env, home), SETTINGS_FILE) });
28013
- 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) });
28014
28233
  }
28015
28234
  const out = [];
28016
28235
  const seen = /* @__PURE__ */ new Set();
28017
28236
  for (const f of files) {
28018
28237
  if (seen.has(f.path)) continue;
28019
28238
  seen.add(f.path);
28020
- if (!existsSync15(f.path)) {
28239
+ if (!existsSync16(f.path)) {
28021
28240
  out.push(`${f.label}: ${f.path} (absent)`);
28022
28241
  continue;
28023
28242
  }
28024
28243
  let text = "";
28025
28244
  try {
28026
- text = readFileSync15(f.path, "utf8");
28245
+ text = readFileSync16(f.path, "utf8");
28027
28246
  } catch (err) {
28028
28247
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
28029
28248
  continue;
@@ -28094,9 +28313,9 @@ async function buildIssueBody(i) {
28094
28313
  async function writeIssueReport(i) {
28095
28314
  const tilde = tildeOf(i.env);
28096
28315
  const body = await buildIssueBody(i);
28097
- const dir = join18(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
28316
+ const dir = join19(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
28098
28317
  mkdirSync7(dir, { recursive: true });
28099
- 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`);
28100
28319
  writeFileSync4(file2, body);
28101
28320
  const shown2 = tilde(file2);
28102
28321
  const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
@@ -28123,7 +28342,7 @@ async function guard(id, run) {
28123
28342
  }
28124
28343
  }
28125
28344
  async function codexDb(ctx, adapter) {
28126
- if (adapter.id !== "codex" || !existsSync16(ctx.project.dbPath)) return null;
28345
+ if (adapter.id !== "codex" || !existsSync17(ctx.project.dbPath)) return null;
28127
28346
  try {
28128
28347
  return await openDb(ctx.project, { readOnly: true });
28129
28348
  } catch {
@@ -28159,11 +28378,11 @@ async function hookRow(ctx, adapter, host) {
28159
28378
  }
28160
28379
  }
28161
28380
  function ownServerId(configDir, projectKey) {
28162
- const dir = join19(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
28163
- if (!existsSync16(dir)) return "";
28381
+ const dir = join20(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
28382
+ if (!existsSync17(dir)) return "";
28164
28383
  for (const name of readdirSync8(dir)) {
28165
28384
  if (!name.endsWith(OWNER_PID_EXT)) continue;
28166
- 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);
28167
28386
  }
28168
28387
  return "";
28169
28388
  }
@@ -28193,7 +28412,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
28193
28412
  D9: () => checkIndex(project),
28194
28413
  D10: () => checkMode(adapter, ctx.hostPermission),
28195
28414
  // D-1331-OC-PERM-1
28196
- D11: () => checkShell(env)
28415
+ D11: () => checkRuntimes(env, checkShell(env))
28197
28416
  };
28198
28417
  const rows = [];
28199
28418
  for (const id of DOCTOR_CHECK_ORDER) rows.push(await guard(id, checks[id]));
@@ -28220,11 +28439,12 @@ function reportEnv(env) {
28220
28439
  }
28221
28440
  async function doctorReply(ctx, host) {
28222
28441
  const adapter = getAdapter(ctx.project.agent);
28442
+ const runtime = runtimeInfo(host.env, ctx.signal);
28223
28443
  const rows = await runDoctorChecks(ctx, adapter, host);
28224
28444
  const failed = rows.some((r) => r.status === "FAIL");
28225
- 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}`;
28226
28446
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
28227
- const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
28447
+ const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
28228
28448
  const table3 = buildReport(input);
28229
28449
  let notes = [];
28230
28450
  if (failed) {
@@ -28236,7 +28456,8 @@ async function doctorReply(ctx, host) {
28236
28456
  }
28237
28457
  const look = rows.find((r) => r.status === "FAIL") ?? rows.find((r) => r.status !== "PASS");
28238
28458
  const docs = look === void 0 ? [] : [DOCTOR_DOCS_LABEL + DOCTOR_DOCS_LINK(look.id)];
28239
- 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");
28240
28461
  const bytes5 = Buffer.byteLength(whole2, "utf8");
28241
28462
  if (bytes5 <= REPORT_CAP) return { text: whole2, isError: false, sandboxBytes: bytes5 };
28242
28463
  const db = await openDb(ctx.project);
@@ -28245,9 +28466,14 @@ async function doctorReply(ctx, host) {
28245
28466
  } finally {
28246
28467
  closeDb(db);
28247
28468
  }
28248
- const text = [envLine2, buildReportHead(input), ...docs, ...notes].join("\n");
28469
+ const text = [envLine2, buildReportHead(input), ...docs, ...info, ...notes].join("\n");
28249
28470
  return { text, isError: false, sandboxBytes: bytes5 };
28250
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
+ }
28251
28477
  async function handler2(_input, ctx) {
28252
28478
  return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
28253
28479
  }
@@ -28261,9 +28487,9 @@ var ctxDoctor = Object.freeze({
28261
28487
  });
28262
28488
 
28263
28489
  // src/core/tools/execute.ts
28264
- 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";
28265
28491
  import { tmpdir as tmpdir3 } from "node:os";
28266
- import { dirname as dirname11, 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";
28267
28493
 
28268
28494
  // src/core/sandbox/win-build.ts
28269
28495
  var SEPARATORS2 = ";&|(\n";
@@ -28346,7 +28572,7 @@ function schemaLine(issue4) {
28346
28572
  }
28347
28573
  function fileError(given, abs, root) {
28348
28574
  let dir = abs;
28349
- while (!existsSync17(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
28575
+ while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
28350
28576
  if (isInside(root, dir)) return null;
28351
28577
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
28352
28578
  }
@@ -28415,7 +28641,12 @@ async function handler3(raw, ctx) {
28415
28641
  if (bad !== null) return fail5(bad);
28416
28642
  extra.CTX_FILE = abs;
28417
28643
  }
28418
- const runtime = findRuntime(input.language);
28644
+ let runtime;
28645
+ try {
28646
+ runtime = findRuntime(input.language);
28647
+ } catch {
28648
+ runtime = null;
28649
+ }
28419
28650
  if (runtime === null) return fail5(noRuntimeError(input.language).toLine());
28420
28651
  const env = buildChildEnv(process.env, extra);
28421
28652
  const timeoutMs = input.timeoutMs ?? EXEC_TIMEOUT_MS;
@@ -28427,8 +28658,8 @@ async function handler3(raw, ctx) {
28427
28658
  if (takesDashC(input.language, runtime)) {
28428
28659
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
28429
28660
  } else {
28430
- tmpDir = mkdtempSync2(join20(tmpdir3(), TMP_PREFIX));
28431
- 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] ?? ""));
28432
28663
  writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
28433
28664
  argv = scriptArgv(input.language, runtime, file2);
28434
28665
  }
@@ -28464,12 +28695,12 @@ var ctxExecute = {
28464
28695
  };
28465
28696
 
28466
28697
  // src/core/tools/index.ts
28467
- import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
28468
- import { dirname as dirname12, 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";
28469
28700
 
28470
28701
  // src/core/index/walk.ts
28471
- import { readdirSync as readdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28472
- 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";
28473
28704
  var GITIGNORE = ".gitignore";
28474
28705
  var GIT_DIR = ".git";
28475
28706
  function walkDir(root, containmentRoot) {
@@ -28478,7 +28709,7 @@ function walkDir(root, containmentRoot) {
28478
28709
  const found = [];
28479
28710
  visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
28480
28711
  found.sort(compareFound);
28481
- 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) }));
28482
28713
  }
28483
28714
  function visit(abs, rel, parent, contain, seen, found) {
28484
28715
  let entries;
@@ -28487,10 +28718,10 @@ function visit(abs, rel, parent, contain, seen, found) {
28487
28718
  } catch {
28488
28719
  return;
28489
28720
  }
28490
- 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;
28491
28722
  for (const e of entries) {
28492
28723
  if (e.name === GIT_DIR) continue;
28493
- const path8 = join21(abs, e.name);
28724
+ const path8 = join22(abs, e.name);
28494
28725
  let isDir = e.isDirectory();
28495
28726
  let isFile = e.isFile();
28496
28727
  let target = path8;
@@ -28530,7 +28761,7 @@ function compareFound(a, b) {
28530
28761
  function readRules(file2, base) {
28531
28762
  let body;
28532
28763
  try {
28533
- body = readFileSync17(file2, "utf8");
28764
+ body = readFileSync18(file2, "utf8");
28534
28765
  } catch {
28535
28766
  return [];
28536
28767
  }
@@ -28613,10 +28844,12 @@ function globSeg(pat, name) {
28613
28844
  }
28614
28845
 
28615
28846
  // src/core/sandbox/fetch.ts
28847
+ import { readFileSync as readFileSync19 } from "node:fs";
28616
28848
  import { lookup } from "node:dns/promises";
28617
28849
  import http from "node:http";
28618
28850
  import https from "node:https";
28619
28851
  import { BlockList, isIP } from "node:net";
28852
+ import { join as join23 } from "node:path";
28620
28853
  import { connect as tlsConnect } from "node:tls";
28621
28854
  var PRIVATE_RANGES = [
28622
28855
  ["127.0.0.0", 8, "ipv4"],
@@ -28648,6 +28881,21 @@ for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix,
28648
28881
  var STATUS_OK_FIRST = 200;
28649
28882
  var STATUS_OK_END = 300;
28650
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
+ }
28651
28899
  function fail6(code) {
28652
28900
  return new CtxError("FETCH_FAILED", { code });
28653
28901
  }
@@ -28756,11 +29004,11 @@ function request(u, conn, proxy, signal) {
28756
29004
  const onErr = (err) => reject(fail6(causeCode(err)));
28757
29005
  if (proxy === void 0) {
28758
29006
  const mod = u.protocol === "https:" ? https : http;
28759
- 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 } });
28760
29008
  req.on("response", resolve13).on("error", onErr).end();
28761
29009
  return;
28762
29010
  }
28763
- const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
29011
+ const proxyHeaders = proxy.auth === void 0 ? { ...baseHeaders() } : { ...baseHeaders(), "proxy-authorization": proxy.auth };
28764
29012
  if (u.protocol === "http:") {
28765
29013
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
28766
29014
  req.on("response", resolve13).on("error", onErr).end();
@@ -28780,7 +29028,7 @@ function request(u, conn, proxy, signal) {
28780
29028
  port,
28781
29029
  path: path8,
28782
29030
  signal,
28783
- headers: { host: u.host },
29031
+ headers: { ...baseHeaders(), host: u.host },
28784
29032
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
28785
29033
  });
28786
29034
  req.on("response", resolve13).on("error", onErr).end();
@@ -28822,7 +29070,7 @@ async function safeFetch(url4, signal) {
28822
29070
  }
28823
29071
  if (status < STATUS_OK_FIRST || status >= STATUS_OK_END) {
28824
29072
  res.resume();
28825
- throw fail6(status);
29073
+ throw fail6(status + " from " + bare(current.hostname));
28826
29074
  }
28827
29075
  const body = await readBody(res);
28828
29076
  const shown2 = new URL(current.href);
@@ -32658,14 +32906,14 @@ function kindOfType(contentType) {
32658
32906
  }
32659
32907
  function readUtf8(absPath) {
32660
32908
  try {
32661
- return utf8.decode(readFileSync18(absPath));
32909
+ return utf8.decode(readFileSync20(absPath));
32662
32910
  } catch {
32663
32911
  return void 0;
32664
32912
  }
32665
32913
  }
32666
32914
  function missingOrOutside(given, abs, root) {
32667
32915
  let dir = abs;
32668
- while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
32916
+ while (!existsSync19(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
32669
32917
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32670
32918
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32671
32919
  }
@@ -32676,7 +32924,7 @@ function pathItems(input, project) {
32676
32924
  if (statSync8(abs).isDirectory()) {
32677
32925
  return walkDir(abs, project.containmentRoot).map((f) => ({
32678
32926
  sourceKind: "path",
32679
- label: pathLabel(join22(base, f.relPath)),
32927
+ label: pathLabel(join24(base, f.relPath)),
32680
32928
  kind: kindOfPath(f.relPath),
32681
32929
  read: () => readUtf8(f.absPath)
32682
32930
  }));
@@ -33216,8 +33464,8 @@ var ctxStats = Object.freeze({
33216
33464
  });
33217
33465
 
33218
33466
  // src/core/ops/host-write.ts
33219
- import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33220
- import { dirname as dirname13, 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";
33221
33469
  function defaultWrite(file2, text) {
33222
33470
  writeFileSync6(file2, text, "utf8");
33223
33471
  }
@@ -33226,17 +33474,20 @@ function hostConfigPath(agent, home, env) {
33226
33474
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
33227
33475
  switch (agent) {
33228
33476
  case "opencode":
33229
- return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
33477
+ return join25(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
33230
33478
  // D-WIN-OPENCODE-DIR-1
33231
33479
  case "pi":
33232
- return join23(piAgentDirOf(env, home), SETTINGS_FILE);
33480
+ return join25(piAgentDirOf(env, home), SETTINGS_FILE);
33233
33481
  case "gemini":
33234
- return join23(geminiDirOf(env, home), SETTINGS_FILE);
33482
+ return join25(geminiDirOf(env, home), SETTINGS_FILE);
33235
33483
  // D-R38-GEMINI-HOME-1
33236
33484
  case "copilot-cli":
33237
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
33238
33489
  default:
33239
- return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
33490
+ return join25(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
33240
33491
  }
33241
33492
  }
33242
33493
  function cell3(value) {
@@ -33248,8 +33499,8 @@ function toRow(file2, edit) {
33248
33499
  function writeWithRollback(file2, text, write2, atomic) {
33249
33500
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
33250
33501
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
33251
- const had = existsSync19(file2);
33252
- mkdirSync8(dirname13(file2), { recursive: true });
33502
+ const had = existsSync20(file2);
33503
+ mkdirSync8(dirname14(file2), { recursive: true });
33253
33504
  if (had) copyFileSync(file2, trash);
33254
33505
  try {
33255
33506
  write2(tmp, text);
@@ -33278,7 +33529,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
33278
33529
  if (requested === null) return [];
33279
33530
  const current = readHostConfig(row5.id, requested);
33280
33531
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
33281
- const exists = existsSync19(current.path);
33532
+ const exists = existsSync20(current.path);
33282
33533
  if (exists && result.text === current.text) return [];
33283
33534
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
33284
33535
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -33286,15 +33537,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
33286
33537
  }
33287
33538
 
33288
33539
  // src/core/ops/uninstall.ts
33289
- import { existsSync as existsSync20, readdirSync as readdirSync10, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
33290
- 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";
33291
33542
  function row2(area, before, after) {
33292
33543
  return { area, before, after };
33293
33544
  }
33294
33545
  function stopServers(configDir, projectKey) {
33295
33546
  const stopped = listLiveOwners(configDir, projectKey);
33296
- const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
33297
- 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");
33298
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 };
33299
33550
  }
33300
33551
  function rootOrNull(adapter, env) {
@@ -33312,15 +33563,15 @@ function removeCache(adapter, env, configDir) {
33312
33563
  const root = rootOrNull(adapter, env);
33313
33564
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
33314
33565
  if (adapter.installMode === "marketplace") {
33315
- 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);
33316
33567
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
33317
33568
  }
33318
33569
  rmSync6(root, { recursive: true, force: true });
33319
33570
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
33320
33571
  }
33321
33572
  case "plugin": {
33322
- const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
33323
- 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);
33324
33575
  rmSync6(agentDir, { recursive: true, force: true });
33325
33576
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
33326
33577
  }
@@ -33365,7 +33616,7 @@ function ownEntries2(agent, env) {
33365
33616
  }
33366
33617
  if (agent === "opencode") {
33367
33618
  return [{
33368
- file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
33619
+ file: join26(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
33369
33620
  // D-WIN-OPENCODE-DIR-1
33370
33621
  key: OPENCODE_PLUGIN_KEY,
33371
33622
  shown: OPENCODE_PLUGIN_KEY,
@@ -33376,13 +33627,22 @@ function ownEntries2(agent, env) {
33376
33627
  if (agent === "pi") {
33377
33628
  const agentDir = piAgentDirOf(env, home);
33378
33629
  return [{
33379
- file: join24(agentDir, SETTINGS_FILE),
33630
+ file: join26(agentDir, SETTINGS_FILE),
33380
33631
  key: PI_PACKAGES_KEY,
33381
33632
  shown: PI_PACKAGES_KEY,
33382
33633
  has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
33383
33634
  drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
33384
33635
  }];
33385
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
+ }
33386
33646
  return [];
33387
33647
  }
33388
33648
  function removeOwnEntries(agent, env) {
@@ -33398,12 +33658,12 @@ function removeOwnEntries(agent, env) {
33398
33658
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
33399
33659
  }
33400
33660
  function removeProjectData(configDir, projectKey) {
33401
- const projects = join24(configDir, PROJECTS_DIR_NAME);
33402
- const dir = join24(projects, projectKey);
33403
- 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);
33404
33664
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
33405
33665
  for (const name of readdirSync10(dir)) {
33406
- 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 });
33407
33667
  }
33408
33668
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
33409
33669
  }
@@ -33411,12 +33671,12 @@ function runUninstall(input) {
33411
33671
  const configDir = resolveConfigDir(input.env);
33412
33672
  const stop = stopServers(configDir, input.project.projectKey);
33413
33673
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
33414
- 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));
33415
33675
  return { rows, stopped: stop.stopped };
33416
33676
  }
33417
33677
 
33418
33678
  // src/core/ops/v1-remove.ts
33419
- 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";
33420
33680
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
33421
33681
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
33422
33682
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -33428,7 +33688,7 @@ function moveAside(target, undo) {
33428
33688
  }
33429
33689
  function keepAside(target, undo) {
33430
33690
  let aside = target + UPGRADE_ASIDE_SUFFIX;
33431
- 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;
33432
33692
  renameWithRetry(target, aside);
33433
33693
  undo.push({ trash: aside, target, keep: true });
33434
33694
  return aside;
@@ -33467,8 +33727,8 @@ function locate(doc, path8) {
33467
33727
  return null;
33468
33728
  }
33469
33729
  function stripJsonEntries(agent, file2, findings, kept, undo) {
33470
- const layout = hostLayout(readFileSync19(file2, "utf8"));
33471
- const text = hostText(readFileSync19(file2, "utf8"));
33730
+ const layout = hostLayout(readFileSync21(file2, "utf8"));
33731
+ const text = hostText(readFileSync21(file2, "utf8"));
33472
33732
  const doc = parseHostConfig(agent, file2, text, "jsonc");
33473
33733
  const hit = /* @__PURE__ */ new Set();
33474
33734
  const byContainer = /* @__PURE__ */ new Map();
@@ -33505,20 +33765,20 @@ function removeV1(agent, findings, project) {
33505
33765
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
33506
33766
  else if (f.path === "") {
33507
33767
  if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
33508
- else if (existsSync21(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
33509
- 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)) {
33510
33770
  moveAside(f.file, undo);
33511
33771
  done.set(f, UPGRADE_REMOVED);
33512
33772
  } else done.set(f, UPGRADE_NOT_FOUND);
33513
33773
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
33514
33774
  }
33515
33775
  for (const [file2, list4] of entries) {
33516
- if (!existsSync21(file2)) {
33776
+ if (!existsSync22(file2)) {
33517
33777
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
33518
33778
  continue;
33519
33779
  }
33520
33780
  if (file2.endsWith(TOML_EXT)) {
33521
- const rawToml = readFileSync19(file2, "utf8");
33781
+ const rawToml = readFileSync21(file2, "utf8");
33522
33782
  const tomlLayout = hostLayout(rawToml);
33523
33783
  let text = hostText(rawToml);
33524
33784
  for (const f of list4) {
@@ -33546,7 +33806,7 @@ function removeV1(agent, findings, project) {
33546
33806
  },
33547
33807
  rollback() {
33548
33808
  for (const u of undo.splice(0).reverse()) {
33549
- if (!existsSync21(u.trash)) continue;
33809
+ if (!existsSync22(u.trash)) continue;
33550
33810
  rmSync7(u.target, { recursive: true, force: true });
33551
33811
  renameWithRetry(u.trash, u.target);
33552
33812
  }
@@ -33677,8 +33937,8 @@ function checkCall(tool, input) {
33677
33937
 
33678
33938
  // src/entries/server.ts
33679
33939
  import { randomUUID } from "node:crypto";
33680
- import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33681
- import { dirname as dirname14, 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";
33682
33942
  import { fileURLToPath as fileURLToPath3 } from "node:url";
33683
33943
 
33684
33944
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -51649,8 +51909,8 @@ function liftWireOnlyMaterial(message3, kind) {
51649
51909
  };
51650
51910
  }
51651
51911
  function codecResultValidator(codec, method) {
51652
- const probe = codec.validateResult(method, void 0);
51653
- 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;
51654
51914
  return { "~standard": {
51655
51915
  version: 1,
51656
51916
  vendor: "mcp-wire-codec",
@@ -61743,8 +62003,8 @@ function installExitGuard(opts) {
61743
62003
  }
61744
62004
 
61745
62005
  // src/core/store/cleanup.ts
61746
- import { existsSync as existsSync22, readdirSync as readdirSync11, rmSync as rmSync8 } from "node:fs";
61747
- 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";
61748
62008
  function deleteSource(raw, id) {
61749
62009
  raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
61750
62010
  deleteChunkRows(raw, { sourceId: id });
@@ -61779,7 +62039,7 @@ function userVersion(raw) {
61779
62039
  return raw.prepare("PRAGMA user_version").get().user_version;
61780
62040
  }
61781
62041
  function openForSweep(dbPath, projectKey) {
61782
- 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))) {
61783
62043
  throw new CtxError("DB_GONE");
61784
62044
  }
61785
62045
  const sqlite = process.getBuiltinModule("node:sqlite");
@@ -61800,8 +62060,8 @@ function lastAccess(raw) {
61800
62060
  return row5.t;
61801
62061
  }
61802
62062
  function sweepOne(configDir, projectKey, cutoff) {
61803
- const dir = join25(configDir, PROJECTS_DIR_NAME, projectKey);
61804
- 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);
61805
62065
  let dead;
61806
62066
  try {
61807
62067
  dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
@@ -61814,7 +62074,7 @@ function sweepOne(configDir, projectKey, cutoff) {
61814
62074
  function sweepDeadProjects(configDir) {
61815
62075
  let entries;
61816
62076
  try {
61817
- entries = readdirSync11(join25(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
62077
+ entries = readdirSync11(join27(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
61818
62078
  } catch (err) {
61819
62079
  if (err.code === "ENOENT") return [];
61820
62080
  throw err;
@@ -61940,7 +62200,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
61940
62200
  const fromHost = workspaceFromMeta(meta3);
61941
62201
  if (fromHost !== void 0) return fromHost;
61942
62202
  if (script === void 0 || script === "") return spawnCwd;
61943
- return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
62203
+ return realOrSame(spawnCwd) === realOrSame(dirname15(script)) ? "" : spawnCwd;
61944
62204
  }
61945
62205
  function errorReply(err) {
61946
62206
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
@@ -61979,15 +62239,15 @@ async function startServer(argv, env) {
61979
62239
  opening.catch(() => pending.delete(project.dbPath));
61980
62240
  }
61981
62241
  const db = await opening;
61982
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
62242
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
61983
62243
  return db;
61984
62244
  }
61985
62245
  function stopMarker(configDir, projectKey) {
61986
- 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);
61987
62247
  }
61988
62248
  function stopRequested() {
61989
62249
  const configDir = resolveConfigDir(process.env);
61990
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
62250
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
61991
62251
  }
61992
62252
  async function journal(project, ctx, name, reply4) {
61993
62253
  const db = await ownDb(project);
@@ -62107,6 +62367,11 @@ if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url)))
62107
62367
  function str3(v) {
62108
62368
  return typeof v === "string" ? v : "";
62109
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
+ }
62110
62375
  function textOf2(content) {
62111
62376
  if (typeof content === "string") return content;
62112
62377
  if (!Array.isArray(content)) return "";
@@ -62115,15 +62380,18 @@ function textOf2(content) {
62115
62380
  function field(v, key) {
62116
62381
  return typeof v === "object" && v !== null && !Array.isArray(v) ? v[key] : void 0;
62117
62382
  }
62118
- function excludedTools(pi) {
62119
- 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") {
62120
62388
  try {
62121
- 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?.()) ?? [];
62122
62392
  } catch {
62123
62393
  return [];
62124
62394
  }
62125
- const list4 = field(field(settings, "contextMode"), "excludeTools");
62126
- return Array.isArray(list4) ? list4.filter((n) => typeof n === "string") : [];
62127
62395
  }
62128
62396
  function errorReply2(err) {
62129
62397
  return { text: err instanceof CtxError ? err.toLine() : INTERNAL_ERROR_LINE, isError: true, sandboxBytes: 0 };
@@ -62133,6 +62401,10 @@ function toPi(reply4) {
62133
62401
  return { content: [{ type: "text", text: reply4.text }], details: {} };
62134
62402
  }
62135
62403
  function piExtension(pi) {
62404
+ hostExtension(pi, "pi");
62405
+ }
62406
+ function hostExtension(pi, host = "pi") {
62407
+ const agent = host;
62136
62408
  const env = process.env;
62137
62409
  let sessionId = "";
62138
62410
  let cwd = "";
@@ -62142,15 +62414,16 @@ function piExtension(pi) {
62142
62414
  let payload = "";
62143
62415
  const journal = ownJournal();
62144
62416
  let toolsRegistered = false;
62417
+ let openPrompt;
62145
62418
  function identify(ctx) {
62146
62419
  if (sessionId === "") sessionId = str3(ctx?.sessionManager?.getSessionId());
62147
62420
  if (cwd === "") cwd = str3(ctx?.cwd);
62148
62421
  }
62149
62422
  function hook(raw, atTurn) {
62150
- return handleHook("pi", { ...raw, sessionId, cwd, turn: atTurn }, env);
62423
+ return handleHook(agent, { ...raw, sessionId, cwd, turn: atTurn }, env);
62151
62424
  }
62152
62425
  function projectOf() {
62153
- project ??= resolveProject("pi", { env, argv: process.argv, cwd, piCwd: cwd });
62426
+ project ??= resolveProject(agent, { env, argv: process.argv, cwd, piCwd: cwd });
62154
62427
  return project;
62155
62428
  }
62156
62429
  async function runTool(tool, params, signal) {
@@ -62183,6 +62456,7 @@ function piExtension(pi) {
62183
62456
  label: tool.name,
62184
62457
  description: tool.description,
62185
62458
  parameters: external_exports.toJSONSchema(tool.schema),
62459
+ loadMode: "essential",
62186
62460
  execute: async (_toolCallId, params, signal) => toPi(await runTool(tool, params, signal))
62187
62461
  };
62188
62462
  }
@@ -62196,10 +62470,13 @@ function piExtension(pi) {
62196
62470
  }
62197
62471
  pi.on("before_agent_start", async (event, ctx) => {
62198
62472
  identify(ctx);
62199
- 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;
62200
62477
  registerTools();
62201
- const base = str3(event.systemPrompt);
62202
- const withPayload = () => ({ systemPrompt: base === "" ? payload : base + "\n\n" + payload });
62478
+ const withPayload = () => ({ systemPrompt: appendPayload(event.systemPrompt, payload) });
62479
+ if (rerun && payload !== "") return withPayload();
62203
62480
  let out;
62204
62481
  try {
62205
62482
  out = await hook({ type: compactPending ? "session_compact" : "session_start" }, turn);
@@ -62217,6 +62494,7 @@ function piExtension(pi) {
62217
62494
  });
62218
62495
  pi.on("input", async (event, ctx) => {
62219
62496
  identify(ctx);
62497
+ openPrompt = void 0;
62220
62498
  await hook({ type: "input", message: str3(event.text) }, turn + 1);
62221
62499
  return void 0;
62222
62500
  });
@@ -62234,7 +62512,7 @@ function piExtension(pi) {
62234
62512
  input: event.input,
62235
62513
  content: textOf2(event.content),
62236
62514
  isError: event.isError === true,
62237
- keep: excludedTools(pi).includes(str3(event.toolName))
62515
+ keep: excludedTools(pi, host).includes(str3(event.toolName))
62238
62516
  }, turn);
62239
62517
  if (out.stdout === "") return void 0;
62240
62518
  const patch = { content: [{ type: "text", text: out.stdout }] };
@@ -62243,11 +62521,19 @@ function piExtension(pi) {
62243
62521
  });
62244
62522
  pi.on("session_compact", () => {
62245
62523
  compactPending = true;
62524
+ openPrompt = void 0;
62525
+ return void 0;
62526
+ });
62527
+ pi.on("agent_end", () => {
62528
+ openPrompt = void 0;
62246
62529
  return void 0;
62247
62530
  });
62531
+ if (host === "omp") registerTools();
62248
62532
  }
62249
62533
  export {
62250
- piExtension as default
62534
+ piExtension as default,
62535
+ excludedTools,
62536
+ hostExtension
62251
62537
  };
62252
62538
  /*! Bundled license information:
62253
62539