Skip to content

feat(cli): astryx --json component and component() carry the theme values the text output prints - #11510

Draft
cixzhang wants to merge 6 commits into
mainfrom
fix/cli-component-json-theme
Draft

cixzhang wants to merge 6 commits into
mainfrom
fix/cli-component-json-theme

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

User need

An agent or script that reads astryx --json component Banner cannot see the custom values the configured theme adds, while the text view of astryx component Banner marks them with * once a built theme exports them (#5103 makes astryx theme build emit them). The two views must carry the same facts (architecture:cli-surface INV4, INV5), and component() from @astryxdesign/cli/api must return what --json prints (spec:AST-042 FR1). Today the JSON leaves the values out, so a builder who works from JSON picks only built-in values and misses the ones their own theme defines.

A second gap: when a recorded theme fails to load, the text view exits 1 and the JSON view exits 0 with a normal answer, so the same condition exits differently by output mode (INV8).

Problem and solution fit

  • component() adds data.theme to a detail result and a list result. Each row of a batch is a detail read of its own, so each row carries it too. The text view marks the same values with *.
  • The theme lookup moves from the CLI client into the theme subject's adapter: resolveActiveTheme in api/theme/_adapter.mjs, re-exported by api/theme/theme.mjs (not by api/index). The component adapter calls it. The API passes no warning handler, so a JSON read prints nothing on standard error (INV12). The text view passes one that prints each warning, as before.
  • The lookup returns one list of custom values per component, merged without duplicates from a built theme module's themeVariants export (across its props) and the theme object's own variants field, which it already read. The text view prints that list as value*, as on main. The themeVariants read comes from @jiunshinn's work in fix(cli): expose built theme variants in component docs #5103, whose review surfaced the gap, and keeps that authorship.
  • A detail, list or batch read whose recorded theme throws while it loads now fails with ERR_THEME_LOAD and exit 1 in JSON too. The props, source, showcase and blocks views print no theme value, so neither view loads the theme for them, and both exit the same way.

Current specification

  • architecture:cli-surface INV4, INV5: text is a projection of the JSON, and text field names mirror JSON keys. INV7: the CommandDoc names the new field. INV8: the same condition exits the same way with and without --json. INV12: no chatter in JSON mode.
  • spec:AST-042 FR1: the API and the CLI's JSON return the same result.
  • spec:AST-017 DEC-4: a new response field ships with its type, contract tests and docs.

values mirrors the text field for field: one list per component, the list the text marks with * (INV4, INV5). A per-prop shape, with prop:value* labels in the text, would change both views together in a later pull request.

Public delta and caller burden

{
  "type": "component.detail",
  "data": {
    "name": "Banner",
    "theme": {"name": "acme", "values": {"banner": ["glass", "critical"]}}
  }
}
  • data.theme is {name, values} or null when no theme is configured or the configured theme is not found. values lists each component's custom values; it stays {} for a built theme until astryx theme build emits themeVariants (fix(cli): expose built theme variants in component docs #5103).
  • --props, --source, --showcase and --blocks results do not change and do not load the theme.
  • Types: ComponentTheme and ComponentThemeField in @astryxdesign/cli/json; ComponentDetailResponse and ComponentListResponse carry theme.
  • Text: the label stays value*. A theme whose built module exports themeVariants now gets those values marked, where main marked none, because the lookup reads that export as well as the theme object's variants field.
  • Exit codes: a detail, list or batch read whose recorded theme throws while loading exits 1 with ERR_THEME_LOAD in JSON, as it already did in text; component()'s throws list and the command's exit-code text name it. The props, source, showcase and blocks reads no longer load the theme, so they no longer exit 1 in text for it. A theme that cannot be found still answers, with data.theme: null.

Design and alternatives

  • Adding the field in the CLI command after component() returns breaks spec:AST-042 FR1, because the API and the JSON then differ.
  • values takes the shape the text already has: one list per component, the list it marks with *. Labelling each value with the prop that takes it (prop:value* in the text, a per-prop level in the JSON) is a separate decision; if it is made, both views change together in one pull request.

Evidence

  • Red first: 10 new and changed cases in resolve-theme.test.mjs failed on main: data.theme on detail, list and batch rows, null for broken and missing themes, the name for working themes, and JSON exit 1 for a theme that throws.
  • component() returns the same data.theme as astryx --json component, and the text view prints glass* for the same project.
  • The props, source, showcase and blocks reads carry no theme, print no theme warning in text or JSON, and answer with exit 0 in both views when the recorded theme throws.
  • Goldens: component.json and component-zh.json gain "theme": null.

Scope

Components: cli (component command, component API, theme lookup)

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project node on resolve-theme, component-format, doc-loads, text-json-parity, api/component and golden-reads: 14 files, 639 tests pass. The red cases above, and the four props, source, showcase and blocks reads with a throwing theme (text exited 1, JSON 0), fail on main.
  • vitest run packages/cli/test/golden-reads.test.mjs -u: the two component goldens update with "theme": null; golden-reads and experimental-isolation then pass (101 tests).
  • pnpm -F @astryxdesign/cli typecheck:strict and typecheck:json-api: no errors. pnpm -F @astryxdesign/cli sync:api-types, readme:check, pnpm check:changesets and pnpm check:repo (the CLI structure checks INV21–INV23 included) pass.
  • On the macOS machine used here, seven api/theme-edit lock, case-folding and preview-folder tests fail locally. None of those modules imports a file this pull request changes; CI runs them on Linux.

Owner and land path

  • Owner: fix lane 2, an agent working for @cixzhang on Astryx maintenance.
  • Land path: Approved and ready; held for a maintainer decision on the new public CLI types. It merges through CI once that decision is made; if the decision is no, it closes with the reason.

jiunshinn and others added 2 commits November 12, 2026 21:18
…rop for each theme value

The theme lookup reads the custom values a built theme module exports as
themeVariants, by component key and prop, instead of a variants field on the
theme object. The text view prints each value as prop:value*, so a component
with two extensible props says which prop takes which value.

Ported from #5103 so that component() and the JSON output can carry the
same values.
A detail result and a list result carry data.theme: the configured theme's
name and the custom values it adds, by component key and prop, which the
text view marks with *. Each batch row is a detail read, so it carries it
too. The theme subject's adapter resolves the active theme and prints
nothing in JSON; the text view still prints each warning. A recorded theme
that fails to load exits 1 with ERR_THEME_LOAD in JSON too. The response
types, the command and function docs, and the goldens follow.

Co-authored-by: jiunshinn <[email protected]>
@vercel

vercel Bot commented Nov 13, 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 13, 2026 1:49pm UTC

Request Review

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

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 3:34 PM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a32fa41

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · db31f8b

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 4.17 MB packed (+2.4 kB); no new dependencies.

API changes: cli +4 · ~2 · −0

6 API changes (advisory)
Package Where Signature Usage
+ cli ./api · Types · type ComponentTheme type ComponentTheme = { name: string | null; values: Record<string, string[]> } | null import type {ComponentTheme} from '@astryxdesign/cli/api'
+ cli ./api · Types · type ComponentThemeField type ComponentThemeField import type {ComponentThemeField} from '@astryxdesign/cli/api'
+ cli ./json · Also exported from an earlier entry point · ComponentTheme ComponentTheme (./api) import {ComponentTheme} from '@astryxdesign/cli/json'
+ cli ./json · Also exported from an earlier entry point · ComponentThemeField ComponentThemeField (./api) import {ComponentThemeField} from '@astryxdesign/cli/json'
~ cli ./api · Types · type ComponentDetailResponse data: ComponentDoc & ComponentOwnership & ComponentDetailScope → data: ComponentDoc & ComponentOwnership & ComponentDetailScope & ComponentThemeField import type {ComponentDetailResponse} from '@astryxdesign/cli/api'; const x: ComponentDetailResponse = {data: …}
~ cli ./api · Types · type ComponentListResponse data: ComponentListData → data: ComponentListData & ComponentThemeField import type {ComponentListResponse} from '@astryxdesign/cli/api'; const x: ComponentListResponse = {data: …}

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@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. An engineering owner approved the theme-values direction for this head (data.theme, its themeVariants source and the prop:value* label), so five fixes remain.

  • The changeset and description say a recorded theme that fails to load now exits 1 in JSON as it does in text, but astryx component Button --props (and --source, --showcase, --blocks) still exits 1 in text and 0 in JSON because the text handler in commands/component.mjs loads the theme for every read; gate that lookup to detail and list reads or narrow the claim.
  • component() can now reject with ERR_THEME_LOAD, but neither its throws list in api/component/component.doc.mjs nor the command's exitCodes names that failure.
  • ComponentListRead and ComponentDetailRead in component.type.mjs become public types of @astryxdesign/cli/api and @astryxdesign/cli/json through the export * barrels, so move them beside ComponentRead in component.mjs.
  • Miss: componentTheme in api/component/_adapter.mjs copies the command's theme-load error formatting, so the error text now has two owners; throw ERR_THEME_LOAD once from resolveActiveTheme or one shared helper and delete the copy in commands/component.mjs.
  • The description cites a theme-authoring-contract INV18 that does not exist, places the lookup in api/theme/_active-theme.mjs instead of api/theme/_adapter.mjs, and says the text view already marks theme values with *, which no built theme does today.

Non-blocking: the package-field path no longer reads a variants field on the theme object, which the changeset should say and which the "byte-for-byte" comment in api/theme/_adapter.mjs no longer matches. CI has not run on this draft head.

Claims and files checked
  • Claim: JSON and component() return data.theme on detail, batch-row detail and list results: verified (head tests and probe).
  • Claim: each theme value prints as prop:value*: verified (formatter tests, Banner probe).
  • Claim: data.theme is null without a theme and values stays empty until a built module exports themeVariants: verified.
  • Claim: a recorded theme that fails to load now exits 1 with ERR_THEME_LOAD in JSON as in text: false for the props, source, showcase and blocks reads.
  • Claim: a theme that cannot be found prints no warning in JSON: verified.
  • Claim: today's JSON leaves theme values out: verified on the base.
  • Claim: today's text view marks theme values with *: false for every built theme.
  • Claim: text and JSON exit differently for a throwing theme today: verified on the base.
  • Claim: the lookup moved into an internal API module named _active-theme.mjs: false location (it is in api/theme/_adapter.mjs and stays internal).
  • Claim: a JSON read prints nothing on standard error: verified.
  • Claim: values come from themeVariants by component and prop: verified.
  • Claim: the ported parts keep their original authorship: verified (first commit).
  • Claim: the cited CLI-surface, command-admission and response-field claims exist: verified; the cited theme-authoring-contract INV18 does not exist.
  • Claim: props, source, showcase and blocks results do not change and do not load the theme: true for JSON; the text view still loads it.
  • Claim: new types ComponentTheme and ComponentThemeField, and the response types carry theme: verified; two further types are also published.
  • Claim: a theme that cannot be found still answers with data.theme: null: verified.
  • Claim: the new and changed theme cases fail on main: verified (18 cases fail on the base).
  • Claim: the named suite passes (13 files, 622 tests): verified.
  • Claim: the two goldens gain "theme": null and the golden tests pass: verified.
  • Claim: JSON-API typecheck and README check pass: verified; the strict typecheck shows only two errors in untouched templates that need a built theme package.
  • File .changeset/cli-component-json-theme.md: exit-parity claim too broad.
  • File packages/cli/api/component/_adapter.mjs: duplicated theme-load error formatting.
  • File packages/cli/api/component/component.doc.mjs: throws lacks ERR_THEME_LOAD.
  • File packages/cli/api/component/component.mjs: clear.
  • File packages/cli/api/component/component.type.mjs: two intermediate types published.
  • File packages/cli/api/component/detail/detail.mjs: clear.
  • File packages/cli/api/component/list/list.mjs: clear.
  • File packages/cli/api/theme/_adapter.mjs: non-blocking stale comment about the package-field lookup.
  • File packages/cli/api/theme/theme.mjs: clear.
  • File packages/cli/clients/cli/commands/component.doc.mjs: exit codes lack the theme failure.
  • File packages/cli/clients/cli/lib/component-format.mjs: clear.
  • File packages/cli/clients/cli/lib/component-format.test.mjs: non-blocking comment says the build already exports themeVariants.
  • File packages/cli/clients/cli/lib/resolve-theme.mjs: clear.
  • File packages/cli/clients/cli/lib/resolve-theme.test.mjs: clear; the throwing case is tested for detail only.
  • File packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • File packages/cli/test/__golden__/component-zh.json: clear.
  • File packages/cli/test/__golden__/component.json: clear.

Automated review (maintainer link)

Comment thread .changeset/cli-component-json-theme.md Resolved
The text view loaded the theme for every read, so a props, source, showcase
or blocks read exited 1 in text and 0 in JSON when the recorded theme threw.
It now loads the theme only for a detail, list, or batch read with a detail
row, the reads for which component() returns data.theme. component()'s
throws list and the command's exit-code text name ERR_THEME_LOAD. The two
read typedefs move to an internal module the barrels do not re-export.

Co-authored-by: jiunshinn <[email protected]>

@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.

Approval waits on an engineering owner's decision for this head, and two fixes remain; the exit-code parity, the ERR_THEME_LOAD docs and the two internal types from the last review are fixed.

The earlier /approve-spec names a previous commit, and no current record settles: the data.theme field ({name, values} or null) with its ComponentTheme and ComponentThemeField types; reading values from a built theme's themeVariants export, keyed by component and then prop; the prop:value* text label; and the --props, --source, --showcase and --blocks text views now exiting 0 without loading the theme. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Blocking

  • The recorded-theme load error is built twice, in componentTheme (packages/cli/api/component/_adapter.mjs) and in the text handler's catch (packages/cli/clients/cli/commands/component.mjs), and the handler's copy can no longer run, so please delete it or have both use one helper.
  • The description lists architecture:theme-compilation INV18 under current specification, but that record ends at INV17 on main, so please move that line out and say the values shape waits on the owner decision.

Non-blocking

  • The package-field lookup no longer reads a variants field on the theme object (a hand-written theme with variants loses its * marks), so please say so in the changeset and drop the "byte-for-byte" wording in packages/cli/api/theme/_adapter.mjs.
Claims and files checked

Claims (changeset and description):

  • JSON and component() return data.theme on detail, batch-row detail and list results: verified (resolve-theme.test.mjs:647-686).
  • The values are the ones the text marks, printed as prop:value*: verified (component-format.test.mjs:255-338, resolve-theme.test.mjs:688-697).
  • data.theme is null without a theme and values stays empty until a built module exports themeVariants: verified (api/component/_adapter.mjs:961-963, resolve-theme.test.mjs:670-678).
  • A detail, list or batch read with a throwing recorded theme exits 1 with ERR_THEME_LOAD in JSON as in text: verified (resolve-theme.test.mjs:600-617, exit probe).
  • Props, source, showcase and blocks reads no longer load the theme or warn about it: verified (commands/component.mjs:269-290, resolve-theme.test.mjs:520-598).
  • A theme that cannot be found prints no warning in JSON: verified (resolve-theme.test.mjs:486-518).
  • The lookup lives in the theme subject's adapter, re-exported by api/theme/theme.mjs and not by the API index: verified.
  • The API passes no warning handler and the text view prints each warning: verified (api/theme/_adapter.mjs:1627-1630, clients/cli/lib/resolve-theme.mjs:26-27).
  • The cited CLI-surface, command-admission and response-field clauses exist and say what is quoted: verified.
  • The theme-compilation INV18 citation is current specification: false (the record ends at INV17 on main).
  • ComponentTheme and ComponentThemeField reach the JSON types; the response types carry theme: verified (generated declarations).
  • component()'s throws and the command's exit codes name the new failure: verified (component.doc.mjs:195-198, commands/component.doc.mjs:98-101).
  • The new and changed cases fail on main: verified (26 fail on the base, including the four new projection cases).
  • The named suite passes (14 files, 639 tests): verified.
  • Both goldens gain "theme": null: verified.
  • Type, README, changeset and repository checks pass: verified for typecheck:json-api, readme:check, check:changesets and check:cli-structure; typecheck:strict shows only two unrelated template errors from an unbuilt theme package here.

Files:

  • .changeset/cli-component-json-theme.md: non-blocking (does not mention the dropped variants read).
  • packages/cli/api/component/_adapter.mjs: blocking (duplicated theme-load error).
  • packages/cli/api/component/_read.type.mjs: clear.
  • packages/cli/api/component/component.doc.mjs: clear.
  • packages/cli/api/component/component.mjs: clear (field shape waits on the owner decision).
  • packages/cli/api/component/component.type.mjs: clear (types wait on the owner decision).
  • packages/cli/api/component/detail/detail.mjs: clear.
  • packages/cli/api/component/list/list.mjs: clear.
  • packages/cli/api/theme/_adapter.mjs: non-blocking ("byte-for-byte" comment, variants marker).
  • packages/cli/api/theme/theme.mjs: clear.
  • packages/cli/clients/cli/commands/component.doc.mjs: clear.
  • packages/cli/clients/cli/commands/component.mjs: blocking (unreachable copy of the theme-load error).
  • packages/cli/clients/cli/lib/component-format.mjs: clear (label waits on the owner decision).
  • packages/cli/clients/cli/lib/component-format.test.mjs: clear.
  • packages/cli/clients/cli/lib/resolve-theme.mjs: clear.
  • packages/cli/clients/cli/lib/resolve-theme.test.mjs: clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/test/__golden__/component-zh.json: clear.
  • packages/cli/test/__golden__/component.json: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/theme/_adapter.mjs Resolved
component() reports a recorded theme that fails to load as ERR_THEME_LOAD
before the text handler runs, so the handler's own copy of that error could
no longer run and is gone. The adapter comment no longer calls the package
field lookup byte-for-byte, and the changeset says a theme object's own
variants field no longer adds marks.

Co-authored-by: jiunshinn <[email protected]>

@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.

Approval waits on an engineering owner's decision for this head, and two fixes remain; the duplicated theme-load error, the theme-compilation citation, the adapter comment and the changeset note from the last review are fixed.

The earlier /approve-spec names a previous commit, and no current record settles: the data.theme field ({name, values} or null) with its ComponentTheme and ComponentThemeField types; reading values from a theme module's themeVariants export, keyed by component and then prop; the prop:value* text label; and the --props, --source, --showcase and --blocks text views exiting 0 without loading the theme. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Blocking

  • Miss: packages/cli/foundation/response/response-types.doc.mjs, and the README response table generated from it, still describe component.list and component.detail without theme, so please name the field and its null case there and add it to the component.detail field list in response-types.doc.test.mjs.
  • Miss: extractVariants in packages/cli/api/theme/_adapter.mjs passes any themeVariants object into JSON, so an export such as {button: ['glass']} shows up in data.theme.values while the text marks nothing and the published string[] type does not hold, so please normalize the map once in the resolver and add a test with a flat-array export.
Claims and files checked

Claims (changeset and description):

  • JSON and component() return data.theme on detail, batch-row detail and list results: verified (resolve-theme.test.mjs:647-668).
  • The values are the ones the text marks, printed as prop:value*: verified for a well-formed export (component-format.test.mjs:255-338, resolve-theme.test.mjs:688-698); false for other export shapes (blocking finding above).
  • data.theme is null without a theme, and values stays empty until a theme module exports themeVariants: verified (api/component/_adapter.mjs:961-963, resolve-theme.test.mjs:670-678).
  • A detail, list or batch read with a throwing recorded theme exits 1 with ERR_THEME_LOAD in JSON as in text: verified (resolve-theme.test.mjs:600-618).
  • Props, source, showcase and blocks reads no longer load the theme or warn about it, in text or JSON: verified (commands/component.mjs:269-279, resolve-theme.test.mjs:520-598).
  • A theme that cannot be found prints no warning in JSON: verified (resolve-theme.test.mjs:486-518).
  • A theme object's own variants field no longer adds marks: verified (api/theme/_adapter.mjs:1591-1611, resolve-theme.test.mjs:721-727, and a run on both trees).
  • The lookup lives in the theme adapter, re-exported by api/theme/theme.mjs and not by the API index: verified.
  • The API passes no warning handler and the text view prints each warning: verified (api/theme/_adapter.mjs:1627-1630, clients/cli/lib/resolve-theme.mjs:24-27).
  • The cited CLI-surface, command-admission and response-field clauses exist and say what is quoted: verified; the response-field clause's documentation requirement is not fully met (blocking finding above).
  • The record for themeVariants is proposed in #5103, not current: verified (the theme-compilation record ends at INV17 on main).
  • ComponentTheme and ComponentThemeField reach the JSON types and the response types carry theme: verified (component.type.mjs:43-56, :136).
  • component()'s throws and the command's exit codes name the new failure: verified (component.doc.mjs:195-198, commands/component.doc.mjs:96-101).
  • The new and changed cases fail on main: verified on the previous commit; the test files are unchanged since.
  • The named suite passes (14 files, 639 tests): verified.
  • Both goldens gain "theme": null: verified.
  • Type, README, changeset and repository checks pass: verified for typecheck:json-api, readme:check, check:changesets and check:cli-structure; typecheck:strict shows only two unrelated template errors from an unbuilt theme package here.

Files:

  • .changeset/cli-component-json-theme.md: clear (field shape waits on the owner decision).
  • packages/cli/api/component/_adapter.mjs: blocking (returns the unchecked themeVariants map as values).
  • packages/cli/api/component/_read.type.mjs: clear.
  • packages/cli/api/component/component.doc.mjs: clear.
  • packages/cli/api/component/component.mjs: clear (field shape waits on the owner decision).
  • packages/cli/api/component/component.type.mjs: blocking (the new field is missing from the response reference).
  • packages/cli/api/component/detail/detail.mjs: clear.
  • packages/cli/api/component/list/list.mjs: clear.
  • packages/cli/api/theme/_adapter.mjs: blocking (extractVariants accepts any object).
  • packages/cli/api/theme/theme.mjs: clear.
  • packages/cli/clients/cli/commands/component.doc.mjs: clear.
  • packages/cli/clients/cli/commands/component.mjs: clear (one error path now; projection loading waits on the owner decision).
  • packages/cli/clients/cli/lib/component-format.mjs: clear (label waits on the owner decision).
  • packages/cli/clients/cli/lib/component-format.test.mjs: clear.
  • packages/cli/clients/cli/lib/resolve-theme.mjs: clear.
  • packages/cli/clients/cli/lib/resolve-theme.test.mjs: clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear.
  • packages/cli/test/__golden__/component-zh.json: clear.
  • packages/cli/test/__golden__/component.json: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/theme/_adapter.mjs Resolved
… them

The text view keeps main's value* label, and data.theme.values mirrors it: one
list per component key, merged without duplicates from a built module's
themeVariants export (across props) and the theme object's own variants
field, which the lookup still reads. The prop-keyed shape and the prop:value*
label wait for their own change.

Co-authored-by: jiunshinn <[email protected]>
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 439070e

@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. An engineering owner approved the direction for this head, so only three documentation fixes remain before approval.

  • Regression: component()'s doc (packages/cli/api/component/component.doc.mjs:28-30), the component command doc (packages/cli/clients/cli/commands/component.doc.mjs:27-29) and componentTheme's JSDoc (packages/cli/api/component/_adapter.mjs:935-936) still say data.theme lists values "by component and prop", but this head returns one list per component ({button: ['glass', 'jumbo']}), so please say "by component" in all three.
  • Miss: the JSON response reference (packages/cli/foundation/response/response-types.doc.mjs, the component.list and component.detail entries that generate the README response table) and the returns entries for those types in component.doc.mjs still do not name theme or its null case, which spec:AST-017 DEC-4's complete-documentation rule requires, so please add it there and to the component.detail field list in response-types.doc.test.mjs.
  • The description's "Design and alternatives" section rejects shipping main's flat shape and changing it later, yet this head ships that flat per-component shape while the description plans a per-prop shape in a later pull request, and its "Text: unchanged" line misses that a module exporting themeVariants now gets * marks, so please update both to match what ships.

The exit-code parity, the ERR_THEME_LOAD docs and the themeVariants normalization from earlier rounds are fixed. CI has not run on this draft head.

Claims and files checked
  • Claim: detail and list results, and each batch row's detail, carry data.theme — verified (component.mjs:282-306, batch rows at :221-238; tests in resolve-theme.test.mjs:648-669).
  • Claim: the theme lookup moves into the theme adapter, is not exported from the API index, and JSON reads print no warning — verified (theme/_adapter.mjs:1665-1725, theme.mjs:32-36, probe with a missing theme).
  • Claim: one list per component, merged without duplicates from themeVariants and the theme object's variants — verified (theme/_adapter.mjs:1595-1632; tests at resolve-theme.test.mjs:709-755).
  • Claim: the text view prints the list as value*, as on main — verified (formatter unchanged since the base).
  • Claim: text is unchanged — false for modules that export themeVariants (base no marks, head glass* jumbo*).
  • Claim: a throwing recorded theme makes detail, list and batch reads exit 1 with ERR_THEME_LOAD in JSON as in text — verified (probe; resolve-theme.test.mjs:601-620).
  • Claim: props, source, showcase and blocks reads skip the theme and exit 0 in both views — verified (commands/component.mjs:269-279; tests at :583-600).
  • Claim: a theme that cannot be found answers with data.theme: null — verified (probe).
  • Claim: ERR_THEME_LOAD is named in component()'s throws and the command's exit codes — verified (component.doc.mjs:195-198, commands/component.doc.mjs:100).
  • Claim: the per-component shape is the final shape and a per-prop shape would come later — contradictory (Design section versus Current specification section).
  • Claim: red-first cases fail on main — verified (23 resolve-theme.test.mjs cases fail with the head's tests on the base).
  • Claim: goldens gain "theme": null — verified.
  • Claim: the named suites, typecheck:json-api, readme:check and check:changesets pass — verified (15 files, 650 tests); typecheck:strict reports two template errors in files this change does not touch.
  • Changeset: every sentence verified against the code and the probe.
  • .changeset/cli-component-json-theme.md — clear.
  • packages/cli/api/component/_adapter.mjs — JSDoc says "by component key and prop".
  • packages/cli/api/component/_read.type.mjs — clear.
  • packages/cli/api/component/component.doc.mjs — description says "by component and prop"; returns entries omit theme.
  • packages/cli/api/component/component.mjs — clear.
  • packages/cli/api/component/component.type.mjs — clear.
  • packages/cli/api/component/detail/detail.mjs — clear.
  • packages/cli/api/component/list/list.mjs — clear.
  • packages/cli/api/theme/_adapter.mjs — clear.
  • packages/cli/api/theme/theme.mjs — clear.
  • packages/cli/clients/cli/commands/component.doc.mjs — description says "by component and prop".
  • packages/cli/clients/cli/commands/component.mjs — clear.
  • packages/cli/clients/cli/lib/component-format.test.mjs — clear.
  • packages/cli/clients/cli/lib/resolve-theme.mjs — clear.
  • packages/cli/clients/cli/lib/resolve-theme.test.mjs — clear.
  • packages/cli/foundation/doc-compiler/doc-loads.test.mjs — clear.
  • packages/cli/test/__golden__/component-zh.json — clear.
  • packages/cli/test/__golden__/component.json — clear.

Automated review (maintainer link)

…eference

The function doc, the command doc and the adapter JSDoc said data.theme lists
values by component and prop; it lists them by component. The JSON response
reference and component()'s returns for component.list and component.detail
now name theme and its null case, the README response table follows, and
the response-types test checks the detail entry names theme.

Co-authored-by: jiunshinn <[email protected]>
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec db31f8b

@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. An engineering owner approved the direction for this head, CI passed, and no blocking finding remains. data.theme on detail, list and batch-row results, the ERR_THEME_LOAD exit in JSON, and the projection reads that no longer load the theme all match their tests, docs and the command's text output.

Claims and files checked
  • Changeset: detail results, each batch row's detail and list results carry data.theme — verified (component.mjs:282-306; tests in resolve-theme.test.mjs:648-669).
  • Changeset: it holds the theme's name and, per component, the custom values the text marks with * — verified (theme/_adapter.mjs:1595-1632; test :689-699); JSON also keeps keys the text never looks up, such as a capitalised Button.
  • Changeset: the list merges a built module's themeVariants export and the theme object's own variants field — verified (tests :709-733).
  • Changeset: data.theme is null without a theme — verified (test :671-679).
  • Changeset: a detail, list or batch read whose recorded theme throws exits 1 with ERR_THEME_LOAD in JSON, as in text — verified (test :601-620; list and batch reads checked too).
  • Changeset: props, source, showcase and blocks reads no longer load the theme or warn — verified for text (commands/component.mjs:269-279; tests :583-600, :681-687); JSON never loaded it.
  • Changeset: a theme that cannot be found prints no warning in JSON — verified (empty standard error).
  • Description: on the base, JSON omits the values and a throwing theme exits 1 in text but 0 in JSON — verified.
  • Description: the lookup moves to the theme adapter as resolveActiveTheme, exported from the theme module but not from api/index — verified.
  • Description: the API passes no warning handler and the text passes one — verified (component/_adapter.mjs:944-964, resolve-theme.mjs:26-27).
  • Description: one merged list per component, the text label stays value* — verified.
  • Description: values stays {} for built themes until theme build emits themeVariants — verified (the seven built themes export neither field).
  • Description: the types reach the JSON entry point, and throws and the exit codes name ERR_THEME_LOAD — verified (component.type.mjs:43-58, component.doc.mjs:195-198, commands/component.doc.mjs:100).
  • Description: the red cases fail on the base — verified (they fail there with the rest of the new cases).
  • Description: component() returns the same data.theme as --json, and the text prints glass* — verified (test :689-699).
  • Description: the goldens gain "theme": null — verified.
  • Files: all 21 changed files visited; each is clear, apart from a non-blocking wording note on the gate comments in component.mjs:285-288 and commands/component.mjs:267-268.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — db31f8bb Deployed Nov 13, 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.

2 participants