Skip to content

fix: make CI Format pass (format broken baseline + add pre-commit hook)#1190

Merged
RhysSullivan merged 2 commits into
mainfrom
fix/fmt-precommit-hook
Jun 28, 2026
Merged

fix: make CI Format pass (format broken baseline + add pre-commit hook)#1190
RhysSullivan merged 2 commits into
mainfrom
fix/fmt-precommit-hook

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Jun 28, 2026

Copy link
Copy Markdown
Owner

The real problem

origin/main itself was already failing bun run format:check (oxfmt --check .): 20 package.json files were unformatted (publishConfig key order, access sorts before exports). Because the Format job runs on the merge result, every PR inherited a red Format check no matter what it changed. That is why fmt appeared to fail on essentially every agent PR; it was not the agents' diffs.

A secondary gap: the repo had no git hooks, so nothing formatted commits locally before they were pushed either.

What this does

  1. chore: format package.json publishConfig - formats the 20 unformatted package.json files so the baseline is green. The change is a pure, idempotent key reorder (verified by re-running oxfmt). The existing changeset:version script already runs oxfmt ., so the release flow keeps them formatted going forward.

  2. ci: auto-format staged code with a pre-commit hook - prevention so this cannot silently come back via locally-authored commits:

    • .githooks/pre-commit: formats staged JS/TS/JSON with oxfmt --write and re-stages them. Touches only staged files (matching the existing 'stage just your own files' rule), honours .oxfmtrc.json ignorePatterns, NUL-safe, and no-ops when oxfmt is not installed yet.
    • scripts/bootstrap.ts: sets git config core.hooksPath .githooks. hooksPath is local config that is never cloned or copied into worktrees, so bootstrap re-applies it on every fresh checkout / agent worktree.

Test

  • After the package.json commit, oxfmt --check . passes across all 1533 files locally.
  • The pre-commit hook was exercised with multiple staged misformatted files (including a path containing a space): all were rewritten and re-staged, and the committed blobs passed oxfmt --check.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 536d31c Commit Preview URL

Branch Preview URL
Jun 28 2026, 09:38 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 536d31c Jun 28 2026, 09:39 PM

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown

Greptile Summary

This PR addresses recurring CI format job failures caused by unformatted commits from contributors (especially agents) that skipped bun run format. It adds a pre-commit git hook that automatically formats staged JS/TS/JSON files with oxfmt and re-stages them, and wires the hook into scripts/bootstrap.ts so every fresh checkout or worktree picks it up.

  • .githooks/pre-commit: Uses a NUL-delimited while read loop into a bash array to safely enumerate staged files, then formats them in-place and re-stages. The --no-error-on-unmatched-pattern flag prevents false failures when all staged files are excluded by .oxfmtrc.json.
  • scripts/bootstrap.ts: Adds git config core.hooksPath .githooks so the hook is activated automatically on every fresh checkout and agent worktree.
  • packages/*/package.json (21 files): Purely cosmetic reformatting — "access": "public" moves from the end of publishConfig to the beginning; JSON key order does not affect npm publish semantics.

Confidence Score: 5/5

Safe to merge. The hook is correctly implemented and all package.json changes are cosmetic reformatting with no functional impact.

The pre-commit hook uses the correct bash array technique to handle NUL-delimited filenames, gracefully no-ops when oxfmt is absent, and the bootstrap wiring is straightforward. Package.json changes only reorder keys within publishConfig, which has no effect on npm publish semantics.

No files require special attention.

Important Files Changed

Filename Overview
.githooks/pre-commit New pre-commit hook that correctly reads NUL-delimited staged filenames into a bash array, formats with oxfmt, and re-stages. Handles the bash 3.2 macOS constraint, gracefully no-ops when oxfmt is absent, and documents the partial-staging caveat.
scripts/bootstrap.ts Adds a single git config call to set core.hooksPath on every fresh checkout or worktree; straightforward and correct.
packages/core/sdk/package.json Cosmetic-only: moves "access": "public" before "exports" within publishConfig. JSON key order has no effect on npm publish behavior.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Dev as Developer / Agent
    participant Git as git commit
    participant Hook as .githooks/pre-commit
    participant oxfmt as oxfmt (node_modules/.bin)
    participant CI as CI format job

    Dev->>Git: git commit
    Git->>Hook: invoke pre-commit hook
    Hook->>Hook: git diff --cached --name-only -z
    alt oxfmt not installed
        Hook-->>Git: exit 0 (skip, warn)
    else no staged formattable files
        Hook-->>Git: exit 0
    else files to format
        Hook->>oxfmt: --write --no-error-on-unmatched-pattern [files]
        oxfmt-->>Hook: files rewritten in place
        Hook->>Git: git add -- [files]
        Hook-->>Git: exit 0
        Git-->>Dev: commit created already formatted
        Dev->>CI: push
        CI-->>Dev: format check passes
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Dev as Developer / Agent
    participant Git as git commit
    participant Hook as .githooks/pre-commit
    participant oxfmt as oxfmt (node_modules/.bin)
    participant CI as CI format job

    Dev->>Git: git commit
    Git->>Hook: invoke pre-commit hook
    Hook->>Hook: git diff --cached --name-only -z
    alt oxfmt not installed
        Hook-->>Git: exit 0 (skip, warn)
    else no staged formattable files
        Hook-->>Git: exit 0
    else files to format
        Hook->>oxfmt: --write --no-error-on-unmatched-pattern [files]
        oxfmt-->>Hook: files rewritten in place
        Hook->>Git: git add -- [files]
        Hook-->>Git: exit 0
        Git-->>Dev: commit created already formatted
        Dev->>CI: push
        CI-->>Dev: format check passes
    end
Loading

Reviews (2): Last reviewed commit: "chore: format package.json publishConfig..." | Re-trigger Greptile

Comment thread .githooks/pre-commit Outdated
Comment thread .githooks/pre-commit Outdated
@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1190

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1190

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1190

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1190

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1190

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1190

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1190

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1190

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1190

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1190

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1190

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1190

executor

npm i https://pkg.pr.new/executor@1190

commit: c0aae4b

Adds .githooks/pre-commit that runs oxfmt --write on staged JS/TS/JSON
and re-stages them, and wires git config core.hooksPath .githooks into
bootstrap so every fresh checkout and worktree activates it.

Commits now land already-formatted, so the CI format job (oxfmt --check)
stops failing on contributions that skipped running format manually. The
hook only touches staged files, matching the existing rule to stage just
your own files. It honours .oxfmtrc.json ignorePatterns and no-ops when
oxfmt is not yet installed.
origin/main was already failing oxfmt --check on 20 package.json files
(publishConfig key order: access sorts before exports), so every PR
inherited a red Format check regardless of its own contents. Format them
once to make the baseline green.
@RhysSullivan RhysSullivan force-pushed the fix/fmt-precommit-hook branch from c0aae4b to 536d31c Compare June 28, 2026 21:36
@RhysSullivan RhysSullivan changed the title ci: auto-format staged code with a pre-commit hook fix: make CI Format pass (format broken baseline + add pre-commit hook) Jun 28, 2026
@RhysSullivan RhysSullivan merged commit e8c0612 into main Jun 28, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant