Skip to content

fix(cli): template docs never print a raw {@command} or {@pm} token; build and search text show doc commands with the project's command - #12214

Merged
josephfarina merged 4 commits into
mainfrom
josephfarina/template-doc-tokens
Nov 17, 2026
Merged

josephfarina merged 4 commits into
mainfrom
josephfarina/template-doc-tokens

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A template's doc can write a command with a doc token, {@command docs icons} or {@pm …}, the same way a component's or a topic's doc does. astryx template --list, astryx template <name> --skeleton, astryx build, astryx search and astryx component <Name> --blocks printed that token as written, in text and in --json, so a reader saw {@command docs icons} instead of a command, and an agent could not run it. build and search text also printed every description's commands bare, which does not run where the CLI is reached through the package manager.

Problem and solution fit

  • Why it happens: component docs and topics render their tokens when the API reads them; template docs never did. build and search text print descriptions as their JSON carries them.
  • Why it matters: every command the CLI prints must start with the command the picker chooses, and JSON readers must get the bare command, never token syntax.
  • Fix:
    • The template, build and search APIs render a template description's tokens (renderTokens), so --json carries the bare astryx … command. The JSON shape does not change.
    • docText (formatters) shows a doc text field's bare commands with the project's command, by the same prefixCliCommands rule that emit applies to doc Markdown. template --list, --skeleton, build (with and without --verbose) and search text use it for descriptions.
    • template() and build() render a {@pm} step for the project their cwd names, as search() does (runWithDocPackageManager), so one answer never mixes package managers.
    • Template discovery still keeps the authored text, so a docs link to a template renders its summary once, and an escaped token stays written.
    • A template's source prints byte for byte.

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

  • api/template/{list,show,skeleton}, api/build/_adapter.mjs, api/search/_gather-templates.mjs: render the description's tokens.
  • formatters/index.mjs: docText.
  • template.mjs, build.mjs, search.mjs: text descriptions through docText.
  • No new option and no JSON shape change.

