context-mode 1.0.153 → 1.0.154

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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.153"
9
+ "version": "1.0.154"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "context-mode",
14
14
  "source": "./",
15
15
  "description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
16
- "version": "1.0.153",
16
+ "version": "1.0.154",
17
17
  "author": {
18
18
  "name": "Mert Koseoğlu"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.153",
3
+ "version": "1.0.154",
4
4
  "description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.153",
3
+ "version": "1.0.154",
4
4
  "description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -3,7 +3,7 @@
3
3
  "name": "Context Mode",
4
4
  "kind": "tool",
5
5
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
6
- "version": "1.0.153",
6
+ "version": "1.0.154",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.153",
3
+ "version": "1.0.154",
4
4
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -18,14 +18,50 @@ export const formatters = {
18
18
  permissionDecision: "ask",
19
19
  },
20
20
  }),
21
- modify: (updatedInput) => ({
22
- hookSpecificOutput: {
23
- hookEventName: "PreToolUse",
24
- permissionDecision: "allow",
25
- permissionDecisionReason: "Routed to context-mode sandbox",
26
- updatedInput,
27
- },
28
- }),
21
+ // Tool-aware modify handling for claude-code:
22
+ //
23
+ // - Bash redirect (updatedInput.command): CC v2.1.x ignores
24
+ // `updatedInput.command` substitution under `permissionDecision: "allow"`
25
+ // — original command runs unchanged. Verified via /diagnose Phase 4
26
+ // forced-deny probe: only `permissionDecision: "deny"` is honored for
27
+ // Bash blocking. Emit deny + extract echo payload into
28
+ // `permissionDecisionReason`.
29
+ //
30
+ // - Agent prompt injection (updatedInput.prompt): CC honors
31
+ // allow+updatedInput for Agent tool — modified prompt reaches the
32
+ // subagent. Keep modify shape so subagent routing-block injection works.
33
+ //
34
+ // - Any other shape: pass through as modify and let CC decide.
35
+ //
36
+ // Other adapters (gemini-cli, vscode-copilot, etc.) keep their own modify
37
+ // semantics — their hosts implement updatedInput differently or not at all.
38
+ modify: (updatedInput) => {
39
+ const ui = updatedInput ?? {};
40
+ const isBashCommandRedirect = "command" in ui;
41
+ if (!isBashCommandRedirect) {
42
+ return {
43
+ hookSpecificOutput: {
44
+ hookEventName: "PreToolUse",
45
+ updatedInput: ui,
46
+ },
47
+ };
48
+ }
49
+ // routing.mjs wraps the redirect guidance in `echo "..."` form.
50
+ // Extract the quoted payload as the deny reason. Fall back to a generic
51
+ // ADR-0003 CASE A message if the shape doesn't match.
52
+ const cmd = ui.command ?? "";
53
+ const m = cmd.match(/^echo\s+"(.+)"$/s);
54
+ const reason = m
55
+ ? m[1]
56
+ : "Redirected to ctx_execute / ctx_fetch_and_index. Call ctx_execute(language, code) to fetch and derive your answer in one round trip, or call ctx_fetch_and_index(url, source) when you want to query the response later via ctx_search. Both have full network access. Retry the same call on a transient DNS error (EAI_AGAIN, ETIMEDOUT, ENETUNREACH).";
57
+ return {
58
+ hookSpecificOutput: {
59
+ hookEventName: "PreToolUse",
60
+ permissionDecision: "deny",
61
+ permissionDecisionReason: reason,
62
+ },
63
+ };
64
+ },
29
65
  context: (additionalContext) => ({
30
66
  hookSpecificOutput: {
31
67
  hookEventName: "PreToolUse",
@@ -54,14 +54,50 @@ export function formatDecision(decision) {
54
54
  },
55
55
  };
56
56
 
57
- case "modify":
57
+ case "modify": {
58
58
  if (isHeadless()) return null;
59
+
60
+ // Tool-aware modify handling:
61
+ //
62
+ // - Bash redirect (updatedInput.command): CC v2.1.x ignores
63
+ // `updatedInput.command` substitution under `permissionDecision: "allow"`
64
+ // — original command runs unchanged. Verified via /diagnose Phase 4
65
+ // forced-deny probe: only `permissionDecision: "deny"` is honored for
66
+ // Bash blocking. Emit deny + extract echo payload into
67
+ // `permissionDecisionReason`.
68
+ //
69
+ // - Agent prompt injection (updatedInput.prompt): CC honors allow+updatedInput
70
+ // for the Agent tool — the modified prompt actually reaches the subagent.
71
+ // Keep the original modify shape so subagent routing-block injection works.
72
+ //
73
+ // - Any other shape: pass through as modify (no command, no prompt — let
74
+ // CC decide if the field is honored).
75
+ const ui = decision.updatedInput ?? {};
76
+ const isBashCommandRedirect = "command" in ui;
77
+ if (!isBashCommandRedirect) {
78
+ return {
79
+ hookSpecificOutput: {
80
+ hookEventName: "PreToolUse",
81
+ updatedInput: ui,
82
+ },
83
+ };
84
+ }
85
+ // routing.mjs wraps the redirect guidance in `echo "..."` form.
86
+ // Extract the quoted payload as the deny reason. Fall back to a generic
87
+ // ADR-0003 CASE A message if the shape doesn't match.
88
+ const cmd = ui.command ?? "";
89
+ const m = cmd.match(/^echo\s+"(.+)"$/s);
90
+ const reason = m
91
+ ? m[1]
92
+ : "Redirected to ctx_execute / ctx_fetch_and_index. Call ctx_execute(language, code) to fetch and derive your answer in one round trip, or call ctx_fetch_and_index(url, source) when you want to query the response later via ctx_search. Both have full network access. Retry the same call on a transient DNS error (EAI_AGAIN, ETIMEDOUT, ENETUNREACH).";
59
93
  return {
60
94
  hookSpecificOutput: {
61
95
  hookEventName: "PreToolUse",
62
- updatedInput: decision.updatedInput,
96
+ permissionDecision: "deny",
97
+ permissionDecisionReason: reason,
63
98
  },
64
99
  };
100
+ }
65
101
 
66
102
  case "context":
67
103
  return {
@@ -3,7 +3,7 @@
3
3
  "name": "Context Mode",
4
4
  "kind": "tool",
5
5
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
6
- "version": "1.0.153",
6
+ "version": "1.0.154",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.153",
3
+ "version": "1.0.154",
4
4
  "type": "module",
5
5
  "description": "MCP plugin that saves 98% of your context window. Works with Claude Code, Gemini CLI, VS Code Copilot, OpenCode, and Codex CLI. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
6
6
  "author": "Mert Koseoğlu",