Repository navigation
feat(cli): astryx --json component and component() carry the theme values the text output prints - #11510
feat(cli): astryx --json component and component() carry the theme values the text output prints#11510cixzhang wants to merge 6 commits into
Conversation
…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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec a32fa41 |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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 incommands/component.mjsloads the theme for every read; gate that lookup to detail and list reads or narrow the claim. component()can now reject withERR_THEME_LOAD, but neither itsthrowslist inapi/component/component.doc.mjsnor the command'sexitCodesnames that failure.ComponentListReadandComponentDetailReadincomponent.type.mjsbecome public types of@astryxdesign/cli/apiand@astryxdesign/cli/jsonthrough theexport *barrels, so move them besideComponentReadincomponent.mjs.- Miss:
componentThemeinapi/component/_adapter.mjscopies the command's theme-load error formatting, so the error text now has two owners; throwERR_THEME_LOADonce fromresolveActiveThemeor one shared helper and delete the copy incommands/component.mjs. - The description cites a theme-authoring-contract INV18 that does not exist, places the lookup in
api/theme/_active-theme.mjsinstead ofapi/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()returndata.themeon 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.themeisnullwithout a theme andvaluesstays empty until a built module exportsthemeVariants: verified. - Claim: a recorded theme that fails to load now exits 1 with
ERR_THEME_LOADin 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 inapi/theme/_adapter.mjsand stays internal). - Claim: a JSON read prints nothing on standard error: verified.
- Claim: values come from
themeVariantsby 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
ComponentThemeandComponentThemeField, and the response types carrytheme: 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": nulland 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:throwslacksERR_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 exportsthemeVariants. - 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.
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]>
There was a problem hiding this comment.
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-compilationINV18 under current specification, but that record ends at INV17 on main, so please move that line out and say thevaluesshape waits on the owner decision.
Non-blocking
- The package-field lookup no longer reads a
variantsfield on the theme object (a hand-written theme withvariantsloses its*marks), so please say so in the changeset and drop the "byte-for-byte" wording inpackages/cli/api/theme/_adapter.mjs.
Claims and files checked
Claims (changeset and description):
- JSON and
component()returndata.themeon 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.themeisnullwithout a theme andvaluesstays empty until a built module exportsthemeVariants: 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_LOADin 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.mjsand 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).
ComponentThemeandComponentThemeFieldreach the JSON types; the response types carrytheme: verified (generated declarations).component()'sthrowsand 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:changesetsandcheck:cli-structure;typecheck:strictshows only two unrelated template errors from an unbuilt theme package here.
Files:
.changeset/cli-component-json-theme.md: non-blocking (does not mention the droppedvariantsread).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,variantsmarker).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.
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]>
There was a problem hiding this comment.
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 describecomponent.listandcomponent.detailwithouttheme, so please name the field and itsnullcase there and add it to thecomponent.detailfield list inresponse-types.doc.test.mjs. - Miss:
extractVariantsinpackages/cli/api/theme/_adapter.mjspasses anythemeVariantsobject into JSON, so an export such as{button: ['glass']}shows up indata.theme.valueswhile the text marks nothing and the publishedstring[]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()returndata.themeon 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.themeisnullwithout a theme, andvaluesstays empty until a theme module exportsthemeVariants: 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_LOADin 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
variantsfield 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.mjsand 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
themeVariantsis proposed in #5103, not current: verified (the theme-compilation record ends at INV17 on main). ComponentThemeandComponentThemeFieldreach the JSON types and the response types carrytheme: verified (component.type.mjs:43-56,:136).component()'sthrowsand 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:changesetsandcheck:cli-structure;typecheck:strictshows 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 uncheckedthemeVariantsmap asvalues).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 (extractVariantsaccepts 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.
… 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]>
|
/approve-spec 439070e |
There was a problem hiding this comment.
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), thecomponentcommand doc (packages/cli/clients/cli/commands/component.doc.mjs:27-29) andcomponentTheme's JSDoc (packages/cli/api/component/_adapter.mjs:935-936) still saydata.themelists 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, thecomponent.listandcomponent.detailentries that generate the README response table) and thereturnsentries for those types incomponent.doc.mjsstill do not namethemeor itsnullcase, whichspec:AST-017DEC-4's complete-documentation rule requires, so please add it there and to thecomponent.detailfield list inresponse-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
themeVariantsnow 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 inresolve-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
themeVariantsand the theme object'svariants— verified (theme/_adapter.mjs:1595-1632; tests atresolve-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, headglass* jumbo*). - Claim: a throwing recorded theme makes detail, list and batch reads exit 1 with
ERR_THEME_LOADin 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_LOADis named incomponent()'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.mjscases fail with the head's tests on the base). - Claim: goldens gain
"theme": null— verified. - Claim: the named suites,
typecheck:json-api,readme:checkandcheck:changesetspass — verified (15 files, 650 tests);typecheck:strictreports 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";returnsentries omittheme.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.
…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]>
|
/approve-spec db31f8b |
There was a problem hiding this comment.
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 inresolve-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 capitalisedButton. - Changeset: the list merges a built module's
themeVariantsexport and the theme object's ownvariantsfield — verified (tests:709-733). - Changeset:
data.themeisnullwithout a theme — verified (test:671-679). - Changeset: a detail, list or batch read whose recorded theme throws exits 1 with
ERR_THEME_LOADin 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 fromapi/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:
valuesstays{}for built themes until theme build emitsthemeVariants— verified (the seven built themes export neither field). - Description: the types reach the JSON entry point, and
throwsand the exit codes nameERR_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 samedata.themeas--json, and the text printsglass*— 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-288andcommands/component.mjs:267-268.
User need
An agent or script that reads
astryx --json component Bannercannot see the custom values the configured theme adds, while the text view ofastryx component Bannermarks them with*once a built theme exports them (#5103 makesastryx theme buildemit them). The two views must carry the same facts (architecture:cli-surfaceINV4, INV5), andcomponent()from@astryxdesign/cli/apimust return what--jsonprints (spec:AST-042FR1). 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()addsdata.themeto 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*.resolveActiveThemeinapi/theme/_adapter.mjs, re-exported byapi/theme/theme.mjs(not byapi/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.themeVariantsexport (across its props) and the theme object's ownvariantsfield, which it already read. The text view prints that list asvalue*, as onmain. ThethemeVariantsread 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.ERR_THEME_LOADand 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-surfaceINV4, INV5: text is a projection of the JSON, and text field names mirror JSON keys. INV7: theCommandDocnames the new field. INV8: the same condition exits the same way with and without--json. INV12: no chatter in JSON mode.spec:AST-042FR1: the API and the CLI's JSON return the same result.spec:AST-017DEC-4: a new response field ships with its type, contract tests and docs.valuesmirrors the text field for field: one list per component, the list the text marks with*(INV4, INV5). A per-prop shape, withprop: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.themeis{name, values}ornullwhen no theme is configured or the configured theme is not found.valueslists each component's custom values; it stays{}for a built theme untilastryx theme buildemitsthemeVariants(fix(cli): expose built theme variants in component docs #5103).--props,--source,--showcaseand--blocksresults do not change and do not load the theme.ComponentThemeandComponentThemeFieldin@astryxdesign/cli/json;ComponentDetailResponseandComponentListResponsecarrytheme.value*. A theme whose built module exportsthemeVariantsnow gets those values marked, wheremainmarked none, because the lookup reads that export as well as the theme object'svariantsfield.ERR_THEME_LOADin JSON, as it already did in text;component()'sthrowslist 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, withdata.theme: null.Design and alternatives
component()returns breaksspec:AST-042FR1, because the API and the JSON then differ.valuestakes 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
resolve-theme.test.mjsfailed on main:data.themeon detail, list and batch rows,nullfor broken and missing themes, the name for working themes, and JSON exit 1 for a theme that throws.component()returns the samedata.themeasastryx --json component, and the text view printsglass*for the same project.theme, print no theme warning in text or JSON, and answer with exit 0 in both views when the recorded theme throws.component.jsonandcomponent-zh.jsongain"theme": null.Scope
Components: cli (component command, component API, theme lookup)
Testing
vitest run --project nodeonresolve-theme,component-format,doc-loads,text-json-parity,api/componentandgolden-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-readsandexperimental-isolationthen pass (101 tests).pnpm -F @astryxdesign/cli typecheck:strictandtypecheck:json-api: no errors.pnpm -F @astryxdesign/cli sync:api-types,readme:check,pnpm check:changesetsandpnpm check:repo(the CLI structure checks INV21–INV23 included) pass.api/theme-editlock, 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