Skip to content

fix(cli): make hook detail text a projection of its JSON - #6537

Merged
josephfarina merged 1 commit into
mainfrom
cli-spec/lifecycle/hook-text-projection
Sep 24, 2026
Merged

josephfarina merged 1 commit into
mainfrom
cli-spec/lifecycle/hook-text-projection

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User impact

astryx hook <name> (text) printed a "Related block templates" section: for useAnnounce, ten block templates with descriptions. astryx hook <name> --json returns 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.detail envelope carries. For each related component (a field the envelope already has), it points to astryx component <name> --blocks, which returns the block templates as JSON.

Problem and solution fit

  • Why does it occur? The command handler called findRelatedBlocks for each related component while rendering text, after the API call; the API never returned that data.
  • Why does it harm the task? Text and JSON are supposed to be two views of one answer. Here the text was the richer one, so --json callers silently got less.
  • Why does that matter? Agents branch on --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):

  • INV4: "Human output is a projection of the JSON, produced only by the formatters."
  • System model, Work: "The command is a thin wrapper: parse, call, render."

Smallest restoration

  • packages/cli/clients/cli/commands/hook/index.mjs: drop the render-time findRelatedBlocks loop and its section; when data.relatedComponents is non-empty, print one line naming them and the component <name> --blocks lookup.

No change to the hook.detail schema, exit codes, or the list and --params views. Adding block templates to the hook.detail envelope instead would be a public schema addition; that is a separate feature decision, not needed to restore the invariant.

Evidence

  • Reproduction before the change: astryx hook useAnnounce prints "Related block templates" with VisuallyHiddenLiveRegion, ToastShowcase, and eight more; none of these names appear in astryx hook useAnnounce --json.
  • Result after the change: the text ends with 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.
  • Representative unchanged path: hook --list (all detail levels), hook <name> --params, and hook <name> --json output are byte-identical; the full CLI suite passes.
  • Regression test or other mutation-sensitive proof: clients/cli/commands/hook.text-projection.test.mjs collects 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

  • 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/hook/index.mjs packages/cli/clients/cli/commands/hook.text-projection.test.mjs
pnpm check:repo
pnpm exec vitest run packages/cli   # 271 files passed, 1 skipped; 4300 tests passed

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.
@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:36am 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, 8:26 AM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Preview availability: Storybook and Sandbox were not published for this CI run.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

25 of 420 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Chat Full AI Chat probe light 42,708
Chat Empty State probe light 42,708
Chat Full AI Chat probe dark 41,786
Chat Empty State probe dark 41,786
Slider Default probe light 15,617
Slider Default probe dark 15,615
Chat With Attachments probe light 12,964
Chat With Attachments probe dark 12,114
InputGroup With Typeahead probe light 11,012
InputGroup With Typeahead probe dark 9,189
ComplexSelector Tree list with search probe light 6,245
TextArea Vertical Form Alignment probe light 5,634
ComplexSelector Tree list with search probe dark 5,602
TextArea Vertical Form Alignment probe dark 5,047
ComplexSelector Fruit ripeness selector neutral light 4,007
ComplexSelector Fruit ripeness selector neutral dark 3,825
ToggleButton Group Single probe dark 1,538
ToggleButton Group Single probe light 1,538
MediaTheme On Dark neutral dark 838
Banner Collapsible Content (Expanded) probe dark 92

and 5 more.


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.

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]

@josephfarina
josephfarina marked this pull request as ready for review September 24, 2026 20:39
@josephfarina
josephfarina merged commit 97dcfe6 into main Sep 24, 2026
38 checks passed
@github-actions
github-actions Bot deleted the cli-spec/lifecycle/hook-text-projection branch September 25, 2026 06:23

This branch was successfully deployed

1 active deployment
Preview — 43e54e2e 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