fix: tool name matching
This commit is contained in:
parent
9c18d28cbe
commit
9792b1411f
2 changed files with 52 additions and 11 deletions
|
|
@ -122,6 +122,21 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
if (!args) return name;
|
if (!args) return name;
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
// CLI Internal Tools (snake_case)
|
||||||
|
case "read_file":
|
||||||
|
return `Read(${args.filepath || ""})`;
|
||||||
|
case "write_file":
|
||||||
|
return `Write(${args.filepath || ""})`;
|
||||||
|
case "list_files":
|
||||||
|
return `List(${args.dirpath || ""})`;
|
||||||
|
case "search_code":
|
||||||
|
return `Search(${args.pattern || ""})`;
|
||||||
|
case "run_terminal_command":
|
||||||
|
return `Terminal(${args.command || ""})`;
|
||||||
|
case "view_diff":
|
||||||
|
return `Diff(${args.path || "."})`;
|
||||||
|
|
||||||
|
// External Claude Code Tools (PascalCase)
|
||||||
case "Read":
|
case "Read":
|
||||||
return `Read(${args.file_path || args.path || ""})`;
|
return `Read(${args.file_path || args.path || ""})`;
|
||||||
case "Write":
|
case "Write":
|
||||||
|
|
@ -130,29 +145,29 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
||||||
case "MultiEdit":
|
case "MultiEdit":
|
||||||
return `Edit(${args.file_path || ""})`;
|
return `Edit(${args.file_path || ""})`;
|
||||||
case "Bash":
|
case "Bash":
|
||||||
return `Bash(${args.command || ""})`;
|
return `Terminal(${args.command || ""})`;
|
||||||
case "Glob":
|
case "Glob":
|
||||||
return `Glob(${args.pattern || ""})`;
|
return `Find(${args.pattern || ""})`;
|
||||||
case "Grep":
|
case "Grep":
|
||||||
return `Grep(${args.pattern || ""})`;
|
return `Search(${args.pattern || ""})`;
|
||||||
case "LS":
|
case "LS":
|
||||||
return `LS(${args.path || ""})`;
|
return `List(${args.path || ""})`;
|
||||||
case "NotebookRead":
|
case "NotebookRead":
|
||||||
return `NotebookRead(${args.notebook_path || ""})`;
|
return `Notebook(${args.notebook_path || ""})`;
|
||||||
case "NotebookEdit":
|
case "NotebookEdit":
|
||||||
return `NotebookEdit(${args.notebook_path || ""})`;
|
return `Notebook(${args.notebook_path || ""})`;
|
||||||
case "WebFetch":
|
case "WebFetch":
|
||||||
return `WebFetch(${args.url || ""})`;
|
return `Web(${args.url || ""})`;
|
||||||
case "WebSearch":
|
case "WebSearch":
|
||||||
return `WebSearch(${args.query || ""})`;
|
return `Search(${args.query || ""})`;
|
||||||
case "TodoWrite":
|
case "TodoWrite":
|
||||||
return `TodoWrite(${args.todos?.length || 0} items)`;
|
return `Todo(${args.todos?.length || 0} items)`;
|
||||||
case "Task":
|
case "Task":
|
||||||
return `Task(${args.description || ""})`;
|
return `Task(${args.description || ""})`;
|
||||||
default:
|
default:
|
||||||
// Handle MCP tools or unknown tools
|
// Handle MCP tools or unknown tools
|
||||||
if (name.startsWith("mcp__")) {
|
if (name.startsWith("mcp__")) {
|
||||||
const mcpToolName = name.replace("mcp__", "");
|
const mcpToolName = name.replace("mcp__", "").replace("ide__", "");
|
||||||
const firstParam = Object.values(args)[0];
|
const firstParam = Object.values(args)[0];
|
||||||
return `${mcpToolName}(${firstParam || ""})`;
|
return `${mcpToolName}(${firstParam || ""})`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,32 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
|
|
||||||
// Use exact tool name matching
|
// Use exact tool name matching
|
||||||
switch (toolName) {
|
switch (toolName) {
|
||||||
|
// CLI Internal Tools (snake_case)
|
||||||
|
case "read_file":
|
||||||
|
// Try to extract file path from content if it contains line numbers
|
||||||
|
if (content.includes("→")) {
|
||||||
|
const pathMatch = content.match(/^(.+?):/);
|
||||||
|
const filePath = pathMatch ? pathMatch[1] : "file";
|
||||||
|
return `Read ${filePath} (${lines} lines)`;
|
||||||
|
}
|
||||||
|
return `Read tool output (${lines} lines)`;
|
||||||
|
|
||||||
|
case "write_file":
|
||||||
|
return "File written successfully";
|
||||||
|
|
||||||
|
case "list_files":
|
||||||
|
return `Listed ${lines} ${lines === 1 ? 'item' : 'items'}`;
|
||||||
|
|
||||||
|
case "search_code":
|
||||||
|
return `Found ${lines} ${lines === 1 ? 'match' : 'matches'}`;
|
||||||
|
|
||||||
|
case "run_terminal_command":
|
||||||
|
return `Command output (${lines} lines)`;
|
||||||
|
|
||||||
|
case "view_diff":
|
||||||
|
return `Diff output (${lines} lines)`;
|
||||||
|
|
||||||
|
// External Claude Code Tools (PascalCase)
|
||||||
case "Read":
|
case "Read":
|
||||||
// Try to extract file path from content if it contains line numbers
|
// Try to extract file path from content if it contains line numbers
|
||||||
if (content.includes("→")) {
|
if (content.includes("→")) {
|
||||||
|
|
@ -68,7 +94,7 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
||||||
default:
|
default:
|
||||||
// Handle MCP tools or unknown tools
|
// Handle MCP tools or unknown tools
|
||||||
if (toolName?.startsWith("mcp__")) {
|
if (toolName?.startsWith("mcp__")) {
|
||||||
const mcpToolName = toolName.replace("mcp__", "");
|
const mcpToolName = toolName.replace("mcp__", "").replace("ide__", "");
|
||||||
return `${mcpToolName} tool output (${lines} lines)`;
|
return `${mcpToolName} tool output (${lines} lines)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue