Skip to content

fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone - #12092

Closed
josephfarina wants to merge 3 commits into
mainfrom
josephfarina/theme-build-selected-core-facts
Closed

josephfarina wants to merge 3 commits into
mainfrom
josephfarina/theme-build-selected-core-facts

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User impact

A theme that gives a component a custom variant, such as a Badge variant: 'gray' that Core does not ship, needs a .variants.d.ts file so that <Badge variant="gray"> type-checks. theme build writes it, and references it from the theme's .d.ts.

Through a CLI installed for the computer (npm install -g @astryxdesign/cli), theme build writes neither: the theme builds, but the app's TypeScript rejects the custom variant. Because the same theme built by a CLI installed beside Core does get the file, the two copies disagree about the same source. In an app whose theme was built by one, the other reports it stale:

$ astryx theme build src/themes/team-purple/teamPurpleTheme.ts --check
src/themes/team-purple/team-purple.d.ts  outdated
$ astryx doctor
theme-local-builds  fail  Local theme outputs are missing or stale: team-purple.

and rebuilding with the first drops the type declarations the app relies on.

After this change, both copies write the same files: a CLI installed for the computer reads the component docs and types of the project's Core, which it already builds with, and writes the variant declarations.

The built module's doc comment also names the command that ran the build (built by \npx @astryxdesign/[email protected] theme build`, pnpm exec astryx, or a tool's own command), so two people building the same theme with different package managers or tools wrote different modules, and theme build --checkreported the other's build as stale. It now namesastryx theme build`, as the generated header already does.

Problem and solution fit

  1. Why does it happen? theme build loads the project's Core to build a theme, but reads the component docs and types that decide which variants need declarations from a Core beside the CLI. A CLI installed for the computer has none beside it, so it finds no component and declares no variant. Separately, the module's doc comment prints the invocation that ran the build.
  2. Why does it harm the task? The app's types miss the theme's variants, and doctor and theme build --check fail on a theme that is up to date, depending on which copy built it.
  3. Why does that matter? A CLI installed for the computer is how people use Astryx outside a project and in projects without their own CLI, and a team or a tool can build the same theme through different copies.

The build now reads Core's docs and types from the Core it selected for the build, the same one it loads the theme with; only before a build selects one does it fall back to the Core beside the CLI. The caches of those reads are kept per Core. The doc comment names the canonical command, so the module no longer depends on how the CLI was started.

Expected behavior and authority

  • spec:AST-081 FR3: a run answers as a project with that release of Core installed would. spec:AST-050 FR11 check 5: every added local theme is built, and its outputs match its source. A build's outputs follow from its source and the Core it builds with, not from which copy of the same CLI release ran it. No record changes.

Smallest restoration

  • api/theme/build/build.mjs: resolveCoreRoot() returns the package root of the Core the build selected (from its theme entry), else the Core beside the CLI. The known-values index, component declarations, augmentation targets and known components are cached per Core. The build keeps the facts of the project's installed Core when it has one. The module's doc comment names astryx theme build.

Evidence

  • Reproduction: an app with a local theme that extends neutral, built by a CLI installed beside Core (the theme's .variants.d.ts declares neutral's custom Badge variant), then checked by the same release installed for the computer. Before: theme build --check reported team-purple.d.ts outdated, and doctor's theme-local-builds failed. Rebuilding with the computer's copy wrote no .variants.d.ts.
  • Result with only api/theme/build/build.mjs replaced in both copies: the computer's copy writes the same five files, byte for byte apart from the header's command line; --check is up to date and theme-local-builds passes.
  • Regression test: build.global-copy.test.mjs places the packed CLI as a global install with no Core beside it and builds a theme with a custom Badge variant in an app that installed Core. It expects the .variants.d.ts declaration, the .d.ts reference, and the canonical command in the module. It fails on main (no .variants.d.ts).

Scope

