context-mode 2.1.10 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Context window saver for 10 coding agents. Local and free: sandboxed code execution, FTS5 search, session continuity.",
2
+ "description": "Context window saver for 11 coding agents. Local and free: sandboxed code execution, FTS5 search, session continuity.",
3
3
  "hooks": "hooks/qwen.json",
4
4
  "mcpServers": {
5
5
  "context-mode": {
@@ -12,5 +12,5 @@
12
12
  }
13
13
  },
14
14
  "name": "context-mode",
15
- "version": "2.1.10"
15
+ "version": "2.2.0"
16
16
  }
package/run.mjs CHANGED
@@ -293,6 +293,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
293
293
  qwen: READ_IMAGES_AND_PDF,
294
294
  opencode: READ_IMAGES_AND_PDF,
295
295
  pi: READ_IMAGES,
296
+ omp: READ_IMAGES,
296
297
  vscode: READ_IMAGES,
297
298
  zcode: READ_IMAGES,
298
299
  "copilot-cli": [],
@@ -362,7 +363,9 @@ var AGENT_HOME_DIR = Object.freeze({
362
363
  kiro: [".kiro"],
363
364
  zcode: [".zcode"],
364
365
  pi: [".pi"],
365
- opencode: [".config", "opencode"]
366
+ opencode: [".config", "opencode"],
367
+ omp: [".omp"]
368
+ // ADR-0026: OMP data and plugins live under ~/.omp
366
369
  });
367
370
  var UPGRADE_MODES = Object.freeze(["upgrade", "uninstall"]);
368
371
  var GIT_CLONE_ARGS = Object.freeze(["clone", "--depth", "1", "--branch"]);
@@ -407,16 +410,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
407
410
  binaries: [],
408
411
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
409
412
  }),
