Repository navigation
feat(runtime)!: select exact vetted Pi extension tools #9265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
97001cc
3682c28
5fd10f0
cc928ba
7fbec6a
b3834d6
d0c473b
4841029
c28e446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,9 +185,9 @@ func parseClaudeToolSpecs(specs []string) (tools, bashAllowlist []string) { | |
| // read, bash, edit, write, grep, find, ls — every non-Windows built-in; pi | ||
| // also has powershell — all activated via settings.json defaultTools, since | ||
| // pi alone starts with only the first four). Claude tools without a pi | ||
| // counterpart are reported as unsupported; Skill maps to no tool (pi's | ||
| // skills are prompt-driven), and Bootstrap adds read for it, since pi only | ||
| // emits the skills section of the system prompt when read is active. | ||
| // counterpart resolve as exact vetted extension tool names. Skill maps to | ||
| // no tool (pi's skills are prompt-driven), and Bootstrap adds read for it: | ||
| // pi emits the skills section of the system prompt only when read is active. | ||
| var piToolForClaude = map[string]string{ | ||
| "Bash": "bash", | ||
| "Read": "read", | ||
|
|
@@ -311,8 +311,11 @@ func piToolsFor(claudeTools []string) (tools, unsupported []string) { | |
| } | ||
| pt, ok := piToolForClaude[ct] | ||
| if !ok { | ||
| unsupported = append(unsupported, ct) | ||
| continue | ||
| if !piNativeToolName(ct) { | ||
| unsupported = append(unsupported, ct) | ||
| continue | ||
| } | ||
| pt = ct | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| if !seen[pt] { | ||
| seen[pt] = true | ||
|
|
@@ -321,3 +324,35 @@ func piToolsFor(claudeTools []string) (tools, unsupported []string) { | |
| } | ||
| return tools, unsupported | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOW (architect): The native versus MCP classification now lives in two places: this regex plus piMCPResourcePattern in Go, and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| // Exact native names cannot contain wildcards or CLI list separators. | ||
| var piExactNativeTool = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_-]*$`) | ||
|
|
||
| func piNativeToolsFor(specs []string) []string { | ||
| var out []string | ||
| for _, name := range specs { | ||
| if _, builtin := piToolForClaude[name]; builtin || name == "Skill" || name == piAgentToolName || name == piAgentToolAlias || name == "ListMcpResourcesTool" || name == "ReadMcpResourceTool" || piMCPSelectorPattern.MatchString(name) || piMCPResourcePattern(name) { | ||
| continue | ||
| } | ||
| if piNativeToolName(name) && !hasTool(out, name) { | ||
| out = append(out, name) | ||
| } | ||
| } | ||
| return out | ||
| } | ||
|
|
||
| func piReservedUnmappedToolName(name string) bool { | ||
| switch name { | ||
| case "powershell", "codemode", "tool_search": | ||
| return true | ||
| default: | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| func piNativeToolName(name string) bool { | ||
|
eshulman2 marked this conversation as resolved.
Resolved
|
||
| if _, builtin := claudeToolForPi[name]; builtin || piReservedUnmappedToolName(name) { | ||
| return false | ||
| } | ||
| return piExactNativeTool.MatchString(name) && !strings.HasPrefix(name, "mcp__") && !strings.HasPrefix(name, "list_mcp_") && !strings.HasPrefix(name, "read_mcp_") | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.