context-mode 2.2.0 → 2.2.2
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/.zcode-plugin/plugin.json +1 -1
- package/README.md +75 -75
- package/SHA256SUMS +17 -17
- package/cli.mjs +29 -15
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +100 -98
- package/hooks/claude-code.json +12 -0
- package/opencode/plugin.js +876 -436
- package/package.json +1 -1
- package/pi/index.js +1041 -584
- package/qwen-extension.json +1 -1
- package/run.mjs +92 -30
- package/search.mjs +92 -30
- package/server.mjs +291 -101
package/cli.mjs
CHANGED
|
@@ -26,6 +26,7 @@ function readReplaceTrigger(raw) {
|
|
|
26
26
|
var REPLACE_TRIGGER_BYTES = readReplaceTrigger(process.env[REPLACE_TRIGGER_ENV]);
|
|
27
27
|
var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
|
|
28
28
|
var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
|
|
29
|
+
var SKILL_LOAD_TOOLS = Object.freeze(["Skill"]);
|
|
29
30
|
var WEIGHT = Object.freeze({ toolerr: 900, decision: 700, prompt: 500, edit: 400, index: 200 });
|
|
30
31
|
var DECAY_X1000 = Object.freeze([
|
|
31
32
|
1e3,
|
|
@@ -169,6 +170,7 @@ var EXEC_LANGUAGES = Object.freeze(["shell", "powershell", "javascript", "typesc
|
|
|
169
170
|
var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
170
171
|
var PLAIN_OUTPUT_ENV = Object.freeze({ NO_COLOR: "1", FORCE_COLOR: "0" });
|
|
171
172
|
var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" });
|
|
173
|
+
var HOST_SESSION_META = Object.freeze({ zcode: "session_id" });
|
|
172
174
|
var NODE_MIN = "24.15.0";
|
|
173
175
|
var DATA_ROOT = "~/.context-mode";
|
|
174
176
|
var DATA_DIR_ENV = "CONTEXT_MODE_DATA_DIR";
|
|
@@ -691,6 +693,7 @@ var SHELL_TOOL_NAMES = Object.freeze(["Bash", "PowerShell"]);
|
|
|
691
693
|
var POWERSHELL_TOOL = "PowerShell";
|
|
692
694
|
var SHELL_CANONICAL = "Bash";
|
|
693
695
|
var CLAUDE_SHAPE_EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse"];
|
|
696
|
+
var FAILURE_EVENT = "PostToolUseFailure";
|
|
694
697
|
var MCP_PREFIX = "mcp__";
|
|
695
698
|
var MCP_SEP = "__";
|
|
696
699
|
var CLAUDE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
@@ -864,7 +867,14 @@ function requireFields(raw) {
|
|
|
864
867
|
}
|
|
865
868
|
function decode(raw) {
|
|
866
869
|
requireFields(raw);
|
|
867
|
-
const
|
|
870
|
+
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === FAILURE_EVENT;
|
|
871
|
+
const payload = failure ? { ...raw, hook_event_name: "PostToolUse" } : raw;
|
|
872
|
+
const ev = decodeClaudeShape(payload, "claude-code", TOOL_NAME_PREFIX, CLAUDE_SOURCES);
|
|
873
|
+
if (failure) {
|
|
874
|
+
const error = raw.error;
|
|
875
|
+
const text2 = typeof error === "string" ? error : error === void 0 ? "" : JSON.stringify(error);
|
|
876
|
+
ev.result = { isError: true, bytes: Buffer.byteLength(text2), text: text2, keep: true };
|
|
877
|
+
}
|
|
868
878
|
if (ev.tool !== void 0 && ev.tool.name === POWERSHELL_TOOL) ev.tool.canonicalName = SHELL_CANONICAL;
|
|
869
879
|
if (ev.cwd === "") ev.cwd = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
870
880
|
if (ev.event === "PostToolUse" && ev.tool !== void 0 && ev.tool.callId === void 0) {
|
|
@@ -1043,9 +1053,9 @@ var NATIVE_TO_CANONICAL2 = {
|
|
|
1043
1053
|
grep_search: "Grep",
|
|
1044
1054
|
web_fetch: "WebFetch"
|
|
1045
1055
|
};
|
|
1046
|
-
var
|
|
1056
|
+
var FAILURE_EVENT2 = "PostToolUseFailure";
|
|
1047
1057
|
function decode4(raw) {
|
|
1048
|
-
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name ===
|
|
1058
|
+
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === FAILURE_EVENT2;
|
|
1049
1059
|
const payload = failure ? { ...raw, hook_event_name: "PostToolUse" } : raw;
|
|
1050
1060
|
const ev = decodeClaudeShape(payload, "qwen", TOOL_NAME_PREFIX4, QWEN_SOURCES);
|
|
1051
1061
|
if (ev.tool !== void 0 && Object.hasOwn(NATIVE_TO_CANONICAL2, ev.tool.name)) ev.tool.canonicalName = NATIVE_TO_CANONICAL2[ev.tool.name];
|
|
@@ -1365,12 +1375,12 @@ var TOOL_NAME_PREFIX8 = "mcp__context-mode__";
|
|
|
1365
1375
|
var PLUGIN_TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
1366
1376
|
var ZCODE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
1367
1377
|
var TWINS = { hook_event_name: "hookEventName", session_id: "sessionId" };
|
|
1368
|
-
var
|
|
1378
|
+
var FAILURE_EVENT3 = "PostToolUseFailure";
|
|
1369
1379
|
function decode8(raw) {
|
|
1370
1380
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("zcode: hook payload is not a JSON object");
|
|
1371
1381
|
const p3 = { ...raw };
|
|
1372
1382
|
for (const [snake2, camel] of Object.entries(TWINS)) if (p3[snake2] === void 0) p3[snake2] = p3[camel];
|
|
1373
|
-
const failure = p3.hook_event_name ===
|
|
1383
|
+
const failure = p3.hook_event_name === FAILURE_EVENT3;
|
|
1374
1384
|
if (failure) p3.hook_event_name = "PostToolUse";
|
|
1375
1385
|
const toolName = typeof p3.tool_name === "string" ? p3.tool_name : "";
|
|
1376
1386
|
const prefix = toolName.startsWith(PLUGIN_TOOL_NAME_PREFIX) ? PLUGIN_TOOL_NAME_PREFIX : TOOL_NAME_PREFIX8;
|
|
@@ -1461,7 +1471,8 @@ var OPENCODE_EVENTS = {
|
|
|
1461
1471
|
var SHELL_TOOL_NAME = "bash";
|
|
1462
1472
|
var READ_TOOL_NAME = "read";
|
|
1463
1473
|
var SHELL_TOOL_NAMES5 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
1464
|
-
var
|
|
1474
|
+
var SKILL_TOOL_NAME = "skill";
|
|
1475
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", [READ_TOOL_NAME]: "Read", [SKILL_TOOL_NAME]: "Skill", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n3) => [n3, "Bash"])) };
|
|
1465
1476
|
function toCanonicalTool(name) {
|
|
1466
1477
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
1467
1478
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -5228,7 +5239,7 @@ CREATE VIRTUAL TABLE line_units USING fts5(
|
|
|
5228
5239
|
`;
|
|
5229
5240
|
|
|
5230
5241
|
// src/core/store/db.ts
|
|
5231
|
-
var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
|
|
5242
|
+
var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, renameSync, rmSync, statSync: statSync2 } = process.getBuiltinModule("node:fs");
|
|
5232
5243
|
|
|
5233
5244
|
// src/core/ops/doctor-config.ts
|
|
5234
5245
|
import { existsSync as existsSync11, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "node:fs";
|
|
@@ -7310,7 +7321,7 @@ function parseTOML(code, options) {
|
|
|
7310
7321
|
}
|
|
7311
7322
|
|
|
7312
7323
|
// src/core/ops/atomic-file.ts
|
|
7313
|
-
import { mkdirSync as mkdirSync3, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
7324
|
+
import { mkdirSync as mkdirSync3, renameSync as renameSync2, unlinkSync, writeFileSync } from "node:fs";
|
|
7314
7325
|
import path4 from "node:path";
|
|
7315
7326
|
function sleepSync(ms) {
|
|
7316
7327
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
@@ -7319,7 +7330,7 @@ function errCode(e) {
|
|
|
7319
7330
|
return e.code;
|
|
7320
7331
|
}
|
|
7321
7332
|
function renameWithRetry(from, to, opts = {}) {
|
|
7322
|
-
const rename = opts.rename ??
|
|
7333
|
+
const rename = opts.rename ?? renameSync2;
|
|
7323
7334
|
const sleep = opts.sleep ?? sleepSync;
|
|
7324
7335
|
const win = (opts.platform ?? process.platform) === "win32";
|
|
7325
7336
|
for (let attempt = 0; ; attempt += 1) {
|
|
@@ -8987,7 +8998,7 @@ import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
|
8987
8998
|
|
|
8988
8999
|
// src/setup/spawn-bin.ts
|
|
8989
9000
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
8990
|
-
import { accessSync as accessSync2, constants as fsc, statSync as
|
|
9001
|
+
import { accessSync as accessSync2, constants as fsc, statSync as statSync3 } from "node:fs";
|
|
8991
9002
|
import path11 from "node:path";
|
|
8992
9003
|
var WIN_EXT = ".COM;.EXE;.BAT;.CMD";
|
|
8993
9004
|
var WIN_SHIM_EXTS = Object.freeze([".cmd", ".bat"]);
|
|
@@ -9005,7 +9016,7 @@ function whichBin(bin, env, platform = process.platform) {
|
|
|
9005
9016
|
const f2 = path11.join(dir, n3);
|
|
9006
9017
|
try {
|
|
9007
9018
|
accessSync2(f2, fsc.X_OK);
|
|
9008
|
-
if (
|
|
9019
|
+
if (statSync3(f2).isFile()) return f2;
|
|
9009
9020
|
} catch {
|
|
9010
9021
|
}
|
|
9011
9022
|
}
|
|
@@ -9382,7 +9393,7 @@ function listCopilotHooks(env, file, cwd) {
|
|
|
9382
9393
|
|
|
9383
9394
|
// src/setup/engine.ts
|
|
9384
9395
|
import { spawn as spawn5, spawnSync as spawnSync4 } from "node:child_process";
|
|
9385
|
-
import { closeSync as closeSync3, existsSync as existsSync19, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync14, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync10, rmSync as rmSync2, statSync as
|
|
9396
|
+
import { closeSync as closeSync3, existsSync as existsSync19, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync14, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync10, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9386
9397
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
9387
9398
|
import path14 from "node:path";
|
|
9388
9399
|
|
|
@@ -9499,7 +9510,7 @@ function hostBin(bin, env, platform = process.platform) {
|
|
|
9499
9510
|
for (const dir of pathEntries(get("PATH") ?? "", platform)) {
|
|
9500
9511
|
const own2 = which(bin, { PATH: dir, ...get("PATHEXT") ? { PATHEXT: get("PATHEXT") } : {} }, platform);
|
|
9501
9512
|
for (const f2 of [own2, ...real2.extra.map((p3) => path14.join(dir, ...p3))]) {
|
|
9502
|
-
if (!f2 || !existsSync19(f2) || !
|
|
9513
|
+
if (!f2 || !existsSync19(f2) || !statSync4(f2).isFile()) continue;
|
|
9503
9514
|
const file = realpathSync10(f2);
|
|
9504
9515
|
if (isNativeBinary(file) || owningPackage(path14.dirname(file)) === real2.pkg) return { file: f2, shims };
|
|
9505
9516
|
shims.push(f2);
|
|
@@ -9836,7 +9847,10 @@ function opencodeListCheck(bin, major, env) {
|
|
|
9836
9847
|
} catch {
|
|
9837
9848
|
out2 = void 0;
|
|
9838
9849
|
}
|
|
9839
|
-
if (r2.status !== 0)
|
|
9850
|
+
if (r2.status !== 0) {
|
|
9851
|
+
const host = `${r2.stderr}`.split("\n").map((l) => l.trim()).filter(Boolean).slice(0, 3).join(" ");
|
|
9852
|
+
return { name: "list", ok: true, warn: true, detail: `${what} exited ${r2.status}: ${host}; doctor checked the entry and hooks on disk` };
|
|
9853
|
+
}
|
|
9840
9854
|
if (major >= 2) {
|
|
9841
9855
|
if (!Array.isArray(out2)) return { name: "list", ok: false, detail: `${what} printed no config list: ${first(r2.stdout)}` };
|
|
9842
9856
|
const listed2 = out2.some((d) => isObj5(d) && isObj5(d.info) && isObj5(d.info.mcp) && isObj5(d.info.mcp.servers) && isObj5(d.info.mcp.servers[SERVER_KEY]));
|
|
@@ -10775,7 +10789,7 @@ async function runDoctor(opts) {
|
|
|
10775
10789
|
res.reason = gone.map((c3) => `${c3.name}: ${c3.detail}`).join("; ");
|
|
10776
10790
|
}
|
|
10777
10791
|
if (res.status === "PASS") {
|
|
10778
|
-
if (res.v1.some((f2) => !UPGRADE_REPORT_ONLY_REASONS.includes(f2.reason))) {
|
|
10792
|
+
if (res.v1.some((f2) => !UPGRADE_REPORT_ONLY_REASONS.includes(f2.reason) && !UPGRADE_KEEP_ASIDE_REASONS.includes(f2.reason))) {
|
|
10779
10793
|
res.status = "FAIL";
|
|
10780
10794
|
res.reason = V1_FORM_REASON;
|
|
10781
10795
|
} else if (res.changes.length && !onlyTrust(row, res.changes) && !hasPluginIssue(row)) {
|
package/copilot/plugin.json
CHANGED
package/gemini-extension.json
CHANGED