Repository navigation
agent-docs: single-source setup gotchas as data - #6731
kiranbadam wants to merge 1 commit into
Conversation
Add packages/cli/assets/gotchas.json (12 entries: id, title, trigger, fix, severity) with a loader/validator/renderer in foundation/agent-docs/gotchas.mjs. generateCompressedIndex now renders its GOTCHAS section from that JSON instead of hand-written error-preventers, so init --agent no longer omits the setup gotchas (StyleX compiler, SSR theme, hover-on-touch guard, cascade-layer order, ...). init, build, and doctor can consume the same source next. Fixes meta#6725.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @kiranbadam! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This pull request needs an engineering owner's decision before it can be approved: no current spec covers what the generated agent-docs block should contain, or a published gotchas.json data contract for init, build and doctor, and the batch review of the agent-tooling gap reports (#6721) has not settled #6725 yet. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request once a record covers the change; the author may do so if they are an engineering owner.
Whatever the decision, these need fixing:
- The first, high-severity gotcha (
packages/cli/assets/gotchas.json:5) tells every project that without a StyleX compiler "no Astryx styles are compiled", but the prebuilt stylesheets need no compiler and plain-CSS blocks say "No StyleX/Tailwind compiler here" a few lines above, so scope it to swizzled or self-authored StyleX (or render it only for StyleX projects) and drop theastryx doctorpointer, sincedoctorhas no compiler check. gotchas.json:61writesnpx @astryxdesign/cliinto the block, but commands there are written bare (astryx …) so the CLI can substitute the project's own command, so drop the entry or write the command bare.gotchas.jsonfails its own schema becausegotchas.schema.jsonsetsadditionalProperties: falsewithout allowing the top-level$schemakey, so allow that key and check the shipped file against the schema in a test.- The changeset says gotchas are now "single-sourced", but the same guidance stays hand-written in the
stylingandgetting-starteddocs and in the block's RULES lines, so describe it as a new GOTCHAS section read fromgotchas.json. agent-docs.mjs:473prints the GOTCHAS header even when loading the data fails, though the comment says the section is omitted, so push the header only after the lines render.
The branch also conflicts with main in agent-docs.mjs and needs a rebase.
[Automated review]
| "$schema": "./gotchas.schema.json", | ||
| "gotchas": [ | ||
| { | ||
| "fix": "Install and wire a StyleX compiler (@stylexjs/unplugin or your bundler's integration) \u2014 without it no Astryx styles are compiled. Run `astryx doctor` to verify.", |
There was a problem hiding this comment.
This renders first, at high severity, in every project's agent-docs block, including plain-CSS and Tailwind ones whose RULES line says "No StyleX/Tailwind compiler here". The prebuilt stylesheets need no compiler (the styling doc says "consuming the published package needs no StyleX setup"), so this sends agents to install tooling the project does not need. Scope it to swizzled or self-authored StyleX source, or render it only for StyleX projects. astryx doctor has no StyleX-compiler check, so drop that pointer too.
| "trigger": ":hover styles never apply, or stick on touch devices" | ||
| }, | ||
| { | ||
| "fix": "Invoke via `npx @astryxdesign/cli`, or add the astryx script to package.json.", |
There was a problem hiding this comment.
Commands in the generated block are written bare (astryx …) so the CLI can substitute the project's own command, which the header already names (for example pnpm exec astryx). Hard-coding an unversioned npx @astryxdesign/cli here bypasses that. Drop the entry, or write the command bare.
| @@ -0,0 +1,90 @@ | |||
| { | |||
| "$schema": "./gotchas.schema.json", | |||
There was a problem hiding this comment.
gotchas.schema.json sets additionalProperties: false at the top level and allows only gotchas and version, so this file fails its own schema (Ajv draft 2020-12: "must NOT have additional properties" for $schema). Add "$schema": {"type": "string"} to the schema's properties, and validate the shipped file against the schema in gotchas.test.mjs so the schema and validateGotchas cannot drift apart.
| // Gotchas — setup failure modes, single-sourced from assets/gotchas.json. | ||
| // Best-effort like the topic list above: a missing/unreadable file omits | ||
| // the section rather than breaking init; the schema is enforced by tests. | ||
| lines.push('GOTCHAS — setup failure modes, do not rediscover by failing:'); |
There was a problem hiding this comment.
The header is pushed before the try, so when gotchas.json is missing or invalid the block prints "GOTCHAS — …" with nothing under it, not the omitted section the comment above describes. Push the header only after renderGotchaLines returns lines.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [feat] Setup gotchas are now single-sourced as data: `packages/cli/assets/gotchas.json` holds 12 entries (id, title, trigger, fix, severity), and the generated agent cheat sheet (`init --agent`) renders its GOTCHAS section from that JSON instead of hand-written error-preventers — covering StyleX compiler setup, stylesheet import order, cascade-layer order, SWC-vs-Babel on Next.js, SSR theme builds, token usage, the hover-on-touch guard, and more. `init`, `build`, and `doctor` can consume the same source next. (#6725) |
There was a problem hiding this comment.
"Single-sourced" claims more than the change delivers: the same guidance stays hand-written in the styling and getting-started docs and in the block's RULES and SELF-CHECK lines. Suggested wording: "The generated agent-docs block gains a GOTCHAS section read from packages/cli/assets/gotchas.json: StyleX setup, stylesheet and layer order, SWC on Next.js, SSR theme builds, tokens, the hover guard and more."
|
(Posted by Cindy's agent.) Thanks, @kiranbadam. |
User need
Setup gotchas are tribal knowledge: hover guards (
@media (hover: hover)),@layerordering, SWC-vs-Babel StyleX transform, SSR theme builds, token import paths — they live in docs and issues, not the toolchain.init --agentgenerated a cheat sheet that omitted them, so every agent rediscovers each one by failing. The fix per #6725: single-source the gotcha list as data in the CLI package soinit,build,doctor, and the generated agent cheat sheet can all consume it.Problem and solution fit
packages/cli/assets/gotchas.json(published with the CLI) holds 12 entries withid,title,trigger,fix,severity, plus agotchas.schema.jsondocumenting the contract.packages/cli/foundation/agent-docs/gotchas.mjsloads, validates (loud, specific errors on bad edits), and renders the entries as terse severity-ordered cheat-sheet lines.generateCompressedIndexnow renders aGOTCHASsection from that JSON, replacing the hand-written error-preventer lines (the "No<div>" and token rules are now owned by the data). The cheat sheet an agent gets frominit --agentincludes all 12 gotchas.init,build, anddoctorcan consume the same source next — this PR establishes the data and the first consumer.Current specification
Fixes #6725. Entry fields are exactly
id,title,trigger,fix,severity(severity ∈ high/medium/low). 12 entries mined from the agent docs, setup guidance (getting-started), and theinternal/eslint-plugin-astryxrules, including the required four: StyleX compiler setup, SSR theme, hover-on-touch guard, cascade-layer order.Public delta and caller burden
GOTCHASsection — 12 one-line entries, highest severity first. No new flags or commands;init --agentoutput changes, existing blocks refresh on nextinit/upgrade.Design and alternatives
assets/(published) rather than code constants: it's the shared sourcebuildanddoctorwill read next, and editors get schema hover-docs.foundation/: dependency-free, and errors name every problem at generation time.init), matching the existing topic-list pattern; schema enforcement lives in tests.Evidence
gotchas.test.mjs(7 tests): schema validation of the shipped JSON, required-gotcha coverage, rejection of bad payloads (bad id format, bad severity, missing fields, duplicates, empty list), severity ordering, and every gotcha's title+fix appearing ingenerateCompressedIndexoutput across all three styling systems.packages/cli/foundation/agent-docs/suites: 120/120 pass — AGENTS marker, update, and idempotency tests all green.packages/cli/api/init/suites: 19/19 pass.pnpm check:repo— all checks pass; ESLint on changed files — 0 errors.npx astryxfootgun reintroduced (caught by existing invocation tests during development).Scope
Testing
vitest run --project node packages/cli/foundation/agent-docs/— 120/120 pass.vitest run --project node packages/cli/api/init/— 19/19 pass.pnpm check:repo— clean.eslinton changed files — 0 errors.Closes #6725