Skip to content

Add oxfmt, format the repo, fix the showcase typecheck - #1

Merged
samkim merged 4 commits into
mainfrom
chore/oxfmt
Sep 27, 2026
Merged

samkim merged 4 commits into
mainfrom
chore/oxfmt

Conversation

@samkim

@samkim samkim commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Four commits, reviewable in order:

  • 3e4877f — tooling: .oxfmtrc.json, mage fmt:all / fmt:check, a CI format job, a CONTRIBUTING section
  • 8a54b7b — Markdown reformat, 179 files
  • 02d2b61 — TypeScript reformat, 146 files, plus the rebuilt web bundles
  • b802a07 — declare the capture-engine globals once instead of per demo

Decisions

One style for all web code. showcase/ was written without semicolons and with single quotes; web/ with both. This applies one config to both, so showcase gains roughly 1,550 semicolons and 1,380 quote flips. A nested showcase/.oxfmtrc.json could have preserved its style; we chose consistency.

Prose wraps at 80 columns, matching what the docs already did by hand.

oxfmt is pinned at 0.70.0 and run through pnpm dlx, so there is no root package.json and nothing added to the go.mod tool block.

Targets are explicit globs. Excluded: generated MDX, toolkits/ and **/SKILL.md (parsed by skillmd), testdata, webassets/dist, and CLAUDE.md.

Implications

Formatting is now a blocking CI check. Run mage fmt:all before opening a PR, and run it until fmt:check is clean — oxfmt occasionally needs a second pass.

Read 02d2b61 by behavior, not by diff. Nothing in it was hand-written; mage fmt:all on its parent reproduces it exactly. One line has a real consequence: the formatter added an explicit {" "} in agentlink.tsx to preserve a space in JSX, which changed a bundle's content hash, so the rebuilt bundle and manifest are committed with it.

showcase typecheck passes again, but nothing in CI runs it — the frontend job covers web/ only. That gap is why the five errors accumulated, and it is not closed here.

Verification

mage fmt:check, mage web:check, go build ./..., web typecheck and 1532 tests, showcase typecheck and 41 tests, both demo builds, docs:check.

🤖 Generated with Claude Code

Neither Markdown nor TypeScript had a formatter. Prose wrapping in the docs
ranged from roughly 70 to 90 columns and was maintained by hand, and the
frontend under web/ and showcase/ had only typecheck and tests.

oxfmt covers both from one pinned binary. Its Markdown output was compared
against Prettier 3 with the equivalent settings on README.md and came back
byte-identical, including the cases a naive reflow gets wrong, such as
breaking inside an inline code span.

The version is pinned exactly in magefiles/fmt.go and in the workflow, and
invoked through `pnpm dlx` rather than a root package.json, which this
repository does not have, or the go.mod tool block, which would pull the
formatter's archive-handling dependency tree into the module graph.

The targets are explicit globs rather than a tree walk, so a new file type
cannot start being rewritten without someone adding it here. Excluded in
.oxfmtrc.json: the generated MDX reference pages that mage docs:cli and
docs:crd own, the skill definitions under toolkits/ and **/SKILL.md that
skillmd parses, testdata, the built bundles under webassets/dist, and
CLAUDE.md, which is a symlink to AGENTS.md.

This commit adds the tooling only. The reformat it produces follows.
Mechanical, produced by `mage fmt:all`. 179 files: prose rewrapped at 80
columns, table cells padded, emphasis markers normalized to underscores,
blockquotes rewrapped.

No prose was changed. Verified by normalizing whitespace, table separator
runs, and emphasis markers out of every changed file and comparing against
HEAD, and separately by extracting every fenced code block before and after:
zero code blocks differ.

Skill definitions, generated MDX, and testdata are excluded by .oxfmtrc.json,
so nothing a parser or a digest depends on is touched.
Mechanical, produced by `mage fmt:all`. 146 of 160 .ts/.tsx files under web/
and showcase/, which had no formatter before this.

One source change has a compiled consequence. In agentlink.tsx the formatter
broke a long JSX line and, to preserve the significant space before the link,
emitted an explicit {" "}. The rendered DOM is unchanged; the compiled chunk
represents that space as its own child instead of a trailing space on the
preceding text node, which changes the chunk's content hash. The rebuilt
bundle and manifest are committed here so `mage web:check` stays green.

Verified: web typecheck passes, and 1532 tests across 148 files pass.
showcase typecheck fails, but it fails identically at the previous commit —
pre-existing breakage in demos/slacksim that CI does not catch, because the
frontend job runs typecheck only in web/.
`pnpm typecheck` in showcase/ failed with five errors, all from one cause.
slacksim and consolesim each carried their own `declare global` for
window.__showcase and window.__showcaseStory, typed to that demo's own
richer interfaces. A `declare global` is program-wide, so under
tsconfig.json — which includes both demos — those are two declarations of
one property with two types (TS2717), and the four other errors are what
follows once TypeScript resolves each property to the other demo's type.
Nothing broke at runtime, where exactly one demo loads per page.

The globals now live once in demos/showcase-globals.d.ts, typed as the
contract the capture engine actually uses: set a caption, move the pointer,
run a beat. Both demos' OverlayControl and Rect were already byte-identical,
so nothing is lost. `run` and `playTo` are declared as returning
`Promise<void> | void`, which both demos satisfy — slacksim's beats are
immediate store mutations, consolesim's type into a terminal over time — and
awaiting either still works.

slacksim's bindControl now returns the ShowcaseControl it binds, so main.tsx
uses that value instead of reading window.__showcase! back out and asserting
a narrower type than the global carries. That also removes an excess-property
error on the object literal.

Verified: showcase typecheck passes, as do tsconfig.slacksim.json and
tsconfig.consolesim.json on their own, 41 tests across 6 files, both demo
builds, docs:check, mage fmt:check, mage web:check, and go build.

Note: nothing in CI runs showcase typecheck. The frontend job runs typecheck
only in web/, which is why these errors were able to accumulate.
@samkim
samkim requested a review from josephschorr September 25, 2026 23:53

@josephschorr josephschorr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@samkim
samkim merged commit 88a94d4 into main Sep 27, 2026
9 of 10 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.

2 participants