(text: string, max: number)
| 117 | } |
| 118 | |
| 119 | function truncate(text: string, max: number): string { |
| 120 | const oneLine = text.replace(/\n/g, "\\n") |
| 121 | return oneLine.length > max ? oneLine.slice(0, max) + "…" : oneLine |
| 122 | } |
| 123 | |
| 124 | export async function fileEdit(args: Record<string, unknown>, context: ToolContext): Promise<ToolResult> { |
| 125 | const edit: EditSpec = { |