context-mode 2.1.9 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.mjs CHANGED
@@ -7,9 +7,9 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/entries/cli.ts
10
- import { spawn as spawn4 } from "node:child_process";
11
- import { readFileSync as readFileSync14, realpathSync as realpathSync11 } from "node:fs";
12
- import path14 from "node:path";
10
+ import { spawn as spawn6 } from "node:child_process";
11
+ import { readFileSync as readFileSync16, realpathSync as realpathSync12 } from "node:fs";
12
+ import path16 from "node:path";
13
13
  import { fileURLToPath as fileURLToPath3 } from "node:url";
14
14
 
15
15
  // src/core/contracts/constants.ts
@@ -244,6 +244,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
244
244
  qwen: READ_IMAGES_AND_PDF,
245
245
  opencode: READ_IMAGES_AND_PDF,
246
246
  pi: READ_IMAGES,
247
+ omp: READ_IMAGES,
247
248
  vscode: READ_IMAGES,
248
249
  zcode: READ_IMAGES,
249
250
  "copilot-cli": [],
@@ -309,6 +310,7 @@ function D2_NODE_DETAIL(version) {
309
310
  var D2_SQLITE_DETAIL = "node:sqlite failed to load";
310
311
  var D2_SQLITE_FIX = "run ctx_doctor";
311
312
  var D3_PARTS = Object.freeze(["MCP entry", "hook entries", "hook timeout"]);
313
+ var PLUGIN_CACHE_DIR_NAME = "cache";
312
314
  var PLUGIN_MARKETPLACE_NAME = "context-mode";
313
315
  var AGENT_HOME_DIR = Object.freeze({
314
316
  "claude-code": [".claude"],
@@ -320,7 +322,9 @@ var AGENT_HOME_DIR = Object.freeze({
320
322
  kiro: [".kiro"],
321
323
  zcode: [".zcode"],
322
324
  pi: [".pi"],
323
- opencode: [".config", "opencode"]
325
+ opencode: [".config", "opencode"],
326
+ omp: [".omp"]
327
+ // ADR-0026: OMP data and plugins live under ~/.omp
324
328
  });
325
329
  var UPGRADE_MODES = Object.freeze(["upgrade", "uninstall"]);
326
330
  var GIT_CLONE_ARGS = Object.freeze(["clone", "--depth", "1", "--branch"]);
@@ -364,16 +368,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
364
368
  binaries: [],
365
369
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
366
370
  }),
367
- unsupported({
368
- id: "omp",
369
- name: "OMP (oh-my-pi)",
370
- clientNames: ["omp-coding-agent"],
371
- envVars: [],
372
- pluginPaths: [],
373
- configDirs: [".omp"],
374
- binaries: ["omp"],
375
- 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)"
376
- }),
377
371
  unsupported({
378
372
  id: "openclaw",
379
373
  name: "OpenClaw",
@@ -436,7 +430,9 @@ var HOOK_HOST_FILE = Object.freeze({
436
430
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
437
431
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
438
432
  pi: null,
439
- opencode: null
433
+ opencode: null,
434
+ omp: null
435
+ // ADR-0026: in-process, no hook file
440
436
  });
441
437
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
442
438
  var KIRO_TOOL_MATCHERS = Object.freeze([["@mcp", "mcp"], ["shell", "shell"]]);
@@ -456,6 +452,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
456
452
  gemini: "gemini extensions update context-mode",
457
453
  qwen: "qwen extensions update context-mode",
458
454
  pi: "pi update --extensions",
455
+ omp: "omp plugin upgrade context-mode",
456
+ // ADR-0026 decision 4: OMP native update
459
457
  opencode: "opencode plugin update",
460
458
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
461
459
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -678,6 +676,8 @@ var NATIVE_INSTALL = Object.freeze({
678
676
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
679
677
  opencode: ["opencode plugin add context-mode"],
680
678
  pi: ["pi install npm:context-mode"],
679
+ omp: ["omp plugin install context-mode"],
680
+ // ADR-0026 decision 4: OMP native install
681
681
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
682
682
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
683
683
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -1405,6 +1405,9 @@ function readResult6(p3) {
1405
1405
  if (p3.keep === true) info.keep = true;
1406
1406
  return info;
1407
1407
  }
1408
+ function decodeOmp(raw) {
1409
+ return { ...decode9(raw), agent: "omp" };
1410
+ }
1408
1411
  function decode9(raw) {
1409
1412
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
1410
1413
  const p3 = raw;
@@ -1706,10 +1709,32 @@ var ADAPTERS = Object.freeze([
1706
1709
  decode: decode10,
1707
1710
  encode: encode10,
1708
1711
  toCanonicalTool
1712
+ },
1713
+ {
1714
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
1715
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
1716
+ id: "omp",
1717
+ installMode: "in-process",
1718
+ projectSource: "pi:ctx.cwd",
1719
+ toolNamePrefix: TOOL_NAME_PREFIX9,
1720
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
1721
+ execReadOnlyHint: false,
1722
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
1723
+ compactDelivery: "pi-flag",
1724
+ compactSummary: "none",
1725
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
1726
+ denyChannel: "deny-reason",
1727
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
1728
+ skillChannel: { kind: "package", path: "skills" },
1729
+ // D-OMP-SKILLS-1
1730
+ decode: decodeOmp,
1731
+ encode: encode9,
1732
+ checkPermission
1733
+ // D-OMP-FIRE-1: agent omp in rows
1709
1734
  }
1710
1735
  ]);
1711
1736
  var BY_ID = new Map(ADAPTERS.map((r2) => [r2.id, r2]));
1712
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
1737
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
1713
1738
  function hasReplace(row) {
1714
1739
  return REPLACE_ROWS.has(row.id);
1715
1740
  }
@@ -1718,7 +1743,7 @@ function getAdapter(id) {
1718
1743
  }
1719
1744
 
1720
1745
  // src/core/contracts/agents.ts
1721
- var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
1746
+ var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode", "omp"];
1722
1747
 
1723
1748
  // src/core/ops/unsupported-host.ts
1724
1749
  var SUPPORTED_AGENTS_LINE = `Supported agents: ${AGENT_IDS.join(", ")} (${SUPPORTED_AGENTS_DOCS_URL}).`;
@@ -1969,9 +1994,9 @@ Examples:
1969
1994
  // src/cli/commands.ts
1970
1995
  import { spawnSync as spawnSync5 } from "node:child_process";
1971
1996
  import { createHash as createHash2 } from "node:crypto";
1972
- import { existsSync as existsSync18, mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
1997
+ import { existsSync as existsSync20, mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
1973
1998
  import os from "node:os";
1974
- import path13 from "node:path";
1999
+ import path15 from "node:path";
1975
2000
 
1976
2001
  // node_modules/@clack/prompts/dist/index.mjs
1977
2002
  var dist_exports = {};
@@ -4958,6 +4983,15 @@ function codexDirOf(env, home) {
4958
4983
  const dir = env[CODEX_HOME_ENV];
4959
4984
  return dir !== void 0 && dir !== "" ? dir : join2(home, ...AGENT_HOME_DIR.codex);
4960
4985
  }
4986
+ function codexPluginHomeOf(bundleDir) {
4987
+ let dir = resolve(bundleDir);
4988
+ while (dirname2(dir) !== dir) {
4989
+ const up = dirname2(dir);
4990
+ if (basename(dir) === PLUGIN_CACHE_DIR_NAME && basename(up) === HOST_PLUGINS_DIR_NAME) return dirname2(up);
4991
+ dir = up;
4992
+ }
4993
+ return null;
4994
+ }
4961
4995
  function copilotDirOf(env, home) {
4962
4996
  const dir = env[COPILOT_HOME_ENV];
4963
4997
  return dir !== void 0 && dir !== "" ? dir : join2(home, ...AGENT_HOME_DIR["copilot-cli"]);
@@ -4980,14 +5014,14 @@ function kiroDirOf(env, home, platform = process.platform) {
4980
5014
  if (!p3.isAbsolute(up) && up.split(p3.sep)[0] !== "..") return fallback;
4981
5015
  return abs;
4982
5016
  }
4983
- function realOrSelf(path15) {
5017
+ function realOrSelf(path17) {
4984
5018
  const tail = [];
4985
- for (let at = path15; ; ) {
5019
+ for (let at = path17; ; ) {
4986
5020
  try {
4987
5021
  return join2(realpathSync.native(at), ...tail.reverse());
4988
5022
  } catch {
4989
5023
  const up = dirname2(at);
4990
- if (up === at) return path15;
5024
+ if (up === at) return path17;
4991
5025
  tail.push(basename(at));
4992
5026
  at = up;
4993
5027
  }
@@ -5031,8 +5065,8 @@ function dataRootOf(env, home) {
5031
5065
 
5032
5066
  // src/core/ops/doctor-issue.ts
5033
5067
  import { spawnSync } from "node:child_process";
5034
- import { closeSync as closeSync2, existsSync as existsSync10, fstatSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync7, readSync as readSync2, realpathSync as realpathSync5, writeFileSync as writeFileSync2 } from "node:fs";
5035
- import { delimiter, join as join11 } from "node:path";
5068
+ import { closeSync as closeSync2, existsSync as existsSync12, fstatSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync9, readSync as readSync2, realpathSync as realpathSync6, writeFileSync as writeFileSync2 } from "node:fs";
5069
+ import { delimiter, dirname as dirname8, join as join13 } from "node:path";
5036
5070
 
5037
5071
  // src/core/hooks/fallback.ts
5038
5072
  import { join as join5, resolve as resolve4 } from "node:path";
@@ -5092,6 +5126,21 @@ function envValue(env, name, platform = process.platform) {
5092
5126
  return key === void 0 ? void 0 : env[key];
5093
5127
  }
5094
5128
 
5129
+ // src/core/sandbox/runtimes.ts
5130
+ import { accessSync, constants as fsConstants, statSync } from "node:fs";
5131
+ import path2 from "node:path";
5132
+ var WIN_STARTABLE_EXT = Object.freeze([".exe", ".com"]);
5133
+
5134
+ // src/core/sandbox/spawn.ts
5135
+ import { spawn as spawn2 } from "node:child_process";
5136
+ import path3 from "node:path";
5137
+
5138
+ // src/core/sandbox/kill.ts
5139
+ import { spawn } from "node:child_process";
5140
+
5141
+ // src/core/sandbox/spawn.ts
5142
+ var NOT_STARTED = Object.freeze({ stdout: Buffer.alloc(0), stderr: Buffer.alloc(0), exitCode: null, killed: null });
5143
+
5095
5144
  // src/core/store/schema.ts
5096
5145
  var PRAGMAS = `
5097
5146
  PRAGMA busy_timeout = ${DB_TIMEOUT_MS};
@@ -5182,8 +5231,8 @@ CREATE VIRTUAL TABLE line_units USING fts5(
5182
5231
  var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
5183
5232
 
5184
5233
  // src/core/ops/doctor-config.ts
5185
- import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
5186
- import { dirname as dirname7, isAbsolute as isAbsolute3, join as join10, resolve as resolve5 } from "node:path";
5234
+ import { existsSync as existsSync11, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "node:fs";
5235
+ import { dirname as dirname7, isAbsolute as isAbsolute4, join as join12, resolve as resolve5 } from "node:path";
5187
5236
 
5188
5237
  // src/core/ops/host-text.ts
5189
5238
  var BOM_CODE = 65279;
@@ -7262,7 +7311,7 @@ function parseTOML(code, options) {
7262
7311
 
7263
7312
  // src/core/ops/atomic-file.ts
7264
7313
  import { mkdirSync as mkdirSync3, renameSync, unlinkSync, writeFileSync } from "node:fs";
7265
- import path2 from "node:path";
7314
+ import path4 from "node:path";
7266
7315
  function sleepSync(ms) {
7267
7316
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
7268
7317
  }
@@ -7312,8 +7361,8 @@ function removeTmpFile(tmp, opts = {}) {
7312
7361
  }
7313
7362
  }
7314
7363
  function atomicWriteFile(file, text2, opts = {}) {
7315
- mkdirSync3(path2.dirname(file), { recursive: true });
7316
- const tmp = path2.join(path2.dirname(file), `${ATOMIC_TMP_PREFIX}${path2.basename(file)}${ATOMIC_TMP_MARK}${process.pid}`);
7364
+ mkdirSync3(path4.dirname(file), { recursive: true });
7365
+ const tmp = path4.join(path4.dirname(file), `${ATOMIC_TMP_PREFIX}${path4.basename(file)}${ATOMIC_TMP_MARK}${process.pid}`);
7317
7366
  try {
7318
7367
  writeFileSync(tmp, text2);
7319
7368
  renameWithRetry(tmp, file, opts);
@@ -7504,14 +7553,14 @@ function scanToml(text2) {
7504
7553
  continue;
7505
7554
  }
7506
7555
  if (!node.resolvedKey.every((seg) => typeof seg === "string")) continue;
7507
- const path15 = node.resolvedKey;
7508
- for (const kv of node.body) addKey(path15, kv);
7556
+ const path17 = node.resolvedKey;
7557
+ for (const kv of node.body) addKey(path17, kv);
7509
7558
  if (node.kind !== "standard") continue;
7510
7559
  const start = lineStartOf(text2, node.range[0]);
7511
7560
  const headEnd = lineEndOf(text2, node.key.range[1]);
7512
7561
  const last2 = node.body[node.body.length - 1];
7513
7562
  tables.push({
7514
- path: path15,
7563
+ path: path17,
7515
7564
  header: text2.slice(start, text2[headEnd - 1] === "\n" ? headEnd - 1 : headEnd),
7516
7565
  start,
7517
7566
  end: last2 === void 0 ? headEnd : lineEndOf(text2, last2.range[1])
@@ -7522,16 +7571,16 @@ function scanToml(text2) {
7522
7571
  function tomlTableSpans(text2) {
7523
7572
  return scanToml(text2).tables;
7524
7573
  }
7525
- function parseHostConfig(agent, path15, text2, format) {
7574
+ function parseHostConfig(agent, path17, text2, format) {
7526
7575
  try {
7527
7576
  return format === "toml" ? scanToml(text2).value : scanJson(text2, format).value;
7528
7577
  } catch {
7529
- throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path15, format });
7578
+ throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path17, format });
7530
7579
  }
7531
7580
  }
7532
- function hostConfigValueAt(value, path15) {
7581
+ function hostConfigValueAt(value, path17) {
7533
7582
  let cur = value;
7534
- for (const seg of path15) {
7583
+ for (const seg of path17) {
7535
7584
  if (!isPlainObject(cur)) return void 0;
7536
7585
  cur = cur[seg];
7537
7586
  }
@@ -7564,32 +7613,32 @@ function indentUnit(root, clean) {
7564
7613
  function render(value, unit, base) {
7565
7614
  return JSON.stringify(value, null, unit).split("\n").join("\n" + base);
7566
7615
  }
7567
- function nest(path15, value) {
7616
+ function nest(path17, value) {
7568
7617
  let out2 = value;
7569
- for (let k = path15.length - 1; k >= 0; k -= 1) out2 = { [path15[k]]: out2 };
7618
+ for (let k = path17.length - 1; k >= 0; k -= 1) out2 = { [path17[k]]: out2 };
7570
7619
  return out2;
7571
7620
  }
7572
- function setJsonText(text2, format, path15, value) {
7621
+ function setJsonText(text2, format, path17, value) {
7573
7622
  const doc = scanJson(text2, format);
7574
7623
  const unit = indentUnit(doc.root, doc.clean);
7575
- if (doc.root === null) return render(nest(path15, value), unit, "") + "\n";
7624
+ if (doc.root === null) return render(nest(path17, value), unit, "") + "\n";
7576
7625
  let node = doc.root;
7577
7626
  let depth = 0;
7578
- while (depth < path15.length && node.kind === "object") {
7579
- const hit = node.members.find((m3) => m3.key === path15[depth]);
7627
+ while (depth < path17.length && node.kind === "object") {
7628
+ const hit = node.members.find((m3) => m3.key === path17[depth]);
7580
7629
  if (hit === void 0) break;
7581
7630
  node = hit.node;
7582
7631
  depth += 1;
7583
7632
  }
7584
- if (depth === path15.length) {
7633
+ if (depth === path17.length) {
7585
7634
  return text2.slice(0, node.start) + render(value, unit, lineIndent(doc.clean, node.start)) + text2.slice(node.end);
7586
7635
  }
7587
- if (node.kind !== "object") throw new SyntaxError("not an object at " + path15.slice(0, depth).join("."));
7588
- const rest = nest(path15.slice(depth + 1), value);
7636
+ if (node.kind !== "object") throw new SyntaxError("not an object at " + path17.slice(0, depth).join("."));
7637
+ const rest = nest(path17.slice(depth + 1), value);
7589
7638
  const last2 = node.members[node.members.length - 1];
7590
7639
  if (last2 === void 0) {
7591
7640
  const base2 = lineIndent(doc.clean, node.start);
7592
- const member2 = "\n" + base2 + unit + JSON.stringify(path15[depth]) + ": " + render(rest, unit, base2 + unit) + "\n" + base2;
7641
+ const member2 = "\n" + base2 + unit + JSON.stringify(path17[depth]) + ": " + render(rest, unit, base2 + unit) + "\n" + base2;
7593
7642
  return text2.slice(0, node.start + 1) + member2 + text2.slice(node.end - 1);
7594
7643
  }
7595
7644
  const base = lineIndent(doc.clean, last2.keyStart);
@@ -7597,7 +7646,7 @@ function setJsonText(text2, format, path15, value) {
7597
7646
  while (" \r\n".includes(doc.clean[at])) at += 1;
7598
7647
  const trailing = doc.clean[at] === ",";
7599
7648
  const insertAt = trailing ? at + 1 : last2.node.end;
7600
- const member = (trailing ? "" : ",") + "\n" + base + JSON.stringify(path15[depth]) + ": " + render(rest, unit, base);
7649
+ const member = (trailing ? "" : ",") + "\n" + base + JSON.stringify(path17[depth]) + ": " + render(rest, unit, base);
7601
7650
  return text2.slice(0, insertAt) + member + text2.slice(insertAt);
7602
7651
  }
7603
7652
  function tomlScalar(v) {
@@ -7615,17 +7664,17 @@ function tomlHeaderKey(seg) {
7615
7664
  }
7616
7665
  return seg;
7617
7666
  }
7618
- function tomlBlock(path15, value) {
7619
- let out2 = "[" + path15.map(tomlHeaderKey).join(".") + "]\n";
7667
+ function tomlBlock(path17, value) {
7668
+ let out2 = "[" + path17.map(tomlHeaderKey).join(".") + "]\n";
7620
7669
  const subs = [];
7621
7670
  for (const [k, v] of Object.entries(value)) {
7622
- if (isPlainObject(v)) subs.push(tomlBlock([...path15, k], v));
7671
+ if (isPlainObject(v)) subs.push(tomlBlock([...path17, k], v));
7623
7672
  else out2 += tomlHeaderKey(k) + " = " + tomlScalar(v) + "\n";
7624
7673
  }
7625
7674
  return [out2, ...subs].join("\n");
7626
7675
  }
7627
- function under(path15, prefix) {
7628
- return path15.length >= prefix.length && prefix.every((seg, k) => path15[k] === seg);
7676
+ function under(path17, prefix) {
7677
+ return path17.length >= prefix.length && prefix.every((seg, k) => path17[k] === seg);
7629
7678
  }
7630
7679
  function keyLineRange(text2, k) {
7631
7680
  const ls = lineStartOf(text2, k.start);
@@ -7642,10 +7691,10 @@ function withValueAt(root, rel, value) {
7642
7691
  else base[rel[0]] = next;
7643
7692
  return base;
7644
7693
  }
7645
- function replaceToml(text2, doc, path15, value) {
7646
- const block2 = value === void 0 ? "" : tomlBlock(path15, value);
7647
- const owned = doc.tables.filter((t2) => under(t2.path, path15));
7648
- const cuts = doc.keys.filter((k) => under(k.full, path15) && !under(k.base, path15)).map((k) => [...keyLineRange(text2, k), ""]);
7694
+ function replaceToml(text2, doc, path17, value) {
7695
+ const block2 = value === void 0 ? "" : tomlBlock(path17, value);
7696
+ const owned = doc.tables.filter((t2) => under(t2.path, path17));
7697
+ const cuts = doc.keys.filter((k) => under(k.full, path17) && !under(k.base, path17)).map((k) => [...keyLineRange(text2, k), ""]);
7649
7698
  owned.forEach((t2, n3) => cuts.push([t2.start, t2.end, n3 === 0 ? block2 : ""]));
7650
7699
  cuts.sort((a2, b3) => b3[0] - a2[0]);
7651
7700
  let out2 = text2;
@@ -7655,27 +7704,27 @@ function replaceToml(text2, doc, path15, value) {
7655
7704
  return out2 + sep3 + block2;
7656
7705
  }
7657
7706
  var tableLike = (v) => v === void 0 || isPlainObject(v);
7658
- function setTomlText(text2, path15, value) {
7707
+ function setTomlText(text2, path17, value) {
7659
7708
  if (value !== void 0 && !isPlainObject(value)) throw new SyntaxError("TOML edits replace a whole table");
7660
7709
  const doc = scanToml(text2);
7661
- const cur = hostConfigValueAt(doc.value, path15);
7710
+ const cur = hostConfigValueAt(doc.value, path17);
7662
7711
  if (sameValue(cur, value)) return text2;
7663
- const inline = doc.keys.find((k) => k.inline && k.full.length < path15.length && under(path15, k.full));
7712
+ const inline = doc.keys.find((k) => k.inline && k.full.length < path17.length && under(path17, k.full));
7664
7713
  if (inline !== void 0) {
7665
- const whole = withValueAt(hostConfigValueAt(doc.value, inline.full), path15.slice(inline.full.length), value);
7714
+ const whole = withValueAt(hostConfigValueAt(doc.value, inline.full), path17.slice(inline.full.length), value);
7666
7715
  return replaceToml(text2, doc, inline.full, whole);
7667
7716
  }
7668
7717
  if (isPlainObject(cur) && isPlainObject(value)) {
7669
7718
  const names = [.../* @__PURE__ */ new Set([...Object.keys(cur), ...Object.keys(value)])].filter((k) => !sameValue(cur[k], value[k]));
7670
7719
  if (names.every((k) => tableLike(cur[k]) && tableLike(value[k]))) {
7671
7720
  let out2 = text2;
7672
- for (const k of names) out2 = setTomlText(out2, [...path15, k], value[k]);
7721
+ for (const k of names) out2 = setTomlText(out2, [...path17, k], value[k]);
7673
7722
  return out2;
7674
7723
  }
7675
7724
  }
7676
- return replaceToml(text2, doc, path15, value);
7725
+ return replaceToml(text2, doc, path17, value);
7677
7726
  }
7678
- function setText(agent, path15, text2, format, key, value) {
7727
+ function setText(agent, path17, text2, format, key, value) {
7679
7728
  try {
7680
7729
  if (format !== "toml") return setJsonText(text2, format, key, value);
7681
7730
  const out2 = setTomlText(text2, key, value);
@@ -7684,7 +7733,7 @@ function setText(agent, path15, text2, format, key, value) {
7684
7733
  if (!sameValue(landed, value) && !(emptyTable && landed === void 0)) throw new SyntaxError("edit did not land");
7685
7734
  return out2;
7686
7735
  } catch {
7687
- throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path15, format });
7736
+ throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path17, format });
7688
7737
  }
7689
7738
  }
7690
7739
  function isNodeCommand(command) {
@@ -7702,26 +7751,26 @@ function ownMcpValue(agent, node, server) {
7702
7751
  function opencodePluginFile() {
7703
7752
  return ownBundleDir();
7704
7753
  }
7705
- function applyEdits(agent, path15, text2, format, wanted) {
7706
- const parsed = parseHostConfig(agent, path15, text2, format);
7754
+ function applyEdits(agent, path17, text2, format, wanted) {
7755
+ const parsed = parseHostConfig(agent, path17, text2, format);
7707
7756
  let out2 = text2;
7708
7757
  const edits = [];
7709
7758
  for (const [key, after] of wanted) {
7710
7759
  const before = hostConfigValueAt(parsed, key);
7711
7760
  if (sameValue(before, after)) continue;
7712
- out2 = setText(agent, path15, out2, format, key, after);
7761
+ out2 = setText(agent, path17, out2, format, key, after);
7713
7762
  edits.push({ path: key.join("."), before, after });
7714
7763
  }
7715
7764
  return { text: out2, format, edits };
7716
7765
  }
7717
- function editHostConfigText(agent, path15, text2, format, wanted) {
7718
- return applyEdits(agent, path15, text2, format, wanted);
7766
+ function editHostConfigText(agent, path17, text2, format, wanted) {
7767
+ return applyEdits(agent, path17, text2, format, wanted);
7719
7768
  }
7720
7769
 
7721
7770
  // src/core/ops/detect-v1.ts
7722
7771
  var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
7723
7772
  var keyPath = (...parts) => parts.join(".");
7724
- var finding = (file, path15, reason) => ({ file, path: path15, reason });
7773
+ var finding = (file, path17, reason) => ({ file, path: path17, reason });
7725
7774
  function stripJsonc(text2) {
7726
7775
  let out2 = "";
7727
7776
  let inStr = false;
@@ -8039,7 +8088,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8039
8088
 
8040
8089
  // src/setup/pi-gate.ts
8041
8090
  import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync4 } from "node:fs";
8042
- import path3 from "node:path";
8091
+ import path5 from "node:path";
8043
8092
  var OWN_FILE = "pi/index.js";
8044
8093
  var EXTENSIONS_KEY = "extensions";
8045
8094
  var PROJECT_DIR = ".pi";
@@ -8058,7 +8107,7 @@ var real = (p3) => {
8058
8107
  try {
8059
8108
  return realpathSync4(p3);
8060
8109
  } catch {
8061
- return path3.resolve(p3);
8110
+ return path5.resolve(p3);
8062
8111
  }
8063
8112
  };
8064
8113
  function sourceName(source) {
@@ -8086,14 +8135,14 @@ function ownEntries(src, pkgDir) {
8086
8135
  return out2;
8087
8136
  }
8088
8137
  function matchesAny(patterns, pkgDir) {
8089
- const abs = path3.join(pkgDir, OWN_FILE).split(path3.sep).join("/");
8138
+ const abs = path5.join(pkgDir, OWN_FILE).split(path5.sep).join("/");
8090
8139
  return patterns.some((p3) => {
8091
8140
  const g2 = p3.startsWith("./") ? p3.slice(2) : p3;
8092
- return [OWN_FILE, path3.posix.basename(OWN_FILE), abs].some((c3) => path3.posix.matchesGlob(c3, g2));
8141
+ return [OWN_FILE, path5.posix.basename(OWN_FILE), abs].some((c3) => path5.posix.matchesGlob(c3, g2));
8093
8142
  });
8094
8143
  }
8095
8144
  var exactAny = (patterns, pkgDir) => {
8096
- const abs = path3.join(pkgDir, OWN_FILE).split(path3.sep).join("/");
8145
+ const abs = path5.join(pkgDir, OWN_FILE).split(path5.sep).join("/");
8097
8146
  return patterns.some((p3) => {
8098
8147
  const g2 = p3.startsWith("./") ? p3.slice(2) : p3;
8099
8148
  return g2 === OWN_FILE || g2 === abs;
@@ -8110,14 +8159,14 @@ function loads(patterns, pkgDir) {
8110
8159
  return on;
8111
8160
  }
8112
8161
  function projectTrusted(agentDir, userDoc, cwd) {
8113
- const trust = load(path3.join(agentDir, TRUST_FILE));
8162
+ const trust = load(path5.join(agentDir, TRUST_FILE));
8114
8163
  const entries = /* @__PURE__ */ new Map();
8115
8164
  if (trust && typeof trust.doc === "object" && trust.doc !== null) for (const [k, v] of Object.entries(trust.doc)) entries.set(real(k), v);
8116
8165
  let dir = real(cwd);
8117
8166
  for (; ; ) {
8118
8167
  const v = entries.get(dir);
8119
8168
  if (v === true || v === false) return v;
8120
- const up = path3.dirname(dir);
8169
+ const up = path5.dirname(dir);
8121
8170
  if (up === dir) break;
8122
8171
  dir = up;
8123
8172
  }
@@ -8125,8 +8174,8 @@ function projectTrusted(agentDir, userDoc, cwd) {
8125
8174
  }
8126
8175
  function piSettingsGate(env, home, pkgDir, cwd) {
8127
8176
  const agentDir = piAgentDirOf(env, home);
8128
- const user = load(path3.join(agentDir, SETTINGS_FILE));
8129
- const project = load(path3.join(cwd, PROJECT_DIR, SETTINGS_FILE));
8177
+ const user = load(path5.join(agentDir, SETTINGS_FILE));
8178
+ const project = load(path5.join(cwd, PROJECT_DIR, SETTINGS_FILE));
8130
8179
  const projectOwn = project && projectTrusted(agentDir, user?.doc, cwd) ? ownEntries(project, pkgDir) : [];
8131
8180
  const effective = projectOwn.length ? projectOwn : user ? ownEntries(user, pkgDir) : [];
8132
8181
  for (const e of effective) {
@@ -8137,6 +8186,77 @@ function piSettingsGate(env, home, pkgDir, cwd) {
8137
8186
  return void 0;
8138
8187
  }
8139
8188
 
8189
+ // src/core/ops/doctor-env.ts
8190
+ import { existsSync as existsSync9, readFileSync as readFileSync6, realpathSync as realpathSync5 } from "node:fs";
8191
+ import { isAbsolute as isAbsolute3, join as join10, relative as relative2 } from "node:path";
8192
+
8193
+ // src/core/ops/omp-import.ts
8194
+ import { join as join11 } from "node:path";
8195
+ var { existsSync: existsSync10, readFileSync: readFileSync7 } = process.getBuiltinModule("node:fs");
8196
+ var OMP_DISABLED_SERVERS_KEY = "disabledServers";
8197
+ var OMP_MCP_FILE = "mcp.json";
8198
+ var OMP_CONFIG_FILE = "config.yml";
8199
+ var ENABLED_PROVIDERS = "enabledProviders";
8200
+ var DISABLED_PROVIDERS = "disabledProviders";
8201
+ var CLAUDE_PROVIDER = "claude";
8202
+ var ALL_PROVIDERS = ["*", "all"];
8203
+ function ompImportFiles(home) {
8204
+ const agentDir = join11(home, ...AGENT_HOME_DIR.omp, PI_AGENT_DIR);
8205
+ return { config: join11(agentDir, OMP_CONFIG_FILE), mcp: join11(agentDir, OMP_MCP_FILE), claude: join11(home, CLAUDE_USER_CONFIG_FILE) };
8206
+ }
8207
+ function readText2(file) {
8208
+ try {
8209
+ return existsSync10(file) ? hostText(readFileSync7(file, "utf8")) : void 0;
8210
+ } catch {
8211
+ return void 0;
8212
+ }
8213
+ }
8214
+ var unquote = (s) => {
8215
+ const t2 = s.trim();
8216
+ const q = t2[0];
8217
+ return (q === '"' || q === "'") && t2.endsWith(q) && t2.length > 1 ? t2.slice(1, -1) : t2;
8218
+ };
8219
+ var withoutComment = (s) => {
8220
+ const at = s.indexOf(" #");
8221
+ return at === -1 ? s : s.slice(0, at);
8222
+ };
8223
+ function yamlTopList(text2, key) {
8224
+ const lines = text2.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
8225
+ const head = `${key}:`;
8226
+ const at = lines.findIndex((l) => l.startsWith(head));
8227
+ if (at === -1) return [];
8228
+ const rest = withoutComment(lines[at].slice(head.length)).trim();
8229
+ if (rest.startsWith("[")) {
8230
+ const end = rest.indexOf("]");
8231
+ return (end === -1 ? rest.slice(1) : rest.slice(1, end)).split(",").map(unquote).filter((x2) => x2 !== "");
8232
+ }
8233
+ if (rest !== "") return [];
8234
+ const out2 = [];
8235
+ for (const line of lines.slice(at + 1)) {
8236
+ const t2 = line.trim();
8237
+ if (t2 === "" || t2.startsWith("#")) continue;
8238
+ if (line === line.trimStart() && !t2.startsWith("-")) break;
8239
+ if (!t2.startsWith("-")) break;
8240
+ out2.push(unquote(withoutComment(t2.slice(1))));
8241
+ }
8242
+ return out2;
8243
+ }
8244
+ function ompImportsUs(files, env) {
8245
+ const config = readText2(files.config) ?? "";
8246
+ if (yamlTopList(config, DISABLED_PROVIDERS).includes(CLAUDE_PROVIDER)) return false;
8247
+ const enabled = yamlTopList(config, ENABLED_PROVIDERS);
8248
+ const dirSet = env[CLAUDE_CONFIG_DIR_ENV] !== void 0 && env[CLAUDE_CONFIG_DIR_ENV] !== "";
8249
+ if (!dirSet && !enabled.some((p3) => p3 === CLAUDE_PROVIDER || ALL_PROVIDERS.includes(p3))) return false;
8250
+ const claude = readText2(files.claude);
8251
+ if (claude === void 0) return false;
8252
+ try {
8253
+ const servers = JSON.parse(claude)[MCP_SERVERS_KEY];
8254
+ return typeof servers === "object" && servers !== null && Object.hasOwn(servers, SERVER_KEY);
8255
+ } catch {
8256
+ return false;
8257
+ }
8258
+ }
8259
+
8140
8260
  // src/core/ops/doctor-config.ts
8141
8261
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
8142
8262
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -8206,17 +8326,17 @@ function opencodePluginDirs(configDir, worktree) {
8206
8326
  return [configDir, opencodeProjectDir(worktree)];
8207
8327
  }
8208
8328
  function opencodeProjectDir(worktree) {
8209
- return join10(worktree, OPENCODE_PROJECT_DIR);
8329
+ return join12(worktree, OPENCODE_PROJECT_DIR);
8210
8330
  }
8211
8331
  function packageResolves(fromDir) {
8212
8332
  for (let d = fromDir; ; d = dirname7(d)) {
8213
- if (existsSync9(join10(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
8333
+ if (existsSync11(join12(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
8214
8334
  if (dirname7(d) === d) return false;
8215
8335
  }
8216
8336
  }
8217
8337
  function opencodeDirPlugins(dirs) {
8218
8338
  const bundle = opencodePluginFile();
8219
- const ownFile = join10(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
8339
+ const ownFile = join12(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
8220
8340
  const isModule = (p3) => OWN_PLUGIN_MODULES.includes(p3);
8221
8341
  const isPath = (p3) => {
8222
8342
  if (p3 === ownFile || p3 === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -8226,7 +8346,7 @@ function opencodeDirPlugins(dirs) {
8226
8346
  };
8227
8347
  const out2 = [];
8228
8348
  for (const dir of dirs) {
8229
- const pdir = join10(dir, OPENCODE_PLUGINS_DIR);
8349
+ const pdir = join12(dir, OPENCODE_PLUGINS_DIR);
8230
8350
  let names;
8231
8351
  try {
8232
8352
  names = readdirSync5(pdir);
@@ -8234,12 +8354,12 @@ function opencodeDirPlugins(dirs) {
8234
8354
  continue;
8235
8355
  }
8236
8356
  for (const name of names) {
8237
- const loose = OPENCODE_PLUGIN_EXTS.some((x2) => name.endsWith(x2)) ? [join10(pdir, name)] : [];
8238
- const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x2) => join10(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x2}`))];
8357
+ const loose = OPENCODE_PLUGIN_EXTS.some((x2) => name.endsWith(x2)) ? [join12(pdir, name)] : [];
8358
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x2) => join12(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x2}`))];
8239
8359
  for (const f2 of files) {
8240
8360
  let text2;
8241
8361
  try {
8242
- const b3 = readFileSync6(f2);
8362
+ const b3 = readFileSync8(f2);
8243
8363
  if (b3.length > OPENCODE_DIR_FILE_MAX) continue;
8244
8364
  text2 = b3.toString("utf8");
8245
8365
  } catch {
@@ -8250,7 +8370,7 @@ function opencodeDirPlugins(dirs) {
8250
8370
  const loads2 = lits.some((p3) => {
8251
8371
  if (isModule(p3)) return packageResolves(dirname7(f2));
8252
8372
  const bare = p3.startsWith(FILE_URL_PREFIX) ? p3.slice(FILE_URL_PREFIX.length) : p3;
8253
- return existsSync9(isAbsolute3(bare) ? bare : resolve5(dirname7(f2), bare));
8373
+ return existsSync11(isAbsolute4(bare) ? bare : resolve5(dirname7(f2), bare));
8254
8374
  });
8255
8375
  out2.push({ file: f2, loads: loads2 });
8256
8376
  }
@@ -8270,8 +8390,8 @@ function formUrl(title, summary) {
8270
8390
  }
8271
8391
 
8272
8392
  // src/setup/registry.ts
8273
- import { existsSync as existsSync11, realpathSync as realpathSync6 } from "node:fs";
8274
- import path4 from "node:path";
8393
+ import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
8394
+ import path6 from "node:path";
8275
8395
 
8276
8396
  // src/setup/hook-shapes.ts
8277
8397
  var MS_PER_SECOND = 1e3;
@@ -8322,7 +8442,9 @@ var HOOK_SHAPES = {
8322
8442
  kiro: kiroShape,
8323
8443
  zcode: zcodeShape,
8324
8444
  pi: null,
8325
- opencode: null
8445
+ opencode: null,
8446
+ omp: null
8447
+ // ADR-0026: in-process like pi
8326
8448
  };
8327
8449
 
8328
8450
  // src/setup/registry.ts
@@ -8356,11 +8478,11 @@ var OPENCODE_HOME_SEGS = AGENT_HOME_DIR.opencode;
8356
8478
  function agentPath(ctx, id, rel) {
8357
8479
  const segs = typeof rel === "string" ? rel.split("/") : [...rel];
8358
8480
  const codexHome = ctx.env[CODEX_HOME_ENV2];
8359
- if (id === "codex" && segs[0] === CODEX_DIR && codexHome !== void 0 && codexHome !== "") return path4.join(codexHome, ...segs.slice(1));
8360
- if (id === "copilot-cli" && segs[0] === COPILOT_DIR) return path4.join(copilotDirOf(ctx.env, ctx.home), ...segs.slice(1));
8361
- if (id === "kiro" && segs[0] === KIRO_DIR) return path4.join(kiroDirOf(ctx.env, ctx.home), ...segs.slice(1));
8362
- if (id === "opencode" && segs[0] === OPENCODE_HOME_SEGS[0] && segs[1] === OPENCODE_HOME_SEGS[1]) return path4.join(opencodeDirOf(ctx.env, ctx.home), ...segs.slice(2));
8363
- return path4.join(ctx.home, ...segs);
8481
+ if (id === "codex" && segs[0] === CODEX_DIR && codexHome !== void 0 && codexHome !== "") return path6.join(codexHome, ...segs.slice(1));
8482
+ if (id === "copilot-cli" && segs[0] === COPILOT_DIR) return path6.join(copilotDirOf(ctx.env, ctx.home), ...segs.slice(1));
8483
+ if (id === "kiro" && segs[0] === KIRO_DIR) return path6.join(kiroDirOf(ctx.env, ctx.home), ...segs.slice(1));
8484
+ if (id === "opencode" && segs[0] === OPENCODE_HOME_SEGS[0] && segs[1] === OPENCODE_HOME_SEGS[1]) return path6.join(opencodeDirOf(ctx.env, ctx.home), ...segs.slice(2));
8485
+ return path6.join(ctx.home, ...segs);
8364
8486
  }
8365
8487
  function renderSkill(text2, prefix) {
8366
8488
  const prefixes = typeof prefix === "string" ? [prefix] : prefix;
@@ -8390,7 +8512,7 @@ function extensionPlugin(bin, id) {
8390
8512
  };
8391
8513
  }
8392
8514
  var NATIVE_PLUGIN = {
8393
- codex: { bin: "codex", args: ["plugin", "list", "--json"], plugin: PLUGIN_ID, hooksVia: ".codex-plugin", skillsVia: path4.join("codex", SKILLS_DIR_NAME), format: "codex-json", hookTrust: true },
8515
+ codex: { bin: "codex", args: ["plugin", "list", "--json"], plugin: PLUGIN_ID, hooksVia: ".codex-plugin", skillsVia: path6.join("codex", SKILLS_DIR_NAME), format: "codex-json", hookTrust: true },
8394
8516
  qwen: extensionPlugin("qwen", "qwen"),
8395
8517
  gemini: extensionPlugin("gemini", "gemini"),
8396
8518
  // D-R44-ZCODE-NATIVE-1 (host audit zcode-1/2): `zcode plugins install context-mode@context-mode` lists as JSON; ZCode loads
@@ -8407,7 +8529,7 @@ var NATIVE_PLUGIN = {
8407
8529
  };
8408
8530
  var CELLAR_SEGMENT = "/Cellar/";
8409
8531
  var NODE_BIN = ["bin", "node"];
8410
- var REAL_FS = { exists: existsSync11, real: (p3) => realpathSync6.native(p3) };
8532
+ var REAL_FS = { exists: existsSync13, real: (p3) => realpathSync7.native(p3) };
8411
8533
  function stableNodePath(execPath, fs2 = REAL_FS) {
8412
8534
  const at = execPath.indexOf(CELLAR_SEGMENT);
8413
8535
  if (at < 0) return execPath;
@@ -8422,9 +8544,10 @@ function stableNodePath(execPath, fs2 = REAL_FS) {
8422
8544
  }
8423
8545
  return execPath;
8424
8546
  }
8547
+ var BARE_NODE_ON_WINDOWS = ["codex", "qwen", "copilot-cli", "vscode"];
8425
8548
  var SETUP_NODE = stableNodePath(process.execPath);
8426
8549
  function serverCmd(ctx, id) {
8427
- return [SETUP_NODE, path4.join(ctx.pkgDir, SERVER_BUNDLE), AGENT_FLAG, id];
8550
+ return [SETUP_NODE, path6.join(ctx.pkgDir, SERVER_BUNDLE), AGENT_FLAG, id];
8428
8551
  }
8429
8552
  function hookCommandString(row) {
8430
8553
  const [node, file, flag, id] = row.hookCommand ?? [];
@@ -8454,7 +8577,7 @@ function configFor(ctx, id) {
8454
8577
  }
8455
8578
  if (id === "opencode") {
8456
8579
  return {
8457
- file: path4.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
8580
+ file: path6.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
8458
8581
  format: "jsonc",
8459
8582
  key: ["mcp", SERVER_KEY],
8460
8583
  value: { type: "local", command: [node, server, flag, agent], enabled: true }
@@ -8477,13 +8600,16 @@ function cliFor(ctx, id) {
8477
8600
  return { bin: "copilot", install: [["mcp", "add", SERVER_KEY, "--", ...s]], remove: [["mcp", "remove", SERVER_KEY]] };
8478
8601
  case "pi":
8479
8602
  return { bin: "pi", install: [["install", ctx.pkgDir]], remove: [["remove", ctx.pkgDir]] };
8603
+ // ADR-0026 decision 4: OMP installs from its own plugin store by name (T23, T24).
8604
+ case "omp":
8605
+ return { bin: "omp", install: [["plugin", "install", SERVER_KEY]], remove: [["plugin", "uninstall", SERVER_KEY]] };
8480
8606
  default:
8481
8607
  return void 0;
8482
8608
  }
8483
8609
  }
8484
8610
  function copyFor(ctx, id) {
8485
8611
  if (id !== "claude-code") return void 0;
8486
- const file = path4.join(claudeDirOf(ctx.env, ctx.home), HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE);
8612
+ const file = path6.join(claudeDirOf(ctx.env, ctx.home), HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE);
8487
8613
  return {
8488
8614
  host: "Claude Code",
8489
8615
  bin: "claude",
@@ -8502,6 +8628,8 @@ var LIST = {
8502
8628
  qwen: { bin: "qwen", args: ["extensions", "list"] },
8503
8629
  "copilot-cli": { bin: "copilot", args: ["mcp", "list"] },
8504
8630
  pi: { bin: "pi", args: ["list"] },
8631
+ omp: { bin: "omp", args: ["plugin", "list"] },
8632
+ // ADR-0026
8505
8633
  // D-HF-OPENCODE-LIST-1: --pure skips external plugins, so a fresh HOME does not wait on the @opencode-ai/plugin install.
8506
8634
  opencode: { bin: "opencode", args: ["mcp", "list", "--pure"] }
8507
8635
  };
@@ -8513,12 +8641,12 @@ function hookFilesFor(ctx, id) {
8513
8641
  case "copilot-cli":
8514
8642
  return [{ file: agentPath(ctx, id, [COPILOT_DIR, "hooks", "context-mode.json"]), mode: "rewrite" }];
8515
8643
  case "claude-code":
8516
- return [{ file: path4.join(claudeDirOf(ctx.env, home), "settings.json"), mode: "drop" }];
8644
+ return [{ file: path6.join(claudeDirOf(ctx.env, home), "settings.json"), mode: "drop" }];
8517
8645
  case "gemini":
8518
- return [{ file: path4.join(geminiDirOf(ctx.env, home), "settings.json"), mode: "drop" }];
8646
+ return [{ file: path6.join(geminiDirOf(ctx.env, home), "settings.json"), mode: "drop" }];
8519
8647
  // D-R38-GEMINI-HOME-1
8520
8648
  case "qwen":
8521
- return [{ file: path4.join(home, ".qwen", "settings.json"), mode: "drop" }];
8649
+ return [{ file: path6.join(home, ".qwen", "settings.json"), mode: "drop" }];
8522
8650
  default:
8523
8651
  return [];
8524
8652
  }
@@ -8529,13 +8657,13 @@ function hookInstallFor(ctx, row, command) {
8529
8657
  const shape = HOOK_SHAPES[row.id];
8530
8658
  if (!shape) throw new Error(`setup: ${row.id} has a home-file hook channel and no hook shape`);
8531
8659
  const file = agentPath(ctx, row.id, ch.path);
8532
- if (row.id === "codex") return { kind: "file", file, shape: shape(row, command), command, trust: path4.join(path4.dirname(file), CODEX_CONFIG_FILE) };
8660
+ if (row.id === "codex") return { kind: "file", file, shape: shape(row, command), command, trust: path6.join(path6.dirname(file), CODEX_CONFIG_FILE) };
8533
8661
  return { kind: "file", file, shape: shape(row, command), command };
8534
8662
  }
8535
8663
  if (row.id === "opencode") {
8536
8664
  return {
8537
8665
  kind: "plugin-list",
8538
- file: path4.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
8666
+ file: path6.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
8539
8667
  key: ["plugin"],
8540
8668
  worktree: ctx.cwd ?? process.cwd(),
8541
8669
  // D-R54-OC-PLUGINS-DIR-1: <project>/.opencode/plugins
@@ -8553,11 +8681,11 @@ function skillInstallFor(ctx, row) {
8553
8681
  const ch = row.skillChannel;
8554
8682
  if (ch.kind === "package") return { kind: "package", via: ch.path };
8555
8683
  const dir = agentPath(ctx, row.id, ch.path);
8556
- const src = path4.join(ctx.pkgDir, bareSkillDir());
8684
+ const src = path6.join(ctx.pkgDir, bareSkillDir());
8557
8685
  return { kind: "dir", dir, prefixes: skillDirPrefixes(ch.path), files: COMMAND_SKILLS.map((name) => ({
8558
8686
  name,
8559
- src: path4.join(src, name, SKILL_FILE),
8560
- file: path4.join(dir, name, SKILL_FILE)
8687
+ src: path6.join(src, name, SKILL_FILE),
8688
+ file: path6.join(dir, name, SKILL_FILE)
8561
8689
  })) };
8562
8690
  }
8563
8691
  function buildRegistry(ctx) {
@@ -8565,8 +8693,8 @@ function buildRegistry(ctx) {
8565
8693
  const id = row.id;
8566
8694
  const config = configFor(ctx, id);
8567
8695
  const hookFiles = hookFilesFor(ctx, id);
8568
- const runCommand2 = [SETUP_NODE, path4.join(ctx.pkgDir, HOOK_BUNDLE), AGENT_FLAG, id];
8569
- const bareNode = (id === "codex" || id === "qwen") && (ctx.platform ?? process.platform) === "win32";
8696
+ const runCommand2 = [SETUP_NODE, path6.join(ctx.pkgDir, HOOK_BUNDLE), AGENT_FLAG, id];
8697
+ const bareNode = BARE_NODE_ON_WINDOWS.includes(id) && (ctx.platform ?? process.platform) === "win32";
8570
8698
  const hookCommand = bareNode ? [HOST_NODE_COMMAND, ...runCommand2.slice(1)] : runCommand2;
8571
8699
  const command = `${bareNode ? HOST_NODE_COMMAND : `"${hookCommand[0]}"`} "${hookCommand[1]}" ${AGENT_FLAG} ${id}`;
8572
8700
  const hookInstall = hookInstallFor(ctx, getAdapter(id), command);
@@ -8578,7 +8706,9 @@ function buildRegistry(ctx) {
8578
8706
  ...hookFiles.map((h2) => h2.file),
8579
8707
  ...hookInstall.kind === "package" ? [] : [hookInstall.file],
8580
8708
  ...hookInstall.kind === "file" && hookInstall.trust ? [hookInstall.trust] : [],
8581
- ...skillInstall.kind === "dir" ? skillInstall.files.map((f2) => f2.file) : []
8709
+ ...skillInstall.kind === "dir" ? skillInstall.files.map((f2) => f2.file) : [],
8710
+ ...id === "omp" ? [ompImportFiles(ctx.home).mcp] : []
8711
+ // ADR-0026 decision 11: disabledServers, only when OMP imports us
8582
8712
  ];
8583
8713
  const out2 = {
8584
8714
  id,
@@ -8591,7 +8721,7 @@ function buildRegistry(ctx) {
8591
8721
  hookInstall,
8592
8722
  skillInstall,
8593
8723
  hookRunCommand: runCommand2,
8594
- allowedWrites: [...new Set(writes.map((f2) => path4.resolve(f2)))],
8724
+ allowedWrites: [...new Set(writes.map((f2) => path6.resolve(f2)))],
8595
8725
  goldenPayload: golden(row, ctx.home)
8596
8726
  };
8597
8727
  if (copilotSettings) out2.copilotSettings = copilotSettings;
@@ -8604,15 +8734,15 @@ function buildRegistry(ctx) {
8604
8734
  });
8605
8735
  }
8606
8736
  function assertWritable(row, file) {
8607
- const abs = path4.resolve(file);
8608
- if (INSTRUCTION_FILES.includes(path4.basename(abs)) || !row.allowedWrites.includes(abs)) {
8737
+ const abs = path6.resolve(file);
8738
+ if (INSTRUCTION_FILES.includes(path6.basename(abs)) || !row.allowedWrites.includes(abs)) {
8609
8739
  throw new Error(`setup: write to ${abs} is not allowed for ${row.id}`);
8610
8740
  }
8611
8741
  }
8612
8742
 
8613
8743
  // src/setup/gemini-gate.ts
8614
- import { existsSync as existsSync12, readFileSync as readFileSync8 } from "node:fs";
8615
- import path5 from "node:path";
8744
+ import { existsSync as existsSync14, readFileSync as readFileSync10 } from "node:fs";
8745
+ import path7 from "node:path";
8616
8746
  var GEMINI_DIR = ".gemini";
8617
8747
  var SETTINGS_FILE2 = "settings.json";
8618
8748
  var SYSTEM_PATH_ENV = "GEMINI_CLI_SYSTEM_SETTINGS_PATH";
@@ -8628,18 +8758,18 @@ function systemSettingsPath(env) {
8628
8758
  }
8629
8759
  function systemDefaultsPath(env) {
8630
8760
  const set2 = env[SYSTEM_DEFAULTS_ENV];
8631
- return set2 ? set2 : path5.join(path5.dirname(systemSettingsPath(env)), SYSTEM_DEFAULTS_FILE);
8761
+ return set2 ? set2 : path7.join(path7.dirname(systemSettingsPath(env)), SYSTEM_DEFAULTS_FILE);
8632
8762
  }
8633
8763
  function load2(file) {
8634
- if (!existsSync12(file)) return void 0;
8764
+ if (!existsSync14(file)) return void 0;
8635
8765
  try {
8636
- return { file, doc: parseHostConfig(OWN_AGENT, file, hostText(readFileSync8(file, "utf8")), "jsonc") };
8766
+ return { file, doc: parseHostConfig(OWN_AGENT, file, hostText(readFileSync10(file, "utf8")), "jsonc") };
8637
8767
  } catch {
8638
8768
  return void 0;
8639
8769
  }
8640
8770
  }
8641
8771
  function sources(env, home, cwd) {
8642
- return [systemDefaultsPath(env), path5.join(geminiDirOf(env, home), SETTINGS_FILE2), path5.join(cwd, GEMINI_DIR, SETTINGS_FILE2), systemSettingsPath(env)].map(load2).filter((s) => s !== void 0);
8772
+ return [systemDefaultsPath(env), path7.join(geminiDirOf(env, home), SETTINGS_FILE2), path7.join(cwd, GEMINI_DIR, SETTINGS_FILE2), systemSettingsPath(env)].map(load2).filter((s) => s !== void 0);
8643
8773
  }
8644
8774
  function ownHookEntry(entry2) {
8645
8775
  return typeof entry2 === "string" && entry2.includes(HOOK_BUNDLE) && entry2.includes(`${AGENT_FLAG} ${OWN_AGENT}`);
@@ -8665,8 +8795,8 @@ function geminiSettingsGate(env, home, cwd) {
8665
8795
  }
8666
8796
 
8667
8797
  // src/setup/zcode-gate.ts
8668
- import { existsSync as existsSync13, readFileSync as readFileSync9 } from "node:fs";
8669
- import path6 from "node:path";
8798
+ import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
8799
+ import path8 from "node:path";
8670
8800
  var OWN_AGENT2 = "zcode";
8671
8801
  var EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "PostToolUse", "PostToolUseFailure", "Stop"];
8672
8802
  var HOOK_TYPES = ["process", "command"];
@@ -8756,11 +8886,11 @@ function zcodeSchemaBad(doc) {
8756
8886
  );
8757
8887
  }
8758
8888
  function zcodeConfigGate(home) {
8759
- const file = path6.join(home, ".zcode", "cli", "config.json");
8760
- if (!existsSync13(file)) return void 0;
8889
+ const file = path8.join(home, ".zcode", "cli", "config.json");
8890
+ if (!existsSync15(file)) return void 0;
8761
8891
  let doc;
8762
8892
  try {
8763
- doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync9(file, "utf8")), "json");
8893
+ doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync11(file, "utf8")), "json");
8764
8894
  } catch {
8765
8895
  return void 0;
8766
8896
  }
@@ -8770,8 +8900,8 @@ function zcodeConfigGate(home) {
8770
8900
  }
8771
8901
 
8772
8902
  // src/setup/vscode-gate.ts
8773
- import { existsSync as existsSync14, readFileSync as readFileSync10 } from "node:fs";
8774
- import path7 from "node:path";
8903
+ import { existsSync as existsSync16, readFileSync as readFileSync12 } from "node:fs";
8904
+ import path9 from "node:path";
8775
8905
  var SETTINGS_FILE3 = "settings.json";
8776
8906
  var WORKSPACE_DIR = ".vscode";
8777
8907
  var USE_HOOKS_KEY = "chat.useHooks";
@@ -8779,16 +8909,16 @@ var LOCATIONS_KEY = "chat.hookFilesLocations";
8779
8909
  var OWN_LOCATION = "~/.copilot/hooks";
8780
8910
  var MANAGED_KEYS = ["allowManagedHooksOnly", "strictPluginOnlyCustomization"];
8781
8911
  function load3(file) {
8782
- if (!existsSync14(file)) return void 0;
8912
+ if (!existsSync16(file)) return void 0;
8783
8913
  try {
8784
- return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync10(file, "utf8")), "jsonc") };
8914
+ return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync12(file, "utf8")), "jsonc") };
8785
8915
  } catch {
8786
8916
  return void 0;
8787
8917
  }
8788
8918
  }
8789
8919
  function managedSettingsPath(env) {
8790
8920
  if (process.platform === "darwin") return "/Library/Application Support/GitHubCopilot/managed-settings.json";
8791
- if (process.platform === "win32") return path7.join(env.ProgramFiles || "C:\\Program Files", "GitHubCopilot", "managed-settings.json");
8921
+ if (process.platform === "win32") return path9.join(env.ProgramFiles || "C:\\Program Files", "GitHubCopilot", "managed-settings.json");
8792
8922
  return "/etc/github-copilot/managed-settings.json";
8793
8923
  }
8794
8924
  function vscodeSettingsGate(env, home, cwd, managedFile = managedSettingsPath(env)) {
@@ -8800,7 +8930,7 @@ function vscodeSettingsGate(env, home, cwd, managedFile = managedSettingsPath(en
8800
8930
  }
8801
8931
  }
8802
8932
  }
8803
- const srcs = [path7.join(vscodeUserDirOf(env, home), SETTINGS_FILE3), path7.join(cwd, WORKSPACE_DIR, SETTINGS_FILE3)].map(load3).filter((s) => s !== void 0);
8933
+ const srcs = [path9.join(vscodeUserDirOf(env, home), SETTINGS_FILE3), path9.join(cwd, WORKSPACE_DIR, SETTINGS_FILE3)].map(load3).filter((s) => s !== void 0);
8804
8934
  let hooks;
8805
8935
  let locations;
8806
8936
  for (const s of srcs) {
@@ -8821,8 +8951,8 @@ function vscodeSettingsGate(env, home, cwd, managedFile = managedSettingsPath(en
8821
8951
  }
8822
8952
 
8823
8953
  // src/setup/qwen-gate.ts
8824
- import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
8825
- import path8 from "node:path";
8954
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "node:fs";
8955
+ import path10 from "node:path";
8826
8956
  var KEY = "disableAllHooks";
8827
8957
  var SETTINGS = "settings.json";
8828
8958
  var SYSTEM_ENV = "QWEN_CODE_SYSTEM_SETTINGS_PATH";
@@ -8832,15 +8962,15 @@ var WIN_SYSTEM = "C:\\ProgramData\\qwen-code\\settings.json";
8832
8962
  var LINUX_SYSTEM = "/etc/qwen-code/settings.json";
8833
8963
  function settingsFiles(env, home, cwd, platform) {
8834
8964
  const sys = env[SYSTEM_ENV] || (platform === "darwin" ? DARWIN_SYSTEM : platform === "win32" ? WIN_SYSTEM : LINUX_SYSTEM);
8835
- const userDir = env[HOME_ENV] || path8.join(home, ".qwen");
8836
- return [sys, path8.join(userDir, SETTINGS), path8.join(cwd, ".qwen", SETTINGS)];
8965
+ const userDir = env[HOME_ENV] || path10.join(home, ".qwen");
8966
+ return [sys, path10.join(userDir, SETTINGS), path10.join(cwd, ".qwen", SETTINGS)];
8837
8967
  }
8838
8968
  function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platform) {
8839
8969
  for (const file of settingsFiles(env, home, cwd, platform)) {
8840
- if (!existsSync15(file)) continue;
8970
+ if (!existsSync17(file)) continue;
8841
8971
  let value;
8842
8972
  try {
8843
- value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync11(file, "utf8")), "jsonc"), [KEY]);
8973
+ value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync13(file, "utf8")), "jsonc"), [KEY]);
8844
8974
  } catch {
8845
8975
  continue;
8846
8976
  }
@@ -8851,14 +8981,14 @@ function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platfor
8851
8981
 
8852
8982
  // src/setup/codex-trust.ts
8853
8983
  import { createHash } from "node:crypto";
8854
- import { existsSync as existsSync16, realpathSync as realpathSync7 } from "node:fs";
8855
- import path10 from "node:path";
8856
- import { spawn, spawnSync as spawnSync3 } from "node:child_process";
8984
+ import { existsSync as existsSync18, realpathSync as realpathSync8 } from "node:fs";
8985
+ import path12 from "node:path";
8986
+ import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
8857
8987
 
8858
8988
  // src/setup/spawn-bin.ts
8859
8989
  import { spawnSync as spawnSync2 } from "node:child_process";
8860
- import { accessSync, constants as fsc, statSync } from "node:fs";
8861
- import path9 from "node:path";
8990
+ import { accessSync as accessSync2, constants as fsc, statSync as statSync2 } from "node:fs";
8991
+ import path11 from "node:path";
8862
8992
  var WIN_EXT = ".COM;.EXE;.BAT;.CMD";
8863
8993
  var WIN_SHIM_EXTS = Object.freeze([".cmd", ".bat"]);
8864
8994
  var DEFAULT_COMSPEC = "cmd.exe";
@@ -8869,13 +8999,13 @@ function whichBin(bin, env, platform = process.platform) {
8869
8999
  const get = (k) => envGet(env, k);
8870
9000
  const win = platform === "win32";
8871
9001
  const exts = win ? (get("PATHEXT") || WIN_EXT).split(";").filter(Boolean) : [""];
8872
- const names = win && path9.extname(bin) ? [bin] : exts.map((e) => bin + e.toLowerCase());
9002
+ const names = win && path11.extname(bin) ? [bin] : exts.map((e) => bin + e.toLowerCase());
8873
9003
  for (const dir of pathEntries(get("PATH") ?? "", platform)) {
8874
9004
  for (const n3 of names) {
8875
- const f2 = path9.join(dir, n3);
9005
+ const f2 = path11.join(dir, n3);
8876
9006
  try {
8877
- accessSync(f2, fsc.X_OK);
8878
- if (statSync(f2).isFile()) return f2;
9007
+ accessSync2(f2, fsc.X_OK);
9008
+ if (statSync2(f2).isFile()) return f2;
8879
9009
  } catch {
8880
9010
  }
8881
9011
  }
@@ -8913,7 +9043,7 @@ function winCmdLine(file, args, env = {}) {
8913
9043
  return `"${[file, ...args].map(q).join(" ")}"`;
8914
9044
  }
8915
9045
  function spawnForm(file, args, env, platform = process.platform) {
8916
- if (platform === "win32" && WIN_SHIM_EXTS.includes(path9.extname(file).toLowerCase())) {
9046
+ if (platform === "win32" && WIN_SHIM_EXTS.includes(path11.extname(file).toLowerCase())) {
8917
9047
  return { command: envGet(env, "COMSPEC") || DEFAULT_COMSPEC, args: ["/d", "/v:off", "/s", "/c", winCmdLine(file, args, env)], windowsVerbatimArguments: true };
8918
9048
  }
8919
9049
  return { command: file, args, windowsVerbatimArguments: false };
@@ -8950,13 +9080,13 @@ function snake(name) {
8950
9080
  return out2;
8951
9081
  }
8952
9082
  function realFile(file) {
8953
- let dir = path10.resolve(file);
9083
+ let dir = path12.resolve(file);
8954
9084
  const rest = [];
8955
- while (!existsSync16(dir) && path10.dirname(dir) !== dir) {
8956
- rest.unshift(path10.basename(dir));
8957
- dir = path10.dirname(dir);
9085
+ while (!existsSync18(dir) && path12.dirname(dir) !== dir) {
9086
+ rest.unshift(path12.basename(dir));
9087
+ dir = path12.dirname(dir);
8958
9088
  }
8959
- return path10.join(realpathSync7(dir), ...rest);
9089
+ return path12.join(realpathSync8(dir), ...rest);
8960
9090
  }
8961
9091
  var ASK_TIMEOUT_MS = 1e4;
8962
9092
  var ASK_TRIES = 3;
@@ -8985,10 +9115,10 @@ function askCodexHome(env) {
8985
9115
  return void 0;
8986
9116
  }
8987
9117
  function sameDir(a2, b3, platform = process.platform) {
8988
- if (platform !== "win32") return path10.posix.normalize(a2) === path10.posix.normalize(b3);
9118
+ if (platform !== "win32") return path12.posix.normalize(a2) === path12.posix.normalize(b3);
8989
9119
  const norm = (p3) => {
8990
9120
  const bare = p3.startsWith(WIN_VERBATIM_PREFIX) ? p3.slice(WIN_VERBATIM_PREFIX.length) : p3;
8991
- const n3 = path10.win32.normalize(bare).toLowerCase();
9121
+ const n3 = path12.win32.normalize(bare).toLowerCase();
8992
9122
  return n3.length > 3 && n3.endsWith("\\") ? n3.slice(0, -1) : n3;
8993
9123
  };
8994
9124
  return norm(a2) === norm(b3);
@@ -8999,9 +9129,9 @@ function codexKeyDir(o2, platform = process.platform) {
8999
9129
  function codexTrustEntries(hooksFile, doc, command, env) {
9000
9130
  const out2 = [];
9001
9131
  if (!isObj3(doc) || !isObj3(doc.hooks)) return out2;
9002
- const abs = path10.resolve(hooksFile);
9003
- const dir = codexKeyDir({ dir: path10.dirname(abs), asked: env ? askCodexHome(env) : void 0, real: env && !env.CODEX_HOME ? (p3) => path10.resolve(p3) : realFile });
9004
- const real2 = (dir.startsWith(WIN_VERBATIM_PREFIX) ? path10.win32 : path10).join(dir, path10.basename(abs));
9132
+ const abs = path12.resolve(hooksFile);
9133
+ const dir = codexKeyDir({ dir: path12.dirname(abs), asked: env ? askCodexHome(env) : void 0, real: env && !env.CODEX_HOME ? (p3) => path12.resolve(p3) : realFile });
9134
+ const real2 = (dir.startsWith(WIN_VERBATIM_PREFIX) ? path12.win32 : path12).join(dir, path12.basename(abs));
9005
9135
  for (const [event, groups] of Object.entries(doc.hooks)) {
9006
9136
  if (!Array.isArray(groups)) continue;
9007
9137
  groups.forEach((g2, gi) => {
@@ -9054,7 +9184,7 @@ function askPluginHooks(env, pluginId, cwd) {
9054
9184
  resolve6({ kind: "silent" });
9055
9185
  return;
9056
9186
  }
9057
- const child = spawn(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
9187
+ const child = spawn3(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
9058
9188
  let buf = "";
9059
9189
  let done = false;
9060
9190
  let exited = false;
@@ -9156,18 +9286,18 @@ function untrustedPluginHooksDetail(hooks) {
9156
9286
  }
9157
9287
 
9158
9288
  // src/setup/copilot-hooks.ts
9159
- import { spawn as spawn2 } from "node:child_process";
9160
- import { realpathSync as realpathSync8 } from "node:fs";
9161
- import path11 from "node:path";
9289
+ import { spawn as spawn4 } from "node:child_process";
9290
+ import { realpathSync as realpathSync9 } from "node:fs";
9291
+ import path13 from "node:path";
9162
9292
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
9163
9293
  var ASK_TIMEOUT_MS2 = 15e3;
9164
9294
  var HEADER_END = "\r\n\r\n";
9165
9295
  var LENGTH_HEADER = "content-length";
9166
9296
  var USER_ORIGIN = "user";
9167
9297
  function canon(p3) {
9168
- let r2 = path11.resolve(p3);
9298
+ let r2 = path13.resolve(p3);
9169
9299
  try {
9170
- r2 = realpathSync8(r2);
9300
+ r2 = realpathSync9(r2);
9171
9301
  } catch {
9172
9302
  }
9173
9303
  return process.platform === "win32" ? r2.toLowerCase() : r2;
@@ -9176,10 +9306,10 @@ function copilotHooksFromReply(m3, file) {
9176
9306
  const out2 = [];
9177
9307
  if (!isObj4(m3) || !isObj4(m3.result) || !Array.isArray(m3.result.hooks)) return out2;
9178
9308
  const want = canon(file);
9179
- const base = path11.dirname(path11.dirname(path11.resolve(file)));
9309
+ const base = path13.dirname(path13.dirname(path13.resolve(file)));
9180
9310
  for (const h2 of m3.result.hooks) {
9181
9311
  if (!isObj4(h2) || h2.origin !== USER_ORIGIN || typeof h2.source !== "string" || typeof h2.hookType !== "string" || typeof h2.enabled !== "boolean") continue;
9182
- if (canon(path11.isAbsolute(h2.source) ? h2.source : path11.join(base, h2.source)) !== want) continue;
9312
+ if (canon(path13.isAbsolute(h2.source) ? h2.source : path13.join(base, h2.source)) !== want) continue;
9183
9313
  out2.push({ event: h2.hookType, source: h2.source, enabled: h2.enabled, ...typeof h2.disableKey === "string" ? { disableKey: h2.disableKey } : {} });
9184
9314
  }
9185
9315
  return out2;
@@ -9208,7 +9338,7 @@ function listCopilotHooks(env, file, cwd) {
9208
9338
  resolve6(void 0);
9209
9339
  return;
9210
9340
  }
9211
- const child = spawn2(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
9341
+ const child = spawn4(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
9212
9342
  let buf = Buffer.alloc(0);
9213
9343
  let done = false;
9214
9344
  const finish2 = (v) => {
@@ -9251,10 +9381,10 @@ function listCopilotHooks(env, file, cwd) {
9251
9381
  }
9252
9382
 
9253
9383
  // src/setup/engine.ts
9254
- import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
9255
- import { closeSync as closeSync3, existsSync as existsSync17, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync12, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync9, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
9384
+ import { spawn as spawn5, spawnSync as spawnSync4 } from "node:child_process";
9385
+ import { closeSync as closeSync3, existsSync as existsSync19, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync14, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync10, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "node:fs";
9256
9386
  import { tmpdir as tmpdir2 } from "node:os";
9257
- import path12 from "node:path";
9387
+ import path14 from "node:path";
9258
9388
 
9259
9389
  // src/setup/hook-sample.ts
9260
9390
  var SAMPLE_FILE = "big.log";
@@ -9291,6 +9421,7 @@ function hookSample(id, cwd, text2) {
9291
9421
  case "copilot-cli":
9292
9422
  return { effect, payload: { sessionId: SAMPLE_SESSION, timestamp: Date.now(), cwd, toolName: tool, toolArgs: JSON.stringify(command), toolResult: { resultType: "success", textResultForLlm: text2 } } };
9293
9423
  case "pi":
9424
+ case "omp":
9294
9425
  return { effect, payload: { type: event, sessionId: SAMPLE_SESSION, cwd, toolName: tool, input: command, content: text2, isError: false } };
9295
9426
  case "opencode":
9296
9427
  return { effect, payload: { type: event, sessionID: SAMPLE_SESSION, directory: cwd, tool, args: command, ...effect === "replace" ? { output: text2 } : {} } };
@@ -9348,16 +9479,16 @@ function isNativeBinary(file) {
9348
9479
  return BINARY_MAGICS.some((m3) => hex.startsWith(m3));
9349
9480
  }
9350
9481
  function owningPackage(dir) {
9351
- for (let d = dir; ; d = path12.dirname(d)) {
9352
- const f2 = path12.join(d, "package.json");
9353
- if (existsSync17(f2)) {
9482
+ for (let d = dir; ; d = path14.dirname(d)) {
9483
+ const f2 = path14.join(d, "package.json");
9484
+ if (existsSync19(f2)) {
9354
9485
  try {
9355
- return String(JSON.parse(hostText(readFileSync12(f2, "utf8"))).name);
9486
+ return String(JSON.parse(hostText(readFileSync14(f2, "utf8"))).name);
9356
9487
  } catch {
9357
9488
  return void 0;
9358
9489
  }
9359
9490
  }
9360
- if (path12.dirname(d) === d) return void 0;
9491
+ if (path14.dirname(d) === d) return void 0;
9361
9492
  }
9362
9493
  }
9363
9494
  function hostBin(bin, env, platform = process.platform) {
@@ -9367,10 +9498,10 @@ function hostBin(bin, env, platform = process.platform) {
9367
9498
  const shims = [];
9368
9499
  for (const dir of pathEntries(get("PATH") ?? "", platform)) {
9369
9500
  const own2 = which(bin, { PATH: dir, ...get("PATHEXT") ? { PATHEXT: get("PATHEXT") } : {} }, platform);
9370
- for (const f2 of [own2, ...real2.extra.map((p3) => path12.join(dir, ...p3))]) {
9371
- if (!f2 || !existsSync17(f2) || !statSync2(f2).isFile()) continue;
9372
- const file = realpathSync9(f2);
9373
- if (isNativeBinary(file) || owningPackage(path12.dirname(file)) === real2.pkg) return { file: f2, shims };
9501
+ for (const f2 of [own2, ...real2.extra.map((p3) => path14.join(dir, ...p3))]) {
9502
+ if (!f2 || !existsSync19(f2) || !statSync3(f2).isFile()) continue;
9503
+ const file = realpathSync10(f2);
9504
+ if (isNativeBinary(file) || owningPackage(path14.dirname(file)) === real2.pkg) return { file: f2, shims };
9374
9505
  shims.push(f2);
9375
9506
  }
9376
9507
  }
@@ -9385,10 +9516,10 @@ function runBin(bin, args, env, input, timeout = VERIFY_TIMEOUT_MS) {
9385
9516
  return spawnShim(hostBin(bin, env).file ?? bin, args, env, { encoding: "utf8", input, timeout, maxBuffer: Infinity });
9386
9517
  }
9387
9518
  function readOr(file) {
9388
- return existsSync17(file) ? hostText(readFileSync12(file, "utf8")) : void 0;
9519
+ return existsSync19(file) ? hostText(readFileSync14(file, "utf8")) : void 0;
9389
9520
  }
9390
9521
  function readRaw(file) {
9391
- return existsSync17(file) ? readFileSync12(file, "utf8") : void 0;
9522
+ return existsSync19(file) ? readFileSync14(file, "utf8") : void 0;
9392
9523
  }
9393
9524
  var atomicWrite = atomicWriteFile;
9394
9525
  function pidAlive(pid) {
@@ -9530,9 +9661,9 @@ function isNativeSpec(e) {
9530
9661
  return isNativeOpencodeEntry(e, OPENCODE_PLUGIN_KEY);
9531
9662
  }
9532
9663
  function isStaleOwnPlugin(e, entry2) {
9533
- if (typeof e !== "string" || e === entry2 || !path12.isAbsolute(e)) return false;
9534
- if (e === path12.join(entry2, ...OPENCODE_PLUGIN_PATH)) return true;
9535
- if (existsSync17(e)) return false;
9664
+ if (typeof e !== "string" || e === entry2 || !path14.isAbsolute(e)) return false;
9665
+ if (e === path14.join(entry2, ...OPENCODE_PLUGIN_PATH)) return true;
9666
+ if (existsSync19(e)) return false;
9536
9667
  const seg = e.split("\\").join("/").split("/");
9537
9668
  const n3 = seg.length;
9538
9669
  if (n3 >= 3 && seg[n3 - 1] === "plugin.js" && seg[n3 - 2] === "opencode" && seg[n3 - 3] === "context-mode") return true;
@@ -9549,8 +9680,8 @@ function nativePluginsKey(doc, file) {
9549
9680
  return Array.isArray(v) && v.some((e) => isNativeOpencodeEntry(e, k));
9550
9681
  });
9551
9682
  if (native(doc)) return true;
9552
- if (opencodeDirPlugin([path12.dirname(file)]) !== void 0) return true;
9553
- return OPENCODE_CONFIG_FILES.map((n3) => path12.join(path12.dirname(file), n3)).filter((f2) => f2 !== file).some((f2) => {
9683
+ if (opencodeDirPlugin([path14.dirname(file)]) !== void 0) return true;
9684
+ return OPENCODE_CONFIG_FILES.map((n3) => path14.join(path14.dirname(file), n3)).filter((f2) => f2 !== file).some((f2) => {
9554
9685
  const text2 = readOr(f2);
9555
9686
  if (text2 === void 0 || text2.trim() === "") return false;
9556
9687
  try {
@@ -9620,12 +9751,20 @@ function planSkills(row, edits) {
9620
9751
  const s = row.skillInstall;
9621
9752
  if (s.kind !== "dir") return;
9622
9753
  for (const f2 of s.files) {
9623
- if (!existsSync17(f2.src)) throw new Error(`preflight: ${f2.src} is missing`);
9624
- const after = renderSkill(readFileSync12(f2.src, "utf8"), s.prefixes);
9754
+ if (!existsSync19(f2.src)) throw new Error(`preflight: ${f2.src} is missing`);
9755
+ const after = renderSkill(readFileSync14(f2.src, "utf8"), s.prefixes);
9625
9756
  const before = readRaw(f2.file);
9626
9757
  if (before !== after) edits.push({ plain: true, file: f2.file, before, after, changes: [{ file: f2.file, path: f2.name, before: before === void 0 ? null : "old", after: "SKILL.md" }] });
9627
9758
  }
9628
9759
  }
9760
+ function planOmpImport(row, edits, ctx) {
9761
+ const files = ompImportFiles(ctx.home);
9762
+ if (!ompImportsUs(files, ctx.env)) return;
9763
+ planJsonKeys(row, edits, files.mcp, "json", (doc) => {
9764
+ const cur = Array.isArray(doc[OMP_DISABLED_SERVERS_KEY]) ? doc[OMP_DISABLED_SERVERS_KEY] : [];
9765
+ return cur.includes(SERVER_KEY) ? [] : [[[OMP_DISABLED_SERVERS_KEY], [...cur, SERVER_KEY]]];
9766
+ });
9767
+ }
9629
9768
  function planRow(row, listed, stale, env, disabled = false) {
9630
9769
  const edits = [];
9631
9770
  if (row.config) {
@@ -9740,10 +9879,10 @@ var SETTINGS_FILES = ["settings.json", "settings.local.json"];
9740
9879
  function disabledBySettings(row) {
9741
9880
  const c3 = row.copy;
9742
9881
  if (!c3) return void 0;
9743
- const dirs = [path12.dirname(path12.dirname(c3.file)), path12.join(process.cwd(), ".claude")];
9882
+ const dirs = [path14.dirname(path14.dirname(c3.file)), path14.join(process.cwd(), ".claude")];
9744
9883
  for (const dir of dirs) {
9745
9884
  for (const name of SETTINGS_FILES) {
9746
- const file = path12.join(dir, name);
9885
+ const file = path14.join(dir, name);
9747
9886
  const text2 = readOr(file);
9748
9887
  if (text2 === void 0) continue;
9749
9888
  let doc;
@@ -9767,7 +9906,7 @@ function hookEnabledCheck(row, status) {
9767
9906
  }
9768
9907
  function packageVersion(pkgDir) {
9769
9908
  try {
9770
- const v = JSON.parse(hostText(readFileSync12(path12.join(pkgDir, "package.json"), "utf8"))).version;
9909
+ const v = JSON.parse(hostText(readFileSync14(path14.join(pkgDir, "package.json"), "utf8"))).version;
9771
9910
  return typeof v === "string" ? v : void 0;
9772
9911
  } catch {
9773
9912
  return void 0;
@@ -9815,7 +9954,7 @@ function degradedDetail(node, env) {
9815
9954
  }
9816
9955
  function mcpCheck(cmd, env) {
9817
9956
  return new Promise((resolve6) => {
9818
- const child = spawn3(cmd[0], cmd.slice(1), { env, stdio: ["pipe", "pipe", "ignore"], detached: process.platform !== "win32", windowsHide: true });
9957
+ const child = spawn5(cmd[0], cmd.slice(1), { env, stdio: ["pipe", "pipe", "ignore"], detached: process.platform !== "win32", windowsHide: true });
9819
9958
  const reap = () => {
9820
9959
  child.kill();
9821
9960
  };
@@ -9956,14 +10095,14 @@ function hookRegisteredCheck(row, env, list2) {
9956
10095
  return { name: "hook-registered", ok: false, detail: issue ?? `${h2.file} lacks the context-mode hook entry${oc2 ? "; run: opencode plugin add context-mode" : ""}` };
9957
10096
  }
9958
10097
  function hookRunsCheck(row, env) {
9959
- const root = mkdtempSync(path12.join(tmpdir2(), "cm-doctor-runs-"));
10098
+ const root = mkdtempSync(path14.join(tmpdir2(), "cm-doctor-runs-"));
9960
10099
  try {
9961
- const home = path12.join(root, "home");
9962
- const proj = path12.join(root, "proj");
10100
+ const home = path14.join(root, "home");
10101
+ const proj = path14.join(root, "proj");
9963
10102
  mkdirSync5(home);
9964
10103
  mkdirSync5(proj);
9965
10104
  const text2 = sampleText();
9966
- writeFileSync3(path12.join(proj, SAMPLE_FILE), text2);
10105
+ writeFileSync3(path14.join(proj, SAMPLE_FILE), text2);
9967
10106
  const { effect, payload } = hookSample(row.id, proj, text2);
9968
10107
  const sampleEnv = { ...env, HOME: home, USERPROFILE: home };
9969
10108
  delete sampleEnv.CLAUDE_PROJECT_DIR;
@@ -9978,8 +10117,8 @@ function hookRunsCheck(row, env) {
9978
10117
  var SEEN_SQL = "SELECT 1 FROM events WHERE agent = ? LIMIT 1";
9979
10118
  var NOT_SEEN_LINE = "not seen yet, run one tool call";
9980
10119
  function hookSeenCheck(row, dataRoot) {
9981
- const base = path12.join(dataRoot, PROJECTS_DIR_NAME);
9982
- const dirs = existsSync17(base) ? readdirSync6(base) : [];
10120
+ const base = path14.join(dataRoot, PROJECTS_DIR_NAME);
10121
+ const dirs = existsSync19(base) ? readdirSync6(base) : [];
9983
10122
  let sqlite;
9984
10123
  try {
9985
10124
  sqlite = process.getBuiltinModule("node:sqlite");
@@ -9987,8 +10126,8 @@ function hookSeenCheck(row, dataRoot) {
9987
10126
  sqlite = void 0;
9988
10127
  }
9989
10128
  for (const d of dirs) {
9990
- const file = path12.join(base, d, DB_FILE_NAME);
9991
- if (!sqlite || !existsSync17(file)) continue;
10129
+ const file = path14.join(base, d, DB_FILE_NAME);
10130
+ if (!sqlite || !existsSync19(file)) continue;
9992
10131
  let db;
9993
10132
  try {
9994
10133
  db = new sqlite.DatabaseSync(file, { readOnly: true });
@@ -10004,18 +10143,18 @@ var SKILL_TOOL_STEM = "ctx_";
10004
10143
  function skillsCheck(row, pkgDir) {
10005
10144
  const s = row.skillInstall;
10006
10145
  if (s.kind === "package") {
10007
- const files = COMMAND_SKILLS.map((n3) => path12.join(pkgDir, s.via, n3, SKILL_FILE));
10008
- const miss = files.filter((f2) => !existsSync17(f2));
10146
+ const files = COMMAND_SKILLS.map((n3) => path14.join(pkgDir, s.via, n3, SKILL_FILE));
10147
+ const miss = files.filter((f2) => !existsSync19(f2));
10009
10148
  if (miss.length) return { name: "skills", ok: false, detail: `missing ${miss.join(", ")}` };
10010
10149
  const own2 = getAdapter(row.id).toolNamePrefix + SKILL_TOOL_STEM;
10011
10150
  const foreign = [...new Set(ADAPTERS.map((r2) => r2.toolNamePrefix + SKILL_TOOL_STEM))].filter((n3) => n3 !== SKILL_TOOL_STEM && n3 !== own2);
10012
10151
  const bad2 = files.filter((f2) => {
10013
- const t2 = readFileSync12(f2, "utf8");
10152
+ const t2 = readFileSync14(f2, "utf8");
10014
10153
  return !t2.includes(own2) && foreign.some((n3) => t2.includes(n3));
10015
10154
  });
10016
10155
  return { name: "skills", ok: bad2.length === 0, detail: bad2.length ? `${bad2.join(", ")} without the ${own2}* tool name` : void 0 };
10017
10156
  }
10018
- const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync17(f2.src) ? renderSkill(readFileSync12(f2.src, "utf8"), s.prefixes) : void 0));
10157
+ const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync19(f2.src) ? renderSkill(readFileSync14(f2.src, "utf8"), s.prefixes) : void 0));
10019
10158
  return { name: "skills", ok: bad.length === 0, detail: bad.length ? `${bad.map((f2) => f2.file).join(", ")} missing or without the ${s.prefixes.join(" / ") || "plain"} tool prefix` : void 0 };
10020
10159
  }
10021
10160
  var CODEX_CONFIG_FILE2 = "config.toml";
@@ -10072,7 +10211,70 @@ function jsonState(n3, text2) {
10072
10211
  const hookGate = hooks.some((h2) => isObj5(h2) && typeof h2.command === "string" && h2.command.includes(own2)) ? void 0 : `the installed ${n3.plugin} runs no ${own2} hook; run: ${n3.bin} plugins update ${n3.plugin}`;
10073
10212
  return { state: "enabled", workspaceOff: false, hookGate };
10074
10213
  }
10075
- function nativeState(row, env) {
10214
+ function unlistedExtension(n3, env, home, out2, status) {
10215
+ if (n3.bin !== "gemini") return void 0;
10216
+ const dir = path14.join(geminiDirOf(env, home), "extensions", n3.plugin);
10217
+ if (!existsSync19(path14.join(dir, "gemini-extension.json"))) return void 0;
10218
+ const cmd = [n3.bin, ...n3.args].join(" ");
10219
+ const first = out2.split("\n").map((l) => l.trim()).find((l) => l.length)?.slice(0, 300) ?? `exit ${status}`;
10220
+ return { dir, note: `context-mode is installed in ${dir}, and ${cmd} answered "${first}" in place of the extension list; run ${cmd} in a terminal and fix that answer (gemini auth)` };
10221
+ }
10222
+ var EXT_ENABLEMENT_FILE = "extension-enablement.json";
10223
+ function slashDir(p3) {
10224
+ let r2 = p3.split("\\").join("/");
10225
+ if (!r2.startsWith("/")) r2 = `/${r2}`;
10226
+ return r2.endsWith("/") ? r2 : `${r2}/`;
10227
+ }
10228
+ function geminiEnablement(n3, env, home, cwd) {
10229
+ const file = path14.join(geminiDirOf(env, home), "extensions", EXT_ENABLEMENT_FILE);
10230
+ const text2 = readOr(file);
10231
+ if (text2 === void 0) return { file, on: true };
10232
+ let doc;
10233
+ try {
10234
+ doc = JSON.parse(text2);
10235
+ } catch {
10236
+ return { file, on: false, bad: true };
10237
+ }
10238
+ const mine = isObj5(doc) ? doc[n3.plugin] : void 0;
10239
+ const rules = isObj5(mine) && Array.isArray(mine.overrides) ? mine.overrides : [];
10240
+ const here = slashDir(cwd);
10241
+ let on = true;
10242
+ for (const rule of rules) {
10243
+ if (typeof rule !== "string") continue;
10244
+ const off = rule.startsWith("!");
10245
+ let base = off ? rule.slice(1) : rule;
10246
+ const subdirs = base.endsWith("*");
10247
+ if (subdirs) base = base.slice(0, -1);
10248
+ base = slashDir(base);
10249
+ if (subdirs ? here.startsWith(base) : here === base) on = !off;
10250
+ }
10251
+ return { file, on };
10252
+ }
10253
+ function diskHookCheck(row, n3, dir) {
10254
+ const name = "hook-registered";
10255
+ const file = path14.join(dir, n3.hooksVia);
10256
+ const text2 = readOr(file);
10257
+ if (text2 === void 0) return { name, ok: false, detail: `${file} is missing; run: ${NATIVE_INSTALL.gemini[0]}` };
10258
+ let doc;
10259
+ try {
10260
+ doc = JSON.parse(text2);
10261
+ } catch {
10262
+ return { name, ok: false, detail: `${file} is not valid JSON; run: ${NATIVE_INSTALL.gemini[0]}` };
10263
+ }
10264
+ return holdsOwn(doc, row.id) ? { name, ok: true } : { name, ok: false, detail: `${file} holds no ${AGENT_FLAG} ${row.id} hook; run: ${NATIVE_INSTALL.gemini[0]}` };
10265
+ }
10266
+ var EXT_BUNDLE_DIR = ["plugins", "claude-code"];
10267
+ function diskRow(row, n3, dir) {
10268
+ const bundle = (f2) => path14.join(dir, ...EXT_BUNDLE_DIR, f2);
10269
+ return {
10270
+ ...nativeRow(row, n3),
10271
+ listCommand: void 0,
10272
+ serverCommand: [row.serverCommand[0], bundle(SERVER_BUNDLE), AGENT_FLAG, row.id],
10273
+ hookRunCommand: [row.hookRunCommand[0], bundle(HOOK_BUNDLE), AGENT_FLAG, row.id],
10274
+ ...row.hookCommand ? { hookCommand: [row.hookRunCommand[0], bundle(HOOK_BUNDLE), AGENT_FLAG, row.id] } : {}
10275
+ };
10276
+ }
10277
+ function nativeState(row, env, home) {
10076
10278
  const none = { state: void 0, workspaceOff: false };
10077
10279
  const n3 = row.nativePlugin;
10078
10280
  if (!n3 || !hostBin(n3.bin, env).file) return none;
@@ -10082,10 +10284,19 @@ function nativeState(row, env) {
10082
10284
  const cmd = [n3.bin, ...n3.args].join(" ");
10083
10285
  return { ...none, stopped: `${cmd} stopped before it finished (${why}); it names ${n3.plugin}, run ${cmd} in a terminal` };
10084
10286
  }
10287
+ if (n3.format === "extension") {
10288
+ const out2 = `${r2.stdout}${r2.stderr}`;
10289
+ const st = r2.status === 0 ? extensionState(n3, out2) : none;
10290
+ if (st.state !== void 0) return st;
10291
+ const unlisted = unlistedExtension(n3, env, home, out2, r2.status);
10292
+ if (!unlisted) return st;
10293
+ const en = geminiEnablement(n3, env, home, process.cwd());
10294
+ if (en.bad) return { ...none, stopped: `${en.file} is not valid JSON, so gemini cannot read which projects enable context-mode; fix that file. ${unlisted.note}` };
10295
+ return { state: en.on ? "enabled" : "disabled", workspaceOff: false, disk: { ...unlisted, enablement: en.file } };
10296
+ }
10085
10297
  if (r2.status !== 0) return none;
10086
10298
  if (n3.format === "json") return jsonState(n3, `${r2.stdout}`);
10087
- if (n3.format === "codex-json") return { state: codexJsonState(n3, `${r2.stdout}`), workspaceOff: false };
10088
- return extensionState(n3, `${r2.stdout}${r2.stderr}`);
10299
+ return { state: codexJsonState(n3, `${r2.stdout}`), workspaceOff: false };
10089
10300
  }
10090
10301
  function nativeRow(row, n3) {
10091
10302
  return {
@@ -10101,12 +10312,22 @@ function nativeRow(row, n3) {
10101
10312
  }
10102
10313
  async function nativeResult(row, ctx, apply2) {
10103
10314
  const n3 = row.nativePlugin;
10104
- const { state, workspaceOff, hookGate, stopped } = nativeState(row, ctx.env);
10315
+ const { state, workspaceOff, hookGate, stopped, disk } = nativeState(row, ctx.env, ctx.home);
10105
10316
  const bin = n3 ? hostBin(n3.bin, ctx.env).file : void 0;
10106
10317
  if (stopped) return { id: row.id, status: "FAIL", v1: [], changes: [], checks: [], bin, reason: stopped };
10318
+ if (n3?.format === "codex-json" && !bin && codexPluginHomeOf(ctx.pkgDir) !== null) return codexCacheResult(row, ctx, apply2);
10107
10319
  if (!n3 || state === void 0) return void 0;
10108
10320
  if (state === "disabled") {
10109
10321
  if (!n3.enable) return void 0;
10322
+ if (disk) return {
10323
+ id: row.id,
10324
+ status: "FAIL",
10325
+ v1: [],
10326
+ changes: [],
10327
+ checks: [],
10328
+ bin,
10329
+ reason: `context-mode is installed in ${disk.dir} but disabled for ${process.cwd()} in ${disk.enablement}, run ${n3.bin} ${n3.enable.join(" ")}`
10330
+ };
10110
10331
  return {
10111
10332
  id: row.id,
10112
10333
  status: "FAIL",
@@ -10129,7 +10350,10 @@ async function nativeResult(row, ctx, apply2) {
10129
10350
  return { ...res, status: "FAIL", reason: e.message, rolledBack: true };
10130
10351
  }
10131
10352
  }
10132
- res.checks = await verifyRow(nativeRow(row, n3), ctx);
10353
+ if (disk) {
10354
+ res.checks = (await verifyRow(diskRow(row, n3, disk.dir), { ...ctx, pkgDir: disk.dir })).map((c3) => c3.name === "hook-registered" ? diskHookCheck(row, n3, disk.dir) : c3);
10355
+ res.checks.push({ name: "list", ok: true, warn: true, detail: `${disk.note}; doctor checked the extension files on disk` });
10356
+ } else res.checks = await verifyRow(nativeRow(row, n3), ctx);
10133
10357
  if (n3.hookTrust) res.checks = withHookTrust(res.checks, hooks, !!apply2?.dryRun);
10134
10358
  if (n3.format === "extension") res.checks = withHookGate(res.checks, geminiGate(n3, ctx, workspaceOff));
10135
10359
  if (n3.format === "json") res.checks = withHookGate(res.checks, hookGate);
@@ -10144,8 +10368,83 @@ async function nativeResult(row, ctx, apply2) {
10144
10368
  }
10145
10369
  return res;
10146
10370
  }
10371
+ function codexCacheEdits(row, found) {
10372
+ const edits = [];
10373
+ const c3 = row.config;
10374
+ const text2 = c3 ? readOr(c3.file) : void 0;
10375
+ if (c3 && text2 !== void 0) {
10376
+ let cur;
10377
+ try {
10378
+ cur = hostConfigValueAt(parseHostConfig(row.id, c3.file, text2, c3.format), c3.key);
10379
+ } catch {
10380
+ throw new Error(parseFail(row, c3.file));
10381
+ }
10382
+ if (cur !== void 0) {
10383
+ const res = editHostConfigText(row.id, c3.file, text2, c3.format, [[c3.key, void 0]]);
10384
+ const run = isObj5(cur) ? [cur.command, ...Array.isArray(cur.args) ? cur.args : []].filter((x2) => typeof x2 === "string").join(" ") : "";
10385
+ found.push(`${c3.file}: [${c3.key.join(".")}] runs ${run}`);
10386
+ if (res.edits.length) edits.push({ file: c3.file, before: text2, after: res.text, changes: res.edits.map((e) => ({ file: c3.file, ...e })) });
10387
+ }
10388
+ }
10389
+ const h2 = row.hookInstall;
10390
+ if (h2.kind === "file") planJsonKeys(row, edits, h2.file, "json", (doc) => {
10391
+ if (!isObj5(doc.hooks)) return [];
10392
+ const own2 = (x2) => {
10393
+ const hit = isObj5(x2) && isOwnHookCommand(x2.command, row.id);
10394
+ if (hit) found.push(`${h2.file}: ${String(x2.command)}`);
10395
+ return hit;
10396
+ };
10397
+ const hooks = {};
10398
+ for (const [ev, groups] of Object.entries(doc.hooks)) {
10399
+ if (!Array.isArray(groups)) {
10400
+ hooks[ev] = groups;
10401
+ continue;
10402
+ }
10403
+ const kept = groups.flatMap((g2) => {
10404
+ if (own2(g2)) return [];
10405
+ if (!isObj5(g2) || !Array.isArray(g2.hooks) || !g2.hooks.length) return [g2];
10406
+ const inner = g2.hooks.filter((x2) => !own2(x2));
10407
+ return inner.length ? [{ ...g2, hooks: inner }] : [];
10408
+ });
10409
+ if (kept.length || !groups.length) hooks[ev] = kept;
10410
+ }
10411
+ return [[["hooks"], hooks]];
10412
+ });
10413
+ return edits;
10414
+ }
10415
+ async function codexCacheResult(row, ctx, apply2) {
10416
+ const res = { id: row.id, status: "PASS", v1: [], changes: [], checks: [] };
10417
+ const found = [];
10418
+ let edits;
10419
+ try {
10420
+ edits = codexCacheEdits(row, found);
10421
+ } catch (e) {
10422
+ return { ...res, status: "FAIL", reason: e.message };
10423
+ }
10424
+ res.changes = edits.flatMap((e) => e.changes);
10425
+ const plugin = `the codex plugin in ${codexPluginHomeOf(ctx.pkgDir)} runs the MCP server and the hooks`;
10426
+ if (!apply2 && found.length) {
10427
+ res.checks = found.map((f2) => ({ name: "pinned-entry", ok: false, detail: `${f2}; ${plugin}, this entry runs a second copy and its path goes away on a plugin update; run: context-mode setup` }));
10428
+ return { ...res, status: "FAIL", reason: res.checks.map((c3) => `${c3.name}: ${c3.detail}`).join("; ") };
10429
+ }
10430
+ if (apply2 && !apply2.dryRun) {
10431
+ try {
10432
+ for (const e of edits) {
10433
+ assertWritable(row, e.file);
10434
+ const raw = readRaw(e.file);
10435
+ apply2.run.record({ agent: row.id, file: e.file, existed: raw !== void 0 }, raw);
10436
+ atomicWrite(e.file, raw === void 0 ? e.after : withLayout(e.after, hostLayout(raw)));
10437
+ }
10438
+ } catch (e) {
10439
+ apply2.run.rollback(row.id, ctx.env);
10440
+ return { ...res, status: "FAIL", reason: e.message, rolledBack: true };
10441
+ }
10442
+ }
10443
+ res.checks = [{ name: "hook-registered", ok: true, warn: true, detail: `${plugin}; codex is not on PATH, so check them with: codex plugin list` }];
10444
+ return res;
10445
+ }
10147
10446
  function trustPluginHooks(row, ctx, apply2, hooks) {
10148
- const file = path12.join(codexDirOf(ctx.env, ctx.home), CODEX_CONFIG_FILE2);
10447
+ const file = path14.join(codexDirOf(ctx.env, ctx.home), CODEX_CONFIG_FILE2);
10149
10448
  const text2 = readOr(file);
10150
10449
  let edit;
10151
10450
  try {
@@ -10238,10 +10537,14 @@ async function enableCopilotHooks(row, ctx, run) {
10238
10537
  return edit.edits.map((e) => ({ file: settings2, ...e }));
10239
10538
  }
10240
10539
  var isObjSetup = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
10241
- async function verifyRow(row, ctx) {
10540
+ function listOnce(row, env) {
10541
+ let ls;
10542
+ return () => ls ??= listState(row, env);
10543
+ }
10544
+ async function verifyRow(row, ctx, list2 = () => listState(row, ctx.env)) {
10242
10545
  const env = ctx.env;
10243
10546
  const checks = [parseCheck(row)];
10244
- const ls = listState(row, env);
10547
+ const ls = list2();
10245
10548
  const l = ls.check;
10246
10549
  if (l) checks.push(l);
10247
10550
  const cp = copyCheck(row, ctx.pkgDir);
@@ -10266,16 +10569,16 @@ var Run = class {
10266
10569
  this.runId = runId;
10267
10570
  }
10268
10571
  get dir() {
10269
- return path12.join(this.root, BACKUP_DIR, this.runId);
10572
+ return path14.join(this.root, BACKUP_DIR, this.runId);
10270
10573
  }
10271
10574
  save() {
10272
- if (this.manifest) atomicWrite(path12.join(this.dir, MANIFEST), JSON.stringify(this.manifest, null, 2));
10575
+ if (this.manifest) atomicWrite(path14.join(this.dir, MANIFEST), JSON.stringify(this.manifest, null, 2));
10273
10576
  }
10274
10577
  record(e, bytes) {
10275
10578
  if (!this.manifest) this.manifest = { runId: this.runId, path: this.dir, entries: [] };
10276
10579
  if (bytes !== void 0) {
10277
- const rel = path12.join(FILES, String(this.manifest.entries.length));
10278
- atomicWrite(path12.join(this.dir, rel), bytes);
10580
+ const rel = path14.join(FILES, String(this.manifest.entries.length));
10581
+ atomicWrite(path14.join(this.dir, rel), bytes);
10279
10582
  e.backup = rel;
10280
10583
  }
10281
10584
  this.manifest.entries.push(e);
@@ -10295,12 +10598,12 @@ function undo(dir, entries, env) {
10295
10598
  continue;
10296
10599
  }
10297
10600
  if (!e.file) continue;
10298
- if (e.existed && e.backup) atomicWrite(e.file, readFileSync12(path12.join(dir, e.backup), "utf8"));
10601
+ if (e.existed && e.backup) atomicWrite(e.file, readFileSync14(path14.join(dir, e.backup), "utf8"));
10299
10602
  else unlinkWithRetry(e.file);
10300
10603
  }
10301
10604
  }
10302
10605
  function takeLock(root, runId) {
10303
- const file = path12.join(root, LOCK_FILE);
10606
+ const file = path14.join(root, LOCK_FILE);
10304
10607
  mkdirSync5(root, { recursive: true });
10305
10608
  for (let attempt = 0; attempt < 2; attempt++) {
10306
10609
  try {
@@ -10310,7 +10613,7 @@ function takeLock(root, runId) {
10310
10613
  if (e.code !== "EEXIST") throw e;
10311
10614
  let pid = 0;
10312
10615
  try {
10313
- pid = Number(JSON.parse(readFileSync12(file, "utf8")).pid);
10616
+ pid = Number(JSON.parse(readFileSync14(file, "utf8")).pid);
10314
10617
  } catch {
10315
10618
  }
10316
10619
  if (pid && pidAlive(pid)) return `setup lock ${file} is held by pid ${pid}; wait for that run or remove the lock`;
@@ -10325,10 +10628,10 @@ function agentHomeDir(id, ctx) {
10325
10628
  if (id === "kiro") return kiroDirOf(ctx.env, ctx.home);
10326
10629
  if (id === "opencode") return opencodeDirOf(ctx.env, ctx.home);
10327
10630
  if (id === "gemini") return geminiDirOf(ctx.env, ctx.home);
10328
- return path12.join(ctx.home, ...AGENT_HOME_DIR[id]);
10631
+ return path14.join(ctx.home, ...AGENT_HOME_DIR[id]);
10329
10632
  }
10330
10633
  function detectAgents(reg, ctx) {
10331
- return reg.filter((r2) => existsSync17(agentHomeDir(r2.id, ctx)) || r2.listCommand && which(r2.listCommand.bin, ctx.env)).map((r2) => r2.id);
10634
+ return reg.filter((r2) => existsSync19(agentHomeDir(r2.id, ctx)) || r2.listCommand && which(r2.listCommand.bin, ctx.env)).map((r2) => r2.id);
10332
10635
  }
10333
10636
  async function runSetup(opts) {
10334
10637
  const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env, cwd: opts.cwd };
@@ -10337,7 +10640,7 @@ async function runSetup(opts) {
10337
10640
  const nodeVersion = opts.nodeVersion ?? process.version;
10338
10641
  if (nodeTooOld(nodeVersion)) return { exitCode: 1, agents: [], error: formatError("NODE_TOO_OLD", { v: nodeVersion }) };
10339
10642
  for (const f2 of ["server.mjs", "hook.mjs"]) {
10340
- if (!existsSync17(path12.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path12.join(ctx.pkgDir, f2)} is missing` };
10643
+ if (!existsSync19(path14.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path14.join(ctx.pkgDir, f2)} is missing` };
10341
10644
  }
10342
10645
  const ids = opts.agents ?? detectAgents(reg, ctx);
10343
10646
  const root = dataRootOf(ctx.env, ctx.home);
@@ -10350,7 +10653,7 @@ async function runSetup(opts) {
10350
10653
  let current;
10351
10654
  const onAbort = () => {
10352
10655
  if (current !== void 0 && !opts.dryRun) run.rollback(current, ctx.env);
10353
- if (!opts.dryRun) rmSync2(path12.join(root, LOCK_FILE), { force: true });
10656
+ if (!opts.dryRun) rmSync2(path14.join(root, LOCK_FILE), { force: true });
10354
10657
  };
10355
10658
  opts.signal?.addEventListener("abort", onAbort, { once: true });
10356
10659
  try {
@@ -10369,11 +10672,11 @@ async function runSetup(opts) {
10369
10672
  }
10370
10673
  } finally {
10371
10674
  opts.signal?.removeEventListener("abort", onAbort);
10372
- if (!opts.dryRun) rmSync2(path12.join(root, LOCK_FILE), { force: true });
10675
+ if (!opts.dryRun) rmSync2(path14.join(root, LOCK_FILE), { force: true });
10373
10676
  }
10374
10677
  return { exitCode: agents.some((a2) => a2.status === "FAIL") ? 1 : 0, agents, backupDir: run.manifest ? run.dir : void 0 };
10375
10678
  }
10376
- async function setupRow(row, ctx, run, dryRun) {
10679
+ async function setupRow(row, ctx, run, dryRun, list2 = () => listState(row, ctx.env)) {
10377
10680
  const res = { id: row.id, status: "PASS", v1: [], changes: [], checks: [] };
10378
10681
  const needsBin = !row.config && row.cli;
10379
10682
  if (needsBin) {
@@ -10385,10 +10688,11 @@ async function setupRow(row, ctx, run, dryRun) {
10385
10688
  if (!row.config && !row.cli) return { ...res, status: "SKIPPED", reason: `${row.id}: no setup path in the registry` };
10386
10689
  let plan;
10387
10690
  try {
10388
- const ls = needsBin ? listState(row, ctx.env) : { status: void 0, check: void 0, broken: void 0 };
10691
+ const ls = needsBin ? list2() : { status: void 0, check: void 0, broken: void 0 };
10389
10692
  if (ls.broken) return { ...res, status: "SKIPPED", reason: ls.broken };
10390
10693
  const listed = ls.check?.ok === true;
10391
10694
  plan = planRow(row, listed, copyCheck(row, ctx.pkgDir)?.ok === false, ctx.env, listed && ls.status === "disabled");
10695
+ if (row.id === "omp") planOmpImport(row, plan.edits, ctx);
10392
10696
  } catch (e) {
10393
10697
  return { ...res, status: "FAIL", reason: e.message };
10394
10698
  }
@@ -10444,7 +10748,7 @@ async function runDoctor(opts) {
10444
10748
  const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env, cwd: opts.cwd };
10445
10749
  const reg = buildRegistry(ctx);
10446
10750
  for (const f2 of ["server.mjs", "hook.mjs"]) {
10447
- if (!existsSync17(path12.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path12.join(ctx.pkgDir, f2)} is missing` };
10751
+ if (!existsSync19(path14.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path14.join(ctx.pkgDir, f2)} is missing` };
10448
10752
  }
10449
10753
  const ids = opts.agents ?? detectAgents(reg, ctx);
10450
10754
  const run = new Run(dataRootOf(ctx.env, ctx.home), "doctor");
@@ -10462,7 +10766,14 @@ async function runDoctor(opts) {
10462
10766
  opts.onAgent?.(id, "done", native);
10463
10767
  continue;
10464
10768
  }
10465
- const res = await setupRow(row, ctx, run, true);
10769
+ const list2 = listOnce(row, ctx.env);
10770
+ const res = await setupRow(row, ctx, run, true, list2);
10771
+ const gone = row.id === "codex" ? missingPinnedChecks(row) : [];
10772
+ if (gone.length) {
10773
+ res.status = "FAIL";
10774
+ res.checks = [...gone, ...res.checks];
10775
+ res.reason = gone.map((c3) => `${c3.name}: ${c3.detail}`).join("; ");
10776
+ }
10466
10777
  if (res.status === "PASS") {
10467
10778
  if (res.v1.some((f2) => !UPGRADE_REPORT_ONLY_REASONS.includes(f2.reason))) {
10468
10779
  res.status = "FAIL";
@@ -10471,7 +10782,7 @@ async function runDoctor(opts) {
10471
10782
  res.status = "FAIL";
10472
10783
  res.reason = notSetUpReason(row, res, ctx.env);
10473
10784
  } else {
10474
- res.checks = await verifyRow(row, ctx);
10785
+ res.checks = await verifyRow(row, ctx, list2);
10475
10786
  const bad = res.checks.filter((c3) => !c3.ok);
10476
10787
  if (bad.length) {
10477
10788
  res.status = "FAIL";
@@ -10486,11 +10797,51 @@ async function runDoctor(opts) {
10486
10797
  }
10487
10798
  return { exitCode: agents.some((a2) => a2.status === "FAIL") ? 1 : 0, agents };
10488
10799
  }
10800
+ function missingPinnedChecks(row) {
10801
+ const paths = [];
10802
+ const c3 = row.config;
10803
+ const text2 = c3 ? readOr(c3.file) : void 0;
10804
+ if (c3 && text2 !== void 0) {
10805
+ let cur;
10806
+ try {
10807
+ cur = hostConfigValueAt(parseHostConfig(row.id, c3.file, text2, c3.format), c3.key);
10808
+ } catch {
10809
+ cur = void 0;
10810
+ }
10811
+ if (isObj5(cur) && Array.isArray(cur.args)) {
10812
+ for (const a2 of cur.args) if (typeof a2 === "string" && path14.basename(a2) === "server.mjs") paths.push(a2);
10813
+ }
10814
+ }
10815
+ const h2 = row.hookInstall;
10816
+ const hooksText = h2.kind === "file" ? readOr(h2.file) : void 0;
10817
+ if (hooksText !== void 0) {
10818
+ let doc;
10819
+ try {
10820
+ doc = JSON.parse(hooksText);
10821
+ } catch {
10822
+ doc = void 0;
10823
+ }
10824
+ const walk = (v) => {
10825
+ if (typeof v === "string") {
10826
+ if (isOwnHookCommand(v, row.id)) paths.push(hookPathOf(v));
10827
+ } else if (Array.isArray(v)) v.forEach(walk);
10828
+ else if (isObj5(v)) Object.values(v).forEach(walk);
10829
+ };
10830
+ if (isObj5(doc)) walk(doc.hooks);
10831
+ }
10832
+ return [...new Set(paths)].filter((f2) => path14.isAbsolute(f2) && !existsSync19(f2)).map((f2) => ({ name: "missing-file", ok: false, detail: `${f2} does not exist (a Codex plugin update replaces its version dir); run: context-mode setup` }));
10833
+ }
10834
+ function hookPathOf(cmd) {
10835
+ const at = cmd.lastIndexOf(HOOK_BUNDLE);
10836
+ const end = at + HOOK_BUNDLE.length;
10837
+ const start = cmd[end] === '"' ? cmd.lastIndexOf('"', at) + 1 : cmd.lastIndexOf(" ", at) + 1;
10838
+ return cmd.slice(start, end);
10839
+ }
10489
10840
  function notSetUpReason(row, res, env) {
10490
10841
  const h2 = row.hookInstall;
10491
10842
  const missing = row.id === "opencode" && h2.kind === "plugin-list" && res.changes.some((c3) => c3.path === h2.key[0]);
10492
10843
  const oc2 = missing && hostBin("opencode", env).file !== void 0 && opencodeMajor("opencode", env) >= 2;
10493
- const dead = missing ? opencodeDirPlugins(opencodePluginDirs(path12.dirname(h2.file), h2.worktree)).find((p3) => !p3.loads) : void 0;
10844
+ const dead = missing ? opencodeDirPlugins(opencodePluginDirs(path14.dirname(h2.file), h2.worktree)).find((p3) => !p3.loads) : void 0;
10494
10845
  const hint = dead ? `; ${dead.file} loads context-mode once ${OPENCODE_PACKAGE_DIR_HINT} is next to it or above it` : "";
10495
10846
  if (oc2) return `${NOT_SET_UP_REASON}, or run: opencode plugin add context-mode${hint}`;
10496
10847
  if (hint) return NOT_SET_UP_REASON + hint;
@@ -10523,27 +10874,27 @@ function isTrust(row, c3) {
10523
10874
  function runRemove(opts) {
10524
10875
  const env = opts.env ?? process.env;
10525
10876
  const root = dataRootOf(env, opts.home);
10526
- const base = path12.join(root, BACKUP_DIR);
10527
- if (!existsSync17(base)) return { exitCode: 0, restored: 0 };
10877
+ const base = path14.join(root, BACKUP_DIR);
10878
+ if (!existsSync19(base)) return { exitCode: 0, restored: 0 };
10528
10879
  const held = takeLock(root, "remove");
10529
10880
  if (held) return { exitCode: 1, restored: 0, error: held };
10530
10881
  let restored = 0;
10531
10882
  try {
10532
- const runs = readdirSync6(base).map((r2) => path12.join(base, r2)).filter((d) => existsSync17(path12.join(d, MANIFEST))).sort().reverse();
10883
+ const runs = readdirSync6(base).map((r2) => path14.join(base, r2)).filter((d) => existsSync19(path14.join(d, MANIFEST))).sort().reverse();
10533
10884
  for (const dir of runs) {
10534
- const m3 = JSON.parse(readFileSync12(path12.join(dir, MANIFEST), "utf8"));
10885
+ const m3 = JSON.parse(readFileSync14(path14.join(dir, MANIFEST), "utf8"));
10535
10886
  undo(dir, m3.entries, env);
10536
10887
  restored += m3.entries.length;
10537
- renameWithRetry(path12.join(dir, MANIFEST), path12.join(dir, MANIFEST_DONE));
10888
+ renameWithRetry(path14.join(dir, MANIFEST), path14.join(dir, MANIFEST_DONE));
10538
10889
  }
10539
10890
  } finally {
10540
- rmSync2(path12.join(root, LOCK_FILE), { force: true });
10891
+ rmSync2(path14.join(root, LOCK_FILE), { force: true });
10541
10892
  }
10542
10893
  return { exitCode: 0, restored };
10543
10894
  }
10544
10895
 
10545
10896
  // src/setup/print.ts
10546
- import { readFileSync as readFileSync13 } from "node:fs";
10897
+ import { readFileSync as readFileSync15 } from "node:fs";
10547
10898
  var SHELL_SAFE_PUNCT = "@%+=:,./-_";
10548
10899
  function isShellSafe(s) {
10549
10900
  if (s === "") return false;
@@ -10571,7 +10922,7 @@ function printPlan(row, env) {
10571
10922
  else if (h2.kind === "plugin-list") steps.push({ kind: "hook", file: h2.file, block: JSON.stringify({ [h2.key[0]]: [h2.entry] }, null, 2) + "\n" });
10572
10923
  const sk = row.skillInstall;
10573
10924
  if (sk.kind === "dir") {
10574
- for (const f2 of sk.files) steps.push({ kind: "skill", file: f2.file, block: renderSkill(readFileSync13(f2.src, "utf8"), sk.prefixes) });
10925
+ for (const f2 of sk.files) steps.push({ kind: "skill", file: f2.file, block: renderSkill(readFileSync15(f2.src, "utf8"), sk.prefixes) });
10575
10926
  }
10576
10927
  return { agent: row.id, steps, verify: `context-mode doctor --agents ${row.id}` };
10577
10928
  }
@@ -10742,9 +11093,9 @@ async function report(ui, command, res, write) {
10742
11093
  const { text: text2, title } = buildIssueReport(command, res, ui);
10743
11094
  let file = "";
10744
11095
  if (write) {
10745
- const dir = path13.join(dataRootOf(ui.ctx.env, ui.ctx.home), REPORT_DIR);
11096
+ const dir = path15.join(dataRootOf(ui.ctx.env, ui.ctx.home), REPORT_DIR);
10746
11097
  mkdirSync6(dir, { recursive: true });
10747
- file = path13.join(dir, `${command}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
11098
+ file = path15.join(dir, `${command}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
10748
11099
  writeFileSync4(file, text2);
10749
11100
  }
10750
11101
  const gh = `gh issue create --repo ${ISSUE_REPO} --title ${JSON.stringify(title)} --label bug --body-file ${JSON.stringify(file || "<report>")}`;
@@ -10853,7 +11204,7 @@ async function remove(ui) {
10853
11204
  }
10854
11205
  }
10855
11206
  if (ui.f.dryRun) {
10856
- out(`Would restore every file recorded under ${path13.join(dataRootOf(ui.ctx.env, ui.ctx.home), "backups")}`);
11207
+ out(`Would restore every file recorded under ${path15.join(dataRootOf(ui.ctx.env, ui.ctx.home), "backups")}`);
10857
11208
  return EXIT_OK;
10858
11209
  }
10859
11210
  const r2 = runRemove({ home: ui.ctx.home, env: ui.ctx.env });
@@ -10998,8 +11349,8 @@ async function upgrade(ui) {
10998
11349
  return EXIT_FAIL;
10999
11350
  }
11000
11351
  const root = `${spawnSync5(npm, ["root", "-g"], { env: ui.ctx.env, encoding: "utf8", shell, windowsHide: true }).stdout ?? ""}`.trim();
11001
- const cli = path13.join(root, "context-mode", "cli.mjs");
11002
- if (!root || !existsSync18(cli)) {
11352
+ const cli = path15.join(root, "context-mode", "cli.mjs");
11353
+ if (!root || !existsSync20(cli)) {
11003
11354
  err(`FAIL upgrade: ${cli} not found after ${install}. Fix: ${install}`);
11004
11355
  return EXIT_FAIL;
11005
11356
  }
@@ -11038,12 +11389,12 @@ Run context-mode ${cmd} --help.`);
11038
11389
  }
11039
11390
 
11040
11391
  // src/entries/is-entry.ts
11041
- import { realpathSync as realpathSync10 } from "node:fs";
11392
+ import { realpathSync as realpathSync11 } from "node:fs";
11042
11393
  function isEntry(main2, argv1, self) {
11043
11394
  if (main2 !== void 0) return main2;
11044
11395
  if (argv1 === void 0 || argv1 === "") return false;
11045
11396
  try {
11046
- return realpathSync10(argv1) === realpathSync10(self);
11397
+ return realpathSync11(argv1) === realpathSync11(self);
11047
11398
  } catch {
11048
11399
  return false;
11049
11400
  }
@@ -11094,10 +11445,10 @@ function route(argv, version) {
11094
11445
  ` };
11095
11446
  }
11096
11447
  function main() {
11097
- const dir = path14.dirname(realpathSync11(fileURLToPath3(import.meta.url)));
11448
+ const dir = path16.dirname(realpathSync12(fileURLToPath3(import.meta.url)));
11098
11449
  let version = "";
11099
11450
  try {
11100
- version = String(JSON.parse(readFileSync14(path14.join(dir, PACKAGE_FILE), "utf8")).version);
11451
+ version = String(JSON.parse(readFileSync16(path16.join(dir, PACKAGE_FILE), "utf8")).version);
11101
11452
  } catch (err2) {
11102
11453
  process.stderr.write(`${SERVER_KEY}: cannot read ${PACKAGE_FILE}: ${err2.message}
11103
11454
  `);
@@ -11121,7 +11472,7 @@ function main() {
11121
11472
  process.exitCode = r2.code;
11122
11473
  return;
11123
11474
  }
11124
- const child = spawn4(process.execPath, [path14.join(dir, r2.file), ...r2.args], { stdio: "inherit", windowsHide: true });
11475
+ const child = spawn6(process.execPath, [path16.join(dir, r2.file), ...r2.args], { stdio: "inherit", windowsHide: true });
11125
11476
  process.on("SIGINT", () => {
11126
11477
  });
11127
11478
  child.on("error", (err2) => {