context-mode 2.1.10 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/server.mjs CHANGED
@@ -7,8 +7,8 @@ var __export = (target, all) => {
7
7
 
8
8
  // src/entries/server.ts
9
9
  import { randomUUID } from "node:crypto";
10
- import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
11
- import { dirname as dirname14, join as join23 } from "node:path";
10
+ import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
11
+ import { dirname as dirname14, join as join25 } from "node:path";
12
12
  import { fileURLToPath as fileURLToPath3 } from "node:url";
13
13
 
14
14
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -17979,8 +17979,8 @@ function liftWireOnlyMaterial(message2, kind) {
17979
17979
  };
17980
17980
  }
17981
17981
  function codecResultValidator(codec, method) {
17982
- const probe = codec.validateResult(method, void 0);
17983
- if (!probe.ok && probe.reason === "not-in-era") return void 0;
17982
+ const probe2 = codec.validateResult(method, void 0);
17983
+ if (!probe2.ok && probe2.reason === "not-in-era") return void 0;
17984
17984
  return { "~standard": {
17985
17985
  version: 1,
17986
17986
  vendor: "mcp-wire-codec",
@@ -28052,7 +28052,7 @@ function toError(value) {
28052
28052
  }
28053
28053
 
28054
28054
  // src/core/contracts/agents.ts
28055
- var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
28055
+ var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode", "omp"];
28056
28056
 
28057
28057
  // src/core/contracts/constants.ts
28058
28058
  var SERVER_KEY = "context-mode";
@@ -28227,6 +28227,10 @@ var DB_TIMEOUT_MS = 5e3;
28227
28227
  var DB_WAL_SUFFIX = "-wal";
28228
28228
  var DB_SHM_SUFFIX = "-shm";
28229
28229
  var DB_TMP_SUFFIX = ".tmp";
28230
+ var DB_LINK_DENIED_CODES = ["EACCES", "EPERM", "ENOSYS", "ENOTSUP", "EOPNOTSUPP"];
28231
+ var DB_PUBLISH_CLAIM_SUFFIX = ".publish";
28232
+ var DB_CLAIM_BUSY_CODES = ["EEXIST", "EPERM"];
28233
+ var DB_PUBLISH_POLL_MS = 5;
28230
28234
  var SQLITE_PRIMARY_CODE_MASK = 255;
28231
28235
  var SQLITE_CORRUPT_CODE = 11;
28232
28236
  var SQLITE_NOTADB_CODE = 26;
@@ -28355,6 +28359,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
28355
28359
  qwen: READ_IMAGES_AND_PDF,
28356
28360
  opencode: READ_IMAGES_AND_PDF,
28357
28361
  pi: READ_IMAGES,
28362
+ omp: READ_IMAGES,
28358
28363
  vscode: READ_IMAGES,
28359
28364
  zcode: READ_IMAGES,
28360
28365
  "copilot-cli": [],
@@ -28446,7 +28451,7 @@ function PURGE_SUMMARY(rows, scope) {
28446
28451
  var DECISION_SOURCE = "decision";
28447
28452
  var DECISION_USER_LABEL = "decision (user)";
28448
28453
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
28449
- var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
28454
+ var BUNDLE_SHA = true ? "1fce537096e8e2b7d1924c2b5ff2b83287f157ee" : void 0;
28450
28455
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
28451
28456
  var DOCTOR_LABEL = Object.freeze({
28452
28457
  D1: "version",
@@ -28602,7 +28607,9 @@ var AGENT_HOME_DIR = Object.freeze({
28602
28607
  kiro: [".kiro"],
28603
28608
  zcode: [".zcode"],
28604
28609
  pi: [".pi"],
28605
- opencode: [".config", "opencode"]
28610
+ opencode: [".config", "opencode"],
28611
+ omp: [".omp"]
28612
+ // ADR-0026: OMP data and plugins live under ~/.omp
28606
28613
  });
28607
28614
  var UPGRADE_RESTART_LINE = "restart needed";
28608
28615
  var UPGRADE_HOST_AREA = "host update";
@@ -28690,16 +28697,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
28690
28697
  binaries: [],
28691
28698
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
28692
28699
  }),
28693
- unsupported({
28694
- id: "omp",
28695
- name: "OMP (oh-my-pi)",
28696
- clientNames: ["omp-coding-agent"],
28697
- envVars: [],
28698
- pluginPaths: [],
28699
- configDirs: [".omp"],
28700
- binaries: ["omp"],
28701
- source: "v1.0.169:src/adapters/client-map.ts:37; detect.ts:543 (PI_CODING_AGENT_DIR is not a signal: supported Pi reads it too)"
28702
- }),
28703
28700
  unsupported({
28704
28701
  id: "openclaw",
28705
28702
  name: "OpenClaw",
@@ -28766,7 +28763,9 @@ var HOOK_HOST_FILE = Object.freeze({
28766
28763
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
28767
28764
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
28768
28765
  pi: null,
28769
- opencode: null
28766
+ opencode: null,
28767
+ omp: null
28768
+ // ADR-0026: in-process, no hook file
28770
28769
  });
28771
28770
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
28772
28771
  var HOOK_MATCHER_FIELD = "matcher";
@@ -28817,6 +28816,12 @@ var D11_POSIX_FIX = "install sh or add it to PATH";
28817
28816
  function D11_PASS_DETAIL(shell, win) {
28818
28817
  return `${win ? "Git Bash" : "sh"}: ${shell}`;
28819
28818
  }
28819
+ function D11_RUNTIME_DETAIL(lang, unreadable) {
28820
+ return `${lang} not found, unreadable on PATH: ${unreadable.join(", ")}`;
28821
+ }
28822
+ function D11_RUNTIME_FIX(lang) {
28823
+ return `install ${lang}, or turn off its app alias and PATH entry that cannot be read`;
28824
+ }
28820
28825
  var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
28821
28826
  var HEAL_TMP_SUFFIX = ".heal";
28822
28827
  var HEAL_TS_SEP = ".";
@@ -28828,6 +28833,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
28828
28833
  gemini: "gemini extensions update context-mode",
28829
28834
  qwen: "qwen extensions update context-mode",
28830
28835
  pi: "pi update --extensions",
28836
+ omp: "omp plugin upgrade context-mode",
28837
+ // ADR-0026 decision 4: OMP native update
28831
28838
  opencode: "opencode plugin update",
28832
28839
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
28833
28840
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -28871,6 +28878,14 @@ var PI_NPM_DIR = "npm";
28871
28878
  var PI_NODE_MODULES_DIR = "node_modules";
28872
28879
  var PI_PACKAGE_JSON_FILE = "package.json";
28873
28880
  var PI_LIST_COMMAND = "pi list";
28881
+ var OMP_LIST_COMMAND = "omp plugin list";
28882
+ var OMP_ENABLE_COMMAND = "omp plugin enable context-mode";
28883
+ var OMP_MIN_VERSION = "14.7.0";
28884
+ var OMP_FLOOR_INFO = (v) => `OMP ${v} is older than the tested floor ${OMP_MIN_VERSION}. Update it with: omp update`;
28885
+ var OMP_CONTENT_INFO = "OMP keeps tool output in content; context-mode writes its notes there.";
28886
+ var OMP_PRINT_MODE_INFO = "Print mode sends no prompt event. Use omp or omp --mode rpc to keep prompts.";
28887
+ var OMP_SCRIPTS_INFO = "Add < /dev/null in scripts.";
28888
+ var OMP_IMPORT_INFO = (claude, mcp) => `OMP also imports context-mode from ${claude}. To run it once, add "context-mode" to disabledServers in ${mcp}.`;
28874
28889
  var PI_CURRENT_MAJOR = 2;
28875
28890
  var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
28876
28891
  var V1_TMP_PREFIX = "context-mode-";
@@ -29081,6 +29096,8 @@ var NATIVE_INSTALL = Object.freeze({
29081
29096
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
29082
29097
  opencode: ["opencode plugin add context-mode"],
29083
29098
  pi: ["pi install npm:context-mode"],
29099
+ omp: ["omp plugin install context-mode"],
29100
+ // ADR-0026 decision 4: OMP native install
29084
29101
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
29085
29102
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
29086
29103
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -29301,7 +29318,7 @@ function openReadOnlyHandle(sqlite, path8, opts = {}) {
29301
29318
  }
29302
29319
 
29303
29320
  // src/core/store/db.ts
29304
- var { existsSync, linkSync, mkdirSync, rmSync } = process.getBuiltinModule("node:fs");
29321
+ var { existsSync, linkSync, mkdirSync, renameSync, rmSync, statSync } = process.getBuiltinModule("node:fs");
29305
29322
  function versionParts(v) {
29306
29323
  const bare2 = v.startsWith("v") ? v.slice(1) : v;
29307
29324
  return bare2.split(".").map((p) => Number.parseInt(p, 10));
@@ -29333,6 +29350,34 @@ function readUserVersion(raw) {
29333
29350
  const row5 = raw.prepare("PRAGMA user_version").get();
29334
29351
  return row5.user_version;
29335
29352
  }
29353
+ function errCode(err) {
29354
+ return err.code ?? "";
29355
+ }
29356
+ function publishWithoutLink(tmp, path8) {
29357
+ const claim3 = path8 + DB_PUBLISH_CLAIM_SUFFIX;
29358
+ const start = Date.now();
29359
+ for (; ; ) {
29360
+ if (existsSync(path8)) return;
29361
+ try {
29362
+ mkdirSync(claim3);
29363
+ } catch (err) {
29364
+ if (!DB_CLAIM_BUSY_CODES.includes(errCode(err))) throw err;
29365
+ if (Date.now() - start < DB_TIMEOUT_MS) {
29366
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, DB_PUBLISH_POLL_MS);
29367
+ continue;
29368
+ }
29369
+ const held = statSync(claim3, { throwIfNoEntry: false });
29370
+ if (held !== void 0 && held.mtimeMs < start) rmSync(claim3, { recursive: true, force: true });
29371
+ throw new Error(`context.db was not published within ${DB_TIMEOUT_MS} ms: ${claim3} was held; open again`);
29372
+ }
29373
+ try {
29374
+ if (!existsSync(path8)) renameSync(tmp, path8);
29375
+ } finally {
29376
+ rmSync(claim3, { recursive: true, force: true });
29377
+ }
29378
+ return;
29379
+ }
29380
+ }
29336
29381
  function createAtomically(sqlite, path8) {
29337
29382
  const { randomUUID: randomUUID2 } = process.getBuiltinModule("node:crypto");
29338
29383
  const tmp = path8 + "." + randomUUID2() + DB_TMP_SUFFIX;
@@ -29346,7 +29391,9 @@ function createAtomically(sqlite, path8) {
29346
29391
  try {
29347
29392
  linkSync(tmp, path8);
29348
29393
  } catch (err) {
29349
- if (err.code !== "EEXIST") throw err;
29394
+ const code = errCode(err);
29395
+ if (DB_LINK_DENIED_CODES.includes(code)) publishWithoutLink(tmp, path8);
29396
+ else if (code !== "EEXIST") throw err;
29350
29397
  }
29351
29398
  } finally {
29352
29399
  for (const suffix of ["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]) rmSync(tmp + suffix, { force: true });
@@ -29842,7 +29889,7 @@ function sha256Hex(text) {
29842
29889
  }
29843
29890
 
29844
29891
  // src/core/project/resolve.ts
29845
- var { existsSync: existsSync3, readFileSync: readFileSync2, realpathSync: realpathSync3, statSync } = process.getBuiltinModule("node:fs");
29892
+ var { existsSync: existsSync3, readFileSync: readFileSync2, realpathSync: realpathSync3, statSync: statSync2 } = process.getBuiltinModule("node:fs");
29846
29893
  function sourceOf(agent) {
29847
29894
  switch (agent) {
29848
29895
  case "claude-code":
@@ -29859,6 +29906,7 @@ function sourceOf(agent) {
29859
29906
  case "opencode":
29860
29907
  return "spawn-cwd";
29861
29908
  case "pi":
29909
+ case "omp":
29862
29910
  return "pi:ctx.cwd";
29863
29911
  }
29864
29912
  }
@@ -29902,7 +29950,7 @@ function gitDirs(dir) {
29902
29950
  function gitDirAt(dotGit) {
29903
29951
  let gitDir;
29904
29952
  try {
29905
- if (statSync(dotGit).isDirectory()) {
29953
+ if (statSync2(dotGit).isDirectory()) {
29906
29954
  gitDir = dotGit;
29907
29955
  } else {
29908
29956
  const line = firstLine(dotGit);
@@ -32517,12 +32565,12 @@ function recallQueryText(prompt) {
32517
32565
  if (cur !== "" && kept.size < RECALL_QUERY_MAX_TERMS) add(cur);
32518
32566
  return [...kept.size > 0 ? kept : all].join(" ");
32519
32567
  }
32520
- function queryUnits(db, sessionId, q, limit) {
32568
+ function queryUnits(db, sessionId, q, limit, maxSourceId = Number.MAX_SAFE_INTEGER) {
32521
32569
  const match = searchTerms(q).join(" OR ");
32522
32570
  if (match === "" || sessionId === "") return [];
32523
32571
  const rows = db.raw.prepare(
32524
- "SELECT u.source_id AS source_id, u.ord AS ord, u.body AS body, -bm25(line_units) AS score, s.label AS label FROM line_units u JOIN sources s ON s.id = u.source_id WHERE line_units MATCH ? AND u.session_id = ? ORDER BY bm25(line_units) LIMIT ?"
32525
- ).all(match, sessionId, limit);
32572
+ "SELECT u.source_id AS source_id, u.ord AS ord, u.body AS body, -bm25(line_units) AS score, s.label AS label FROM line_units u JOIN sources s ON s.id = u.source_id WHERE line_units MATCH ? AND u.session_id = ? AND s.id <= ? ORDER BY bm25(line_units) LIMIT ?"
32573
+ ).all(match, sessionId, maxSourceId, limit);
32526
32574
  return rows.map((r) => ({ sourceId: Number(r.source_id), ord: Number(r.ord), label: r.label, body: r.body, score: r.score }));
32527
32575
  }
32528
32576
 
@@ -32535,7 +32583,7 @@ function ownersDir(configDir, projectKey) {
32535
32583
  function ownerFile(configDir, projectKey, serverId) {
32536
32584
  return join4(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
32537
32585
  }
32538
- function errCode(err) {
32586
+ function errCode2(err) {
32539
32587
  return err.code;
32540
32588
  }
32541
32589
  function writeOwnerPid(configDir, projectKey, serverId) {
@@ -32551,8 +32599,8 @@ function isLive(pid) {
32551
32599
  process.kill(pid, 0);
32552
32600
  return true;
32553
32601
  } catch (err) {
32554
- if (errCode(err) === "ESRCH") return false;
32555
- if (errCode(err) === "EPERM") return true;
32602
+ if (errCode2(err) === "ESRCH") return false;
32603
+ if (errCode2(err) === "EPERM") return true;
32556
32604
  throw err;
32557
32605
  }
32558
32606
  }
@@ -32562,7 +32610,7 @@ function listLiveOwners(configDir, projectKey) {
32562
32610
  try {
32563
32611
  names = readdirSync2(dir);
32564
32612
  } catch (err) {
32565
- if (errCode(err) === "ENOENT") return [];
32613
+ if (errCode2(err) === "ENOENT") return [];
32566
32614
  throw err;
32567
32615
  }
32568
32616
  const live = [];
@@ -32573,7 +32621,7 @@ function listLiveOwners(configDir, projectKey) {
32573
32621
  try {
32574
32622
  text = readFileSync3(file2, "utf8");
32575
32623
  } catch (err) {
32576
- if (errCode(err) === "ENOENT") continue;
32624
+ if (errCode2(err) === "ENOENT") continue;
32577
32625
  throw err;
32578
32626
  }
32579
32627
  const serverId = basename3(name, OWNER_PID_EXT);
@@ -44102,7 +44150,7 @@ function cutPoint(src, start, end, scratch) {
44102
44150
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
44103
44151
  return { end: start + r.read, written: r.written };
44104
44152
  }
44105
- function merge4(src, blocks, join24, cap, lineCut) {
44153
+ function merge4(src, blocks, join26, cap, lineCut) {
44106
44154
  const out = [];
44107
44155
  const scratch = new Uint8Array(cap);
44108
44156
  let wide;
@@ -44112,7 +44160,7 @@ function merge4(src, blocks, join24, cap, lineCut) {
44112
44160
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
44113
44161
  };
44114
44162
  for (const b of blocks) {
44115
- if (cur !== void 0 && !join24) {
44163
+ if (cur !== void 0 && !join26) {
44116
44164
  emit(cur.start, cur.end, curBytes);
44117
44165
  cur = void 0;
44118
44166
  }
@@ -44206,7 +44254,7 @@ function buildChildEnv(parent, extra) {
44206
44254
  }
44207
44255
 
44208
44256
  // src/core/sandbox/runtimes.ts
44209
- import { accessSync, constants as fsConstants, statSync as statSync2 } from "node:fs";
44257
+ import { accessSync, constants as fsConstants, statSync as statSync3 } from "node:fs";
44210
44258
  import path from "node:path";
44211
44259
 
44212
44260
  // src/core/sandbox/path-entries.ts
@@ -44248,22 +44296,34 @@ function fileNames(name, pathExt) {
44248
44296
  if (!isWin() || path.extname(name) !== "") return [name];
44249
44297
  return [...pathExt.map((ext) => name + ext), name];
44250
44298
  }
44251
- function isRunnable(full) {
44252
- const st = statSync2(full, { throwIfNoEntry: false });
44253
- if (st === void 0 || !st.isFile()) return false;
44299
+ function probe(full) {
44300
+ let st;
44301
+ try {
44302
+ st = statSync3(full, { throwIfNoEntry: false });
44303
+ } catch {
44304
+ return "unreadable";
44305
+ }
44306
+ if (st === void 0 || !st.isFile()) return "absent";
44254
44307
  if (isWin()) {
44255
44308
  const ext = path.extname(full).toLowerCase();
44256
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
44309
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
44257
44310
  }
44258
44311
  try {
44259
44312
  accessSync(full, fsConstants.X_OK);
44260
- return true;
44313
+ return "runnable";
44261
44314
  } catch {
44262
- return false;
44315
+ return "absent";
44263
44316
  }
44264
44317
  }
44318
+ function isRunnable(full) {
44319
+ return probe(full) === "runnable";
44320
+ }
44265
44321
  function findRuntime(lang, env = process.env) {
44266
- if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
44322
+ return lookupRuntime(lang, env).found;
44323
+ }
44324
+ function lookupRuntime(lang, env = process.env) {
44325
+ const unreadable = [];
44326
+ if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
44267
44327
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
44268
44328
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
44269
44329
  const names = candidates(lang);
@@ -44272,13 +44332,15 @@ function findRuntime(lang, env = process.env) {
44272
44332
  for (const name of names) {
44273
44333
  for (const file2 of fileNames(name, pathExt)) {
44274
44334
  const full = path.join(dir, file2);
44275
- if (!isRunnable(full)) continue;
44276
- if (!isWin() || path.extname(full) !== "") return full;
44335
+ const state = probe(full);
44336
+ if (state === "unreadable") unreadable.push(full);
44337
+ if (state !== "runnable") continue;
44338
+ if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
44277
44339
  if (shim === null) shim = full;
44278
44340
  }
44279
44341
  }
44280
44342
  }
44281
- return shim;
44343
+ return { found: shim, unreadable };
44282
44344
  }
44283
44345
  function findGitBash(env) {
44284
44346
  const git2 = findRuntime(GIT_BIN, env);
@@ -44358,7 +44420,7 @@ function runProcess(argv, o) {
44358
44420
  let stopTimer;
44359
44421
  const kill = () => {
44360
44422
  if (child.pid !== void 0) killTree(child.pid);
44361
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
44423
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
44362
44424
  };
44363
44425
  const onAbort = () => {
44364
44426
  if (killedBy !== null || settled) return;
@@ -44387,15 +44449,21 @@ function runProcess(argv, o) {
44387
44449
  ...held ? { held: true } : {}
44388
44450
  });
44389
44451
  };
44390
- const finishHeld = () => {
44452
+ const finishHeld = (force = false) => {
44391
44453
  if (settled) return;
44392
- held = exited && killedBy === null;
44393
- child.stdout.destroy();
44394
- child.stderr.destroy();
44395
- if (child.pid !== void 0) killTree(child.pid);
44396
- settle3(child.exitCode);
44454
+ const seen = chunkCount;
44455
+ setImmediate(() => {
44456
+ if (settled || !force && chunkCount !== seen) return;
44457
+ held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
44458
+ child.stdout.destroy();
44459
+ child.stderr.destroy();
44460
+ if (child.pid !== void 0) killTree(child.pid);
44461
+ settle3(child.exitCode);
44462
+ });
44397
44463
  };
44464
+ let chunkCount = 0;
44398
44465
  const bump = () => {
44466
+ chunkCount++;
44399
44467
  if (!exited || settled) return;
44400
44468
  clearTimeout(graceTimer);
44401
44469
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -44413,7 +44481,7 @@ function runProcess(argv, o) {
44413
44481
  if (settled) return;
44414
44482
  exited = true;
44415
44483
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
44416
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
44484
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
44417
44485
  });
44418
44486
  child.on("error", () => settle3(null));
44419
44487
  child.stdin.on("error", () => {
@@ -44426,7 +44494,7 @@ function runProcess(argv, o) {
44426
44494
  }
44427
44495
 
44428
44496
  // src/core/index/auto-memory.ts
44429
- import { readdirSync as readdirSync4, readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
44497
+ import { readdirSync as readdirSync4, readFileSync as readFileSync4, statSync as statSync4 } from "node:fs";
44430
44498
  import { join as join6 } from "node:path";
44431
44499
  var MEMORY_FILES = Object.freeze([
44432
44500
  Object.freeze(["CLAUDE.md"]),
@@ -44452,7 +44520,7 @@ function readAutoMemory(project) {
44452
44520
  const path8 = join6(project.worktree, ...segs);
44453
44521
  if (!isInside(project.worktree, path8)) continue;
44454
44522
  try {
44455
- const st = statSync3(path8);
44523
+ const st = statSync4(path8);
44456
44524
  if (!st.isFile()) continue;
44457
44525
  rows.push({
44458
44526
  origin: "memory",
@@ -44576,15 +44644,42 @@ function sourceCount(db, scope, ctx, source) {
44576
44644
  });
44577
44645
  return Number(row5.n);
44578
44646
  }
44579
- function zeroHits(db, scope, ctx, source, mem, offset = 0) {
44580
- const n = sourceCount(db, scope, ctx, source) + mem.rows.length;
44647
+ function zeroHits(db, scope, ctx, source, mem, nm, queries, offset = 0) {
44648
+ const inScope = sourceCount(db, scope, ctx, source);
44649
+ const n = inScope + mem.rows.length;
44581
44650
  if (offset > 0) return reply("No more hits past offset " + offset + ' in scope "' + scope + '" across ' + n + " source(s).", false);
44582
- return reply('No hits in scope "' + scope + '" across ' + n + " source(s).", false);
44651
+ const head = 'No hits in scope "' + scope + '" across ' + n + " source(s).";
44652
+ const pick4 = nm.pick;
44653
+ if (pick4 === null || mem.named || inScope > 0) return reply(head, false);
44654
+ if (pick4.id !== null) {
44655
+ const wider = scope === "session" && sourceCount(db, "worktree", ctx, source) > 0 ? "worktree" : "project";
44656
+ return reply(head + "\nSource " + JSON.stringify(nm.arg) + ' is stored in scope "' + wider + '": ' + callText(queries, wider, nm.arg, "") + " searches it.", false);
44657
+ }
44658
+ return reply(head + "\n" + unknownSource(db, scope, ctx, nm.arg), true);
44659
+ }
44660
+ var STORED_SOURCES = `
44661
+ SELECT MAX(id) AS id, label FROM sources
44662
+ WHERE (:scope <> 'session' OR session_id = :session_id)
44663
+ AND (:scope <> 'worktree' OR worktree = :worktree)
44664
+ GROUP BY label ORDER BY MAX(id) DESC LIMIT :limit`;
44665
+ var STORED_SOURCES_SHOWN = 5;
44666
+ function unknownSource(db, scope, ctx, given) {
44667
+ const line = "Source " + JSON.stringify(given) + ' is not a stored source in scope "' + scope + '".';
44668
+ const rows = db.raw.prepare(STORED_SOURCES).all({
44669
+ scope,
44670
+ session_id: ctx.sessionId,
44671
+ worktree: ctx.project.worktree,
44672
+ limit: STORED_SOURCES_SHOWN + 1
44673
+ });
44674
+ if (rows.length === 0) return line + '\nctx_index stores one: ctx_index({content:"...", source:' + JSON.stringify(given) + "}).";
44675
+ const names = rows.slice(0, STORED_SOURCES_SHOWN).map((r) => isLongLabel(r.label) ? sourceHandle(Number(r.id)) : JSON.stringify(r.label));
44676
+ const more = rows.length > STORED_SOURCES_SHOWN ? ", ..." : "";
44677
+ return line + "\nStored sources, newest first: " + names.join(", ") + more + ". " + callText([], scope, void 0, 'sort:"timeline"') + " lists them all.";
44583
44678
  }
44584
44679
  function named(given, pick4) {
44585
- if (given === void 0 || pick4 === null) return { arg: given, note: null };
44680
+ if (given === void 0 || pick4 === null) return { arg: given, note: null, pick: null };
44586
44681
  const arg = pick4.id !== null && isLongLabel(given) ? sourceHandle(pick4.id) : given;
44587
- return { arg, note: collisionLine(given, pick4) };
44682
+ return { arg, note: collisionLine(given, pick4), pick: pick4 };
44588
44683
  }
44589
44684
  function sourceCard(db, id, input, scope, arg) {
44590
44685
  const row5 = sourceCardRow(db, id);
@@ -44716,7 +44811,7 @@ function relevance(db, given, scope, ctx, nm, ms, indexed) {
44716
44811
  });
44717
44812
  const take = fetched.map((h) => replyHits(h, size));
44718
44813
  const pages = fetched.map((h, i) => h.slice(0, take[i]));
44719
- if (pages.every((p) => p.length === 0)) return zeroHits(db, scope, ctx, input.source, ms, offset);
44814
+ if (pages.every((p) => p.length === 0)) return zeroHits(db, scope, ctx, input.source, ms, nm, input.queries, offset);
44720
44815
  const moreLine3 = (q, pos) => "More: " + callText([q], scope, nm.arg, "offset:" + pos);
44721
44816
  let reserve = 0;
44722
44817
  for (const q of input.queries) reserve += bytes2(moreLine3(q, offset + size)) + 1;
@@ -44786,7 +44881,7 @@ function timelineLine(r) {
44786
44881
  }
44787
44882
  function timeline(db, input, scope, ctx, nm, ms) {
44788
44883
  const page2 = ftsQueryTimeline(db, scope, ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, input.after ?? null, input.source, ms.rows);
44789
- if (page2.rows.length === 0) return zeroHits(db, scope, ctx, input.source, ms);
44884
+ if (page2.rows.length === 0) return zeroHits(db, scope, ctx, input.source, ms, nm, input.queries);
44790
44885
  const moreLine3 = (ts) => "more: " + callText(input.queries, scope, nm.arg, 'sort:"timeline", after:' + ts);
44791
44886
  const reserve = bytes2(moreLine3(page2.rows[page2.rows.length - 1].ts)) + 1;
44792
44887
  const lines = nm.note === null ? [] : [nm.note];
@@ -45089,8 +45184,8 @@ var ctxBatch = Object.freeze({
45089
45184
  });
45090
45185
 
45091
45186
  // src/core/tools/doctor.ts
45092
- import { readdirSync as readdirSync8, readFileSync as readFileSync13, existsSync as existsSync17 } from "node:fs";
45093
- import { basename as basename5, join as join17 } from "node:path";
45187
+ import { readdirSync as readdirSync8, readFileSync as readFileSync14, existsSync as existsSync18 } from "node:fs";
45188
+ import { basename as basename5, join as join18 } from "node:path";
45094
45189
 
45095
45190
  // src/adapters/claude-code.ts
45096
45191
  var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
@@ -45812,6 +45907,9 @@ function readResult6(p) {
45812
45907
  if (p.keep === true) info.keep = true;
45813
45908
  return info;
45814
45909
  }
45910
+ function decodeOmp(raw) {
45911
+ return { ...decode11(raw), agent: "omp" };
45912
+ }
45815
45913
  function decode11(raw) {
45816
45914
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
45817
45915
  const p = raw;
@@ -46113,10 +46211,32 @@ var ADAPTERS = Object.freeze([
46113
46211
  decode: decode12,
46114
46212
  encode: encode12,
46115
46213
  toCanonicalTool
46214
+ },
46215
+ {
46216
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
46217
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
46218
+ id: "omp",
46219
+ installMode: "in-process",
46220
+ projectSource: "pi:ctx.cwd",
46221
+ toolNamePrefix: TOOL_NAME_PREFIX9,
46222
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
46223
+ execReadOnlyHint: false,
46224
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
46225
+ compactDelivery: "pi-flag",
46226
+ compactSummary: "none",
46227
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
46228
+ denyChannel: "deny-reason",
46229
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
46230
+ skillChannel: { kind: "package", path: "skills" },
46231
+ // D-OMP-SKILLS-1
46232
+ decode: decodeOmp,
46233
+ encode: encode11,
46234
+ checkPermission
46235
+ // D-OMP-FIRE-1: agent omp in rows
46116
46236
  }
46117
46237
  ]);
46118
46238
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
46119
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
46239
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
46120
46240
  function hasReplace(row5) {
46121
46241
  return REPLACE_ROWS.has(row5.id);
46122
46242
  }
@@ -46147,8 +46267,8 @@ function ownBundleDir() {
46147
46267
  }
46148
46268
 
46149
46269
  // src/core/ops/doctor-config.ts
46150
- import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "node:fs";
46151
- import { dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
46270
+ import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync11 } from "node:fs";
46271
+ import { dirname as dirname7, isAbsolute as isAbsolute4, join as join13, resolve as resolve4 } from "node:path";
46152
46272
 
46153
46273
  // src/core/ops/host-text.ts
46154
46274
  var BOM_CODE = 65279;
@@ -48226,16 +48346,16 @@ function parseTOML(code, options) {
48226
48346
  }
48227
48347
 
48228
48348
  // src/core/ops/atomic-file.ts
48229
- import { mkdirSync as mkdirSync4, renameSync, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
48349
+ import { mkdirSync as mkdirSync4, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
48230
48350
  import path3 from "node:path";
48231
48351
  function sleepSync(ms) {
48232
48352
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
48233
48353
  }
48234
- function errCode2(e) {
48354
+ function errCode3(e) {
48235
48355
  return e.code;
48236
48356
  }
48237
48357
  function renameWithRetry(from, to, opts = {}) {
48238
- const rename = opts.rename ?? renameSync;
48358
+ const rename = opts.rename ?? renameSync2;
48239
48359
  const sleep2 = opts.sleep ?? sleepSync;
48240
48360
  const win = (opts.platform ?? process.platform) === "win32";
48241
48361
  for (let attempt = 0; ; attempt += 1) {
@@ -48243,7 +48363,7 @@ function renameWithRetry(from, to, opts = {}) {
48243
48363
  rename(from, to);
48244
48364
  return;
48245
48365
  } catch (e) {
48246
- const busy = win && ATOMIC_RENAME_BUSY_CODES.includes(errCode2(e) ?? "");
48366
+ const busy = win && ATOMIC_RENAME_BUSY_CODES.includes(errCode3(e) ?? "");
48247
48367
  if (!busy || attempt >= ATOMIC_RENAME_RETRIES) throw e;
48248
48368
  sleep2(ATOMIC_RENAME_DELAY_MS);
48249
48369
  }
@@ -48258,15 +48378,15 @@ function unlinkWithRetry(file2, opts = {}) {
48258
48378
  unlink(file2);
48259
48379
  return;
48260
48380
  } catch (e) {
48261
- if (errCode2(e) === "ENOENT") return;
48262
- const busy = win && ATOMIC_RENAME_BUSY_CODES.includes(errCode2(e) ?? "");
48381
+ if (errCode3(e) === "ENOENT") return;
48382
+ const busy = win && ATOMIC_RENAME_BUSY_CODES.includes(errCode3(e) ?? "");
48263
48383
  if (!busy || attempt >= ATOMIC_RENAME_RETRIES) throw replaceFailure(file2, e);
48264
48384
  sleep2(ATOMIC_RENAME_DELAY_MS);
48265
48385
  }
48266
48386
  }
48267
48387
  }
48268
48388
  function replaceFailure(file2, e) {
48269
- const busy = ATOMIC_RENAME_BUSY_CODES.includes(errCode2(e) ?? "");
48389
+ const busy = ATOMIC_RENAME_BUSY_CODES.includes(errCode3(e) ?? "");
48270
48390
  const cause = e.message;
48271
48391
  return new Error(busy ? `Could not replace ${file2}: ${cause}. Fix: close the program using ${file2}, then re-run` : `Could not write ${file2}: ${cause}. Fix: check the path and its permissions, then re-run`, { cause: e });
48272
48392
  }
@@ -49160,6 +49280,14 @@ function configEntryRoot(adapter, env) {
49160
49280
  if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
49161
49281
  return dirname6(script);
49162
49282
  }
49283
+ function packageDirOf(dir) {
49284
+ for (let cur = dir; ; ) {
49285
+ if (existsSync8(join10(cur, D1_PACKAGE_FILE))) return cur;
49286
+ const up = dirname6(cur);
49287
+ if (up === cur) return dir;
49288
+ cur = up;
49289
+ }
49290
+ }
49163
49291
  function candidate(adapter, env, worktree) {
49164
49292
  switch (adapter.installMode) {
49165
49293
  case "marketplace":
@@ -49173,7 +49301,7 @@ function candidate(adapter, env, worktree) {
49173
49301
  case "plugin":
49174
49302
  return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
49175
49303
  case "in-process":
49176
- return dirname6(fileURLToPath2(import.meta.url));
49304
+ return packageDirOf(dirname6(fileURLToPath2(import.meta.url)));
49177
49305
  }
49178
49306
  }
49179
49307
  function resolvePluginRoot(adapter, env, worktree) {
@@ -49254,14 +49382,281 @@ function piInstalledIn(env, home, pkgDir, cwd) {
49254
49382
  return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
49255
49383
  }
49256
49384
 
49385
+ // src/core/ops/doctor-env.ts
49386
+ import { existsSync as existsSync10, readFileSync as readFileSync9, realpathSync as realpathSync6 } from "node:fs";
49387
+ import { isAbsolute as isAbsolute3, join as join11, relative as relative2 } from "node:path";
49388
+ function pass(id, detail = DOCTOR_PASS_DETAIL) {
49389
+ return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
49390
+ }
49391
+ function unknown4(id, detail, fixCommand) {
49392
+ return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
49393
+ }
49394
+ function fail(id, detail, fixCommand) {
49395
+ return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
49396
+ }
49397
+ function warn(id, detail, fixCommand) {
49398
+ return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
49399
+ }
49400
+ function bundleVersion(bundleDir2) {
49401
+ try {
49402
+ const v = JSON.parse(readFileSync9(join11(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
49403
+ return typeof v === "string" && v !== "" ? v : void 0;
49404
+ } catch {
49405
+ return void 0;
49406
+ }
49407
+ }
49408
+ function channelOf(version4) {
49409
+ const at = version4.indexOf(D1_PRERELEASE_SEP);
49410
+ if (at < 0) return D1_DEFAULT_TAG;
49411
+ const pre = version4.slice(at + 1);
49412
+ const dot = pre.indexOf(".");
49413
+ const tag = dot < 0 ? pre : pre.slice(0, dot);
49414
+ return tag === "" ? D1_DEFAULT_TAG : tag;
49415
+ }
49416
+ function firstLine2(b) {
49417
+ const text = b.toString("utf8").trim();
49418
+ const nl = text.indexOf("\n");
49419
+ return (nl < 0 ? text : text.slice(0, nl)).trim();
49420
+ }
49421
+ function gitCause(r, timeoutMs) {
49422
+ if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
49423
+ if (r.killed === "cancel") return D1_GIT_CANCEL;
49424
+ if (r.exitCode === null) return D1_GIT_NO_START;
49425
+ return D1_GIT_EXIT(r.exitCode, firstLine2(r.stderr));
49426
+ }
49427
+ function fetchCause(err, timeoutMs) {
49428
+ const name = err instanceof Error ? err.name : "";
49429
+ if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
49430
+ const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
49431
+ const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
49432
+ const msg = cause instanceof Error ? cause.message : String(cause);
49433
+ const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
49434
+ return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
49435
+ }
49436
+ async function npmLatest(url4, tag, signal, timeoutMs) {
49437
+ try {
49438
+ const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
49439
+ if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
49440
+ const body = await res.json();
49441
+ const v = typeof body === "object" && body !== null ? body[tag] : void 0;
49442
+ return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag) };
49443
+ } catch (err) {
49444
+ return { ok: false, cause: fetchCause(err, timeoutMs) };
49445
+ }
49446
+ }
49447
+ function digits(s) {
49448
+ if (s === "") return false;
49449
+ for (const ch of s) if (ch < "0" || ch > "9") return false;
49450
+ return true;
49451
+ }
49452
+ function parseVersion(v) {
49453
+ const at = v.indexOf(D1_PRERELEASE_SEP);
49454
+ const core = (at < 0 ? v : v.slice(0, at)).split(NODE_VERSION_SEP);
49455
+ if (core.length !== 3 || !core.every(digits)) return null;
49456
+ const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
49457
+ if (at < 0) return { core: nums, pre: [] };
49458
+ const pre = v.slice(at + 1).split(NODE_VERSION_SEP);
49459
+ if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
49460
+ if (pre.length === 1) return { core: nums, pre: [pre[0]] };
49461
+ return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
49462
+ }
49463
+ function sign(n) {
49464
+ return n < 0 ? -1 : n > 0 ? 1 : 0;
49465
+ }
49466
+ function compareVersions(a, b) {
49467
+ const x = parseVersion(a);
49468
+ const y = parseVersion(b);
49469
+ if (x === null || y === null) return null;
49470
+ for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
49471
+ if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
49472
+ if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
49473
+ return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
49474
+ }
49475
+ function highestTag(stdout, tag) {
49476
+ let best;
49477
+ for (const line of stdout.split("\n")) {
49478
+ const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
49479
+ if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
49480
+ const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
49481
+ if (parseVersion(v) === null || channelOf(v) !== tag) continue;
49482
+ if (best === void 0 || compareVersions(v, best) === 1) best = v;
49483
+ }
49484
+ return best;
49485
+ }
49486
+ function versionRow(head, installed, tag, source, latest, tail, update) {
49487
+ const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
49488
+ if (cmp === 0) return pass("D1", head + D1_LATEST_PASS(tag, source) + tail);
49489
+ if (cmp > 0) return pass("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
49490
+ return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
49491
+ }
49492
+ async function checkVersion(i) {
49493
+ if (i.bundleSha === void 0) return unknown4("D1", D1_DEV_BUILD_DETAIL);
49494
+ const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
49495
+ if (i.version === void 0) return unknown4("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
49496
+ const tag = channelOf(i.version);
49497
+ const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
49498
+ const git2 = findRuntime(GIT_BIN, i.env);
49499
+ const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
49500
+ if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
49501
+ let cause = D1_GIT_MISSING;
49502
+ if (git2 !== null) {
49503
+ const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
49504
+ cwd: i.cwd,
49505
+ env: { ...i.env, ...GIT_NO_PROMPT_ENV },
49506
+ signal: i.signal,
49507
+ timeoutMs: i.timeoutMs
49508
+ });
49509
+ if (r.exitCode === 0 && r.killed === null) {
49510
+ const latest = highestTag(r.stdout.toString("utf8"), tag);
49511
+ if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
49512
+ cause = D1_GIT_NO_TAG(tag);
49513
+ } else {
49514
+ cause = gitCause(r, i.timeoutMs);
49515
+ }
49516
+ }
49517
+ return unknown4("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
49518
+ }
49519
+ function numbers(v) {
49520
+ const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
49521
+ return bare2.split(NODE_VERSION_SEP).map(Number);
49522
+ }
49523
+ function belowMin(version4) {
49524
+ const got = numbers(version4);
49525
+ const min = numbers(NODE_MIN);
49526
+ for (let k = 0; k < min.length; k++) {
49527
+ const g = got[k] ?? 0;
49528
+ if (g !== min[k]) return g < min[k];
49529
+ }
49530
+ return false;
49531
+ }
49532
+ async function sqliteLoads() {
49533
+ try {
49534
+ await import(SQLITE_MODULE);
49535
+ return true;
49536
+ } catch {
49537
+ return false;
49538
+ }
49539
+ }
49540
+ async function checkNode(i) {
49541
+ const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
49542
+ const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
49543
+ if (belowMin(i.nodeVersion)) return fail("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
49544
+ if (!await sqliteLoads()) return fail("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
49545
+ return pass("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
49546
+ }
49547
+ function checkMcp(ctx, adapter) {
49548
+ const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
49549
+ const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
49550
+ if (named2 || versioned) return pass("D6");
49551
+ return adapter?.installMode === "in-process" ? pass("D6", D6_IN_PROCESS_DETAIL) : unknown4("D6", D6_UNKNOWN_DETAIL);
49552
+ }
49553
+ function piCwdInside(worktree, piCwd) {
49554
+ if (piCwd === void 0 || !existsSync10(piCwd)) return false;
49555
+ const rel = relative2(worktree, realpathSync6.native(piCwd));
49556
+ return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
49557
+ }
49558
+ function checkProject(i) {
49559
+ const bad = fail("D7", D7_DETAIL(i.project.source), D7_FIX);
49560
+ if (i.project.source !== i.adapter.projectSource) return bad;
49561
+ if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
49562
+ return pass("D7");
49563
+ }
49564
+ function checkMode(adapter, hostPermission) {
49565
+ if (hostPermission === "missing") return fail("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
49566
+ if (hostPermission === "wired") return pass("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
49567
+ return pass("D10", D10_DETAIL(adapter.denyChannel));
49568
+ }
49569
+ function checkShell(env) {
49570
+ const win = process.platform === "win32";
49571
+ const shell = findRuntime("shell", env);
49572
+ if (shell !== null) return pass("D11", D11_PASS_DETAIL(shell, win));
49573
+ return win ? fail("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
49574
+ }
49575
+ function checkRuntimes(env, shellRow) {
49576
+ if (shellRow.status !== "PASS") return shellRow;
49577
+ for (const lang of EXEC_LANGUAGES) {
49578
+ if (lang === "shell") continue;
49579
+ const r = lookupRuntime(lang, env);
49580
+ if (r.found === null && r.unreadable.length > 0) return warn("D11", D11_RUNTIME_DETAIL(lang, r.unreadable), D11_RUNTIME_FIX(lang));
49581
+ }
49582
+ return shellRow;
49583
+ }
49584
+
49585
+ // src/core/ops/omp-import.ts
49586
+ import { join as join12 } from "node:path";
49587
+ var { existsSync: existsSync11, readFileSync: readFileSync10 } = process.getBuiltinModule("node:fs");
49588
+ var OMP_DISABLED_SERVERS_KEY = "disabledServers";
49589
+ var OMP_MCP_FILE = "mcp.json";
49590
+ var OMP_CONFIG_FILE = "config.yml";
49591
+ var ENABLED_PROVIDERS = "enabledProviders";
49592
+ var DISABLED_PROVIDERS = "disabledProviders";
49593
+ var CLAUDE_PROVIDER = "claude";
49594
+ var ALL_PROVIDERS = ["*", "all"];
49595
+ function ompImportFiles(home) {
49596
+ const agentDir = join12(home, ...AGENT_HOME_DIR.omp, PI_AGENT_DIR);
49597
+ return { config: join12(agentDir, OMP_CONFIG_FILE), mcp: join12(agentDir, OMP_MCP_FILE), claude: join12(home, CLAUDE_USER_CONFIG_FILE) };
49598
+ }
49599
+ function readText2(file2) {
49600
+ try {
49601
+ return existsSync11(file2) ? hostText(readFileSync10(file2, "utf8")) : void 0;
49602
+ } catch {
49603
+ return void 0;
49604
+ }
49605
+ }
49606
+ var unquote = (s) => {
49607
+ const t = s.trim();
49608
+ const q = t[0];
49609
+ return (q === '"' || q === "'") && t.endsWith(q) && t.length > 1 ? t.slice(1, -1) : t;
49610
+ };
49611
+ var withoutComment = (s) => {
49612
+ const at = s.indexOf(" #");
49613
+ return at === -1 ? s : s.slice(0, at);
49614
+ };
49615
+ function yamlTopList(text, key) {
49616
+ const lines = text.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
49617
+ const head = `${key}:`;
49618
+ const at = lines.findIndex((l) => l.startsWith(head));
49619
+ if (at === -1) return [];
49620
+ const rest = withoutComment(lines[at].slice(head.length)).trim();
49621
+ if (rest.startsWith("[")) {
49622
+ const end = rest.indexOf("]");
49623
+ return (end === -1 ? rest.slice(1) : rest.slice(1, end)).split(",").map(unquote).filter((x) => x !== "");
49624
+ }
49625
+ if (rest !== "") return [];
49626
+ const out = [];
49627
+ for (const line of lines.slice(at + 1)) {
49628
+ const t = line.trim();
49629
+ if (t === "" || t.startsWith("#")) continue;
49630
+ if (line === line.trimStart() && !t.startsWith("-")) break;
49631
+ if (!t.startsWith("-")) break;
49632
+ out.push(unquote(withoutComment(t.slice(1))));
49633
+ }
49634
+ return out;
49635
+ }
49636
+ function ompImportsUs(files, env) {
49637
+ const config4 = readText2(files.config) ?? "";
49638
+ if (yamlTopList(config4, DISABLED_PROVIDERS).includes(CLAUDE_PROVIDER)) return false;
49639
+ const enabled = yamlTopList(config4, ENABLED_PROVIDERS);
49640
+ const dirSet = env[CLAUDE_CONFIG_DIR_ENV] !== void 0 && env[CLAUDE_CONFIG_DIR_ENV] !== "";
49641
+ if (!dirSet && !enabled.some((p) => p === CLAUDE_PROVIDER || ALL_PROVIDERS.includes(p))) return false;
49642
+ const claude = readText2(files.claude);
49643
+ if (claude === void 0) return false;
49644
+ try {
49645
+ const servers = JSON.parse(claude)[MCP_SERVERS_KEY];
49646
+ return typeof servers === "object" && servers !== null && Object.hasOwn(servers, SERVER_KEY);
49647
+ } catch {
49648
+ return false;
49649
+ }
49650
+ }
49651
+
49257
49652
  // src/core/ops/doctor-config.ts
49258
49653
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
49259
49654
  var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
49260
49655
  var list = (v) => Array.isArray(v) ? v : [];
49261
- function pass(id) {
49656
+ function pass2(id) {
49262
49657
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail: DOCTOR_PASS_DETAIL };
49263
49658
  }
49264
- function fail(id, detail, fixCommand) {
49659
+ function fail2(id, detail, fixCommand) {
49265
49660
  return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
49266
49661
  }
49267
49662
  function readParsed(agent, file2) {
@@ -49331,11 +49726,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
49331
49726
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
49332
49727
  function mcpFile(row5, home, env) {
49333
49728
  const spec = OWN_MCP_ENTRY[row5.id];
49334
- if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
49729
+ if (row5.id === "codex") return join13(codexDirOf(env, home), CONFIG_TOML_FILE);
49335
49730
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
49336
- if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
49731
+ if (row5.id === "opencode") return join13(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
49337
49732
  if (row5.id === "pi") {
49338
- return join11(piAgentDirOf(env, home), SETTINGS_FILE);
49733
+ return join13(piAgentDirOf(env, home), SETTINGS_FILE);
49339
49734
  }
49340
49735
  return null;
49341
49736
  }
@@ -49348,27 +49743,27 @@ function codexNativeDir(env, home) {
49348
49743
  const codexDir = codexDirOf(env, home);
49349
49744
  let enabled;
49350
49745
  try {
49351
- enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
49746
+ enabled = hostConfigValueAt(readParsed("codex", join13(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
49352
49747
  } catch {
49353
49748
  return null;
49354
49749
  }
49355
49750
  if (enabled !== true) return null;
49356
- const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
49357
- if (!existsSync10(cache)) return null;
49751
+ const cache = join13(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
49752
+ if (!existsSync12(cache)) return null;
49358
49753
  const found = [];
49359
49754
  for (const market of readdirSync7(cache)) {
49360
- const plugin = join11(cache, market, SERVER_KEY);
49361
- if (!existsSync10(plugin)) continue;
49755
+ const plugin = join13(cache, market, SERVER_KEY);
49756
+ if (!existsSync12(plugin)) continue;
49362
49757
  for (const version4 of readdirSync7(plugin).sort()) {
49363
- const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
49364
- if (existsSync10(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
49758
+ const dir = join13(plugin, version4, CODEX_PLUGIN_SUBDIR);
49759
+ if (existsSync12(join13(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
49365
49760
  }
49366
49761
  }
49367
49762
  return found.length === 0 ? null : found[found.length - 1];
49368
49763
  }
49369
49764
  function nativeMcpWrong(dir, row5) {
49370
49765
  try {
49371
- const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
49766
+ const entry = hostConfigValueAt(readParsed(row5.id, join13(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
49372
49767
  if (!isObject4(entry)) return true;
49373
49768
  const args = list(entry[MCP_ARGS_FIELD]);
49374
49769
  const script = args[0];
@@ -49439,17 +49834,17 @@ function opencodePluginDirs(configDir, worktree) {
49439
49834
  return [configDir, opencodeProjectDir(worktree)];
49440
49835
  }
49441
49836
  function opencodeProjectDir(worktree) {
49442
- return join11(worktree, OPENCODE_PROJECT_DIR);
49837
+ return join13(worktree, OPENCODE_PROJECT_DIR);
49443
49838
  }
49444
49839
  function packageResolves(fromDir) {
49445
49840
  for (let d = fromDir; ; d = dirname7(d)) {
49446
- if (existsSync10(join11(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
49841
+ if (existsSync12(join13(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
49447
49842
  if (dirname7(d) === d) return false;
49448
49843
  }
49449
49844
  }
49450
49845
  function opencodeDirPlugins(dirs) {
49451
49846
  const bundle = opencodePluginFile();
49452
- const ownFile = join11(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
49847
+ const ownFile = join13(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
49453
49848
  const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
49454
49849
  const isPath = (p) => {
49455
49850
  if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
@@ -49459,7 +49854,7 @@ function opencodeDirPlugins(dirs) {
49459
49854
  };
49460
49855
  const out = [];
49461
49856
  for (const dir of dirs) {
49462
- const pdir = join11(dir, OPENCODE_PLUGINS_DIR);
49857
+ const pdir = join13(dir, OPENCODE_PLUGINS_DIR);
49463
49858
  let names;
49464
49859
  try {
49465
49860
  names = readdirSync7(pdir);
@@ -49467,12 +49862,12 @@ function opencodeDirPlugins(dirs) {
49467
49862
  continue;
49468
49863
  }
49469
49864
  for (const name of names) {
49470
- const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join11(pdir, name)] : [];
49471
- const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join11(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
49865
+ const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join13(pdir, name)] : [];
49866
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join13(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
49472
49867
  for (const f of files) {
49473
49868
  let text;
49474
49869
  try {
49475
- const b = readFileSync9(f);
49870
+ const b = readFileSync11(f);
49476
49871
  if (b.length > OPENCODE_DIR_FILE_MAX) continue;
49477
49872
  text = b.toString("utf8");
49478
49873
  } catch {
@@ -49483,7 +49878,7 @@ function opencodeDirPlugins(dirs) {
49483
49878
  const loads = lits.some((p) => {
49484
49879
  if (isModule(p)) return packageResolves(dirname7(f));
49485
49880
  const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
49486
- return existsSync10(isAbsolute3(bare2) ? bare2 : resolve4(dirname7(f), bare2));
49881
+ return existsSync12(isAbsolute4(bare2) ? bare2 : resolve4(dirname7(f), bare2));
49487
49882
  });
49488
49883
  out.push({ file: f, loads });
49489
49884
  }
@@ -49501,19 +49896,19 @@ function opencodeMcpOwn(entry) {
49501
49896
  return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
49502
49897
  }
49503
49898
  function opencodeFileValue(file2) {
49504
- if (!existsSync10(file2)) return {};
49505
- return parseHostConfig("opencode", file2, hostText(readFileSync9(file2, "utf8")), "jsonc");
49899
+ if (!existsSync12(file2)) return {};
49900
+ return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
49506
49901
  }
49507
49902
  function opencodeValueListed(value) {
49508
49903
  const bundle = opencodePluginFile();
49509
- const own4 = [bundle, join11(bundle, ...OPENCODE_PLUGIN_PATH)];
49904
+ const own4 = [bundle, join13(bundle, ...OPENCODE_PLUGIN_PATH)];
49510
49905
  if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
49511
49906
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
49512
49907
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
49513
49908
  }
49514
49909
  function opencodeListed(file2, worktree) {
49515
49910
  const dirs = [dirname7(file2), worktree];
49516
- if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join11(dir, name)))))) return true;
49911
+ if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join13(dir, name)))))) return true;
49517
49912
  return opencodeDirPlugin(opencodePluginDirs(dirname7(file2), worktree)) !== void 0;
49518
49913
  }
49519
49914
  function mcpWrong(row5, home, env, worktree) {
@@ -49535,7 +49930,7 @@ function mcpWrong(row5, home, env, worktree) {
49535
49930
  function hookFile(row5, spec, home, env, worktree) {
49536
49931
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
49537
49932
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
49538
- const file2 = native !== null ? join11(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join11(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join11(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join11(kiroDirOf(env, home), ...spec.file.slice(1)) : join11(root, ...spec.file);
49933
+ const file2 = native !== null ? join13(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join13(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join13(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join13(kiroDirOf(env, home), ...spec.file.slice(1)) : join13(root, ...spec.file);
49539
49934
  return file2;
49540
49935
  }
49541
49936
  function hookParts(row5, home, env, worktree) {
@@ -49546,7 +49941,7 @@ function hookParts(row5, home, env, worktree) {
49546
49941
  const file2 = hookFile(row5, spec, home, env, worktree);
49547
49942
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
49548
49943
  if (row5.id === "codex") {
49549
- const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
49944
+ const config4 = readParsed(row5.id, join13(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
49550
49945
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
49551
49946
  }
49552
49947
  } catch {
@@ -49575,29 +49970,67 @@ function hookParts(row5, home, env, worktree) {
49575
49970
  }
49576
49971
  function checkHostConfig(row5, env, worktree) {
49577
49972
  const home = homeDirOf(env);
49578
- if (home === null) return fail("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
49973
+ if (home === null) return fail2("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
49579
49974
  if (row5.installMode === "marketplace") {
49580
49975
  const choice = marketplaceChoice(env, worktree);
49581
- if ("installs" in choice) return fail("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
49976
+ if ("installs" in choice) return fail2("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
49582
49977
  }
49583
49978
  if (row5.id === "pi") return checkPiInstall(env, home, worktree);
49979
+ if (row5.id === "omp") return checkOmpInstall(home);
49584
49980
  const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
49585
- if (parts.length === 0) return pass("D3");
49981
+ if (parts.length === 0) return pass2("D3");
49586
49982
  const detail = D3_DETAIL(parts);
49587
49983
  const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
49588
- return fail("D3", detail, fix);
49984
+ return fail2("D3", detail, fix);
49589
49985
  }
49590
49986
  function checkPiInstall(env, home, worktree) {
49591
49987
  const found = piInstalledIn(env, home, ownBundleDir(), worktree);
49592
- if (found !== void 0) return { ...pass("D3"), detail: found };
49593
- return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join11(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
49988
+ if (found !== void 0) return { ...pass2("D3"), detail: found };
49989
+ return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join13(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
49990
+ }
49991
+ var OMP_PLUGINS_DIR = "plugins";
49992
+ var OMP_LOCK_FILE = "omp-plugins.lock.json";
49993
+ function readJson2(file2) {
49994
+ try {
49995
+ const doc = JSON.parse(readFileSync11(file2, "utf8"));
49996
+ return typeof doc === "object" && doc !== null ? doc : void 0;
49997
+ } catch {
49998
+ return void 0;
49999
+ }
50000
+ }
50001
+ function ownEntry(doc, key) {
50002
+ const map2 = doc?.[key];
50003
+ return typeof map2 === "object" && map2 !== null ? map2[SERVER_KEY] : void 0;
50004
+ }
50005
+ function checkOmpInstall(home) {
50006
+ const dir = join13(home, ...AGENT_HOME_DIR.omp, OMP_PLUGINS_DIR);
50007
+ const lock = join13(dir, OMP_LOCK_FILE);
50008
+ const pkg = join13(dir, PI_PACKAGE_JSON_FILE);
50009
+ const entry = ownEntry(readJson2(lock), "plugins");
50010
+ const missing2 = (file2) => fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + file2, NATIVE_INSTALL.omp[0]);
50011
+ if (typeof entry !== "object" || entry === null) return missing2(lock);
50012
+ if (ownEntry(readJson2(pkg), "dependencies") === void 0) return missing2(pkg);
50013
+ if (entry.enabled !== true) return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + lock, OMP_ENABLE_COMMAND);
50014
+ return { ...pass2("D3"), detail: lock };
50015
+ }
50016
+ function ompInfoLines(env, version4) {
50017
+ const out = [];
50018
+ if (version4 !== void 0 && compareVersions(version4, OMP_MIN_VERSION) === -1) out.push(OMP_FLOOR_INFO(version4));
50019
+ out.push(OMP_CONTENT_INFO, OMP_PRINT_MODE_INFO, OMP_SCRIPTS_INFO);
50020
+ const home = homeDirOf(env);
50021
+ if (home === null) return out;
50022
+ const files = ompImportFiles(home);
50023
+ if (!ompImportsUs(files, env)) return out;
50024
+ const listed = readJson2(files.mcp)?.[OMP_DISABLED_SERVERS_KEY];
50025
+ if (!(Array.isArray(listed) && listed.includes(SERVER_KEY))) out.push(OMP_IMPORT_INFO(files.claude, files.mcp));
50026
+ return out;
49594
50027
  }
49595
50028
  function checkV1Leftovers(agent, home, scope = {}) {
49596
50029
  const findings = detectV1(agent, home, scope);
49597
- if (findings.length === 0) return pass("D4");
50030
+ if (findings.length === 0) return pass2("D4");
49598
50031
  const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
49599
- if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
49600
- return { ...fail("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
50032
+ if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass2("D4"), detail };
50033
+ return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
49601
50034
  }
49602
50035
  function parsedOrNull(agent, file2, jsonc) {
49603
50036
  try {
@@ -49608,13 +50041,13 @@ function parsedOrNull(agent, file2, jsonc) {
49608
50041
  }
49609
50042
  }
49610
50043
  function checkDoubleFire(agent, worktree) {
49611
- if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
49612
- const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
50044
+ if (agent !== "claude-code" && agent !== "vscode") return pass2("D5b");
50045
+ const claude = parsedOrNull(agent, join13(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
49613
50046
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
49614
50047
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
49615
- const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
50048
+ const vscode = parsedOrNull(agent, join13(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
49616
50049
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
49617
- return hooksOn && useClaudeHooks ? fail("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
50050
+ return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass2("D5b");
49618
50051
  }
49619
50052
  function configPaths(row5, env, worktree) {
49620
50053
  const home = homeDirOf(env);
@@ -49623,7 +50056,7 @@ function configPaths(row5, env, worktree) {
49623
50056
  const mcp = mcpFile(row5, home, env);
49624
50057
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
49625
50058
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
49626
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
50059
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join13(native, CODEX_PLUGIN_MCP_FILE) });
49627
50060
  const spec = HOOK_HOST_FILE[row5.id];
49628
50061
  if (spec !== null) {
49629
50062
  try {
@@ -49643,10 +50076,10 @@ function configPaths(row5, env, worktree) {
49643
50076
  }
49644
50077
 
49645
50078
  // src/core/ops/doctor-db.ts
49646
- import { existsSync as existsSync11, statSync as statSync4 } from "node:fs";
49647
- var unknown4 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
49648
- var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
49649
- var fail2 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
50079
+ import { existsSync as existsSync13, statSync as statSync5 } from "node:fs";
50080
+ var unknown5 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
50081
+ var pass3 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
50082
+ var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
49650
50083
  function isCorrupt2(err) {
49651
50084
  if (typeof err !== "object" || err === null) return false;
49652
50085
  const code = err.errcode;
@@ -49685,17 +50118,17 @@ function orphanFiles(dbPath) {
49685
50118
  const files = [];
49686
50119
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
49687
50120
  const path8 = dbPath + suffix;
49688
- if (existsSync11(path8)) files.push({ path: path8, bytes: statSync4(path8).size });
50121
+ if (existsSync13(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
49689
50122
  }
49690
- return files.length > 0 && !existsSync11(dbPath) ? files : [];
50123
+ return files.length > 0 && !existsSync13(dbPath) ? files : [];
49691
50124
  }
49692
50125
  async function checkDb(project) {
49693
50126
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
49694
50127
  const orphan = orphanFiles(project.dbPath);
49695
- if (orphan.length > 0) return { row: fail2(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
49696
- if (!existsSync11(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
50128
+ if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
50129
+ if (!existsSync13(project.dbPath)) return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
49697
50130
  const sqlite = await loadSqlite2();
49698
- if (sqlite === null) return { row: unknown4("D8", D2_SQLITE_DETAIL), ...clean };
50131
+ if (sqlite === null) return { row: unknown5("D8", D2_SQLITE_DETAIL), ...clean };
49699
50132
  let raw = null;
49700
50133
  try {
49701
50134
  raw = openRead(sqlite, project.dbPath);
@@ -49708,226 +50141,35 @@ async function checkDb(project) {
49708
50141
  }
49709
50142
  const schemaStale = got !== null && got !== SCHEMA_VERSION;
49710
50143
  const integrityFailed = failsOnCorrupt(() => !integrityOk(db));
49711
- if (integrityFailed) return { row: fail2(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
49712
- if (schemaStale && got !== null) return { row: fail2(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
49713
- return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
50144
+ if (integrityFailed) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
50145
+ if (schemaStale && got !== null) return { row: fail3(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
50146
+ return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
49714
50147
  } catch (err) {
49715
- if (isCorrupt2(err)) return { row: fail2(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
49716
- return { row: unknown4("D8", message(err)), ...clean };
50148
+ if (isCorrupt2(err)) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
50149
+ return { row: unknown5("D8", message(err)), ...clean };
49717
50150
  } finally {
49718
50151
  raw?.close();
49719
50152
  }
49720
50153
  }
49721
50154
  async function checkIndex(project) {
49722
- if (!existsSync11(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
50155
+ if (!existsSync13(project.dbPath)) return pass3("D9", D9_INDEX_DETAIL(0, 0));
49723
50156
  const sqlite = await loadSqlite2();
49724
- if (sqlite === null) return unknown4("D9", D2_SQLITE_DETAIL);
50157
+ if (sqlite === null) return unknown5("D9", D2_SQLITE_DETAIL);
49725
50158
  let raw = null;
49726
50159
  try {
49727
50160
  raw = openRead(sqlite, project.dbPath);
49728
50161
  const sources = Number(cell(raw.prepare("SELECT count(*) FROM sources").get()));
49729
50162
  const chunks = Number(cell(raw.prepare("SELECT count(*) FROM chunks").get()));
49730
- return pass2("D9", D9_INDEX_DETAIL(sources, chunks));
50163
+ return pass3("D9", D9_INDEX_DETAIL(sources, chunks));
49731
50164
  } catch (err) {
49732
- return unknown4("D9", message(err));
50165
+ return unknown5("D9", message(err));
49733
50166
  } finally {
49734
50167
  raw?.close();
49735
50168
  }
49736
50169
  }
49737
50170
 
49738
- // src/core/ops/doctor-env.ts
49739
- import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
49740
- import { isAbsolute as isAbsolute4, join as join12, relative as relative2 } from "node:path";
49741
- function pass3(id, detail = DOCTOR_PASS_DETAIL) {
49742
- return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
49743
- }
49744
- function unknown5(id, detail, fixCommand) {
49745
- return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
49746
- }
49747
- function fail3(id, detail, fixCommand) {
49748
- return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
49749
- }
49750
- function warn(id, detail, fixCommand) {
49751
- return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
49752
- }
49753
- function bundleVersion(bundleDir2) {
49754
- try {
49755
- const v = JSON.parse(readFileSync10(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
49756
- return typeof v === "string" && v !== "" ? v : void 0;
49757
- } catch {
49758
- return void 0;
49759
- }
49760
- }
49761
- function channelOf(version4) {
49762
- const at = version4.indexOf(D1_PRERELEASE_SEP);
49763
- if (at < 0) return D1_DEFAULT_TAG;
49764
- const pre = version4.slice(at + 1);
49765
- const dot = pre.indexOf(".");
49766
- const tag = dot < 0 ? pre : pre.slice(0, dot);
49767
- return tag === "" ? D1_DEFAULT_TAG : tag;
49768
- }
49769
- function firstLine2(b) {
49770
- const text = b.toString("utf8").trim();
49771
- const nl = text.indexOf("\n");
49772
- return (nl < 0 ? text : text.slice(0, nl)).trim();
49773
- }
49774
- function gitCause(r, timeoutMs) {
49775
- if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
49776
- if (r.killed === "cancel") return D1_GIT_CANCEL;
49777
- if (r.exitCode === null) return D1_GIT_NO_START;
49778
- return D1_GIT_EXIT(r.exitCode, firstLine2(r.stderr));
49779
- }
49780
- function fetchCause(err, timeoutMs) {
49781
- const name = err instanceof Error ? err.name : "";
49782
- if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
49783
- const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
49784
- const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
49785
- const msg = cause instanceof Error ? cause.message : String(cause);
49786
- const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
49787
- return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
49788
- }
49789
- async function npmLatest(url4, tag, signal, timeoutMs) {
49790
- try {
49791
- const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
49792
- if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
49793
- const body = await res.json();
49794
- const v = typeof body === "object" && body !== null ? body[tag] : void 0;
49795
- return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag) };
49796
- } catch (err) {
49797
- return { ok: false, cause: fetchCause(err, timeoutMs) };
49798
- }
49799
- }
49800
- function digits(s) {
49801
- if (s === "") return false;
49802
- for (const ch of s) if (ch < "0" || ch > "9") return false;
49803
- return true;
49804
- }
49805
- function parseVersion(v) {
49806
- const at = v.indexOf(D1_PRERELEASE_SEP);
49807
- const core = (at < 0 ? v : v.slice(0, at)).split(NODE_VERSION_SEP);
49808
- if (core.length !== 3 || !core.every(digits)) return null;
49809
- const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
49810
- if (at < 0) return { core: nums, pre: [] };
49811
- const pre = v.slice(at + 1).split(NODE_VERSION_SEP);
49812
- if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
49813
- if (pre.length === 1) return { core: nums, pre: [pre[0]] };
49814
- return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
49815
- }
49816
- function sign(n) {
49817
- return n < 0 ? -1 : n > 0 ? 1 : 0;
49818
- }
49819
- function compareVersions(a, b) {
49820
- const x = parseVersion(a);
49821
- const y = parseVersion(b);
49822
- if (x === null || y === null) return null;
49823
- for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
49824
- if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
49825
- if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
49826
- return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
49827
- }
49828
- function highestTag(stdout, tag) {
49829
- let best;
49830
- for (const line of stdout.split("\n")) {
49831
- const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
49832
- if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
49833
- const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
49834
- if (parseVersion(v) === null || channelOf(v) !== tag) continue;
49835
- if (best === void 0 || compareVersions(v, best) === 1) best = v;
49836
- }
49837
- return best;
49838
- }
49839
- function versionRow(head, installed, tag, source, latest, tail, update) {
49840
- const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
49841
- if (cmp === 0) return pass3("D1", head + D1_LATEST_PASS(tag, source) + tail);
49842
- if (cmp > 0) return pass3("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
49843
- return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
49844
- }
49845
- async function checkVersion(i) {
49846
- if (i.bundleSha === void 0) return unknown5("D1", D1_DEV_BUILD_DETAIL);
49847
- const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
49848
- if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
49849
- const tag = channelOf(i.version);
49850
- const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
49851
- const git2 = findRuntime(GIT_BIN, i.env);
49852
- const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
49853
- if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
49854
- let cause = D1_GIT_MISSING;
49855
- if (git2 !== null) {
49856
- const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
49857
- cwd: i.cwd,
49858
- env: { ...i.env, ...GIT_NO_PROMPT_ENV },
49859
- signal: i.signal,
49860
- timeoutMs: i.timeoutMs
49861
- });
49862
- if (r.exitCode === 0 && r.killed === null) {
49863
- const latest = highestTag(r.stdout.toString("utf8"), tag);
49864
- if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
49865
- cause = D1_GIT_NO_TAG(tag);
49866
- } else {
49867
- cause = gitCause(r, i.timeoutMs);
49868
- }
49869
- }
49870
- return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
49871
- }
49872
- function numbers(v) {
49873
- const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
49874
- return bare2.split(NODE_VERSION_SEP).map(Number);
49875
- }
49876
- function belowMin(version4) {
49877
- const got = numbers(version4);
49878
- const min = numbers(NODE_MIN);
49879
- for (let k = 0; k < min.length; k++) {
49880
- const g = got[k] ?? 0;
49881
- if (g !== min[k]) return g < min[k];
49882
- }
49883
- return false;
49884
- }
49885
- async function sqliteLoads() {
49886
- try {
49887
- await import(SQLITE_MODULE);
49888
- return true;
49889
- } catch {
49890
- return false;
49891
- }
49892
- }
49893
- async function checkNode(i) {
49894
- const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
49895
- const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
49896
- if (belowMin(i.nodeVersion)) return fail3("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
49897
- if (!await sqliteLoads()) return fail3("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
49898
- return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
49899
- }
49900
- function checkMcp(ctx, adapter) {
49901
- const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
49902
- const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
49903
- if (named2 || versioned) return pass3("D6");
49904
- return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown5("D6", D6_UNKNOWN_DETAIL);
49905
- }
49906
- function piCwdInside(worktree, piCwd) {
49907
- if (piCwd === void 0 || !existsSync12(piCwd)) return false;
49908
- const rel = relative2(worktree, realpathSync6.native(piCwd));
49909
- return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
49910
- }
49911
- function checkProject(i) {
49912
- const bad = fail3("D7", D7_DETAIL(i.project.source), D7_FIX);
49913
- if (i.project.source !== i.adapter.projectSource) return bad;
49914
- if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
49915
- return pass3("D7");
49916
- }
49917
- function checkMode(adapter, hostPermission) {
49918
- if (hostPermission === "missing") return fail3("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
49919
- if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
49920
- return pass3("D10", D10_DETAIL(adapter.denyChannel));
49921
- }
49922
- function checkShell(env) {
49923
- const win = process.platform === "win32";
49924
- const shell = findRuntime("shell", env);
49925
- if (shell !== null) return pass3("D11", D11_PASS_DETAIL(shell, win));
49926
- return win ? fail3("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail3("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
49927
- }
49928
-
49929
50171
  // src/core/ops/doctor-hook.ts
49930
- import { existsSync as existsSync14, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
50172
+ import { existsSync as existsSync15, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync12, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
49931
50173
  import { tmpdir as tmpdir2 } from "node:os";
49932
50174
  import path7 from "node:path";
49933
50175
 
@@ -51671,7 +51913,9 @@ var HOST_SHAPES = {
51671
51913
  kiro: kiro_default,
51672
51914
  zcode: zcode_default,
51673
51915
  pi: pi_default,
51674
- opencode: opencode_default
51916
+ opencode: opencode_default,
51917
+ omp: pi_default
51918
+ // ADR-0026: OMP reads the Pi extension reply
51675
51919
  };
51676
51920
  var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
51677
51921
  var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
@@ -51753,13 +51997,13 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
51753
51997
 
51754
51998
  // src/setup/codex-trust.ts
51755
51999
  import { createHash } from "node:crypto";
51756
- import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
52000
+ import { existsSync as existsSync14, realpathSync as realpathSync7 } from "node:fs";
51757
52001
  import path6 from "node:path";
51758
52002
  import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
51759
52003
 
51760
52004
  // src/setup/spawn-bin.ts
51761
52005
  import { spawnSync } from "node:child_process";
51762
- import { accessSync as accessSync2, constants as fsc, statSync as statSync5 } from "node:fs";
52006
+ import { accessSync as accessSync2, constants as fsc, statSync as statSync6 } from "node:fs";
51763
52007
  import path5 from "node:path";
51764
52008
  var WIN_EXT = ".COM;.EXE;.BAT;.CMD";
51765
52009
  var WIN_SHIM_EXTS = Object.freeze([".cmd", ".bat"]);
@@ -51777,7 +52021,7 @@ function whichBin(bin, env, platform = process.platform) {
51777
52021
  const f = path5.join(dir, n);
51778
52022
  try {
51779
52023
  accessSync2(f, fsc.X_OK);
51780
- if (statSync5(f).isFile()) return f;
52024
+ if (statSync6(f).isFile()) return f;
51781
52025
  } catch {
51782
52026
  }
51783
52027
  }
@@ -51976,10 +52220,10 @@ function isObject6(v) {
51976
52220
  }
51977
52221
  function loadFixture(bundleDir2, agent) {
51978
52222
  const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
51979
- if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
52223
+ if (!existsSync15(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
51980
52224
  let all;
51981
52225
  try {
51982
- all = JSON.parse(hostText(readFileSync11(file2, "utf8")));
52226
+ all = JSON.parse(hostText(readFileSync12(file2, "utf8")));
51983
52227
  } catch (err) {
51984
52228
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
51985
52229
  }
@@ -52001,7 +52245,8 @@ var CWD_KEY = {
52001
52245
  kiro: "cwd",
52002
52246
  zcode: "cwd",
52003
52247
  pi: "cwd",
52004
- opencode: "directory"
52248
+ opencode: "directory",
52249
+ omp: "cwd"
52005
52250
  };
52006
52251
  function payloadFor(agent, payload, worktree) {
52007
52252
  return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
@@ -52193,7 +52438,7 @@ async function codexStopDetail(i, timeoutMs) {
52193
52438
  timeoutMs,
52194
52439
  stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
52195
52440
  });
52196
- const logged = existsSync14(path7.join(home, HOOK_ERROR_LOG_FILE));
52441
+ const logged = existsSync15(path7.join(home, HOOK_ERROR_LOG_FILE));
52197
52442
  return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
52198
52443
  } finally {
52199
52444
  rmSync4(home, { recursive: true, force: true });
@@ -52204,7 +52449,7 @@ async function checkHookRoundTrip(i) {
52204
52449
  const trust = await codexPluginTrust(i);
52205
52450
  if (trust !== null) return trust;
52206
52451
  }
52207
- if (i.agent === "codex" && existsSync14(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
52452
+ if (i.agent === "codex" && existsSync15(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
52208
52453
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
52209
52454
  }
52210
52455
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -52253,14 +52498,14 @@ async function checkHookRoundTrip(i) {
52253
52498
  }
52254
52499
 
52255
52500
  // src/core/hooks/fallback.ts
52256
- import { join as join14, resolve as resolve7 } from "node:path";
52501
+ import { join as join15, resolve as resolve7 } from "node:path";
52257
52502
 
52258
52503
  // src/core/policy/read-media.ts
52259
52504
  import { extname } from "node:path";
52260
52505
  var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
52261
52506
 
52262
52507
  // src/core/policy/own-file.ts
52263
- import { extname as extname2, join as join13, resolve as resolve6 } from "node:path";
52508
+ import { extname as extname2, join as join14, resolve as resolve6 } from "node:path";
52264
52509
 
52265
52510
  // src/core/hooks/fallback.ts
52266
52511
  var fs = process.getBuiltinModule("node:fs");
@@ -52269,9 +52514,9 @@ function homeOf(env) {
52269
52514
  }
52270
52515
  function hookLogPath(env) {
52271
52516
  const dir = env[DATA_DIR_ENV];
52272
- if (dir !== void 0 && dir !== "") return join14(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
52517
+ if (dir !== void 0 && dir !== "") return join15(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
52273
52518
  const home = homeOf(env);
52274
- return home === "" ? "" : join14(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
52519
+ return home === "" ? "" : join15(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
52275
52520
  }
52276
52521
  function lastHookError(env) {
52277
52522
  try {
@@ -52301,8 +52546,8 @@ function lastHookError(env) {
52301
52546
  }
52302
52547
 
52303
52548
  // src/core/ops/db-heal.ts
52304
- import { existsSync as existsSync15, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
52305
- import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
52549
+ import { existsSync as existsSync16, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
52550
+ import { basename as basename4, dirname as dirname8, join as join16 } from "node:path";
52306
52551
  function integrityOk2(rows) {
52307
52552
  return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
52308
52553
  }
@@ -52336,7 +52581,7 @@ function renameAside(dbPath) {
52336
52581
  const ts = String(Date.now());
52337
52582
  for (const suffix of DB_SIBLING_SUFFIXES) {
52338
52583
  const file2 = dbPath + suffix;
52339
- if (existsSync15(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
52584
+ if (existsSync16(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
52340
52585
  }
52341
52586
  return ts;
52342
52587
  }
@@ -52359,7 +52604,7 @@ function utcStamp(now) {
52359
52604
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
52360
52605
  }
52361
52606
  function makeOrphanDir(projectDir) {
52362
- const base = join15(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
52607
+ const base = join16(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
52363
52608
  for (let n = 1; ; n += 1) {
52364
52609
  const dir = n === 1 ? base : base + "-" + String(n);
52365
52610
  try {
@@ -52376,7 +52621,7 @@ async function healOrphan(project, files, row5) {
52376
52621
  try {
52377
52622
  dir = makeOrphanDir(dirname8(project.dbPath));
52378
52623
  for (const f of files) {
52379
- const to = join15(dir, basename4(f.path));
52624
+ const to = join16(dir, basename4(f.path));
52380
52625
  renameWithRetry(f.path, to);
52381
52626
  moved.push({ path: to, bytes: f.bytes });
52382
52627
  }
@@ -52474,8 +52719,8 @@ function unsupportedHostOf(sig) {
52474
52719
 
52475
52720
  // src/core/ops/doctor-issue.ts
52476
52721
  import { spawnSync as spawnSync3 } from "node:child_process";
52477
- import { closeSync as closeSync2, existsSync as existsSync16, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync12, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
52478
- import { delimiter, dirname as dirname9, join as join16 } from "node:path";
52722
+ import { closeSync as closeSync2, existsSync as existsSync17, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
52723
+ import { delimiter, dirname as dirname9, join as join17 } from "node:path";
52479
52724
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
52480
52725
  function tildeOf(env) {
52481
52726
  const home = homeDirOf(env);
@@ -52531,8 +52776,8 @@ function onPath(env, tool) {
52531
52776
  const out = [];
52532
52777
  for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
52533
52778
  if (dir === "") continue;
52534
- for (const n of names) if (existsSync16(join16(dir, n))) {
52535
- out.push(join16(dir, n));
52779
+ for (const n of names) if (existsSync17(join17(dir, n))) {
52780
+ out.push(join17(dir, n));
52536
52781
  break;
52537
52782
  }
52538
52783
  }
@@ -52540,7 +52785,7 @@ function onPath(env, tool) {
52540
52785
  }
52541
52786
  function hookLogTail(env) {
52542
52787
  const file2 = hookLogPath(env);
52543
- if (file2 === "" || !existsSync16(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
52788
+ if (file2 === "" || !existsSync17(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
52544
52789
  try {
52545
52790
  const fd = openSync2(file2, "r");
52546
52791
  try {
@@ -52560,7 +52805,7 @@ function hookLogTail(env) {
52560
52805
  }
52561
52806
  async function journalRows(ctx) {
52562
52807
  const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
52563
- if (!existsSync16(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
52808
+ if (!existsSync17(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
52564
52809
  try {
52565
52810
  const db = await openDb(ctx.project, { readOnly: true });
52566
52811
  try {
@@ -52578,21 +52823,21 @@ function agentConfig(adapter, env, worktree) {
52578
52823
  const home = homeDirOf(env);
52579
52824
  const files = configPaths(adapter, env, worktree);
52580
52825
  if (home !== null) {
52581
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join16(claudeDirOf(env, home), SETTINGS_FILE) });
52582
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join16(codexDirOf(env, home), CONFIG_TOML_FILE) });
52826
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join17(claudeDirOf(env, home), SETTINGS_FILE) });
52827
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join17(codexDirOf(env, home), CONFIG_TOML_FILE) });
52583
52828
  }
52584
52829
  const out = [];
52585
52830
  const seen = /* @__PURE__ */ new Set();
52586
52831
  for (const f of files) {
52587
52832
  if (seen.has(f.path)) continue;
52588
52833
  seen.add(f.path);
52589
- if (!existsSync16(f.path)) {
52834
+ if (!existsSync17(f.path)) {
52590
52835
  out.push(`${f.label}: ${f.path} (absent)`);
52591
52836
  continue;
52592
52837
  }
52593
52838
  let text = "";
52594
52839
  try {
52595
- text = readFileSync12(f.path, "utf8");
52840
+ text = readFileSync13(f.path, "utf8");
52596
52841
  } catch (err) {
52597
52842
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
52598
52843
  continue;
@@ -52663,9 +52908,9 @@ async function buildIssueBody(i) {
52663
52908
  async function writeIssueReport(i) {
52664
52909
  const tilde = tildeOf(i.env);
52665
52910
  const body = await buildIssueBody(i);
52666
- const dir = join16(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
52911
+ const dir = join17(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
52667
52912
  mkdirSync7(dir, { recursive: true });
52668
- const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
52913
+ const file2 = join17(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
52669
52914
  writeFileSync4(file2, body);
52670
52915
  const shown2 = tilde(file2);
52671
52916
  const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
@@ -52711,7 +52956,7 @@ async function guard(id, run) {
52711
52956
  }
52712
52957
  }
52713
52958
  async function codexDb(ctx, adapter) {
52714
- if (adapter.id !== "codex" || !existsSync17(ctx.project.dbPath)) return null;
52959
+ if (adapter.id !== "codex" || !existsSync18(ctx.project.dbPath)) return null;
52715
52960
  try {
52716
52961
  return await openDb(ctx.project, { readOnly: true });
52717
52962
  } catch {
@@ -52747,11 +52992,11 @@ async function hookRow(ctx, adapter, host) {
52747
52992
  }
52748
52993
  }
52749
52994
  function ownServerId(configDir, projectKey) {
52750
- const dir = join17(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
52751
- if (!existsSync17(dir)) return "";
52995
+ const dir = join18(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
52996
+ if (!existsSync18(dir)) return "";
52752
52997
  for (const name of readdirSync8(dir)) {
52753
52998
  if (!name.endsWith(OWNER_PID_EXT)) continue;
52754
- if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
52999
+ if (readFileSync14(join18(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
52755
53000
  }
52756
53001
  return "";
52757
53002
  }
@@ -52781,7 +53026,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
52781
53026
  D9: () => checkIndex(project),
52782
53027
  D10: () => checkMode(adapter, ctx.hostPermission),
52783
53028
  // D-1331-OC-PERM-1
52784
- D11: () => checkShell(env)
53029
+ D11: () => checkRuntimes(env, checkShell(env))
52785
53030
  };
52786
53031
  const rows = [];
52787
53032
  for (const id of DOCTOR_CHECK_ORDER) rows.push(await guard(id, checks[id]));
@@ -52811,7 +53056,7 @@ async function doctorReply(ctx, host) {
52811
53056
  const runtime = runtimeInfo(host.env, ctx.signal);
52812
53057
  const rows = await runDoctorChecks(ctx, adapter, host);
52813
53058
  const failed = rows.some((r) => r.status === "FAIL");
52814
- const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
53059
+ const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : adapter.id === "omp" ? ompCommand(rows, failed) : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
52815
53060
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
52816
53061
  const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
52817
53062
  const table3 = buildReport(input);
@@ -52825,7 +53070,8 @@ async function doctorReply(ctx, host) {
52825
53070
  }
52826
53071
  const look = rows.find((r) => r.status === "FAIL") ?? rows.find((r) => r.status !== "PASS");
52827
53072
  const docs = look === void 0 ? [] : [DOCTOR_DOCS_LABEL + DOCTOR_DOCS_LINK(look.id)];
52828
- const whole2 = [envLine2, table3, ...docs, ...notes].join("\n");
53073
+ const info = adapter.id === "omp" ? ompInfoLines(host.env, ctx.clientInfo?.version) : [];
53074
+ const whole2 = [envLine2, table3, ...docs, ...info, ...notes].join("\n");
52829
53075
  const bytes5 = Buffer.byteLength(whole2, "utf8");
52830
53076
  if (bytes5 <= REPORT_CAP) return { text: whole2, isError: false, sandboxBytes: bytes5 };
52831
53077
  const db = await openDb(ctx.project);
@@ -52834,9 +53080,14 @@ async function doctorReply(ctx, host) {
52834
53080
  } finally {
52835
53081
  closeDb(db);
52836
53082
  }
52837
- const text = [envLine2, buildReportHead(input), ...docs, ...notes].join("\n");
53083
+ const text = [envLine2, buildReportHead(input), ...docs, ...info, ...notes].join("\n");
52838
53084
  return { text, isError: false, sandboxBytes: bytes5 };
52839
53085
  }
53086
+ function ompCommand(rows, failed) {
53087
+ if (!failed) return OMP_LIST_COMMAND;
53088
+ const d3 = rows.find((r) => r.id === "D3" && r.status === "FAIL");
53089
+ return d3?.fixCommand ?? NATIVE_INSTALL.omp[0];
53090
+ }
52840
53091
  async function handler2(_input, ctx) {
52841
53092
  return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
52842
53093
  }
@@ -52850,9 +53101,9 @@ var ctxDoctor = Object.freeze({
52850
53101
  });
52851
53102
 
52852
53103
  // src/core/tools/execute.ts
52853
- import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
53104
+ import { existsSync as existsSync19, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
52854
53105
  import { tmpdir as tmpdir3 } from "node:os";
52855
- import { dirname as dirname11, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
53106
+ import { dirname as dirname11, join as join19, parse as parse5, resolve as resolve8 } from "node:path";
52856
53107
 
52857
53108
  // src/core/index/select.ts
52858
53109
  var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
@@ -52974,7 +53225,7 @@ function schemaLine(issue4) {
52974
53225
  }
52975
53226
  function fileError(given, abs, root) {
52976
53227
  let dir = abs;
52977
- while (!existsSync18(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
53228
+ while (!existsSync19(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
52978
53229
  if (isInside(root, dir)) return null;
52979
53230
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
52980
53231
  }
@@ -53043,7 +53294,12 @@ async function handler3(raw, ctx) {
53043
53294
  if (bad !== null) return fail4(bad);
53044
53295
  extra.CTX_FILE = abs;
53045
53296
  }
53046
- const runtime = findRuntime(input.language);
53297
+ let runtime;
53298
+ try {
53299
+ runtime = findRuntime(input.language);
53300
+ } catch {
53301
+ runtime = null;
53302
+ }
53047
53303
  if (runtime === null) return fail4(noRuntimeError(input.language).toLine());
53048
53304
  const env = buildChildEnv(process.env, extra);
53049
53305
  const timeoutMs = input.timeoutMs ?? EXEC_TIMEOUT_MS;
@@ -53055,8 +53311,8 @@ async function handler3(raw, ctx) {
53055
53311
  if (takesDashC(input.language, runtime)) {
53056
53312
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
53057
53313
  } else {
53058
- tmpDir = mkdtempSync2(join18(tmpdir3(), TMP_PREFIX));
53059
- const file2 = join18(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
53314
+ tmpDir = mkdtempSync2(join19(tmpdir3(), TMP_PREFIX));
53315
+ const file2 = join19(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
53060
53316
  writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
53061
53317
  argv = scriptArgv(input.language, runtime, file2);
53062
53318
  }
@@ -53092,12 +53348,12 @@ var ctxExecute = {
53092
53348
  };
53093
53349
 
53094
53350
  // src/core/tools/index.ts
53095
- import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
53096
- import { dirname as dirname12, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
53351
+ import { existsSync as existsSync20, readFileSync as readFileSync17, statSync as statSync8 } from "node:fs";
53352
+ import { dirname as dirname12, extname as extname3, join as join22, relative as relative3, resolve as resolve9 } from "node:path";
53097
53353
 
53098
53354
  // src/core/index/walk.ts
53099
- import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
53100
- import { join as join19 } from "node:path";
53355
+ import { readdirSync as readdirSync9, readFileSync as readFileSync15, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
53356
+ import { join as join20 } from "node:path";
53101
53357
  var GITIGNORE = ".gitignore";
53102
53358
  var GIT_DIR = ".git";
53103
53359
  function walkDir(root, containmentRoot) {
@@ -53106,7 +53362,7 @@ function walkDir(root, containmentRoot) {
53106
53362
  const found = [];
53107
53363
  visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
53108
53364
  found.sort(compareFound);
53109
- return found.map((f) => ({ absPath: f.absPath, relPath: join19(...f.dir, f.name) }));
53365
+ return found.map((f) => ({ absPath: f.absPath, relPath: join20(...f.dir, f.name) }));
53110
53366
  }
53111
53367
  function visit(abs, rel, parent, contain, seen, found) {
53112
53368
  let entries;
@@ -53115,10 +53371,10 @@ function visit(abs, rel, parent, contain, seen, found) {
53115
53371
  } catch {
53116
53372
  return;
53117
53373
  }
53118
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join19(abs, GITIGNORE), rel)) : parent;
53374
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join20(abs, GITIGNORE), rel)) : parent;
53119
53375
  for (const e of entries) {
53120
53376
  if (e.name === GIT_DIR) continue;
53121
- const path8 = join19(abs, e.name);
53377
+ const path8 = join20(abs, e.name);
53122
53378
  let isDir = e.isDirectory();
53123
53379
  let isFile = e.isFile();
53124
53380
  let target = path8;
@@ -53130,7 +53386,7 @@ function visit(abs, rel, parent, contain, seen, found) {
53130
53386
  continue;
53131
53387
  }
53132
53388
  if (!isInside(contain, resolved)) continue;
53133
- const st = statSync6(resolved);
53389
+ const st = statSync7(resolved);
53134
53390
  isDir = st.isDirectory();
53135
53391
  isFile = st.isFile();
53136
53392
  target = resolved;
@@ -53158,7 +53414,7 @@ function compareFound(a, b) {
53158
53414
  function readRules(file2, base) {
53159
53415
  let body;
53160
53416
  try {
53161
- body = readFileSync14(file2, "utf8");
53417
+ body = readFileSync15(file2, "utf8");
53162
53418
  } catch {
53163
53419
  return [];
53164
53420
  }
@@ -53241,10 +53497,12 @@ function globSeg(pat, name) {
53241
53497
  }
53242
53498
 
53243
53499
  // src/core/sandbox/fetch.ts
53500
+ import { readFileSync as readFileSync16 } from "node:fs";
53244
53501
  import { lookup } from "node:dns/promises";
53245
53502
  import http from "node:http";
53246
53503
  import https from "node:https";
53247
53504
  import { BlockList, isIP } from "node:net";
53505
+ import { join as join21 } from "node:path";
53248
53506
  import { connect as tlsConnect } from "node:tls";
53249
53507
  var PRIVATE_RANGES = [
53250
53508
  ["127.0.0.0", 8, "ipv4"],
@@ -53276,6 +53534,21 @@ for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix,
53276
53534
  var STATUS_OK_FIRST = 200;
53277
53535
  var STATUS_OK_END = 300;
53278
53536
  var STATUS_REDIRECT = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
53537
+ var UA_HOME = "https://github.com/mksglu/context-mode";
53538
+ var UA_DEV_VERSION = "dev";
53539
+ var namedHeaders;
53540
+ function baseHeaders() {
53541
+ if (namedHeaders === void 0) {
53542
+ let version4 = UA_DEV_VERSION;
53543
+ try {
53544
+ const v = JSON.parse(readFileSync16(join21(ownBundleDir(), D1_PACKAGE_FILE), "utf8")).version;
53545
+ if (typeof v === "string" && v !== "") version4 = v;
53546
+ } catch {
53547
+ }
53548
+ namedHeaders = Object.freeze({ "user-agent": "context-mode/" + version4 + " (+" + UA_HOME + ")", accept: "*/*" });
53549
+ }
53550
+ return namedHeaders;
53551
+ }
53279
53552
  function fail5(code) {
53280
53553
  return new CtxError("FETCH_FAILED", { code });
53281
53554
  }
@@ -53384,11 +53657,11 @@ function request(u, conn, proxy, signal) {
53384
53657
  const onErr = (err) => reject(fail5(causeCode(err)));
53385
53658
  if (proxy === void 0) {
53386
53659
  const mod = u.protocol === "https:" ? https : http;
53387
- const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
53660
+ const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { ...baseHeaders(), host: u.host } });
53388
53661
  req.on("response", resolve10).on("error", onErr).end();
53389
53662
  return;
53390
53663
  }
53391
- const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
53664
+ const proxyHeaders = proxy.auth === void 0 ? { ...baseHeaders() } : { ...baseHeaders(), "proxy-authorization": proxy.auth };
53392
53665
  if (u.protocol === "http:") {
53393
53666
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
53394
53667
  req.on("response", resolve10).on("error", onErr).end();
@@ -53408,7 +53681,7 @@ function request(u, conn, proxy, signal) {
53408
53681
  port,
53409
53682
  path: path8,
53410
53683
  signal,
53411
- headers: { host: u.host },
53684
+ headers: { ...baseHeaders(), host: u.host },
53412
53685
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
53413
53686
  });
53414
53687
  req.on("response", resolve10).on("error", onErr).end();
@@ -53450,7 +53723,7 @@ async function safeFetch(url4, signal) {
53450
53723
  }
53451
53724
  if (status < STATUS_OK_FIRST || status >= STATUS_OK_END) {
53452
53725
  res.resume();
53453
- throw fail5(status);
53726
+ throw fail5(status + " from " + bare(current.hostname));
53454
53727
  }
53455
53728
  const body = await readBody(res);
53456
53729
  const shown2 = new URL(current.href);
@@ -57286,14 +57559,14 @@ function kindOfType(contentType) {
57286
57559
  }
57287
57560
  function readUtf8(absPath) {
57288
57561
  try {
57289
- return utf8.decode(readFileSync15(absPath));
57562
+ return utf8.decode(readFileSync17(absPath));
57290
57563
  } catch {
57291
57564
  return void 0;
57292
57565
  }
57293
57566
  }
57294
57567
  function missingOrOutside(given, abs, root) {
57295
57568
  let dir = abs;
57296
- while (!existsSync19(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
57569
+ while (!existsSync20(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
57297
57570
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
57298
57571
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
57299
57572
  }
@@ -57301,10 +57574,10 @@ function pathItems(input, project) {
57301
57574
  const abs = resolve9(project.worktree, input.path);
57302
57575
  if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
57303
57576
  const base = relative3(project.worktree, abs);
57304
- if (statSync7(abs).isDirectory()) {
57577
+ if (statSync8(abs).isDirectory()) {
57305
57578
  return walkDir(abs, project.containmentRoot).map((f) => ({
57306
57579
  sourceKind: "path",
57307
- label: pathLabel(join20(base, f.relPath)),
57580
+ label: pathLabel(join22(base, f.relPath)),
57308
57581
  kind: kindOfPath(f.relPath),
57309
57582
  read: () => readUtf8(f.absPath)
57310
57583
  }));
@@ -58104,8 +58377,8 @@ var ctxStats = Object.freeze({
58104
58377
  });
58105
58378
 
58106
58379
  // src/core/ops/host-write.ts
58107
- import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
58108
- import { dirname as dirname13, join as join21 } from "node:path";
58380
+ import { copyFileSync, existsSync as existsSync21, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
58381
+ import { dirname as dirname13, join as join23 } from "node:path";
58109
58382
  function defaultWrite(file2, text) {
58110
58383
  writeFileSync6(file2, text, "utf8");
58111
58384
  }
@@ -58114,17 +58387,20 @@ function hostConfigPath(agent, home, env) {
58114
58387
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
58115
58388
  switch (agent) {
58116
58389
  case "opencode":
58117
- return join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
58390
+ return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
58118
58391
  // D-WIN-OPENCODE-DIR-1
58119
58392
  case "pi":
58120
- return join21(piAgentDirOf(env, home), SETTINGS_FILE);
58393
+ return join23(piAgentDirOf(env, home), SETTINGS_FILE);
58121
58394
  case "gemini":
58122
- return join21(geminiDirOf(env, home), SETTINGS_FILE);
58395
+ return join23(geminiDirOf(env, home), SETTINGS_FILE);
58123
58396
  // D-R38-GEMINI-HOME-1
58124
58397
  case "copilot-cli":
58125
58398
  return null;
58399
+ case "omp":
58400
+ return null;
58401
+ // ADR-0026 decision 8 (D-OMP-UPGRADE-1): OMP loads the plugin from its own store; no MCP entry, nothing under ~/.pi
58126
58402
  default:
58127
- return join21(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
58403
+ return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
58128
58404
  }
58129
58405
  }
58130
58406
  function cell3(value) {
@@ -58136,7 +58412,7 @@ function toRow(file2, edit) {
58136
58412
  function writeWithRollback(file2, text, write, atomic) {
58137
58413
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
58138
58414
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
58139
- const had = existsSync20(file2);
58415
+ const had = existsSync21(file2);
58140
58416
  mkdirSync8(dirname13(file2), { recursive: true });
58141
58417
  if (had) copyFileSync(file2, trash);
58142
58418
  try {
@@ -58166,7 +58442,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
58166
58442
  if (requested === null) return [];
58167
58443
  const current = readHostConfig(row5.id, requested);
58168
58444
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
58169
- const exists = existsSync20(current.path);
58445
+ const exists = existsSync21(current.path);
58170
58446
  if (exists && result.text === current.text) return [];
58171
58447
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
58172
58448
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -58174,15 +58450,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
58174
58450
  }
58175
58451
 
58176
58452
  // src/core/ops/uninstall.ts
58177
- import { existsSync as existsSync21, readdirSync as readdirSync10, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
58178
- import { join as join22 } from "node:path";
58453
+ import { existsSync as existsSync22, readdirSync as readdirSync10, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
58454
+ import { join as join24 } from "node:path";
58179
58455
  function row2(area, before, after) {
58180
58456
  return { area, before, after };
58181
58457
  }
58182
58458
  function stopServers(configDir, projectKey) {
58183
58459
  const stopped = listLiveOwners(configDir, projectKey);
58184
- const dir = join22(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
58185
- for (const serverId of stopped) writeFileSync7(join22(dir, serverId + OWNER_STOP_EXT), "", "utf8");
58460
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
58461
+ for (const serverId of stopped) writeFileSync7(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
58186
58462
  return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
58187
58463
  }
58188
58464
  function rootOrNull(adapter, env) {
@@ -58200,15 +58476,15 @@ function removeCache(adapter, env, configDir) {
58200
58476
  const root = rootOrNull(adapter, env);
58201
58477
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
58202
58478
  if (adapter.installMode === "marketplace") {
58203
- const cache = join22(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
58479
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
58204
58480
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
58205
58481
  }
58206
58482
  rmSync7(root, { recursive: true, force: true });
58207
58483
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
58208
58484
  }
58209
58485
  case "plugin": {
58210
- const agentDir = join22(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
58211
- if (!existsSync21(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
58486
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
58487
+ if (!existsSync22(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
58212
58488
  rmSync7(agentDir, { recursive: true, force: true });
58213
58489
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
58214
58490
  }
@@ -58253,7 +58529,7 @@ function ownEntries2(agent, env) {
58253
58529
  }
58254
58530
  if (agent === "opencode") {
58255
58531
  return [{
58256
- file: join22(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
58532
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
58257
58533
  // D-WIN-OPENCODE-DIR-1
58258
58534
  key: OPENCODE_PLUGIN_KEY,
58259
58535
  shown: OPENCODE_PLUGIN_KEY,
@@ -58264,13 +58540,22 @@ function ownEntries2(agent, env) {
58264
58540
  if (agent === "pi") {
58265
58541
  const agentDir = piAgentDirOf(env, home);
58266
58542
  return [{
58267
- file: join22(agentDir, SETTINGS_FILE),
58543
+ file: join24(agentDir, SETTINGS_FILE),
58268
58544
  key: PI_PACKAGES_KEY,
58269
58545
  shown: PI_PACKAGES_KEY,
58270
58546
  has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
58271
58547
  drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
58272
58548
  }];
58273
58549
  }
58550
+ if (agent === "omp") {
58551
+ return [{
58552
+ file: ompImportFiles(home).mcp,
58553
+ key: OMP_DISABLED_SERVERS_KEY,
58554
+ shown: OMP_DISABLED_SERVERS_KEY,
58555
+ has: (v) => Array.isArray(v) && v.includes(SERVER_KEY),
58556
+ drop: (v) => v.filter((x) => x !== SERVER_KEY)
58557
+ }];
58558
+ }
58274
58559
  return [];
58275
58560
  }
58276
58561
  function removeOwnEntries(agent, env) {
@@ -58286,12 +58571,12 @@ function removeOwnEntries(agent, env) {
58286
58571
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
58287
58572
  }
58288
58573
  function removeProjectData(configDir, projectKey) {
58289
- const projects = join22(configDir, PROJECTS_DIR_NAME);
58290
- const dir = join22(projects, projectKey);
58291
- if (!existsSync21(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
58574
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
58575
+ const dir = join24(projects, projectKey);
58576
+ if (!existsSync22(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
58292
58577
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
58293
58578
  for (const name of readdirSync10(dir)) {
58294
- if (name !== OWNERS_DIR_NAME) rmSync7(join22(dir, name), { recursive: true, force: true });
58579
+ if (name !== OWNERS_DIR_NAME) rmSync7(join24(dir, name), { recursive: true, force: true });
58295
58580
  }
58296
58581
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
58297
58582
  }
@@ -58299,12 +58584,12 @@ function runUninstall(input) {
58299
58584
  const configDir = resolveConfigDir(input.env);
58300
58585
  const stop = stopServers(configDir, input.project.projectKey);
58301
58586
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
58302
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join22(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
58587
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
58303
58588
  return { rows, stopped: stop.stopped };
58304
58589
  }
58305
58590
 
58306
58591
  // src/core/ops/v1-remove.ts
58307
- import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync16, rmSync as rmSync8 } from "node:fs";
58592
+ import { copyFileSync as copyFileSync2, existsSync as existsSync23, readFileSync as readFileSync18, rmSync as rmSync8 } from "node:fs";
58308
58593
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
58309
58594
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
58310
58595
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -58316,7 +58601,7 @@ function moveAside(target, undo) {
58316
58601
  }
58317
58602
  function keepAside(target, undo) {
58318
58603
  let aside = target + UPGRADE_ASIDE_SUFFIX;
58319
- for (let n = 2; existsSync22(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
58604
+ for (let n = 2; existsSync23(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
58320
58605
  renameWithRetry(target, aside);
58321
58606
  undo.push({ trash: aside, target, keep: true });
58322
58607
  return aside;
@@ -58355,8 +58640,8 @@ function locate(doc, path8) {
58355
58640
  return null;
58356
58641
  }
58357
58642
  function stripJsonEntries(agent, file2, findings, kept, undo) {
58358
- const layout = hostLayout(readFileSync16(file2, "utf8"));
58359
- const text = hostText(readFileSync16(file2, "utf8"));
58643
+ const layout = hostLayout(readFileSync18(file2, "utf8"));
58644
+ const text = hostText(readFileSync18(file2, "utf8"));
58360
58645
  const doc = parseHostConfig(agent, file2, text, "jsonc");
58361
58646
  const hit = /* @__PURE__ */ new Set();
58362
58647
  const byContainer = /* @__PURE__ */ new Map();
@@ -58393,20 +58678,20 @@ function removeV1(agent, findings, project) {
58393
58678
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
58394
58679
  else if (f.path === "") {
58395
58680
  if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
58396
- else if (existsSync22(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
58397
- else if (existsSync22(f.file)) {
58681
+ else if (existsSync23(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
58682
+ else if (existsSync23(f.file)) {
58398
58683
  moveAside(f.file, undo);
58399
58684
  done.set(f, UPGRADE_REMOVED);
58400
58685
  } else done.set(f, UPGRADE_NOT_FOUND);
58401
58686
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
58402
58687
  }
58403
58688
  for (const [file2, list3] of entries) {
58404
- if (!existsSync22(file2)) {
58689
+ if (!existsSync23(file2)) {
58405
58690
  for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
58406
58691
  continue;
58407
58692
  }
58408
58693
  if (file2.endsWith(TOML_EXT)) {
58409
- const rawToml = readFileSync16(file2, "utf8");
58694
+ const rawToml = readFileSync18(file2, "utf8");
58410
58695
  const tomlLayout = hostLayout(rawToml);
58411
58696
  let text = hostText(rawToml);
58412
58697
  for (const f of list3) {
@@ -58434,7 +58719,7 @@ function removeV1(agent, findings, project) {
58434
58719
  },
58435
58720
  rollback() {
58436
58721
  for (const u of undo.splice(0).reverse()) {
58437
- if (!existsSync22(u.trash)) continue;
58722
+ if (!existsSync23(u.trash)) continue;
58438
58723
  rmSync8(u.target, { recursive: true, force: true });
58439
58724
  renameWithRetry(u.trash, u.target);
58440
58725
  }
@@ -58710,15 +58995,15 @@ async function startServer(argv, env) {
58710
58995
  opening.catch(() => pending.delete(project.dbPath));
58711
58996
  }
58712
58997
  const db = await opening;
58713
- if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
58998
+ if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
58714
58999
  return db;
58715
59000
  }
58716
59001
  function stopMarker(configDir, projectKey) {
58717
- return join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
59002
+ return join25(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
58718
59003
  }
58719
59004
  function stopRequested() {
58720
59005
  const configDir = resolveConfigDir(process.env);
58721
- return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
59006
+ return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
58722
59007
  }
58723
59008
  async function journal(project, ctx, name, reply4) {
58724
59009
  const db = await ownDb(project);