feat(tools): rewrite wire-visible tool names to internal opencode names
Introduces src/tools/wire-names.ts as the single source of truth for the tool-name bidirectional mapping and replaces the 'strip mcp_ prefix' behavior in src/response/mcp.ts with a full alias-aware rewrite. The previous mcp-prefix stripper only knew how to remove a single hard-coded prefix; it could not convert Claude's PascalCase wire names (Bash, Read, Grep, etc.) back to the lowercase internal form that the rest of opencode expects. Tool-use content blocks in responses now survive both directions of the rewrite. Source - src/tools/wire-names.ts (new): toWireToolName / toInternalToolName pair. NATIVE_WIRE_NAME_BY_INTERNAL covers the 7 native tools (bash, read, glob, grep, edit, write, skill). PRESERVED_WIRE_NAMES keeps advisor + tool_search_tool_regex intact on both sides. detectLegacyDoublePrefix throws TypeError for mcp_mcp_* inputs. Pascal-case fallback converters handle anything outside the explicit allowlist. - src/response/mcp.ts: stripMcpPrefixFromToolNameField becomes rewriteWireToolNameField, routing through toInternalToolName. stripMcpPrefixFromToolUseBlock and stripMcpPrefixFromToolReferenceBlock now rewrite rather than strip. Tests - tests/unit/tools/wire-names.test.ts: covers the 7-tool mapping, Pascal-case round-trip, preserved wire names, legacy-prefix stripping, and double-prefix error. - tests/unit/request/wire-tool-naming.test.ts: end-to-end coverage through transformRequestBody and stripMcpPrefixFromJsonBody. 7/7 tests pass.
V
Vacbo committed
d0a06cfc906a1deec64b3353c38e6ee7b9739232
Parent: 0cf7325