Files
oh-my-pi/packages/coding-agent/src/modes/utils/tools-markdown.ts
T
can1357 e59436ba31 feat(coding-agent): added /tools command to display available agent tools
- Added `/tools` slash command to display agent-visible tools in interactive sessions.
- Added `handleToolsCommand()` method to InteractiveMode to delegate tools display to command controller.
- Added `buildToolsMarkdown()` utility function to generate formatted markdown table of available tools.
- Refactored `showMarkdownPanel()` helper to reduce duplication in markdown display logic across commands.
2026-04-01 20:32:59 +02:00

28 lines
712 B
TypeScript

import type { Tool } from "../../tools";
export interface ToolsMarkdownBindings {
tools: ReadonlyArray<Pick<Tool, "description" | "name">>;
}
function escapeTableCell(value: string): string {
return value
.replace(/\|/g, "\\|")
.replace(/\r?\n+/g, " ")
.trim();
}
export function buildToolsMarkdown(bindings: ToolsMarkdownBindings): string {
if (bindings.tools.length === 0) {
return "No tools are currently visible to the agent.";
}
return [
"| Tool | Description |",
"|------|-------------|",
...bindings.tools.map(tool => {
const description = escapeTableCell(tool.description) || "No description provided.";
return `| \`${tool.name}\` | ${description} |`;
}),
].join("\n");
}