Components: CLI (theme build through a CLI installed for the computer)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project node over api/theme (every build test included), api/theme-edit, api/doctor/theme-checks and foundation/discovery/core-theme-facts: 399 files, 5,344 passed. The new build.global-copy test fails on main.
  • ESLint and Prettier on the changed files.

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 16, 2026 3:54pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 16, 2026, 4:12 PM UTC

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · cba8838

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes: the fix does what it says, since a CLI copy with no Core beside it now writes the same theme outputs as a copy with Core, but one line breaks the build.

  • packages/cli/api/theme/build/build.mjs:1838 fails TypeScript's strict check (TS18048: 'index' is possibly 'undefined') because Map.get can return undefined, so the root pnpm build (at sync:api-types) and the CLI typecheck fail; keep the promise in a local before awaiting it, as the inline suggestion shows.

The preview deployment fails on both commits, which matches this build failure. Everything else checked out: the new test fails on main and passes here, and one theme built through both kinds of copy gives the same five files.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: a CLI installed for the computer now writes the same theme files as one installed beside Core. Verified: a side-by-side build gives five identical files apart from the ignored command line; the new test.
  • Claim: the build reads component docs and types from the Core it builds with. Verified: build.mjs:1849-1891.
  • Claim: a theme with a custom variant now gets its .variants.d.ts and the .d.ts reference. Verified: the new test fails on main at line 94 and passes here.
  • Claim: before, that CLI wrote no variant declarations, and doctor and theme build --check called another copy's build stale. Verified: on main the global copy writes four files and a .d.ts without the reference; doctor's local-build check runs the strict check.
  • Claim: the module's doc comment names astryx theme build whatever ran the build. Verified: build.mjs:4219; the theme packages' built modules differ only in that line.
  • Claim: only before a build selects a Core does it fall back to the Core beside the CLI. Verified: build.mjs:1850-1857.
  • Claim: the caches of those reads are kept per Core. Verified: build.mjs:1815, :1912, :1962, :4326.
  • Claim: the build keeps the facts of the project's installed Core when it has one. Verified: build.mjs:4747-4752.
  • Claim: the generated header already names astryx theme build. Verified: build.mjs:755.
  • Claim: the theme, doctor and core-facts tests pass. Verified for the subset rerun here: 65 files, 909 passed, 1 skipped.
  • Claim: no new public API. Verified: the API report lists no row for any built package, and no command or option changed.
  • File packages/cli/api/theme/build/build.mjs: finding (TS18048 at line 1838).
  • File packages/cli/api/theme/build/build.global-copy.test.mjs: clear.
  • File .changeset/theme-build-selected-core-facts.md: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/theme/build/build.mjs Resolved

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: the required checks have not run on this head yet, because the CI run was refused for capacity ("CI is full"), so re-run its jobs before merging.

The earlier blocker is fixed: getKnownValues now keeps the promise in a local before awaiting it, and the root pnpm build and the CLI's strict typecheck pass. A CLI copy with no Core beside it now writes the same five theme files as a copy with Core, and each copy's theme build --check accepts the other's build; the new test fails on main and passes here.

Claims and files checked

