context-mode 2.0.0-next.11 → 2.0.0-next.13
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/SHA256SUMS +14 -14
- package/cli.mjs +89 -23
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +88 -84
- package/opencode/plugin.js +383 -157
- package/package.json +1 -1
- package/pi/index.js +434 -195
- package/qwen-extension.json +1 -1
- package/run.mjs +42 -12
- package/search.mjs +42 -12
- package/server.mjs +211 -101
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import{createRequire as __cmRequire}from"node:module";if(typeof process.getBuiltinModule!=="function")process.getBuiltinModule=(id)=>__cmRequire(import.meta.url)(id);
|
|
2
|
+
|
|
1
3
|
// src/entries/run.ts
|
|
2
4
|
import { basename as basename2 } from "node:path";
|
|
3
5
|
|
|
@@ -206,6 +208,24 @@ var DENY_WEBFETCH_TOOLS = Object.freeze(["ctx_index", "ctx_search"]);
|
|
|
206
208
|
var USER_DENY_REASON_PREFIX = "Blocked by security policy: matches deny pattern ";
|
|
207
209
|
var POLICY_UNREADABLE_LINE = "context-mode: your deny rules could not be read. Fix: run ctx_doctor.";
|
|
208
210
|
var PARSE_ERROR_DENY_LINE = "context-mode: could not parse this command; it may be blocked by your own rules. Run it through ctx_execute instead.";
|
|
211
|
+
var HOOK_FAIL_TOOL_KEYS = Object.freeze(["tool_name", "toolName", "tool"]);
|
|
212
|
+
var HOOK_FAIL_EVENT_KEYS = Object.freeze(["hook_event_name", "hookEventName", "type"]);
|
|
213
|
+
var HOOK_FAIL_INPUT_KEYS = Object.freeze(["tool_input", "toolArgs", "input", "args"]);
|
|
214
|
+
var HOOK_FAIL_CWD_KEYS = Object.freeze(["cwd", "directory"]);
|
|
215
|
+
var HOOK_FAIL_PRE_EVENTS = Object.freeze(["pretooluse", "beforetool", "tool_call", "execute.before", "tool.execute.before"]);
|
|
216
|
+
var HOOK_FAULT_STAGES = Object.freeze(["decode", "project", "policy", "store", "encode"]);
|
|
217
|
+
var HOOK_FAIL_TOOLS = Object.freeze({
|
|
218
|
+
shell: Object.freeze(["Bash", "bash", "shell"]),
|
|
219
|
+
read: Object.freeze(["Read", "read_file"]),
|
|
220
|
+
grep: Object.freeze(["Grep", "grep_search"]),
|
|
221
|
+
fetch: Object.freeze(["WebFetch", "web_fetch", "fetch"])
|
|
222
|
+
});
|
|
223
|
+
var HOOK_FAIL_REDIRECT = Object.freeze({
|
|
224
|
+
read: "Read the file in parts with offset and limit, or process it with ctx_execute(language, code); only what you print comes back.",
|
|
225
|
+
shell: "Run the command with ctx_execute(language, code) or ctx_batch instead; only the part that matches your intent comes back.",
|
|
226
|
+
grep: "Search with ctx_execute(language, code), or index the files with ctx_index and query them with ctx_search.",
|
|
227
|
+
fetch: "Index the URL with ctx_index and query it with ctx_search."
|
|
228
|
+
});
|
|
209
229
|
var BOUNDED_COMMANDS = Object.freeze(["pwd", "whoami", "uname", "id", "realpath", "ln"]);
|
|
210
230
|
var BOUNDED_GIT_SUBCOMMANDS = Object.freeze(["status"]);
|
|
211
231
|
var VERSION_PROBE_FLAGS = Object.freeze(["--version", "-v"]);
|
|
@@ -362,6 +382,7 @@ var V1_REASON = Object.freeze({
|
|
|
362
382
|
});
|
|
363
383
|
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering]);
|
|
364
384
|
var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
|
|
385
|
+
var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
|
|
365
386
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
366
387
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
367
388
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -4241,6 +4262,7 @@ function pipeline(p) {
|
|
|
4241
4262
|
all.push(...last.cmds);
|
|
4242
4263
|
const t = at(p);
|
|
4243
4264
|
if (t !== void 0 && t.kind === "op" && PIPES.includes(t.text)) {
|
|
4265
|
+
for (const c of last.cmds) c.pipesOut = true;
|
|
4244
4266
|
p.i++;
|
|
4245
4267
|
continue;
|
|
4246
4268
|
}
|
|
@@ -4330,7 +4352,7 @@ var WRAPPERS = Object.freeze({
|
|
|
4330
4352
|
command: { valueShorts: NONE, valueLongs: [], assignments: false, duration: false, refuseShorts: "vV" },
|
|
4331
4353
|
xargs: { valueShorts: "aEdILnPs", valueLongs: ["--arg-file", "--delimiter", "--max-args", "--max-procs", "--max-chars"], assignments: false, duration: false, refuseShorts: NONE }
|
|
4332
4354
|
});
|
|
4333
|
-
var SHELLS = ["bash", "sh"];
|
|
4355
|
+
var SHELLS = ["bash", "sh", "zsh"];
|
|
4334
4356
|
var SCRIPT_FLAG = "c";
|
|
4335
4357
|
var SHELL_LABEL_SUFFIX = " -c";
|
|
4336
4358
|
var SHELL_VALUE_OPTS = ["-o", "+o", "-O", "+O"];
|
|
@@ -4731,6 +4753,7 @@ function inlineHttp(raw) {
|
|
|
4731
4753
|
}
|
|
4732
4754
|
return false;
|
|
4733
4755
|
}
|
|
4756
|
+
var CD_COMMAND = "cd";
|
|
4734
4757
|
function fileSize(abs) {
|
|
4735
4758
|
try {
|
|
4736
4759
|
const st = statSync(abs);
|
|
@@ -4752,17 +4775,24 @@ function read(ev, row, input) {
|
|
|
4752
4775
|
}
|
|
4753
4776
|
function shellDump(cmds, cwd, row) {
|
|
4754
4777
|
if (row.nativeTools.read !== void 0 && row.nativeTools.read.length > 0 && dumpRunsThenReplaces(row)) return null;
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4778
|
+
let dir = cwd;
|
|
4779
|
+
let verdict = null;
|
|
4780
|
+
for (const c of cmds) {
|
|
4781
|
+
const name = c.argv0.toLowerCase();
|
|
4782
|
+
if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve(dir, c.args[0]);
|
|
4783
|
+
if (c.redirectsToFile || c.endsInBoundedSink || c.pipesOut === true || c.insideConstruct !== void 0) continue;
|
|
4784
|
+
if (!has(SHELL_DUMP_COMMANDS, name)) continue;
|
|
4785
|
+
const d = dumpTarget(name, c.args);
|
|
4786
|
+
if (d === null) continue;
|
|
4787
|
+
if (d.bounded) {
|
|
4788
|
+
verdict = ALLOW;
|
|
4789
|
+
continue;
|
|
4790
|
+
}
|
|
4791
|
+
const abs = resolve(dir, d.file);
|
|
4792
|
+
const size = fileSize(abs);
|
|
4793
|
+
if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row.toolNamePrefix));
|
|
4794
|
+
}
|
|
4795
|
+
return verdict;
|
|
4766
4796
|
}
|
|
4767
4797
|
var allDigits2 = (s) => s !== "" && [...s].every((ch) => ch >= "0" && ch <= "9");
|
|
4768
4798
|
function countFlag(a) {
|
package/search.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import{createRequire as __cmRequire}from"node:module";if(typeof process.getBuiltinModule!=="function")process.getBuiltinModule=(id)=>__cmRequire(import.meta.url)(id);
|
|
2
|
+
|
|
1
3
|
// src/entries/run.ts
|
|
2
4
|
import { basename as basename2 } from "node:path";
|
|
3
5
|
|
|
@@ -206,6 +208,24 @@ var DENY_WEBFETCH_TOOLS = Object.freeze(["ctx_index", "ctx_search"]);
|
|
|
206
208
|
var USER_DENY_REASON_PREFIX = "Blocked by security policy: matches deny pattern ";
|
|
207
209
|
var POLICY_UNREADABLE_LINE = "context-mode: your deny rules could not be read. Fix: run ctx_doctor.";
|
|
208
210
|
var PARSE_ERROR_DENY_LINE = "context-mode: could not parse this command; it may be blocked by your own rules. Run it through ctx_execute instead.";
|
|
211
|
+
var HOOK_FAIL_TOOL_KEYS = Object.freeze(["tool_name", "toolName", "tool"]);
|
|
212
|
+
var HOOK_FAIL_EVENT_KEYS = Object.freeze(["hook_event_name", "hookEventName", "type"]);
|
|
213
|
+
var HOOK_FAIL_INPUT_KEYS = Object.freeze(["tool_input", "toolArgs", "input", "args"]);
|
|
214
|
+
var HOOK_FAIL_CWD_KEYS = Object.freeze(["cwd", "directory"]);
|
|
215
|
+
var HOOK_FAIL_PRE_EVENTS = Object.freeze(["pretooluse", "beforetool", "tool_call", "execute.before", "tool.execute.before"]);
|
|
216
|
+
var HOOK_FAULT_STAGES = Object.freeze(["decode", "project", "policy", "store", "encode"]);
|
|
217
|
+
var HOOK_FAIL_TOOLS = Object.freeze({
|
|
218
|
+
shell: Object.freeze(["Bash", "bash", "shell"]),
|
|
219
|
+
read: Object.freeze(["Read", "read_file"]),
|
|
220
|
+
grep: Object.freeze(["Grep", "grep_search"]),
|
|
221
|
+
fetch: Object.freeze(["WebFetch", "web_fetch", "fetch"])
|
|
222
|
+
});
|
|
223
|
+
var HOOK_FAIL_REDIRECT = Object.freeze({
|
|
224
|
+
read: "Read the file in parts with offset and limit, or process it with ctx_execute(language, code); only what you print comes back.",
|
|
225
|
+
shell: "Run the command with ctx_execute(language, code) or ctx_batch instead; only the part that matches your intent comes back.",
|
|
226
|
+
grep: "Search with ctx_execute(language, code), or index the files with ctx_index and query them with ctx_search.",
|
|
227
|
+
fetch: "Index the URL with ctx_index and query it with ctx_search."
|
|
228
|
+
});
|
|
209
229
|
var BOUNDED_COMMANDS = Object.freeze(["pwd", "whoami", "uname", "id", "realpath", "ln"]);
|
|
210
230
|
var BOUNDED_GIT_SUBCOMMANDS = Object.freeze(["status"]);
|
|
211
231
|
var VERSION_PROBE_FLAGS = Object.freeze(["--version", "-v"]);
|
|
@@ -362,6 +382,7 @@ var V1_REASON = Object.freeze({
|
|
|
362
382
|
});
|
|
363
383
|
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering]);
|
|
364
384
|
var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
|
|
385
|
+
var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
|
|
365
386
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
366
387
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
367
388
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -4241,6 +4262,7 @@ function pipeline(p) {
|
|
|
4241
4262
|
all.push(...last.cmds);
|
|
4242
4263
|
const t = at(p);
|
|
4243
4264
|
if (t !== void 0 && t.kind === "op" && PIPES.includes(t.text)) {
|
|
4265
|
+
for (const c of last.cmds) c.pipesOut = true;
|
|
4244
4266
|
p.i++;
|
|
4245
4267
|
continue;
|
|
4246
4268
|
}
|
|
@@ -4330,7 +4352,7 @@ var WRAPPERS = Object.freeze({
|
|
|
4330
4352
|
command: { valueShorts: NONE, valueLongs: [], assignments: false, duration: false, refuseShorts: "vV" },
|
|
4331
4353
|
xargs: { valueShorts: "aEdILnPs", valueLongs: ["--arg-file", "--delimiter", "--max-args", "--max-procs", "--max-chars"], assignments: false, duration: false, refuseShorts: NONE }
|
|
4332
4354
|
});
|
|
4333
|
-
var SHELLS = ["bash", "sh"];
|
|
4355
|
+
var SHELLS = ["bash", "sh", "zsh"];
|
|
4334
4356
|
var SCRIPT_FLAG = "c";
|
|
4335
4357
|
var SHELL_LABEL_SUFFIX = " -c";
|
|
4336
4358
|
var SHELL_VALUE_OPTS = ["-o", "+o", "-O", "+O"];
|
|
@@ -4731,6 +4753,7 @@ function inlineHttp(raw) {
|
|
|
4731
4753
|
}
|
|
4732
4754
|
return false;
|
|
4733
4755
|
}
|
|
4756
|
+
var CD_COMMAND = "cd";
|
|
4734
4757
|
function fileSize(abs) {
|
|
4735
4758
|
try {
|
|
4736
4759
|
const st = statSync(abs);
|
|
@@ -4752,17 +4775,24 @@ function read(ev, row, input) {
|
|
|
4752
4775
|
}
|
|
4753
4776
|
function shellDump(cmds, cwd, row) {
|
|
4754
4777
|
if (row.nativeTools.read !== void 0 && row.nativeTools.read.length > 0 && dumpRunsThenReplaces(row)) return null;
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4778
|
+
let dir = cwd;
|
|
4779
|
+
let verdict = null;
|
|
4780
|
+
for (const c of cmds) {
|
|
4781
|
+
const name = c.argv0.toLowerCase();
|
|
4782
|
+
if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve(dir, c.args[0]);
|
|
4783
|
+
if (c.redirectsToFile || c.endsInBoundedSink || c.pipesOut === true || c.insideConstruct !== void 0) continue;
|
|
4784
|
+
if (!has(SHELL_DUMP_COMMANDS, name)) continue;
|
|
4785
|
+
const d = dumpTarget(name, c.args);
|
|
4786
|
+
if (d === null) continue;
|
|
4787
|
+
if (d.bounded) {
|
|
4788
|
+
verdict = ALLOW;
|
|
4789
|
+
continue;
|
|
4790
|
+
}
|
|
4791
|
+
const abs = resolve(dir, d.file);
|
|
4792
|
+
const size = fileSize(abs);
|
|
4793
|
+
if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row.toolNamePrefix));
|
|
4794
|
+
}
|
|
4795
|
+
return verdict;
|
|
4766
4796
|
}
|
|
4767
4797
|
var allDigits2 = (s) => s !== "" && [...s].every((ch) => ch >= "0" && ch <= "9");
|
|
4768
4798
|
function countFlag(a) {
|