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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +2 -2
- package/.zcode-plugin/plugin.json +2 -2
- package/README.md +98 -79
- package/SHA256SUMS +21 -20
- package/cli.mjs +438 -99
- package/copilot/plugin.json +2 -2
- package/fixtures/hook-roundtrip.json +13 -0
- package/gemini-extension.json +2 -2
- package/hook.mjs +97 -97
- package/omp/index.js +5 -0
- package/opencode/plugin.js +823 -438
- package/package.json +9 -2
- package/pi/index.js +888 -465
- package/qwen-extension.json +2 -2
- package/run.mjs +136 -47
- package/search.mjs +136 -47
- package/server.mjs +704 -419
- package/skills/ctx-doctor/SKILL.md +1 -1
- package/skills/ctx-stats/SKILL.md +1 -1
- package/skills/ctx-upgrade/SKILL.md +1 -1
package/search.mjs
CHANGED
|
@@ -168,6 +168,10 @@ var DB_TIMEOUT_MS = 5e3;
|
|
|
168
168
|
var DB_WAL_SUFFIX = "-wal";
|
|
169
169
|
var DB_SHM_SUFFIX = "-shm";
|
|
170
170
|
var DB_TMP_SUFFIX = ".tmp";
|
|
171
|
+
var DB_LINK_DENIED_CODES = ["EACCES", "EPERM", "ENOSYS", "ENOTSUP", "EOPNOTSUPP"];
|
|
172
|
+
var DB_PUBLISH_CLAIM_SUFFIX = ".publish";
|
|
173
|
+
var DB_CLAIM_BUSY_CODES = ["EEXIST", "EPERM"];
|
|
174
|
+
var DB_PUBLISH_POLL_MS = 5;
|
|
171
175
|
var SQLITE_PRIMARY_CODE_MASK = 255;
|
|
172
176
|
var SQLITE_CORRUPT_CODE = 11;
|
|
173
177
|
var SQLITE_NOTADB_CODE = 26;
|
|
@@ -293,6 +297,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
|
|
|
293
297
|
qwen: READ_IMAGES_AND_PDF,
|
|
294
298
|
opencode: READ_IMAGES_AND_PDF,
|
|
295
299
|
pi: READ_IMAGES,
|
|
300
|
+
omp: READ_IMAGES,
|
|
296
301
|
vscode: READ_IMAGES,
|
|
297
302
|
zcode: READ_IMAGES,
|
|
298
303
|
"copilot-cli": [],
|
|
@@ -362,7 +367,9 @@ var AGENT_HOME_DIR = Object.freeze({
|
|
|
362
367
|
kiro: [".kiro"],
|
|
363
368
|
zcode: [".zcode"],
|
|
364
369
|
pi: [".pi"],
|
|
365
|
-
opencode: [".config", "opencode"]
|
|
370
|
+
opencode: [".config", "opencode"],
|
|
371
|
+
omp: [".omp"]
|
|
372
|
+
// ADR-0026: OMP data and plugins live under ~/.omp
|
|
366
373
|
});
|
|
367
374
|
var UPGRADE_MODES = Object.freeze(["upgrade", "uninstall"]);
|
|
368
375
|
var GIT_CLONE_ARGS = Object.freeze(["clone", "--depth", "1", "--branch"]);
|
|
@@ -407,16 +414,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
|
|
|
407
414
|
binaries: [],
|
|
408
415
|
source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
|
|
409
416
|
}),
|
|
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
417
|
unsupported({
|
|
421
418
|
id: "openclaw",
|
|
422
419
|
name: "OpenClaw",
|
|
@@ -478,7 +475,9 @@ var HOOK_HOST_FILE = Object.freeze({
|
|
|
478
475
|
kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
|
|
479
476
|
zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
|
|
480
477
|
pi: null,
|
|
481
|
-
opencode: null
|
|
478
|
+
opencode: null,
|
|
479
|
+
omp: null
|
|
480
|
+
// ADR-0026: in-process, no hook file
|
|
482
481
|
});
|
|
483
482
|
var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
|
|
484
483
|
var KIRO_TOOL_MATCHERS = Object.freeze([["@mcp", "mcp"], ["shell", "shell"]]);
|
|
@@ -490,6 +489,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
|
490
489
|
gemini: "gemini extensions update context-mode",
|
|
491
490
|
qwen: "qwen extensions update context-mode",
|
|
492
491
|
pi: "pi update --extensions",
|
|
492
|
+
omp: "omp plugin upgrade context-mode",
|
|
493
|
+
// ADR-0026 decision 4: OMP native update
|
|
493
494
|
opencode: "opencode plugin update",
|
|
494
495
|
"copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
|
|
495
496
|
vscode: "npm i -g context-mode && context-mode setup --agents vscode",
|
|
@@ -655,6 +656,8 @@ var NATIVE_INSTALL = Object.freeze({
|
|
|
655
656
|
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
|
|
656
657
|
opencode: ["opencode plugin add context-mode"],
|
|
657
658
|
pi: ["pi install npm:context-mode"],
|
|
659
|
+
omp: ["omp plugin install context-mode"],
|
|
660
|
+
// ADR-0026 decision 4: OMP native install
|
|
658
661
|
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
659
662
|
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
660
663
|
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
@@ -1386,6 +1389,9 @@ function readResult6(p) {
|
|
|
1386
1389
|
if (p.keep === true) info.keep = true;
|
|
1387
1390
|
return info;
|
|
1388
1391
|
}
|
|
1392
|
+
function decodeOmp(raw) {
|
|
1393
|
+
return { ...decode9(raw), agent: "omp" };
|
|
1394
|
+
}
|
|
1389
1395
|
function decode9(raw) {
|
|
1390
1396
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
|
|
1391
1397
|
const p = raw;
|
|
@@ -1687,14 +1693,36 @@ var ADAPTERS = Object.freeze([
|
|
|
1687
1693
|
decode: decode10,
|
|
1688
1694
|
encode: encode10,
|
|
1689
1695
|
toCanonicalTool
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
// ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
|
|
1699
|
+
// permission check; tool names stay bare. Only the entry path and the skills folder are its own.
|
|
1700
|
+
id: "omp",
|
|
1701
|
+
installMode: "in-process",
|
|
1702
|
+
projectSource: "pi:ctx.cwd",
|
|
1703
|
+
toolNamePrefix: TOOL_NAME_PREFIX9,
|
|
1704
|
+
nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
|
|
1705
|
+
execReadOnlyHint: false,
|
|
1706
|
+
eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
|
|
1707
|
+
compactDelivery: "pi-flag",
|
|
1708
|
+
compactSummary: "none",
|
|
1709
|
+
hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
|
|
1710
|
+
denyChannel: "deny-reason",
|
|
1711
|
+
hookChannel: { kind: "in-process", path: "omp/index.js" },
|
|
1712
|
+
skillChannel: { kind: "package", path: "skills" },
|
|
1713
|
+
// D-OMP-SKILLS-1
|
|
1714
|
+
decode: decodeOmp,
|
|
1715
|
+
encode: encode9,
|
|
1716
|
+
checkPermission
|
|
1717
|
+
// D-OMP-FIRE-1: agent omp in rows
|
|
1690
1718
|
}
|
|
1691
1719
|
]);
|
|
1692
1720
|
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"]);
|
|
1721
|
+
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
|
|
1694
1722
|
function hasReplace(row) {
|
|
1695
1723
|
return REPLACE_ROWS.has(row.id);
|
|
1696
1724
|
}
|
|
1697
|
-
var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi"]);
|
|
1725
|
+
var DUMP_REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "copilot-cli", "pi", "omp"]);
|
|
1698
1726
|
function dumpRunsThenReplaces(row) {
|
|
1699
1727
|
return DUMP_REPLACE_ROWS.has(row.id) && hasReplace(row);
|
|
1700
1728
|
}
|
|
@@ -1913,7 +1941,7 @@ function openReadOnlyHandle(sqlite, path3, opts = {}) {
|
|
|
1913
1941
|
}
|
|
1914
1942
|
|
|
1915
1943
|
// src/core/store/db.ts
|
|
1916
|
-
var { existsSync, linkSync, mkdirSync, rmSync } = process.getBuiltinModule("node:fs");
|
|
1944
|
+
var { existsSync, linkSync, mkdirSync, renameSync, rmSync, statSync } = process.getBuiltinModule("node:fs");
|
|
1917
1945
|
function versionParts(v) {
|
|
1918
1946
|
const bare = v.startsWith("v") ? v.slice(1) : v;
|
|
1919
1947
|
return bare.split(".").map((p) => Number.parseInt(p, 10));
|
|
@@ -1945,6 +1973,34 @@ function readUserVersion(raw) {
|
|
|
1945
1973
|
const row = raw.prepare("PRAGMA user_version").get();
|
|
1946
1974
|
return row.user_version;
|
|
1947
1975
|
}
|
|
1976
|
+
function errCode(err) {
|
|
1977
|
+
return err.code ?? "";
|
|
1978
|
+
}
|
|
1979
|
+
function publishWithoutLink(tmp, path3) {
|
|
1980
|
+
const claim = path3 + DB_PUBLISH_CLAIM_SUFFIX;
|
|
1981
|
+
const start = Date.now();
|
|
1982
|
+
for (; ; ) {
|
|
1983
|
+
if (existsSync(path3)) return;
|
|
1984
|
+
try {
|
|
1985
|
+
mkdirSync(claim);
|
|
1986
|
+
} catch (err) {
|
|
1987
|
+
if (!DB_CLAIM_BUSY_CODES.includes(errCode(err))) throw err;
|
|
1988
|
+
if (Date.now() - start < DB_TIMEOUT_MS) {
|
|
1989
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, DB_PUBLISH_POLL_MS);
|
|
1990
|
+
continue;
|
|
1991
|
+
}
|
|
1992
|
+
const held = statSync(claim, { throwIfNoEntry: false });
|
|
1993
|
+
if (held !== void 0 && held.mtimeMs < start) rmSync(claim, { recursive: true, force: true });
|
|
1994
|
+
throw new Error(`context.db was not published within ${DB_TIMEOUT_MS} ms: ${claim} was held; open again`);
|
|
1995
|
+
}
|
|
1996
|
+
try {
|
|
1997
|
+
if (!existsSync(path3)) renameSync(tmp, path3);
|
|
1998
|
+
} finally {
|
|
1999
|
+
rmSync(claim, { recursive: true, force: true });
|
|
2000
|
+
}
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
1948
2004
|
function createAtomically(sqlite, path3) {
|
|
1949
2005
|
const { randomUUID: randomUUID2 } = process.getBuiltinModule("node:crypto");
|
|
1950
2006
|
const tmp = path3 + "." + randomUUID2() + DB_TMP_SUFFIX;
|
|
@@ -1958,7 +2014,9 @@ function createAtomically(sqlite, path3) {
|
|
|
1958
2014
|
try {
|
|
1959
2015
|
linkSync(tmp, path3);
|
|
1960
2016
|
} catch (err) {
|
|
1961
|
-
|
|
2017
|
+
const code = errCode(err);
|
|
2018
|
+
if (DB_LINK_DENIED_CODES.includes(code)) publishWithoutLink(tmp, path3);
|
|
2019
|
+
else if (code !== "EEXIST") throw err;
|
|
1962
2020
|
}
|
|
1963
2021
|
} finally {
|
|
1964
2022
|
for (const suffix of ["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]) rmSync(tmp + suffix, { force: true });
|
|
@@ -5191,8 +5249,12 @@ var CC_READ_ONLY_DENY = Object.freeze(["Agent", "Artifact", "ArtifactComments",
|
|
|
5191
5249
|
var CLAUDE_CODE_BUILT_INS = Object.freeze({
|
|
5192
5250
|
"general-purpose": { tools: null, disallowed: [] },
|
|
5193
5251
|
fork: { tools: null, disallowed: [] },
|
|
5252
|
+
claude: { tools: null, disallowed: [] },
|
|
5194
5253
|
Explore: { tools: null, disallowed: [...CC_READ_ONLY_DENY] },
|
|
5195
|
-
Plan: { tools: null, disallowed: [...CC_READ_ONLY_DENY] }
|
|
5254
|
+
Plan: { tools: null, disallowed: [...CC_READ_ONLY_DENY] },
|
|
5255
|
+
"claude-code-guide": { tools: ["Glob", "Grep", "Read", "WebFetch", "WebSearch"], disallowed: [] },
|
|
5256
|
+
"statusline-setup": { tools: ["Read", "Edit"], disallowed: [] },
|
|
5257
|
+
"web-fetch": { tools: ["WebFetch"], disallowed: [] }
|
|
5196
5258
|
});
|
|
5197
5259
|
function isSubagentCall(ev) {
|
|
5198
5260
|
return ev.agentId !== void 0 && ev.agentId !== "";
|
|
@@ -5201,13 +5263,15 @@ function isSubagentCall(ev) {
|
|
|
5201
5263
|
// src/core/policy/unwrap.ts
|
|
5202
5264
|
var NONE = "";
|
|
5203
5265
|
var WRAPPERS = Object.freeze({
|
|
5204
|
-
sudo: { valueShorts: "ugpChDrtUTR", valueLongs: ["--user", "--group", "--prompt", "--chdir", "--host"], assignments: true, duration: false, refuseShorts: NONE },
|
|
5205
|
-
env: { valueShorts: "uCS", valueLongs: ["--unset", "--chdir", "--split-string"], assignments: true, duration: false, refuseShorts: NONE },
|
|
5206
|
-
time: { valueShorts: "fo", valueLongs: ["--format", "--output"], assignments: false, duration: false, refuseShorts: NONE },
|
|
5207
|
-
nice: { valueShorts: "n", valueLongs: ["--adjustment"], assignments: false, duration: false, refuseShorts: NONE },
|
|
5208
|
-
timeout: { valueShorts: "sk", valueLongs: ["--signal", "--kill-after"], assignments: false, duration: true, refuseShorts: NONE },
|
|
5209
|
-
command: { valueShorts: NONE, valueLongs: [], assignments: false, duration: false, refuseShorts: "vV" },
|
|
5210
|
-
xargs: { valueShorts: "aEdILnPs", valueLongs: ["--arg-file", "--delimiter", "--max-args", "--max-procs", "--max-chars"], assignments: false, duration: false, refuseShorts: NONE }
|
|
5266
|
+
sudo: { valueShorts: "ugpChDrtUTR", valueLongs: ["--user", "--group", "--prompt", "--chdir", "--host"], assignments: true, duration: false, refuseShorts: NONE, subcommands: [] },
|
|
5267
|
+
env: { valueShorts: "uCS", valueLongs: ["--unset", "--chdir", "--split-string"], assignments: true, duration: false, refuseShorts: NONE, subcommands: [] },
|
|
5268
|
+
time: { valueShorts: "fo", valueLongs: ["--format", "--output"], assignments: false, duration: false, refuseShorts: NONE, subcommands: [] },
|
|
5269
|
+
nice: { valueShorts: "n", valueLongs: ["--adjustment"], assignments: false, duration: false, refuseShorts: NONE, subcommands: [] },
|
|
5270
|
+
timeout: { valueShorts: "sk", valueLongs: ["--signal", "--kill-after"], assignments: false, duration: true, refuseShorts: NONE, subcommands: [] },
|
|
5271
|
+
command: { valueShorts: NONE, valueLongs: [], assignments: false, duration: false, refuseShorts: "vV", subcommands: [] },
|
|
5272
|
+
xargs: { valueShorts: "aEdILnPs", valueLongs: ["--arg-file", "--delimiter", "--max-args", "--max-procs", "--max-chars"], assignments: false, duration: false, refuseShorts: NONE, subcommands: [] },
|
|
5273
|
+
// #1388: rtk (rtk-ai/rtk) runs the inner command as-is under `proxy` / `bypass`; its other subcommands are rtk's own.
|
|
5274
|
+
rtk: { valueShorts: NONE, valueLongs: [], assignments: false, duration: false, refuseShorts: NONE, subcommands: ["proxy", "bypass"] }
|
|
5211
5275
|
});
|
|
5212
5276
|
var SHELLS = ["bash", "sh", "zsh"];
|
|
5213
5277
|
var SCRIPT_FLAG = "c";
|
|
@@ -5230,6 +5294,10 @@ function isDuration(s) {
|
|
|
5230
5294
|
}
|
|
5231
5295
|
function peel(w, args) {
|
|
5232
5296
|
let k = 0;
|
|
5297
|
+
if (w.subcommands.length > 0) {
|
|
5298
|
+
if (args.length === 0 || !w.subcommands.includes(args[0])) return null;
|
|
5299
|
+
k = 1;
|
|
5300
|
+
}
|
|
5233
5301
|
while (k < args.length) {
|
|
5234
5302
|
const a = args[k];
|
|
5235
5303
|
if (a === LONG_OPT2) {
|
|
@@ -5600,7 +5668,7 @@ function isMediaRead(agent, abs) {
|
|
|
5600
5668
|
}
|
|
5601
5669
|
|
|
5602
5670
|
// src/core/policy/decide.ts
|
|
5603
|
-
var { statSync } = process.getBuiltinModule("node:fs");
|
|
5671
|
+
var { statSync: statSync2 } = process.getBuiltinModule("node:fs");
|
|
5604
5672
|
var BASH = "Bash";
|
|
5605
5673
|
var READ = "Read";
|
|
5606
5674
|
var WEBFETCH = "WebFetch";
|
|
@@ -5791,7 +5859,7 @@ function inlineHttp(raw) {
|
|
|
5791
5859
|
var CD_COMMAND = "cd";
|
|
5792
5860
|
function fileSize(abs) {
|
|
5793
5861
|
try {
|
|
5794
|
-
const st =
|
|
5862
|
+
const st = statSync2(abs);
|
|
5795
5863
|
return st.isFile() ? st.size : -1;
|
|
5796
5864
|
} catch {
|
|
5797
5865
|
return -1;
|
|
@@ -6025,7 +6093,7 @@ function sha256Hex(text) {
|
|
|
6025
6093
|
}
|
|
6026
6094
|
|
|
6027
6095
|
// src/core/project/resolve.ts
|
|
6028
|
-
var { existsSync: existsSync3, readFileSync: readFileSync4, realpathSync: realpathSync3, statSync:
|
|
6096
|
+
var { existsSync: existsSync3, readFileSync: readFileSync4, realpathSync: realpathSync3, statSync: statSync3 } = process.getBuiltinModule("node:fs");
|
|
6029
6097
|
function sourceOf(agent) {
|
|
6030
6098
|
switch (agent) {
|
|
6031
6099
|
case "claude-code":
|
|
@@ -6042,6 +6110,7 @@ function sourceOf(agent) {
|
|
|
6042
6110
|
case "opencode":
|
|
6043
6111
|
return "spawn-cwd";
|
|
6044
6112
|
case "pi":
|
|
6113
|
+
case "omp":
|
|
6045
6114
|
return "pi:ctx.cwd";
|
|
6046
6115
|
}
|
|
6047
6116
|
}
|
|
@@ -6085,7 +6154,7 @@ function gitDirs(dir) {
|
|
|
6085
6154
|
function gitDirAt(dotGit) {
|
|
6086
6155
|
let gitDir;
|
|
6087
6156
|
try {
|
|
6088
|
-
if (
|
|
6157
|
+
if (statSync3(dotGit).isDirectory()) {
|
|
6089
6158
|
gitDir = dotGit;
|
|
6090
6159
|
} else {
|
|
6091
6160
|
const line = firstLine(dotGit);
|
|
@@ -6191,7 +6260,7 @@ function buildChildEnv(parent, extra) {
|
|
|
6191
6260
|
}
|
|
6192
6261
|
|
|
6193
6262
|
// src/core/sandbox/runtimes.ts
|
|
6194
|
-
import { accessSync, constants as fsConstants, statSync as
|
|
6263
|
+
import { accessSync, constants as fsConstants, statSync as statSync4 } from "node:fs";
|
|
6195
6264
|
import path from "node:path";
|
|
6196
6265
|
|
|
6197
6266
|
// src/core/sandbox/path-entries.ts
|
|
@@ -6233,22 +6302,34 @@ function fileNames(name, pathExt) {
|
|
|
6233
6302
|
if (!isWin() || path.extname(name) !== "") return [name];
|
|
6234
6303
|
return [...pathExt.map((ext) => name + ext), name];
|
|
6235
6304
|
}
|
|
6236
|
-
function
|
|
6237
|
-
|
|
6238
|
-
|
|
6305
|
+
function probe(full) {
|
|
6306
|
+
let st;
|
|
6307
|
+
try {
|
|
6308
|
+
st = statSync4(full, { throwIfNoEntry: false });
|
|
6309
|
+
} catch {
|
|
6310
|
+
return "unreadable";
|
|
6311
|
+
}
|
|
6312
|
+
if (st === void 0 || !st.isFile()) return "absent";
|
|
6239
6313
|
if (isWin()) {
|
|
6240
6314
|
const ext = path.extname(full).toLowerCase();
|
|
6241
|
-
return ext === "" || WIN_STARTABLE_EXT.includes(ext);
|
|
6315
|
+
return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
|
|
6242
6316
|
}
|
|
6243
6317
|
try {
|
|
6244
6318
|
accessSync(full, fsConstants.X_OK);
|
|
6245
|
-
return
|
|
6319
|
+
return "runnable";
|
|
6246
6320
|
} catch {
|
|
6247
|
-
return
|
|
6321
|
+
return "absent";
|
|
6248
6322
|
}
|
|
6249
6323
|
}
|
|
6324
|
+
function isRunnable(full) {
|
|
6325
|
+
return probe(full) === "runnable";
|
|
6326
|
+
}
|
|
6250
6327
|
function findRuntime(lang, env = process.env) {
|
|
6251
|
-
|
|
6328
|
+
return lookupRuntime(lang, env).found;
|
|
6329
|
+
}
|
|
6330
|
+
function lookupRuntime(lang, env = process.env) {
|
|
6331
|
+
const unreadable = [];
|
|
6332
|
+
if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
|
|
6252
6333
|
const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
|
|
6253
6334
|
const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
|
|
6254
6335
|
const names = candidates(lang);
|
|
@@ -6257,13 +6338,15 @@ function findRuntime(lang, env = process.env) {
|
|
|
6257
6338
|
for (const name of names) {
|
|
6258
6339
|
for (const file of fileNames(name, pathExt)) {
|
|
6259
6340
|
const full = path.join(dir, file);
|
|
6260
|
-
|
|
6261
|
-
if (
|
|
6341
|
+
const state = probe(full);
|
|
6342
|
+
if (state === "unreadable") unreadable.push(full);
|
|
6343
|
+
if (state !== "runnable") continue;
|
|
6344
|
+
if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
|
|
6262
6345
|
if (shim === null) shim = full;
|
|
6263
6346
|
}
|
|
6264
6347
|
}
|
|
6265
6348
|
}
|
|
6266
|
-
return shim;
|
|
6349
|
+
return { found: shim, unreadable };
|
|
6267
6350
|
}
|
|
6268
6351
|
function findGitBash(env) {
|
|
6269
6352
|
const git2 = findRuntime(GIT_BIN, env);
|
|
@@ -6343,7 +6426,7 @@ function runProcess(argv, o) {
|
|
|
6343
6426
|
let stopTimer;
|
|
6344
6427
|
const kill = () => {
|
|
6345
6428
|
if (child.pid !== void 0) killTree(child.pid);
|
|
6346
|
-
if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
|
|
6429
|
+
if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
|
|
6347
6430
|
};
|
|
6348
6431
|
const onAbort = () => {
|
|
6349
6432
|
if (killedBy !== null || settled) return;
|
|
@@ -6372,15 +6455,21 @@ function runProcess(argv, o) {
|
|
|
6372
6455
|
...held ? { held: true } : {}
|
|
6373
6456
|
});
|
|
6374
6457
|
};
|
|
6375
|
-
const finishHeld = () => {
|
|
6458
|
+
const finishHeld = (force = false) => {
|
|
6376
6459
|
if (settled) return;
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6460
|
+
const seen = chunkCount;
|
|
6461
|
+
setImmediate(() => {
|
|
6462
|
+
if (settled || !force && chunkCount !== seen) return;
|
|
6463
|
+
held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
|
|
6464
|
+
child.stdout.destroy();
|
|
6465
|
+
child.stderr.destroy();
|
|
6466
|
+
if (child.pid !== void 0) killTree(child.pid);
|
|
6467
|
+
settle(child.exitCode);
|
|
6468
|
+
});
|
|
6382
6469
|
};
|
|
6470
|
+
let chunkCount = 0;
|
|
6383
6471
|
const bump = () => {
|
|
6472
|
+
chunkCount++;
|
|
6384
6473
|
if (!exited || settled) return;
|
|
6385
6474
|
clearTimeout(graceTimer);
|
|
6386
6475
|
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
@@ -6398,7 +6487,7 @@ function runProcess(argv, o) {
|
|
|
6398
6487
|
if (settled) return;
|
|
6399
6488
|
exited = true;
|
|
6400
6489
|
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
6401
|
-
drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
|
|
6490
|
+
drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
|
|
6402
6491
|
});
|
|
6403
6492
|
child.on("error", () => settle(null));
|
|
6404
6493
|
child.stdin.on("error", () => {
|