Review mode: full; reason: rebase

  • Claim: a CLI installed for the computer now writes the same theme files as one installed beside Core. Verified: one theme built through both gives the same five files byte for byte; the new test.
  • Claim: the build reads the component docs and types of the Core it builds with, which is the project's. Verified: build.mjs:1855-1897.
  • Claim: a theme with a custom variant now gets its .variants.d.ts and the .d.ts reference. Verified: the new test fails on main at line 94 and passes here.
  • Claim: before, that CLI wrote no variant declarations, and doctor and theme build --check called another copy's build stale. Verified: on main the global copy writes four files and each copy's --check rejects the other's build; doctor's local-build check runs the same strict check (api/doctor/theme-checks.mjs:1619-1623).
  • Claim: the module's doc comment names astryx theme build whatever ran the build, so different package managers and tools write the same module. Verified: build.mjs:4383; the theme packages' built modules differ only in that line.
  • Claim: only before a build selects a Core does it fall back to the Core beside the CLI. Verified: build.mjs:1855-1864, and every build path selects a Core before the first read.
  • Claim: the caches of those reads are kept per Core. Verified: build.mjs:1818, :1918, :1968, :4490.
  • Claim: the build keeps the facts of the project's installed Core when it has one. Verified: build.mjs:4909-4916.
  • Claim: the generated header already names astryx theme build. Verified: build.mjs:758.
  • Claim: the governing records are the global-mode and app-theme specs, and no record changes. Verified: the global-mode spec's same-files and installed-Core requirements and the app-theme spec's doctor check 5 cover every change; no record is edited.
  • Claim: the regression test builds a custom Badge variant through a packed global copy with no Core and fails on main. Verified: it fails on main at line 94.
  • Claim: with the fix, both copies write the same five files, --check is up to date and the local-build check passes. Verified for the files and --check; the local-build check runs the same comparison.
  • Claim: the theme, theme-edit, doctor theme-check and core-theme-facts tests pass. Verified: the same suites pass here (449 files, 5,604 passed, 5 skipped).
  • Claim: ESLint and Prettier pass on the changed files. Verified: both clean.
  • Claim: no new public API. Verified: the API report lists no row for any published package, and no command or option changed.
  • File packages/cli/api/theme/build/build.mjs: clear; the strict-typecheck failure in getKnownValues is fixed (build.mjs:1838-1843), and the root build and tsconfig.strict.json pass.
  • File packages/cli/api/theme/build/build.global-copy.test.mjs: clear.
  • File .changeset/theme-build-selected-core-facts.md: clear.

Automated review (maintainer link)

@josephfarina josephfarina reopened this Nov 17, 2026
josephfarina added a commit that referenced this pull request Nov 18, 2026
…variant declarations, and names the build command alone
josephfarina added a commit that referenced this pull request Nov 19, 2026
…variant declarations, and names the build command alone
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12252 docs(cli): agent docs name the prop names that differ from other libraries
  Author: Joey Farina <[email protected]>
- #12154 fix(core): a numeric typography weight builds through an extended base's adaptation rules
  Author: Joey <[email protected]>
- #12092 fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone
  Author: Joey Farina <[email protected]>
- #12316 fix(core): a shorthand never follows its own longhand in one style merge
  Author: josephfarina <[email protected]>
- #12357 fix(core): a Table stays the scroll region when a host scrolls every table's parent
  Author: Joey Farina <[email protected]>
- #12349 fix(core): end a mouse drag a sandboxed frame never saw released
  Author: josephfarina <[email protected]>
- #12425 fix(cli): use a stored doc parse only with the zod release that made it
  Author: Joey <[email protected]>
- #12396 fix(AppShell): with the standard width points, a server-rendered shell hides its inline side nav on a phone before its script runs
  Author: Joey <[email protected]>
- #12438 fix(charts): end dots draw whole and a thinned axis keeps its last label
  Author: Joey Farina <[email protected]>
- #12448 fix(cli): upgrade outside a project names the project, not --from
  Author: Joey Farina <[email protected]>
- #12459 fix(templates): the dashboard scorecard fits a phone screen
  Author: Joey Farina <[email protected]>
- #12428 fix(core): Field labels draw in a bolder face than their description
  Author: Joey Farina <[email protected]>
- #12435 fix(theme-matcha): dark menus, popovers and muted fills take the theme's deep gray neutral
  Author: Joey <[email protected]>
- #12432 fix(templates): dashboard chart labels show whole instead of clipped by the chart edge
  Author: Joey Farina <[email protected]>
- #12441 fix(cli): mark icon-set generated calls pure so apps drop unused icons
  Author: Joey Farina <[email protected]>
- #12472 fix(MetadataListItem): a value breaks only a word longer than its line
  Author: Joey <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12718.

@github-actions
github-actions Bot deleted the josephfarina/theme-build-selected-core-facts branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — cba88380 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant