Skip to content

fix(cli): keep component detail text a projection of its JSON - #6574

Merged
josephfarina merged 1 commit into
mainfrom
cli-spec/component-swizzle/component-detail-related-blocks
Sep 24, 2026
Merged

josephfarina merged 1 commit into
mainfrom
cli-spec/component-swizzle/component-detail-related-blocks

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User impact

Anyone who reads astryx component <Name> as text, and any agent that compares the text with astryx component <Name> --json. The text view printed a "Related block templates" section: a dirName/description record for every block that uses the component (about 20 for Button). The --json envelope has no such field. So the two views of one command disagreed, and the text held data a machine caller cannot get from that call. After this change the text shows only what the envelope holds. The block list stays one flag away: astryx component <Name> --blocks returns it in both text and JSON.

Problem and solution fit

  • Why does it happen? The command's text branch called findRelatedBlocks() on its own, after the API returned, and rendered the result. The API result never contained it.
  • Why does it hurt the task? The CLI treats --json as the source of truth and the text as a view of it. A section that exists only in text drifts from the JSON, and agents that read JSON never learn it exists. It also made text mode do extra block discovery that JSON mode skips, so the two modes did different work.
  • Why does it matter? Callers rely on the rule that the text is a projection of the envelope and that field names match between the views. That rule is what keeps the views from drifting.

The fix removes the text-only lookup and its section. The same data stays reachable through the existing --blocks view, which returns it in the envelope.

Expected behavior and authority

docs/architecture/cli-surface.md (current):

INV4 — Human output is a projection of the JSON, produced only by the formatters.

INV5 — Text field names mirror JSON keys one to one. The two views cannot drift, and every field stays greppable.

(dirName is not a key anywhere in the component.detail envelope.)

Compatibility (spec:AST-017 FR3, FR5): the --json schema does not change. Only text that the envelope never carried is removed.

Smallest restoration

clients/cli/commands/component/index.mjs: the component.detail text branch emits the formatted doc and nothing else, and the unused findRelatedBlocks import goes. The --blocks view, the other detail levels and every JSON path are untouched.

Evidence

  • Reproduction before the change: astryx component Button prints Related block templates and records such as dirName: AppShellMobileHookUsage. astryx --json component Button contains no dirName and no related-block field.
  • Result after the change: the text ends with the component's doc. astryx component Button --blocks still lists the showcase, examples and related blocks.
  • Representative unchanged path: --detail brief|compact|full text for a component, --props, --source, --showcase, --blocks, and every --json envelope.
  • Regression test: clients/cli/commands/component.test.mjs > "component text output" checks that the JSON has no related-block data and that the text has no dirName: records and no related-blocks heading. It fails on main and passes with the fix. Reverting only component/index.mjs turns it red again.

Scope

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

Testing

pnpm -F @astryxdesign/cli exec tsc --project tsconfig.api-dts.json
pnpm check:cli-structure
pnpm -F @astryxdesign/cli readme:check
pnpm -F @astryxdesign/cli typecheck:json-api
pnpm -F @astryxdesign/cli typecheck:strict
ASTRYX_STRICT_LINT=1 pnpm exec eslint packages/cli/clients/cli/commands/component/index.mjs packages/cli/clients/cli/commands/component.test.mjs
pnpm check:repo
pnpm exec vitest run packages/cli    # 4299 passed, 5 skipped

The text view of `component <Name>` appended related block templates that the
command looked up on its own, so the text showed data the --json envelope
never carried. The list stays available through --blocks.
@vercel

vercel Bot commented Sep 24, 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 Sep 24, 2026 7:55am UTC

Request Review

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

astracat-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Sep 24, 2026, 10:07 AM UTC

@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 recommended for this focused CLI fix.

astryx component <Name> text output no longer prints the "Related block templates" records that the --json envelope never carried, which restores the documented rule that human output is a projection of the JSON and that text field names mirror JSON keys. The JSON output, other views, and the existing --blocks view — which still returns the block list in both text and JSON — are unchanged, so this is a contract-restoring, nonbreaking change with a patch Changeset.

The added regression test covers both sides: the JSON contains no related-block records and the text contains no dirName: records or related-blocks heading. One note for transparency: the test suite results reported in the PR were not independently rerun in this review, though the code, the --blocks preservation path, and the test assertions were inspected directly.

[Automated review]

github-actions Bot added a commit that referenced this pull request Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run completed, but its trusted analysis is unavailable.

The exact-head preview is not available yet.


Generated by PR Enrichment workflow | View current CI run

@josephfarina
josephfarina marked this pull request as ready for review September 24, 2026 20:45
@josephfarina
josephfarina merged commit 8fcc7d1 into main Sep 24, 2026
56 of 58 checks passed
@github-actions
github-actions Bot deleted the cli-spec/component-swizzle/component-detail-related-blocks branch September 25, 2026 06:23

This branch was successfully deployed

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant