@cjhyy/code-shell-capability-coding 0.8.0 → 0.8.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.
|
@@ -49,17 +49,15 @@ export declare function writeClaudeMcpConfigFile(options: ClaudeMcpConfigOptions
|
|
|
49
49
|
*
|
|
50
50
|
* Safety therefore rests on ONE property, enforced below rather than assumed:
|
|
51
51
|
* every emitted name is `mcp__<server>__<tool>`, which routes to CodeShell's own
|
|
52
|
-
* `ToolExecutor` and exposure policy.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* `ToolExecutor` and exposure policy. CodeShell deliberately exposes governed
|
|
53
|
+
* alternatives named `Read`, `Bash`, `Write`, and `Edit`; after qualification
|
|
54
|
+
* these become `mcp__codeshell_tools__Read`, etc. They do not pre-approve Claude
|
|
55
|
+
* Code's bare built-ins with the same names.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* looks like a built-in-tool pattern (`Bash(git *)`, `*`) or is already qualified
|
|
62
|
-
* for a different server is a programming error.
|
|
57
|
+
* The function accepts only plain tool identifiers sourced from the exposed
|
|
58
|
+
* CodeShell registry, then adds the MCP namespace itself. Anything that looks
|
|
59
|
+
* like a Claude permission pattern (`Bash(git *)`, `*`) or is already qualified
|
|
60
|
+
* for another server is a programming error and is rejected.
|
|
63
61
|
*/
|
|
64
62
|
export declare function claudeAllowedToolNames(toolNames: Iterable<string>, serverName?: string): string[];
|
|
65
63
|
/**
|
|
@@ -24,30 +24,6 @@ import { join } from "node:path";
|
|
|
24
24
|
export const CLAUDE_MCP_SERVER_NAME = "codeshell_tools";
|
|
25
25
|
/** `mcp__<server>__<tool>` — the only shape that may reach `--allowed-tools`. */
|
|
26
26
|
const MCP_TOOL_NAME = /^mcp__[a-z0-9_]+__[A-Za-z0-9_]+$/;
|
|
27
|
-
/**
|
|
28
|
-
* Claude Code's own built-in tools. They share the plain-identifier shape with
|
|
29
|
-
* CodeShell tool names, so shape validation alone cannot separate them — and
|
|
30
|
-
* pre-approving one of these grants the untrusted runtime an unapproved built-in.
|
|
31
|
-
* Over-inclusive on purpose: a false positive is a loud error at a call site, a
|
|
32
|
-
* false negative is a silent capability grant.
|
|
33
|
-
*/
|
|
34
|
-
const CLAUDE_BUILTIN_TOOL_NAMES = new Set([
|
|
35
|
-
"Agent",
|
|
36
|
-
"Bash",
|
|
37
|
-
"BashOutput",
|
|
38
|
-
"Edit",
|
|
39
|
-
"ExitPlanMode",
|
|
40
|
-
"Glob",
|
|
41
|
-
"Grep",
|
|
42
|
-
"KillShell",
|
|
43
|
-
"NotebookEdit",
|
|
44
|
-
"Read",
|
|
45
|
-
"Task",
|
|
46
|
-
"TodoWrite",
|
|
47
|
-
"WebFetch",
|
|
48
|
-
"WebSearch",
|
|
49
|
-
"Write",
|
|
50
|
-
]);
|
|
51
27
|
/**
|
|
52
28
|
* The `--mcp-config` payload as an inline JSON string.
|
|
53
29
|
*
|
|
@@ -107,17 +83,15 @@ export function writeClaudeMcpConfigFile(options) {
|
|
|
107
83
|
*
|
|
108
84
|
* Safety therefore rests on ONE property, enforced below rather than assumed:
|
|
109
85
|
* every emitted name is `mcp__<server>__<tool>`, which routes to CodeShell's own
|
|
110
|
-
* `ToolExecutor` and exposure policy.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
86
|
+
* `ToolExecutor` and exposure policy. CodeShell deliberately exposes governed
|
|
87
|
+
* alternatives named `Read`, `Bash`, `Write`, and `Edit`; after qualification
|
|
88
|
+
* these become `mcp__codeshell_tools__Read`, etc. They do not pre-approve Claude
|
|
89
|
+
* Code's bare built-ins with the same names.
|
|
114
90
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* looks like a built-in-tool pattern (`Bash(git *)`, `*`) or is already qualified
|
|
120
|
-
* for a different server is a programming error.
|
|
91
|
+
* The function accepts only plain tool identifiers sourced from the exposed
|
|
92
|
+
* CodeShell registry, then adds the MCP namespace itself. Anything that looks
|
|
93
|
+
* like a Claude permission pattern (`Bash(git *)`, `*`) or is already qualified
|
|
94
|
+
* for another server is a programming error and is rejected.
|
|
121
95
|
*/
|
|
122
96
|
export function claudeAllowedToolNames(toolNames, serverName = CLAUDE_MCP_SERVER_NAME) {
|
|
123
97
|
const reject = (name, why) => {
|
|
@@ -136,11 +110,6 @@ export function claudeAllowedToolNames(toolNames, serverName = CLAUDE_MCP_SERVER
|
|
|
136
110
|
if (name.startsWith("mcp__")) {
|
|
137
111
|
return reject(name, "already qualified — pass a plain CodeShell tool name");
|
|
138
112
|
}
|
|
139
|
-
// Claude Code's own built-ins share the identifier shape, so shape alone is
|
|
140
|
-
// not enough — these must never be pre-approved through this path.
|
|
141
|
-
if (CLAUDE_BUILTIN_TOOL_NAMES.has(name)) {
|
|
142
|
-
return reject(name, "this is a Claude Code built-in tool, not a CodeShell tool");
|
|
143
|
-
}
|
|
144
113
|
const qualified = `mcp__${serverName}__${name}`;
|
|
145
114
|
if (!MCP_TOOL_NAME.test(qualified))
|
|
146
115
|
return reject(name, "does not qualify as an MCP tool name");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cjhyy/code-shell-capability-coding",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Coding capability pack for the generic code-shell agent core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@cjhyy/code-shell-core": "0.8.
|
|
42
|
+
"@cjhyy/code-shell-core": "0.8.2"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=20.10"
|