| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { T3_MCP_TOOL_NAMES, resolveT3McpToolPresentation } from "./t3McpToolPresentation.ts"; |
| 4 | |
| 5 | describe("resolveT3McpToolPresentation", () => { |
| 6 | it("recognizes every T3 tool across provider prefixes and completion suffixes", () => { |
| 7 | for (const tool of T3_MCP_TOOL_NAMES) { |
| 8 | const presentation = resolveT3McpToolPresentation(tool); |
| 9 | for (const prefix of [ |
| 10 | "mcp__t3-code__", |
| 11 | "mcp__t3_code__", |
| 12 | "mcp__t3code__", |
| 13 | "T3-code.", |
| 14 | "t3_code/", |
| 15 | "t3code:", |
| 16 | "mcp_t3-code_", |
| 17 | "T3 Code ", |
| 18 | "t3-code · ", |
| 19 | ]) { |
| 20 | expect(resolveT3McpToolPresentation(`${prefix}${tool} completed`), tool).toEqual( |
| 21 | presentation, |
| 22 | ); |
| 23 | } |
| 24 | expect(resolveT3McpToolPresentation(`mcp__another-server__${tool}`), tool).toBeNull(); |
| 25 | } |
| 26 | }); |
| 27 | it("pretty prints Claude and Cursor T3 MCP tool names", () => { |
| 28 | expect(resolveT3McpToolPresentation("mcp__t3-code__t3_thread_read")).toEqual({ |
| 29 | displayName: "Read a T3 thread", |
| 30 | logo: "t3-code", |
| 31 | }); |
| 32 | }); |
| 33 | |
| 34 | it("pretty prints Codex T3 MCP tool names", () => { |
| 35 | expect(resolveT3McpToolPresentation("t3-code.create_threads")).toEqual({ |
| 36 | displayName: "Create T3 threads", |
| 37 | logo: "t3-code", |
| 38 | }); |
| 39 | }); |
| 40 | |
| 41 | it("pretty prints thread metadata updates", () => { |
| 42 | expect(resolveT3McpToolPresentation("mcp__t3-code__t3_thread_update")).toEqual({ |
| 43 | displayName: "Update T3 thread metadata", |
| 44 | logo: "t3-code", |
| 45 | }); |
| 46 | }); |
| 47 | |
| 48 | it("pretty prints bare T3 MCP toolkit names", () => { |
| 49 | expect(resolveT3McpToolPresentation("list_scheduled_tasks")).toEqual({ |
| 50 | displayName: "List scheduled tasks", |
| 51 | logo: "t3-code", |
| 52 | }); |
| 53 | }); |
| 54 | |
| 55 | it("pretty prints worktree T3 MCP tool names", () => { |
| 56 | expect(resolveT3McpToolPresentation("mcp__t3-code__t3_worktree_handoff")).toEqual({ |
| 57 | displayName: "Hand off thread to a git worktree", |
| 58 | logo: "t3-code", |
| 59 | }); |
| 60 | expect(resolveT3McpToolPresentation("t3-code.t3_worktree_status")).toEqual({ |
| 61 | displayName: "Get thread worktree status", |
| 62 | logo: "t3-code", |
| 63 | }); |
| 64 | }); |
| 65 | |
| 66 | it("pretty prints preview T3 MCP tool names", () => { |
| 67 | expect(resolveT3McpToolPresentation("T3-code.preview_open")).toEqual({ |
| 68 | displayName: "Open a page in the preview browser", |
| 69 | logo: "t3-code", |
| 70 | }); |
| 71 | expect(resolveT3McpToolPresentation("mcp__t3-code__preview_status")).toEqual({ |
| 72 | displayName: "Get preview browser status", |
| 73 | logo: "t3-code", |
| 74 | }); |
| 75 | }); |
| 76 | |
| 77 | it("matches the separator variants ACP registry agents emit", () => { |
| 78 | for (const name of [ |
| 79 | "mcp_t3-code_delegate_task", |
| 80 | "t3_code:delegate_task", |
| 81 | "t3code/delegate_task", |
| 82 | "t3-code delegate_task", |
| 83 | "T3 Code delegate_task", |
| 84 | "t3-code__delegate_task", |
| 85 | ]) { |
| 86 | expect(resolveT3McpToolPresentation(name)?.displayName).toBe("Delegate a child task"); |
| 87 | } |
| 88 | }); |
| 89 | |
| 90 | it("matches OpenCode 2's per-thread server names, whose thread ids hold underscores", () => { |
| 91 | expect( |
| 92 | resolveT3McpToolPresentation("t3-code-thread_opencode2-adapter_delegate_task")?.displayName, |
| 93 | ).toBe("Delegate a child task"); |
| 94 | expect(resolveT3McpToolPresentation("t3-code-thread_opencode2-adapter_not_a_tool")).toBeNull(); |
| 95 | }); |
| 96 | |
| 97 | it("keeps unknown MCP tools on the generic renderer path", () => { |
| 98 | expect(resolveT3McpToolPresentation("mcp__github__search_issues")).toBeNull(); |
| 99 | expect(resolveT3McpToolPresentation("t3-code.not_a_real_tool")).toBeNull(); |
| 100 | }); |
| 101 | }); |