diff --git a/hooks/core/routing.mjs b/hooks/core/routing.mjs index e92ab46b2..c8a1b4181 100644 --- a/hooks/core/routing.mjs +++ b/hooks/core/routing.mjs @@ -532,6 +532,7 @@ const TOOL_ALIASES = { "view": "Read", "grep": "Grep", "fetch": "WebFetch", + "webfetch": "WebFetch", "agent": "Agent", // Codex CLI "shell": "Bash", diff --git a/tests/hooks/core-routing.test.ts b/tests/hooks/core-routing.test.ts index 310c94d8f..ae4cf0193 100644 --- a/tests/hooks/core-routing.test.ts +++ b/tests/hooks/core-routing.test.ts @@ -490,6 +490,22 @@ describe("routePreToolUse", () => { expect(subagent.status).toBe(0); expect(subagent.stdout).toBe(""); }); + + it("treats opencode webfetch as WebFetch and blocks it (#1052)", () => { + const url = "https://example.com"; + const result = routePreToolUse( + "webfetch", + { url }, + undefined, + "opencode", + "opencode-webfetch", + ); + expect(result).not.toBeNull(); + expect(result!.action).toBe("deny"); + expect(result!.reason).toContain("WebFetch redirected"); + expect(result!.reason).toContain("fetch_and_index"); + expect(result!.reason).toContain("ctx_search"); + }); }); // ─── MCP readiness: all redirects degrade gracefully (#230) ───