MCPcopy Index your code
hub / github.com/CloudAI-X/opencode-workflow / AutoFormatPlugin

Function AutoFormatPlugin

plugins/auto-format.ts:17–40  ·  view source on GitHub ↗
({ $ })

Source from the content-addressed store, hash-verified

15}
16
17export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected