Skip to content

fix(cli): component docs print their commands with the project's runner in text - #12212

Merged
josephfarina merged 3 commits into
mainfrom
josephfarina/command-token-runner
Nov 17, 2026
Merged

josephfarina merged 3 commits into
mainfrom
josephfarina/command-token-runner

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A component doc can write a command with a doc token, {@command docs icons}, or link to a doc with {@link …}. astryx docs shows such a command the way the project runs the CLI, for example pnpm exec astryx docs icons or the command an integration declares. astryx component and astryx discover <package>/<Component> printed it as a bare astryx docs icons, which does not run in a project where the CLI is only reachable through the package manager. An agent that copies the command gets "command not found" and has to guess the runner.

Problem and solution fit

  • Why it happens: doc tokens render to the bare astryx … command on purpose, so JSON readers get one runnable form. Text output then puts the project's command in front. astryx docs does that step (prefixCliCommands); the component text formatters print the rendered Markdown without it.
  • Why it matters: every command the CLI prints must start with the command the picker chooses for the folder. A bare astryx is right only where the global copy answers.
  • Fix: code() blocks marked lang: 'markdown' are doc text. emit shows the bare astryx commands in them with the project's command, through the same prefixCliCommands that astryx docs uses. The component detail (all detail levels), --props, the brief list, and discover's component detail print as Markdown blocks. Any other code() block, such as a template's source or a skeleton, still prints byte for byte, and prose blocks are unchanged.

Expected behavior and authority

  • spec:AST-081 FR5: every command the CLI prints for its caller to run starts with the command name the picker chooses.
  • packages/cli/clients/cli/commands/docs.mjs header: docs write commands as bare astryx …; text output prefixes them with the project's invocation, and JSON keeps them bare.

Smallest restoration

  • packages/cli/clients/cli/formatters/index.mjs: a Block knows whether it is doc Markdown; code(source, {lang: 'markdown'}) marks it; emit prefixes only those blocks.
  • component.mjs and discover.mjs mark their component Markdown.
  • No JSON change, no new option, no change to prose blocks or verbatim blocks.

Evidence

  • Reproduction before the change: a component doc whose description writes {@command docs icons}, in a project whose integration declares cliCommand: 'acme astryx'. astryx component AcmeCard (full, compact, brief) printed `astryx docs icons`.
  • Result after the change: the same reads print `acme astryx docs icons`; --props does too for a prop description.
  • A bare command a Core doc writes by hand behaves the same: through a host door host astryx, astryx component CheckboxInput --props prints "See `host astryx docs icons`" (it printed `astryx docs icons`).
  • Representative unchanged path: --json still carries `astryx docs icons`; astryx template acme-board prints the template's source with its `astryx docs icons` comment as written.
  • Regression test: packages/cli/clients/cli/commands/command-tokens.text.test.mjs (fails on the base for the three detail levels, passes here). api/component/doc-links.test.mjs now expects the text read to show the runner and no longer the bare command (that assertion fails on the base).

Scope

Components: CLI text formatters, astryx component, astryx discover

  • 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.

Out of scope, same family: template docs do not render doc tokens at all yet (a {@command …} in a template's description prints as written in astryx template, build, and search), and astryx search / astryx build text print component and template descriptions as their JSON does. Both need their own change.

Testing

  • pnpm exec vitest run --project node packages/cli
  • pnpm check:repo; ESLint and Prettier on the changed files.

…er in text

A component doc's {@command} tokens and {@link} targets render to the bare
astryx command, which astryx docs shows with the project's command in text.
astryx component and discover's component detail printed it bare. Markdown
code blocks now carry their kind, and emit shows their commands with the
project's command through the same prefixCliCommands docs uses; JSON keeps
the bare command, and verbatim blocks keep their bytes.
@vercel

vercel Bot commented Nov 17, 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 Nov 17, 2026 3:23am UTC

Request Review

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

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 3:53 AM UTC

@josephfarina

Copy link
Copy Markdown
Contributor Author

Closing in favor of #12211, which fixes the same thing through one helper (showDocText). The discover <package>/<Component> detail and template docs in build and search will follow on top of #12211 with that same helper.

@josephfarina

Copy link
Copy Markdown
Contributor Author

Reopened: #12211 was closed in favor of this one, so this is the one change for component and discover doc text. Template docs in template, build and search follow on top of it.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 82d826e

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.23 MB packed (+345 B); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


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.

Requesting changes: the fix restores the project's command in component and discover doc text and keeps --json bare, but one claim in the description does not hold.

  • packages/cli/api/component/doc-links.test.mjs:201 also matches the bare `astryx docs acme-setup` and passes against main, so the test does not "expect the text read to show the runner" as the description says; add expect(text.stdout).not.toContain('`astryx docs acme-setup`'); after it (that fails on main and passes here) or drop the claim.

CI's test jobs did not run on this head because the run was refused for capacity, so re-run all jobs with the next push.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: astryx docs already shows doc commands with the project's command through the shared prefix helper: verified.
  • Claim: astryx component and astryx discover <package>/<Component> printed doc commands bare: verified on main.
  • Claim: Markdown-marked code blocks are doc text and emit prefixes only those: verified (formatters/index.mjs).
  • Claim: component detail at every level, --props, the full list and discover's component detail print as Markdown blocks: verified.
  • Claim: {@command …} tokens, {@link …} targets and bare astryx code spans all get the project's command in text: verified by the new tests and a stricter {@link} check.
  • Claim: --json keeps the bare command: verified (test).
  • Claim: template source, skeletons and other verbatim blocks print as written: verified (test; no marker on those blocks).
  • Claim: a Core prop doc's bare command shows the host door's command: verified (test fails on main, passes here).
  • Claim: the new regression test fails on main for the three detail levels: verified.
  • Claim: doc-links.test.mjs now expects the text read to show the runner: false (its assertion also matches the bare command).
  • Claim: template descriptions still print doc tokens as written (out of scope): verified.
  • Claim: the CLI tests, ESLint and Prettier pass: verified, apart from three environment-bound test files that fail the same way on main.
  • File: .changeset/component-doc-commands-runner.md: clear.
  • File: packages/cli/clients/cli/formatters/index.mjs: clear.
  • File: packages/cli/clients/cli/commands/component.mjs: clear.
  • File: packages/cli/clients/cli/commands/discover.mjs: clear.
  • File: packages/cli/clients/cli/commands/command-tokens.text.test.mjs: clear.
  • File: packages/cli/api/component/doc-links.test.mjs: finding above.

Automated review (maintainer link)

@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.

Approved pending CI: CI has not finished on this head yet.

The earlier finding is fixed: the component-links test now also checks that text no longer prints the bare astryx docs acme-setup, and that check fails against main. Component and discover <package>/<Component> doc text now print commands with the project's command, and --json keeps them bare.

Two optional follow-ups: a picked command name that itself starts with astryx is applied twice to commands the formatter already picked (no conforming door has such a name), and one assertion on discover <package>/<Component> in command-tokens.text.test.mjs would pin that path.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules since the last review: changed rules (0): none.
  • Claim: astryx docs already shows doc commands with the project's command through the shared prefix helper: verified.
  • Claim: astryx component and astryx discover <package>/<Component> printed doc commands bare: verified on main.
  • Claim: doc tokens render bare so JSON carries one form, and text puts the project's command in front: verified.
  • Claim: every printed command must start with the command the picker chooses: verified against the global-mode spec.
  • Claim: Markdown-marked code blocks are doc text and emit prefixes only those: verified (formatters/index.mjs).
  • Claim: component detail at every level, --props, the brief-entry list and discover's component detail print as Markdown blocks: verified.
  • Claim: template source, skeletons and other verbatim blocks print as written, and prose blocks are unchanged: verified (test; no marker on those blocks).
  • Claim: the docs command's header states the bare-in-docs, prefixed-in-text rule: verified.
  • Claim: no JSON change and no new option: verified.
  • Claim: with an integration command, full, compact, brief and --props printed the bare command and now print the integration's command: verified (tests fail on main, pass here).
  • Claim: a Core prop doc's bare command shows the host door's command: verified (test fails on main, passes here).
  • Claim: --json keeps the bare command and astryx template keeps the source comment: verified (tests).
  • Claim: the new regression test fails on main for the three detail levels: verified.
  • Claim: the component-links test now expects the runner and no longer the bare command, and that assertion fails on main: verified.
  • Claim: one defect, no tag-alongs, no new public API, no internal context: verified.
  • Claim: template docs and search/build text are out of scope and unchanged: verified.
  • Claim: the CLI tests, the repository checks, ESLint and Prettier pass: verified, apart from three environment-bound test files that fail the same way on main.
  • Claim (release note): component and discover doc commands print with the project's command, --json stays bare: verified.
  • File: .changeset/component-doc-commands-runner.md: clear.
  • File: packages/cli/clients/cli/formatters/index.mjs: clear (optional follow-up above).
  • File: packages/cli/clients/cli/commands/component.mjs: clear.
  • File: packages/cli/clients/cli/commands/discover.mjs: clear (optional follow-up above).
  • File: packages/cli/clients/cli/commands/command-tokens.text.test.mjs: clear.
  • File: packages/cli/api/component/doc-links.test.mjs: clear (earlier finding fixed).

Automated review (maintainer link)

@josephfarina
josephfarina merged commit 2fb7c5b into main Nov 17, 2026
78 checks passed
@github-actions
github-actions Bot deleted the josephfarina/command-token-runner branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 82d826e3 Deployed Nov 17, 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