Evidence

  • Reproduction before the change (in a project whose integration declares cliCommand: 'acme astryx' and ships a template whose description writes {@command docs icons}): the four surfaces printed {@command docs icons} in text and JSON.
  • Result after the change: text prints `acme astryx docs icons`; JSON prints `astryx docs icons`; no output contains {@command.
  • Representative unchanged path: astryx template <name> prints the template's source, including a `astryx docs icons` comment, byte for byte, in text and in data.source.
  • Regression test: packages/cli/clients/cli/commands/template-doc-tokens.test.mjs (8 cases; 7 fail on the base, and the template-source case passes on both). It covers template list and skeleton, build with and without --verbose, search, component --blocks, and template() / build() called with a Yarn project's cwd from a pnpm folder. search.test.mjs's field-mirror test now expects a description's commands with the project's command in text.

Scope

Not in this change: a {@link …} in a template's description still prints as written in template, build and search. Resolving it needs the docs catalog on those paths, which is its own change.

Components: CLI template, build, search, component --blocks, text formatters

  • 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 exec vitest run --project node packages/cli
  • pnpm check:repo, pnpm -F @astryxdesign/cli typecheck:strict, ESLint and Prettier on the changed files.

@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 5:07am 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, 5:18 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.

Changes requested: template doc tokens now render on every surface the new test covers, but one text view still prints a bare command, and the title promises more than the fix does.

  • astryx build <query> --verbose prints the chosen TEMPLATE's description without docText (packages/cli/clients/cli/commands/build.mjs:274), so a project whose integration declares its own CLI command still sees a bare `astryx …` command there; add description: docText to that record and a --verbose case to template-doc-tokens.test.mjs.
  • The title says template docs "never print a raw doc token", but a {@link …} token in a template description still prints as written in template, build and search; narrow the title to the {@command} and {@pm} tokens the changeset names, or resolve links in those views too.

The rest checks out: JSON stays bare with an unchanged shape, a template's source still prints byte for byte, and the new test fails on the base as described.

Claims and files checked

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

  • Claim: a template doc's command and package-manager tokens no longer print as written in template list, skeleton, build and search. Verified: the new test, and a package-manager token checked on each surface.
  • Claim: text shows those commands with the project's command, as the docs command does. Verified for template list, skeleton, plain build and search; false for build --verbose (build.mjs:274).
  • Claim: JSON carries the bare astryx … command and keeps its shape. Verified: the test's JSON assertions; the diff changes values only.
  • Claim: build and search text show every description's commands with the project's command. Verified for search (search.test.mjs); false for build --verbose (build.mjs:274).
  • Claim: a template's source still prints byte for byte. Verified: the source case passes on base and head.
  • Claim: before the change, the four surfaces printed the raw token in text and JSON. Verified: 4 of the new test's 5 cases fail on the base.
  • Claim: component docs and topics already render their tokens, and template docs did not. Verified in the docs adapter and the base template APIs.
  • Claim: template discovery keeps the authored text, so a docs link to a template renders its summary once and an escaped token stays written. Verified: discovery is unchanged and the docs adapter renders a linked template's summary once.
  • Claim: no new option and no JSON shape change. Verified: no command doc changes.
  • Claim: every printed command starts with the picked command and JSON stays bare (the global-mode spec, FR5, and the docs command's header). Verified against both.
  • Claim: the new test fails 4 of 5 cases on the base and the source case passes on both. Verified by running it on the base.
  • Claim: the search field-mirror test now expects prefixed commands in text. Verified: it passes on the head.
  • Claim: the listed test, lint and format commands pass. The template, build, search, API and formatter suites pass on the head; ESLint is clean on the changed files; Prettier differs only on an unchanged search.mjs line that fails on the base too.
  • Claim (title): template docs never print a raw doc token. False: a {@link …} token still prints as written.
  • File .changeset/template-doc-tokens.md: finding (its build claim is false under --verbose).
  • File packages/cli/api/build/_adapter.mjs: clear.
  • File packages/cli/api/search/_gather-templates.mjs: clear.
  • File packages/cli/api/template/list/list.mjs: clear.
  • File packages/cli/api/template/show/show.mjs: clear.
  • File packages/cli/api/template/skeleton/skeleton.mjs: clear.
  • File packages/cli/clients/cli/commands/build.mjs: finding (verbose TEMPLATE record, line 274).
  • File packages/cli/clients/cli/commands/search.mjs: clear.
  • File packages/cli/clients/cli/commands/search.test.mjs: clear.
  • File packages/cli/clients/cli/commands/template-doc-tokens.test.mjs: clear (the verbose build case belongs with the build fix).
  • File packages/cli/clients/cli/commands/template.mjs: clear.
  • File packages/cli/clients/cli/formatters/index.mjs: clear.

Automated review (maintainer link)

@josephfarina josephfarina changed the title fix(cli): template docs never print a raw doc token; build and search text show doc commands with the project's command fix(cli): template docs never print a raw {@command} or {@pm} token; build and search text show doc commands with the project's command Nov 17, 2026

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

Changes requested: the build --verbose record and the {@link} title claim from the last review are fixed, and template tokens now render in template, build and search, but the title's guarantee still reaches one command this change does not cover.

  • Miss: the title says template docs "never print a raw {@command} or {@pm} token", but astryx component <Name> --blocks still prints a block template's description as written, raw token included, in text and --json (packages/cli/api/component/detail/blocks/blocks.mjs:29, packages/cli/clients/cli/commands/component.mjs:200 and :212); name the commands in the title, or render that description with renderTokens, format those two records with docText, and add a component --blocks case to template-doc-tokens.test.mjs.

The rest checks out: JSON keeps its shape and carries bare commands, a template's source prints byte for byte, and the new test fails 4 of its 5 cases on the base and its new --verbose case on the previous revision.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Claim (title): template docs never print a raw command or package-manager token. False: astryx component <Name> --blocks prints one (blocks.mjs:29, component.mjs:200, :212).
  • Claim (title): build and search text show doc commands with the project's command. Verified: build.mjs:216, :225-226, :274; search.mjs:198-199; a probe of each text view.
  • Claim: a template doc can write a command or package-manager token the way component and topic docs do. Verified: the global-mode spec's FR5 has integration docs write tokens, and template descriptions now compile like other docs.
  • Claim: before the change, template list, skeleton, build and search printed the token as written, in text and JSON. Verified: a probe on the base, and 4 of the new test's 5 cases fail there.
  • Claim: build and search text printed every description's commands bare. Verified on the base: build.mjs formatted only command, and search.mjs only cut the first sentence.
  • Claim: component docs and topics render tokens when the API reads them; template docs did not. Verified in the docs adapter and the base template APIs.
  • Claim: the template, build and search APIs render description tokens, so JSON carries bare commands and keeps its shape. Verified: five API projections change values only; probe JSON.
  • Claim: docText applies the prefix rule emit uses for doc Markdown, in template list, skeleton, build (with and without verbose) and search text. Verified: formatters/index.mjs:420-425 and :436-449; probe.
  • Claim: discovery keeps the authored text, so a docs link to a template renders its summary once and an escaped token stays written. Verified: discovery is unchanged and the docs adapter renders once.
  • Claim: a template's source prints byte for byte. Verified: the source case passes on the base and the head.
  • Claim: every printed command starts with the picked command and JSON stays bare (the global-mode spec's FR5 and the docs command's header). Verified against both.
  • Claim: no new option and no JSON shape change. Verified: no command doc or result type changes.
  • Claim: after the change, text prints the project's command, JSON the bare command, and no output of the four commands holds the token. Verified: probe and test.
  • Claim: the new test fails 4 of 5 cases on the base and the source case passes on both. Verified by running it on the base.
  • Claim: the search field-mirror test expects prefixed commands in text. Verified: 33 tests pass on the head.
  • Claim: a link token in a template description still prints as written (scope). Verified: consistent with the code.
  • Claim: no hidden public API, default or interaction change, and no internal context in public text. Verified.
  • Claim: the listed test, repository, type, lint and format checks pass. Partly verified: the template, build, search, API and formatter suites pass on the head (141 files); ESLint is clean on the changed files; Prettier flags only an unchanged search.mjs line that fails on the base too; the strict typecheck reports only two unbuilt theme imports in unchanged templates; the repository checks pass apart from three that need a git working tree.
  • Changeset: template list and skeleton, build and search show tokens as commands, with the project's command in text and bare in JSON, shape unchanged. Verified, including build --verbose.
  • Changeset: build and search text show every description's commands with the project's command. Verified.
  • Changeset: a template's source still prints byte for byte. Verified.
  • File .changeset/template-doc-tokens.md: clear.
  • File packages/cli/api/build/_adapter.mjs: clear.
  • File packages/cli/api/search/_gather-templates.mjs: clear.
  • File packages/cli/api/template/list/list.mjs: clear.
  • File packages/cli/api/template/show/show.mjs: clear.
  • File packages/cli/api/template/skeleton/skeleton.mjs: clear.
  • File packages/cli/clients/cli/commands/build.mjs: clear (the verbose TEMPLATE record is fixed at line 274).
  • File packages/cli/clients/cli/commands/search.mjs: clear.
  • File packages/cli/clients/cli/commands/search.test.mjs: clear.
  • File packages/cli/clients/cli/commands/template-doc-tokens.test.mjs: clear (a component --blocks case belongs with the fix, if the fix extends to that command).
  • File packages/cli/clients/cli/commands/template.mjs: clear.
  • File packages/cli/clients/cli/formatters/index.mjs: clear.

Automated review (maintainer link)

… text show doc commands with the project's command

A template doc's {@command} and {@pm} tokens printed as written in template,
build and search output, in text and JSON. The template, build and search
APIs now render them, so JSON carries the bare astryx command, and the text
views show each description's commands with the project's command through
docText, the same rule emit applies to doc Markdown. A template's source
still prints byte for byte.
… shows its commands with the project's command
@josephfarina
josephfarina changed the base branch from josephfarina/command-token-runner to main November 17, 2026 04:21
@josephfarina
josephfarina force-pushed the josephfarina/template-doc-tokens branch from eac553a to 345c3e6 Compare November 17, 2026 04:21

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

Changes requested: component <Name> --blocks and build --verbose now render and prefix template doc commands as the last reviews asked, but two things remain.

  • Miss: template() and build() from @astryxdesign/cli/api render a description's {@pm …} step for the process's working folder instead of the cwd they are given (packages/cli/api/template/list/list.mjs:54, show/show.mjs:58, skeleton/skeleton.mjs:261, packages/cli/api/build/_adapter.mjs:120, :129, :149), so a Yarn project read from a pnpm folder gets pnpm add … and one build() answer shows pnpm add in start and yarn add in pages for the same template; run both inside runWithDocPackageManager(docPackageManager(cwd), …) as search() does, and add a {@pm} case with a differing cwd.
  • The description says the new test fails 4 of its 5 cases on the base, but it now has 6 cases and 5 fail there (the component --blocks case), so update that line and name component --blocks among the fixed surfaces.

Everything else checks out: JSON keeps its shape with bare commands, text carries the picked command name on every surface, escaped tokens stay written, and a template's source prints byte for byte.

Claims and files checked

Review mode: full; reason: rebase

  • Claim (title): template docs never print a raw command or package-manager token. Verified: template list and skeleton, build, search and component --blocks render it (new test, 6 cases).
  • Claim (title): build and search text show doc commands with the project's command. Verified: build.mjs:216, :225-226, :274; search.mjs:198-199.
  • Claim: a template doc can write a command or package-manager token the way component and topic docs do. Verified: the global-mode spec has integration docs write tokens, and one renderer serves every doc.
  • Claim: before the change, template list, skeleton, build and search printed the token as written, in text and JSON. Verified: the new test's cases fail on the base.
  • Claim: build and search text printed every description's commands bare. Verified on the base: build formatted only command, and search only cut the first sentence.
  • Claim: component docs and topics render tokens when read, and template docs did not. Verified in the docs adapter, the component API and the base template APIs.
  • Claim: the template, build and search APIs render description tokens, JSON carries bare commands, and its shape does not change. Verified for the keys and command tokens; package-manager tokens follow the process's folder when template() or build() gets another cwd (finding above).
  • Claim: docText applies the prefix rule emit uses, in template list, skeleton, build (with and without verbose) and search text. Verified: formatters/index.mjs:420-425.
  • Claim: discovery keeps the authored text, so a docs link renders a template's summary once and an escaped token stays written. Verified: discovery is unchanged, and a probe shows an escaped token written once on every surface.
  • Claim: a template's source prints byte for byte. Verified: the source case passes on the base and the head.
  • Claim: the regression test fails 4 of its 5 cases on the base. False: it has 6 cases and 5 fail on the base.
  • Claim: the search field-mirror test expects a description's commands with the project's command in text. Verified: search.test.mjs:397-403.
  • Claim: a link token in a template description still prints as written. Verified: the token renderer leaves link tokens alone.
  • Claim: no new option and no JSON shape change. Verified.
  • Changeset: tokens no longer print as written; template, build and search show the picked command in text and the bare command in JSON with an unchanged shape; build and search text prefix every description; a template's source prints byte for byte. Verified by the new test and build.mjs, search.mjs.
  • Claim (testing): the CLI node tests and ESLint pass on the changed files. Verified: the CLI suites around the change and ESLint pass on the head.
  • File .changeset/template-doc-tokens.md: clear.
  • File packages/cli/api/build/_adapter.mjs: finding (package-manager token follows the process's folder).
  • File packages/cli/api/component/detail/blocks/blocks.mjs: clear (the component API sets the scope from cwd).
  • File packages/cli/api/search/_gather-templates.mjs: clear.
  • File packages/cli/api/template/list/list.mjs: finding (same).
  • File packages/cli/api/template/show/show.mjs: finding (same).
  • File packages/cli/api/template/skeleton/skeleton.mjs: finding (same).
  • File packages/cli/clients/cli/commands/build.mjs: clear.
  • File packages/cli/clients/cli/commands/component.mjs: clear.
  • File packages/cli/clients/cli/commands/search.mjs: clear.
  • File packages/cli/clients/cli/commands/search.test.mjs: clear.
  • File packages/cli/clients/cli/commands/template-doc-tokens.test.mjs: clear (no package-manager token case; the description's count is stale).
  • File packages/cli/clients/cli/commands/template.mjs: clear.
  • File packages/cli/clients/cli/formatters/index.mjs: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/template/list/list.mjs Resolved
Comment thread packages/cli/api/build/_adapter.mjs Resolved

@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: some test-node shards and other required checks have not finished on this head yet.

Template and block descriptions now render {@command …} and {@pm …} on every surface that prints them, and template() and build() follow their cwd for package-manager steps, which fixes both points from the last review. The new tests fail before each fix and pass here.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Claim (title): template docs never print a raw command or package-manager token. Verified: every reader of a template or block description in the API and CLI renders it (template list, show and skeleton, the build adapter, search's template gatherer, component detail blocks); the new test's surface cases pass.
  • Claim (title): build and search text show doc commands with the project's command. Verified: build.mjs:216, :225-226, :274; search.mjs:198-199.
  • Claim: a template doc can write a command or package-manager token the way component and topic docs do. Verified: the global-mode spec's FR5 has integration docs write tokens, and one renderer serves every doc.
  • Claim: before the change, template list, skeleton, build, search and component --blocks printed the token as written, in text and JSON. Verified: those cases fail on the base.
  • Claim: build and search text printed every description's commands bare. Verified on the base: build formatted only command, search only cut the first sentence, and the search field-mirror test fails there.
  • Claim: component docs and topics render tokens when read, and template docs did not. Verified in the component and docs APIs and the base template projections.
  • Claim: the template, build and search APIs render description tokens, JSON carries bare commands, and its shape does not change. Verified: the projections change values only; probe and test JSON.
  • Claim: docText applies the prefix rule emit uses, in template list, skeleton, build (with and without verbose) and search text. Verified: formatters/index.mjs:420-425 beside emit at :435-449.
  • Claim: template() and build() render a package-manager step for the project their cwd names, as search() does, so one answer never mixes package managers. Verified for package-manager steps: api/template/template.mjs:119-126, api/build/build.mjs:62-79; the two new cases fail on the previous revision and pass here. The build answer's StyleX setup note still names the CLI runner of the process's folder, unchanged from main.
  • Claim: discovery keeps the authored text, so a docs link renders a template's summary once and an escaped token stays written. Verified: discovery is unchanged, and a probe shows an escaped token written once.
  • Claim: a template's source prints byte for byte. Verified: the source case passes on the base and the head.
  • Claim: the CLI must print every command with the picked command name and keep JSON bare (the global-mode spec's FR5 and the docs command's header). Verified against both.
  • Claim: the smallest restoration lists the projections, docText and the three text commands. Verified, though narrower than the change: it leaves out component --blocks and the cwd scope, which the fix and evidence sections name.
  • Claim: the regression test has 8 cases; 7 fail on the base and the template-source case passes on both. Verified by a red-first run.
  • Claim: the search field-mirror test expects a description's commands with the project's command in text. Verified: search.test.mjs:397-407; 33 tests pass.
  • Claim: a link token in a template description still prints as written. Verified: the token renderer leaves link tokens alone.
  • Claim: no new option, no JSON shape change, no hidden public API, and no internal context in public text. Verified.
  • Claim (testing): the CLI tests, repository checks, strict typecheck, ESLint and Prettier pass. Partly verified: 160 related CLI test files pass; ESLint is clean; Prettier flags only unchanged lines in two changed files that fail on the base too; the strict typecheck reports only an unbuilt theme in two unchanged templates, as on the base; the changeset, CLI-structure, sync and manifest checks pass.
  • Changeset: template, build and search show tokens as the project's command in text and the bare command in JSON with an unchanged shape; build and search text prefix every description; a template's source prints byte for byte. Verified by the new test, build.mjs and search.mjs.
  • File .changeset/template-doc-tokens.md: clear.
  • File packages/cli/api/build/_adapter.mjs: clear.
  • File packages/cli/api/build/build.mjs: clear (sets the package-manager scope from cwd).
  • File packages/cli/api/component/detail/blocks/blocks.mjs: clear.
  • File packages/cli/api/search/_gather-templates.mjs: clear.
  • File packages/cli/api/template/list/list.mjs: clear.
  • File packages/cli/api/template/show/show.mjs: clear.
  • File packages/cli/api/template/skeleton/skeleton.mjs: clear.
  • File packages/cli/api/template/template.mjs: clear (sets the package-manager scope from cwd).
  • File packages/cli/clients/cli/commands/build.mjs: clear.
  • File packages/cli/clients/cli/commands/component.mjs: clear.
  • File packages/cli/clients/cli/commands/search.mjs: clear.
  • File packages/cli/clients/cli/commands/search.test.mjs: clear.
  • File packages/cli/clients/cli/commands/template-doc-tokens.test.mjs: clear (8 cases, including the cwd package-manager cases).
  • File packages/cli/clients/cli/commands/template.mjs: clear.
  • File packages/cli/clients/cli/formatters/index.mjs: clear.

Automated review (maintainer link)

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9fe44bf

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.24 MB packed (+641 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

@josephfarina
josephfarina merged commit f39ed02 into main Nov 17, 2026
79 checks passed
@github-actions
github-actions Bot deleted the josephfarina/template-doc-tokens branch November 18, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 9fe44bf9 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