mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Detect Paseo MCP tool names across provider formats (Claude's mcp__paseo__*, Codex's paseo.*) and display humanized leaf names with the Paseo SVG logo instead of raw namespaced strings.
200 lines
5.0 KiB
TypeScript
200 lines
5.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { buildToolCallDisplayModel } from "./tool-call-display.js";
|
|
|
|
describe("shared tool-call display mapping", () => {
|
|
it("builds summary from canonical detail", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "read_file",
|
|
status: "running",
|
|
error: null,
|
|
detail: {
|
|
type: "read",
|
|
filePath: "/tmp/repo/src/index.ts",
|
|
},
|
|
cwd: "/tmp/repo",
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Read",
|
|
summary: "src/index.ts",
|
|
});
|
|
});
|
|
|
|
it("does not infer summaries from unknown raw detail", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "exec_command",
|
|
status: "running",
|
|
error: null,
|
|
detail: {
|
|
type: "unknown",
|
|
input: { command: "npm test" },
|
|
output: null,
|
|
},
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Exec Command",
|
|
});
|
|
});
|
|
|
|
it("uses sub-agent detail for task label and description", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "task",
|
|
status: "running",
|
|
error: null,
|
|
detail: {
|
|
type: "sub_agent",
|
|
subAgentType: "Explore",
|
|
description: "Inspect repository structure",
|
|
log: "[Read] README.md",
|
|
actions: [
|
|
{
|
|
index: 1,
|
|
toolName: "Read",
|
|
summary: "README.md",
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Explore",
|
|
summary: "Inspect repository structure",
|
|
});
|
|
});
|
|
|
|
it("builds display model for worktree setup detail", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "paseo_worktree_setup",
|
|
status: "running",
|
|
error: null,
|
|
detail: {
|
|
type: "worktree_setup",
|
|
worktreePath: "/tmp/repo/.paseo/worktrees/repo/branch",
|
|
branchName: "feature-branch",
|
|
log: "==> [1/1] Running: npm install\n",
|
|
commands: [
|
|
{
|
|
index: 1,
|
|
command: "npm install",
|
|
cwd: "/tmp/repo/.paseo/worktrees/repo/branch",
|
|
status: "running",
|
|
exitCode: null,
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Worktree Setup",
|
|
summary: "feature-branch",
|
|
});
|
|
});
|
|
|
|
it("provides errorText for failed calls", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "shell",
|
|
status: "failed",
|
|
error: { message: "boom" },
|
|
detail: {
|
|
type: "unknown",
|
|
input: null,
|
|
output: null,
|
|
},
|
|
});
|
|
|
|
expect(display.errorText).toBe('{\n "message": "boom"\n}');
|
|
});
|
|
|
|
it("labels terminal interaction rows without a summary when no command is available", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "terminal",
|
|
status: "completed",
|
|
error: null,
|
|
detail: {
|
|
type: "plain_text",
|
|
icon: "square_terminal",
|
|
},
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Terminal",
|
|
});
|
|
});
|
|
|
|
it("uses the command as terminal interaction summary when available", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "terminal",
|
|
status: "completed",
|
|
error: null,
|
|
detail: {
|
|
type: "plain_text",
|
|
label: "npm run test",
|
|
icon: "square_terminal",
|
|
},
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Terminal",
|
|
summary: "npm run test",
|
|
});
|
|
});
|
|
|
|
it("humanizes Paseo MCP tool names (Claude Code format)", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "mcp__paseo__create_agent",
|
|
status: "running",
|
|
error: null,
|
|
detail: { type: "unknown", input: null, output: null },
|
|
});
|
|
expect(display.displayName).toBe("Create Agent");
|
|
});
|
|
|
|
it("humanizes Paseo MCP tool names (Codex format)", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "paseo.create_agent",
|
|
status: "running",
|
|
error: null,
|
|
detail: { type: "unknown", input: null, output: null },
|
|
});
|
|
expect(display.displayName).toBe("Create Agent");
|
|
});
|
|
|
|
it("humanizes list_agents Paseo tool", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "mcp__paseo__list_agents",
|
|
status: "running",
|
|
error: null,
|
|
detail: { type: "unknown", input: null, output: null },
|
|
});
|
|
expect(display.displayName).toBe("List Agents");
|
|
});
|
|
|
|
it("does not override speak tool display name", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "speak",
|
|
status: "running",
|
|
error: null,
|
|
detail: { type: "unknown", input: null, output: null },
|
|
});
|
|
expect(display.displayName).toBe("Speak");
|
|
});
|
|
|
|
it("labels plan detail rows as Plan", () => {
|
|
const display = buildToolCallDisplayModel({
|
|
name: "plan",
|
|
status: "completed",
|
|
error: null,
|
|
detail: {
|
|
type: "plan",
|
|
text: "### Login Screen\n- Build layout",
|
|
},
|
|
});
|
|
|
|
expect(display).toEqual({
|
|
displayName: "Plan",
|
|
});
|
|
});
|
|
});
|