Repository navigation
fix(cli): make hook detail text a projection of its JSON - #6537
Conversation
The single-hook text view looked up related block templates in the command layer and printed them, so text showed data that hook --json never returns. The text now shows only the envelope, and points to the JSON-backed component --blocks lookup for each related component.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression25 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 5 more. Generated by PR Enrichment workflow | View full report |
There was a problem hiding this comment.
This change restores the CLI invariant that human-readable output is a projection of the JSON envelope: astryx hook <name> no longer prints block templates that astryx hook <name> --json does not carry, and instead points to the existing astryx component <name> --blocks command, which returns them as JSON. The new regression test covers exactly that property — it collects the related components' block names and asserts none is shown in text unless the JSON carries it — and it passes. No envelope schema, exit code, or list/--params behavior changes.
[Automated review]
User impact
astryx hook <name>(text) printed a "Related block templates" section: foruseAnnounce, ten block templates with descriptions.astryx hook <name> --jsonreturns none of that, so an agent reading the envelope — the CLI's primary caller — could not get what a human reader saw, and the two views disagreed about what the command answers.After this change the text shows only what the
hook.detailenvelope carries. For each related component (a field the envelope already has), it points toastryx component <name> --blocks, which returns the block templates as JSON.Problem and solution fit
findRelatedBlocksfor each related component while rendering text, after the API call; the API never returned that data.--jsoncallers silently got less.--json; data that only exists in the text view is invisible to them and cannot be tested against the response contract.The fix removes the render-time lookup so the text becomes a projection of the envelope, and keeps the information reachable through the existing JSON-backed command.
Expected behavior and authority
docs/architecture/cli-surface.md(authority: current):Smallest restoration
packages/cli/clients/cli/commands/hook/index.mjs: drop the render-timefindRelatedBlocksloop and its section; whendata.relatedComponentsis non-empty, print one line naming them and thecomponent <name> --blockslookup.No change to the
hook.detailschema, exit codes, or the list and--paramsviews. Adding block templates to thehook.detailenvelope instead would be a public schema addition; that is a separate feature decision, not needed to restore the invariant.Evidence
astryx hook useAnnounceprints "Related block templates" withVisuallyHiddenLiveRegion,ToastShowcase, and eight more; none of these names appear inastryx hook useAnnounce --json.Block templates: pnpm exec astryx component <name> --blocks for VisuallyHidden, Toast(the invocation prefix follows the detected package manager); every name it shows is in the envelope.hook --list(all detail levels),hook <name> --params, andhook <name> --jsonoutput are byte-identical; the full CLI suite passes.clients/cli/commands/hook.text-projection.test.mjscollects the related components' block names and asserts none is shown in text unless the JSON carries it, and that the lookup hint is printed. With only the fix reverted both tests fail (ten block names shown in text but absent from JSON).Scope
Testing