context-mode 2.1.10 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/server.mjs CHANGED
@@ -7,8 +7,8 @@ var __export = (target, all) => {
7
7
 
8
8
  // src/entries/server.ts
9
9
  import { randomUUID } from "node:crypto";
10
- import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
11
- import { dirname as dirname14, join as join23 } from "node:path";
10
+ import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
11
+ import { dirname as dirname14, join as join25 } from "node:path";
12
12
  import { fileURLToPath as fileURLToPath3 } from "node:url";
13
13
 
14
14
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -17979,8 +17979,8 @@ function liftWireOnlyMaterial(message2, kind) {
17979
17979
  };
17980
17980
  }
17981
17981
  function codecResultValidator(codec, method) {
17982
- const probe = codec.validateResult(method, void 0);
17983
- if (!probe.ok && probe.reason === "not-in-era") return void 0;
17982
+ const probe2 = codec.validateResult(method, void 0);
17983
+ if (!probe2.ok && probe2.reason === "not-in-era") return void 0;
17984
17984
  return { "~standard": {
17985
17985
  version: 1,
17986
17986
  vendor: "mcp-wire-codec",
@@ -28052,7 +28052,7 @@ function toError(value) {
28052
28052
  }
28053
28053
 
28054
28054
  // src/core/contracts/agents.ts
28055
- var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
28055
+ var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode", "omp"];
28056
28056
 
28057
28057
  // src/core/contracts/constants.ts
28058
28058
  var SERVER_KEY = "context-mode";
@@ -28355,6 +28355,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
28355
28355
  qwen: READ_IMAGES_AND_PDF,
28356
28356
  opencode: READ_IMAGES_AND_PDF,
28357
28357
  pi: READ_IMAGES,
28358
+ omp: READ_IMAGES,
28358
28359
  vscode: READ_IMAGES,
28359
28360
  zcode: READ_IMAGES,
28360
28361
  "copilot-cli": [],
@@ -28446,7 +28447,7 @@ function PURGE_SUMMARY(rows, scope) {
28446
28447
  var DECISION_SOURCE = "decision";
28447
28448
  var DECISION_USER_LABEL = "decision (user)";
28448
28449
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
28449
- var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
28450
+ var BUNDLE_SHA = true ? "9cb2aaa5ebb63491960b3f3e9655a5821383eae4" : void 0;
28450
28451
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
28451
28452
  var DOCTOR_LABEL = Object.freeze({
28452
28453
  D1: "version",
@@ -28602,7 +28603,9 @@ var AGENT_HOME_DIR = Object.freeze({
28602
28603
  kiro: [".kiro"],
28603
28604
  zcode: [".zcode"],
28604
28605
  pi: [".pi"],
28605
- opencode: [".config", "opencode"]
28606
+ opencode: [".config", "opencode"],
28607
+ omp: [".omp"]
28608
+ // ADR-0026: OMP data and plugins live under ~/.omp
28606
28609
  });
28607
28610
  var UPGRADE_RESTART_LINE = "restart needed";
28608
28611
  var UPGRADE_HOST_AREA = "host update";
@@ -28690,16 +28693,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
28690
28693
  binaries: [],
28691
28694
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
28692
28695
  }),
28693
- unsupported({
28694
- id: "omp",
28695
- name: "OMP (oh-my-pi)",
28696
- clientNames: ["omp-coding-agent"],
28697
- envVars: [],
28698
- pluginPaths: [],
28699
- configDirs: [".omp"],
28700
- binaries: ["omp"],
28701
- 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)"
28702
- }),
28703
28696
  unsupported({
28704
28697
  id: "openclaw",
28705
28698
  name: "OpenClaw",
@@ -28766,7 +28759,9 @@ var HOOK_HOST_FILE = Object.freeze({
28766
28759
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
28767
28760
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
28768
28761
  pi: null,
28769
- opencode: null
28762
+ opencode: null,
28763
+ omp: null
28764
+ // ADR-0026: in-process, no hook file
28770
28765
  });
28771
28766
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
28772
28767
  var HOOK_MATCHER_FIELD = "matcher";
@@ -28817,6 +28812,12 @@ var D11_POSIX_FIX = "install sh or add it to PATH";
28817
28812
  function D11_PASS_DETAIL(shell, win) {
28818
28813
  return `${win ? "Git Bash" : "sh"}: ${shell}`;
28819
28814
  }
28815
+ function D11_RUNTIME_DETAIL(lang, unreadable) {
28816
+ return `${lang} not found, unreadable on PATH: ${unreadable.join(", ")}`;
28817
+ }
28818
+ function D11_RUNTIME_FIX(lang) {
28819
+ return `install ${lang}, or turn off its app alias and PATH entry that cannot be read`;
28820
+ }
28820
28821
  var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
28821
28822
  var HEAL_TMP_SUFFIX = ".heal";
28822
28823
  var HEAL_TS_SEP = ".";
@@ -28828,6 +28829,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
28828
28829
  gemini: "gemini extensions update context-mode",
28829
28830
  qwen: "qwen extensions update context-mode",
28830
28831
  pi: "pi update --extensions",
28832
+ omp: "omp plugin upgrade context-mode",
28833
+ // ADR-0026 decision 4: OMP native update
28831
28834
  opencode: "opencode plugin update",
28832
28835
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
28833
28836
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -28871,6 +28874,14 @@ var PI_NPM_DIR = "npm";
28871
28874
  var PI_NODE_MODULES_DIR = "node_modules";
28872
28875
  var PI_PACKAGE_JSON_FILE = "package.json";
28873
28876
  var PI_LIST_COMMAND = "pi list";
28877
+ var OMP_LIST_COMMAND = "omp plugin list";
28878
+ var OMP_ENABLE_COMMAND = "omp plugin enable context-mode";
28879
+ var OMP_MIN_VERSION = "14.7.0";
28880
+ var OMP_FLOOR_INFO = (v) => `OMP ${v} is older than the tested floor ${OMP_MIN_VERSION}. Update it with: omp update`;
28881
+ var OMP_CONTENT_INFO = "OMP keeps tool output in content; context-mode writes its notes there.";
28882
+ var OMP_PRINT_MODE_INFO = "Print mode sends no prompt event. Use omp or omp --mode rpc to keep prompts.";
28883
+ var OMP_SCRIPTS_INFO = "Add < /dev/null in scripts.";
28884
+ var OMP_IMPORT_INFO = (claude, mcp) => `OMP also imports context-mode from ${claude}. To run it once, add "context-mode" to disabledServers in ${mcp}.`;
28874
28885
  var PI_CURRENT_MAJOR = 2;
28875
28886
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
28876
28887
  var V1_TMP_PREFIX = "context-mode-";
@@ -29081,6 +29092,8 @@ var NATIVE_INSTALL = Object.freeze({
29081
29092
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
29082
29093
  opencode: ["opencode plugin add context-mode"],
29083
29094
  pi: ["pi install npm:context-mode"],
29095
+ omp: ["omp plugin install context-mode"],
29096
+ // ADR-0026 decision 4: OMP native install
29084
29097
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
29085
29098
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
29086
29099
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -29859,6 +29872,7 @@ function sourceOf(agent) {
29859
29872
  case "opencode":
29860
29873
  return "spawn-cwd";
29861
29874
  case "pi":
29875
+ case "omp":
29862
29876
  return "pi:ctx.cwd";
29863
29877
  }
29864
29878
  }
@@ -44102,7 +44116,7 @@ function cutPoint(src, start, end, scratch) {
44102
44116
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
44103
44117
  return { end: start + r.read, written: r.written };
44104
44118
  }
44105
- function merge4(src, blocks, join24, cap, lineCut) {
44119
+ function merge4(src, blocks, join26, cap, lineCut) {
44106
44120
  const out = [];
44107
44121
  const scratch = new Uint8Array(cap);
44108
44122
  let wide;
@@ -44112,7 +44126,7 @@ function merge4(src, blocks, join24, cap, lineCut) {
44112
44126
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
44113
44127
  };
44114
44128
  for (const b of blocks) {
44115
- if (cur !== void 0 && !join24) {
44129
+ if (cur !== void 0 && !join26) {
44116
44130
  emit(cur.start, cur.end, curBytes);
44117
44131
  cur = void 0;
44118
44132
  }
@@ -44248,22 +44262,34 @@ function fileNames(name, pathExt) {
44248
44262
  if (!isWin() || path.extname(name) !== "") return [name];
44249
44263
  return [...pathExt.map((ext) => name + ext), name];
44250
44264
  }
44251
- function isRunnable(full) {
44252
- const st = statSync2(full, { throwIfNoEntry: false });
44253
- if (st === void 0 || !st.isFile()) return false;
44265
+ function probe(full) {
44266
+ let st;
44267
+ try {
44268
+ st = statSync2(full, { throwIfNoEntry: false });
44269
+ } catch {
44270
+ return "unreadable";
44271
+ }
44272
+ if (st === void 0 || !st.isFile()) return "absent";
44254
44273
  if (isWin()) {
44255
44274
  const ext = path.extname(full).toLowerCase();
44256
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
44275
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
44257
44276
  }
44258
44277
  try {
44259
44278
  accessSync(full, fsConstants.X_OK);
44260
- return true;
44279
+ return "runnable";
44261
44280
  } catch {
44262
- return false;
44281
+ return "absent";
44263
44282
  }
44264
44283
  }
44284
+ function isRunnable(full) {
44285
+ return probe(full) === "runnable";
44286
+ }
44265
44287
  function findRuntime(lang, env = process.env) {
44266
- if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
44288
+ return lookupRuntime(lang, env).found;
44289
+ }
44290
+ function lookupRuntime(lang, env = process.env) {
44291
+ const unreadable = [];
44292
+ if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
44267
44293
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
44268
44294
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
44269
44295
  const names = candidates(lang);
@@ -44272,13 +44298,15 @@ function findRuntime(lang, env = process.env) {
44272
44298
  for (const name of names) {
44273
44299
  for (const file2 of fileNames(name, pathExt)) {
44274
44300
  const full = path.join(dir, file2);
44275
- if (!isRunnable(full)) continue;
44276
- if (!isWin() || path.extname(full) !== "") return full;
44301
+ const state = probe(full);
44302
+ if (state === "unreadable") unreadable.push(full);
44303
+ if (state !== "runnable") continue;
44304
+ if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
44277
44305
  if (shim === null) shim = full;
44278
44306
  }
44279
44307
  }
44280
44308
  }
44281
- return shim;
44309
+ return { found: shim, unreadable };
44282
44310
  }
44283
44311
  function findGitBash(env) {
44284
44312
  const git2 = findRuntime(GIT_BIN, env);
@@ -44358,7 +44386,7 @@ function runProcess(argv, o) {
44358
44386
  let stopTimer;
44359
44387
  const kill = () => {
44360
44388
  if (child.pid !== void 0) killTree(child.pid);
44361
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
44389
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
44362
44390
  };
44363
44391
  const onAbort = () => {
44364
44392
  if (killedBy !== null || settled) return;
@@ -44387,15 +44415,21 @@ function runProcess(argv, o) {
44387
44415
  ...held ? { held: true } : {}
44388
44416
  });
44389
44417
  };
44390
- const finishHeld = () => {
44418
+ const finishHeld = (force = false) => {
44391
44419
  if (settled) return;
44392
- held = exited && killedBy === null;
44393
- child.stdout.destroy();
44394
- child.stderr.destroy();
44395
- if (child.pid !== void 0) killTree(child.pid);
44396
- settle3(child.exitCode);
44420
+ const seen = chunkCount;
44421
+ setImmediate(() => {
44422
+ if (settled || !force && chunkCount !== seen) return;
44423
+ held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
44424
+ child.stdout.destroy();
44425
+ child.stderr.destroy();
44426
+ if (child.pid !== void 0) killTree(child.pid);
44427
+ settle3(child.exitCode);
44428
+ });
44397
44429
  };
44430
+ let chunkCount = 0;
44398
44431
  const bump = () => {
44432
+ chunkCount++;
44399
44433
  if (!exited || settled) return;
44400
44434
  clearTimeout(graceTimer);
44401
44435
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -44413,7 +44447,7 @@ function runProcess(argv, o) {
44413
44447
  if (settled) return;
44414
44448
  exited = true;
44415
44449
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
44416
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
44450
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
44417
44451
  });
44418
44452
  child.on("error", () => settle3(null));
44419
44453
  child.stdin.on("error", () => {
@@ -45089,8 +45123,8 @@ var ctxBatch = Object.freeze({
45089
45123
  });
45090
45124
 
45091
45125
  // src/core/tools/doctor.ts
45092
- import { readdirSync as readdirSync8, readFileSync as readFileSync13, existsSync as existsSync17 } from "node:fs";
45093
- import { basename as basename5, join as join17 } from "node:path";
45126
+ import { readdirSync as readdirSync8, readFileSync as readFileSync14, existsSync as existsSync18 } from "node:fs";
45127
+ import { basename as basename5, join as join18 } from "node:path";
45094
45128
 
45095
45129
  // src/adapters/claude-code.ts
45096
45130
  var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
@@ -45812,6 +45846,9 @@ function readResult6(p) {
45812
45846
  if (p.keep === true) info.keep = true;
45813
45847
  return info;
45814
45848
  }
45849
+ function decodeOmp(raw) {
45850
+ return { ...decode11(raw), agent: "omp" };
45851
+ }
45815
45852
  function decode11(raw) {
45816
45853
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
45817
45854
  const p = raw;
@@ -46113,10 +46150,32 @@ var ADAPTERS = Object.freeze([
46113
46150
  decode: decode12,
46114
46151
  encode: encode12,
46115
46152
  toCanonicalTool
46153
+ },
46154
+ {
46155
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
46156
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
46157
+ id: "omp",
46158
+ installMode: "in-process",
46159
+ projectSource: "pi:ctx.cwd",
46160
+ toolNamePrefix: TOOL_NAME_PREFIX9,
46161
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
46162
+ execReadOnlyHint: false,
46163
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
46164
+ compactDelivery: "pi-flag",
46165
+ compactSummary: "none",
46166
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
46167
+ denyChannel: "deny-reason",
46168
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
46169
+ skillChannel: { kind: "package", path: "skills" },
46170
+ // D-OMP-SKILLS-1
46171
+ decode: decodeOmp,
46172
+ encode: encode11,
46173
+ checkPermission
46174
+ // D-OMP-FIRE-1: agent omp in rows
46116
46175
  }
46117
46176
  ]);
46118
46177
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
46119
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
46178
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
46120
46179
  function hasReplace(row5) {
46121
46180
  return REPLACE_ROWS.has(row5.id);
46122
46181
  }
@@ -46147,8 +46206,8 @@ function ownBundleDir() {
46147
46206
  }
46148
46207
 
46149
46208
  // src/core/ops/doctor-config.ts
46150
- import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "node:fs";
46151
- import { dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
46209
+ import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync11 } from "node:fs";
46210
+ import { dirname as dirname7, isAbsolute as isAbsolute4, join as join13, resolve as resolve4 } from "node:path";
46152
46211
 
46153
46212
  // src/core/ops/host-text.ts
46154
46213
  var BOM_CODE = 65279;
@@ -49160,6 +49219,14 @@ function configEntryRoot(adapter, env) {
49160
49219
  if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
49161
49220
  return dirname6(script);
49162
49221
  }
49222
+ function packageDirOf(dir) {
49223
+ for (let cur = dir; ; ) {
49224
+ if (existsSync8(join10(cur, D1_PACKAGE_FILE))) return cur;
49225
+ const up = dirname6(cur);
49226
+ if (up === cur) return dir;
49227
+ cur = up;
49228
+ }
49229
+ }
49163
49230
  function candidate(adapter, env, worktree) {
49164
49231
  switch (adapter.installMode) {
49165
49232
  case "marketplace":
@@ -49173,7 +49240,7 @@ function candidate(adapter, env, worktree) {
49173
49240
  case "plugin":
49174
49241
  return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
49175
49242
  case "in-process":
49176
- return dirname6(fileURLToPath2(import.meta.url));
49243
+ return packageDirOf(dirname6(fileURLToPath2(import.meta.url)));
49177
49244
  }
49178
49245
  }
49179
49246
  function resolvePluginRoot(adapter, env, worktree) {
@@ -49254,14 +49321,281 @@ function piInstalledIn(env, home, pkgDir, cwd) {
49254
49321
  return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
49255
49322
  }
49256
49323
 
49324
+ // src/core/ops/doctor-env.ts
49325
+ import { existsSync as existsSync10, readFileSync as readFileSync9, realpathSync as realpathSync6 } from "node:fs";
49326
+ import { isAbsolute as isAbsolute3, join as join11, relative as relative2 } from "node:path";
49327
+ function pass(id, detail = DOCTOR_PASS_DETAIL) {
49328
+ return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
49329
+ }
49330
+ function unknown4(id, detail, fixCommand) {
49331
+ return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
49332
+ }
49333
+ function fail(id, detail, fixCommand) {
49334
+ return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
49335
+ }
49336
+ function warn(id, detail, fixCommand) {
49337
+ return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
49338
+ }
49339
+ function bundleVersion(bundleDir2) {
49340
+ try {
49341
+ const v = JSON.parse(readFileSync9(join11(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
49342
+ return typeof v === "string" && v !== "" ? v : void 0;
49343
+ } catch {
49344
+ return void 0;
49345
+ }
49346
+ }
49347
+ function channelOf(version4) {
49348
+ const at = version4.indexOf(D1_PRERELEASE_SEP);
49349
+ if (at < 0) return D1_DEFAULT_TAG;
49350
+ const pre = version4.slice(at + 1);
49351
+ const dot = pre.indexOf(".");
49352
+ const tag = dot < 0 ? pre : pre.slice(0, dot);
49353
+ return tag === "" ? D1_DEFAULT_TAG : tag;
49354
+ }
49355
+ function firstLine2(b) {
49356
+ const text = b.toString("utf8").trim();
49357
+ const nl = text.indexOf("\n");
49358
+ return (nl < 0 ? text : text.slice(0, nl)).trim();
49359
+ }
49360
+ function gitCause(r, timeoutMs) {
49361
+ if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
49362
+ if (r.killed === "cancel") return D1_GIT_CANCEL;
49363
+ if (r.exitCode === null) return D1_GIT_NO_START;
49364
+ return D1_GIT_EXIT(r.exitCode, firstLine2(r.stderr));
49365
+ }
49366
+ function fetchCause(err, timeoutMs) {
49367
+ const name = err instanceof Error ? err.name : "";
49368
+ if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
49369
+ const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
49370
+ const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
49371
+ const msg = cause instanceof Error ? cause.message : String(cause);
49372
+ const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
49373
+ return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
49374
+ }
49375
+ async function npmLatest(url4, tag, signal, timeoutMs) {
49376
+ try {
49377
+ const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
49378
+ if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
49379
+ const body = await res.json();
49380
+ const v = typeof body === "object" && body !== null ? body[tag] : void 0;
49381
+ return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag) };
49382
+ } catch (err) {
49383
+ return { ok: false, cause: fetchCause(err, timeoutMs) };
49384
+ }
49385
+ }
49386
+ function digits(s) {
49387
+ if (s === "") return false;
49388
+ for (const ch of s) if (ch < "0" || ch > "9") return false;
49389
+ return true;
49390
+ }
49391
+ function parseVersion(v) {
49392
+ const at = v.indexOf(D1_PRERELEASE_SEP);
49393
+ const core = (at < 0 ? v : v.slice(0, at)).split(NODE_VERSION_SEP);
49394
+ if (core.length !== 3 || !core.every(digits)) return null;
49395
+ const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
49396
+ if (at < 0) return { core: nums, pre: [] };
49397
+ const pre = v.slice(at + 1).split(NODE_VERSION_SEP);
49398
+ if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
49399
+ if (pre.length === 1) return { core: nums, pre: [pre[0]] };
49400
+ return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
49401
+ }
49402
+ function sign(n) {
49403
+ return n < 0 ? -1 : n > 0 ? 1 : 0;
49404
+ }
49405
+ function compareVersions(a, b) {
49406
+ const x = parseVersion(a);
49407
+ const y = parseVersion(b);
49408
+ if (x === null || y === null) return null;
49409
+ for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
49410
+ if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
49411
+ if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
49412
+ return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
49413
+ }
49414
+ function highestTag(stdout, tag) {
49415
+ let best;
49416
+ for (const line of stdout.split("\n")) {
49417
+ const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
49418
+ if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
49419
+ const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
49420
+ if (parseVersion(v) === null || channelOf(v) !== tag) continue;
49421
+ if (best === void 0 || compareVersions(v, best) === 1) best = v;
49422
+ }
49423
+ return best;
49424
+ }
49425
+ function versionRow(head, installed, tag, source, latest, tail, update) {
49426
+ const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
49427
+ if (cmp === 0) return pass("D1", head + D1_LATEST_PASS(tag, source) + tail);
49428
+ if (cmp > 0) return pass("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
49429
+ return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
49430
+ }
49431
+ async function checkVersion(i) {
49432
+ if (i.bundleSha === void 0) return unknown4("D1", D1_DEV_BUILD_DETAIL);
49433
+ const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
49434
+ if (i.version === void 0) return unknown4("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
49435
+ const tag = channelOf(i.version);
49436
+ const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
49437
+ const git2 = findRuntime(GIT_BIN, i.env);
49438
+ const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
49439
+ if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
49440
+ let cause = D1_GIT_MISSING;
49441
+ if (git2 !== null) {
49442
+ const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
49443
+ cwd: i.cwd,
49444
+ env: { ...i.env, ...GIT_NO_PROMPT_ENV },
49445
+ signal: i.signal,
49446
+ timeoutMs: i.timeoutMs
49447
+ });
49448
+ if (r.exitCode === 0 && r.killed === null) {
49449
+ const latest = highestTag(r.stdout.toString("utf8"), tag);
49450
+ if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
49451
+ cause = D1_GIT_NO_TAG(tag);
49452
+ } else {
49453
+ cause = gitCause(r, i.timeoutMs);
49454
+ }
49455
+ }
49456
+ return unknown4("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
49457
+ }
49458
+ function numbers(v) {
49459
+ const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
49460
+ return bare2.split(NODE_VERSION_SEP).map(Number);
49461
+ }
49462
+ function belowMin(version4) {
49463
+ const got = numbers(version4);
49464
+ const min = numbers(NODE_MIN);
49465
+ for (let k = 0; k < min.length; k++) {
49466
+ const g = got[k] ?? 0;
49467
+ if (g !== min[k]) return g < min[k];
49468
+ }
49469
+ return false;
49470
+ }
49471
+ async function sqliteLoads() {
49472
+ try {
49473
+ await import(SQLITE_MODULE);
49474
+ return true;
49475
+ } catch {
49476
+ return false;
49477
+ }
49478
+ }
49479
+ async function checkNode(i) {
49480
+ const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
49481
+ const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
49482
+ if (belowMin(i.nodeVersion)) return fail("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
49483
+ if (!await sqliteLoads()) return fail("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
49484
+ return pass("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
49485
+ }
49486
+ function checkMcp(ctx, adapter) {
49487
+ const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
49488
+ const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
49489
+ if (named2 || versioned) return pass("D6");
49490
+ return adapter?.installMode === "in-process" ? pass("D6", D6_IN_PROCESS_DETAIL) : unknown4("D6", D6_UNKNOWN_DETAIL);
49491
+ }
49492
+ function piCwdInside(worktree, piCwd) {
49493
+ if (piCwd === void 0 || !existsSync10(piCwd)) return false;
49494
+ const rel = relative2(worktree, realpathSync6.native(piCwd));
49495
+ return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
49496
+ }
49497
+ function checkProject(i) {
49498
+ const bad = fail("D7", D7_DETAIL(i.project.source), D7_FIX);
49499
+ if (i.project.source !== i.adapter.projectSource) return bad;
49500
+ if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
49501
+ return pass("D7");
49502
+ }
49503
+ function checkMode(adapter, hostPermission) {
49504
+ if (hostPermission === "missing") return fail("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
49505
+ if (hostPermission === "wired") return pass("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
49506
+ return pass("D10", D10_DETAIL(adapter.denyChannel));
49507
+ }
49508
+ function checkShell(env) {
49509
+ const win = process.platform === "win32";
49510
+ const shell = findRuntime("shell", env);
49511
+ if (shell !== null) return pass("D11", D11_PASS_DETAIL(shell, win));
49512
+ return win ? fail("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
49513
+ }
49514
+ function checkRuntimes(env, shellRow) {
49515
+ if (shellRow.status !== "PASS") return shellRow;
49516
+ for (const lang of EXEC_LANGUAGES) {
49517
+ if (lang === "shell") continue;
49518
+ const r = lookupRuntime(lang, env);
49519
+ if (r.found === null && r.unreadable.length > 0) return warn("D11", D11_RUNTIME_DETAIL(lang, r.unreadable), D11_RUNTIME_FIX(lang));
49520
+ }
49521
+ return shellRow;
49522
+ }
49523
+
49524
+ // src/core/ops/omp-import.ts
49525
+ import { join as join12 } from "node:path";
49526
+ var { existsSync: existsSync11, readFileSync: readFileSync10 } = process.getBuiltinModule("node:fs");
49527
+ var OMP_DISABLED_SERVERS_KEY = "disabledServers";
49528
+ var OMP_MCP_FILE = "mcp.json";
49529
+ var OMP_CONFIG_FILE = "config.yml";
49530
+ var ENABLED_PROVIDERS = "enabledProviders";
49531
+ var DISABLED_PROVIDERS = "disabledProviders";
49532
+ var CLAUDE_PROVIDER = "claude";
49533
+ var ALL_PROVIDERS = ["*", "all"];
49534
+ function ompImportFiles(home) {
49535
+ const agentDir = join12(home, ...AGENT_HOME_DIR.omp, PI_AGENT_DIR);
49536
+ return { config: join12(agentDir, OMP_CONFIG_FILE), mcp: join12(agentDir, OMP_MCP_FILE), claude: join12(home, CLAUDE_USER_CONFIG_FILE) };
49537
+ }
49538
+ function readText2(file2) {
49539
+ try {
49540
+ return existsSync11(file2) ? hostText(readFileSync10(file2, "utf8")) : void 0;
49541
+ } catch {
49542
+ return void 0;
49543
+ }
49544
+ }
49545
+ var unquote = (s) => {
49546
+ const t = s.trim();
49547
+ const q = t[0];
49548
+ return (q === '"' || q === "'") && t.endsWith(q) && t.length > 1 ? t.slice(1, -1) : t;
49549
+ };
49550
+ var withoutComment = (s) => {
49551
+ const at = s.indexOf(" #");
49552
+ return at === -1 ? s : s.slice(0, at);
49553
+ };
49554
+ function yamlTopList(text, key) {
49555
+ const lines = text.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
49556
+ const head = `${key}:`;
49557
+ const at = lines.findIndex((l) => l.startsWith(head));
49558
+ if (at === -1) return [];
49559
+ const rest = withoutComment(lines[at].slice(head.length)).trim();
49560
+ if (rest.startsWith("[")) {
49561
+ const end = rest.indexOf("]");
49562
+ return (end === -1 ? rest.slice(1) : rest.slice(1, end)).split(",").map(unquote).filter((x) => x !== "");
49563
+ }
49564
+ if (rest !== "") return [];
49565
+ const out = [];
49566
+ for (const line of lines.slice(at + 1)) {
49567
+ const t = line.trim();
49568
+ if (t === "" || t.startsWith("#")) continue;
49569
+ if (line === line.trimStart() && !t.startsWith("-")) break;
49570
+ if (!t.startsWith("-")) break;
49571
+ out.push(unquote(withoutComment(t.slice(1))));
49572
+ }
49573
+ return out;
49574
+ }
49575
+ function ompImportsUs(files, env) {
49576
+ const config4 = readText2(files.config) ?? "";
49577
+ if (yamlTopList(config4, DISABLED_PROVIDERS).includes(CLAUDE_PROVIDER)) return false;
49578
+ const enabled = yamlTopList(config4, ENABLED_PROVIDERS);
49579
+ const dirSet = env[CLAUDE_CONFIG_DIR_ENV] !== void 0 && env[CLAUDE_CONFIG_DIR_ENV] !== "";
49580
+ if (!dirSet && !enabled.some((p) => p === CLAUDE_PROVIDER || ALL_PROVIDERS.includes(p))) return false;
49581
+ const claude = readText2(files.claude);
49582
+ if (claude === void 0) return false;
49583
+ try {
49584
+ const servers = JSON.parse(claude)[MCP_SERVERS_KEY];
49585
+ return typeof servers === "object" && servers !== null && Object.hasOwn(servers, SERVER_KEY);
49586
+ } catch {
49587
+ return false;
49588
+ }
49589
+ }
49590
+
49257
49591
  // src/core/ops/doctor-config.ts
49258
49592
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
49259
49593
  var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
49260
49594
  var list = (v) => Array.isArray(v) ? v : [];
49261
- function pass(id) {
49595
+ function pass2(id) {
49262
49596
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail: DOCTOR_PASS_DETAIL };
49263
49597
  }
49264
- function fail(id, detail, fixCommand) {
49598
+ function fail2(id, detail, fixCommand) {
49265
49599
  return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
49266
49600
  }
49267
49601
  function readParsed(agent, file2) {
@@ -49331,11 +49665,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
49331
49665
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
49332
49666
  function mcpFile(row5, home, env) {
49333
49667
  const spec = OWN_MCP_ENTRY[row5.id];
49334
- if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
49668
+ if (row5.id === "codex") return join13(codexDirOf(env, home), CONFIG_TOML_FILE);
49335
49669
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
49336
- if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
49670
+ if (row5.id === "opencode") return join13(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
49337
49671
  if (row5.id === "pi") {
49338
- return join11(piAgentDirOf(env, home), SETTINGS_FILE);
49672
+ return join13(piAgentDirOf(env, home), SETTINGS_FILE);
49339
49673
  }
49340
49674
  return null;
49341
49675
  }
@@ -49348,27 +49682,27 @@ function codexNativeDir(env, home) {
49348
49682
  const codexDir = codexDirOf(env, home);
49349
49683
  let enabled;
49350
49684
  try {
49351
- enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
49685
+ enabled = hostConfigValueAt(readParsed("codex", join13(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
49352
49686
  } catch {
49353
49687
  return null;
49354
49688
  }
49355
49689
  if (enabled !== true) return null;
49356
- const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
49357
- if (!existsSync10(cache)) return null;
49690
+ const cache = join13(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
49691
+ if (!existsSync12(cache)) return null;
49358
49692
  const found = [];
49359
49693
  for (const market of readdirSync7(cache)) {
49360
- const plugin = join11(cache, market, SERVER_KEY);
49361
- if (!existsSync10(plugin)) continue;
49694
+ const plugin = join13(cache, market, SERVER_KEY);
49695
+ if (!existsSync12(plugin)) continue;
49362
49696
  for (const version4 of readdirSync7(plugin).sort()) {
49363
- const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
49364
- if (existsSync10(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
49697
+ const dir = join13(plugin, version4, CODEX_PLUGIN_SUBDIR);
49698
+ if (existsSync12(join13(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
49365
49699
  }
49366
49700
  }
49367
49701
  return found.length === 0 ? null : found[found.length - 1];
49368
49702
  }
49369
49703
  function nativeMcpWrong(dir, row5) {
49370
49704
  try {
49371
- const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
49705
+ const entry = hostConfigValueAt(readParsed(row5.id, join13(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
49372
49706
  if (!isObject4(entry)) return true;
49373
49707
  const args = list(entry[MCP_ARGS_FIELD]);
49374
49708
  const script = args[0];
@@ -49439,17 +49773,17 @@ function opencodePluginDirs(configDir, worktree) {
49439
49773
  return [configDir, opencodeProjectDir(worktree)];
49440
49774
  }
49441
49775
  function opencodeProjectDir(worktree) {
49442
- return join11(worktree, OPENCODE_PROJECT_DIR);
49776
+ return join13(worktree, OPENCODE_PROJECT_DIR);
49443
49777
  }
49444
49778
  function packageResolves(fromDir) {
49445
49779
  for (let d = fromDir; ; d = dirname7(d)) {
49446
- if (existsSync10(join11(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
49780
+ if (existsSync12(join13(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
49447
49781
  if (dirname7(d) === d) return false;
49448
49782
  }
49449
49783
  }
49450
49784
  function opencodeDirPlugins(dirs) {
49451
49785
  const bundle = opencodePluginFile();
49452
- const ownFile = join11(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
49786
+ const ownFile = join13(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
49453
49787
  const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
49454
49788
  const isPath = (p) => {
49455
49789
  if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -49459,7 +49793,7 @@ function opencodeDirPlugins(dirs) {
49459
49793
  };
49460
49794
  const out = [];
49461
49795
  for (const dir of dirs) {
49462
- const pdir = join11(dir, OPENCODE_PLUGINS_DIR);
49796
+ const pdir = join13(dir, OPENCODE_PLUGINS_DIR);
49463
49797
  let names;
49464
49798
  try {
49465
49799
  names = readdirSync7(pdir);
@@ -49467,12 +49801,12 @@ function opencodeDirPlugins(dirs) {
49467
49801
  continue;
49468
49802
  }
49469
49803
  for (const name of names) {
49470
- const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join11(pdir, name)] : [];
49471
- const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join11(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
49804
+ const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join13(pdir, name)] : [];
49805
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join13(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
49472
49806
  for (const f of files) {
49473
49807
  let text;
49474
49808
  try {
49475
- const b = readFileSync9(f);
49809
+ const b = readFileSync11(f);
49476
49810
  if (b.length > OPENCODE_DIR_FILE_MAX) continue;
49477
49811
  text = b.toString("utf8");
49478
49812
  } catch {
@@ -49483,7 +49817,7 @@ function opencodeDirPlugins(dirs) {
49483
49817
  const loads = lits.some((p) => {
49484
49818
  if (isModule(p)) return packageResolves(dirname7(f));
49485
49819
  const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
49486
- return existsSync10(isAbsolute3(bare2) ? bare2 : resolve4(dirname7(f), bare2));
49820
+ return existsSync12(isAbsolute4(bare2) ? bare2 : resolve4(dirname7(f), bare2));
49487
49821
  });
49488
49822
  out.push({ file: f, loads });
49489
49823
  }
@@ -49501,19 +49835,19 @@ function opencodeMcpOwn(entry) {
49501
49835
  return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
49502
49836
  }
49503
49837
  function opencodeFileValue(file2) {
49504
- if (!existsSync10(file2)) return {};
49505
- return parseHostConfig("opencode", file2, hostText(readFileSync9(file2, "utf8")), "jsonc");
49838
+ if (!existsSync12(file2)) return {};
49839
+ return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
49506
49840
  }
49507
49841
  function opencodeValueListed(value) {
49508
49842
  const bundle = opencodePluginFile();
49509
- const own4 = [bundle, join11(bundle, ...OPENCODE_PLUGIN_PATH)];
49843
+ const own4 = [bundle, join13(bundle, ...OPENCODE_PLUGIN_PATH)];
49510
49844
  if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
49511
49845
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
49512
49846
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
49513
49847
  }
49514
49848
  function opencodeListed(file2, worktree) {
49515
49849
  const dirs = [dirname7(file2), worktree];
49516
- if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join11(dir, name)))))) return true;
49850
+ if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join13(dir, name)))))) return true;
49517
49851
  return opencodeDirPlugin(opencodePluginDirs(dirname7(file2), worktree)) !== void 0;
49518
49852
  }
49519
49853
  function mcpWrong(row5, home, env, worktree) {
@@ -49535,7 +49869,7 @@ function mcpWrong(row5, home, env, worktree) {
49535
49869
  function hookFile(row5, spec, home, env, worktree) {
49536
49870
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
49537
49871
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
49538
- const file2 = native !== null ? join11(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join11(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join11(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join11(kiroDirOf(env, home), ...spec.file.slice(1)) : join11(root, ...spec.file);
49872
+ const file2 = native !== null ? join13(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join13(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join13(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join13(kiroDirOf(env, home), ...spec.file.slice(1)) : join13(root, ...spec.file);
49539
49873
  return file2;
49540
49874
  }
49541
49875
  function hookParts(row5, home, env, worktree) {
@@ -49546,7 +49880,7 @@ function hookParts(row5, home, env, worktree) {
49546
49880
  const file2 = hookFile(row5, spec, home, env, worktree);
49547
49881
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
49548
49882
  if (row5.id === "codex") {
49549
- const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
49883
+ const config4 = readParsed(row5.id, join13(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
49550
49884
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
49551
49885
  }
49552
49886
  } catch {
@@ -49575,29 +49909,67 @@ function hookParts(row5, home, env, worktree) {
49575
49909
  }
49576
49910
  function checkHostConfig(row5, env, worktree) {
49577
49911
  const home = homeDirOf(env);
49578
- if (home === null) return fail("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
49912
+ if (home === null) return fail2("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
49579
49913
  if (row5.installMode === "marketplace") {
49580
49914
  const choice = marketplaceChoice(env, worktree);
49581
- if ("installs" in choice) return fail("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
49915
+ if ("installs" in choice) return fail2("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
49582
49916
  }
49583
49917
  if (row5.id === "pi") return checkPiInstall(env, home, worktree);
49918
+ if (row5.id === "omp") return checkOmpInstall(home);
49584
49919
  const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
49585
- if (parts.length === 0) return pass("D3");
49920
+ if (parts.length === 0) return pass2("D3");
49586
49921
  const detail = D3_DETAIL(parts);
49587
49922
  const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
49588
- return fail("D3", detail, fix);
49923
+ return fail2("D3", detail, fix);
49589
49924
  }
49590
49925
  function checkPiInstall(env, home, worktree) {
49591
49926
  const found = piInstalledIn(env, home, ownBundleDir(), worktree);
49592
- if (found !== void 0) return { ...pass("D3"), detail: found };
49593
- return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join11(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
49927
+ if (found !== void 0) return { ...pass2("D3"), detail: found };
49928
+ return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join13(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
49929
+ }
49930
+ var OMP_PLUGINS_DIR = "plugins";
49931
+ var OMP_LOCK_FILE = "omp-plugins.lock.json";
49932
+ function readJson2(file2) {
49933
+ try {
49934
+ const doc = JSON.parse(readFileSync11(file2, "utf8"));
49935
+ return typeof doc === "object" && doc !== null ? doc : void 0;
49936
+ } catch {
49937
+ return void 0;
49938
+ }
49939
+ }
49940
+ function ownEntry(doc, key) {
49941
+ const map2 = doc?.[key];
49942
+ return typeof map2 === "object" && map2 !== null ? map2[SERVER_KEY] : void 0;
49943
+ }
49944
+ function checkOmpInstall(home) {
49945
+ const dir = join13(home, ...AGENT_HOME_DIR.omp, OMP_PLUGINS_DIR);
49946
+ const lock = join13(dir, OMP_LOCK_FILE);
49947
+ const pkg = join13(dir, PI_PACKAGE_JSON_FILE);
49948
+ const entry = ownEntry(readJson2(lock), "plugins");
49949
+ const missing2 = (file2) => fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + file2, NATIVE_INSTALL.omp[0]);
49950
+ if (typeof entry !== "object" || entry === null) return missing2(lock);
49951
+ if (ownEntry(readJson2(pkg), "dependencies") === void 0) return missing2(pkg);
49952
+ if (entry.enabled !== true) return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + lock, OMP_ENABLE_COMMAND);
49953
+ return { ...pass2("D3"), detail: lock };
49954
+ }
49955
+ function ompInfoLines(env, version4) {
49956
+ const out = [];
49957
+ if (version4 !== void 0 && compareVersions(version4, OMP_MIN_VERSION) === -1) out.push(OMP_FLOOR_INFO(version4));
49958
+ out.push(OMP_CONTENT_INFO, OMP_PRINT_MODE_INFO, OMP_SCRIPTS_INFO);
49959
+ const home = homeDirOf(env);
49960
+ if (home === null) return out;
49961
+ const files = ompImportFiles(home);
49962
+ if (!ompImportsUs(files, env)) return out;
49963
+ const listed = readJson2(files.mcp)?.[OMP_DISABLED_SERVERS_KEY];
49964
+ if (!(Array.isArray(listed) && listed.includes(SERVER_KEY))) out.push(OMP_IMPORT_INFO(files.claude, files.mcp));
49965
+ return out;
49594
49966
  }
49595
49967
  function checkV1Leftovers(agent, home, scope = {}) {
49596
49968
  const findings = detectV1(agent, home, scope);
49597
- if (findings.length === 0) return pass("D4");
49969
+ if (findings.length === 0) return pass2("D4");
49598
49970
  const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
49599
- if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
49600
- return { ...fail("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
49971
+ if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass2("D4"), detail };
49972
+ return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
49601
49973
  }
49602
49974
  function parsedOrNull(agent, file2, jsonc) {
49603
49975
  try {
@@ -49608,13 +49980,13 @@ function parsedOrNull(agent, file2, jsonc) {
49608
49980
  }
49609
49981
  }
49610
49982
  function checkDoubleFire(agent, worktree) {
49611
- if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
49612
- const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
49983
+ if (agent !== "claude-code" && agent !== "vscode") return pass2("D5b");
49984
+ const claude = parsedOrNull(agent, join13(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
49613
49985
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
49614
49986
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
49615
- const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
49987
+ const vscode = parsedOrNull(agent, join13(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
49616
49988
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
49617
- return hooksOn && useClaudeHooks ? fail("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
49989
+ return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass2("D5b");
49618
49990
  }
49619
49991
  function configPaths(row5, env, worktree) {
49620
49992
  const home = homeDirOf(env);
@@ -49623,7 +49995,7 @@ function configPaths(row5, env, worktree) {
49623
49995
  const mcp = mcpFile(row5, home, env);
49624
49996
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
49625
49997
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
49626
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
49998
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join13(native, CODEX_PLUGIN_MCP_FILE) });
49627
49999
  const spec = HOOK_HOST_FILE[row5.id];
49628
50000
  if (spec !== null) {
49629
50001
  try {
@@ -49643,10 +50015,10 @@ function configPaths(row5, env, worktree) {
49643
50015
  }
49644
50016
 
49645
50017
  // src/core/ops/doctor-db.ts
49646
- import { existsSync as existsSync11, statSync as statSync4 } from "node:fs";
49647
- var unknown4 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
49648
- var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
49649
- var fail2 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
50018
+ import { existsSync as existsSync13, statSync as statSync4 } from "node:fs";
50019
+ var unknown5 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
50020
+ var pass3 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
50021
+ var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
49650
50022
  function isCorrupt2(err) {
49651
50023
  if (typeof err !== "object" || err === null) return false;
49652
50024
  const code = err.errcode;
@@ -49685,17 +50057,17 @@ function orphanFiles(dbPath) {
49685
50057
  const files = [];
49686
50058
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
49687
50059
  const path8 = dbPath + suffix;
49688
- if (existsSync11(path8)) files.push({ path: path8, bytes: statSync4(path8).size });
50060
+ if (existsSync13(path8)) files.push({ path: path8, bytes: statSync4(path8).size });
49689
50061
  }
49690
- return files.length > 0 && !existsSync11(dbPath) ? files : [];
50062
+ return files.length > 0 && !existsSync13(dbPath) ? files : [];
49691
50063
  }
49692
50064
  async function checkDb(project) {
49693
50065
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
49694
50066
  const orphan = orphanFiles(project.dbPath);
49695
- if (orphan.length > 0) return { row: fail2(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
49696
- if (!existsSync11(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
50067
+ if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
50068
+ if (!existsSync13(project.dbPath)) return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
49697
50069
  const sqlite = await loadSqlite2();
49698
- if (sqlite === null) return { row: unknown4("D8", D2_SQLITE_DETAIL), ...clean };
50070
+ if (sqlite === null) return { row: unknown5("D8", D2_SQLITE_DETAIL), ...clean };
49699
50071
  let raw = null;
49700
50072
  try {
49701
50073
  raw = openRead(sqlite, project.dbPath);
@@ -49708,226 +50080,35 @@ async function checkDb(project) {
49708
50080
  }
49709
50081
  const schemaStale = got !== null && got !== SCHEMA_VERSION;
49710
50082
  const integrityFailed = failsOnCorrupt(() => !integrityOk(db));
49711
- if (integrityFailed) return { row: fail2(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
49712
- if (schemaStale && got !== null) return { row: fail2(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
49713
- return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
50083
+ if (integrityFailed) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
50084
+ if (schemaStale && got !== null) return { row: fail3(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
50085
+ return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
49714
50086
  } catch (err) {
49715
- if (isCorrupt2(err)) return { row: fail2(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
49716
- return { row: unknown4("D8", message(err)), ...clean };
50087
+ if (isCorrupt2(err)) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
50088
+ return { row: unknown5("D8", message(err)), ...clean };
49717
50089
  } finally {
49718
50090
  raw?.close();
49719
50091
  }
49720
50092
  }
49721
50093
  async function checkIndex(project) {
49722
- if (!existsSync11(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
50094
+ if (!existsSync13(project.dbPath)) return pass3("D9", D9_INDEX_DETAIL(0, 0));
49723
50095
  const sqlite = await loadSqlite2();
49724
- if (sqlite === null) return unknown4("D9", D2_SQLITE_DETAIL);
50096
+ if (sqlite === null) return unknown5("D9", D2_SQLITE_DETAIL);
49725
50097
  let raw = null;
49726
50098
  try {
49727
50099
  raw = openRead(sqlite, project.dbPath);
49728
50100
  const sources = Number(cell(raw.prepare("SELECT count(*) FROM sources").get()));
49729
50101
  const chunks = Number(cell(raw.prepare("SELECT count(*) FROM chunks").get()));
49730
- return pass2("D9", D9_INDEX_DETAIL(sources, chunks));
50102
+ return pass3("D9", D9_INDEX_DETAIL(sources, chunks));
49731
50103
  } catch (err) {
49732
- return unknown4("D9", message(err));
50104
+ return unknown5("D9", message(err));
49733
50105
  } finally {
49734
50106
  raw?.close();
49735
50107
  }
49736
50108
  }
49737
50109
 
49738
- // src/core/ops/doctor-env.ts
49739
- import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
49740
- import { isAbsolute as isAbsolute4, join as join12, relative as relative2 } from "node:path";
49741
- function pass3(id, detail = DOCTOR_PASS_DETAIL) {
49742
- return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
49743
- }
49744
- function unknown5(id, detail, fixCommand) {
49745
- return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
49746
- }
49747
- function fail3(id, detail, fixCommand) {
49748
- return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
49749
- }
49750
- function warn(id, detail, fixCommand) {
49751
- return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
49752
- }
49753
- function bundleVersion(bundleDir2) {
49754
- try {
49755
- const v = JSON.parse(readFileSync10(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
49756
- return typeof v === "string" && v !== "" ? v : void 0;
49757
- } catch {
49758
- return void 0;
49759
- }
49760
- }
49761
- function channelOf(version4) {
49762
- const at = version4.indexOf(D1_PRERELEASE_SEP);
49763
- if (at < 0) return D1_DEFAULT_TAG;
49764
- const pre = version4.slice(at + 1);
49765
- const dot = pre.indexOf(".");
49766
- const tag = dot < 0 ? pre : pre.slice(0, dot);
49767
- return tag === "" ? D1_DEFAULT_TAG : tag;
49768
- }
49769
- function firstLine2(b) {
49770
- const text = b.toString("utf8").trim();
49771
- const nl = text.indexOf("\n");
49772
- return (nl < 0 ? text : text.slice(0, nl)).trim();
49773
- }
49774
- function gitCause(r, timeoutMs) {
49775
- if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
49776
- if (r.killed === "cancel") return D1_GIT_CANCEL;
49777
- if (r.exitCode === null) return D1_GIT_NO_START;
49778
- return D1_GIT_EXIT(r.exitCode, firstLine2(r.stderr));
49779
- }
49780
- function fetchCause(err, timeoutMs) {
49781
- const name = err instanceof Error ? err.name : "";
49782
- if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
49783
- const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
49784
- const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
49785
- const msg = cause instanceof Error ? cause.message : String(cause);
49786
- const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
49787
- return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
49788
- }
49789
- async function npmLatest(url4, tag, signal, timeoutMs) {
49790
- try {
49791
- const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
49792
- if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
49793
- const body = await res.json();
49794
- const v = typeof body === "object" && body !== null ? body[tag] : void 0;
49795
- return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag) };
49796
- } catch (err) {
49797
- return { ok: false, cause: fetchCause(err, timeoutMs) };
49798
- }
49799
- }
49800
- function digits(s) {
49801
- if (s === "") return false;
49802
- for (const ch of s) if (ch < "0" || ch > "9") return false;
49803
- return true;
49804
- }
49805
- function parseVersion(v) {
49806
- const at = v.indexOf(D1_PRERELEASE_SEP);
49807
- const core = (at < 0 ? v : v.slice(0, at)).split(NODE_VERSION_SEP);
49808
- if (core.length !== 3 || !core.every(digits)) return null;
49809
- const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
49810
- if (at < 0) return { core: nums, pre: [] };
49811
- const pre = v.slice(at + 1).split(NODE_VERSION_SEP);
49812
- if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
49813
- if (pre.length === 1) return { core: nums, pre: [pre[0]] };
49814
- return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
49815
- }
49816
- function sign(n) {
49817
- return n < 0 ? -1 : n > 0 ? 1 : 0;
49818
- }
49819
- function compareVersions(a, b) {
49820
- const x = parseVersion(a);
49821
- const y = parseVersion(b);
49822
- if (x === null || y === null) return null;
49823
- for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
49824
- if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
49825
- if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
49826
- return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
49827
- }
49828
- function highestTag(stdout, tag) {
49829
- let best;
49830
- for (const line of stdout.split("\n")) {
49831
- const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
49832
- if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
49833
- const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
49834
- if (parseVersion(v) === null || channelOf(v) !== tag) continue;
49835
- if (best === void 0 || compareVersions(v, best) === 1) best = v;
49836
- }
49837
- return best;
49838
- }
49839
- function versionRow(head, installed, tag, source, latest, tail, update) {
49840
- const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
49841
- if (cmp === 0) return pass3("D1", head + D1_LATEST_PASS(tag, source) + tail);
49842
- if (cmp > 0) return pass3("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
49843
- return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
49844
- }
49845
- async function checkVersion(i) {
49846
- if (i.bundleSha === void 0) return unknown5("D1", D1_DEV_BUILD_DETAIL);
49847
- const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
49848
- if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
49849
- const tag = channelOf(i.version);
49850
- const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
49851
- const git2 = findRuntime(GIT_BIN, i.env);
49852
- const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
49853
- if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
49854
- let cause = D1_GIT_MISSING;
49855
- if (git2 !== null) {
49856
- const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
49857
- cwd: i.cwd,
49858
- env: { ...i.env, ...GIT_NO_PROMPT_ENV },
49859
- signal: i.signal,
49860
- timeoutMs: i.timeoutMs
49861
- });
49862
- if (r.exitCode === 0 && r.killed === null) {
49863
- const latest = highestTag(r.stdout.toString("utf8"), tag);
49864
- if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
49865
- cause = D1_GIT_NO_TAG(tag);
49866
- } else {
49867
- cause = gitCause(r, i.timeoutMs);
49868
- }
49869
- }
49870
- return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
49871
- }
49872
- function numbers(v) {
49873
- const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
49874
- return bare2.split(NODE_VERSION_SEP).map(Number);
49875
- }
49876
- function belowMin(version4) {
49877
- const got = numbers(version4);
49878
- const min = numbers(NODE_MIN);
49879
- for (let k = 0; k < min.length; k++) {
49880
- const g = got[k] ?? 0;
49881
- if (g !== min[k]) return g < min[k];
49882
- }
49883
- return false;
49884
- }
49885
- async function sqliteLoads() {
49886
- try {
49887
- await import(SQLITE_MODULE);
49888
- return true;
49889
- } catch {
49890
- return false;
49891
- }
49892
- }
49893
- async function checkNode(i) {
49894
- const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
49895
- const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
49896
- if (belowMin(i.nodeVersion)) return fail3("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
49897
- if (!await sqliteLoads()) return fail3("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
49898
- return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
49899
- }
49900
- function checkMcp(ctx, adapter) {
49901
- const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
49902
- const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
49903
- if (named2 || versioned) return pass3("D6");
49904
- return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown5("D6", D6_UNKNOWN_DETAIL);
49905
- }
49906
- function piCwdInside(worktree, piCwd) {
49907
- if (piCwd === void 0 || !existsSync12(piCwd)) return false;
49908
- const rel = relative2(worktree, realpathSync6.native(piCwd));
49909
- return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
49910
- }
49911
- function checkProject(i) {
49912
- const bad = fail3("D7", D7_DETAIL(i.project.source), D7_FIX);
49913
- if (i.project.source !== i.adapter.projectSource) return bad;
49914
- if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
49915
- return pass3("D7");
49916
- }
49917
- function checkMode(adapter, hostPermission) {
49918
- if (hostPermission === "missing") return fail3("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
49919
- if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
49920
- return pass3("D10", D10_DETAIL(adapter.denyChannel));
49921
- }
49922
- function checkShell(env) {
49923
- const win = process.platform === "win32";
49924
- const shell = findRuntime("shell", env);
49925
- if (shell !== null) return pass3("D11", D11_PASS_DETAIL(shell, win));
49926
- return win ? fail3("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail3("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
49927
- }
49928
-
49929
50110
  // src/core/ops/doctor-hook.ts
49930
- import { existsSync as existsSync14, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
50111
+ import { existsSync as existsSync15, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync12, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
49931
50112
  import { tmpdir as tmpdir2 } from "node:os";
49932
50113
  import path7 from "node:path";
49933
50114
 
@@ -51671,7 +51852,9 @@ var HOST_SHAPES = {
51671
51852
  kiro: kiro_default,
51672
51853
  zcode: zcode_default,
51673
51854
  pi: pi_default,
51674
- opencode: opencode_default
51855
+ opencode: opencode_default,
51856
+ omp: pi_default
51857
+ // ADR-0026: OMP reads the Pi extension reply
51675
51858
  };
51676
51859
  var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
51677
51860
  var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
@@ -51753,7 +51936,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
51753
51936
 
51754
51937
  // src/setup/codex-trust.ts
51755
51938
  import { createHash } from "node:crypto";
51756
- import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
51939
+ import { existsSync as existsSync14, realpathSync as realpathSync7 } from "node:fs";
51757
51940
  import path6 from "node:path";
51758
51941
  import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
51759
51942
 
@@ -51976,10 +52159,10 @@ function isObject6(v) {
51976
52159
  }
51977
52160
  function loadFixture(bundleDir2, agent) {
51978
52161
  const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
51979
- if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
52162
+ if (!existsSync15(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
51980
52163
  let all;
51981
52164
  try {
51982
- all = JSON.parse(hostText(readFileSync11(file2, "utf8")));
52165
+ all = JSON.parse(hostText(readFileSync12(file2, "utf8")));
51983
52166
  } catch (err) {
51984
52167
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
51985
52168
  }
@@ -52001,7 +52184,8 @@ var CWD_KEY = {
52001
52184
  kiro: "cwd",
52002
52185
  zcode: "cwd",
52003
52186
  pi: "cwd",
52004
- opencode: "directory"
52187
+ opencode: "directory",
52188
+ omp: "cwd"
52005
52189
  };
52006
52190
  function payloadFor(agent, payload, worktree) {
52007
52191
  return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
@@ -52193,7 +52377,7 @@ async function codexStopDetail(i, timeoutMs) {
52193
52377
  timeoutMs,
52194
52378
  stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
52195
52379
  });
52196
- const logged = existsSync14(path7.join(home, HOOK_ERROR_LOG_FILE));
52380
+ const logged = existsSync15(path7.join(home, HOOK_ERROR_LOG_FILE));
52197
52381
  return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
52198
52382
  } finally {
52199
52383
  rmSync4(home, { recursive: true, force: true });
@@ -52204,7 +52388,7 @@ async function checkHookRoundTrip(i) {
52204
52388
  const trust = await codexPluginTrust(i);
52205
52389
  if (trust !== null) return trust;
52206
52390
  }
52207
- if (i.agent === "codex" && existsSync14(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
52391
+ if (i.agent === "codex" && existsSync15(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
52208
52392
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
52209
52393
  }
52210
52394
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -52253,14 +52437,14 @@ async function checkHookRoundTrip(i) {
52253
52437
  }
52254
52438
 
52255
52439
  // src/core/hooks/fallback.ts
52256
- import { join as join14, resolve as resolve7 } from "node:path";
52440
+ import { join as join15, resolve as resolve7 } from "node:path";
52257
52441
 
52258
52442
  // src/core/policy/read-media.ts
52259
52443
  import { extname } from "node:path";
52260
52444
  var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
52261
52445
 
52262
52446
  // src/core/policy/own-file.ts
52263
- import { extname as extname2, join as join13, resolve as resolve6 } from "node:path";
52447
+ import { extname as extname2, join as join14, resolve as resolve6 } from "node:path";
52264
52448
 
52265
52449
  // src/core/hooks/fallback.ts
52266
52450
  var fs = process.getBuiltinModule("node:fs");
@@ -52269,9 +52453,9 @@ function homeOf(env) {
52269
52453
  }
52270
52454
  function hookLogPath(env) {
52271
52455
  const dir = env[DATA_DIR_ENV];
52272
- if (dir !== void 0 && dir !== "") return join14(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
52456
+ if (dir !== void 0 && dir !== "") return join15(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
52273
52457
  const home = homeOf(env);
52274
- return home === "" ? "" : join14(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
52458
+ return home === "" ? "" : join15(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
52275
52459
  }
52276
52460
  function lastHookError(env) {
52277
52461
  try {
@@ -52301,8 +52485,8 @@ function lastHookError(env) {
52301
52485
  }
52302
52486
 
52303
52487
  // src/core/ops/db-heal.ts
52304
- import { existsSync as existsSync15, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
52305
- import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
52488
+ import { existsSync as existsSync16, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
52489
+ import { basename as basename4, dirname as dirname8, join as join16 } from "node:path";
52306
52490
  function integrityOk2(rows) {
52307
52491
  return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
52308
52492
  }
@@ -52336,7 +52520,7 @@ function renameAside(dbPath) {
52336
52520
  const ts = String(Date.now());
52337
52521
  for (const suffix of DB_SIBLING_SUFFIXES) {
52338
52522
  const file2 = dbPath + suffix;
52339
- if (existsSync15(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
52523
+ if (existsSync16(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
52340
52524
  }
52341
52525
  return ts;
52342
52526
  }
@@ -52359,7 +52543,7 @@ function utcStamp(now) {
52359
52543
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
52360
52544
  }
52361
52545
  function makeOrphanDir(projectDir) {
52362
- const base = join15(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
52546
+ const base = join16(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
52363
52547
  for (let n = 1; ; n += 1) {
52364
52548
  const dir = n === 1 ? base : base + "-" + String(n);
52365
52549
  try {
@@ -52376,7 +52560,7 @@ async function healOrphan(project, files, row5) {
52376
52560
  try {
52377
52561
  dir = makeOrphanDir(dirname8(project.dbPath));
52378
52562
  for (const f of files) {
52379
- const to = join15(dir, basename4(f.path));
52563
+ const to = join16(dir, basename4(f.path));
52380
52564
  renameWithRetry(f.path, to);
52381
52565
  moved.push({ path: to, bytes: f.bytes });
52382
52566
  }
@@ -52474,8 +52658,8 @@ function unsupportedHostOf(sig) {
52474
52658
 
52475
52659
  // src/core/ops/doctor-issue.ts
52476
52660
  import { spawnSync as spawnSync3 } from "node:child_process";
52477
- import { closeSync as closeSync2, existsSync as existsSync16, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync12, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
52478
- import { delimiter, dirname as dirname9, join as join16 } from "node:path";
52661
+ import { closeSync as closeSync2, existsSync as existsSync17, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
52662
+ import { delimiter, dirname as dirname9, join as join17 } from "node:path";
52479
52663
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
52480
52664
  function tildeOf(env) {
52481
52665
  const home = homeDirOf(env);
@@ -52531,8 +52715,8 @@ function onPath(env, tool) {
52531
52715
  const out = [];
52532
52716
  for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
52533
52717
  if (dir === "") continue;
52534
- for (const n of names) if (existsSync16(join16(dir, n))) {
52535
- out.push(join16(dir, n));
52718
+ for (const n of names) if (existsSync17(join17(dir, n))) {
52719
+ out.push(join17(dir, n));
52536
52720
  break;
52537
52721
  }
52538
52722
  }
@@ -52540,7 +52724,7 @@ function onPath(env, tool) {
52540
52724
  }
52541
52725
  function hookLogTail(env) {
52542
52726
  const file2 = hookLogPath(env);
52543
- if (file2 === "" || !existsSync16(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
52727
+ if (file2 === "" || !existsSync17(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
52544
52728
  try {
52545
52729
  const fd = openSync2(file2, "r");
52546
52730
  try {
@@ -52560,7 +52744,7 @@ function hookLogTail(env) {
52560
52744
  }
52561
52745
  async function journalRows(ctx) {
52562
52746
  const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
52563
- if (!existsSync16(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
52747
+ if (!existsSync17(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
52564
52748
  try {
52565
52749
  const db = await openDb(ctx.project, { readOnly: true });
52566
52750
  try {
@@ -52578,21 +52762,21 @@ function agentConfig(adapter, env, worktree) {
52578
52762
  const home = homeDirOf(env);
52579
52763
  const files = configPaths(adapter, env, worktree);
52580
52764
  if (home !== null) {
52581
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join16(claudeDirOf(env, home), SETTINGS_FILE) });
52582
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join16(codexDirOf(env, home), CONFIG_TOML_FILE) });
52765
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join17(claudeDirOf(env, home), SETTINGS_FILE) });
52766
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join17(codexDirOf(env, home), CONFIG_TOML_FILE) });
52583
52767
  }
52584
52768
  const out = [];
52585
52769
  const seen = /* @__PURE__ */ new Set();
52586
52770
  for (const f of files) {
52587
52771
  if (seen.has(f.path)) continue;
52588
52772
  seen.add(f.path);
52589
- if (!existsSync16(f.path)) {
52773
+ if (!existsSync17(f.path)) {
52590
52774
  out.push(`${f.label}: ${f.path} (absent)`);
52591
52775
  continue;
52592
52776
  }
52593
52777
  let text = "";
52594
52778
  try {
52595
- text = readFileSync12(f.path, "utf8");
52779
+ text = readFileSync13(f.path, "utf8");
52596
52780
  } catch (err) {
52597
52781
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
52598
52782
  continue;
@@ -52663,9 +52847,9 @@ async function buildIssueBody(i) {
52663
52847
  async function writeIssueReport(i) {
52664
52848
  const tilde = tildeOf(i.env);
52665
52849
  const body = await buildIssueBody(i);
52666
- const dir = join16(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
52850
+ const dir = join17(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
52667
52851
  mkdirSync7(dir, { recursive: true });
52668
- const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
52852
+ const file2 = join17(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
52669
52853
  writeFileSync4(file2, body);
52670
52854
  const shown2 = tilde(file2);
52671
52855
  const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
@@ -52711,7 +52895,7 @@ async function guard(id, run) {
52711
52895
  }
52712
52896
  }
52713
52897
  async function codexDb(ctx, adapter) {
52714
- if (adapter.id !== "codex" || !existsSync17(ctx.project.dbPath)) return null;
52898
+ if (adapter.id !== "codex" || !existsSync18(ctx.project.dbPath)) return null;
52715
52899
  try {
52716
52900
  return await openDb(ctx.project, { readOnly: true });
52717
52901
  } catch {
@@ -52747,11 +52931,11 @@ async function hookRow(ctx, adapter, host) {
52747
52931
  }
52748
52932
  }
52749
52933
  function ownServerId(configDir, projectKey) {
52750
- const dir = join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
52751
- if (!existsSync17(dir)) return "";
52934
+ const dir = join18(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
52935
+ if (!existsSync18(dir)) return "";
52752
52936
  for (const name of readdirSync8(dir)) {
52753
52937
  if (!name.endsWith(OWNER_PID_EXT)) continue;
52754
- if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
52938
+ if (readFileSync14(join18(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
52755
52939
  }
52756
52940
  return "";
52757
52941
  }
@@ -52781,7 +52965,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
52781
52965
  D9: () => checkIndex(project),
52782
52966
  D10: () => checkMode(adapter, ctx.hostPermission),
52783
52967
  // D-1331-OC-PERM-1
52784
- D11: () => checkShell(env)
52968
+ D11: () => checkRuntimes(env, checkShell(env))
52785
52969
  };
52786
52970
  const rows = [];
52787
52971
  for (const id of DOCTOR_CHECK_ORDER) rows.push(await guard(id, checks[id]));
@@ -52811,7 +52995,7 @@ async function doctorReply(ctx, host) {
52811
52995
  const runtime = runtimeInfo(host.env, ctx.signal);
52812
52996
  const rows = await runDoctorChecks(ctx, adapter, host);
52813
52997
  const failed = rows.some((r) => r.status === "FAIL");
52814
- const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
52998
+ 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}`;
52815
52999
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
52816
53000
  const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
52817
53001
  const table3 = buildReport(input);
@@ -52825,7 +53009,8 @@ async function doctorReply(ctx, host) {
52825
53009
  }
52826
53010
  const look = rows.find((r) => r.status === "FAIL") ?? rows.find((r) => r.status !== "PASS");
52827
53011
  const docs = look === void 0 ? [] : [DOCTOR_DOCS_LABEL + DOCTOR_DOCS_LINK(look.id)];
52828
- const whole2 = [envLine2, table3, ...docs, ...notes].join("\n");
53012
+ const info = adapter.id === "omp" ? ompInfoLines(host.env, ctx.clientInfo?.version) : [];
53013
+ const whole2 = [envLine2, table3, ...docs, ...info, ...notes].join("\n");
52829
53014
  const bytes5 = Buffer.byteLength(whole2, "utf8");
52830
53015
  if (bytes5 <= REPORT_CAP) return { text: whole2, isError: false, sandboxBytes: bytes5 };
52831
53016
  const db = await openDb(ctx.project);
@@ -52834,9 +53019,14 @@ async function doctorReply(ctx, host) {
52834
53019
  } finally {
52835
53020
  closeDb(db);
52836
53021
  }
52837
- const text = [envLine2, buildReportHead(input), ...docs, ...notes].join("\n");
53022
+ const text = [envLine2, buildReportHead(input), ...docs, ...info, ...notes].join("\n");
52838
53023
  return { text, isError: false, sandboxBytes: bytes5 };
52839
53024
  }
53025
+ function ompCommand(rows, failed) {
53026
+ if (!failed) return OMP_LIST_COMMAND;
53027
+ const d3 = rows.find((r) => r.id === "D3" && r.status === "FAIL");
53028
+ return d3?.fixCommand ?? NATIVE_INSTALL.omp[0];
53029
+ }
52840
53030
  async function handler2(_input, ctx) {
52841
53031
  return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
52842
53032
  }
@@ -52850,9 +53040,9 @@ var ctxDoctor = Object.freeze({
52850
53040
  });
52851
53041
 
52852
53042
  // src/core/tools/execute.ts
52853
- import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
53043
+ import { existsSync as existsSync19, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
52854
53044
  import { tmpdir as tmpdir3 } from "node:os";
52855
- import { dirname as dirname11, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
53045
+ import { dirname as dirname11, join as join19, parse as parse5, resolve as resolve8 } from "node:path";
52856
53046
 
52857
53047
  // src/core/index/select.ts
52858
53048
  var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
@@ -52974,7 +53164,7 @@ function schemaLine(issue4) {
52974
53164
  }
52975
53165
  function fileError(given, abs, root) {
52976
53166
  let dir = abs;
52977
- while (!existsSync18(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
53167
+ while (!existsSync19(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
52978
53168
  if (isInside(root, dir)) return null;
52979
53169
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
52980
53170
  }
@@ -53043,7 +53233,12 @@ async function handler3(raw, ctx) {
53043
53233
  if (bad !== null) return fail4(bad);
53044
53234
  extra.CTX_FILE = abs;
53045
53235
  }
53046
- const runtime = findRuntime(input.language);
53236
+ let runtime;
53237
+ try {
53238
+ runtime = findRuntime(input.language);
53239
+ } catch {
53240
+ runtime = null;
53241
+ }
53047
53242
  if (runtime === null) return fail4(noRuntimeError(input.language).toLine());
53048
53243
  const env = buildChildEnv(process.env, extra);
53049
53244
  const timeoutMs = input.timeoutMs ?? EXEC_TIMEOUT_MS;
@@ -53055,8 +53250,8 @@ async function handler3(raw, ctx) {
53055
53250
  if (takesDashC(input.language, runtime)) {
53056
53251
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
53057
53252
  } else {
53058
- tmpDir = mkdtempSync2(join18(tmpdir3(), TMP_PREFIX));
53059
- const file2 = join18(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
53253
+ tmpDir = mkdtempSync2(join19(tmpdir3(), TMP_PREFIX));
53254
+ const file2 = join19(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
53060
53255
  writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
53061
53256
  argv = scriptArgv(input.language, runtime, file2);
53062
53257
  }
@@ -53092,12 +53287,12 @@ var ctxExecute = {
53092
53287
  };
53093
53288
 
53094
53289
  // src/core/tools/index.ts
53095
- import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
53096
- import { dirname as dirname12, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
53290
+ import { existsSync as existsSync20, readFileSync as readFileSync17, statSync as statSync7 } from "node:fs";
53291
+ import { dirname as dirname12, extname as extname3, join as join22, relative as relative3, resolve as resolve9 } from "node:path";
53097
53292
 
53098
53293
  // src/core/index/walk.ts
53099
- import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
53100
- import { join as join19 } from "node:path";
53294
+ import { readdirSync as readdirSync9, readFileSync as readFileSync15, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
53295
+ import { join as join20 } from "node:path";
53101
53296
  var GITIGNORE = ".gitignore";
53102
53297
  var GIT_DIR = ".git";
53103
53298
  function walkDir(root, containmentRoot) {
@@ -53106,7 +53301,7 @@ function walkDir(root, containmentRoot) {
53106
53301
  const found = [];
53107
53302
  visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
53108
53303
  found.sort(compareFound);
53109
- return found.map((f) => ({ absPath: f.absPath, relPath: join19(...f.dir, f.name) }));
53304
+ return found.map((f) => ({ absPath: f.absPath, relPath: join20(...f.dir, f.name) }));
53110
53305
  }
53111
53306
  function visit(abs, rel, parent, contain, seen, found) {
53112
53307
  let entries;
@@ -53115,10 +53310,10 @@ function visit(abs, rel, parent, contain, seen, found) {
53115
53310
  } catch {
53116
53311
  return;
53117
53312
  }
53118
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join19(abs, GITIGNORE), rel)) : parent;
53313
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join20(abs, GITIGNORE), rel)) : parent;
53119
53314
  for (const e of entries) {
53120
53315
  if (e.name === GIT_DIR) continue;
53121
- const path8 = join19(abs, e.name);
53316
+ const path8 = join20(abs, e.name);
53122
53317
  let isDir = e.isDirectory();
53123
53318
  let isFile = e.isFile();
53124
53319
  let target = path8;
@@ -53158,7 +53353,7 @@ function compareFound(a, b) {
53158
53353
  function readRules(file2, base) {
53159
53354
  let body;
53160
53355
  try {
53161
- body = readFileSync14(file2, "utf8");
53356
+ body = readFileSync15(file2, "utf8");
53162
53357
  } catch {
53163
53358
  return [];
53164
53359
  }
@@ -53241,10 +53436,12 @@ function globSeg(pat, name) {
53241
53436
  }
53242
53437
 
53243
53438
  // src/core/sandbox/fetch.ts
53439
+ import { readFileSync as readFileSync16 } from "node:fs";
53244
53440
  import { lookup } from "node:dns/promises";
53245
53441
  import http from "node:http";
53246
53442
  import https from "node:https";
53247
53443
  import { BlockList, isIP } from "node:net";
53444
+ import { join as join21 } from "node:path";
53248
53445
  import { connect as tlsConnect } from "node:tls";
53249
53446
  var PRIVATE_RANGES = [
53250
53447
  ["127.0.0.0", 8, "ipv4"],
@@ -53276,6 +53473,21 @@ for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix,
53276
53473
  var STATUS_OK_FIRST = 200;
53277
53474
  var STATUS_OK_END = 300;
53278
53475
  var STATUS_REDIRECT = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
53476
+ var UA_HOME = "https://github.com/mksglu/context-mode";
53477
+ var UA_DEV_VERSION = "dev";
53478
+ var namedHeaders;
53479
+ function baseHeaders() {
53480
+ if (namedHeaders === void 0) {
53481
+ let version4 = UA_DEV_VERSION;
53482
+ try {
53483
+ const v = JSON.parse(readFileSync16(join21(ownBundleDir(), D1_PACKAGE_FILE), "utf8")).version;
53484
+ if (typeof v === "string" && v !== "") version4 = v;
53485
+ } catch {
53486
+ }
53487
+ namedHeaders = Object.freeze({ "user-agent": "context-mode/" + version4 + " (+" + UA_HOME + ")", accept: "*/*" });
53488
+ }
53489
+ return namedHeaders;
53490
+ }
53279
53491
  function fail5(code) {
53280
53492
  return new CtxError("FETCH_FAILED", { code });
53281
53493
  }
@@ -53384,11 +53596,11 @@ function request(u, conn, proxy, signal) {
53384
53596
  const onErr = (err) => reject(fail5(causeCode(err)));
53385
53597
  if (proxy === void 0) {
53386
53598
  const mod = u.protocol === "https:" ? https : http;
53387
- const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
53599
+ const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { ...baseHeaders(), host: u.host } });
53388
53600
  req.on("response", resolve10).on("error", onErr).end();
53389
53601
  return;
53390
53602
  }
53391
- const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
53603
+ const proxyHeaders = proxy.auth === void 0 ? { ...baseHeaders() } : { ...baseHeaders(), "proxy-authorization": proxy.auth };
53392
53604
  if (u.protocol === "http:") {
53393
53605
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
53394
53606
  req.on("response", resolve10).on("error", onErr).end();
@@ -53408,7 +53620,7 @@ function request(u, conn, proxy, signal) {
53408
53620
  port,
53409
53621
  path: path8,
53410
53622
  signal,
53411
- headers: { host: u.host },
53623
+ headers: { ...baseHeaders(), host: u.host },
53412
53624
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
53413
53625
  });
53414
53626
  req.on("response", resolve10).on("error", onErr).end();
@@ -53450,7 +53662,7 @@ async function safeFetch(url4, signal) {
53450
53662
  }
53451
53663
  if (status < STATUS_OK_FIRST || status >= STATUS_OK_END) {
53452
53664
  res.resume();
53453
- throw fail5(status);
53665
+ throw fail5(status + " from " + bare(current.hostname));
53454
53666
  }
53455
53667
  const body = await readBody(res);
53456
53668
  const shown2 = new URL(current.href);
@@ -57286,14 +57498,14 @@ function kindOfType(contentType) {
57286
57498
  }
57287
57499
  function readUtf8(absPath) {
57288
57500
  try {
57289
- return utf8.decode(readFileSync15(absPath));
57501
+ return utf8.decode(readFileSync17(absPath));
57290
57502
  } catch {
57291
57503
  return void 0;
57292
57504
  }
57293
57505
  }
57294
57506
  function missingOrOutside(given, abs, root) {
57295
57507
  let dir = abs;
57296
- while (!existsSync19(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
57508
+ while (!existsSync20(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
57297
57509
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
57298
57510
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
57299
57511
  }
@@ -57304,7 +57516,7 @@ function pathItems(input, project) {
57304
57516
  if (statSync7(abs).isDirectory()) {
57305
57517
  return walkDir(abs, project.containmentRoot).map((f) => ({
57306
57518
  sourceKind: "path",
57307
- label: pathLabel(join20(base, f.relPath)),
57519
+ label: pathLabel(join22(base, f.relPath)),
57308
57520
  kind: kindOfPath(f.relPath),
57309
57521
  read: () => readUtf8(f.absPath)
57310
57522
  }));
@@ -58104,8 +58316,8 @@ var ctxStats = Object.freeze({
58104
58316
  });
58105
58317
 
58106
58318
  // src/core/ops/host-write.ts
58107
- import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
58108
- import { dirname as dirname13, join as join21 } from "node:path";
58319
+ import { copyFileSync, existsSync as existsSync21, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
58320
+ import { dirname as dirname13, join as join23 } from "node:path";
58109
58321
  function defaultWrite(file2, text) {
58110
58322
  writeFileSync6(file2, text, "utf8");
58111
58323
  }
@@ -58114,17 +58326,20 @@ function hostConfigPath(agent, home, env) {
58114
58326
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
58115
58327
  switch (agent) {
58116
58328
  case "opencode":
58117
- return join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
58329
+ return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
58118
58330
  // D-WIN-OPENCODE-DIR-1
58119
58331
  case "pi":
58120
- return join21(piAgentDirOf(env, home), SETTINGS_FILE);
58332
+ return join23(piAgentDirOf(env, home), SETTINGS_FILE);
58121
58333
  case "gemini":
58122
- return join21(geminiDirOf(env, home), SETTINGS_FILE);
58334
+ return join23(geminiDirOf(env, home), SETTINGS_FILE);
58123
58335
  // D-R38-GEMINI-HOME-1
58124
58336
  case "copilot-cli":
58125
58337
  return null;
58338
+ case "omp":
58339
+ return null;
58340
+ // ADR-0026 decision 8 (D-OMP-UPGRADE-1): OMP loads the plugin from its own store; no MCP entry, nothing under ~/.pi
58126
58341
  default:
58127
- return join21(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
58342
+ return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
58128
58343
  }
58129
58344
  }
58130
58345
  function cell3(value) {
@@ -58136,7 +58351,7 @@ function toRow(file2, edit) {
58136
58351
  function writeWithRollback(file2, text, write, atomic) {
58137
58352
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
58138
58353
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
58139
- const had = existsSync20(file2);
58354
+ const had = existsSync21(file2);
58140
58355
  mkdirSync8(dirname13(file2), { recursive: true });
58141
58356
  if (had) copyFileSync(file2, trash);
58142
58357
  try {
@@ -58166,7 +58381,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
58166
58381
  if (requested === null) return [];
58167
58382
  const current = readHostConfig(row5.id, requested);
58168
58383
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
58169
- const exists = existsSync20(current.path);
58384
+ const exists = existsSync21(current.path);
58170
58385
  if (exists && result.text === current.text) return [];
58171
58386
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
58172
58387
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -58174,15 +58389,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
58174
58389
  }
58175
58390
 
58176
58391
  // src/core/ops/uninstall.ts
58177
- import { existsSync as existsSync21, readdirSync as readdirSync10, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
58178
- import { join as join22 } from "node:path";
58392
+ import { existsSync as existsSync22, readdirSync as readdirSync10, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
58393
+ import { join as join24 } from "node:path";
58179
58394
  function row2(area, before, after) {
58180
58395
  return { area, before, after };
58181
58396
  }
58182
58397
  function stopServers(configDir, projectKey) {
58183
58398
  const stopped = listLiveOwners(configDir, projectKey);
58184
- const dir = join22(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
58185
- for (const serverId of stopped) writeFileSync7(join22(dir, serverId + OWNER_STOP_EXT), "", "utf8");
58399
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
58400
+ for (const serverId of stopped) writeFileSync7(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
58186
58401
  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 };
58187
58402
  }
58188
58403
  function rootOrNull(adapter, env) {
@@ -58200,15 +58415,15 @@ function removeCache(adapter, env, configDir) {
58200
58415
  const root = rootOrNull(adapter, env);
58201
58416
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
58202
58417
  if (adapter.installMode === "marketplace") {
58203
- const cache = join22(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
58418
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
58204
58419
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
58205
58420
  }
58206
58421
  rmSync7(root, { recursive: true, force: true });
58207
58422
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
58208
58423
  }
58209
58424
  case "plugin": {
58210
- const agentDir = join22(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
58211
- if (!existsSync21(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
58425
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
58426
+ if (!existsSync22(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
58212
58427
  rmSync7(agentDir, { recursive: true, force: true });
58213
58428
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
58214
58429
  }
@@ -58253,7 +58468,7 @@ function ownEntries2(agent, env) {
58253
58468
  }
58254
58469
  if (agent === "opencode") {
58255
58470
  return [{
58256
- file: join22(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
58471
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
58257
58472
  // D-WIN-OPENCODE-DIR-1
58258
58473
  key: OPENCODE_PLUGIN_KEY,
58259
58474
  shown: OPENCODE_PLUGIN_KEY,
@@ -58264,13 +58479,22 @@ function ownEntries2(agent, env) {
58264
58479
  if (agent === "pi") {
58265
58480
  const agentDir = piAgentDirOf(env, home);
58266
58481
  return [{
58267
- file: join22(agentDir, SETTINGS_FILE),
58482
+ file: join24(agentDir, SETTINGS_FILE),
58268
58483
  key: PI_PACKAGES_KEY,
58269
58484
  shown: PI_PACKAGES_KEY,
58270
58485
  has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
58271
58486
  drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
58272
58487
  }];
58273
58488
  }
58489
+ if (agent === "omp") {
58490
+ return [{
58491
+ file: ompImportFiles(home).mcp,
58492
+ key: OMP_DISABLED_SERVERS_KEY,
58493
+ shown: OMP_DISABLED_SERVERS_KEY,
58494
+ has: (v) => Array.isArray(v) && v.includes(SERVER_KEY),
58495
+ drop: (v) => v.filter((x) => x !== SERVER_KEY)
58496
+ }];
58497
+ }
58274
58498
  return [];
58275
58499
  }
58276
58500
  function removeOwnEntries(agent, env) {
@@ -58286,12 +58510,12 @@ function removeOwnEntries(agent, env) {
58286
58510
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
58287
58511
  }
58288
58512
  function removeProjectData(configDir, projectKey) {
58289
- const projects = join22(configDir, PROJECTS_DIR_NAME);
58290
- const dir = join22(projects, projectKey);
58291
- if (!existsSync21(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
58513
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
58514
+ const dir = join24(projects, projectKey);
58515
+ if (!existsSync22(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
58292
58516
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
58293
58517
  for (const name of readdirSync10(dir)) {
58294
- if (name !== OWNERS_DIR_NAME) rmSync7(join22(dir, name), { recursive: true, force: true });
58518
+ if (name !== OWNERS_DIR_NAME) rmSync7(join24(dir, name), { recursive: true, force: true });
58295
58519
  }
58296
58520
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
58297
58521
  }
@@ -58299,12 +58523,12 @@ function runUninstall(input) {
58299
58523
  const configDir = resolveConfigDir(input.env);
58300
58524
  const stop = stopServers(configDir, input.project.projectKey);
58301
58525
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
58302
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join22(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
58526
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
58303
58527
  return { rows, stopped: stop.stopped };
58304
58528
  }
58305
58529
 
58306
58530
  // src/core/ops/v1-remove.ts
58307
- import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync16, rmSync as rmSync8 } from "node:fs";
58531
+ import { copyFileSync as copyFileSync2, existsSync as existsSync23, readFileSync as readFileSync18, rmSync as rmSync8 } from "node:fs";
58308
58532
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
58309
58533
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
58310
58534
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -58316,7 +58540,7 @@ function moveAside(target, undo) {
58316
58540
  }
58317
58541
  function keepAside(target, undo) {
58318
58542
  let aside = target + UPGRADE_ASIDE_SUFFIX;
58319
- for (let n = 2; existsSync22(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
58543
+ for (let n = 2; existsSync23(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
58320
58544
  renameWithRetry(target, aside);
58321
58545
  undo.push({ trash: aside, target, keep: true });
58322
58546
  return aside;
@@ -58355,8 +58579,8 @@ function locate(doc, path8) {
58355
58579
  return null;
58356
58580
  }
58357
58581
  function stripJsonEntries(agent, file2, findings, kept, undo) {
58358
- const layout = hostLayout(readFileSync16(file2, "utf8"));
58359
- const text = hostText(readFileSync16(file2, "utf8"));
58582
+ const layout = hostLayout(readFileSync18(file2, "utf8"));
58583
+ const text = hostText(readFileSync18(file2, "utf8"));
58360
58584
  const doc = parseHostConfig(agent, file2, text, "jsonc");
58361
58585
  const hit = /* @__PURE__ */ new Set();
58362
58586
  const byContainer = /* @__PURE__ */ new Map();
@@ -58393,20 +58617,20 @@ function removeV1(agent, findings, project) {
58393
58617
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
58394
58618
  else if (f.path === "") {
58395
58619
  if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
58396
- else if (existsSync22(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
58397
- else if (existsSync22(f.file)) {
58620
+ else if (existsSync23(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
58621
+ else if (existsSync23(f.file)) {
58398
58622
  moveAside(f.file, undo);
58399
58623
  done.set(f, UPGRADE_REMOVED);
58400
58624
  } else done.set(f, UPGRADE_NOT_FOUND);
58401
58625
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
58402
58626
  }
58403
58627
  for (const [file2, list3] of entries) {
58404
- if (!existsSync22(file2)) {
58628
+ if (!existsSync23(file2)) {
58405
58629
  for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
58406
58630
  continue;
58407
58631
  }
58408
58632
  if (file2.endsWith(TOML_EXT)) {
58409
- const rawToml = readFileSync16(file2, "utf8");
58633
+ const rawToml = readFileSync18(file2, "utf8");
58410
58634
  const tomlLayout = hostLayout(rawToml);
58411
58635
  let text = hostText(rawToml);
58412
58636
  for (const f of list3) {
@@ -58434,7 +58658,7 @@ function removeV1(agent, findings, project) {
58434
58658
  },
58435
58659
  rollback() {
58436
58660
  for (const u of undo.splice(0).reverse()) {
58437
- if (!existsSync22(u.trash)) continue;
58661
+ if (!existsSync23(u.trash)) continue;
58438
58662
  rmSync8(u.target, { recursive: true, force: true });
58439
58663
  renameWithRetry(u.trash, u.target);
58440
58664
  }
@@ -58710,15 +58934,15 @@ async function startServer(argv, env) {
58710
58934
  opening.catch(() => pending.delete(project.dbPath));
58711
58935
  }
58712
58936
  const db = await opening;
58713
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
58937
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
58714
58938
  return db;
58715
58939
  }
58716
58940
  function stopMarker(configDir, projectKey) {
58717
- return join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
58941
+ return join25(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
58718
58942
  }
58719
58943
  function stopRequested() {
58720
58944
  const configDir = resolveConfigDir(process.env);
58721
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
58945
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
58722
58946
  }
58723
58947
  async function journal(project, ctx, name, reply4) {
58724
58948
  const db = await ownDb(project);