You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(workspace): support tool name remapping in workspace tools config (#13687)
## Summary
- Adds a `name` property to `WorkspaceToolConfig` so workspace tools can
be exposed under custom names to the LLM
- Mastracode uses this to remap workspace tools back to its original
names (`view`, `search_content`, `string_replace_lsp`, etc.) so they
match the tool guidance prompts
- Removes hardcoded tool-name cross-references from `edit-file` and
`ast-edit` descriptions/output, since tools can be renamed or disabled
- Extracts tool names into `MC_TOOLS` constants and
`TOOL_NAME_OVERRIDES` mapping in `mastracode/src/tool-names.ts` for
reuse across permissions, TUI, subagents, and tool guidance
- Fixes pre-existing test failures in mastracode's `extra-tools.test.ts`
that still expected workspace tools in `createDynamicTools()` output
## Test plan
- [x] All 19 core workspace tool creation tests pass (including 6 new
name remapping tests)
- [x] All 14 mastracode extra-tools tests pass
- [x] Core and mastracode packages build cleanly
- [x] Verify mastracode works end-to-end with remapped tool names
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Tools can now be exposed under custom names while maintaining their
original configuration identifiers.
* **Documentation**
* Updated tool descriptions to remove implementation-specific references
for improved clarity.
* **Refactor**
* Standardized tool name references throughout the codebase for
consistency and maintainability.
* **Tests**
* Added comprehensive test coverage for custom tool name remapping
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: CalebBarnes <CalebBarnes@users.noreply.github.com>
Added `name` property to `WorkspaceToolConfig` for remapping workspace tool names. Tools can now be exposed under custom names to the LLM while keeping the original constant as the config key.
Workspace tool names are now remapped to canonical names (`view`, `search_content`, `string_replace_lsp`, etc.) so they match tool guidance prompts, permissions, and TUI rendering.
**${MC_TOOLS.EXECUTE_COMMAND}** — Run shell commands
59
61
- Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
60
-
- Do NOT use for: file reading (use view), file search (use search_content/find_files), file editing (use string_replace_lsp/write_file).
62
+
- Do NOT use for: file reading (use ${MC_TOOLS.VIEW}), file search (use ${MC_TOOLS.SEARCH_CONTENT}/${MC_TOOLS.FIND_FILES}), file editing (use ${MC_TOOLS.STRING_REPLACE_LSP}/${MC_TOOLS.WRITE_FILE}).
61
63
- Commands have a 30-second default timeout. Use the \`timeout\` parameter for longer-running commands.
62
64
- Pipe to \`| tail -N\` for commands with long output — the full output streams to the user, only the last N lines are returned to you. If you're building any kind of package you should be tailing.
63
65
- Good: Run independent commands in parallel when possible.
64
-
- Bad: Running \`cat file.txt\` — use the view tool instead.`);
66
+
- Bad: Running \`cat file.txt\` — use the ${MC_TOOLS.VIEW} tool instead.`);
65
67
}
66
68
67
69
if(readTools.length>0){
@@ -73,22 +75,22 @@ You have access to the following tools. Use the RIGHT tool for the job:`);
73
75
if(modeId!=='plan'){
74
76
constwriteTools: string[]=[];
75
77
76
-
if(!denied.has('string_replace_lsp')){
78
+
if(!denied.has(MC_TOOLS.STRING_REPLACE_LSP)){
77
79
writeTools.push(`
78
-
**string_replace_lsp** — Edit files by replacing exact text
79
-
- You MUST read a file with \`view\` before editing it.
80
+
**${MC_TOOLS.STRING_REPLACE_LSP}** — Edit files by replacing exact text
81
+
- You MUST read a file with \`${MC_TOOLS.VIEW}\` before editing it.
80
82
- \`old_str\` must be an exact match of existing text in the file.
81
83
- Provide enough surrounding context in \`old_str\` to make it unique.
82
-
- For creating new files, use \`write_file\` instead.
84
+
- For creating new files, use \`${MC_TOOLS.WRITE_FILE}\` instead.
83
85
- Good: Include 2-3 lines of surrounding context to ensure uniqueness.
84
86
- Bad: Using just \`return true;\` — too common, will match multiple places.`);
85
87
}
86
88
87
-
if(!denied.has('write_file')){
89
+
if(!denied.has(MC_TOOLS.WRITE_FILE)){
88
90
writeTools.push(`
89
-
**write_file** — Create new files or overwrite existing ones
91
+
**${MC_TOOLS.WRITE_FILE}** — Create new files or overwrite existing ones
90
92
- Use this to create new files.
91
-
- If overwriting an existing file, you MUST have read it first with \`view\`.
93
+
- If overwriting an existing file, you MUST have read it first with \`${MC_TOOLS.VIEW}\`.
92
94
- NEVER create files unless necessary. Prefer editing existing files.`);
0 commit comments