From 5716e842c8128d665043ffae8a1727fa1da31b28 Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Mon, 2 Mar 2026 12:54:57 +0100 Subject: [PATCH] test: add ToolRegistry tool name contract test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifies that tool names kilo-vscode depends on (bash, task, read, write, glob, edit, todowrite) are still registered in the upstream ToolRegistry in packages/ui/src/components/message-part.tsx. Ref: testing-gaps-and-visual-testing-plan.md ยง1.2 --- .../tests/unit/tool-registry-contract.test.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 packages/kilo-vscode/tests/unit/tool-registry-contract.test.ts diff --git a/packages/kilo-vscode/tests/unit/tool-registry-contract.test.ts b/packages/kilo-vscode/tests/unit/tool-registry-contract.test.ts new file mode 100644 index 00000000000..9c34ad5aa11 --- /dev/null +++ b/packages/kilo-vscode/tests/unit/tool-registry-contract.test.ts @@ -0,0 +1,36 @@ +/** + * ToolRegistry tool name contract test. + * + * The kilo-vscode webview overrides specific tool names in + * VscodeToolOverrides.tsx (e.g. "bash") and TaskToolExpanded.tsx (e.g. "task"). + * VscodeSessionTurn also calls getToolInfo() from @kilocode/kilo-ui/message-part. + * + * This test verifies that the tool names we depend on are still registered + * in the upstream ToolRegistry (message-part.tsx). If upstream removes or + * renames a tool, this test will fail. + */ + +import { describe, it, expect } from "bun:test" +import fs from "node:fs" +import path from "node:path" + +const MONOREPO_ROOT = path.resolve(import.meta.dir, "../../../..") +const MESSAGE_PART_FILE = path.join(MONOREPO_ROOT, "packages/ui/src/components/message-part.tsx") + +/** + * Tool names that kilo-vscode overrides or uses directly. + * Sources: + * - VscodeToolOverrides.tsx: "bash" + * - TaskToolExpanded.tsx: "task" + * - VscodeSessionTurn.tsx uses getToolInfo() which handles all of these + */ +const TOOL_NAMES_WE_DEPEND_ON = ["bash", "task", "read", "write", "glob", "edit", "todowrite"] + +describe("ToolRegistry tool name contract", () => { + it("all tools overridden or used by kilo-vscode are still registered in ToolRegistry", () => { + const src = fs.readFileSync(MESSAGE_PART_FILE, "utf-8") + for (const name of TOOL_NAMES_WE_DEPEND_ON) { + expect(src, `Tool "${name}" no longer registered in message-part.tsx`).toContain(`name: "${name}"`) + } + }) +})