You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: configuring clang-format, air or uv by name silently disables the formatter #46868
Configuring clang-format, air or uv in the formatter section silently turns that formatter off. The name works for disabled: true, but any other override kills it.
packages/opencode/src/format/index.ts:134 looks up the built-in with Formatter[name as keyof typeof Formatter], where name is the config key. That reads the module's export identifier, not the formatter's published name. Three built-ins differ between the two:
config key, as the docs publish it
export identifier in format/formatter.ts
clang-format
clang
air
rlang
uv
uvformat
For those three the lookup returns undefined. The next lines then build the entry from builtIn ?? { extensions: [] } and set enabled to async () => info.command ?? false. With no command in the config, enabled always returns false, and the built-in extensions are replaced by an empty list. The formatter is gone.
The published name is the right key. formatters is already keyed by item.name at index.ts:130, status() reports item.name, and docs/formatters.mdx lists clang-format, air and uv in its Built-in table. The docs also say "You can configure built-in formatters with options like environment or extensions", which is the case that breaks.
clang-format reports extensions: [] and enabled: false. Writing a .c file does not format it. Removing the clang-format block restores the formatter, so adding an override is what disables it.
The same happens with air and with uv. A correctly named built-in such as gofmt is not affected, because its export identifier and its name match.
Measured
Added to packages/opencode/test/format/format.test.ts on ef27925, with Formatter.clang pointed at a scratch extension and a command that appends C:
config: { formatter: { "clang-format": {} } }
file contents after Format.file() expected "xC" actual "x"
The command never runs. The same config for all three names makes status() return an empty extensions list for each, instead of the built-in list.
Good catch and precise trace. One important scoping note for anyone picking this up: this bug exists on the legacy dev code path (packages/opencode/src/format/index.ts), but it is already resolved on the current v2 line, where the formatter layer was rewritten.
On v2 (packages/core/src/formatter/builtins.ts), each built-in now carries its published name as Info.name — clang-format (const clang), air (const air), uv (const uv) — and the config merge in packages/core/src/config/plugin/formatter.ts resolves overrides by name, not by export identifier:
So configuring { "formatter": { "clang-format": { "environment": { ... } } } } on v2 finds the built-in correctly and preserves its extensions/enabled. The same holds for air and uv.
The dev-line lookup at packages/opencode/src/format/index.ts:134 (Formatter[name as keyof typeof Formatter]) is the one that breaks for clang-format / air / uv, exactly as you describe. If a fix is wanted on dev, the minimal change is to key the override lookup by each built-in's name property instead of its export identifier — matching the two disabled/remove paths that already use the config key — or to add the three alias mappings. The v2 rewrite shows the intended direction (resolve by item.name).
I cannot find that v2 code. Measured against dev at ef27925, which is the default branch.
GET contents/packages/core/src/formatter/builtins.ts?ref=dev 404
GET contents/packages/core/src/config/plugin/formatter.ts?ref=dev 404
code search for "formatter.name === name" in this repo 0 hits
packages/core/src/config/plugin/ exists, and holds agent.ts, command.ts, external.ts, provider.ts, reference.ts and skill.ts. It has no formatter.ts. The only formatter module under packages/core/src/config is formatter.ts at that level, which defines the schema and not the merge.
If the rewrite lives on a branch, name it and I will read it there.
The scoping point stands either way. #46869 keys the built-ins by Info.name and reads that map for the override lookup, which is the direction you describe.
The branch is v2 — the repository's active development branch per the AGENTS.md convention ("Base all new branches and worktrees on v2"). The GitHub default branch is dev, which is why the ref=dev lookups 404: the formatter rewrite lives on v2, not on dev.
Paths on the v2 branch:
packages/core/src/formatter/builtins.ts — built-ins carry their published name as Info.name (clang-format, air, uv), and
packages/core/src/config/plugin/formatter.ts — the override merge resolves with builtIns.find((formatter) => formatter.name === name).
So the v2 behavior matches what #46869 implements on the dev line (keying built-ins by Info.name). Recent v2-only merges confirm the workflow (e.g. #46866, #46864, #46857 all merged into v2 this week). Your #46869 is the right direction for dev; if the maintainers prefer to converge on v2, the fix is already inherent there and #46869 may only be needed for the legacy line.
Confirmed. My check was wrong about how to read the branch, not about the paths. GitHub code search indexes the default branch only, which is dev, so it returns nothing for v2. The git tree API at refs/heads/v2 shows both files: packages/core/src/formatter/builtins.ts and packages/core/src/config/plugin/formatter.ts.
v2 resolves the override with builtIns.find((formatter) => formatter.name === name), so this bug is already fixed there. #46869 only helps the dev line.
v2 is also where the work lands. Of the last 40 merged pull requests, 36 target v2 and 4 target dev. The v2 AGENTS.md says the default branch is v2 and that pull requests should target v2. The dev copy still names dev, which is why I read that one.
One defect does carry over to v2. packages/core/src/tool/plugin/edit.ts compares input.oldString === input.newString on the raw input near the top. It converts both strings to the file's line ending about thirty lines below that check. So a CRLF file takes oldString spelled CRLF and newString spelled LF past the guard. After the conversion the two are equal. The edit then writes the file back unchanged and reports one replacement. That is what #46849 fixes on dev, and the same gap is in the new file.
packages/opencode does not exist on v2, so #46860 is a dev line fix only.
This is fixed in v2, as confirmed above: formatter overrides are matched by their published names, so configuring clang-format, air, or uv preserves the built-in extensions and enablement unless explicitly overridden.
To get v2, run npm i -g @opencode/cli@latest. If you still see this on v2, please open a new issue with the details.
Activity
argszero commentedon Sep 2, 2026
Good catch and precise trace. One important scoping note for anyone picking this up: this bug exists on the legacy
devcode path (packages/opencode/src/format/index.ts), but it is already resolved on the currentv2line, where the formatter layer was rewritten.On
v2(packages/core/src/formatter/builtins.ts), each built-in now carries its published name asInfo.name—clang-format(constclang),air(constair),uv(constuv) — and the config merge inpackages/core/src/config/plugin/formatter.tsresolves overrides by name, not by export identifier:So configuring
{ "formatter": { "clang-format": { "environment": { ... } } } }on v2 finds the built-in correctly and preserves its extensions/enabled. The same holds forairanduv.The
dev-line lookup atpackages/opencode/src/format/index.ts:134(Formatter[name as keyof typeof Formatter]) is the one that breaks forclang-format/air/uv, exactly as you describe. If a fix is wanted ondev, the minimal change is to key the override lookup by each built-in'snameproperty instead of its export identifier — matching the twodisabled/removepaths that already use the config key — or to add the three alias mappings. The v2 rewrite shows the intended direction (resolve byitem.name).devYRPauli commentedon Sep 2, 2026
I cannot find that v2 code. Measured against
devatef27925, which is the default branch.packages/core/src/config/plugin/exists, and holdsagent.ts,command.ts,external.ts,provider.ts,reference.tsandskill.ts. It has noformatter.ts. The only formatter module underpackages/core/src/configisformatter.tsat that level, which defines the schema and not the merge.If the rewrite lives on a branch, name it and I will read it there.
The scoping point stands either way. #46869 keys the built-ins by
Info.nameand reads that map for the override lookup, which is the direction you describe.argszero commentedon Sep 3, 2026
The branch is
v2— the repository's active development branch per the AGENTS.md convention ("Base all new branches and worktrees on v2"). The GitHub default branch isdev, which is why theref=devlookups 404: the formatter rewrite lives onv2, not ondev.Paths on the
v2branch:packages/core/src/formatter/builtins.ts— built-ins carry their published name asInfo.name(clang-format,air,uv), andpackages/core/src/config/plugin/formatter.ts— the override merge resolves withbuiltIns.find((formatter) => formatter.name === name).So the v2 behavior matches what #46869 implements on the
devline (keying built-ins byInfo.name). Recent v2-only merges confirm the workflow (e.g. #46866, #46864, #46857 all merged intov2this week). Your #46869 is the right direction fordev; if the maintainers prefer to converge onv2, the fix is already inherent there and #46869 may only be needed for the legacy line.devYRPauli commentedon Sep 3, 2026
Confirmed. My check was wrong about how to read the branch, not about the paths. GitHub code search indexes the default branch only, which is
dev, so it returns nothing for v2. The git tree API atrefs/heads/v2shows both files:packages/core/src/formatter/builtins.tsandpackages/core/src/config/plugin/formatter.ts.v2 resolves the override with
builtIns.find((formatter) => formatter.name === name), so this bug is already fixed there. #46869 only helps thedevline.v2 is also where the work lands. Of the last 40 merged pull requests, 36 target
v2and 4 targetdev. The v2AGENTS.mdsays the default branch isv2and that pull requests should targetv2. Thedevcopy still namesdev, which is why I read that one.One defect does carry over to v2.
packages/core/src/tool/plugin/edit.tscomparesinput.oldString === input.newStringon the raw input near the top. It converts both strings to the file's line ending about thirty lines below that check. So a CRLF file takesoldStringspelled CRLF andnewStringspelled LF past the guard. After the conversion the two are equal. The edit then writes the file back unchanged and reports one replacement. That is what #46849 fixes ondev, and the same gap is in the new file.packages/opencodedoes not exist on v2, so #46860 is adevline fix only.neriousy commentedon Oct 19, 2026
This is fixed in v2, as confirmed above: formatter overrides are matched by their published names, so configuring
clang-format,air, oruvpreserves the built-in extensions and enablement unless explicitly overridden.To get v2, run
npm i -g @opencode/cli@latest. If you still see this on v2, please open a new issue with the details.Update the open-source counts to 2026-10-19