context-mode 2.0.0-next.22 → 2.0.0-next.24
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 +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/LICENSE +94 -0
- package/README.md +370 -0
- package/SHA256SUMS +16 -14
- package/cli.mjs +50 -18
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +59 -57
- package/opencode/plugin.js +423 -190
- package/package.json +3 -1
- package/pi/index.js +474 -241
- package/qwen-extension.json +1 -1
- package/run.mjs +6 -2
- package/search.mjs +6 -2
- package/server.mjs +462 -229
package/cli.mjs
CHANGED
|
@@ -1596,7 +1596,7 @@ Examples:
|
|
|
1596
1596
|
};
|
|
1597
1597
|
|
|
1598
1598
|
// src/cli/commands.ts
|
|
1599
|
-
import { spawnSync as
|
|
1599
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
1600
1600
|
import { createHash as createHash2 } from "node:crypto";
|
|
1601
1601
|
import { existsSync as existsSync13, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
1602
1602
|
import os from "node:os";
|
|
@@ -8017,7 +8017,7 @@ function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platfor
|
|
|
8017
8017
|
import { createHash } from "node:crypto";
|
|
8018
8018
|
import { existsSync as existsSync11, realpathSync as realpathSync4 } from "node:fs";
|
|
8019
8019
|
import path10 from "node:path";
|
|
8020
|
-
import { spawn } from "node:child_process";
|
|
8020
|
+
import { spawn, spawnSync as spawnSync2 } from "node:child_process";
|
|
8021
8021
|
|
|
8022
8022
|
// src/setup/spawn-bin.ts
|
|
8023
8023
|
import { spawnSync } from "node:child_process";
|
|
@@ -8189,6 +8189,7 @@ function codexTrustEntries(hooksFile, doc, command, env) {
|
|
|
8189
8189
|
return out2;
|
|
8190
8190
|
}
|
|
8191
8191
|
var LIST_TIMEOUT_MS = 15e3;
|
|
8192
|
+
var EXIT_GRACE_MS = 5e3;
|
|
8192
8193
|
var PLUGIN_SOURCE = "plugin";
|
|
8193
8194
|
var TRUSTED = "trusted";
|
|
8194
8195
|
function pluginHooksFromReply(m3, pluginId) {
|
|
@@ -8219,13 +8220,25 @@ function listPluginHooks(env, pluginId, cwd) {
|
|
|
8219
8220
|
const child = spawn(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
|
|
8220
8221
|
let buf = "";
|
|
8221
8222
|
let done = false;
|
|
8223
|
+
let exited = false;
|
|
8224
|
+
let result;
|
|
8225
|
+
const settle = () => {
|
|
8226
|
+
clearTimeout(grace);
|
|
8227
|
+
resolve(result);
|
|
8228
|
+
};
|
|
8229
|
+
let grace;
|
|
8222
8230
|
const finish2 = (v) => {
|
|
8223
8231
|
if (done) return;
|
|
8224
8232
|
done = true;
|
|
8225
8233
|
clearTimeout(timer);
|
|
8234
|
+
result = v;
|
|
8226
8235
|
child.stdin.destroy();
|
|
8227
|
-
|
|
8228
|
-
|
|
8236
|
+
if (exited) {
|
|
8237
|
+
settle();
|
|
8238
|
+
return;
|
|
8239
|
+
}
|
|
8240
|
+
grace = setTimeout(settle, EXIT_GRACE_MS);
|
|
8241
|
+
stopTree(child.pid, () => child.kill());
|
|
8229
8242
|
};
|
|
8230
8243
|
const timer = setTimeout(() => finish2(void 0), LIST_TIMEOUT_MS);
|
|
8231
8244
|
const send = (o2) => {
|
|
@@ -8236,7 +8249,11 @@ function listPluginHooks(env, pluginId, cwd) {
|
|
|
8236
8249
|
}
|
|
8237
8250
|
};
|
|
8238
8251
|
child.on("error", () => finish2(void 0));
|
|
8239
|
-
child.on("close", () =>
|
|
8252
|
+
child.on("close", () => {
|
|
8253
|
+
exited = true;
|
|
8254
|
+
if (done) settle();
|
|
8255
|
+
else finish2(void 0);
|
|
8256
|
+
});
|
|
8240
8257
|
child.stdin.on("error", () => finish2(void 0));
|
|
8241
8258
|
child.stdout.setEncoding("utf8");
|
|
8242
8259
|
child.stdout.on("data", (d) => {
|
|
@@ -8260,6 +8277,15 @@ function listPluginHooks(env, pluginId, cwd) {
|
|
|
8260
8277
|
send({ id: 1, method: "initialize", params: { clientInfo: { name: "context-mode-setup", version: "2.0.0" } } });
|
|
8261
8278
|
});
|
|
8262
8279
|
}
|
|
8280
|
+
function stopTree(pid, kill) {
|
|
8281
|
+
if (process.platform === "win32" && pid !== void 0) {
|
|
8282
|
+
try {
|
|
8283
|
+
spawnSync2("taskkill", ["/pid", String(pid), "/T", "/F"], { windowsHide: true, stdio: "ignore", timeout: 5e3 });
|
|
8284
|
+
} catch {
|
|
8285
|
+
}
|
|
8286
|
+
}
|
|
8287
|
+
kill();
|
|
8288
|
+
}
|
|
8263
8289
|
var HASH_PART_SEP = "/";
|
|
8264
8290
|
function hookHashOf(currentHash) {
|
|
8265
8291
|
const cut = currentHash.indexOf(HASH_PART_SEP);
|
|
@@ -8268,6 +8294,13 @@ function hookHashOf(currentHash) {
|
|
|
8268
8294
|
function pluginTrustEntries(hooks) {
|
|
8269
8295
|
return hooks.filter((h2) => !h2.trusted).map((h2) => [[...TRUST_KEY, h2.key], { [HASH_FIELD]: hookHashOf(h2.hash) }]);
|
|
8270
8296
|
}
|
|
8297
|
+
var CODEX_PLUGIN_ID = `${SERVER_KEY}@${SERVER_KEY}`;
|
|
8298
|
+
var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
|
|
8299
|
+
function untrustedPluginHooksDetail(hooks) {
|
|
8300
|
+
const bad = hooks.filter((h2) => !h2.trusted);
|
|
8301
|
+
if (!bad.length) return void 0;
|
|
8302
|
+
return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks untrusted, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
|
|
8303
|
+
}
|
|
8271
8304
|
|
|
8272
8305
|
// src/setup/copilot-hooks.ts
|
|
8273
8306
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -8365,7 +8398,7 @@ function listCopilotHooks(env, file, cwd) {
|
|
|
8365
8398
|
}
|
|
8366
8399
|
|
|
8367
8400
|
// src/setup/engine.ts
|
|
8368
|
-
import { spawn as spawn3, spawnSync as
|
|
8401
|
+
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
8369
8402
|
import { closeSync, existsSync as existsSync12, mkdirSync as mkdirSync3, mkdtempSync, openSync, readFileSync as readFileSync9, readSync, readdirSync as readdirSync5, realpathSync as realpathSync6, rmSync, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
8370
8403
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
8371
8404
|
import path12 from "node:path";
|
|
@@ -8897,7 +8930,7 @@ function hookRound(row, env) {
|
|
|
8897
8930
|
const bare = [];
|
|
8898
8931
|
for (let i2 = 0; i2 < HOOK_SAMPLES; i2++) {
|
|
8899
8932
|
let t2 = performance.now();
|
|
8900
|
-
const r2 =
|
|
8933
|
+
const r2 = spawnSync3(cmd[0], cmd.slice(1), { env, input, encoding: "utf8", timeout: VERIFY_TIMEOUT_MS, windowsHide: true });
|
|
8901
8934
|
wall.push(performance.now() - t2);
|
|
8902
8935
|
if (r2.status !== 0) return { name: "hook", ok: false, detail: `hook exited ${r2.status}: ${`${r2.stderr}`.trim()}` };
|
|
8903
8936
|
const out2 = `${r2.stdout}`.trim();
|
|
@@ -8910,7 +8943,7 @@ function hookRound(row, env) {
|
|
|
8910
8943
|
if (!isObj5(j2)) return { name: "hook", ok: false, detail: `hook answer is not a JSON object: ${out2.slice(0, 200)}` };
|
|
8911
8944
|
}
|
|
8912
8945
|
t2 = performance.now();
|
|
8913
|
-
|
|
8946
|
+
spawnSync3(cmd[0], ["-e", ""], { env, timeout: VERIFY_TIMEOUT_MS, windowsHide: true });
|
|
8914
8947
|
bare.push(performance.now() - t2);
|
|
8915
8948
|
}
|
|
8916
8949
|
const wallP95Ms = Math.round(p95(wall));
|
|
@@ -8974,7 +9007,7 @@ function hookRunsCheck(row, env) {
|
|
|
8974
9007
|
const sampleEnv = { ...env, HOME: home, USERPROFILE: home };
|
|
8975
9008
|
delete sampleEnv.CLAUDE_PROJECT_DIR;
|
|
8976
9009
|
const cmd = row.hookRunCommand;
|
|
8977
|
-
const r2 =
|
|
9010
|
+
const r2 = spawnSync3(cmd[0], cmd.slice(1), { env: sampleEnv, cwd: proj, input: JSON.stringify(payload), encoding: "utf8", timeout: VERIFY_TIMEOUT_MS, windowsHide: true });
|
|
8978
9011
|
const bad = sampleVerdict(row.id, effect, text2, { status: r2.status, stdout: `${r2.stdout ?? ""}`, stderr: `${r2.stderr ?? ""}` });
|
|
8979
9012
|
return bad === null ? { name: "hook-runs", ok: true } : { name: "hook-runs", ok: false, detail: bad };
|
|
8980
9013
|
} finally {
|
|
@@ -9145,12 +9178,11 @@ function withHookGate(checks, detail) {
|
|
|
9145
9178
|
if (detail === void 0) return checks;
|
|
9146
9179
|
return checks.map((c3) => c3.name === "hook-registered" ? { name: c3.name, ok: false, detail } : c3);
|
|
9147
9180
|
}
|
|
9148
|
-
var UNTRUSTED_FIX =
|
|
9181
|
+
var UNTRUSTED_FIX = CODEX_UNTRUSTED_FIX;
|
|
9149
9182
|
function withHookTrust(checks, hooks, dryRun) {
|
|
9150
9183
|
if (hooks === void 0) return [...checks, { name: "hook-trust", ok: true, warn: true, detail: "codex did not report hook trust (codex app-server hooks/list)" }];
|
|
9151
|
-
const
|
|
9152
|
-
if (
|
|
9153
|
-
const detail = `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks untrusted, so they do not run; ${UNTRUSTED_FIX}`;
|
|
9184
|
+
const detail = untrustedPluginHooksDetail(hooks);
|
|
9185
|
+
if (detail === void 0 || dryRun) return checks;
|
|
9154
9186
|
return checks.map((c3) => c3.name === "hook-registered" ? { name: c3.name, ok: false, detail } : c3);
|
|
9155
9187
|
}
|
|
9156
9188
|
async function copilotEnabledCheck(row, ctx) {
|
|
@@ -9671,7 +9703,7 @@ function buildIssueReport(command, res, ui) {
|
|
|
9671
9703
|
return { text: redact(lines.join("\n"), ui.ctx), title };
|
|
9672
9704
|
}
|
|
9673
9705
|
function ghReady(env) {
|
|
9674
|
-
const r2 =
|
|
9706
|
+
const r2 = spawnSync4("gh", ["auth", "status"], { env, stdio: "ignore", timeout: 1e4, windowsHide: true });
|
|
9675
9707
|
return r2.status === 0;
|
|
9676
9708
|
}
|
|
9677
9709
|
function issueUrl(title, body) {
|
|
@@ -9702,7 +9734,7 @@ async function report(ui, command, res, write) {
|
|
|
9702
9734
|
return;
|
|
9703
9735
|
}
|
|
9704
9736
|
if (file && ghReady(ui.ctx.env)) {
|
|
9705
|
-
const r2 =
|
|
9737
|
+
const r2 = spawnSync4("gh", ["issue", "create", "--repo", ISSUE_REPO, "--title", title, "--body-file", file], { env: ui.ctx.env, encoding: "utf8", timeout: 6e4, windowsHide: true });
|
|
9706
9738
|
if (r2.status === 0) {
|
|
9707
9739
|
p3.log.success(`Issue opened: ${`${r2.stdout}`.trim()}`);
|
|
9708
9740
|
return;
|
|
@@ -9925,20 +9957,20 @@ async function upgrade(ui) {
|
|
|
9925
9957
|
}
|
|
9926
9958
|
const shell = process.platform === "win32";
|
|
9927
9959
|
progress2(ui, `running ${install}`);
|
|
9928
|
-
const r2 =
|
|
9960
|
+
const r2 = spawnSync4(npm, ["i", "-g", spec], { env: ui.ctx.env, encoding: "utf8", shell, windowsHide: true });
|
|
9929
9961
|
if (r2.status !== 0) {
|
|
9930
9962
|
const why = (`${r2.stderr ?? ""}`.trim().split("\n").pop() ?? "") || (r2.error?.message ?? "");
|
|
9931
9963
|
err(`FAIL upgrade: ${install} exited ${r2.status ?? "?"}${why ? `: ${why}` : ""}. Fix: ${install}`);
|
|
9932
9964
|
return EXIT_FAIL;
|
|
9933
9965
|
}
|
|
9934
|
-
const root = `${
|
|
9966
|
+
const root = `${spawnSync4(npm, ["root", "-g"], { env: ui.ctx.env, encoding: "utf8", shell, windowsHide: true }).stdout ?? ""}`.trim();
|
|
9935
9967
|
const cli = path13.join(root, "context-mode", "cli.mjs");
|
|
9936
9968
|
if (!root || !existsSync13(cli)) {
|
|
9937
9969
|
err(`FAIL upgrade: ${cli} not found after ${install}. Fix: ${install}`);
|
|
9938
9970
|
return EXIT_FAIL;
|
|
9939
9971
|
}
|
|
9940
9972
|
progress2(ui, `running context-mode ${repairArgs.join(" ")}`);
|
|
9941
|
-
const c3 =
|
|
9973
|
+
const c3 = spawnSync4(process.execPath, [cli, ...repairArgs], { env: ui.ctx.env, stdio: "inherit", windowsHide: true });
|
|
9942
9974
|
return c3.status ?? (c3.signal === "SIGINT" ? EXIT_SIGINT : EXIT_FAIL);
|
|
9943
9975
|
}
|
|
9944
9976
|
async function runCommand(cmd, args, env) {
|
package/copilot/plugin.json
CHANGED
package/gemini-extension.json
CHANGED