From 7a28d0520a02dd31e24e497d9478ca25bf5e9d0b Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 19 Mar 2026 23:19:36 -0400 Subject: [PATCH] fix(format): handle custom formatter command property with enabled() interface The formatter Info interface uses enabled(): Promise but user configs provide a command property. Added explicit return type to the arrow function that transforms command into the enabled() return value. Also added test to verify custom formatters with command property work. --- packages/opencode/src/format/index.ts | 2 +- packages/opencode/test/format/format.test.ts | 21 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/format/index.ts b/packages/opencode/src/format/index.ts index 8a7ee0af5c..00321be6af 100644 --- a/packages/opencode/src/format/index.ts +++ b/packages/opencode/src/format/index.ts @@ -62,7 +62,7 @@ export namespace Format { formatters[name] = { ...info, name, - enabled: async () => info.command, + enabled: async (): Promise => info.command, } } } else { diff --git a/packages/opencode/test/format/format.test.ts b/packages/opencode/test/format/format.test.ts index 2718e125d0..26c1468d34 100644 --- a/packages/opencode/test/format/format.test.ts +++ b/packages/opencode/test/format/format.test.ts @@ -55,6 +55,27 @@ describe("Format", () => { }) }) + test("status() includes custom formatters with command from config", async () => { + await using tmp = await tmpdir({ + config: { + formatter: { + customtool: { + command: ["echo", "formatted", "$FILE"], + extensions: [".custom"], + }, + }, + }, + }) + + await withServices(tmp.path, Format.layer, async (rt) => { + const statuses = await rt.runPromise(Format.Service.use((s) => s.status())) + const custom = statuses.find((s) => s.name === "customtool") + expect(custom).toBeDefined() + expect(custom!.extensions).toContain(".custom") + expect(custom!.enabled).toBe(true) + }) + }) + test("service initializes without error", async () => { await using tmp = await tmpdir()