continue-custom/extensions/cli/src/tools/formatters.ts
Nate be45ab63ca Add 'extensions/cli/' from commit 'e27a5c87d520e28844c9eac10bc6d301feee4b5e'
git-subtree-dir: extensions/cli
git-subtree-mainline: 1674c2aff1
git-subtree-split: e27a5c87d5
2025-08-20 17:19:56 -07:00

23 lines
714 B
TypeScript

import path from "path";
/**
* Formats a single tool argument for display
* @param value The argument value
* @returns A formatted string representation of the value
*/
export function formatToolArgument(value: any): string {
if (value === null || value === undefined) {
return "";
}
// Convert absolute paths to relative paths
if (typeof value === "string" && path.isAbsolute(value)) {
const workspaceRoot = process.cwd();
const relativePath = path.relative(workspaceRoot, value);
// Normalize path separators to forward slashes for cross-platform consistency
return (relativePath || value).replace(/\\/g, "/");
}
// Return other values as strings
return String(value);
}