context-mode 2.1.9 → 2.1.10

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.
@@ -11,5 +11,5 @@
11
11
  }
12
12
  },
13
13
  "name": "context-mode",
14
- "version": "2.1.9"
14
+ "version": "2.1.10"
15
15
  }
@@ -11,5 +11,5 @@
11
11
  }
12
12
  },
13
13
  "name": "context-mode",
14
- "version": "2.1.9"
14
+ "version": "2.1.10"
15
15
  }
@@ -480,7 +480,7 @@ var DECISION_ANSWERS_KEY = "answers";
480
480
  var DECISION_OPTION_KEY = "option";
481
481
  var DECISION_LABEL_JOIN = " | ";
482
482
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
483
- var BUNDLE_SHA = true ? "9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde" : void 0;
483
+ var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
484
484
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
485
485
  var DOCTOR_LABEL = Object.freeze({
486
486
  D1: "version",
@@ -821,9 +821,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
821
821
  var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
822
822
  var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
823
823
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
824
- function D5_SLOW_DETAIL(ms) {
825
- return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
824
+ var D5_BARE_SHARE = 0.5;
825
+ function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
826
+ return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
826
827
  }
828
+ function D5_SLOW_START_DETAIL(ms, bare2, bound) {
829
+ return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
830
+ }
831
+ var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
827
832
  var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
828
833
  var D5_FIX = "run ctx_upgrade";
829
834
  var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
@@ -27655,10 +27660,13 @@ async function checkHookRoundTrip(i) {
27655
27660
  await runProcess([node.file, "-e", ""], { cwd: i.bundleDir, env: node.env, signal: i.signal, timeoutMs });
27656
27661
  return performance.now() - t;
27657
27662
  });
27663
+ const inProcess = getAdapter(i.agent).installMode === "in-process";
27658
27664
  const hookWalls = [];
27659
27665
  const bareWalls = [];
27660
27666
  let ms = 0;
27661
- for (let n = 1; n <= maxPairs; n++) {
27667
+ let fastBare = 0;
27668
+ let bound = HOOK_P95_MS;
27669
+ for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
27662
27670
  const start = now();
27663
27671
  const node = nodeLaunch(i.env);
27664
27672
  const r = await runProcess([node.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
@@ -27670,13 +27678,17 @@ async function checkHookRoundTrip(i) {
27670
27678
  });
27671
27679
  hookWalls.push(now() - start);
27672
27680
  if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
27681
+ if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
27673
27682
  bareWalls.push(await bareMs());
27674
- ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
27675
- if (n >= minPairs && ms <= HOOK_P95_MS) break;
27683
+ fastBare = Math.round(Math.min(...bareWalls));
27684
+ ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
27685
+ bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
27686
+ if (n >= minPairs && ms <= bound) break;
27676
27687
  }
27677
- if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
27688
+ if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
27678
27689
  const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
27679
27690
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
27691
+ if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
27680
27692
  return row("PASS", DOCTOR_PASS_DETAIL);
27681
27693
  }
27682
27694
 
@@ -27904,7 +27916,7 @@ function unsupportedHostOf(sig) {
27904
27916
  // src/core/ops/doctor-issue.ts
27905
27917
  import { spawnSync as spawnSync3 } from "node:child_process";
27906
27918
  import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync15, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27907
- import { delimiter, join as join18 } from "node:path";
27919
+ import { delimiter, dirname as dirname10, join as join18 } from "node:path";
27908
27920
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27909
27921
  function tildeOf(env) {
27910
27922
  const home = homeDirOf(env);
@@ -27927,13 +27939,28 @@ function maskLine(line) {
27927
27939
  const at2 = Math.max(line.indexOf(":"), line.indexOf("="));
27928
27940
  return at2 === -1 ? DOCTOR_MASK : line.slice(0, at2 + 1) + " " + DOCTOR_MASK;
27929
27941
  }
27930
- function environmentLine(ctx, adapter, env, version2) {
27942
+ async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
27943
+ if (host.bun === void 0) return { node: host.node };
27944
+ const node = findRuntime("javascript", env);
27945
+ if (node === null) return { node: host.node, bun: host.bun, pathNode: null };
27946
+ const childEnv = {};
27947
+ for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
27948
+ const r = await runProcess([node, "--version"], { cwd: dirname10(node), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
27949
+ const out = r.stdout.toString("utf8").trim();
27950
+ return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
27951
+ }
27952
+ function environmentLine(ctx, adapter, env, version2, rt) {
27931
27953
  const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
27932
27954
  const client = ctx.clientInfo;
27933
27955
  const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
27934
27956
  const shell = env.SHELL ?? env.ComSpec ?? "sh";
27935
- return `${DOCTOR_ENV_PREFIX}context-mode ${version2 ?? "source checkout"} (${sha}), agent ${agent}
27936
- ${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}, Node ${process.version}, shell ${shell}`;
27957
+ const what = `${DOCTOR_ENV_PREFIX}context-mode ${version2 ?? "source checkout"} (${sha}), agent ${agent}
27958
+ `;
27959
+ const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
27960
+ if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
27961
+ const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
27962
+ return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
27963
+ ${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
27937
27964
  }
27938
27965
  function gitVersion(env) {
27939
27966
  const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
@@ -28203,11 +28230,12 @@ function reportEnv(env) {
28203
28230
  }
28204
28231
  async function doctorReply(ctx, host) {
28205
28232
  const adapter = getAdapter(ctx.project.agent);
28233
+ const runtime = runtimeInfo(host.env, ctx.signal);
28206
28234
  const rows = await runDoctorChecks(ctx, adapter, host);
28207
28235
  const failed = rows.some((r) => r.status === "FAIL");
28208
28236
  const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
28209
28237
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
28210
- const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
28238
+ const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
28211
28239
  const table3 = buildReport(input);
28212
28240
  let notes = [];
28213
28241
  if (failed) {
@@ -28246,7 +28274,7 @@ var ctxDoctor = Object.freeze({
28246
28274
  // src/core/tools/execute.ts
28247
28275
  import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
28248
28276
  import { tmpdir as tmpdir3 } from "node:os";
28249
- import { dirname as dirname11, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
28277
+ import { dirname as dirname12, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
28250
28278
 
28251
28279
  // src/core/sandbox/win-build.ts
28252
28280
  var SEPARATORS2 = ";&|(\n";
@@ -28329,7 +28357,7 @@ function schemaLine(issue2) {
28329
28357
  }
28330
28358
  function fileError(given, abs, root) {
28331
28359
  let dir = abs;
28332
- while (!existsSync17(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
28360
+ while (!existsSync17(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
28333
28361
  if (isInside(root, dir)) return null;
28334
28362
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
28335
28363
  }
@@ -28448,7 +28476,7 @@ var ctxExecute = {
28448
28476
 
28449
28477
  // src/core/tools/index.ts
28450
28478
  import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
28451
- import { dirname as dirname12, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28479
+ import { dirname as dirname13, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28452
28480
 
28453
28481
  // src/core/index/walk.ts
28454
28482
  import { readdirSync as readdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
@@ -32648,7 +32676,7 @@ function readUtf8(absPath) {
32648
32676
  }
32649
32677
  function missingOrOutside(given, abs, root) {
32650
32678
  let dir = abs;
32651
- while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
32679
+ while (!existsSync18(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
32652
32680
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32653
32681
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32654
32682
  }
@@ -33200,7 +33228,7 @@ var ctxStats = Object.freeze({
33200
33228
 
33201
33229
  // src/core/ops/host-write.ts
33202
33230
  import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33203
- import { dirname as dirname13, join as join23 } from "node:path";
33231
+ import { dirname as dirname14, join as join23 } from "node:path";
33204
33232
  function defaultWrite(file2, text) {
33205
33233
  writeFileSync6(file2, text, "utf8");
33206
33234
  }
@@ -33232,7 +33260,7 @@ function writeWithRollback(file2, text, write2, atomic) {
33232
33260
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
33233
33261
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
33234
33262
  const had = existsSync19(file2);
33235
- mkdirSync8(dirname13(file2), { recursive: true });
33263
+ mkdirSync8(dirname14(file2), { recursive: true });
33236
33264
  if (had) copyFileSync(file2, trash);
33237
33265
  try {
33238
33266
  write2(tmp, text);
package/package.json CHANGED
@@ -69,5 +69,5 @@
69
69
  "url": "git+https://github.com/mksglu/context-mode.git"
70
70
  },
71
71
  "type": "module",
72
- "version": "2.1.9"
72
+ "version": "2.1.10"
73
73
  }
package/pi/index.js CHANGED
@@ -11625,7 +11625,7 @@ var DECISION_ANSWERS_KEY = "answers";
11625
11625
  var DECISION_OPTION_KEY = "option";
11626
11626
  var DECISION_LABEL_JOIN = " | ";
11627
11627
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11628
- var BUNDLE_SHA = true ? "9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde" : void 0;
11628
+ var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
11629
11629
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11630
11630
  var DOCTOR_LABEL = Object.freeze({
11631
11631
  D1: "version",
@@ -11971,9 +11971,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
11971
11971
  var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
11972
11972
  var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
11973
11973
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
11974
- function D5_SLOW_DETAIL(ms) {
11975
- return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
11974
+ var D5_BARE_SHARE = 0.5;
11975
+ function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
11976
+ return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
11976
11977
  }
11978
+ function D5_SLOW_START_DETAIL(ms, bare2, bound) {
11979
+ return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
11980
+ }
11981
+ var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
11977
11982
  var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
11978
11983
  var D5_FIX = "run ctx_upgrade";
11979
11984
  var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
@@ -27662,10 +27667,13 @@ async function checkHookRoundTrip(i) {
27662
27667
  await runProcess([node3.file, "-e", ""], { cwd: i.bundleDir, env: node3.env, signal: i.signal, timeoutMs });
27663
27668
  return performance.now() - t;
27664
27669
  });
27670
+ const inProcess = getAdapter(i.agent).installMode === "in-process";
27665
27671
  const hookWalls = [];
27666
27672
  const bareWalls = [];
27667
27673
  let ms = 0;
27668
- for (let n = 1; n <= maxPairs; n++) {
27674
+ let fastBare = 0;
27675
+ let bound = HOOK_P95_MS;
27676
+ for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
27669
27677
  const start = now();
27670
27678
  const node3 = nodeLaunch(i.env);
27671
27679
  const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
@@ -27677,13 +27685,17 @@ async function checkHookRoundTrip(i) {
27677
27685
  });
27678
27686
  hookWalls.push(now() - start);
27679
27687
  if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
27688
+ if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
27680
27689
  bareWalls.push(await bareMs());
27681
- ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
27682
- if (n >= minPairs && ms <= HOOK_P95_MS) break;
27690
+ fastBare = Math.round(Math.min(...bareWalls));
27691
+ ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
27692
+ bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
27693
+ if (n >= minPairs && ms <= bound) break;
27683
27694
  }
27684
- if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
27695
+ if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
27685
27696
  const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
27686
27697
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
27698
+ if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
27687
27699
  return row("PASS", DOCTOR_PASS_DETAIL);
27688
27700
  }
27689
27701
 
@@ -27921,7 +27933,7 @@ function unsupportedHostOf(sig) {
27921
27933
  // src/core/ops/doctor-issue.ts
27922
27934
  import { spawnSync as spawnSync3 } from "node:child_process";
27923
27935
  import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync15, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27924
- import { delimiter, join as join18 } from "node:path";
27936
+ import { delimiter, dirname as dirname10, join as join18 } from "node:path";
27925
27937
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27926
27938
  function tildeOf(env) {
27927
27939
  const home = homeDirOf(env);
@@ -27944,13 +27956,28 @@ function maskLine(line) {
27944
27956
  const at2 = Math.max(line.indexOf(":"), line.indexOf("="));
27945
27957
  return at2 === -1 ? DOCTOR_MASK : line.slice(0, at2 + 1) + " " + DOCTOR_MASK;
27946
27958
  }
27947
- function environmentLine(ctx, adapter, env, version4) {
27959
+ async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
27960
+ if (host.bun === void 0) return { node: host.node };
27961
+ const node3 = findRuntime("javascript", env);
27962
+ if (node3 === null) return { node: host.node, bun: host.bun, pathNode: null };
27963
+ const childEnv = {};
27964
+ for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
27965
+ const r = await runProcess([node3, "--version"], { cwd: dirname10(node3), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
27966
+ const out = r.stdout.toString("utf8").trim();
27967
+ return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
27968
+ }
27969
+ function environmentLine(ctx, adapter, env, version4, rt) {
27948
27970
  const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
27949
27971
  const client = ctx.clientInfo;
27950
27972
  const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
27951
27973
  const shell = env.SHELL ?? env.ComSpec ?? "sh";
27952
- return `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
27953
- ${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}, Node ${process.version}, shell ${shell}`;
27974
+ const what = `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
27975
+ `;
27976
+ const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
27977
+ if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
27978
+ const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
27979
+ return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
27980
+ ${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
27954
27981
  }
27955
27982
  function gitVersion(env) {
27956
27983
  const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
@@ -28220,11 +28247,12 @@ function reportEnv(env) {
28220
28247
  }
28221
28248
  async function doctorReply(ctx, host) {
28222
28249
  const adapter = getAdapter(ctx.project.agent);
28250
+ const runtime = runtimeInfo(host.env, ctx.signal);
28223
28251
  const rows = await runDoctorChecks(ctx, adapter, host);
28224
28252
  const failed = rows.some((r) => r.status === "FAIL");
28225
28253
  const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
28226
28254
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
28227
- const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
28255
+ const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
28228
28256
  const table3 = buildReport(input);
28229
28257
  let notes = [];
28230
28258
  if (failed) {
@@ -28263,7 +28291,7 @@ var ctxDoctor = Object.freeze({
28263
28291
  // src/core/tools/execute.ts
28264
28292
  import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
28265
28293
  import { tmpdir as tmpdir3 } from "node:os";
28266
- import { dirname as dirname11, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
28294
+ import { dirname as dirname12, join as join20, parse as parse3, resolve as resolve11 } from "node:path";
28267
28295
 
28268
28296
  // src/core/sandbox/win-build.ts
28269
28297
  var SEPARATORS2 = ";&|(\n";
@@ -28346,7 +28374,7 @@ function schemaLine(issue4) {
28346
28374
  }
28347
28375
  function fileError(given, abs, root) {
28348
28376
  let dir = abs;
28349
- while (!existsSync17(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
28377
+ while (!existsSync17(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
28350
28378
  if (isInside(root, dir)) return null;
28351
28379
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
28352
28380
  }
@@ -28465,7 +28493,7 @@ var ctxExecute = {
28465
28493
 
28466
28494
  // src/core/tools/index.ts
28467
28495
  import { existsSync as existsSync18, readFileSync as readFileSync18, statSync as statSync8 } from "node:fs";
28468
- import { dirname as dirname12, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28496
+ import { dirname as dirname13, extname as extname3, join as join22, relative as relative5, resolve as resolve12 } from "node:path";
28469
28497
 
28470
28498
  // src/core/index/walk.ts
28471
28499
  import { readdirSync as readdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
@@ -32665,7 +32693,7 @@ function readUtf8(absPath) {
32665
32693
  }
32666
32694
  function missingOrOutside(given, abs, root) {
32667
32695
  let dir = abs;
32668
- while (!existsSync18(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
32696
+ while (!existsSync18(dir) && dirname13(dir) !== dir) dir = dirname13(dir);
32669
32697
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32670
32698
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32671
32699
  }
@@ -33217,7 +33245,7 @@ var ctxStats = Object.freeze({
33217
33245
 
33218
33246
  // src/core/ops/host-write.ts
33219
33247
  import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
33220
- import { dirname as dirname13, join as join23 } from "node:path";
33248
+ import { dirname as dirname14, join as join23 } from "node:path";
33221
33249
  function defaultWrite(file2, text) {
33222
33250
  writeFileSync6(file2, text, "utf8");
33223
33251
  }
@@ -33249,7 +33277,7 @@ function writeWithRollback(file2, text, write2, atomic) {
33249
33277
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
33250
33278
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
33251
33279
  const had = existsSync19(file2);
33252
- mkdirSync8(dirname13(file2), { recursive: true });
33280
+ mkdirSync8(dirname14(file2), { recursive: true });
33253
33281
  if (had) copyFileSync(file2, trash);
33254
33282
  try {
33255
33283
  write2(tmp, text);
@@ -33678,7 +33706,7 @@ function checkCall(tool, input) {
33678
33706
  // src/entries/server.ts
33679
33707
  import { randomUUID } from "node:crypto";
33680
33708
  import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33681
- import { dirname as dirname14, join as join26 } from "node:path";
33709
+ import { dirname as dirname15, join as join26 } from "node:path";
33682
33710
  import { fileURLToPath as fileURLToPath3 } from "node:url";
33683
33711
 
33684
33712
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -61940,7 +61968,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
61940
61968
  const fromHost = workspaceFromMeta(meta3);
61941
61969
  if (fromHost !== void 0) return fromHost;
61942
61970
  if (script === void 0 || script === "") return spawnCwd;
61943
- return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
61971
+ return realOrSame(spawnCwd) === realOrSame(dirname15(script)) ? "" : spawnCwd;
61944
61972
  }
61945
61973
  function errorReply(err) {
61946
61974
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
@@ -12,5 +12,5 @@
12
12
  }
13
13
  },
14
14
  "name": "context-mode",
15
- "version": "2.1.9"
15
+ "version": "2.1.10"
16
16
  }
package/server.mjs CHANGED
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  // src/entries/server.ts
9
9
  import { randomUUID } from "node:crypto";
10
10
  import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
11
- import { dirname as dirname13, join as join23 } from "node:path";
11
+ import { dirname as dirname14, join as join23 } 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
@@ -28446,7 +28446,7 @@ function PURGE_SUMMARY(rows, scope) {
28446
28446
  var DECISION_SOURCE = "decision";
28447
28447
  var DECISION_USER_LABEL = "decision (user)";
28448
28448
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
28449
- var BUNDLE_SHA = true ? "9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde" : void 0;
28449
+ var BUNDLE_SHA = true ? "877eebcc432f90882c2b5ea04ad22fc95e9dc6c2" : void 0;
28450
28450
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
28451
28451
  var DOCTOR_LABEL = Object.freeze({
28452
28452
  D1: "version",
@@ -28791,9 +28791,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
28791
28791
  var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
28792
28792
  var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
28793
28793
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
28794
- function D5_SLOW_DETAIL(ms) {
28795
- return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
28794
+ var D5_BARE_SHARE = 0.5;
28795
+ function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
28796
+ return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
28796
28797
  }
28798
+ function D5_SLOW_START_DETAIL(ms, bare2, bound) {
28799
+ return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
28800
+ }
28801
+ var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
28797
28802
  var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
28798
28803
  var D5_FIX = "run ctx_upgrade";
28799
28804
  var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
@@ -52215,10 +52220,13 @@ async function checkHookRoundTrip(i) {
52215
52220
  await runProcess([node3.file, "-e", ""], { cwd: i.bundleDir, env: node3.env, signal: i.signal, timeoutMs });
52216
52221
  return performance.now() - t;
52217
52222
  });
52223
+ const inProcess = getAdapter(i.agent).installMode === "in-process";
52218
52224
  const hookWalls = [];
52219
52225
  const bareWalls = [];
52220
52226
  let ms = 0;
52221
- for (let n = 1; n <= maxPairs; n++) {
52227
+ let fastBare = 0;
52228
+ let bound = HOOK_P95_MS;
52229
+ for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
52222
52230
  const start = now();
52223
52231
  const node3 = nodeLaunch(i.env);
52224
52232
  const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
@@ -52230,13 +52238,17 @@ async function checkHookRoundTrip(i) {
52230
52238
  });
52231
52239
  hookWalls.push(now() - start);
52232
52240
  if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
52241
+ if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
52233
52242
  bareWalls.push(await bareMs());
52234
- ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
52235
- if (n >= minPairs && ms <= HOOK_P95_MS) break;
52243
+ fastBare = Math.round(Math.min(...bareWalls));
52244
+ ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
52245
+ bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
52246
+ if (n >= minPairs && ms <= bound) break;
52236
52247
  }
52237
- if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
52248
+ if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
52238
52249
  const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
52239
52250
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
52251
+ if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
52240
52252
  return row("PASS", DOCTOR_PASS_DETAIL);
52241
52253
  }
52242
52254
 
@@ -52463,7 +52475,7 @@ function unsupportedHostOf(sig) {
52463
52475
  // src/core/ops/doctor-issue.ts
52464
52476
  import { spawnSync as spawnSync3 } from "node:child_process";
52465
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";
52466
- import { delimiter, join as join16 } from "node:path";
52478
+ import { delimiter, dirname as dirname9, join as join16 } from "node:path";
52467
52479
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
52468
52480
  function tildeOf(env) {
52469
52481
  const home = homeDirOf(env);
@@ -52486,13 +52498,28 @@ function maskLine(line) {
52486
52498
  const at = Math.max(line.indexOf(":"), line.indexOf("="));
52487
52499
  return at === -1 ? DOCTOR_MASK : line.slice(0, at + 1) + " " + DOCTOR_MASK;
52488
52500
  }
52489
- function environmentLine(ctx, adapter, env, version4) {
52501
+ async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
52502
+ if (host.bun === void 0) return { node: host.node };
52503
+ const node3 = findRuntime("javascript", env);
52504
+ if (node3 === null) return { node: host.node, bun: host.bun, pathNode: null };
52505
+ const childEnv = {};
52506
+ for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
52507
+ const r = await runProcess([node3, "--version"], { cwd: dirname9(node3), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
52508
+ const out = r.stdout.toString("utf8").trim();
52509
+ return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
52510
+ }
52511
+ function environmentLine(ctx, adapter, env, version4, rt) {
52490
52512
  const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
52491
52513
  const client = ctx.clientInfo;
52492
52514
  const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
52493
52515
  const shell = env.SHELL ?? env.ComSpec ?? "sh";
52494
- return `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
52495
- ${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}, Node ${process.version}, shell ${shell}`;
52516
+ const what = `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
52517
+ `;
52518
+ const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
52519
+ if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
52520
+ const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
52521
+ return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
52522
+ ${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
52496
52523
  }
52497
52524
  function gitVersion(env) {
52498
52525
  const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
@@ -52781,11 +52808,12 @@ function reportEnv(env) {
52781
52808
  }
52782
52809
  async function doctorReply(ctx, host) {
52783
52810
  const adapter = getAdapter(ctx.project.agent);
52811
+ const runtime = runtimeInfo(host.env, ctx.signal);
52784
52812
  const rows = await runDoctorChecks(ctx, adapter, host);
52785
52813
  const failed = rows.some((r) => r.status === "FAIL");
52786
52814
  const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
52787
52815
  const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
52788
- const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
52816
+ const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
52789
52817
  const table3 = buildReport(input);
52790
52818
  let notes = [];
52791
52819
  if (failed) {
@@ -52824,7 +52852,7 @@ var ctxDoctor = Object.freeze({
52824
52852
  // src/core/tools/execute.ts
52825
52853
  import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
52826
52854
  import { tmpdir as tmpdir3 } from "node:os";
52827
- import { dirname as dirname10, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
52855
+ import { dirname as dirname11, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
52828
52856
 
52829
52857
  // src/core/index/select.ts
52830
52858
  var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
@@ -52946,7 +52974,7 @@ function schemaLine(issue4) {
52946
52974
  }
52947
52975
  function fileError(given, abs, root) {
52948
52976
  let dir = abs;
52949
- while (!existsSync18(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
52977
+ while (!existsSync18(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
52950
52978
  if (isInside(root, dir)) return null;
52951
52979
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
52952
52980
  }
@@ -53065,7 +53093,7 @@ var ctxExecute = {
53065
53093
 
53066
53094
  // src/core/tools/index.ts
53067
53095
  import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
53068
- import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
53096
+ import { dirname as dirname12, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
53069
53097
 
53070
53098
  // src/core/index/walk.ts
53071
53099
  import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
@@ -57265,7 +57293,7 @@ function readUtf8(absPath) {
57265
57293
  }
57266
57294
  function missingOrOutside(given, abs, root) {
57267
57295
  let dir = abs;
57268
- while (!existsSync19(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
57296
+ while (!existsSync19(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
57269
57297
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
57270
57298
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
57271
57299
  }
@@ -58077,7 +58105,7 @@ var ctxStats = Object.freeze({
58077
58105
 
58078
58106
  // src/core/ops/host-write.ts
58079
58107
  import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
58080
- import { dirname as dirname12, join as join21 } from "node:path";
58108
+ import { dirname as dirname13, join as join21 } from "node:path";
58081
58109
  function defaultWrite(file2, text) {
58082
58110
  writeFileSync6(file2, text, "utf8");
58083
58111
  }
@@ -58109,7 +58137,7 @@ function writeWithRollback(file2, text, write, atomic) {
58109
58137
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
58110
58138
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
58111
58139
  const had = existsSync20(file2);
58112
- mkdirSync8(dirname12(file2), { recursive: true });
58140
+ mkdirSync8(dirname13(file2), { recursive: true });
58113
58141
  if (had) copyFileSync(file2, trash);
58114
58142
  try {
58115
58143
  write(tmp, text);
@@ -58643,7 +58671,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
58643
58671
  const fromHost = workspaceFromMeta(meta3);
58644
58672
  if (fromHost !== void 0) return fromHost;
58645
58673
  if (script === void 0 || script === "") return spawnCwd;
58646
- return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
58674
+ return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
58647
58675
  }
58648
58676
  function errorReply(err) {
58649
58677
  if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };