fix(opencode): format shipped files with Prettier #164

Merged
claudiomaradonna merged 1 commit from fix/prettier-shipped-files into main 2026-10-29 09:02:11 +01:00
Collaborator

Why

An adopter that keeps its tracked files Prettier-clean runs
prettier --check with the .prettierrc Agent Foundry gave it, and it
fails on two files that also came from Agent Foundry: .prettierrc
itself and .opencode/plugins/shellcheck.js. The adopter can format
them, and then meet conflicts at every upgrade, or live with the
failure. Fixes #163.

Running prettier --write on both, as the issue suggests, is not
enough. Prettier splits the plugin's execFile(...) line, and
scripts/verify-agent-config.sh pins that line exactly, so the
validator then fails on the source and on every adopter that keeps
.opencode/.

What changed

Both files are now in Prettier's layout under the shipped
.prettierrc. .prettierrc gets a trailing comma after its last key,
which is valid because Prettier reads .prettierrc with its YAML parser.
In the plugin, only whitespace and line breaks change, and one trailing
comma is added inside a call.

The validator used to pin the execFile call as one line. It now pins
the three lines Prettier gives it: const child = execFile(, checker,
and ["hook"]. It still refuses a plugin that runs the checker in
another mode.

How to verify

From a fresh checkout of the branch, with Prettier 3:

prettier --check .prettierrc .opencode/plugins/*.js
scripts/verify-agent-config.sh
bash tests/agent-config/hook-wiring.sh

The first command reports that all files use Prettier code style. On
main it exits 1 and warns on .prettierrc and
.opencode/plugins/shellcheck.js. The validator then reports
state=template, and the hook-wiring area passes all 21 tests,
including "fails when the OpenCode plugin runs another checker mode".

The Maintenance checks of the README all pass on a516bde, including 299
agent-configuration tests and 46 work-folder tests. The change reviewer
and the security reviewer report no findings. I have not run the plugin
inside OpenCode, because no OpenCode is installed here. git diff -w --word-diff shows that only whitespace, line breaks and the one comma
changed.

Considerations

The Maintenance prettier --check covers Markdown only, so this drift
went unnoticed and could happen again. I left the shipped .prettierrc
and .opencode/plugins/*.js out of that check because adding them adds
a step to the maintenance workflow, and that is your decision.

The validator does not check that the three pinned lines are adjacent
or in order. The security review set this aside as hardening rather
than a finding: the old single-line pin also guarded only against
accidental drift, never against a deliberate edit.

## Why An adopter that keeps its tracked files Prettier-clean runs `prettier --check` with the `.prettierrc` Agent Foundry gave it, and it fails on two files that also came from Agent Foundry: `.prettierrc` itself and `.opencode/plugins/shellcheck.js`. The adopter can format them, and then meet conflicts at every upgrade, or live with the failure. Fixes #163. Running `prettier --write` on both, as the issue suggests, is not enough. Prettier splits the plugin's `execFile(...)` line, and `scripts/verify-agent-config.sh` pins that line exactly, so the validator then fails on the source and on every adopter that keeps `.opencode/`. ## What changed Both files are now in Prettier's layout under the shipped `.prettierrc`. `.prettierrc` gets a trailing comma after its last key, which is valid because Prettier reads `.prettierrc` with its YAML parser. In the plugin, only whitespace and line breaks change, and one trailing comma is added inside a call. The validator used to pin the `execFile` call as one line. It now pins the three lines Prettier gives it: `const child = execFile(`, `checker`, and `["hook"]`. It still refuses a plugin that runs the checker in another mode. ## How to verify From a fresh checkout of the branch, with Prettier 3: ```bash prettier --check .prettierrc .opencode/plugins/*.js scripts/verify-agent-config.sh bash tests/agent-config/hook-wiring.sh ``` The first command reports that all files use Prettier code style. On `main` it exits 1 and warns on `.prettierrc` and `.opencode/plugins/shellcheck.js`. The validator then reports `state=template`, and the hook-wiring area passes all 21 tests, including "fails when the OpenCode plugin runs another checker mode". The Maintenance checks of the README all pass on a516bde, including 299 agent-configuration tests and 46 work-folder tests. The change reviewer and the security reviewer report no findings. I have not run the plugin inside OpenCode, because no OpenCode is installed here. `git diff -w --word-diff` shows that only whitespace, line breaks and the one comma changed. ## Considerations The Maintenance `prettier --check` covers Markdown only, so this drift went unnoticed and could happen again. I left the shipped `.prettierrc` and `.opencode/plugins/*.js` out of that check because adding them adds a step to the maintenance workflow, and that is your decision. The validator does not check that the three pinned lines are adjacent or in order. The security review set this aside as hardening rather than a finding: the old single-line pin also guarded only against accidental drift, never against a deliberate edit.
.prettierrc and the OpenCode shell-check plugin failed prettier --check
under the shipped .prettierrc, so adopters keeping their files
Prettier-clean had to edit them and meet conflicts on upgrade.

Prettier splits the plugin's execFile call, whose line the validator
pinned whole, so the validator now pins the call's lines as Prettier
lays them out, keeping its check that the plugin runs hook mode.

Fixes #163
claudiomaradonna deleted branch fix/prettier-shipped-files 2026-10-29 09:02:14 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/agent-foundry!164
No description provided.