context-mode 2.2.1 → 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 +72 -72
- package/SHA256SUMS +17 -17
- package/cli.mjs +17 -6
- 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 +684 -397
- package/package.json +1 -1
- package/pi/index.js +835 -543
- package/qwen-extension.json +1 -1
- package/run.mjs +32 -14
- package/search.mjs +32 -14
- package/server.mjs +193 -64
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -24,6 +24,7 @@ function readReplaceTrigger(raw) {
|
|
|
24
24
|
var REPLACE_TRIGGER_BYTES = readReplaceTrigger(process.env[REPLACE_TRIGGER_ENV]);
|
|
25
25
|
var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
|
|
26
26
|
var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
|
|
27
|
+
var SKILL_LOAD_TOOLS = Object.freeze(["Skill"]);
|
|
27
28
|
function shellWord(s) {
|
|
28
29
|
return "'" + s.split("'").join("'\\''") + "'";
|
|
29
30
|
}
|
|
@@ -202,6 +203,7 @@ var SEARCH_WRAPPER_FILE = "search.mjs";
|
|
|
202
203
|
var RUN_WRAPPER_AGENT = "claude-code";
|
|
203
204
|
var RUN_SESSION_PREFIX = "mcp:";
|
|
204
205
|
var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" });
|
|
206
|
+
var HOST_SESSION_META = Object.freeze({ zcode: "session_id" });
|
|
205
207
|
var NODE_MIN = "24.15.0";
|
|
206
208
|
var DATA_ROOT = "~/.context-mode";
|
|
207
209
|
var DATA_DIR_ENV = "CONTEXT_MODE_DATA_DIR";
|
|
@@ -675,6 +677,7 @@ var SHELL_TOOL_NAMES = Object.freeze(["Bash", "PowerShell"]);
|
|
|
675
677
|
var POWERSHELL_TOOL = "PowerShell";
|
|
676
678
|
var SHELL_CANONICAL = "Bash";
|
|
677
679
|
var CLAUDE_SHAPE_EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse"];
|
|
680
|
+
var FAILURE_EVENT = "PostToolUseFailure";
|
|
678
681
|
var MCP_PREFIX = "mcp__";
|
|
679
682
|
var MCP_SEP = "__";
|
|
680
683
|
var CLAUDE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
@@ -848,7 +851,14 @@ function requireFields(raw) {
|
|
|
848
851
|
}
|
|
849
852
|
function decode(raw) {
|
|
850
853
|
requireFields(raw);
|
|
851
|
-
const
|
|
854
|
+
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === FAILURE_EVENT;
|
|
855
|
+
const payload = failure ? { ...raw, hook_event_name: "PostToolUse" } : raw;
|
|
856
|
+
const ev = decodeClaudeShape(payload, "claude-code", TOOL_NAME_PREFIX, CLAUDE_SOURCES);
|
|
857
|
+
if (failure) {
|
|
858
|
+
const error = raw.error;
|
|
859
|
+
const text = typeof error === "string" ? error : error === void 0 ? "" : JSON.stringify(error);
|
|
860
|
+
ev.result = { isError: true, bytes: Buffer.byteLength(text), text, keep: true };
|
|
861
|
+
}
|
|
852
862
|
if (ev.tool !== void 0 && ev.tool.name === POWERSHELL_TOOL) ev.tool.canonicalName = SHELL_CANONICAL;
|
|
853
863
|
if (ev.cwd === "") ev.cwd = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
854
864
|
if (ev.event === "PostToolUse" && ev.tool !== void 0 && ev.tool.callId === void 0) {
|
|
@@ -1027,9 +1037,9 @@ var NATIVE_TO_CANONICAL2 = {
|
|
|
1027
1037
|
grep_search: "Grep",
|
|
1028
1038
|
web_fetch: "WebFetch"
|
|
1029
1039
|
};
|
|
1030
|
-
var
|
|
1040
|
+
var FAILURE_EVENT2 = "PostToolUseFailure";
|
|
1031
1041
|
function decode4(raw) {
|
|
1032
|
-
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name ===
|
|
1042
|
+
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === FAILURE_EVENT2;
|
|
1033
1043
|
const payload = failure ? { ...raw, hook_event_name: "PostToolUse" } : raw;
|
|
1034
1044
|
const ev = decodeClaudeShape(payload, "qwen", TOOL_NAME_PREFIX4, QWEN_SOURCES);
|
|
1035
1045
|
if (ev.tool !== void 0 && Object.hasOwn(NATIVE_TO_CANONICAL2, ev.tool.name)) ev.tool.canonicalName = NATIVE_TO_CANONICAL2[ev.tool.name];
|
|
@@ -1349,12 +1359,12 @@ var TOOL_NAME_PREFIX8 = "mcp__context-mode__";
|
|
|
1349
1359
|
var PLUGIN_TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
1350
1360
|
var ZCODE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
1351
1361
|
var TWINS = { hook_event_name: "hookEventName", session_id: "sessionId" };
|
|
1352
|
-
var
|
|
1362
|
+
var FAILURE_EVENT3 = "PostToolUseFailure";
|
|
1353
1363
|
function decode8(raw) {
|
|
1354
1364
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("zcode: hook payload is not a JSON object");
|
|
1355
1365
|
const p = { ...raw };
|
|
1356
1366
|
for (const [snake, camel] of Object.entries(TWINS)) if (p[snake] === void 0) p[snake] = p[camel];
|
|
1357
|
-
const failure = p.hook_event_name ===
|
|
1367
|
+
const failure = p.hook_event_name === FAILURE_EVENT3;
|
|
1358
1368
|
if (failure) p.hook_event_name = "PostToolUse";
|
|
1359
1369
|
const toolName = typeof p.tool_name === "string" ? p.tool_name : "";
|
|
1360
1370
|
const prefix = toolName.startsWith(PLUGIN_TOOL_NAME_PREFIX) ? PLUGIN_TOOL_NAME_PREFIX : TOOL_NAME_PREFIX8;
|
|
@@ -1445,7 +1455,8 @@ var OPENCODE_EVENTS = {
|
|
|
1445
1455
|
var SHELL_TOOL_NAME = "bash";
|
|
1446
1456
|
var READ_TOOL_NAME = "read";
|
|
1447
1457
|
var SHELL_TOOL_NAMES5 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
1448
|
-
var
|
|
1458
|
+
var SKILL_TOOL_NAME = "skill";
|
|
1459
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", [READ_TOOL_NAME]: "Read", [SKILL_TOOL_NAME]: "Skill", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n) => [n, "Bash"])) };
|
|
1449
1460
|
function toCanonicalTool(name) {
|
|
1450
1461
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
1451
1462
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -5978,7 +5989,7 @@ function dumpTarget(name, args) {
|
|
|
5978
5989
|
}
|
|
5979
5990
|
|
|
5980
5991
|
// src/core/project/resolve.ts
|
|
5981
|
-
import { basename as basename2, dirname as dirname3, join as join6, resolve as resolve6 } from "node:path";
|
|
5992
|
+
import { basename as basename2, dirname as dirname3, isAbsolute as isAbsolute3, join as join6, resolve as resolve6 } from "node:path";
|
|
5982
5993
|
|
|
5983
5994
|
// src/core/project/sha256.ts
|
|
5984
5995
|
var K = new Uint32Array([
|
|
@@ -6133,12 +6144,7 @@ function dirOf(kind, src) {
|
|
|
6133
6144
|
}
|
|
6134
6145
|
}
|
|
6135
6146
|
function gitDirs(dir) {
|
|
6136
|
-
let cur;
|
|
6137
|
-
try {
|
|
6138
|
-
cur = realpathSync3.native(dir);
|
|
6139
|
-
} catch {
|
|
6140
|
-
throw new CtxError("NO_GIT_DIR", { path: dir });
|
|
6141
|
-
}
|
|
6147
|
+
let cur = nearestRealDir(dir);
|
|
6142
6148
|
const start = cur;
|
|
6143
6149
|
for (; ; ) {
|
|
6144
6150
|
const gitDir = gitDirAt(join6(cur, GIT_DIR_NAME));
|
|
@@ -6151,6 +6157,18 @@ function gitDirs(dir) {
|
|
|
6151
6157
|
cur = up;
|
|
6152
6158
|
}
|
|
6153
6159
|
}
|
|
6160
|
+
function nearestRealDir(dir) {
|
|
6161
|
+
const walk2 = isAbsolute3(dir);
|
|
6162
|
+
for (let d = walk2 ? resolve6(dir) : dir; ; ) {
|
|
6163
|
+
try {
|
|
6164
|
+
return realpathSync3.native(d);
|
|
6165
|
+
} catch {
|
|
6166
|
+
const up = dirname3(d);
|
|
6167
|
+
if (!walk2 || up === d) throw new CtxError("NO_GIT_DIR", { path: dir });
|
|
6168
|
+
d = up;
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
}
|
|
6154
6172
|
function gitDirAt(dotGit) {
|
|
6155
6173
|
let gitDir;
|
|
6156
6174
|
try {
|
|
@@ -6213,7 +6231,7 @@ function resolveProject(agent, src) {
|
|
|
6213
6231
|
},
|
|
6214
6232
|
worktree,
|
|
6215
6233
|
get containmentRoot() {
|
|
6216
|
-
root ??= plain ?? containmentRootOf(
|
|
6234
|
+
root ??= plain ?? containmentRootOf(worktree, commonDir);
|
|
6217
6235
|
return root;
|
|
6218
6236
|
},
|
|
6219
6237
|
agent,
|
package/search.mjs
CHANGED
|
@@ -24,6 +24,7 @@ function readReplaceTrigger(raw) {
|
|
|
24
24
|
var REPLACE_TRIGGER_BYTES = readReplaceTrigger(process.env[REPLACE_TRIGGER_ENV]);
|
|
25
25
|
var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
|
|
26
26
|
var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
|
|
27
|
+
var SKILL_LOAD_TOOLS = Object.freeze(["Skill"]);
|
|
27
28
|
function shellWord(s) {
|
|
28
29
|
return "'" + s.split("'").join("'\\''") + "'";
|
|
29
30
|
}
|
|
@@ -202,6 +203,7 @@ var SEARCH_WRAPPER_FILE = "search.mjs";
|
|
|
202
203
|
var RUN_WRAPPER_AGENT = "claude-code";
|
|
203
204
|
var RUN_SESSION_PREFIX = "mcp:";
|
|
204
205
|
var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" });
|
|
206
|
+
var HOST_SESSION_META = Object.freeze({ zcode: "session_id" });
|
|
205
207
|
var NODE_MIN = "24.15.0";
|
|
206
208
|
var DATA_ROOT = "~/.context-mode";
|
|
207
209
|
var DATA_DIR_ENV = "CONTEXT_MODE_DATA_DIR";
|
|
@@ -675,6 +677,7 @@ var SHELL_TOOL_NAMES = Object.freeze(["Bash", "PowerShell"]);
|
|
|
675
677
|
var POWERSHELL_TOOL = "PowerShell";
|
|
676
678
|
var SHELL_CANONICAL = "Bash";
|
|
677
679
|
var CLAUDE_SHAPE_EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse"];
|
|
680
|
+
var FAILURE_EVENT = "PostToolUseFailure";
|
|
678
681
|
var MCP_PREFIX = "mcp__";
|
|
679
682
|
var MCP_SEP = "__";
|
|
680
683
|
var CLAUDE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
@@ -848,7 +851,14 @@ function requireFields(raw) {
|
|
|
848
851
|
}
|
|
849
852
|
function decode(raw) {
|
|
850
853
|
requireFields(raw);
|
|
851
|
-
const
|
|
854
|
+
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === FAILURE_EVENT;
|
|
855
|
+
const payload = failure ? { ...raw, hook_event_name: "PostToolUse" } : raw;
|
|
856
|
+
const ev = decodeClaudeShape(payload, "claude-code", TOOL_NAME_PREFIX, CLAUDE_SOURCES);
|
|
857
|
+
if (failure) {
|
|
858
|
+
const error = raw.error;
|
|
859
|
+
const text = typeof error === "string" ? error : error === void 0 ? "" : JSON.stringify(error);
|
|
860
|
+
ev.result = { isError: true, bytes: Buffer.byteLength(text), text, keep: true };
|
|
861
|
+
}
|
|
852
862
|
if (ev.tool !== void 0 && ev.tool.name === POWERSHELL_TOOL) ev.tool.canonicalName = SHELL_CANONICAL;
|
|
853
863
|
if (ev.cwd === "") ev.cwd = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
854
864
|
if (ev.event === "PostToolUse" && ev.tool !== void 0 && ev.tool.callId === void 0) {
|
|
@@ -1027,9 +1037,9 @@ var NATIVE_TO_CANONICAL2 = {
|
|
|
1027
1037
|
grep_search: "Grep",
|
|
1028
1038
|
web_fetch: "WebFetch"
|
|
1029
1039
|
};
|
|
1030
|
-
var
|
|
1040
|
+
var FAILURE_EVENT2 = "PostToolUseFailure";
|
|
1031
1041
|
function decode4(raw) {
|
|
1032
|
-
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name ===
|
|
1042
|
+
const failure = typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === FAILURE_EVENT2;
|
|
1033
1043
|
const payload = failure ? { ...raw, hook_event_name: "PostToolUse" } : raw;
|
|
1034
1044
|
const ev = decodeClaudeShape(payload, "qwen", TOOL_NAME_PREFIX4, QWEN_SOURCES);
|
|
1035
1045
|
if (ev.tool !== void 0 && Object.hasOwn(NATIVE_TO_CANONICAL2, ev.tool.name)) ev.tool.canonicalName = NATIVE_TO_CANONICAL2[ev.tool.name];
|
|
@@ -1349,12 +1359,12 @@ var TOOL_NAME_PREFIX8 = "mcp__context-mode__";
|
|
|
1349
1359
|
var PLUGIN_TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
1350
1360
|
var ZCODE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
1351
1361
|
var TWINS = { hook_event_name: "hookEventName", session_id: "sessionId" };
|
|
1352
|
-
var
|
|
1362
|
+
var FAILURE_EVENT3 = "PostToolUseFailure";
|
|
1353
1363
|
function decode8(raw) {
|
|
1354
1364
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("zcode: hook payload is not a JSON object");
|
|
1355
1365
|
const p = { ...raw };
|
|
1356
1366
|
for (const [snake, camel] of Object.entries(TWINS)) if (p[snake] === void 0) p[snake] = p[camel];
|
|
1357
|
-
const failure = p.hook_event_name ===
|
|
1367
|
+
const failure = p.hook_event_name === FAILURE_EVENT3;
|
|
1358
1368
|
if (failure) p.hook_event_name = "PostToolUse";
|
|
1359
1369
|
const toolName = typeof p.tool_name === "string" ? p.tool_name : "";
|
|
1360
1370
|
const prefix = toolName.startsWith(PLUGIN_TOOL_NAME_PREFIX) ? PLUGIN_TOOL_NAME_PREFIX : TOOL_NAME_PREFIX8;
|
|
@@ -1445,7 +1455,8 @@ var OPENCODE_EVENTS = {
|
|
|
1445
1455
|
var SHELL_TOOL_NAME = "bash";
|
|
1446
1456
|
var READ_TOOL_NAME = "read";
|
|
1447
1457
|
var SHELL_TOOL_NAMES5 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
1448
|
-
var
|
|
1458
|
+
var SKILL_TOOL_NAME = "skill";
|
|
1459
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", [READ_TOOL_NAME]: "Read", [SKILL_TOOL_NAME]: "Skill", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n) => [n, "Bash"])) };
|
|
1449
1460
|
function toCanonicalTool(name) {
|
|
1450
1461
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
1451
1462
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -5978,7 +5989,7 @@ function dumpTarget(name, args) {
|
|
|
5978
5989
|
}
|
|
5979
5990
|
|
|
5980
5991
|
// src/core/project/resolve.ts
|
|
5981
|
-
import { basename as basename2, dirname as dirname3, join as join6, resolve as resolve6 } from "node:path";
|
|
5992
|
+
import { basename as basename2, dirname as dirname3, isAbsolute as isAbsolute3, join as join6, resolve as resolve6 } from "node:path";
|
|
5982
5993
|
|
|
5983
5994
|
// src/core/project/sha256.ts
|
|
5984
5995
|
var K = new Uint32Array([
|
|
@@ -6133,12 +6144,7 @@ function dirOf(kind, src) {
|
|
|
6133
6144
|
}
|
|
6134
6145
|
}
|
|
6135
6146
|
function gitDirs(dir) {
|
|
6136
|
-
let cur;
|
|
6137
|
-
try {
|
|
6138
|
-
cur = realpathSync3.native(dir);
|
|
6139
|
-
} catch {
|
|
6140
|
-
throw new CtxError("NO_GIT_DIR", { path: dir });
|
|
6141
|
-
}
|
|
6147
|
+
let cur = nearestRealDir(dir);
|
|
6142
6148
|
const start = cur;
|
|
6143
6149
|
for (; ; ) {
|
|
6144
6150
|
const gitDir = gitDirAt(join6(cur, GIT_DIR_NAME));
|
|
@@ -6151,6 +6157,18 @@ function gitDirs(dir) {
|
|
|
6151
6157
|
cur = up;
|
|
6152
6158
|
}
|
|
6153
6159
|
}
|
|
6160
|
+
function nearestRealDir(dir) {
|
|
6161
|
+
const walk2 = isAbsolute3(dir);
|
|
6162
|
+
for (let d = walk2 ? resolve6(dir) : dir; ; ) {
|
|
6163
|
+
try {
|
|
6164
|
+
return realpathSync3.native(d);
|
|
6165
|
+
} catch {
|
|
6166
|
+
const up = dirname3(d);
|
|
6167
|
+
if (!walk2 || up === d) throw new CtxError("NO_GIT_DIR", { path: dir });
|
|
6168
|
+
d = up;
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
}
|
|
6154
6172
|
function gitDirAt(dotGit) {
|
|
6155
6173
|
let gitDir;
|
|
6156
6174
|
try {
|
|
@@ -6213,7 +6231,7 @@ function resolveProject(agent, src) {
|
|
|
6213
6231
|
},
|
|
6214
6232
|
worktree,
|
|
6215
6233
|
get containmentRoot() {
|
|
6216
|
-
root ??= plain ?? containmentRootOf(
|
|
6234
|
+
root ??= plain ?? containmentRootOf(worktree, commonDir);
|
|
6217
6235
|
return root;
|
|
6218
6236
|
},
|
|
6219
6237
|
agent,
|