({ $ })
| 15 | } |
| 16 | |
| 17 | export const AutoFormatPlugin = async ({ $ }) => { |
| 18 | return { |
| 19 | "tool.execute.after": async (input, output) => { |
| 20 | if (!["write", "edit"].includes(input.tool)) { |
| 21 | return |
| 22 | } |
| 23 | |
| 24 | const filePath = input.args?.file_path || input.args?.filePath || input.args?.path || "" |
| 25 | if (!filePath) return |
| 26 | |
| 27 | const ext = filePath.match(/\.[^.]+$/)?.[0]?.toLowerCase() |
| 28 | const formatter = ext ? FORMATTERS[ext] : null |
| 29 | |
| 30 | if (formatter) { |
| 31 | try { |
| 32 | const [cmd, ...args] = formatter.split(" ") |
| 33 | await $`${cmd} ${args} ${filePath}`.quiet() |
| 34 | } catch { |
| 35 | // Ignore formatter errors - non-blocking |
| 36 | } |
| 37 | } |
| 38 | }, |
| 39 | } |
| 40 | } |
nothing calls this directly
no outgoing calls
no test coverage detected