context-mode 2.1.10 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.mjs CHANGED
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
 
9
9
  // src/entries/cli.ts
10
10
  import { spawn as spawn6 } from "node:child_process";
11
- import { readFileSync as readFileSync14, realpathSync as realpathSync11 } from "node:fs";
11
+ import { readFileSync as readFileSync16, realpathSync as realpathSync12 } from "node:fs";
12
12
  import path16 from "node:path";
13
13
  import { fileURLToPath as fileURLToPath3 } from "node:url";
14
14
 
@@ -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,7 +1994,7 @@ 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
1999
  import path15 from "node:path";
1975
2000
 
@@ -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"]);
@@ -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, dirname as dirname8, 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";
@@ -5197,8 +5231,8 @@ CREATE VIRTUAL TABLE line_units USING fts5(
5197
5231
  var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
5198
5232
 
5199
5233
  // src/core/ops/doctor-config.ts
5200
- import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
5201
- 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";
5202
5236
 
5203
5237
  // src/core/ops/host-text.ts
5204
5238
  var BOM_CODE = 65279;
@@ -8152,6 +8186,77 @@ function piSettingsGate(env, home, pkgDir, cwd) {
8152
8186
  return void 0;
8153
8187
  }
8154
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
+
8155
8260
  // src/core/ops/doctor-config.ts
8156
8261
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
8157
8262
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -8221,17 +8326,17 @@ function opencodePluginDirs(configDir, worktree) {
8221
8326
  return [configDir, opencodeProjectDir(worktree)];
8222
8327
  }
8223
8328
  function opencodeProjectDir(worktree) {
8224
- return join10(worktree, OPENCODE_PROJECT_DIR);
8329
+ return join12(worktree, OPENCODE_PROJECT_DIR);
8225
8330
  }
8226
8331
  function packageResolves(fromDir) {
8227
8332
  for (let d = fromDir; ; d = dirname7(d)) {
8228
- 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;
8229
8334
  if (dirname7(d) === d) return false;
8230
8335
  }
8231
8336
  }
8232
8337
  function opencodeDirPlugins(dirs) {
8233
8338
  const bundle = opencodePluginFile();
8234
- const ownFile = join10(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
8339
+ const ownFile = join12(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
8235
8340
  const isModule = (p3) => OWN_PLUGIN_MODULES.includes(p3);
8236
8341
  const isPath = (p3) => {
8237
8342
  if (p3 === ownFile || p3 === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -8241,7 +8346,7 @@ function opencodeDirPlugins(dirs) {
8241
8346
  };
8242
8347
  const out2 = [];
8243
8348
  for (const dir of dirs) {
8244
- const pdir = join10(dir, OPENCODE_PLUGINS_DIR);
8349
+ const pdir = join12(dir, OPENCODE_PLUGINS_DIR);
8245
8350
  let names;
8246
8351
  try {
8247
8352
  names = readdirSync5(pdir);
@@ -8249,12 +8354,12 @@ function opencodeDirPlugins(dirs) {
8249
8354
  continue;
8250
8355
  }
8251
8356
  for (const name of names) {
8252
- const loose = OPENCODE_PLUGIN_EXTS.some((x2) => name.endsWith(x2)) ? [join10(pdir, name)] : [];
8253
- 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}`))];
8254
8359
  for (const f2 of files) {
8255
8360
  let text2;
8256
8361
  try {
8257
- const b3 = readFileSync6(f2);
8362
+ const b3 = readFileSync8(f2);
8258
8363
  if (b3.length > OPENCODE_DIR_FILE_MAX) continue;
8259
8364
  text2 = b3.toString("utf8");
8260
8365
  } catch {
@@ -8265,7 +8370,7 @@ function opencodeDirPlugins(dirs) {
8265
8370
  const loads2 = lits.some((p3) => {
8266
8371
  if (isModule(p3)) return packageResolves(dirname7(f2));
8267
8372
  const bare = p3.startsWith(FILE_URL_PREFIX) ? p3.slice(FILE_URL_PREFIX.length) : p3;
8268
- return existsSync9(isAbsolute3(bare) ? bare : resolve5(dirname7(f2), bare));
8373
+ return existsSync11(isAbsolute4(bare) ? bare : resolve5(dirname7(f2), bare));
8269
8374
  });
8270
8375
  out2.push({ file: f2, loads: loads2 });
8271
8376
  }
@@ -8285,7 +8390,7 @@ function formUrl(title, summary) {
8285
8390
  }
8286
8391
 
8287
8392
  // src/setup/registry.ts
8288
- import { existsSync as existsSync11, realpathSync as realpathSync6 } from "node:fs";
8393
+ import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
8289
8394
  import path6 from "node:path";
8290
8395
 
8291
8396
  // src/setup/hook-shapes.ts
@@ -8337,7 +8442,9 @@ var HOOK_SHAPES = {
8337
8442
  kiro: kiroShape,
8338
8443
  zcode: zcodeShape,
8339
8444
  pi: null,
8340
- opencode: null
8445
+ opencode: null,
8446
+ omp: null
8447
+ // ADR-0026: in-process like pi
8341
8448
  };
8342
8449
 
8343
8450
  // src/setup/registry.ts
@@ -8422,7 +8529,7 @@ var NATIVE_PLUGIN = {
8422
8529
  };
8423
8530
  var CELLAR_SEGMENT = "/Cellar/";
8424
8531
  var NODE_BIN = ["bin", "node"];
8425
- var REAL_FS = { exists: existsSync11, real: (p3) => realpathSync6.native(p3) };
8532
+ var REAL_FS = { exists: existsSync13, real: (p3) => realpathSync7.native(p3) };
8426
8533
  function stableNodePath(execPath, fs2 = REAL_FS) {
8427
8534
  const at = execPath.indexOf(CELLAR_SEGMENT);
8428
8535
  if (at < 0) return execPath;
@@ -8437,6 +8544,7 @@ function stableNodePath(execPath, fs2 = REAL_FS) {
8437
8544
  }
8438
8545
  return execPath;
8439
8546
  }
8547
+ var BARE_NODE_ON_WINDOWS = ["codex", "qwen", "copilot-cli", "vscode"];
8440
8548
  var SETUP_NODE = stableNodePath(process.execPath);
8441
8549
  function serverCmd(ctx, id) {
8442
8550
  return [SETUP_NODE, path6.join(ctx.pkgDir, SERVER_BUNDLE), AGENT_FLAG, id];
@@ -8492,6 +8600,9 @@ function cliFor(ctx, id) {
8492
8600
  return { bin: "copilot", install: [["mcp", "add", SERVER_KEY, "--", ...s]], remove: [["mcp", "remove", SERVER_KEY]] };
8493
8601
  case "pi":
8494
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]] };
8495
8606
  default:
8496
8607
  return void 0;
8497
8608
  }
@@ -8517,6 +8628,8 @@ var LIST = {
8517
8628
  qwen: { bin: "qwen", args: ["extensions", "list"] },
8518
8629
  "copilot-cli": { bin: "copilot", args: ["mcp", "list"] },
8519
8630
  pi: { bin: "pi", args: ["list"] },
8631
+ omp: { bin: "omp", args: ["plugin", "list"] },
8632
+ // ADR-0026
8520
8633
  // D-HF-OPENCODE-LIST-1: --pure skips external plugins, so a fresh HOME does not wait on the @opencode-ai/plugin install.
8521
8634
  opencode: { bin: "opencode", args: ["mcp", "list", "--pure"] }
8522
8635
  };
@@ -8581,7 +8694,7 @@ function buildRegistry(ctx) {
8581
8694
  const config = configFor(ctx, id);
8582
8695
  const hookFiles = hookFilesFor(ctx, id);
8583
8696
  const runCommand2 = [SETUP_NODE, path6.join(ctx.pkgDir, HOOK_BUNDLE), AGENT_FLAG, id];
8584
- const bareNode = (id === "codex" || id === "qwen") && (ctx.platform ?? process.platform) === "win32";
8697
+ const bareNode = BARE_NODE_ON_WINDOWS.includes(id) && (ctx.platform ?? process.platform) === "win32";
8585
8698
  const hookCommand = bareNode ? [HOST_NODE_COMMAND, ...runCommand2.slice(1)] : runCommand2;
8586
8699
  const command = `${bareNode ? HOST_NODE_COMMAND : `"${hookCommand[0]}"`} "${hookCommand[1]}" ${AGENT_FLAG} ${id}`;
8587
8700
  const hookInstall = hookInstallFor(ctx, getAdapter(id), command);
@@ -8593,7 +8706,9 @@ function buildRegistry(ctx) {
8593
8706
  ...hookFiles.map((h2) => h2.file),
8594
8707
  ...hookInstall.kind === "package" ? [] : [hookInstall.file],
8595
8708
  ...hookInstall.kind === "file" && hookInstall.trust ? [hookInstall.trust] : [],
8596
- ...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
8597
8712
  ];
8598
8713
  const out2 = {
8599
8714
  id,
@@ -8626,7 +8741,7 @@ function assertWritable(row, file) {
8626
8741
  }
8627
8742
 
8628
8743
  // src/setup/gemini-gate.ts
8629
- import { existsSync as existsSync12, readFileSync as readFileSync8 } from "node:fs";
8744
+ import { existsSync as existsSync14, readFileSync as readFileSync10 } from "node:fs";
8630
8745
  import path7 from "node:path";
8631
8746
  var GEMINI_DIR = ".gemini";
8632
8747
  var SETTINGS_FILE2 = "settings.json";
@@ -8646,9 +8761,9 @@ function systemDefaultsPath(env) {
8646
8761
  return set2 ? set2 : path7.join(path7.dirname(systemSettingsPath(env)), SYSTEM_DEFAULTS_FILE);
8647
8762
  }
8648
8763
  function load2(file) {
8649
- if (!existsSync12(file)) return void 0;
8764
+ if (!existsSync14(file)) return void 0;
8650
8765
  try {
8651
- 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") };
8652
8767
  } catch {
8653
8768
  return void 0;
8654
8769
  }
@@ -8680,7 +8795,7 @@ function geminiSettingsGate(env, home, cwd) {
8680
8795
  }
8681
8796
 
8682
8797
  // src/setup/zcode-gate.ts
8683
- import { existsSync as existsSync13, readFileSync as readFileSync9 } from "node:fs";
8798
+ import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
8684
8799
  import path8 from "node:path";
8685
8800
  var OWN_AGENT2 = "zcode";
8686
8801
  var EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "PostToolUse", "PostToolUseFailure", "Stop"];
@@ -8772,10 +8887,10 @@ function zcodeSchemaBad(doc) {
8772
8887
  }
8773
8888
  function zcodeConfigGate(home) {
8774
8889
  const file = path8.join(home, ".zcode", "cli", "config.json");
8775
- if (!existsSync13(file)) return void 0;
8890
+ if (!existsSync15(file)) return void 0;
8776
8891
  let doc;
8777
8892
  try {
8778
- doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync9(file, "utf8")), "json");
8893
+ doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync11(file, "utf8")), "json");
8779
8894
  } catch {
8780
8895
  return void 0;
8781
8896
  }
@@ -8785,7 +8900,7 @@ function zcodeConfigGate(home) {
8785
8900
  }
8786
8901
 
8787
8902
  // src/setup/vscode-gate.ts
8788
- import { existsSync as existsSync14, readFileSync as readFileSync10 } from "node:fs";
8903
+ import { existsSync as existsSync16, readFileSync as readFileSync12 } from "node:fs";
8789
8904
  import path9 from "node:path";
8790
8905
  var SETTINGS_FILE3 = "settings.json";
8791
8906
  var WORKSPACE_DIR = ".vscode";
@@ -8794,9 +8909,9 @@ var LOCATIONS_KEY = "chat.hookFilesLocations";
8794
8909
  var OWN_LOCATION = "~/.copilot/hooks";
8795
8910
  var MANAGED_KEYS = ["allowManagedHooksOnly", "strictPluginOnlyCustomization"];
8796
8911
  function load3(file) {
8797
- if (!existsSync14(file)) return void 0;
8912
+ if (!existsSync16(file)) return void 0;
8798
8913
  try {
8799
- return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync10(file, "utf8")), "jsonc") };
8914
+ return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync12(file, "utf8")), "jsonc") };
8800
8915
  } catch {
8801
8916
  return void 0;
8802
8917
  }
@@ -8836,7 +8951,7 @@ function vscodeSettingsGate(env, home, cwd, managedFile = managedSettingsPath(en
8836
8951
  }
8837
8952
 
8838
8953
  // src/setup/qwen-gate.ts
8839
- import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
8954
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "node:fs";
8840
8955
  import path10 from "node:path";
8841
8956
  var KEY = "disableAllHooks";
8842
8957
  var SETTINGS = "settings.json";
@@ -8852,10 +8967,10 @@ function settingsFiles(env, home, cwd, platform) {
8852
8967
  }
8853
8968
  function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platform) {
8854
8969
  for (const file of settingsFiles(env, home, cwd, platform)) {
8855
- if (!existsSync15(file)) continue;
8970
+ if (!existsSync17(file)) continue;
8856
8971
  let value;
8857
8972
  try {
8858
- value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync11(file, "utf8")), "jsonc"), [KEY]);
8973
+ value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync13(file, "utf8")), "jsonc"), [KEY]);
8859
8974
  } catch {
8860
8975
  continue;
8861
8976
  }
@@ -8866,7 +8981,7 @@ function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platfor
8866
8981
 
8867
8982
  // src/setup/codex-trust.ts
8868
8983
  import { createHash } from "node:crypto";
8869
- import { existsSync as existsSync16, realpathSync as realpathSync7 } from "node:fs";
8984
+ import { existsSync as existsSync18, realpathSync as realpathSync8 } from "node:fs";
8870
8985
  import path12 from "node:path";
8871
8986
  import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
8872
8987
 
@@ -8967,11 +9082,11 @@ function snake(name) {
8967
9082
  function realFile(file) {
8968
9083
  let dir = path12.resolve(file);
8969
9084
  const rest = [];
8970
- while (!existsSync16(dir) && path12.dirname(dir) !== dir) {
9085
+ while (!existsSync18(dir) && path12.dirname(dir) !== dir) {
8971
9086
  rest.unshift(path12.basename(dir));
8972
9087
  dir = path12.dirname(dir);
8973
9088
  }
8974
- return path12.join(realpathSync7(dir), ...rest);
9089
+ return path12.join(realpathSync8(dir), ...rest);
8975
9090
  }
8976
9091
  var ASK_TIMEOUT_MS = 1e4;
8977
9092
  var ASK_TRIES = 3;
@@ -9172,7 +9287,7 @@ function untrustedPluginHooksDetail(hooks) {
9172
9287
 
9173
9288
  // src/setup/copilot-hooks.ts
9174
9289
  import { spawn as spawn4 } from "node:child_process";
9175
- import { realpathSync as realpathSync8 } from "node:fs";
9290
+ import { realpathSync as realpathSync9 } from "node:fs";
9176
9291
  import path13 from "node:path";
9177
9292
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
9178
9293
  var ASK_TIMEOUT_MS2 = 15e3;
@@ -9182,7 +9297,7 @@ var USER_ORIGIN = "user";
9182
9297
  function canon(p3) {
9183
9298
  let r2 = path13.resolve(p3);
9184
9299
  try {
9185
- r2 = realpathSync8(r2);
9300
+ r2 = realpathSync9(r2);
9186
9301
  } catch {
9187
9302
  }
9188
9303
  return process.platform === "win32" ? r2.toLowerCase() : r2;
@@ -9267,7 +9382,7 @@ function listCopilotHooks(env, file, cwd) {
9267
9382
 
9268
9383
  // src/setup/engine.ts
9269
9384
  import { spawn as spawn5, spawnSync as spawnSync4 } from "node:child_process";
9270
- 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 statSync3, writeFileSync as writeFileSync3 } from "node:fs";
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";
9271
9386
  import { tmpdir as tmpdir2 } from "node:os";
9272
9387
  import path14 from "node:path";
9273
9388
 
@@ -9306,6 +9421,7 @@ function hookSample(id, cwd, text2) {
9306
9421
  case "copilot-cli":
9307
9422
  return { effect, payload: { sessionId: SAMPLE_SESSION, timestamp: Date.now(), cwd, toolName: tool, toolArgs: JSON.stringify(command), toolResult: { resultType: "success", textResultForLlm: text2 } } };
9308
9423
  case "pi":
9424
+ case "omp":
9309
9425
  return { effect, payload: { type: event, sessionId: SAMPLE_SESSION, cwd, toolName: tool, input: command, content: text2, isError: false } };
9310
9426
  case "opencode":
9311
9427
  return { effect, payload: { type: event, sessionID: SAMPLE_SESSION, directory: cwd, tool, args: command, ...effect === "replace" ? { output: text2 } : {} } };
@@ -9365,9 +9481,9 @@ function isNativeBinary(file) {
9365
9481
  function owningPackage(dir) {
9366
9482
  for (let d = dir; ; d = path14.dirname(d)) {
9367
9483
  const f2 = path14.join(d, "package.json");
9368
- if (existsSync17(f2)) {
9484
+ if (existsSync19(f2)) {
9369
9485
  try {
9370
- return String(JSON.parse(hostText(readFileSync12(f2, "utf8"))).name);
9486
+ return String(JSON.parse(hostText(readFileSync14(f2, "utf8"))).name);
9371
9487
  } catch {
9372
9488
  return void 0;
9373
9489
  }
@@ -9383,8 +9499,8 @@ function hostBin(bin, env, platform = process.platform) {
9383
9499
  for (const dir of pathEntries(get("PATH") ?? "", platform)) {
9384
9500
  const own2 = which(bin, { PATH: dir, ...get("PATHEXT") ? { PATHEXT: get("PATHEXT") } : {} }, platform);
9385
9501
  for (const f2 of [own2, ...real2.extra.map((p3) => path14.join(dir, ...p3))]) {
9386
- if (!f2 || !existsSync17(f2) || !statSync3(f2).isFile()) continue;
9387
- const file = realpathSync9(f2);
9502
+ if (!f2 || !existsSync19(f2) || !statSync3(f2).isFile()) continue;
9503
+ const file = realpathSync10(f2);
9388
9504
  if (isNativeBinary(file) || owningPackage(path14.dirname(file)) === real2.pkg) return { file: f2, shims };
9389
9505
  shims.push(f2);
9390
9506
  }
@@ -9400,10 +9516,10 @@ function runBin(bin, args, env, input, timeout = VERIFY_TIMEOUT_MS) {
9400
9516
  return spawnShim(hostBin(bin, env).file ?? bin, args, env, { encoding: "utf8", input, timeout, maxBuffer: Infinity });
9401
9517
  }
9402
9518
  function readOr(file) {
9403
- return existsSync17(file) ? hostText(readFileSync12(file, "utf8")) : void 0;
9519
+ return existsSync19(file) ? hostText(readFileSync14(file, "utf8")) : void 0;
9404
9520
  }
9405
9521
  function readRaw(file) {
9406
- return existsSync17(file) ? readFileSync12(file, "utf8") : void 0;
9522
+ return existsSync19(file) ? readFileSync14(file, "utf8") : void 0;
9407
9523
  }
9408
9524
  var atomicWrite = atomicWriteFile;
9409
9525
  function pidAlive(pid) {
@@ -9547,7 +9663,7 @@ function isNativeSpec(e) {
9547
9663
  function isStaleOwnPlugin(e, entry2) {
9548
9664
  if (typeof e !== "string" || e === entry2 || !path14.isAbsolute(e)) return false;
9549
9665
  if (e === path14.join(entry2, ...OPENCODE_PLUGIN_PATH)) return true;
9550
- if (existsSync17(e)) return false;
9666
+ if (existsSync19(e)) return false;
9551
9667
  const seg = e.split("\\").join("/").split("/");
9552
9668
  const n3 = seg.length;
9553
9669
  if (n3 >= 3 && seg[n3 - 1] === "plugin.js" && seg[n3 - 2] === "opencode" && seg[n3 - 3] === "context-mode") return true;
@@ -9635,12 +9751,20 @@ function planSkills(row, edits) {
9635
9751
  const s = row.skillInstall;
9636
9752
  if (s.kind !== "dir") return;
9637
9753
  for (const f2 of s.files) {
9638
- if (!existsSync17(f2.src)) throw new Error(`preflight: ${f2.src} is missing`);
9639
- 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);
9640
9756
  const before = readRaw(f2.file);
9641
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" }] });
9642
9758
  }
9643
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
+ }
9644
9768
  function planRow(row, listed, stale, env, disabled = false) {
9645
9769
  const edits = [];
9646
9770
  if (row.config) {
@@ -9782,7 +9906,7 @@ function hookEnabledCheck(row, status) {
9782
9906
  }
9783
9907
  function packageVersion(pkgDir) {
9784
9908
  try {
9785
- const v = JSON.parse(hostText(readFileSync12(path14.join(pkgDir, "package.json"), "utf8"))).version;
9909
+ const v = JSON.parse(hostText(readFileSync14(path14.join(pkgDir, "package.json"), "utf8"))).version;
9786
9910
  return typeof v === "string" ? v : void 0;
9787
9911
  } catch {
9788
9912
  return void 0;
@@ -9994,7 +10118,7 @@ var SEEN_SQL = "SELECT 1 FROM events WHERE agent = ? LIMIT 1";
9994
10118
  var NOT_SEEN_LINE = "not seen yet, run one tool call";
9995
10119
  function hookSeenCheck(row, dataRoot) {
9996
10120
  const base = path14.join(dataRoot, PROJECTS_DIR_NAME);
9997
- const dirs = existsSync17(base) ? readdirSync6(base) : [];
10121
+ const dirs = existsSync19(base) ? readdirSync6(base) : [];
9998
10122
  let sqlite;
9999
10123
  try {
10000
10124
  sqlite = process.getBuiltinModule("node:sqlite");
@@ -10003,7 +10127,7 @@ function hookSeenCheck(row, dataRoot) {
10003
10127
  }
10004
10128
  for (const d of dirs) {
10005
10129
  const file = path14.join(base, d, DB_FILE_NAME);
10006
- if (!sqlite || !existsSync17(file)) continue;
10130
+ if (!sqlite || !existsSync19(file)) continue;
10007
10131
  let db;
10008
10132
  try {
10009
10133
  db = new sqlite.DatabaseSync(file, { readOnly: true });
@@ -10020,17 +10144,17 @@ function skillsCheck(row, pkgDir) {
10020
10144
  const s = row.skillInstall;
10021
10145
  if (s.kind === "package") {
10022
10146
  const files = COMMAND_SKILLS.map((n3) => path14.join(pkgDir, s.via, n3, SKILL_FILE));
10023
- const miss = files.filter((f2) => !existsSync17(f2));
10147
+ const miss = files.filter((f2) => !existsSync19(f2));
10024
10148
  if (miss.length) return { name: "skills", ok: false, detail: `missing ${miss.join(", ")}` };
10025
10149
  const own2 = getAdapter(row.id).toolNamePrefix + SKILL_TOOL_STEM;
10026
10150
  const foreign = [...new Set(ADAPTERS.map((r2) => r2.toolNamePrefix + SKILL_TOOL_STEM))].filter((n3) => n3 !== SKILL_TOOL_STEM && n3 !== own2);
10027
10151
  const bad2 = files.filter((f2) => {
10028
- const t2 = readFileSync12(f2, "utf8");
10152
+ const t2 = readFileSync14(f2, "utf8");
10029
10153
  return !t2.includes(own2) && foreign.some((n3) => t2.includes(n3));
10030
10154
  });
10031
10155
  return { name: "skills", ok: bad2.length === 0, detail: bad2.length ? `${bad2.join(", ")} without the ${own2}* tool name` : void 0 };
10032
10156
  }
10033
- 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));
10034
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 };
10035
10159
  }
10036
10160
  var CODEX_CONFIG_FILE2 = "config.toml";
@@ -10087,7 +10211,70 @@ function jsonState(n3, text2) {
10087
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}`;
10088
10212
  return { state: "enabled", workspaceOff: false, hookGate };
10089
10213
  }
10090
- 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) {
10091
10278
  const none = { state: void 0, workspaceOff: false };
10092
10279
  const n3 = row.nativePlugin;
10093
10280
  if (!n3 || !hostBin(n3.bin, env).file) return none;
@@ -10097,10 +10284,19 @@ function nativeState(row, env) {
10097
10284
  const cmd = [n3.bin, ...n3.args].join(" ");
10098
10285
  return { ...none, stopped: `${cmd} stopped before it finished (${why}); it names ${n3.plugin}, run ${cmd} in a terminal` };
10099
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
+ }
10100
10297
  if (r2.status !== 0) return none;
10101
10298
  if (n3.format === "json") return jsonState(n3, `${r2.stdout}`);
10102
- if (n3.format === "codex-json") return { state: codexJsonState(n3, `${r2.stdout}`), workspaceOff: false };
10103
- return extensionState(n3, `${r2.stdout}${r2.stderr}`);
10299
+ return { state: codexJsonState(n3, `${r2.stdout}`), workspaceOff: false };
10104
10300
  }
10105
10301
  function nativeRow(row, n3) {
10106
10302
  return {
@@ -10116,12 +10312,22 @@ function nativeRow(row, n3) {
10116
10312
  }
10117
10313
  async function nativeResult(row, ctx, apply2) {
10118
10314
  const n3 = row.nativePlugin;
10119
- const { state, workspaceOff, hookGate, stopped } = nativeState(row, ctx.env);
10315
+ const { state, workspaceOff, hookGate, stopped, disk } = nativeState(row, ctx.env, ctx.home);
10120
10316
  const bin = n3 ? hostBin(n3.bin, ctx.env).file : void 0;
10121
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);
10122
10319
  if (!n3 || state === void 0) return void 0;
10123
10320
  if (state === "disabled") {
10124
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
+ };
10125
10331
  return {
10126
10332
  id: row.id,
10127
10333
  status: "FAIL",
@@ -10144,7 +10350,10 @@ async function nativeResult(row, ctx, apply2) {
10144
10350
  return { ...res, status: "FAIL", reason: e.message, rolledBack: true };
10145
10351
  }
10146
10352
  }
10147
- 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);
10148
10357
  if (n3.hookTrust) res.checks = withHookTrust(res.checks, hooks, !!apply2?.dryRun);
10149
10358
  if (n3.format === "extension") res.checks = withHookGate(res.checks, geminiGate(n3, ctx, workspaceOff));
10150
10359
  if (n3.format === "json") res.checks = withHookGate(res.checks, hookGate);
@@ -10159,6 +10368,81 @@ async function nativeResult(row, ctx, apply2) {
10159
10368
  }
10160
10369
  return res;
10161
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
+ }
10162
10446
  function trustPluginHooks(row, ctx, apply2, hooks) {
10163
10447
  const file = path14.join(codexDirOf(ctx.env, ctx.home), CODEX_CONFIG_FILE2);
10164
10448
  const text2 = readOr(file);
@@ -10253,10 +10537,14 @@ async function enableCopilotHooks(row, ctx, run) {
10253
10537
  return edit.edits.map((e) => ({ file: settings2, ...e }));
10254
10538
  }
10255
10539
  var isObjSetup = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
10256
- 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)) {
10257
10545
  const env = ctx.env;
10258
10546
  const checks = [parseCheck(row)];
10259
- const ls = listState(row, env);
10547
+ const ls = list2();
10260
10548
  const l = ls.check;
10261
10549
  if (l) checks.push(l);
10262
10550
  const cp = copyCheck(row, ctx.pkgDir);
@@ -10310,7 +10598,7 @@ function undo(dir, entries, env) {
10310
10598
  continue;
10311
10599
  }
10312
10600
  if (!e.file) continue;
10313
- if (e.existed && e.backup) atomicWrite(e.file, readFileSync12(path14.join(dir, e.backup), "utf8"));
10601
+ if (e.existed && e.backup) atomicWrite(e.file, readFileSync14(path14.join(dir, e.backup), "utf8"));
10314
10602
  else unlinkWithRetry(e.file);
10315
10603
  }
10316
10604
  }
@@ -10325,7 +10613,7 @@ function takeLock(root, runId) {
10325
10613
  if (e.code !== "EEXIST") throw e;
10326
10614
  let pid = 0;
10327
10615
  try {
10328
- pid = Number(JSON.parse(readFileSync12(file, "utf8")).pid);
10616
+ pid = Number(JSON.parse(readFileSync14(file, "utf8")).pid);
10329
10617
  } catch {
10330
10618
  }
10331
10619
  if (pid && pidAlive(pid)) return `setup lock ${file} is held by pid ${pid}; wait for that run or remove the lock`;
@@ -10343,7 +10631,7 @@ function agentHomeDir(id, ctx) {
10343
10631
  return path14.join(ctx.home, ...AGENT_HOME_DIR[id]);
10344
10632
  }
10345
10633
  function detectAgents(reg, ctx) {
10346
- 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);
10347
10635
  }
10348
10636
  async function runSetup(opts) {
10349
10637
  const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env, cwd: opts.cwd };
@@ -10352,7 +10640,7 @@ async function runSetup(opts) {
10352
10640
  const nodeVersion = opts.nodeVersion ?? process.version;
10353
10641
  if (nodeTooOld(nodeVersion)) return { exitCode: 1, agents: [], error: formatError("NODE_TOO_OLD", { v: nodeVersion }) };
10354
10642
  for (const f2 of ["server.mjs", "hook.mjs"]) {
10355
- if (!existsSync17(path14.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path14.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` };
10356
10644
  }
10357
10645
  const ids = opts.agents ?? detectAgents(reg, ctx);
10358
10646
  const root = dataRootOf(ctx.env, ctx.home);
@@ -10388,7 +10676,7 @@ async function runSetup(opts) {
10388
10676
  }
10389
10677
  return { exitCode: agents.some((a2) => a2.status === "FAIL") ? 1 : 0, agents, backupDir: run.manifest ? run.dir : void 0 };
10390
10678
  }
10391
- async function setupRow(row, ctx, run, dryRun) {
10679
+ async function setupRow(row, ctx, run, dryRun, list2 = () => listState(row, ctx.env)) {
10392
10680
  const res = { id: row.id, status: "PASS", v1: [], changes: [], checks: [] };
10393
10681
  const needsBin = !row.config && row.cli;
10394
10682
  if (needsBin) {
@@ -10400,10 +10688,11 @@ async function setupRow(row, ctx, run, dryRun) {
10400
10688
  if (!row.config && !row.cli) return { ...res, status: "SKIPPED", reason: `${row.id}: no setup path in the registry` };
10401
10689
  let plan;
10402
10690
  try {
10403
- 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 };
10404
10692
  if (ls.broken) return { ...res, status: "SKIPPED", reason: ls.broken };
10405
10693
  const listed = ls.check?.ok === true;
10406
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);
10407
10696
  } catch (e) {
10408
10697
  return { ...res, status: "FAIL", reason: e.message };
10409
10698
  }
@@ -10459,7 +10748,7 @@ async function runDoctor(opts) {
10459
10748
  const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env, cwd: opts.cwd };
10460
10749
  const reg = buildRegistry(ctx);
10461
10750
  for (const f2 of ["server.mjs", "hook.mjs"]) {
10462
- if (!existsSync17(path14.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path14.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` };
10463
10752
  }
10464
10753
  const ids = opts.agents ?? detectAgents(reg, ctx);
10465
10754
  const run = new Run(dataRootOf(ctx.env, ctx.home), "doctor");
@@ -10477,7 +10766,14 @@ async function runDoctor(opts) {
10477
10766
  opts.onAgent?.(id, "done", native);
10478
10767
  continue;
10479
10768
  }
10480
- 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
+ }
10481
10777
  if (res.status === "PASS") {
10482
10778
  if (res.v1.some((f2) => !UPGRADE_REPORT_ONLY_REASONS.includes(f2.reason))) {
10483
10779
  res.status = "FAIL";
@@ -10486,7 +10782,7 @@ async function runDoctor(opts) {
10486
10782
  res.status = "FAIL";
10487
10783
  res.reason = notSetUpReason(row, res, ctx.env);
10488
10784
  } else {
10489
- res.checks = await verifyRow(row, ctx);
10785
+ res.checks = await verifyRow(row, ctx, list2);
10490
10786
  const bad = res.checks.filter((c3) => !c3.ok);
10491
10787
  if (bad.length) {
10492
10788
  res.status = "FAIL";
@@ -10501,6 +10797,46 @@ async function runDoctor(opts) {
10501
10797
  }
10502
10798
  return { exitCode: agents.some((a2) => a2.status === "FAIL") ? 1 : 0, agents };
10503
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
+ }
10504
10840
  function notSetUpReason(row, res, env) {
10505
10841
  const h2 = row.hookInstall;
10506
10842
  const missing = row.id === "opencode" && h2.kind === "plugin-list" && res.changes.some((c3) => c3.path === h2.key[0]);
@@ -10539,14 +10875,14 @@ function runRemove(opts) {
10539
10875
  const env = opts.env ?? process.env;
10540
10876
  const root = dataRootOf(env, opts.home);
10541
10877
  const base = path14.join(root, BACKUP_DIR);
10542
- if (!existsSync17(base)) return { exitCode: 0, restored: 0 };
10878
+ if (!existsSync19(base)) return { exitCode: 0, restored: 0 };
10543
10879
  const held = takeLock(root, "remove");
10544
10880
  if (held) return { exitCode: 1, restored: 0, error: held };
10545
10881
  let restored = 0;
10546
10882
  try {
10547
- const runs = readdirSync6(base).map((r2) => path14.join(base, r2)).filter((d) => existsSync17(path14.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();
10548
10884
  for (const dir of runs) {
10549
- const m3 = JSON.parse(readFileSync12(path14.join(dir, MANIFEST), "utf8"));
10885
+ const m3 = JSON.parse(readFileSync14(path14.join(dir, MANIFEST), "utf8"));
10550
10886
  undo(dir, m3.entries, env);
10551
10887
  restored += m3.entries.length;
10552
10888
  renameWithRetry(path14.join(dir, MANIFEST), path14.join(dir, MANIFEST_DONE));
@@ -10558,7 +10894,7 @@ function runRemove(opts) {
10558
10894
  }
10559
10895
 
10560
10896
  // src/setup/print.ts
10561
- import { readFileSync as readFileSync13 } from "node:fs";
10897
+ import { readFileSync as readFileSync15 } from "node:fs";
10562
10898
  var SHELL_SAFE_PUNCT = "@%+=:,./-_";
10563
10899
  function isShellSafe(s) {
10564
10900
  if (s === "") return false;
@@ -10586,7 +10922,7 @@ function printPlan(row, env) {
10586
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" });
10587
10923
  const sk = row.skillInstall;
10588
10924
  if (sk.kind === "dir") {
10589
- 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) });
10590
10926
  }
10591
10927
  return { agent: row.id, steps, verify: `context-mode doctor --agents ${row.id}` };
10592
10928
  }
@@ -11014,7 +11350,7 @@ async function upgrade(ui) {
11014
11350
  }
11015
11351
  const root = `${spawnSync5(npm, ["root", "-g"], { env: ui.ctx.env, encoding: "utf8", shell, windowsHide: true }).stdout ?? ""}`.trim();
11016
11352
  const cli = path15.join(root, "context-mode", "cli.mjs");
11017
- if (!root || !existsSync18(cli)) {
11353
+ if (!root || !existsSync20(cli)) {
11018
11354
  err(`FAIL upgrade: ${cli} not found after ${install}. Fix: ${install}`);
11019
11355
  return EXIT_FAIL;
11020
11356
  }
@@ -11053,12 +11389,12 @@ Run context-mode ${cmd} --help.`);
11053
11389
  }
11054
11390
 
11055
11391
  // src/entries/is-entry.ts
11056
- import { realpathSync as realpathSync10 } from "node:fs";
11392
+ import { realpathSync as realpathSync11 } from "node:fs";
11057
11393
  function isEntry(main2, argv1, self) {
11058
11394
  if (main2 !== void 0) return main2;
11059
11395
  if (argv1 === void 0 || argv1 === "") return false;
11060
11396
  try {
11061
- return realpathSync10(argv1) === realpathSync10(self);
11397
+ return realpathSync11(argv1) === realpathSync11(self);
11062
11398
  } catch {
11063
11399
  return false;
11064
11400
  }
@@ -11109,10 +11445,10 @@ function route(argv, version) {
11109
11445
  ` };
11110
11446
  }
11111
11447
  function main() {
11112
- const dir = path16.dirname(realpathSync11(fileURLToPath3(import.meta.url)));
11448
+ const dir = path16.dirname(realpathSync12(fileURLToPath3(import.meta.url)));
11113
11449
  let version = "";
11114
11450
  try {
11115
- version = String(JSON.parse(readFileSync14(path16.join(dir, PACKAGE_FILE), "utf8")).version);
11451
+ version = String(JSON.parse(readFileSync16(path16.join(dir, PACKAGE_FILE), "utf8")).version);
11116
11452
  } catch (err2) {
11117
11453
  process.stderr.write(`${SERVER_KEY}: cannot read ${PACKAGE_FILE}: ${err2.message}
11118
11454
  `);