The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { |
| 4 | T3_MCP_TOOL_NAMES, |
| 5 | resolveT3McpSummaryAction, |
| 6 | resolveT3McpToolDefinition, |
| 7 | resolveT3McpToolPresentation, |
| 8 | } from "./t3McpToolPresentation.ts"; |
| 9 | |
| 10 | describe("resolveT3McpToolPresentation", () => { |
| 11 | it("recognizes every T3 tool across provider prefixes and completion suffixes", () => { |
| 12 | for (const tool of T3_MCP_TOOL_NAMES) { |
| 13 | const presentation = resolveT3McpToolPresentation(tool); |
| 14 | for (const prefix of [ |
| 15 | "mcp__t3-code__", |
| 16 | "mcp__t3_code__", |
| 17 | "mcp__t3code__", |
| 18 | "T3-code.", |
| 19 | "t3code.", |
| 20 | "t3-code-direct.", |
| 21 | "mcp__t3_code_direct__", |
| 22 | "t3_code/", |
| 23 | "t3code:", |
| 24 | "mcp_t3-code_", |
| 25 | "T3 Code ", |
| 26 | "t3-code · ", |
| 27 | ]) { |
| 28 | expect(resolveT3McpToolPresentation(`${prefix}${tool} completed`), tool).toEqual( |
| 29 | presentation, |
| 30 | ); |
| 31 | } |
| 32 | expect(resolveT3McpToolPresentation(`mcp__another-server__${tool}`), tool).toBeNull(); |
| 33 | } |
| 34 | }); |
| 35 | |
| 36 | it("matches OpenCode 2's per-thread server names, whose thread ids hold underscores", () => { |
| 37 | expect( |
| 38 | resolveT3McpToolPresentation("t3-code-thread_opencode2-adapter_delegate_task")?.displayName, |
| 39 | ).toBe("Delegate a child task"); |
| 40 | expect(resolveT3McpToolPresentation("t3-code-thread_opencode2-adapter_not_a_tool")).toBeNull(); |
| 41 | }); |
| 42 | }); |
| 43 | |
| 44 | describe("resolveT3McpToolDefinition", () => { |
| 45 | it("labels an action tool call as the action it ran", () => { |
| 46 | expect( |
| 47 | resolveT3McpToolDefinition("mcp__t3-code__preview_act", { action: "type" })?.labels, |
| 48 | ).toEqual(resolveT3McpToolDefinition("preview_type")?.labels); |
| 49 | expect(resolveT3McpToolDefinition("t3_thread_transfer", { action: "fork" })?.displayName).toBe( |
| 50 | resolveT3McpToolDefinition("t3_thread_fork")?.displayName, |
| 51 | ); |
| 52 | expect(resolveT3McpToolDefinition("preview_act", { action: "unknown" })?.labels[2]).toBe( |
| 53 | "Used", |
| 54 | ); |
| 55 | }); |
| 56 | }); |
| 57 | |
| 58 | describe("resolveT3McpSummaryAction", () => { |
| 59 | it("summarizes an action tool by the action each call ran", () => { |
| 60 | expect(resolveT3McpSummaryAction("mcp__t3-code__t3_queue", { action: "list" })).toBe( |
| 61 | "queue-list", |
| 62 | ); |
| 63 | expect(resolveT3McpSummaryAction("t3_queue", { action: "edit" })).toBe("queue-edit"); |
| 64 | expect(resolveT3McpSummaryAction("t3_thread_transfer", { action: "status" })).toBe( |
| 65 | "thread-transfers", |
| 66 | ); |
| 67 | expect(resolveT3McpSummaryAction("t3_thread_configure", {})).toBe("thread-configuration"); |
| 68 | expect(resolveT3McpSummaryAction("schedule_task", { scheduledTaskId: "task-1" })).toBe( |
| 69 | "schedule-update", |
| 70 | ); |
| 71 | expect(resolveT3McpSummaryAction("delegate_task", { task: "x" })).toBe("delegate"); |
| 72 | }); |
| 73 | }); |