410
- unsupported({
411
- id: "omp",
412
- name: "OMP (oh-my-pi)",
413
- clientNames: ["omp-coding-agent"],
414
- envVars: [],
415
- pluginPaths: [],
416
- configDirs: [".omp"],
417
- binaries: ["omp"],
418
- 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)"
419
- }),
420
413
  unsupported({
421
414
  id: "openclaw",
422
415
  name: "OpenClaw",
@@ -478,7 +471,9 @@ var HOOK_HOST_FILE = Object.freeze({
478
471
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
479
472
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
480
473
  pi: null,
481
- opencode: null
474
+ opencode: null,
475
+ omp: null
476
+ // ADR-0026: in-process, no hook file
482
477
  });
483
478
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
484
479
  var KIRO_TOOL_MATCHERS = Object.freeze([["@mcp", "mcp"], ["shell", "shell"]]);
@@ -490,6 +485,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
490
485
  gemini: "gemini extensions update context-mode",
491
486
  qwen: "qwen extensions update context-mode",
492
487
  pi: "pi update --extensions",
488
+ omp: "omp plugin upgrade context-mode",
489
+ // ADR-0026 decision 4: OMP native update
493
490
  opencode: "opencode plugin update",
494
491
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
495
492
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -655,6 +652,8 @@ var NATIVE_INSTALL = Object.freeze({
655
652
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
656
653
  opencode: ["opencode plugin add context-mode"],
657
654
  pi: ["pi install npm:context-mode"],
655
+ omp: ["omp plugin install context-mode"],
656
+ // ADR-0026 decision 4: OMP native install
658
657
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
659
658
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
660
659
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -1386,6 +1385,9 @@ function readResult6(p) {
1386
1385
  if (p.keep === true) info.keep = true;
1387
1386
  return info;
1388
1387
  }
1388
+ function decodeOmp(raw) {
1389
+ return { ...decode9(raw), agent: "omp" };
1390
+ }
1389
1391
  function decode9(raw) {
1390
1392
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
1391
1393
  const p = raw;
@@ -1687,14 +1689,36 @@ var ADAPTERS = Object.freeze([
1687
1689
  decode: decode10,
1688
1690
  encode: encode10,
1689
1691
  toCanonicalTool
1692
+ },
1693
+ {
1694
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
1695
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
1696
+ id: "omp",
1697
+ installMode: "in-process",
1698
+ projectSource: "pi:ctx.cwd",
1699
+ toolNamePrefix: TOOL_NAME_PREFIX9,
1700
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
1701
+ execReadOnlyHint: false,
1702
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
1703
+ compactDelivery: "pi-flag",
1704
+ compactSummary: "none",
1705
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
1706
+ denyChannel: "deny-reason",
1707
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
1708
+ skillChannel: { kind: "package", path: "skills" },
1709
+ // D-OMP-SKILLS-1
1710
+ decode: decodeOmp,
1711
+ encode: encode9,
1712
+ checkPermission
1713
+ // D-OMP-FIRE-1: agent omp in rows
1690
1714
  }
1691
1715
  ]);
1692
1716
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
1693
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
1717
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
1694
1718
  function hasReplace(row) {
1695
1719
  return REPLACE_ROWS.has(row.id);
1696
1720
  }
1697
- var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi"]);
1721
+ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi", "omp"]);
1698
1722
  function dumpRunsThenReplaces(row) {
1699
1723
  return DUMP_REPLACE_ROWS.has(row.id) && hasReplace(row);
1700
1724
  }
@@ -6042,6 +6066,7 @@ function sourceOf(agent) {
6042
6066
  case "opencode":
6043
6067
  return "spawn-cwd";
6044
6068
  case "pi":
6069
+ case "omp":
6045
6070
  return "pi:ctx.cwd";
6046
6071
  }
6047
6072
  }
@@ -6233,22 +6258,34 @@ function fileNames(name, pathExt) {
6233
6258
  if (!isWin() || path.extname(name) !== "") return [name];
6234
6259
  return [...pathExt.map((ext) => name + ext), name];
6235
6260
  }
6236
- function isRunnable(full) {
6237
- const st = statSync3(full, { throwIfNoEntry: false });
6238
- if (st === void 0 || !st.isFile()) return false;
6261
+ function probe(full) {
6262
+ let st;
6263
+ try {
6264
+ st = statSync3(full, { throwIfNoEntry: false });
6265
+ } catch {
6266
+ return "unreadable";
6267
+ }
6268
+ if (st === void 0 || !st.isFile()) return "absent";
6239
6269
  if (isWin()) {
6240
6270
  const ext = path.extname(full).toLowerCase();
6241
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
6271
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
6242
6272
  }
6243
6273
  try {
6244
6274
  accessSync(full, fsConstants.X_OK);
6245
- return true;
6275
+ return "runnable";
6246
6276
  } catch {
6247
- return false;
6277
+ return "absent";
6248
6278
  }
6249
6279
  }
6280
+ function isRunnable(full) {
6281
+ return probe(full) === "runnable";
6282
+ }
6250
6283
  function findRuntime(lang, env = process.env) {
6251
- if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
6284
+ return lookupRuntime(lang, env).found;
6285
+ }
6286
+ function lookupRuntime(lang, env = process.env) {
6287
+ const unreadable = [];
6288
+ if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
6252
6289
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
6253
6290
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
6254
6291
  const names = candidates(lang);
@@ -6257,13 +6294,15 @@ function findRuntime(lang, env = process.env) {
6257
6294
  for (const name of names) {
6258
6295
  for (const file of fileNames(name, pathExt)) {
6259
6296
  const full = path.join(dir, file);
6260
- if (!isRunnable(full)) continue;
6261
- if (!isWin() || path.extname(full) !== "") return full;
6297
+ const state = probe(full);
6298
+ if (state === "unreadable") unreadable.push(full);
6299
+ if (state !== "runnable") continue;
6300
+ if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
6262
6301
  if (shim === null) shim = full;
6263
6302
  }
6264
6303
  }
6265
6304
  }
6266
- return shim;
6305
+ return { found: shim, unreadable };
6267
6306
  }
6268
6307
  function findGitBash(env) {
6269
6308
  const git2 = findRuntime(GIT_BIN, env);
@@ -6343,7 +6382,7 @@ function runProcess(argv, o) {
6343
6382
  let stopTimer;
6344
6383
  const kill = () => {
6345
6384
  if (child.pid !== void 0) killTree(child.pid);
6346
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
6385
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
6347
6386
  };
6348
6387
  const onAbort = () => {
6349
6388
  if (killedBy !== null || settled) return;
@@ -6372,15 +6411,21 @@ function runProcess(argv, o) {
6372
6411
  ...held ? { held: true } : {}
6373
6412
  });
6374
6413
  };
6375
- const finishHeld = () => {
6414
+ const finishHeld = (force = false) => {
6376
6415
  if (settled) return;
6377
- held = exited && killedBy === null;
6378
- child.stdout.destroy();
6379
- child.stderr.destroy();
6380
- if (child.pid !== void 0) killTree(child.pid);
6381
- settle(child.exitCode);
6416
+ const seen = chunkCount;
6417
+ setImmediate(() => {
6418
+ if (settled || !force && chunkCount !== seen) return;
6419
+ held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
6420
+ child.stdout.destroy();
6421
+ child.stderr.destroy();
6422
+ if (child.pid !== void 0) killTree(child.pid);
6423
+ settle(child.exitCode);
6424
+ });
6382
6425
  };
6426
+ let chunkCount = 0;
6383
6427
  const bump = () => {
6428
+ chunkCount++;
6384
6429
  if (!exited || settled) return;
6385
6430
  clearTimeout(graceTimer);
6386
6431
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -6398,7 +6443,7 @@ function runProcess(argv, o) {
6398
6443
  if (settled) return;
6399
6444
  exited = true;
6400
6445
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
6401
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
6446
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
6402
6447
  });
6403
6448
  child.on("error", () => settle(null));
6404
6449
  child.stdin.on("error", () => {
package/search.mjs CHANGED
@@ -293,6 +293,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
293
293
  qwen: READ_IMAGES_AND_PDF,
294
294
  opencode: READ_IMAGES_AND_PDF,
295
295
  pi: READ_IMAGES,
296
+ omp: READ_IMAGES,
296
297
  vscode: READ_IMAGES,
297
298
  zcode: READ_IMAGES,
298
299
  "copilot-cli": [],
@@ -362,7 +363,9 @@ var AGENT_HOME_DIR = Object.freeze({
362
363
  kiro: [".kiro"],
363
364
  zcode: [".zcode"],
364
365
  pi: [".pi"],
365
- opencode: [".config", "opencode"]
366
+ opencode: [".config", "opencode"],
367
+ omp: [".omp"]
368
+ // ADR-0026: OMP data and plugins live under ~/.omp
366
369
  });
367
370
  var UPGRADE_MODES = Object.freeze(["upgrade", "uninstall"]);
368
371
  var GIT_CLONE_ARGS = Object.freeze(["clone", "--depth", "1", "--branch"]);
@@ -407,16 +410,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
407
410
  binaries: [],
408
411
  source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
409
412
  }),
410
- unsupported({
411
- id: "omp",
412
- name: "OMP (oh-my-pi)",
413
- clientNames: ["omp-coding-agent"],
414
- envVars: [],
415
- pluginPaths: [],
416
- configDirs: [".omp"],
417
- binaries: ["omp"],
418
- 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)"
419
- }),
420
413
  unsupported({
421
414
  id: "openclaw",
422
415
  name: "OpenClaw",
@@ -478,7 +471,9 @@ var HOOK_HOST_FILE = Object.freeze({
478
471
  kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
479
472
  zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
480
473
  pi: null,
481
- opencode: null
474
+ opencode: null,
475
+ omp: null
476
+ // ADR-0026: in-process, no hook file
482
477
  });
483
478
  var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
484
479
  var KIRO_TOOL_MATCHERS = Object.freeze([["@mcp", "mcp"], ["shell", "shell"]]);
@@ -490,6 +485,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
490
485
  gemini: "gemini extensions update context-mode",
491
486
  qwen: "qwen extensions update context-mode",
492
487
  pi: "pi update --extensions",
488
+ omp: "omp plugin upgrade context-mode",
489
+ // ADR-0026 decision 4: OMP native update
493
490
  opencode: "opencode plugin update",
494
491
  "copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
495
492
  vscode: "npm i -g context-mode && context-mode setup --agents vscode",
@@ -655,6 +652,8 @@ var NATIVE_INSTALL = Object.freeze({
655
652
  qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
656
653
  opencode: ["opencode plugin add context-mode"],
657
654
  pi: ["pi install npm:context-mode"],
655
+ omp: ["omp plugin install context-mode"],
656
+ // ADR-0026 decision 4: OMP native install
658
657
  "copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
659
658
  vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
660
659
  kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
@@ -1386,6 +1385,9 @@ function readResult6(p) {
1386
1385
  if (p.keep === true) info.keep = true;
1387
1386
  return info;
1388
1387
  }
1388
+ function decodeOmp(raw) {
1389
+ return { ...decode9(raw), agent: "omp" };
1390
+ }
1389
1391
  function decode9(raw) {
1390
1392
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
1391
1393
  const p = raw;
@@ -1687,14 +1689,36 @@ var ADAPTERS = Object.freeze([
1687
1689
  decode: decode10,
1688
1690
  encode: encode10,
1689
1691
  toCanonicalTool
1692
+ },
1693
+ {
1694
+ // ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
1695
+ // permission check; tool names stay bare. Only the entry path and the skills folder are its own.
1696
+ id: "omp",
1697
+ installMode: "in-process",
1698
+ projectSource: "pi:ctx.cwd",
1699
+ toolNamePrefix: TOOL_NAME_PREFIX9,
1700
+ nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
1701
+ execReadOnlyHint: false,
1702
+ eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
1703
+ compactDelivery: "pi-flag",
1704
+ compactSummary: "none",
1705
+ hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
1706
+ denyChannel: "deny-reason",
1707
+ hookChannel: { kind: "in-process", path: "omp/index.js" },
1708
+ skillChannel: { kind: "package", path: "skills" },
1709
+ // D-OMP-SKILLS-1
1710
+ decode: decodeOmp,
1711
+ encode: encode9,
1712
+ checkPermission
1713
+ // D-OMP-FIRE-1: agent omp in rows
1690
1714
  }
1691
1715
  ]);
1692
1716
  var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
1693
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
1717
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
1694
1718
  function hasReplace(row) {
1695
1719
  return REPLACE_ROWS.has(row.id);
1696
1720
  }
1697
- var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi"]);
1721
+ var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi", "omp"]);
1698
1722
  function dumpRunsThenReplaces(row) {
1699
1723
  return DUMP_REPLACE_ROWS.has(row.id) && hasReplace(row);
1700
1724
  }
@@ -6042,6 +6066,7 @@ function sourceOf(agent) {
6042
6066
  case "opencode":
6043
6067
  return "spawn-cwd";
6044
6068
  case "pi":
6069
+ case "omp":
6045
6070
  return "pi:ctx.cwd";
6046
6071
  }
6047
6072
  }
@@ -6233,22 +6258,34 @@ function fileNames(name, pathExt) {
6233
6258
  if (!isWin() || path.extname(name) !== "") return [name];
6234
6259
  return [...pathExt.map((ext) => name + ext), name];
6235
6260
  }
6236
- function isRunnable(full) {
6237
- const st = statSync3(full, { throwIfNoEntry: false });
6238
- if (st === void 0 || !st.isFile()) return false;
6261
+ function probe(full) {
6262
+ let st;
6263
+ try {
6264
+ st = statSync3(full, { throwIfNoEntry: false });
6265
+ } catch {
6266
+ return "unreadable";
6267
+ }
6268
+ if (st === void 0 || !st.isFile()) return "absent";
6239
6269
  if (isWin()) {
6240
6270
  const ext = path.extname(full).toLowerCase();
6241
- return ext === "" || WIN_STARTABLE_EXT.includes(ext);
6271
+ return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
6242
6272
  }
6243
6273
  try {
6244
6274
  accessSync(full, fsConstants.X_OK);
6245
- return true;
6275
+ return "runnable";
6246
6276
  } catch {
6247
- return false;
6277
+ return "absent";
6248
6278
  }
6249
6279
  }
6280
+ function isRunnable(full) {
6281
+ return probe(full) === "runnable";
6282
+ }
6250
6283
  function findRuntime(lang, env = process.env) {
6251
- if (isWin() && WIN_SHELL_LANGS.includes(lang)) return findGitBash(env);
6284
+ return lookupRuntime(lang, env).found;
6285
+ }
6286
+ function lookupRuntime(lang, env = process.env) {
6287
+ const unreadable = [];
6288
+ if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
6252
6289
  const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
6253
6290
  const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
6254
6291
  const names = candidates(lang);
@@ -6257,13 +6294,15 @@ function findRuntime(lang, env = process.env) {
6257
6294
  for (const name of names) {
6258
6295
  for (const file of fileNames(name, pathExt)) {
6259
6296
  const full = path.join(dir, file);
6260
- if (!isRunnable(full)) continue;
6261
- if (!isWin() || path.extname(full) !== "") return full;
6297
+ const state = probe(full);
6298
+ if (state === "unreadable") unreadable.push(full);
6299
+ if (state !== "runnable") continue;
6300
+ if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
6262
6301
  if (shim === null) shim = full;
6263
6302
  }
6264
6303
  }
6265
6304
  }
6266
- return shim;
6305
+ return { found: shim, unreadable };
6267
6306
  }
6268
6307
  function findGitBash(env) {
6269
6308
  const git2 = findRuntime(GIT_BIN, env);
@@ -6343,7 +6382,7 @@ function runProcess(argv, o) {
6343
6382
  let stopTimer;
6344
6383
  const kill = () => {
6345
6384
  if (child.pid !== void 0) killTree(child.pid);
6346
- if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
6385
+ if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
6347
6386
  };
6348
6387
  const onAbort = () => {
6349
6388
  if (killedBy !== null || settled) return;
@@ -6372,15 +6411,21 @@ function runProcess(argv, o) {
6372
6411
  ...held ? { held: true } : {}
6373
6412
  });
6374
6413
  };
6375
- const finishHeld = () => {
6414
+ const finishHeld = (force = false) => {
6376
6415
  if (settled) return;
6377
- held = exited && killedBy === null;
6378
- child.stdout.destroy();
6379
- child.stderr.destroy();
6380
- if (child.pid !== void 0) killTree(child.pid);
6381
- settle(child.exitCode);
6416
+ const seen = chunkCount;
6417
+ setImmediate(() => {
6418
+ if (settled || !force && chunkCount !== seen) return;
6419
+ held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
6420
+ child.stdout.destroy();
6421
+ child.stderr.destroy();
6422
+ if (child.pid !== void 0) killTree(child.pid);
6423
+ settle(child.exitCode);
6424
+ });
6382
6425
  };
6426
+ let chunkCount = 0;
6383
6427
  const bump = () => {
6428
+ chunkCount++;
6384
6429
  if (!exited || settled) return;
6385
6430
  clearTimeout(graceTimer);
6386
6431
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
@@ -6398,7 +6443,7 @@ function runProcess(argv, o) {
6398
6443
  if (settled) return;
6399
6444
  exited = true;
6400
6445
  graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
6401
- drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
6446
+ drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
6402
6447
  });
6403
6448
  child.on("error", () => settle(null));
6404
6449
  child.stdin.on("error", () => {