Repository navigation
feat(cli): component reads print a short answer by default - #12291
Conversation
A component read prints what the component is, its import, a usage line, every prop as one line, its accessibility requirements, its pieces with one command that reads them all, and the commands that print the rest. The same answer is --detail compact; --detail full prints the whole doc and --json is unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approval waits on an engineering-owner decision about the new default, and five fixes are needed whatever that decision is.
No current spec clause sets which detail level astryx component <Name> prints by default, or lets the default read leave out anatomy, best practices, examples and theming: architecture:cli-surface INV4 only allows shortening a prose field to its first sentence. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, or by amending INV4 to name the component-read default and its routes; the author may record it as an engineering owner.
Fixes needed:
- The synthesized usage line prints
…(U+2026) fromcomponent-format.mjslines 599-604, which breaks INV4's plain-ASCII output and failsdoc-text-ascii.test.mjs, so use...and update the two expectations incomponent-format.test.mjs. - Two existing tests in
packages/cli/api/component/component.test.mjsnow fail: the scoped--propstest (line 447) expects the removed pointer line, and the detail-level test (line 601) compares the new default with--detail compact, which now print the same text. packages/cli/README.mdline 129 still says single-item views default tofull, so update it to say a component read defaults tocompactwhile hook and docs reads default tofull.packages/cli/clients/cli/index.mjscarries a 275-line Prettier reflow beside its one real change on line 795, although the description says unrelated cleanup was removed, so revert the reflow or move it to its own pull request.- The description says compact and brief already left out theming and examples, but on the base compact printed up to three examples and the derived theme properties and brief printed a usage example and theme variables, so correct that sentence.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims:
- A component read, and each row of a batch read, prints the short answer by default: verified (default switch in
component.mjs; Dialog, Button, Table and a two-name batch run). --detail fullprints exactly what the default printed before: verified (byte-identical for Dialog, Button and Table).--jsonis unchanged: verified (the Dialog envelope is byte-identical).--detail brief,--props,--source,--showcase,--blocksand list views are unchanged: verified (their code paths are untouched).--detail compactprints the new short answer: verified.- The
--detailhelp and thecomponentdescription say so: verified. - Usage is a short standalone example, else one element built from the required props: verified, with the non-ASCII placeholder above.
- Every prop prints on one line with its description's first sentence, and
--propsprints them whole: verified in code; the unit test's cut assertion can never fail. - Accessibility requirements and component icon slots print as before: verified for the component itself; sub-component requirements now print only under
--detail full. - The pieces get one batch command that reads them all: verified (the Dialog pieces command exits 0).
- Every part comes from fields each component doc already has: verified.
- Compact and brief already left out theming and examples: false (fix above).
- The cited spec clauses cover the new default: not settled (owner decision above).
- Before and after byte counts: verified within a few bytes, the length of the CLI invocation in each route line.
- Unrelated cleanup was removed or split: false (fix above).
- The focused vitest run passes: true for the files named; three other existing tests fail (fixes above).
- The CLI API types check passes: verified.
- Strict type checking shows no new errors: verified (the same two errors on the base and the head).
- Changeset: the short answer by default, the same answer at
--detail compact, the whole doc at--detail full, and JSON unchanged: verified.
Files:
.changeset/component-short-answer.md: clearpackages/cli/clients/cli/commands/component.doc.mjs: clearpackages/cli/clients/cli/commands/component.mjs: the new default waits on the owner decisionpackages/cli/clients/cli/commands/component.short-answer.test.mjs: clearpackages/cli/clients/cli/index.mjs: unrelated reflow (fix above)packages/cli/clients/cli/lib/component-format.mjs: non-ASCII placeholders (fix above)packages/cli/clients/cli/lib/component-format.test.mjs: expects the non-ASCII placeholder; one assertion can never fail
Plain ASCII placeholders, a last line that names --detail full, INV4 names the component-read default and its routes, docs and help describe the new default, and a test proves the JSON is the same at every detail level.
|
Owner decision (engineering owner, covering this pull request): |
|
/approve-spec 1454ddf |
There was a problem hiding this comment.
Changes requested: one sentence in the architecture:cli-surface INV4 amendment needs narrowing; the rest of the change is ready.
docs/architecture/cli-surface.md:157says "The detail level never changes the JSON", butastryx component --list --jsonandastryx hook --jsonreturn different JSON atbrief,compactandfull, so scope it to component reads, for example "The detail level never changes a component read's JSON."
The engineering-owner approval settles the new default, and the earlier fixes (ASCII placeholders, the two updated tests, the README, the removed reflow and the corrected description) are in. The fix is a new commit, so an engineering owner posts /approve-spec again for the new head. Non-blocking: the More text. assertion in component-format.test.mjs cannot fail, and the working-with-AI guide and the component() JSDoc still describe the old default.
Claims and files checked
Review mode: full; reason: spec-record
Claims:
- The default read prints the short answer (first paragraph, import, usage, one line per prop with its first sentence, accessibility, pieces with one batch command, then the
--propsand--detail fulllines): verified on Dialog, Button and Table and bycomponent.short-answer.test.mjs. --detail compactprints the same answer: verified (component.mjs:267; default and compact output are byte-identical).--detail fullprints the whole doc as before: verified, byte-identical to the base default for Dialog, Button and Table.--jsonis unchanged at every detail level, single and batch: verified against the base and bycomponent.short-answer.test.mjs:54-68.- Every part comes from existing doc fields, so an integration's component gets the same answer: verified (
component-format.mjs:621-710reads only doc fields;component.mjs:136-141builds the routes for any package). --detail brief,--props,--source,--showcase,--blocksand list views are unchanged: verified byte for byte for brief,--propsand lists; the other paths are untouched (component.mjs:176-240).- Help, the command description, the README, the getting-started and author-a-theme docs, the docs skill and the agent prompt describe the new default: verified in the diff.
- Byte counts for Dialog, Button and Table: verified within a few bytes of invocation text (3,946 to 1,881; 8,434 to 3,920; 7,935 to 4,472).
- Before this change compact printed up to three examples and derived theming, and brief a usage line and theme variables: verified in the base formatter.
- The INV4 amendment says the detail level never changes the JSON: false for list reads (blocking finding above).
- The ASCII test covers the short answer: verified, its
formatCompactrow passes. - The formatter tests cover the first paragraph, first sentences, usage, long examples, hooks and bare pieces: verified, except that the first-sentence assertion cannot fail (non-blocking).
- The agent-task results: not reproduced; they are the author's own measurement.
- Unrelated cleanup was removed: verified,
index.mjschanges one help line. - The targeted tests, the knowledge check and the type-surface check pass: verified (577 tests pass here).
- The record touched is the INV4 text and its verification row: verified.
Files:
.changeset/component-short-answer.md: clear.claude/skills/writing-component-docs.md: clearAGENTS.md: cleardocs/architecture/cli-surface.md: blocking finding (line 157)packages/cli/README.md: clearpackages/cli/api/component/component.test.mjs: clearpackages/cli/assets/docs/author-a-theme.doc.mjs: clearpackages/cli/assets/docs/getting-started.doc.mjs: clearpackages/cli/clients/cli/commands/component.doc.mjs: clearpackages/cli/clients/cli/commands/component.mjs: clearpackages/cli/clients/cli/commands/component.short-answer.test.mjs: clearpackages/cli/clients/cli/index.mjs: clearpackages/cli/clients/cli/lib/component-format.mjs: clearpackages/cli/clients/cli/lib/component-format.test.mjs: non-blocking (line 541)
…ining docs INV4 says the detail level never changes a component read's JSON. The working-with-AI guide and the component() JSDoc describe the new default, a test assertion can now fail, and the component-text and docs-topics goldens are regenerated.
|
/approve-spec 5ad6202 |
There was a problem hiding this comment.
Changes requested: the new default is owner-approved and checks out, but a few docs still promise theming output from the default component <Name> read.
- Miss: the theme template that
astryx theme templateandastryx init --features themewrite (packages/cli/assets/theme.template.ts:273-276,:293,:302),packages/cli/assets/docs/author-a-theme.doc.mjs:81andpackages/cli/api/theme/themeTargets.doc.mjs:21still sayastryx component <Name>prints theming targets and public CSS variables, which onlycomponent <Name> --detail fullprints now, so point them at--detail fullas line 79 of the author-a-theme guide already does.
The fix is a new commit, so an engineering owner posts /approve-spec <full head SHA> again for the new head. Optional follow-ups are in the review: the working-with-AI guide still offers --detail compact as a shorter component read, and components with no short example and no required props get a bare <Name /> usage line.
Claims and files checked
Review mode: full; reason: spec-record
- Claims:
- A default component read prints the short answer (what it is, import, usage, one line per prop, accessibility, pieces with one batch command, and the commands for the rest): verified (
component-format.mjs:621-709,component.short-answer.test.mjs:12-33); family docs whose props sit only under their pieces print no usage line (non-blocking). - The same answer is
--detail compact: verified (component.mjs:157-164). --detail fullprints the whole doc as before: verified (byte-identical to the base default for 14 components).--jsonis unchanged: verified (byte-identical to the base for 14 components and a batch;component.short-answer.test.mjs:54-68).- Every part comes from existing doc fields, so an integration's component gets the same answer: verified (the integration golden
component-text.txt). - Each batch row gets its own short answer: verified (
component.short-answer.test.mjs:45-50). --detail brief,--props,--source, list views and--jsonare unchanged: verified (byte-identical for Dialog, Button, Table and the list).- Help, the command description, the
component()JSDoc, README, getting-started, working-with-AI, author-a-theme, the docs skill and the agent prompt describe the new default: false in part (author-a-theme.doc.mjs:81, the blocking finding above). - Default reads shrink (Dialog about 3.9 KB to 1.9 KB, Button 8.4 KB to 3.9 KB, Table 7.9 KB to 4.5 KB): verified within 1% (the figure depends on the printed invocation).
- The CLI surface record names the component-read default, its routes and that the level never changes a component read's JSON: verified (
docs/architecture/cli-surface.md:150-157). - The new tests cover the default,
--detail full, batch rows, JSON identity, ASCII and the formatter cases: verified (they pass on the head; 8 fail on the base). - The agent study results: unverified (the author's own study, not reproduced; nothing in this review rests on it).
- Testing: the targeted test suites, the knowledge check and the published type check pass: verified (156 tests in 6 files,
pnpm check:knowledgeand the type-surface check pass on the head; CI's typecheck passes at this head).
- A default component read prints the short answer (what it is, import, usage, one line per prop, accessibility, pieces with one batch command, and the commands for the rest): verified (
- Files:
.changeset/component-short-answer.md: clear (usage-line note)..claude/skills/writing-component-docs.md: clear.AGENTS.md: clear (line 249 still offers--detail compactas less output; non-blocking).docs/architecture/cli-surface.md: clear (owner-approved at this head).packages/cli/README.md: clear.packages/cli/api/component/component.mjs: clear.packages/cli/api/component/component.test.mjs: clear.packages/cli/assets/docs/author-a-theme.doc.mjs: finding (line 81).packages/cli/assets/docs/getting-started.doc.mjs: clear.packages/cli/assets/docs/working-with-ai.doc.mjs: clear for its change (lines 168 and 175 non-blocking).packages/cli/clients/cli/commands/component.doc.mjs: clear.packages/cli/clients/cli/commands/component.mjs: clear.packages/cli/clients/cli/commands/component.short-answer.test.mjs: clear.packages/cli/clients/cli/index.mjs: clear.packages/cli/clients/cli/lib/component-format.mjs: clear (usage fallback note).packages/cli/clients/cli/lib/component-format.test.mjs: clear.packages/cli/test/__golden__/component-text.txt: clear.packages/cli/test/__golden__/no-icon-set/docs-topics.json: clear.- Unchanged but affected:
packages/cli/assets/theme.template.tsandpackages/cli/api/theme/themeTargets.doc.mjs: finding (above).
The theme template, the author-a-theme guide and the theme targets docs name component <Name> --detail full for theming targets and CSS variables, the working-with-AI guide offers --detail brief for a shorter component read, and a component with no example and no required prop prints no usage line.
|
/approve-spec 9a200e6 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The new default is owner-approved for this head, and the stale theming references from the last review now point at --detail full.
Next: CI's admission job found no room ("CI is full"), so re-run the CI jobs; the required checks still have to pass before merge.
Optional follow-ups, none blocking:
- The changeset and the INV4 text say the short answer prints "a usage line", but 50 of 174 Core component reads (Card, Table and Layout among them) print none, so "a usage line where the doc has a short demo example or required props" would match the code and the description.
- The working-with-AI guide says
--detail brief"cuts it to a one-line signature", while brief prints a signature and four or five more lines.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Claims:
- A default component read prints the short answer: description's first paragraph, import, usage, one line per prop, accessibility requirements, pieces with one batch command, and the
--propsand--detail fullcommands: verified (component-format.mjs:625-714,component.short-answer.test.mjs:12-33); a usage block prints only where the doc has a short demo example or required props (non-blocking note above). - The usage block is the first short example that runs on its own, else one element from the required props, else none; setup examples keep their label: verified (
component-format.mjs:579-608,:647-658; formatter tests). - Every prop prints name, type, default, required, experimental and its first sentence, and
--propsprints them whole: verified (Dialog default and--propsreads). - Accessibility requirements and icon slots print as before: verified (
component-format.mjs:660,:696-699). - The same answer is
--detail compact: verified (component.mjs:157-164). --detail fullprints the whole doc as before: verified (byte-identical to the base default for 9 components).--jsonis unchanged at every detail level, single and batch: verified (byte-identical to the base for 9 components;component.short-answer.test.mjs:54-68).- Each batch row gets its own short answer and routes: verified (
component.short-answer.test.mjs:45-50; batch probe). - Every part comes from existing doc fields, so an integration's component gets the same answer: verified (integration golden
component-text.txt). --detail brief,--props,--source,--showcase,--blocks, list views and--jsonare unchanged: verified (byte-identical for Dialog, Button and Card, the list andhook --json).- Before this change
--detail compactprinted up to three examples and the derived theme properties, and--detail briefa usage line and theme variables: verified (the removedformatCompactlines;formatBriefunchanged). - The CLI surface record names the component-read default, its routes and that the level never changes a component read's JSON: verified (
docs/architecture/cli-surface.md:150-157). - Help, the command description, the
component()JSDoc, README, getting-started, working-with-AI, author-a-theme, the theme targets docs, the theme template comments, the docs skill and the agent prompt describe the new default: verified (the brief sentence is a non-blocking note). - Default reads shrink (Dialog about 3.9 KB to 1.9 KB, Button 8.4 KB to 3.9 KB, Table 7.9 KB to 4.5 KB): verified within 1% (the figure depends on the printed invocation).
- The new tests cover the default,
--detail full, batch rows, JSON identity, ASCII and the formatter cases: verified (157 tests in 6 files pass on this head). - The knowledge check and the published type check pass: verified (both pass on this head).
- The agent study results: unverified (the author's own study, not reproduced; nothing here rests on it).
- A default component read prints the short answer: description's first paragraph, import, usage, one line per prop, accessibility requirements, pieces with one batch command, and the
- Files:
.changeset/component-short-answer.md: clear (usage-line note)..claude/skills/writing-component-docs.md: clear.AGENTS.md: clear (line 249 still offers--detail compactas less output; non-blocking).docs/architecture/cli-surface.md: clear (owner-approved at this head; usage-line note).packages/cli/README.md: clear.packages/cli/api/component/component.mjs: clear.packages/cli/api/component/component.test.mjs: clear.packages/cli/api/theme/themeTargets.doc.mjs: clear.packages/cli/assets/docs/author-a-theme.doc.mjs: clear.packages/cli/assets/docs/getting-started.doc.mjs: clear.packages/cli/assets/docs/working-with-ai.doc.mjs: clear (brief sentence note).packages/cli/assets/theme.template.ts: clear.packages/cli/clients/cli/commands/component.doc.mjs: clear.packages/cli/clients/cli/commands/component.mjs: clear.packages/cli/clients/cli/commands/component.short-answer.test.mjs: clear.packages/cli/clients/cli/commands/theme-targets.doc.mjs: clear.packages/cli/clients/cli/index.mjs: clear.packages/cli/clients/cli/lib/component-format.mjs: clear (usage fallback note).packages/cli/clients/cli/lib/component-format.test.mjs: clear.packages/cli/test/__golden__/component-text.txt: clear.packages/cli/test/__golden__/no-icon-set/docs-topics.json: clear.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [feat] `astryx component <Name>` prints a short answer by default: what the component is, its import, a usage line, every prop as one line (name, type, default, required, and its description's first sentence), its accessibility requirements, its pieces with one command that reads them all, and the commands that print the rest (`--props` for each prop's whole description, `--detail full` for anatomy, best practices, examples and theming). The same answer is `--detail compact`; `--detail full` prints the whole doc as before, and `--json` is unchanged. Every part comes from fields each component doc already has, so an integration's component gets the same answer. |
There was a problem hiding this comment.
Non-blocking: "a usage line" is broader than the code. With no demo example of 20 lines or fewer and no required prop, shortUsage returns null, so 50 of 174 Core component reads (Card, Table and Layout among them) print no usage block. "a usage line where the doc has a short demo example or required props" matches the code and the description; INV4's list says the same at its next amendment.
| { | ||
| type: 'prose', | ||
| text: 'For a shorter read, add `--detail brief` (one line per section) or `--detail compact`. `--dense` swaps in a shorter text where a doc ships one. Use them when pasting CLI output into a web-based AI tool like ChatGPT or Claude.', | ||
| text: 'For a shorter read, add `--detail brief` (one line per section). A component read is short by default; `--detail brief` cuts it to a one-line signature. `--dense` swaps in a shorter text where a doc ships one. Use them when pasting CLI output into a web-based AI tool like ChatGPT or Claude.', |
There was a problem hiding this comment.
Non-blocking: component Dialog --detail brief prints the signature and four more lines (description, Derived, Targets, the other props), so "a one-line signature" overstates the cut. "a short signature summary" fits.
User need
An agent that builds with Astryx runs
astryx component <Name>before it uses a component, and it reads every byte the answer prints. Today the default answer is the whole doc: anatomy, every best practice, every prop with its description, theming tables. To write the code it needs the import, how to use it, the prop names and types, and the pieces it is used with. The rest costs context on every read, and the pieces are another lookup per component.Problem and solution fit
A component read now prints a short answer by default (the
--detail compactlevel, rewritten):<Dialog isOpen={...} onOpenChange={...}>...</Dialog>), and no usage block when the component has neither; setup examples keep their label;architecture:cli-surfaceINV4's cut;--propsprints them whole);component <Name> --propsfor each prop's whole description, and as the last line the--detail fullcommand for the full output (anatomy, best practices, examples and theming).Every part comes from fields each component doc already has, so a component from an integration gets the same answer with no extra authoring.
Current specification
architecture:cli-surfaceINV4: text is a projection of the JSON; a shortened field keeps a route (--detail full,--props, and--jsoncarry every field). INV5 unchanged.spec:AST-017DEC-4 and FR13:--jsonis unchanged at every detail level, and--detail fullremains the text projection of every field. Before this change--detail compactprinted up to three examples and the derived theme properties, and--detail briefprinted a usage example and theme variables; the new compact level prints a usage line and names--detail fullfor the rest.architecture:cli-surfaceINV4 to name the component-read default (compact), its routes (--props,--detail full) and that the detail level never changes a component read's JSON (list and hook JSON keep their levels).docs/contributing/cli-conventions.md, "Output: keep answers short": the change names its routes and is tested with agents.Public delta and caller burden
astryx component <Name>(and of each row of a batch read) is the short answer.--detail fullprints exactly what the default printed before.--detail brief,--props,--source,--showcase,--blocks, list views and--jsonare unchanged.--detail compactprints the new short answer.--detail, thecomponentcommand description, thecomponent()API JSDoc, the CLI README's global options, the getting-started, working-with-AI and author-a-theme docs, thethemeTargets()andtheme targetsdocs, the theme template's comments (they namecomponent <Name> --detail fullas the theming reference), the component-docs skill and the repository agent prompt say so. The component-text and docs-topics goldens are regenerated.Before (default,
component Dialog): 3,956 bytes. After: 1,876 bytes. Button 8,439 → 3,915. Table 7,945 → 4,467.Design and alternatives
--detailis a global option shared with docs reads, andcompactalready meant "the component read with less".Evidence
component.short-answer.test.mjs: the default read prints the short answer and ends with the--detail fullline;--detail fullprints the whole doc; a batch gives each row its routes;--jsonis the same bytes at every detail level (single and batch) and keeps every field.doc-text-ascii.test.mjs: the short answer is plain ASCII.component-format.test.mjs: first paragraph only, each prop with its first sentence, usage from a short example or from required props, long examples skipped, hooks print no usage, bare pieces in one batch command.--detail fullor--propsfor the fact, as the answer tells them.Scope
Components: none (CLI
componentcommand text output only)Testing
pnpm exec vitest run --project node packages/cli/clients/cli/commands/component packages/cli/clients/cli/lib packages/cli/api/component packages/cli/test/docs-graph.test.mjs packages/cli/assets/docs(1,110 tests; 6 slow files that timed out under box load pass when re-run alone)pnpm check:knowledge(records aligned)node .github/scripts/cli-api-types-verify.mjs(passed)tsc --project tsconfig.strict.jsonin packages/cli: no new errors (2 existing errors on main from an unbuilt theme package on the test box)Writing rubric results
Record touched:
architecture:cli-surface(INV4 text and its verification row).R1 narration: none; the added sentences state what a component read prints, in the present tense.
R2 research: none in the record; the agent-check results stay in this description.
R3 evidence: the verification row names the test file, not a change.
R4 rejected alternatives: none in the record.
R5 change references: none.
R6 open questions: none.
R7 project status: none.