An open source design system that's fully customizable and agent ready
TypeScript
[CLI] Doc syntax: {@command}, {@pm}, {@pm-only} tokens, and integration check --next (#7868)
Joey1a552f29b1d1
diff --git a/.changeset/doc-syntax.md b/.changeset/doc-syntax.mdnew file mode 100644index 0000000000..4f204e616e--- /dev/null+++ b/.changeset/doc-syntax.md@@ -0,0 +1,9 @@+---+'@astryxdesign/cli': patch+---++[feat] Docs can write commands so every reader sees their own: `{@command docs theme}` for an Astryx command, `{@pm install @acme/widgets --dev}` for a package-manager step, and `{@pm-only npm "<reason>" pkg set name=x}` for a step only one package manager can do. The CLI shows each one with the reader's runner and package manager (npm, pnpm, Yarn 1, Yarn 2 and newer, or Bun), and `{@@…}` shows a token as written. `astryx docs authoring/building-blocks/docs/doc-syntax` documents them. `doctor integration validate` lists each command a topic writes for one package manager (`package_manager_command`), bare (`plain_command`) or with a runner (`runner_command`), and each token that does not parse (`doc_token`), each with the token to write.++`integration check --next` counts the findings the next minor release turns into warnings, the notes marked `next`, as warnings now, so `--strict --next` fails on them. Every run says how many there are. Without `--next`, `integration check --strict` exits as before.++@josephfarinadiff --git a/apps/docsite/scripts/generate-data.mjs b/apps/docsite/scripts/generate-data.mjsindex 8592ca8386..cce1be2160 100644--- a/apps/docsite/scripts/generate-data.mjs+++ b/apps/docsite/scripts/generate-data.mjs@@ -42,10 +42,12 @@ import {} from './docs-pages.mjs';import {DOCSITE_CLI_COMMAND,+ DOCSITE_PACKAGE_MANAGER,GLOBAL_PAGE,GLOBAL_PAGE_CLI_COMMAND,getCliInvocation,prefixCliCommands,+ runWithDocPackageManager,runWithCliDoor,} from './lib/cli-command.mjs';import {@@ -1934,7 +1936,11 @@ async function generateDocsRegistry() {const stem = topic.topic === GLOBAL_PAGE ? globalStem : cliStem;topic.sections = withCliCommands(topic.sections,- (text, lang = null) => prefixCliCommands(text, stem, lang),+ (text, lang = null) =>+ // The CLI rendered the doc tokens as it compiled the doc (for npm,+ // under runWithDocPackageManager below), so only bare commands are+ // prefixed here.+ prefixCliCommands(text, stem, lang),stem,);}@@ -2630,7 +2636,8 @@ export const shadcnRegistryIsPreview = ${registryIsPreview};console.log('Done.');}-main().catch(err => {+// Every `{@pm}` step on the site reads as npm, whatever this checkout uses.+runWithDocPackageManager(DOCSITE_PACKAGE_MANAGER, main).catch(err => {console.error(err);process.exit(1);});diff --git a/apps/docsite/scripts/lib/cli-command.mjs b/apps/docsite/scripts/lib/cli-command.mjsindex 8ad95f2c26..c44ee44f5a 100644--- a/apps/docsite/scripts/lib/cli-command.mjs+++ b/apps/docsite/scripts/lib/cli-command.mjs@@ -18,11 +18,18 @@ export {runWithCliDoor} from '../../../../packages/cli/foundation/env/cli-commanexport {getCliInvocation,prefixCliCommands,+ runWithDocPackageManager,} from '../../../../packages/cli/foundation/env/package-manager.mjs';/** The command docsite pages show for running the CLI. */export const DOCSITE_CLI_COMMAND = 'npx @astryxdesign/cli';+/**+ * The package manager docsite pages show `{@pm}` steps in: npm, the one every+ * Node install carries, as the install buttons do.+ */+export const DOCSITE_PACKAGE_MANAGER = 'npm';+/** The command the global mode pages show: their readers installed the CLI. */export const GLOBAL_PAGE_CLI_COMMAND = 'astryx';diff --git a/apps/docsite/src/__tests__/route-resolution.test.ts b/apps/docsite/src/__tests__/route-resolution.test.tsindex 1824ff7e64..7046fe6d80 100644--- a/apps/docsite/src/__tests__/route-resolution.test.ts+++ b/apps/docsite/src/__tests__/route-resolution.test.ts@@ -169,7 +169,8 @@ describe('route resolution', () => {);expect(section).toBeDefined();const text = JSON.stringify(section);- expect(text).toContain('npm i -g @astryxdesign/cli');+ // A `{@pm}` step, which the docsite renders for npm.+ expect(text).toContain('npm install -g @astryxdesign/cli');// Its link to the global mode page renders as a command that opens it.expect(text).toContain('`npx @astryxdesign/cli docs global`');expect(linkifyCode('npx @astryxdesign/cli docs global')).toBe(diff --git a/docs/architecture/cli-surface.md b/docs/architecture/cli-surface.mdindex 2d5431a239..07bb7cfcb0 100644--- a/docs/architecture/cli-surface.md+++ b/docs/architecture/cli-surface.md@@ -214,7 +214,8 @@ validate` MUST warn on a PascalCase `.tsx` at the top of the components rootrun of mostly function words, or one that three or more topics share, is nota copy); fluff, a listed padding phrase or a topic whose share of contentwords is under the published floor; and a stray pointer, a code span that is- exactly `astryx docs <name>` for a doc that exists, in a topic's prose,+ exactly `astryx docs <name>`, or a `{@command docs <name>}` token in a code+ span or not (DEC-12), for a doc that exists, in a topic's prose,description or summary or a component doc's text, where a `{@link}` to thatdoc would be checked. It also fails on doc structure a reader silentlydrops: a prop documented twice, an overlay key that names no prop, two@@ -230,8 +231,14 @@ validate` MUST warn on a PascalCase `.tsx` at the top of the components rootraise a conflict with a package's own name. Each `doctor integration`subcommand MUST keep its exit codes, and its JSON MAY change only byadditions. Because builds fail on its findings, it MUST NOT report a finding- the package's code does not contradict, other than the doc faults of DEC-8:+ the package's code does not contradict, other than the doc faults of DEC-8+ and the doc-syntax findings of DEC-12:a check that cannot judge an item lists it as not checked instead (DEC-7).+ A finding that would newly fail a build MUST first ship as a note marked+ `next` in `validate`'s `data.notes`, which fails nothing by default:+ `--next` counts those notes as warnings, so `--strict --next` fails on them+ today, and every run reports how many there are and names that command. The+ next minor release counts them by default (DEC-11).When the running CLI is outside a package's `@astryxdesign/cli` peer range,`astryx doctor integration validate` and `integration check` MUST list a`cli_peer_version` note, which fails nothing, `--strict` included, and@@ -767,8 +774,8 @@ Every integration runs `integration check --strict` in its build (DEC-6), so afalse finding fails a package for a fault it does not have, and its only wayout, dropping `--strict`, also drops the check for every real fault. A checkthat cannot tell whether the code contradicts a doc lists the item as not-checked, which `--strict` does not fail. The one exception is the doc-quality-findings of DEC-8.+checked, which `--strict` does not fail. The exceptions are the doc-quality+findings of DEC-8 and the doc-syntax findings of DEC-12.Rejected: reporting a doubtful item as a warning (`--strict` fails it).### DEC-8 — The strict check fails on copied passages, fluff and stray pointers in docs@@ -778,7 +785,7 @@ Rejected: reporting a doubtful item as a warning (`--strict` fails it).People and agents read integration docs on a budget. A fact written in twotopics goes stale in one of them at the next edit, and padding costs everyreader. So these doc-quality findings fail `--strict` by owner decision, as-the one exception to DEC-7. A copied passage (a run of identical words, after+an exception to DEC-7; DEC-12's doc-syntax findings are the other. A copied passage (a run of identical words, afterthe filters for function-word runs and for boilerplate that three or moretopics share) and a listed padding phrase (outside code and quotes) are exactmatches. The density floor is a threshold, not a contradiction, and a section@@ -789,8 +796,9 @@ topic. The phraselist and the floor are published in the check's docs, and every findingnames the phrase, or the measured density and the floor, so its fix ismechanical. A stray pointer (a code span that is exactly-`astryx docs <name>` for a doc that exists, in a topic's prose, description-or summary or a component doc's text) is exact as well: the `{@link}`+`astryx docs <name>`, or a `{@command docs <name>}` token in a code span or+not (DEC-12), for a doc that exists, in a topic's prose, description or+summary or a component doc's text) is exact as well: the `{@link}`that replaces it prints the command that opens the doc, and doctor's linkcheck then fails it when the doc goes away. A command with more words, or onein a code block, is a walkthrough, not a pointer. Each is a warning, so `integration check --strict` fails on it and@@ -828,6 +836,38 @@ keeps its own upgrade.Rejected: treating every folder with an installed Core as a project (aworkspace member then migrates against a Core its workspace does not use).+### DEC-11 — A new failing check ships under `--next` first++**Decider:** `josephfarina`, `2026-10-21`++A check that would newly fail `integration check --strict` reaches packages+as a `next` note first, so each package can run `integration check --strict+--next`, fix what it finds, and stay ahead of the minor release that turns the+notes into warnings. The default run names the count and the command, because+every package's build runs it.++Rejected: shipping a new failing check only in a minor release (packages+learn of it when their build breaks), and a separate draft per check (the+next minor's changes then live in many places).++### DEC-12 — Doc-syntax findings are listed now and fail in the next minor++**Decider:** `josephfarina`, `2026-10-21`++Docs write commands with the tokens of `spec:AST-081` FR5 so every reader+sees their own runner and package manager. `validate` lists each command a+topic writes for one package manager (`package_manager_command`), bare+(`plain_command`) or with a runner (`runner_command`), and each token that+does not parse or names no command (`doc_token`), as `next` notes with the+token to write: `integration check --strict --next` fails on them now, and+`--strict` from the next minor release (DEC-11). They are doc faults the+package's code does not contradict, the second exception to DEC-7 after+DEC-8.++Rejected: failing `--strict` on them in a patch (packages already running the+check would break on an update), and leaving them unchecked (docs drift back+to one package manager).+## Verification| Invariant | Evidence | Failure signal |@@ -858,7 +898,7 @@ workspace member then migrates against a Core its workspace does not use).| INV32 | `test/cli-strict-guard.test.mjs` lists every command offering `--strict` and every command whose exit depends on warnings; `api/integration/check/check.test.mjs` compares a strict run with the default run | A second command offers `--strict`, a command exits 1 on a warning alone without `--strict`, or a strict run reports a finding the default run does not or outside the command's issue format. || INV33 | `foundation/discovery/prop-drift.test.mjs`, `foundation/discovery/doc-consistency.test.mjs`, `foundation/discovery/type-text.test.mjs`, `clients/cli/commands/doctor-integration.test.mjs`, `test/core-prop-docs.test.mjs` | A removed or renamed prop or a changed union passes unreported, a missing compiler reads as a pass, or a table that leaves out `ref`, `key`, `xstyle`, `className`, `style`, `data-testid`, or an `@internal` prop draws a warning. || INV34 | `foundation/discovery/doc-types.test.mjs`, `foundation/discovery/doc-consistency.test.mjs`, `clients/cli/commands/doctor-integration.test.mjs`, `test/core-doc-types.test.mjs` | An unknown, missing, or mistyped field passes unreported, or a missing compiler reads as a pass. |-| INV35 | `api/integration/check/check.test.mjs`, `clients/cli/commands/integration-check.test.mjs`, `test/integration-check-failures.test.mjs`, `api/search/search.integration-check.test.mjs`, `foundation/discovery/prop-drift.test.mjs`, `foundation/discovery/type-match.test.mjs`, `foundation/discovery/doc-types.test.mjs`, `api/integration/authoring-checks.test.mjs`, `foundation/discovery/stray-pointers.test.mjs`, `foundation/integrations/cli-peer-version.test.mjs` | The default exit differs from a check's own, a warning or a skipped comparison passes `--strict`, text and JSON exit differently, a new failing finding is added without the list changing, a search for ci does not find the command first, a finding is reported on a doc the code does not contradict (for a type, one TypeScript accepts), or a copied passage or a fluff finding passes `--strict`, or a function-word run or shared boilerplate is reported as a copy, or a CLI outside a package's `@astryxdesign/cli` peer range is reported as a warning, fails `--strict`, reaches `integration verify`, or goes unlisted. |+| INV35 | `api/integration/check/check.test.mjs`, `clients/cli/commands/integration-check.test.mjs`, `test/integration-check-failures.test.mjs`, `api/search/search.integration-check.test.mjs`, `foundation/discovery/prop-drift.test.mjs`, `foundation/discovery/type-match.test.mjs`, `foundation/discovery/doc-types.test.mjs`, `api/integration/authoring-checks.test.mjs`, `foundation/discovery/stray-pointers.test.mjs`, `foundation/integrations/cli-peer-version.test.mjs` | The default exit differs from a check's own, a warning or a skipped comparison passes `--strict`, text and JSON exit differently, a new failing finding is added without the list changing, a search for ci does not find the command first, a finding is reported on a doc the code does not contradict (for a type, one TypeScript accepts), or a copied passage or a fluff finding passes `--strict`, or a function-word run or shared boilerplate is reported as a copy, or a CLI outside a package's `@astryxdesign/cli` peer range is reported as a warning, fails `--strict`, reaches `integration verify`, or goes unlisted, or a `next` note fails `--strict` without `--next`, passes `--strict --next`, or goes unreported in the default run. || INV36 | `api/gap-report/gap-report.test.mjs`, `clients/cli/commands/gap-report.test.mjs` | A run without `--to` reaches an `issuesUrl` the handlers did not choose, `--to` runs a handler or files on GitHub without `--confirm-public`, an unknown `--to` sends anything, or the destinations list or its line telling the agent to ask the person is missing while a destination exists. || INV37 | `api/integration/validate-integration.test.mjs`, `api/integration/validate-integration-fixes.test.mjs`, `api/integration/pack-check.test.mjs` | A top-level source with no doc passes `--strict` (a dotted template id such as `landing.page` included), or a test, spec or story file or a subfolder helper is flagged. |diff --git a/docs/specs/AST-046-docs-tree/spec.md b/docs/specs/AST-046-docs-tree/spec.mdindex 761225eba2..cad1f4affe 100644--- a/docs/specs/AST-046-docs-tree/spec.md+++ b/docs/specs/AST-046-docs-tree/spec.md@@ -203,7 +203,13 @@ and references from other packages are an open question (OQ2).sets `id`, and a theme, whose typed descriptor an older CLI rejects alongwith the package's doc topics; `integration add theme` declares the peer.A doc section that sets `before` or `after` needs the same range from the- CLI that reads those fields; `integration verify` warns without it.+ CLI that reads those fields; `integration verify` warns without it. A topic+ or placed guide whose text writes a doc token (`{@command …}`, `{@pm …}`,+ `{@pm-only …}`; an escaped `{@@…}` is not one) needs the range from the+ first CLI that renders tokens, since an older one shows them as written;+ `integration verify` warns without it (`doc_tokens_need_cli`). Component+ docs, template docs and `agentDocs.append` lines are not yet covered by+ that warning.- **FR12 — Every doc has a named home.** Every flat topic, the CLI's andeach integration's, MUST sit in the generated level for its category, in theorder the topic list reads: `foundations` (Foundations) for a foundationsdiff --git a/docs/specs/AST-081-global-mode/spec.md b/docs/specs/AST-081-global-mode/spec.mdindex 4a74123aed..b71f81fec8 100644--- a/docs/specs/AST-081-global-mode/spec.md+++ b/docs/specs/AST-081-global-mode/spec.md@@ -311,20 +311,31 @@ works on is `spec:AST-040` FR9's.counts as absent, never withdraws the integration's other contributions, and`doctor` warns about it; `doctor integration validate` and`integration check` report it as a note (`invalid_cli_command`) beside- their issues, which fails nothing.+ their issues, marked `next`: it fails nothing until the next minor release+ (`architecture:cli-surface` INV35).- The picker names every command the CLI prints or writes: hints and nextsteps, errors and their suggestions, `doctor` fixes, help, docs moves(`spec:AST-047`), recommended commands (`spec:AST-048`), the project'sagent-docs block, the computer-level agent text (FR8), and the setupreminder wherever it is printed. No surface spells a command name of itsown.- - Docs, guides, agent text, and the text an integration supplies, such as- its docs and its agent-doc lines, write every CLI command bare, beginning- `astryx`; the CLI puts the picked name in its place when it prints or- writes that text. A step that installs a door, or starts one by its own- name, is not a CLI command and stays as written.+ - Astryx's own docs, guides and agent text, and an integration's agent-doc+ lines, write every CLI command bare, beginning `astryx`, or as a+ `{@command …}` token. An integration's docs write each as a+ `{@command …}` token; a bare one there is a `plain_command` note+ (`architecture:cli-surface` DEC-12). The CLI puts the picked name in+ place of the leading `astryx` when it prints or writes that text. A doc writes a+ package-manager step as a `{@pm …}` token, or as `{@pm-only <manager>+ "<reason>" …}` for a step only that package manager can do, and `{@@…}`+ shows a token as written. The CLI renders each token as it compiles the+ doc: `{@command …}` as the bare command, and `{@pm …}` in the package+ manager of the project it runs in; a host that shows docs to readers of+ every package manager, such as the docsite, picks one. A step that+ installs a door, or starts one by its own name, is not a CLI command and+ stays as written.- Machine-readable output, error envelopes included, carries every command- bare, beginning `astryx`, and never a picked name.+ bare, beginning `astryx`, and never a picked name or an unrendered+ token.- A command that finishes work with another release names that release(`spec:AST-040` FR13).- **FR6 — The global copy tells its user about newer releases and installs@@ -799,7 +810,7 @@ needs no Changeset.| FR2 | Release check: every page template scaffolded through a door into a project on the previous release, then typechecked; hand-off probes | a project with its own CLI; a project whose CLI and Core differ, both ways; a project with Core only; a workspace member with its own Core under a root CLI; a fresh clone with a lockfile and with only a declared range; an upgrade with a project CLI older than its Core; a declined project CLI, with its release and with it unavailable (the starting copy answers, announced, naming the reason); an unavailable release | A template fails where the matched release passes, a release other than the one equal to the project's Core answers, project configuration runs in another copy, or another release answers in place of an unavailable one || FR3 | Empty-folder run of every command example | each command that needs Core; `doctor`, `swizzle`, and `upgrade`; a folder with no `package.json`; a home folder; a copy with no Core | A command that needs Core fails beside a carried Core, a project check reads it, or output gives a project step || FR4 | Declaration check over every command doc, plus the empty-folder run compared with each declaration | `same`, `refuse`, and `own`; a command group; a command without a value; a released refusal code | A command lacks a value, a `refuse` writes or uses an unlisted code, or a command's behavior differs from its value |-| FR5 | Printed-command check: each command the CLI prints or writes, run from the same folder through the door that printed it; a picker check over every surface that prints a command; a check of shipped text; result-field tests | each door; `project`, `matched`, and `carried`; no declaration, one integration's command, two that agree, two that disagree, and a malformed one; hints, errors, `doctor` fixes, help, docs moves, agent text, and the setup reminder; text and JSON | A printed command reaches another door or release, a surface prints a name the picker did not choose, the picker's order changes, a disagreement prints either integration's command or `doctor` stays silent, a malformed declaration withdraws its integration, shipped text writes a CLI command any way but bare, JSON carries a picked name, `meta.answeredBy` is missing or wrong, or the line prints for the project's own CLI |+| FR5 | Printed-command check: each command the CLI prints or writes, run from the same folder through the door that printed it; a picker check over every surface that prints a command; a check of shipped text; result-field tests | each door; `project`, `matched`, and `carried`; no declaration, one integration's command, two that agree, two that disagree, and a malformed one; hints, errors, `doctor` fixes, help, docs moves, agent text, and the setup reminder; text and JSON | A printed command reaches another door or release, a surface prints a name the picker did not choose, the picker's order changes, a disagreement prints either integration's command or `doctor` stays silent, a malformed declaration withdraws its integration, shipped text writes a CLI command any way but bare or as a `{@command}` token, JSON carries an unrendered token, JSON carries a picked name, `meta.answeredBy` is missing or wrong, or the line prints for the project's own CLI || FR6 | Update check tests | first run; within and after 24 hours; `CI` set to yes and to `false`; `NO_UPDATE_NOTIFIER` set; an unreachable registry; ten runs at once; a requested version; a package runner's copy; inside a project | A check runs in the first day, twice in a day, with `CI` or `NO_UPDATE_NOTIFIER` set, or for a fetched copy; a command waits for it or its output changes; or a check installs or switches a release || FR7 | File-system comparison before and after each command in the empty-folder run and in projects | each command that writes; absolute, traversal, and symlinked paths; a home folder | A file lands outside the named places, or a refusal writes first || FR8 | Release build, drift checks, a starter build in CI, and computer-level text tests | the official list; the agent text for each door; each starter; the global copy's first run and a switch; `--agent` lists; an opt-out; a file a person edited; a file without markers; a link in a file's place; a strict YAML parse of every skill file | A committed copy drifts, a global asset is fetched at run time, the computer-level text names a version, a starter fails to scaffold, install, or build, the global copy writes after an opt-out or into an edited file, a command waits for the text, or a skill's frontmatter does not parse |diff --git a/packages/cli/README.md b/packages/cli/README.mdindex 11fce3564e..163e27bca7 100644--- a/packages/cli/README.md+++ b/packages/cli/README.md@@ -470,69 +470,69 @@ Every response has a `type` discriminant. The full set is below (generated from<!-- BEGIN GENERATED: response-types -->-| Type | What `data` carries |-| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |-| `init.remove` | The removal receipt — returned when --remove-agents is set: `data.removed` is true when a managed agent-docs block was found and removed, and false when there was none to remove. |-| `init.user` | The computer-level agent text receipt — returned when --user is set: `data.files`, one `{path, action, reason?}` per path acted on, the skill file first and then each link to its folder (action `written` \| `linked` \| `unchanged` \| `removed` \| `absent` \| `kept`; `reason` only on `kept`: `edited` when a person changed the text, `not-astryx` when Astryx did not write it), `data.command` (the command the text names), and `data.warnings`. |-| `component.list` | The component catalog grouped by component group (each component's group field): `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries ({name, package, description, import}), or a full ComponentDoc per entry with its package. |-| `component.batch` | The component specialization of the shared `BatchResponse` and `BatchRow` types. An explicit programmatic selector array, or two or more CLI selectors, returns one ordered receipt: `count` plus `results`, one row per selector including duplicates. Every row carries `selector` and `status` (found \| not_found \| ambiguous \| error). A found row carries `result`, the same {type, data} response as one selector. An ambiguous row carries `code`, `error`, and `candidates` ({package, component, kind, installed}). Other failed rows carry `code`, `error`, and optional `suggestions` ({name, reason}). |-| `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc). The envelope's package names the same owner. |-| `component.detail.props` | Just one component's props table (ComponentPropDoc[]). The envelope's package names the npm package that owns the component. |-| `component.detail.source` | One component's source file, as {component, source}. The envelope's package names the npm package that owns the component. |-| `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. The envelope's package names the npm package that owns the component. |-| `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry ({name, package, displayName, description, isShowcase, category}); each block names the package that owns it, and the envelope's package names the component's owner. |-| `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?, replacedPackage?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load. |-| `docs.detail` | One topic's full ReferenceDoc (the JSON read of a topic, --full, --dense, or a topic with one section), with token-ref blocks inlined and each section naming the package that wrote it, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). A topic or guide that took another's place carries replaces and replacedPackage, the package whose topic or guide it replaced. |-| `docs.index` | One topic's section index, the text read of a topic with more than one section (and --index): the topic's name, title, and description, plus sections, each {id, title, package, summary} (pass the id as the section argument; package is the npm package that wrote the section; summary is the section's one-line summary), and links ({up, previous, next}: the commands that open the level it sits in and its neighbors there); replaces and replacedPackage when the topic or guide took another's place. |-| `docs.detail.section` | One ReferenceSection of a topic, found by key or title, with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open its topic index and the sections before and after it). The envelope's package names the npm package that wrote the section. |-| `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down, each naming its package, and a guide an integration replaced its replaces and replacedPackage) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names). |-| `blog.list` | The feed URL plus every post parsed from the RSS feed, each with slug, title, description, date, type, authors, link, and plaintext URL. |-| `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |-| `discover.list` | What the project has, the integrations it loads and the official packages it declares, official packages first (package, the npm package and always equal to name; name, category, components, version, a list per other kind they add, and latest when a source knows it); meta.available lists what the project could add, the official packages first, each with its package and the command that adds it, and meta.sources reports each source, the official list last; when it lists no integration it carries meta.configured to tell "nothing configured" from "nothing discovered". |-| `discover.detail` | One package, for an @scope/name or @scope/name@version query: its package (the npm package the result is about), what the shown version adds, whether the project has it, and, when a source knows the package, its versions, latest release, and the command that adds it. |-| `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query, plus package, the npm package that owns the component. |-| `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. The envelope's package names the same package. |-| `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |-| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, package, score, reason, description, command} (package is the npm package that owns the result), plus import (components, hooks), title, parent (the command that opens the level above), and, for a hit on one section, section (docs), or displayName and kind (templates). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is {skipped, reason}: the domains it skipped (component, hook, template) and why. |-| `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |-| `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, package, command, basis, reason, alternatives, ...} (the start and each alternative name the package that owns the template), pages (search's closest templates), blocks and domain as SearchResultEntry[] (each naming its package), frame and foundation (Core component names), and hint {reason, commands} when thin. |-| `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. The envelope's package is @astryxdesign/core. |-| `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling. The envelope's package names the same owning package. |-| `gap-report.categories` | The fixed gap category values and human-readable labels; when a loaded integration names its own issues URL, meta.destinations lists every destination ({to, default, issuesUrl}) and meta.ask tells an agent to ask the person. |-| `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals; without --to, when a loaded integration names its own issues URL, destinations and ask as on gap-report.categories. |-| `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |-| `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |-| `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. The envelope's package names the npm package that owns the template. |-| `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, demoMediaReplaced (how many Astryx demo media references were replaced with placeholders), notes (setup notes naming what the template needs that the project lacks — missing packages, missing StyleX compiler; empty when satisfied), missingPackages (external package names the template imports that are not in the project), and installCommand (a ready-to-run install command with the detected package manager and workspace version ranges; null when nothing is missing, or when several lockfiles leave the package manager undetermined). The envelope's package names the npm package that owns the template. |-| `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |-| `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. The envelope's package is @astryxdesign/core, the only package that ships hooks. |-| `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |-| `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |-| `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |-| `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |-| `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |-| `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, owner package or local root, source, added, and default fields. Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |-| `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. After add, the envelope package names the npm package that owns the added theme; a local theme has none. |-| `theme.eject` | A local source-fork receipt with the resolved slug, displayName, source theme maintained flag, source-selector package, outputDir, source entry, exportName, and every file written, including the descriptor. The written local descriptor always uses maintained: false. |-| `theme.template` | A write receipt for the annotated theme template: the path (relative to cwd), whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |-| `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states}, where props and states are its legal override keys. |-| `theme.palette.generate` | An author-reviewable OKLCH palette response: recipe (`astryx-oklch-v1`), status (`candidate`), familyCount, stopCount, modes, candidate (`TonalPaletteCandidate`), and generationReceipt. The generationReceipt contains schemaVersion (1), recipe, generatorVersion (`palette-generator-v1`), candidateFormatVersion (`palette-typescript-v1` or `palette-json-v1`), candidateSha256, optional preview, resolved request, and diagnostics. File-write fields are output, receipt, preview, written, and reason (`exists` or null). |-| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |-| `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |-| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. no_codemods and config_fixable carry cliBehindCore ({cliVersion, command}) when the installed Core is newer than the CLI, which then has no codemods for the releases after its own version. |-| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run. |-| `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], outsideProject? (same, refuse, or own; absent on a group), subcommands?), jsonSupported, globalMode ({docs, summary}: what a run may do beyond its command, such as the hand-off to the project's own CLI, the daily update check, and the agent skill file, and the docs topic that explains it), and the flat responseTypes index. |-| `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |-| `version` | The CLI version, for `astryx --version --json`: {version}. |-| `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |-| `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |-| `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message, fix?, file?, line?}] (the issues validation finds in the source and, prefixed packed_, in the packed tree, with the fix and the place when the check knows them). |-| `integration.validate` | The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message} information that fails nothing, such as invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. A runner_command note lists each Astryx command a topic writes with a package runner (its file, line and the bare command to write). A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked \| skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on. |-| `integration.template-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |-| `integration.component-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. When the manifest loads and declares a components root, propDrift compares documented props with the TypeScript props: status (checked \| skipped), reason, typescript, components, typesCompared, typesSkipped, findings (all warnings; a default_mismatch carries docDefault, codeDefault, and a fix), unchecked, typesNotCompared, and propsNotChecked. |-| `integration.doc-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). copiedPassages lists each pair of topics that repeat 10 or more words of prose word for word: topic, section, otherTopic, otherOwner (package \| core), words, passages, owner (the topic that should keep the text), text (the passage as the topic writes it), line (where the copy starts in the topic to change, or null), and message (the exact replacement); each is also a copied_passage warning in issues. fluff lists padding phrases and low-density topics: topic, kind (phrase \| density), phrase, section, file (relative to the package root), line, density, and message (what to cut or write instead); each is also a doc_fluff warning in issues. strayPointers lists each code span that is exactly `astryx docs <name>` for a doc that exists, in the prose, description or summary of a topic or the text fields of a component doc: topic (the topic or component doc), kind (topic \| component), section, field (the field outside any section, such as description or usage.bestPractices[0].description, else null), file (relative to the package root), line, pointer (the written command), link (the {@link} that replaces it), and message; each is also a stray_doc_pointer warning in issues. |-| `integration.check` | Every source check of an integration package in one result: validated (false when no integration manifest was found, so nothing was checked), the package name and version, strict, and checks, one entry per check (validate, components, templates, docs), each with check, errors, warnings, skipped, failed, and response, the envelope that check returns on its own. The totals are errors, warnings, and skipped; unchecked counts what the checks could not compare. With --strict, failures lists each warning and each piece of skipped work again as an error, in the issue format the checks use; it is empty without --strict. failed decides the exit code. |+| Type | What `data` carries |+| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |+| `init.remove` | The removal receipt — returned when --remove-agents is set: `data.removed` is true when a managed agent-docs block was found and removed, and false when there was none to remove. |+| `init.user` | The computer-level agent text receipt — returned when --user is set: `data.files`, one `{path, action, reason?}` per path acted on, the skill file first and then each link to its folder (action `written` \| `linked` \| `unchanged` \| `removed` \| `absent` \| `kept`; `reason` only on `kept`: `edited` when a person changed the text, `not-astryx` when Astryx did not write it), `data.command` (the command the text names), and `data.warnings`. |+| `component.list` | The component catalog grouped by component group (each component's group field): `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries ({name, package, description, import}), or a full ComponentDoc per entry with its package. |+| `component.batch` | The component specialization of the shared `BatchResponse` and `BatchRow` types. An explicit programmatic selector array, or two or more CLI selectors, returns one ordered receipt: `count` plus `results`, one row per selector including duplicates. Every row carries `selector` and `status` (found \| not_found \| ambiguous \| error). A found row carries `result`, the same {type, data} response as one selector. An ambiguous row carries `code`, `error`, and `candidates` ({package, component, kind, installed}). Other failed rows carry `code`, `error`, and optional `suggestions` ({name, reason}). |+| `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc). The envelope's package names the same owner. |+| `component.detail.props` | Just one component's props table (ComponentPropDoc[]). The envelope's package names the npm package that owns the component. |+| `component.detail.source` | One component's source file, as {component, source}. The envelope's package names the npm package that owns the component. |+| `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. The envelope's package names the npm package that owns the component. |+| `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry ({name, package, displayName, description, isShowcase, category}); each block names the package that owns it, and the envelope's package names the component's owner. |+| `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?, replacedPackage?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load. |+| `docs.detail` | One topic's full ReferenceDoc (the JSON read of a topic, --full, --dense, or a topic with one section), with token-ref blocks inlined and each section naming the package that wrote it, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). A topic or guide that took another's place carries replaces and replacedPackage, the package whose topic or guide it replaced. |+| `docs.index` | One topic's section index, the text read of a topic with more than one section (and --index): the topic's name, title, and description, plus sections, each {id, title, package, summary} (pass the id as the section argument; package is the npm package that wrote the section; summary is the section's one-line summary), and links ({up, previous, next}: the commands that open the level it sits in and its neighbors there); replaces and replacedPackage when the topic or guide took another's place. |+| `docs.detail.section` | One ReferenceSection of a topic, found by key or title, with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open its topic index and the sections before and after it). The envelope's package names the npm package that wrote the section. |+| `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down, each naming its package, and a guide an integration replaced its replaces and replacedPackage) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names). |+| `blog.list` | The feed URL plus every post parsed from the RSS feed, each with slug, title, description, date, type, authors, link, and plaintext URL. |+| `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |+| `discover.list` | What the project has, the integrations it loads and the official packages it declares, official packages first (package, the npm package and always equal to name; name, category, components, version, a list per other kind they add, and latest when a source knows it); meta.available lists what the project could add, the official packages first, each with its package and the command that adds it, and meta.sources reports each source, the official list last; when it lists no integration it carries meta.configured to tell "nothing configured" from "nothing discovered". |+| `discover.detail` | One package, for an @scope/name or @scope/name@version query: its package (the npm package the result is about), what the shown version adds, whether the project has it, and, when a source knows the package, its versions, latest release, and the command that adds it. |+| `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query, plus package, the npm package that owns the component. |+| `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. The envelope's package names the same package. |+| `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |+| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, package, score, reason, description, command} (package is the npm package that owns the result), plus import (components, hooks), title, parent (the command that opens the level above), and, for a hit on one section, section (docs), or displayName and kind (templates). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is {skipped, reason}: the domains it skipped (component, hook, template) and why. |+| `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |+| `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, package, command, basis, reason, alternatives, ...} (the start and each alternative name the package that owns the template), pages (search's closest templates), blocks and domain as SearchResultEntry[] (each naming its package), frame and foundation (Core component names), and hint {reason, commands} when thin. |+| `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. The envelope's package is @astryxdesign/core. |+| `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling. The envelope's package names the same owning package. |+| `gap-report.categories` | The fixed gap category values and human-readable labels; when a loaded integration names its own issues URL, meta.destinations lists every destination ({to, default, issuesUrl}) and meta.ask tells an agent to ask the person. |+| `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals; without --to, when a loaded integration names its own issues URL, destinations and ask as on gap-report.categories. |+| `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |+| `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |+| `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. The envelope's package names the npm package that owns the template. |+| `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, demoMediaReplaced (how many Astryx demo media references were replaced with placeholders), notes (setup notes naming what the template needs that the project lacks — missing packages, missing StyleX compiler; empty when satisfied), missingPackages (external package names the template imports that are not in the project), and installCommand (a ready-to-run install command with the detected package manager and workspace version ranges; null when nothing is missing, or when several lockfiles leave the package manager undetermined). The envelope's package names the npm package that owns the template. |+| `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |+| `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. The envelope's package is @astryxdesign/core, the only package that ships hooks. |+| `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |+| `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |+| `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |+| `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |+| `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |+| `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, owner package or local root, source, added, and default fields. Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |+| `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. After add, the envelope package names the npm package that owns the added theme; a local theme has none. |+| `theme.eject` | A local source-fork receipt with the resolved slug, displayName, source theme maintained flag, source-selector package, outputDir, source entry, exportName, and every file written, including the descriptor. The written local descriptor always uses maintained: false. |+| `theme.template` | A write receipt for the annotated theme template: the path (relative to cwd), whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |+| `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states}, where props and states are its legal override keys. |+| `theme.palette.generate` | An author-reviewable OKLCH palette response: recipe (`astryx-oklch-v1`), status (`candidate`), familyCount, stopCount, modes, candidate (`TonalPaletteCandidate`), and generationReceipt. The generationReceipt contains schemaVersion (1), recipe, generatorVersion (`palette-generator-v1`), candidateFormatVersion (`palette-typescript-v1` or `palette-json-v1`), candidateSha256, optional preview, resolved request, and diagnostics. File-write fields are output, receipt, preview, written, and reason (`exists` or null). |+| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |+| `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |+| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. no_codemods and config_fixable carry cliBehindCore ({cliVersion, command}) when the installed Core is newer than the CLI, which then has no codemods for the releases after its own version. |+| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run. |+| `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], outsideProject? (same, refuse, or own; absent on a group), subcommands?), jsonSupported, globalMode ({docs, summary}: what a run may do beyond its command, such as the hand-off to the project's own CLI, the daily update check, and the agent skill file, and the docs topic that explains it), and the flat responseTypes index. |+| `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |+| `version` | The CLI version, for `astryx --version --json`: {version}. |+| `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |+| `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |+| `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message, fix?, file?, line?}] (the issues validation finds in the source and, prefixed packed_, in the packed tree, with the fix and the place when the check knows them). |+| `integration.validate` | The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message, next?} information beside the issues (text output marks a next note [next minor]); a note fails nothing by default, and one with next: true counts as a warning under integration check --next, fails integration check --strict --next, and fails --strict from the next minor release. Notes include invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. For the commands a topic writes, runner_command (written with a package runner), plain_command (written bare), package_manager_command (written for one package manager) and doc_token (a token that does not parse) notes each give the file, line and the token to write. A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked \| skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on. |+| `integration.template-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |+| `integration.component-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. When the manifest loads and declares a components root, propDrift compares documented props with the TypeScript props: status (checked \| skipped), reason, typescript, components, typesCompared, typesSkipped, findings (all warnings; a default_mismatch carries docDefault, codeDefault, and a fix), unchecked, typesNotCompared, and propsNotChecked. |+| `integration.doc-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). copiedPassages lists each pair of topics that repeat 10 or more words of prose word for word: topic, section, otherTopic, otherOwner (package \| core), words, passages, owner (the topic that should keep the text), text (the passage as the topic writes it), line (where the copy starts in the topic to change, or null), and message (the exact replacement); each is also a copied_passage warning in issues. fluff lists padding phrases and low-density topics: topic, kind (phrase \| density), phrase, section, file (relative to the package root), line, density, and message (what to cut or write instead); each is also a doc_fluff warning in issues. strayPointers lists each code span that is exactly `astryx docs <name>` for a doc that exists, in the prose, description or summary of a topic or the text fields of a component doc: topic (the topic or component doc), kind (topic \| component), section, field (the field outside any section, such as description or usage.bestPractices[0].description, else null), file (relative to the package root), line, pointer (the written command), link (the {@link} that replaces it), and message; each is also a stray_doc_pointer warning in issues. |+| `integration.check` | Every source check of an integration package in one result: validated (false when no integration manifest was found, so nothing was checked), the package name and version, strict, next (true with --next), and checks, one entry per check (validate, components, templates, docs), each with check, errors, warnings, skipped, failed, and response, the envelope that check returns on its own. The totals are errors, warnings, and skipped; unchecked counts what the checks could not compare, and upcoming how many of the validate notes carry next: true. With --next those notes count as warnings in the validate row and the totals. With --strict, failures lists each warning and each piece of skipped work again as an error, in the issue format the checks use, and with --strict --next each next note too; it is empty without --strict. failed decides the exit code. |<!-- END GENERATED: response-types --><!-- Generated by scripts/generate-cli-readme.mjs from the response-types EnumDoc. Run `pnpm -F @astryxdesign/cli readme`. -->diff --git a/packages/cli/api/component/_adapter.mjs b/packages/cli/api/component/_adapter.mjsindex 47e44d1f47..65539803a8 100644--- a/packages/cli/api/component/_adapter.mjs+++ b/packages/cli/api/component/_adapter.mjs@@ -718,7 +718,7 @@ export async function linkSearchResponse(response, cwd) {result =>result?.domain === 'component' &&typeof result.description === 'string' &&- result.description.includes('{@link'),+ result.description.includes('{@'),)) {return response;@@ -728,7 +728,7 @@ export async function linkSearchResponse(response, cwd) {if (result?.domain !== 'component' ||typeof result.description !== 'string' ||- !result.description.includes('{@link')+ !result.description.includes('{@')) {linked.push(result);continue;@@ -767,7 +767,8 @@ export async function linkComponentResponse(response, cwd) {) {return response;}- if (!JSON.stringify(response.data ?? null).includes('{@link')) {+ // Doc tokens render in the same pass as links.+ if (!JSON.stringify(response.data ?? null).includes('{@')) {return response;}const catalog = await loadDocsCatalog(cwd);diff --git a/packages/cli/api/component/component.mjs b/packages/cli/api/component/component.mjsindex 3207cb5b57..561f3f949b 100644--- a/packages/cli/api/component/component.mjs+++ b/packages/cli/api/component/component.mjs@@ -12,6 +12,10 @@* Every leaf is also re-exported for direct scripting use.*/+import {+ docPackageManager,+ runWithDocPackageManager,+} from '../../foundation/env/package-manager.mjs';import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';import {AstryxError} from '../error.mjs';import {@@ -258,13 +262,16 @@ async function componentBatch(selectors, options, coreDir) {* )>}*/export async function component(name, options = {}) {+ const cwd = options.cwd ?? process.cwd();// Every read resolves the links in the doc text it returns (spec:AST-047- // FR9); a batch's results are each a read of their own.- return /** @type {any} */ (- await linkComponentResponse(- await componentRead(name, options),- options.cwd ?? process.cwd(),- )+ // FR9); a batch's results are each a read of their own. Doc tokens render+ // for the project in `cwd`.+ return runWithDocPackageManager(+ docPackageManager(cwd),+ async () =>+ /** @type {any} */ (+ await linkComponentResponse(await componentRead(name, options), cwd)+ ),);}diff --git a/packages/cli/api/component/doc-links.test.mjs b/packages/cli/api/component/doc-links.test.mjsindex 86a5b9a453..0a7f0c4b50 100644--- a/packages/cli/api/component/doc-links.test.mjs+++ b/packages/cli/api/component/doc-links.test.mjs@@ -219,6 +219,39 @@ describe("a link in a component doc's text", () => {});});+describe("doc tokens in a component doc's text", () => {+ it(+ 'render with no link beside them, in the read and in search, for the project in cwd',+ async () => {+ scaffold();+ fs.writeFileSync(path.join(tmpDir, 'bun.lock'), '{}\n');+ const docFile = path.join(+ tmpDir,+ 'node_modules/@acme/widgets/components/AcmeButton.doc.mjs',+ );+ fs.writeFileSync(+ docFile,+ `export default ${JSON.stringify({+ ...ACME_BUTTON,+ usage: {+ description:+ 'A button. Install with {@pm install @acme/widgets}; check with {@command doctor}.',+ },+ props: [],+ examples: [],+ })};\n`,+ );+ const read = /** @type {any} */ (+ await component('AcmeButton', {cwd: tmpDir})+ );+ expect(read.data.usage.description).toBe(+ 'A button. Install with `bun add @acme/widgets`; check with `astryx doctor`.',+ );+ },+ SLOW,+ );+});+describe("a link in a topic's description", () => {it('reads as the command that opens its doc, in the detail and the list',diff --git a/packages/cli/api/docs/_adapter.mjs b/packages/cli/api/docs/_adapter.mjsindex 9cb1cd44f2..793d3bac64 100644--- a/packages/cli/api/docs/_adapter.mjs+++ b/packages/cli/api/docs/_adapter.mjs@@ -46,6 +46,7 @@ import {linkBlocks,linkFields,parseLinkTarget,+ renderTokens,} from '../../foundation/doc-compiler/links.mjs';import {createDocId,@@ -315,7 +316,8 @@ function topicTextFields(doc) {* @returns {Promise<string>}*/export async function linkDocText(catalog, providerId, text) {- if (typeof text !== 'string' || !text.includes('{@link')) return text;+ if (typeof text !== 'string') return text;+ if (!text.includes('{@link')) return renderTokens(text);let provider;try {provider = normalizeProviderId(providerId);@@ -343,7 +345,8 @@ export async function linkDocText(catalog, providerId, text) {* @returns {Promise<{doc: T, problems: LinkProblem[]}>}*/export async function linkComponentDoc(catalog, providerId, doc) {- if (!JSON.stringify(doc ?? null).includes('{@link')) {+ // Doc tokens render in the same pass as links (resolveInline).+ if (!JSON.stringify(doc ?? null).includes('{@')) {return {doc, problems: []};}return linkFields(@@ -416,6 +419,7 @@ async function flatTopicInputs(catalog) {providerId: entry.providerId ?? entry.package,name: entry.name,title: title ?? entry.name,+ // Rendered once, with the tree's other summaries (buildProjectTree).summary: description ?? '',category: category ?? null,source: `${entry.package}:${entry.name}`,@@ -488,7 +492,7 @@ async function buildProjectTree(catalog, fresh) {// A summary is a doc's text too: each link in it reads as the command that// opens its doc, wherever the tree's summaries print (spec:AST-047 FR9).for (const node of result.nodes.values()) {- if (typeof node.summary === 'string' && node.summary.includes('{@link')) {+ if (typeof node.summary === 'string' && node.summary.includes('{@')) {const replacement = node.guideOverlay?.replacement;node.summary = await linkSummary(catalog,@@ -517,7 +521,7 @@ async function buildProjectTree(catalog, fresh) {* @returns {Promise<string>}*/async function linkSummary(catalog, tree, providerId, summary) {- if (!summary.includes('{@link')) return summary;+ if (!summary.includes('{@link')) return renderTokens(summary);let provider;try {provider = normalizeProviderId(providerId);@@ -674,7 +678,7 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {id: createDocId(provider, authored.type, authored.name),route: AUTHORING_REFERENCE_ROUTE,title: authored.displayName ?? authored.name,- summary: authored.description ?? '',+ summary: renderTokens(authored.description ?? ''),command: `astryx docs authoring ${authored.name}`,},kind: parsed.kind,@@ -732,13 +736,16 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {// The summary is the target doc's own text, so its links resolve// against the target's provider, never the linking doc's: a Core// component's against the CLI's docs, like its other fields.- if (summaries && link.summary.includes('{@link')) {+ // contributedDocLink returns the authored text; it renders once here.+ if (summaries && link.summary.includes('{@')) {link.summary = await linkSummary(catalog,tree,provider === CORE_COMPONENT_PROVIDER ? CLI_PROVIDER_ID : provider,link.summary,);+ } else {+ link.summary = renderTokens(link.summary);}return {link: {target, ...link}, kind: parsed.kind, typed: null};}diff --git a/packages/cli/api/docs/docOverlays.test.mjs b/packages/cli/api/docs/docOverlays.test.mjsindex 42f663f5f2..bf28be4887 100644--- a/packages/cli/api/docs/docOverlays.test.mjs+++ b/packages/cli/api/docs/docOverlays.test.mjs@@ -176,8 +176,9 @@ describe('the reported defect: docs tokens --dense (#2182)', () => {for (const options of [{}, {dense: true}, {zh: true}]) {const result = await docs('theme', null, options);const rendered = JSON.stringify(result.data.sections);+ // The command, as `{@command …}` or bare `astryx …`: both print it.expect(rendered).toContain(- 'astryx theme palette generate palette.config.json --out palette.generated.ts',+ 'theme palette generate palette.config.json --out palette.generated.ts',);expect(rendered).toContain("import {palette} from './palette.generated';",diff --git a/packages/cli/api/docs/docs.mjs b/packages/cli/api/docs/docs.mjsindex e8831b3a6a..aa3e7f663f 100644--- a/packages/cli/api/docs/docs.mjs+++ b/packages/cli/api/docs/docs.mjs@@ -23,18 +23,50 @@* overlay loading, and resolution they share sit in _adapter.mjs.*/-import {list} from './list/list.mjs';-import {index} from './index/index.mjs';-import {detail} from './detail/detail.mjs';+import {list as listRead} from './list/list.mjs';+import {index as indexRead} from './index/index.mjs';+import {detail as detailRead} from './detail/detail.mjs';import {namespaceSection,- section as sectionLeaf,+ section as sectionRead,} from './detail/section/section.mjs';-import {node as nodeLeaf, nodeView} from './node/node.mjs';+import {node as nodeRead, nodeView} from './node/node.mjs';import {resolveDocsArgument} from './_adapter.mjs';import {AstryxError} from '../error.mjs';import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';-import {formatCliCommand} from '../../foundation/env/package-manager.mjs';+import {+ docPackageManager,+ formatCliCommand,+ runWithDocPackageManager,+} from '../../foundation/env/package-manager.mjs';++/**+ * Run a docs read with `{@pm}` steps rendered for the project in `cwd`, the+ * folder the read is about, not the process's working directory. A host that+ * already chose a package manager keeps its choice.+ * @template T+ * @param {string | undefined} cwd+ * @param {() => T} fn+ * @returns {T}+ */+function inProject(cwd, fn) {+ return runWithDocPackageManager(docPackageManager(cwd ?? process.cwd()), fn);+}++/** @type {typeof listRead} */+const list = (options = {}) => inProject(options?.cwd, () => listRead(options));+/** @type {typeof indexRead} */+const index = (topic, options = {}) =>+ inProject(options?.cwd, () => indexRead(topic, options));+/** @type {typeof detailRead} */+const detail = (topic, options = {}) =>+ inProject(options?.cwd, () => detailRead(topic, options));+/** @type {typeof sectionRead} */+const sectionLeaf = (topic, sectionName, options = {}) =>+ inProject(options?.cwd, () => sectionRead(topic, sectionName, options));+/** @type {typeof nodeRead} */+const nodeLeaf = (route, options = {}) =>+ inProject(options?.cwd, () => nodeRead(route, options));export {list, index, detail, sectionLeaf as section, nodeLeaf as node};@@ -98,6 +130,23 @@ function depthRead(options) {* >}*/export async function docs(topic, section, options = {}) {+ return inProject(options.cwd, () => docsRead(topic, section, options));+}++/**+ * The docs read itself, inside its project's package-manager scope.+ * @param {string} [topic]+ * @param {string} [section]+ * @param {any} [options]+ * @returns {Promise<+ * import('./docs.type.mjs').DocsListResponse |+ * import('./docs.type.mjs').DocsIndexResponse |+ * import('./docs.type.mjs').DocsDetailResponse |+ * import('./docs.type.mjs').DocsDetailSectionResponse |+ * import('./docs.type.mjs').DocsNodeResponse+ * >}+ */+async function docsRead(topic, section, options = {}) {const read = depthRead(options);if (!topic) return list(options);const found = await resolveDocsArgument(topic, options);diff --git a/packages/cli/api/docs/guide-route-targets.test.mjs b/packages/cli/api/docs/guide-route-targets.test.mjsindex ea61b8395e..47292341b2 100644--- a/packages/cli/api/docs/guide-route-targets.test.mjs+++ b/packages/cli/api/docs/guide-route-targets.test.mjs@@ -296,6 +296,7 @@ describe('a flat topic that extends a placed guide by its route', () => {expect(validated.data.notes).toContainEqual({code: 'doc_section_unplaced',message: expect.stringContaining('"no-such-section"'),+ next: true,});const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});expect(docsCheck.data.issues).toEqual([]);@@ -361,6 +362,7 @@ describe('a route that holds no guide', () => {expect(validated.data.notes).toContainEqual({code: 'doc_target_not_found',message: expect.stringContaining('"authoring/no-such-guide"'),+ next: true,});const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});expect(docsCheck.data.issues).toEqual([]);@@ -604,6 +606,7 @@ describe('review follow-ups', () => {expect(validated.data.notes).toContainEqual({code: 'duplicate_guide_replacement',message: expect.stringContaining('"acme-b", is read'),+ next: true,});const check = await integrationCheck({cwd: kitDir(), strict: true});expect(check.data.failed).toBe(false);@@ -756,6 +759,7 @@ describe('third review follow-ups', () => {expect(validated.data.notes).toContainEqual({code: 'duplicate_guide_replacement',message: expect.stringContaining('"acme-b", is read'),+ next: true,});},SLOW,diff --git a/packages/cli/api/docs/integration-tree.test.mjs b/packages/cli/api/docs/integration-tree.test.mjsindex 90e29a9fe6..dcd76df116 100644--- a/packages/cli/api/docs/integration-tree.test.mjs+++ b/packages/cli/api/docs/integration-tree.test.mjs@@ -189,6 +189,28 @@ describe('integration docs in the docs tree', () => {).toEqual(['acme/setup', 'acme/deploy']);}, SLOW);+ it('renders a placed guide summary once, so an escaped token stays written', async () => {+ scaffold({+ ...kit(),+ 'deploy.doc.mjs': guide('deploy', {+ description: 'Show the syntax {@@pm run build} beside {@pm run build}.',+ placement: {parent: 'namespace:acme', slot: 'guides', order: 2},+ }),+ });+ const top = await docs('acme', undefined, {cwd: tmpDir});+ const deploy = top.data.slots[0].children.find((/** @type {any} */ c) => c.route === 'acme/deploy');+ expect(deploy.summary).toMatch(/^Show the syntax \{@pm run build\} beside `\S+ run build`\.$/);+ }, SLOW);++ it('renders a flat topic summary once, so an escaped token stays written', async () => {+ scaffold({+ ...kit(),+ 'notes.doc.mjs': {...kit()['notes.doc.mjs'], description: 'Show the syntax {@@pm run build} beside {@pm run build}.'},+ });+ const listed = await docs('guides', undefined, {cwd: tmpDir});+ expect(JSON.stringify(listed.data)).toContain('Show the syntax {@pm run build} beside `');+ }, SLOW);+it('reads a placed guide one level at a time, with its links resolved', async () => {scaffold(kit());const index = await docs('acme/setup', undefined, {cwd: tmpDir, index: true});diff --git a/packages/cli/api/docs/integrationDocs.test.mjs b/packages/cli/api/docs/integrationDocs.test.mjsindex 53789626b2..2e4347a183 100644--- a/packages/cli/api/docs/integrationDocs.test.mjs+++ b/packages/cli/api/docs/integrationDocs.test.mjs@@ -164,6 +164,46 @@ describe('integration-contributed topics', () => {expect(prose).not.toContain('{@link');}, SLOW);+ it('renders a linked component or template summary once, so an escaped token stays written', async () => {+ scaffold({+ 'using-widgets.doc.mjs': topic({+ name: 'using-widgets',+ title: 'Using widgets',+ sections: [+ {+ title: 'Overview',+ content: [+ {type: 'reference', target: 'component:AcmeButton'},+ {type: 'reference', target: 'block:acme-card'},+ ],+ },+ ],+ }),+ });+ const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');+ fs.writeFileSync(+ path.join(pkgDir, 'astryx.integration.mjs'),+ "export default {components: './components', templates: './templates', docs: './docs'};\n",+ );+ fs.mkdirSync(path.join(pkgDir, 'components'));+ fs.writeFileSync(+ path.join(pkgDir, 'components', 'AcmeButton.doc.mjs'),+ "export default {type: 'component', name: 'AcmeButton', displayName: 'Acme Button', description: 'Shows {@@pm run build}.', props: []};\n",+ );+ fs.writeFileSync(path.join(pkgDir, 'components', 'AcmeButton.tsx'), 'export function AcmeButton() { return null; }\n');+ fs.mkdirSync(path.join(pkgDir, 'templates'));+ fs.writeFileSync(+ path.join(pkgDir, 'templates', 'acme-card.doc.mjs'),+ "export default {type: 'block', name: 'Acme card', description: 'Card for {@@pm run build}.'};\n",+ );+ fs.writeFileSync(path.join(pkgDir, 'templates', 'acme-card.tsx'), 'export default function Fixture() { return null; }\n');++ const detail = await docs('using-widgets', undefined, {cwd: tmpDir, full: true});+ const text = JSON.stringify(detail.data);+ expect(text).toContain('Shows {@pm run build}.');+ expect(text).toContain('Card for {@pm run build}.');+ }, SLOW);+it('selects Core in a link only where the bare name would open something else', async () => {const core = await discoverCoreTemplates();const page = core.find(template => template.type === 'page')?.dirName;@@ -459,3 +499,48 @@ describe('integration-contributed topics', () => {expect(catalog.resolve('deploying')).toBeUndefined();}, SLOW);});++describe('doc tokens in a contributed topic', () => {+ it(+ 'render in the list, the read and search, for the project the read is about',+ async () => {+ scaffold({+ 'deploying.doc.mjs': topic({+ description:+ 'Install with {@pm install @acme/widgets}, then run {@command doctor}.',+ sections: [+ {+ title: 'Overview',+ content: [{type: 'prose', text: 'Run {@command doctor} first.'}],+ },+ ],+ }),+ });+ // The project in tmpDir uses Bun; the process's own folder uses pnpm.+ fs.writeFileSync(path.join(tmpDir, 'bun.lock'), '{}\n');++ const listed = await docs(undefined, undefined, {cwd: tmpDir});+ const entry = listed.data.find(t => t.topic === 'deploying');+ expect(entry.description).toBe(+ 'Install with `bun add @acme/widgets`, then run `astryx doctor`.',+ );+ const detail = await docs('deploying', undefined, {+ cwd: tmpDir,+ full: true,+ });+ expect(JSON.stringify(detail)).not.toContain('{@');+ expect(detail.data.sections[0].content[0].text).toBe(+ 'Run `astryx doctor` first.',+ );+ // Core's own docs show tokens as written on purpose; this topic's render.+ const found = await search('deploying', {cwd: tmpDir, type: 'doc'});+ const hit = found.data.results.find(+ (/** @type {any} */ result) => result.name === 'deploying',+ );+ expect(hit.description).toBe(+ 'Install with `bun add @acme/widgets`, then run `astryx doctor`.',+ );+ },+ SLOW,+ );+});diff --git a/packages/cli/api/doctor/doctor.doc.mjs b/packages/cli/api/doctor/doctor.doc.mjsindex f6964f081b..d155db8851 100644--- a/packages/cli/api/doctor/doctor.doc.mjs+++ b/packages/cli/api/doctor/doctor.doc.mjs@@ -24,7 +24,7 @@ export const doc = {'integration provider identity and contribution issues, agent docs, the ' +'detected package manager, and the health of the docs the CLI reads (authoring ' +'and CLI docs, the docs tree, doc size), and returns a structured ' +- 'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `astryx init --user` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `npm i -g @astryxdesign/cli@latest`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' ++ 'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `{@command init --user}` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `{@pm install @astryxdesign/cli@latest --global}`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +' In global mode: with `cwd` outside a project, it checks the computer instead (the Node version, the version that answered, the newest version it knows of, the astryx commands on the search path, the integrations installed globally, and the agent guide for the computer) and never fails a check because the folder has no project. See {@link namespace:global} and {@link generic:who-answers}.',importPath: '@astryxdesign/cli/api',signature: 'doctor(options?: DoctorOptions): Promise<DoctorResponse>',diff --git a/packages/cli/api/integration/_adapter.mjs b/packages/cli/api/integration/_adapter.mjsindex ffabbfcb6d..f42e2bef02 100644--- a/packages/cli/api/integration/_adapter.mjs+++ b/packages/cli/api/integration/_adapter.mjs@@ -20,7 +20,7 @@ import {packageDocTargets} from '../docs/_adapter.mjs';import {comparePropDocs} from '../../foundation/discovery/prop-drift.mjs';import {findCopiedPassages} from '../../foundation/discovery/copied-passages.mjs';import {findFluff} from '../../foundation/discovery/doc-fluff.mjs';-import {findRunnerCommands} from '../../foundation/discovery/runner-commands.mjs';+import {findDocCommands} from '../../foundation/discovery/runner-commands.mjs';import {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';/**@@ -140,18 +140,19 @@ export async function integrationDocTargets(integration) {}/**- * Each Astryx command a package's topics write with a package runner. A+ * The doc-syntax findings in a package's topics: commands written with a+ * runner, for one package manager, or bare, and tokens that do not parse. A* package whose topics cannot be discovered has none here: the other checks* report topics that do not load.* @param {any} integration a loaded integration* @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}*/-export async function integrationRunnerCommands(integration) {+export async function integrationDocCommands(integration) {let discovered;try {discovered = await discoverIntegrationDocs(integration);} catch {return [];}- return findRunnerCommands(discovered);+ return findDocCommands(discovered);}diff --git a/packages/cli/api/integration/authoring-checks.test.mjs b/packages/cli/api/integration/authoring-checks.test.mjsindex da4258f5ae..25676b8dc5 100644--- a/packages/cli/api/integration/authoring-checks.test.mjs+++ b/packages/cli/api/integration/authoring-checks.test.mjs@@ -1401,7 +1401,7 @@ describe('validateIntegration runner-command notes', () => {line: 1,command: 'pnpm exec astryx doctor',});- expect(hit.message).toContain('Write `astryx doctor`');+ expect(hit.message).toContain('Write the token `{@command doctor}`');// A note only: no issue, so no exit changes on it.expect(data.issues.map((/** @type {any} */ issue) => issue.code),@@ -1544,6 +1544,136 @@ describe('validateIntegration runner-command notes', () => {);});+ it('lists package-manager commands, bare commands and broken tokens with the token to write, all for the next minor', async () => {+ writeTopic(+ 'Add it with `npm install -D @acme/widgets`, run `astryx search acme`, then {@pm add x} and {@cmd docs}. Only npm: `npm pkg set name=x`.',+ );++ const {data} = await validateIntegration(undefined, {cwd: tmpDir});+ const notes = (data.notes ?? []).filter(+ (/** @type {any} */ note) => note.code !== 'runner_command',+ );++ expect(+ notes.map((/** @type {any} */ note) => [note.code, note.next]),+ ).toEqual([+ ['package_manager_command', true],+ ['plain_command', true],+ ['doc_token', true],+ ['doc_token', true],+ ['package_manager_command', true],+ // The fixture's install step, in its bash block.+ ['package_manager_command', true],+ ]);+ const messages = notes.map((/** @type {any} */ note) => note.message);+ expect(messages[0]).toContain('{@pm install @acme/widgets --dev}');+ expect(messages[1]).toContain('{@command search acme}');+ expect(messages[2]).toContain('{@pm}` starts with a verb');+ expect(messages[3]).toContain('Doc tokens are');+ expect(messages[4]).toContain(+ '{@pm-only npm "<why only npm>" pkg set name=x}',+ );+ expect(messages[5]).toContain('{@pm dlx @astryxdesign/cli init}');+ expect(data.issues.map((/** @type {any} */ issue) => issue.code)).toEqual(+ [],+ );+ });++ it('reads a verb named alone as a mention, and TSDoc tags in a TypeScript sample as code', async () => {+ writeTopic(+ 'Scripts run with `npm run`, `pnpm dlx` fetches a package, and `npm i -g`, `yarn global add` and `npm pkg set` each take one.',+ );+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');+ fs.writeFileSync(+ file,+ fs.readFileSync(file, 'utf8').replace(+ /\{"type":"code"[^}]*\}/,+ JSON.stringify({+ type: 'code',+ lang: 'ts',+ code: '/** {@inheritDoc Base.render} */\nexport const x = 1;',+ }),+ ),+ );++ const {data} = await validateIntegration(undefined, {cwd: tmpDir});+ expect(+ (data.notes ?? []).filter((/** @type {any} */ note) =>+ ['package_manager_command', 'doc_token'].includes(note.code),+ ),+ ).toEqual([]);+ });++ it('lists a token that never closes, in prose and in any code block', async () => {+ writeTopic(+ 'Install with {@pm install @acme/widgets --dev before you start.',+ );+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');+ fs.writeFileSync(+ file,+ fs.readFileSync(file, 'utf8').replace(+ /\{"type":"code"[^}]*\}/,+ JSON.stringify({+ type: 'code',+ lang: 'tsx',+ code: '// {@pm install @acme/widgets --dev\nexport const x = 1;',+ }),+ ),+ );++ const {data} = await validateIntegration(undefined, {cwd: tmpDir});+ const tokens = (data.notes ?? []).filter(+ (/** @type {any} */ note) => note.code === 'doc_token',+ );+ expect(tokens).toHaveLength(2);+ expect(tokens[0].message).toContain('never closes');+ });++ it('lists a {@command} token that names no Astryx command', async () => {+ writeTopic('Run {@command dcotor} before you ship.');++ const {data} = await validateIntegration(undefined, {cwd: tmpDir});+ const tokens = (data.notes ?? []).filter(+ (/** @type {any} */ note) => note.code === 'doc_token',+ );+ expect(tokens).toHaveLength(1);+ expect(tokens[0].message).toContain('`dcotor` is not an Astryx command');+ });++ it('reads the command after leading global flags in a {@command} token', async () => {+ writeTopic(+ 'Read it as data with {@command --json component Button} or {@command --detail full docs acme}, not {@command --json dcotor}, {@command --json nosuch docs} or {@command --detail full nosuch}. Check the version with {@command --version}; {@command --json} alone names nothing.',+ );+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});+ const tokens = (data.notes ?? []).filter(+ (/** @type {any} */ note) => note.code === 'doc_token',+ );+ expect(+ tokens.map(note => note.message.match(/`(\w+)` is not/)?.[1]),+ ).toEqual(['dcotor', 'nosuch', 'nosuch', undefined]);+ expect(tokens[3].message).toContain('names no Astryx command');+ });++ it('lists nothing for a topic written in the doc syntax', async () => {+ writeTopic(+ 'Add it with {@pm install @acme/widgets --dev}, run {@command docs acme}, and {@pm-only npm "only npm has pkg" pkg set name=x}. Show the syntax: {@@pm install x}.',+ );+ // The fixture's bash block holds a scoped install step; write it as a token.+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');+ fs.writeFileSync(+ file,+ fs+ .readFileSync(file, 'utf8')+ .replace(+ 'npx @astryxdesign/cli init',+ '{@pm dlx @astryxdesign/cli init}',+ ),+ );++ const {data} = await validateIntegration(undefined, {cwd: tmpDir});+ expect(data.notes ?? []).toEqual([]);+ });+it('lists nothing for bare commands and the scoped install step', async () => {writeTopic('Check it with `astryx doctor` first.');diff --git a/packages/cli/api/integration/check/check.mjs b/packages/cli/api/integration/check/check.mjsindex 10aac71685..7a8c2ae15c 100644--- a/packages/cli/api/integration/check/check.mjs+++ b/packages/cli/api/integration/check/check.mjs@@ -11,7 +11,10 @@* any warning and on any check, or comparison a check carries, that did not* run, so a package can gate its build on its docs staying in sync. `--strict`* adds no check: it reports the same warnings and skipped work again, as- * errors in the checks' own issue format, and fails on them.+ * errors in the checks' own issue format, and fails on them. `--next` counts+ * the findings the next minor release turns into warnings (validate's notes+ * marked `next`) as warnings now, so a package can fix them ahead of the+ * release; every run reports how many there are.** What fails it is a contract for the builds that run it: a new check, or a* new failure code, joins only in a minor release that names it.@@ -236,7 +239,7 @@ export function summarizeCheck(response, context = {}) {* @returns {Promise<IntegrationCheckCommandResponse>}*/export async function integrationCheck(options = {}) {- const {cwd = process.cwd(), strict = false} = options;+ const {cwd = process.cwd(), strict = false, next = false} = options;// One after another: each loads the package through the same discovery./** @type {IntegrationCheckResponse[]} */const responses = [];@@ -253,7 +256,8 @@ export async function integrationCheck(options = {}) {name: validation.data.name,version: validation.data.version,strict,- ...combineChecks(responses, strict),+ next,+ ...combineChecks(responses, strict, next),},};}@@ -265,8 +269,10 @@ export async function integrationCheck(options = {}) {* on its own, so two findings with one message stay two.* @param {IntegrationCheckResponse[]} responses validate first* @param {boolean} strict+ * @param {boolean} [next] count validate's notes marked `next`, the findings+ * the next minor release turns into warnings, as warnings now*/-export function combineChecks(responses, strict) {+export function combineChecks(responses, strict, next = false) {const [validation] = responses;// Only validate reports a missing package.json; the other checks read it// from there instead of each naming a missing manifest.@@ -345,12 +351,36 @@ export function combineChecks(responses, strict) {if (strict) failures.push({check, severity: 'error', ...issue});}});+ // The findings the next minor release turns into warnings: always counted,+ // so the default run can say how many there are, and with `next` counted+ // as warnings now.+ const notes =+ /** @type {{notes?: Array<{code: string, message: string, next?: boolean}>}} */ (+ validation.data+ ).notes ?? [];+ const upcoming = notes.filter(note => note.next === true);+ if (next) {+ warnings += upcoming.length;+ // validate's own row counts them too, so the summary shows what fails.+ checks[0].warnings += upcoming.length;+ if (strict) {+ for (const note of upcoming) {+ failures.push({+ check: 'validate',+ severity: 'error',+ code: note.code,+ message: note.message,+ });+ }+ }+ }return {checks,errors,warnings,skipped,unchecked,+ upcoming: upcoming.length,failures,failed: checks.some(check => check.failed) || failures.length > 0,};diff --git a/packages/cli/api/integration/check/check.test.mjs b/packages/cli/api/integration/check/check.test.mjsindex fad6521e5d..b97d2e549a 100644--- a/packages/cli/api/integration/check/check.test.mjs+++ b/packages/cli/api/integration/check/check.test.mjs@@ -276,6 +276,55 @@ describe('combineChecks', () => {respond('integration.doc-conflicts', {}),];+ it('counts the findings the next minor release fails as upcoming, and fails on them only with strict and next', () => {+ const withNotes = [+ respond('integration.validate', {+ notes: [+ {+ code: 'duplicate_component_doc',+ message: 'Two docs. Fix: one.',+ next: true,+ },+ {code: 'invalid_cli_command', message: 'Not a command.'},+ ],+ }),+ respond('integration.component-conflicts', {}),+ respond('integration.template-conflicts', {}),+ respond('integration.doc-conflicts', {}),+ ];+ // The default run, strict included, fails on none: the next minor does.+ for (const strict of [false, true]) {+ expect(combineChecks(withNotes, strict)).toMatchObject({+ upcoming: 1,+ warnings: 0,+ failures: [],+ failed: false,+ });+ }+ expect(combineChecks(withNotes, false, true)).toMatchObject({+ upcoming: 1,+ warnings: 1,+ failures: [],+ failed: false,+ });+ // validate's own summary row shows the note it now counts.+ expect(combineChecks(withNotes, false, true).checks[0].warnings).toBe(1);+ expect(combineChecks(withNotes, false).checks[0].warnings).toBe(0);+ expect(combineChecks(withNotes, true, true)).toMatchObject({+ upcoming: 1,+ warnings: 1,+ failures: [+ {+ check: 'validate',+ severity: 'error',+ code: 'duplicate_component_doc',+ message: 'Two docs. Fix: one.',+ },+ ],+ failed: true,+ });+ });+it('counts a package-level issue once, and two findings with one message twice, naming each component', () => {const loose = combineChecks(responses, false);const strict = combineChecks(responses, true);diff --git a/packages/cli/api/integration/integration-check.type.mjs b/packages/cli/api/integration/integration-check.type.mjsindex 82d3816a87..90b690351d 100644--- a/packages/cli/api/integration/integration-check.type.mjs+++ b/packages/cli/api/integration/integration-check.type.mjs@@ -11,6 +11,9 @@* current directory by default.* @property {boolean} [strict] Also fail on any warning and on any check that* did not run, not only on errors.+ * @property {boolean} [next] Also count each finding the next minor release+ * turns into a warning (a note marked `next`) as a warning now, so `strict`+ * fails on it.*//**@@ -78,7 +81,7 @@* @property {'integration.check'} type* `unchecked` counts the items the checks list as not compared, which never* fail it.- * @property {{validated: boolean, name: string | null, version: string | null, strict: boolean, checks: IntegrationCheckResult[], errors: number, warnings: number, skipped: string[], unchecked: number, failures: IntegrationCheckFailure[], failed: boolean}} data+ * @property {{validated: boolean, name: string | null, version: string | null, strict: boolean, next: boolean, checks: IntegrationCheckResult[], errors: number, warnings: number, skipped: string[], unchecked: number, upcoming: number, failures: IntegrationCheckFailure[], failed: boolean}} data*/export {};diff --git a/packages/cli/api/integration/integrationCheck.doc.mjs b/packages/cli/api/integration/integrationCheck.doc.mjsindex 313d2e6662..456dd8c846 100644--- a/packages/cli/api/integration/integrationCheck.doc.mjs+++ b/packages/cli/api/integration/integrationCheck.doc.mjs@@ -44,12 +44,19 @@ export const doc = {description:'Also fail on any warning and on any check that did not run, not only on errors. A malformed `cliCommand` is reported as a note (`invalid_cli_command`) in `data.notes` of the validate check, which fails nothing until a minor release names it.',},+ {+ name: 'options.next',+ type: 'boolean',+ default: 'false',+ description:+ "Also count the findings the next minor release turns into warnings, validate's notes marked `next`, as warnings now, so `strict` fails on them.",+ },],returns: [{type: 'integration.check',description:- "`data.validated` (false when no integration manifest was found, so nothing was checked), `data.name` and `data.version` of the package, `data.strict`, and `data.checks`, one entry per check in the order they run (`validate`, `components`, `templates`, `docs`), each with `check`, `errors` (what makes that check's own subcommand exit 1), `warnings`, `skipped` (why work did not run), `failed` (whether that subcommand exits 1), and `response`, the envelope the check returns on its own. The totals are `data.errors`, `data.warnings`, and `data.skipped` (each reason prefixed with its check); an issue every check starts from, such as one about the manifest, counts once, and every other finding counts on its own. `data.unchecked` counts the items the checks list as not compared, which never fail it. With `strict`, `data.failures` lists each warning and each piece of skipped work once again as an error in the checks' own issue format ({check, severity: `error`, code, message, component, prop, fix, file, line}, each where it applies); it is empty without `strict`. `data.failed` decides the exit code.",+ "`data.validated` (false when no integration manifest was found, so nothing was checked), `data.name` and `data.version` of the package, `data.strict`, `data.next`, and `data.checks`, one entry per check in the order they run (`validate`, `components`, `templates`, `docs`), each with `check`, `errors` (what makes that check's own subcommand exit 1), `warnings`, `skipped` (why work did not run), `failed` (whether that subcommand exits 1), and `response`, the envelope the check returns on its own. The totals are `data.errors`, `data.warnings`, and `data.skipped` (each reason prefixed with its check); an issue every check starts from, such as one about the manifest, counts once, and every other finding counts on its own. `data.unchecked` counts the items the checks list as not compared, which never fail it. `data.upcoming` counts the findings the next minor release turns into warnings (validate's notes marked `next`), and `data.next` says whether this run counted them as warnings now. With `strict`, `data.failures` lists each warning and each piece of skipped work once again as an error in the checks' own issue format ({check, severity: `error`, code, message, component, prop, fix, file, line}, each where it applies); it is empty without `strict`. `data.failed` decides the exit code.",},],examples: [diff --git a/packages/cli/api/integration/integrationDocConflicts.doc.mjs b/packages/cli/api/integration/integrationDocConflicts.doc.mjsindex 9b1daec7a9..a6240bf932 100644--- a/packages/cli/api/integration/integrationDocConflicts.doc.mjs+++ b/packages/cli/api/integration/integrationDocConflicts.doc.mjs@@ -19,7 +19,7 @@ export const doc = {"package's topics, or one of them and a Core topic other than the one it replaces. " +'Code and examples are not compared. `fluff` lists each padding phrase, with its file ' +'line, and each topic of 80 or more prose words in which fewer than half carry content. ' +- '`strayPointers` lists each code span that is exactly `astryx docs <name>` for a doc that ' ++ '`strayPointers` lists each code span that is exactly `{@command docs <name>}` for a doc that ' +"exists, in a topic's prose, description or summary or a component doc's text fields, " +'with the `{@link}` that replaces it. ' +'Each entry of these lists is also a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`), so ' +diff --git a/packages/cli/api/integration/pack-check.mjs b/packages/cli/api/integration/pack-check.mjsindex ee3f8d942d..5b9826b16e 100644--- a/packages/cli/api/integration/pack-check.mjs+++ b/packages/cli/api/integration/pack-check.mjs@@ -25,6 +25,7 @@ import * as os from 'node:os';import {fileURLToPath} from 'node:url';import {spawnSync} from 'node:child_process';import {assertWithin} from '../../foundation/fs/path-safety.mjs';+import {commandTokensIn} from '../../foundation/doc-compiler/doc-syntax.mjs';import {resolvePackageDir} from '../../foundation/integrations/integrations.mjs';import {literalThemeName,@@ -37,6 +38,7 @@ import {keywordsCliProblem,replacesCliProblem,sectionIdsCliProblem,+ docTokensCliProblem,sectionPositionCliProblem,themesCliProblem,} from '../../foundation/integrations/cli-requirement.mjs';@@ -323,6 +325,23 @@ function extractTarball(tgzPath, extractDir) {}}+/**+ * Whether any of these doc files writes a doc token (`{@command …}`, `{@pm …}`+ * or `{@pm-only …}`; an escaped `{@@…}` is not one).+ * @param {unknown[]} files+ * @returns {boolean}+ */+function writesDocTokens(files) {+ return files.some(file => {+ if (typeof file !== 'string') return false;+ try {+ return commandTokensIn(fs.readFileSync(file, 'utf8')).length > 0;+ } catch {+ return false;+ }+ });+}+/*** Whether any of these doc files has a section that sets `id`.* @param {string[]} files@@ -1414,6 +1433,20 @@ export async function integrationPackCheck(options = {}) {issues.push(warning('section_position_needs_cli', positionProblem));}}+ // A doc token shows as written on a CLI before the one that renders+ // them. Added in a patch release, it warns and never fails (INV35).+ if (+ problem == null &&+ writesDocTokens([+ ...records.map(record => record.path),+ ...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),+ ])+ ) {+ const tokenProblem = docTokensCliProblem(pkg);+ if (tokenProblem != null) {+ issues.push(warning('doc_tokens_need_cli', tokenProblem));+ }+ }}// A template that sets `replaces` (spec:AST-035) or `keywords` needs a CLI// that reads the field: an older CLI drops that template and can hide thediff --git a/packages/cli/api/integration/pack-check.test.mjs b/packages/cli/api/integration/pack-check.test.mjsindex 46f471daca..5d1faea9cd 100644--- a/packages/cli/api/integration/pack-check.test.mjs+++ b/packages/cli/api/integration/pack-check.test.mjs@@ -1757,6 +1757,36 @@ describe('integrationPackCheck', () => {expect(await issues()).toEqual([]);}, 120_000);+ it('warns when a package whose docs write doc tokens has a CLI range that prints them raw', async () => {+ writePackage({+ manifest: "export default {docs: './docs'};\n",+ themes: false,+ });+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});+ const write = (/** @type {string} */ name, /** @type {string} */ text) =>+ fs.writeFileSync(+ path.join(tmpDir, 'docs', `${name}.doc.mjs`),+ `export default {type: 'generic', name: '${name}', title: 'Notes', description: 'Notes.', sections: [{title: 'Run', content: [{type: 'prose', text: ${JSON.stringify(text)}}]}]};\n`,+ );+ const found = async () =>+ (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(+ (/** @type {{code: string}} */ issue) => issue.code === 'doc_tokens_need_cli',+ );+ // An escaped token is shown as written by every release.+ write('escaped', 'Write {@@pm install x} for an install.');+ expect(await found()).toEqual([]);+ write('tokens', 'Run {@command doctor} first.');+ expect((await found()).map((/** @type {any} */ issue) => issue.severity)).toEqual(['warning']);+ const pkgFile = path.join(tmpDir, 'package.json');+ const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.3'};+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);+ expect(await found()).toHaveLength(1);+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);+ expect(await found()).toEqual([]);+ }, 120_000);+it('fails a package with a template that sets replaces on a CLI range that rejects the field', async () => {writePackage({manifest: "export default {templates: './templates'};\n",diff --git a/packages/cli/api/integration/validate-integration-case-disk.test.mjs b/packages/cli/api/integration/validate-integration-case-disk.test.mjsindex c9016c8904..75f90f2f33 100644--- a/packages/cli/api/integration/validate-integration-case-disk.test.mjs+++ b/packages/cli/api/integration/validate-integration-case-disk.test.mjs@@ -73,6 +73,7 @@ describe('a doc whose name differs from its source only in case, on a case-insenexpect(data.notes).toEqual([{code: 'source_without_component_doc',+ next: true,message:'Component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run, so there the component is missing. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',},@@ -103,6 +104,7 @@ describe('a doc whose name differs from its source only in case, on a case-insenexpect(data.notes).toEqual([{code: 'source_without_component_doc',+ next: true,message:'Hidden component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',},diff --git a/packages/cli/api/integration/validate-integration-gaps.test.mjs b/packages/cli/api/integration/validate-integration-gaps.test.mjsindex 467dc8f246..1a2596a194 100644--- a/packages/cli/api/integration/validate-integration-gaps.test.mjs+++ b/packages/cli/api/integration/validate-integration-gaps.test.mjs@@ -185,7 +185,7 @@ describe('a name that differs from its file name', () => {expect(await issuesOf(dir)).toEqual([]);const issues = await allOf(dir);expect(issues.map(issue => issue.code)).toEqual(['doc_name_mismatch']);- expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message']);+ expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message', 'next']);expect(issues[0].message).toBe('Component doc "AcmeWidget.doc.mjs" sets name: \'AcmeWidgets\', but components/AcmeWidget.tsx, the module its import names, does not export AcmeWidgets, so Astryx lists the component as "AcmeWidget" (its file name), and `astryx component AcmeWidget` prints `import {AcmeWidgets}`. Fix: set name: \'AcmeWidget\' in AcmeWidget.doc.mjs.',);@@ -1369,6 +1369,7 @@ describe('package.json', () => {expect('notes' in validate ? validate.notes : undefined).toEqual([{code: 'invalid_package_json',+ next: true,message:'package.json has no "name", so npm cannot pack or publish the package, and a project that installs it has no name to select it by. Fix: add "name": "@your-scope/your-package" to package.json.',},@@ -1892,7 +1893,9 @@ describe('layout findings 0.7.2 did not fail on', () => {);expect(validate.notes.length).toBeGreaterThan(0);for (const note of validate.notes) {- expect(Object.keys(note).sort()).toEqual(['code', 'message']);+ // Listed now, a warning from the next minor release: `next`.+ expect(Object.keys(note).sort()).toEqual(['code', 'message', 'next']);+ expect(note.next).toBe(true);expect(note.message).toContain('Fix: ');}} finally {@@ -1917,7 +1920,7 @@ describe('layout findings 0.7.2 did not fail on', () => {);expect(run.status, run.stderr).toBe(0);expect(run.stdout).toContain(- 'note (duplicate_component_doc): Component "AcmeWidget" has 2 docs:',+ 'note (duplicate_component_doc): [next minor] Component "AcmeWidget" has 2 docs:',);expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');});@@ -1968,7 +1971,7 @@ describe('name findings listed until the next minor release', () => {);expect(run.status, run.stderr).toBe(0);expect(run.stdout).toContain(- 'note (unknown_block_component): Template "account-card" names "AcmeGizmo" in componentsUsed',+ 'note (unknown_block_component): [next minor] Template "account-card" names "AcmeGizmo" in componentsUsed',);expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');});diff --git a/packages/cli/api/integration/validate-integration.mjs b/packages/cli/api/integration/validate-integration.mjsindex 175ec4e261..b1ea033be3 100644--- a/packages/cli/api/integration/validate-integration.mjs+++ b/packages/cli/api/integration/validate-integration.mjs@@ -38,8 +38,8 @@ import {normalizeProviderId} from '../../foundation/identity/provider-identity.mimport {integrationDocTypes} from '../docs/_adapter.mjs';import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';import {+ integrationDocCommands,integrationDocTargets,- integrationRunnerCommands,} from './_adapter.mjs';import {THEME_SLUG_RE,@@ -489,8 +489,11 @@ async function validateAtPackageDir(const publicImports = await publicImportIssues(packageDir, loaded);issues.push(...publicImports.issues);// Each finding is a note until the next minor makes it a warning.+ // Listed now, a warning from the next minor release: `next`.if (publicImports.notes.length > 0)- (result.notes ??= []).push(...publicImports.notes);+ (result.notes ??= []).push(+ ...publicImports.notes.map(note => ({...note, next: true})),+ );result.publicImports = publicImports.report;if (scanUnreachable) {issues.push(@@ -698,20 +701,23 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {}/**- * The runner-command notes for a package's topics: each Astryx command a topic- * writes with a package runner, where the doc file is, and the bare command to- * write.+ * The doc-syntax notes for a package's topics: each command a topic writes+ * with a runner (`runner_command`), for one package manager+ * (`package_manager_command`), or bare (`plain_command`), and each token that+ * does not parse (`doc_token`), with the file, line and what to write+ * instead. The next minor release turns them into warnings: `next`.* @param {any} integration a loaded integration- * @returns {Promise<Array<{code: string, message: string}>>}+ * @returns {Promise<Array<{code: string, message: string, next: true}>>}*/-async function runnerCommandNotes(integration) {+async function docCommandNotes(integration) {const packageDir = integration.__packageDir;- return (await integrationRunnerCommands(integration)).map(each => ({- code: 'runner_command',+ return (await integrationDocCommands(integration)).map(each => ({+ code: each.code,message:typeof packageDir === 'string'? `${path.relative(packageDir, each.file).split(path.sep).join('/')}: ${each.message}`: each.message,+ next: true,}));}@@ -807,21 +813,32 @@ export async function validateIntegration(pkg, options = {}) {// after the last minor release, each with its fix in the message, which// may not fail `--strict` until the next (architecture:cli-surface INV35):// the layout findings and the component names judged wrong.+ // A finding the next minor release turns into a warning is marked `next`:+ // `integration check --strict --next` fails on it today.const notes = result.found? [- ...(result.notes ?? []),+ // A malformed cliCommand fails --strict from the next minor+ // (spec:AST-081 FR5).+ ...(result.notes ?? []).map(note =>+ note.code === INVALID_CLI_COMMAND ? {...note, next: true} : note,+ ),...(result.listed ?? []).map(issue => ({code: issue.code,message: issue.message,+ next: true,})),- ...(names ?? []).flatMap(each => each.notes),+ ...(names ?? []).flatMap(each =>+ each.notes.map(note => ({...note, next: true})),+ ),]: [];- // Each Astryx command a topic writes with a package runner, as a- // `runner_command` note with its fix, the same way.+ // The doc-syntax findings in the package's topics, as `next` notes with+ // their fixes, the same way.if (integration?.docs) {- notes.push(...(await runnerCommandNotes(integration)));- notes.push(...(await docTargetNotes(integration)));+ notes.push(...(await docCommandNotes(integration)));+ notes.push(+ ...(await docTargetNotes(integration)).map(note => ({...note, next: true})),+ );}return {type: 'integration.validate',diff --git a/packages/cli/api/integration/validate-integration.type.mjs b/packages/cli/api/integration/validate-integration.type.mjsindex 53749b8823..92754f9c59 100644--- a/packages/cli/api/integration/validate-integration.type.mjs+++ b/packages/cli/api/integration/validate-integration.type.mjs@@ -39,9 +39,12 @@* "healthy" — the two are otherwise byte-identical.* @typedef {object} ValidateIntegrationResponse* @property {'integration.validate'} type- * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, publicImports?: PublicImportsReport}} data- * `notes`: information beside the issues that fails nothing, such as- * `invalid_cli_command`, a `cliCommand` that was ignored as malformed;+ * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string, next?: boolean}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, publicImports?: PublicImportsReport}} data+ * `notes`: information beside the issues. A note fails nothing by default;+ * one with `next: true` counts as a warning under `integration check+ * --next`, fails `integration check --strict --next`, and fails `--strict`+ * from the next minor release. Notes include `invalid_cli_command`, a+ * `cliCommand` that was ignored as malformed;* `cli_peer_version`, the running CLI outside the package's* `@astryxdesign/cli` peer range; and* the package layout findings added after the last minor release, each with@@ -54,8 +57,10 @@* still pair (`source_without_component_doc`); `doc_name_mismatch` and* `unknown_block_component` (see `docNames` and `blockComponents`); and* since 0.7.3 each public-import finding; they become warnings in the next- * minor release; and `runner_command`, an Astryx command a topic writes- * with a package runner+ * minor release; and, for the commands a topic writes, `runner_command`+ * (written with a package runner), `plain_command` (written bare),+ * `package_manager_command` (written for one package manager) and+ * `doc_token` (a token that does not parse), each with the token to write*//**diff --git a/packages/cli/api/integration/validateIntegration.doc.mjs b/packages/cli/api/integration/validateIntegration.doc.mjsindex 6981dc5403..ac40feea5a 100644--- a/packages/cli/api/integration/validateIntegration.doc.mjs+++ b/packages/cli/api/integration/validateIntegration.doc.mjs@@ -62,7 +62,7 @@ export const doc = {{type: 'integration.validate',description:- "The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means \"not looked at\", not \"healthy\"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed and `cli_peer_version` when the running CLI is outside the `@astryxdesign/cli` peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. A `runner_command` note lists each Astryx command a topic writes with a package runner, with its file, line and the bare command to write. A `doc_target_not_found` note names a doc whose `replaces` or `extends` names no topic and no guide of the CLI's docs or the package's own (such as a namespace, with the guides below it), so it changes nothing unless an app also installs a package that provides it, and a `doc_section_unplaced` note a section whose `before` or `after` names no section of the topic or guide it extends, so it is added at the end, and a `duplicate_guide_replacement` note two docs of the package that replace one guide, of which only the last is read; they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `component_import_missing_name`, `example_import_not_exported`, `example_import_missing_name`, `template_import_not_exported`, `template_import_outside_root`, `template_private_import`, `template_import_missing_name` and `template_no_default_export`. When the manifest loads, `data.publicImports` is `{status: 'checked', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: an `exports` target not built yet; a module whose export list cannot be read in full (CommonJS, or a declaration file it cannot read); a root import in a package with no `exports` (the root module `main` names is not read); every name an import (other than a component doc's own component) names that its module does not export, while a TypeScript file in the package has a `declare module` block for a relative path or the package's own name or a subpath of it, which can add names to that module (a `declare module` in a comment, `declare global`, a wildcard such as `'*.css'`, and another package's name do not count; a file whose text has `declare module` but that cannot be parsed counts); the same for every such name when the package has more than 5,000 files to search for that block; a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package's own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.",+ "The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means \"not looked at\", not \"healthy\"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message, next?} information beside the issues; a note fails nothing by default, and one with `next: true` counts as a warning under `integration check --next`, fails `integration check --strict --next`, and fails `--strict` from the next minor release. Notes include `invalid_cli_command` for a `cliCommand` that was ignored as malformed and `cli_peer_version` when the running CLI is outside the `@astryxdesign/cli` peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. For the commands a topic writes, `runner_command` (written with a package runner), `plain_command` (written bare), `package_manager_command` (written for one package manager) and `doc_token` (a token that does not parse) notes each give the file, line and the token to write. A `doc_target_not_found` note names a doc whose `replaces` or `extends` names no topic and no guide of the CLI's docs or the package's own (such as a namespace, with the guides below it), so it changes nothing unless an app also installs a package that provides it, and a `doc_section_unplaced` note a section whose `before` or `after` names no section of the topic or guide it extends, so it is added at the end, and a `duplicate_guide_replacement` note two docs of the package that replace one guide, of which only the last is read; they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `component_import_missing_name`, `example_import_not_exported`, `example_import_missing_name`, `template_import_not_exported`, `template_import_outside_root`, `template_private_import`, `template_import_missing_name` and `template_no_default_export`. When the manifest loads, `data.publicImports` is `{status: 'checked', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: an `exports` target not built yet; a module whose export list cannot be read in full (CommonJS, or a declaration file it cannot read); a root import in a package with no `exports` (the root module `main` names is not read); every name an import (other than a component doc's own component) names that its module does not export, while a TypeScript file in the package has a `declare module` block for a relative path or the package's own name or a subpath of it, which can add names to that module (a `declare module` in a comment, `declare global`, a wildcard such as `'*.css'`, and another package's name do not count; a file whose text has `declare module` but that cannot be parsed counts); the same for every such name when the package has more than 5,000 files to search for that block; a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package's own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.",},],examples: [diff --git a/packages/cli/api/search/search.doc.mjs b/packages/cli/api/search/search.doc.mjsindex eae78ae1c5..59268f5a4d 100644--- a/packages/cli/api/search/search.doc.mjs+++ b/packages/cli/api/search/search.doc.mjs@@ -58,7 +58,7 @@ export const doc = {{type: 'search',description:- 'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the topic level (Guides or Foundations) for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `astryx theme add <slug>` (outside a project, where there is no app to add it to, `astryx theme eject <slug>`), and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI\'s own themes). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is `{skipped, reason}`: the domains it skipped (`component`, `hook`, `template`) and why; the results are the docs and themes, and text mode prints one line on standard error.',+ "The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the topic level (Guides or Foundations) for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `{@command theme add <slug>}` (outside a project, where there is no app to add it to, `{@command theme eject <slug>}`), and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI's own themes). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is `{skipped, reason}`: the domains it skipped (`component`, `hook`, `template`) and why; the results are the docs and themes, and text mode prints one line on standard error.",},],throws: [diff --git a/packages/cli/api/search/search.mjs b/packages/cli/api/search/search.mjsindex e116468b3d..046b1e7d11 100644--- a/packages/cli/api/search/search.mjs+++ b/packages/cli/api/search/search.mjs@@ -14,6 +14,10 @@* reads it, so build's output does not move when search's tree does.*/+import {+ docPackageManager,+ runWithDocPackageManager,+} from '../../foundation/env/package-manager.mjs';import {withListingCache} from '../../foundation/fs/listing-cache.mjs';import {gatherCandidates,@@ -52,6 +56,18 @@ export {componentKeywords} from './_adapter.mjs';*/export async function search(query, options = {}) {checkSearchArgs(query, options);+ return runWithDocPackageManager(+ docPackageManager(options.cwd ?? process.cwd()),+ () => searchRead(query, options),+ );+}++/**+ * The search itself, inside its project's package-manager scope.+ * @param {string} query+ * @param {any} options+ */+async function searchRead(query, options) {return withListingCache(async () =>/** @type {import('./search.type.mjs').SearchResponse} */ (@@ -79,6 +95,18 @@ export async function search(query, options = {}) {*/export async function searchCore(query, options = {}) {checkSearchArgs(query, options);+ return runWithDocPackageManager(+ docPackageManager(options.cwd ?? process.cwd()),+ () => searchCoreRead(query, options),+ );+}++/**+ * The lexical search itself, inside its project's package-manager scope.+ * @param {string} query+ * @param {any} options+ */+async function searchCoreRead(query, options) {return withListingCache(async () =>linkSearchResponse(rankLexical(query, options, await gatherCandidates(options)),diff --git a/packages/cli/api/theme/themeBuild.doc.mjs b/packages/cli/api/theme/themeBuild.doc.mjsindex 273bbd6ae1..aa529381a5 100644--- a/packages/cli/api/theme/themeBuild.doc.mjs+++ b/packages/cli/api/theme/themeBuild.doc.mjs@@ -20,7 +20,7 @@ export const doc = {summary:'Compile a defineTheme() file to scoped CSS, a JS module, and type declarations, or check committed outputs for drift in CI.',description:- 'The compiler behind `astryx theme build`. Reads a file that calls defineTheme() and ' ++ 'The compiler behind `{@command theme build}`. Reads a file that calls defineTheme() and ' +'writes a scoped CSS file, a JS module that re-exports the built theme, and a .d.ts ' +'(plus an optional .variants.d.ts when the theme adds custom prop values). It uses ' +"@astryxdesign/core's own generator, so the CSS matches what the <Theme> runtime emits. " +diff --git a/packages/cli/api/theme/themeList.doc.mjs b/packages/cli/api/theme/themeList.doc.mjsindex 4ab0d809a4..afe06097fd 100644--- a/packages/cli/api/theme/themeList.doc.mjs+++ b/packages/cli/api/theme/themeList.doc.mjs@@ -13,7 +13,7 @@ export const doc = {displayName: 'themeList()',summary: 'List themes bundled with this CLI build.',description:- 'Synchronous list of the themes bundled with the CLI. It does not include themes from installed integrations; use themeListAvailable() for the list `astryx theme list` shows.',+ 'Synchronous list of the themes bundled with the CLI. It does not include themes from installed integrations; use themeListAvailable() for the list `{@command theme list}` shows.',importPath: '@astryxdesign/cli/api',signature: 'themeList(): ThemeListResponse',keywords: ['theme', 'list', 'themes', 'bundled', 'available'],diff --git a/packages/cli/api/theme/themeTargets.doc.mjs b/packages/cli/api/theme/themeTargets.doc.mjsindex 820f8267ab..5dc954e5b6 100644--- a/packages/cli/api/theme/themeTargets.doc.mjs+++ b/packages/cli/api/theme/themeTargets.doc.mjs@@ -18,7 +18,7 @@ export const doc = {description:'Enumerates the whole themeable surface: each `defineTheme` components key, the stable ' +'class it paints, the component that declares it, and the props and states that are legal ' +- 'override keys under it. Same source as the Theming table `astryx component <Name>` prints ' ++ 'override keys under it. Same source as the Theming table `{@command component <Name>}` prints ' +'(the component docs), so the list cannot drift from the components, and `theme build` ' +'validates overrides against this exact set. A filter naming a component gives that ' +"component's set; anything else is a case-insensitive substring search over each target's key, class and component.",diff --git a/packages/cli/assets/docs/author-a-theme.doc.mjs b/packages/cli/assets/docs/author-a-theme.doc.mjsindex 2d06eef329..65190f6150 100644--- a/packages/cli/assets/docs/author-a-theme.doc.mjs+++ b/packages/cli/assets/docs/author-a-theme.doc.mjs@@ -15,8 +15,8 @@ export const docs = {title: 'Custom themes',content: [{type: 'prose', text: "Use an installed built theme as the base for ordinary customization. Import it into your source and pass it as `extends` to `defineTheme({extends: importedTheme, ...})`. Build the result, then add the local slug. Only eject when you need to own and maintain a full source fork."},- {type: 'code', lang: 'bash', label: 'Add to use, eject to fork', code: 'astryx theme list\nastryx theme add stone\nastryx theme eject stone\nastryx theme build src/themes/stone/stoneTheme.ts\nastryx theme add stone'},- {type: 'prose', text: "For an annotated map of the whole surface (every defineTheme field, the token families, and the component override syntax, each with the CLI command that prints its reference), run `astryx theme template`. It writes `theme.template.ts` into your project to read and copy from (`astryx init --features theme` writes it as part of project setup)."},+ {type: 'code', lang: 'bash', label: 'Add to use, eject to fork', code: '{@command theme list}\n{@command theme add stone}\n{@command theme eject stone}\n{@command theme build src/themes/stone/stoneTheme.ts}\n{@command theme add stone}'},+ {type: 'prose', text: "For an annotated map of the whole surface (every defineTheme field, the token families, and the component override syntax, each with the CLI command that prints its reference), run `{@command theme template}`. It writes `theme.template.ts` into your project to read and copy from (`{@command init --features theme}` writes it as part of project setup)."},{type: 'prose', text: 'To apply a theme you created, see {@link generic:use-a-theme}. To generate colors from seed values, see the Palette section below. Before you eject a package theme instead, see when that fits in {@link generic:use-a-theme}.'},],},@@ -26,9 +26,9 @@ export const docs = {content: [{type: 'prose', text: 'Name a few seed colors and generate every shade a theme needs, light and dark; {@link generic:generate-a-palette} explains what a palette holds.'},{type: 'code', lang: 'json', label: 'Minimal palette config (palette.config.json)', code: '{"families": [{"id": "ocean", "seed": "#0074e2"}]}'},- {type: 'code', lang: 'bash', label: 'Generate and preview', code: '# Print the palette without writing files\nastryx theme palette generate palette.config.json\n\n# Write palette + receipt, and open a visual preview\nastryx theme palette generate palette.config.json \\\n --out src/themes/ocean/tokens/ocean.palette.ts \\\n --preview preview.html'},+ {type: 'code', lang: 'bash', label: 'Generate and preview', code: '# Print the palette without writing files\n{@command theme palette generate palette.config.json}\n\n# Write palette + receipt, and open a visual preview\n{@command theme palette generate palette.config.json} \\\n --out src/themes/ocean/tokens/ocean.palette.ts \\\n --preview preview.html'},{type: 'prose', text: "The command writes a `.ts` file exporting 21 shades (stops 0–100) for both light and dark, plus a `.receipt.json` to regenerate later. Point your theme's tokens at the palette, then run defineTheme (see below)."},- {type: 'prose', text: 'For the full palette config fields and CLI flags, run `astryx docs cli/commands/theme-palette-generate`. For the integration-authoring walkthrough of connecting a palette to theme tokens, run `astryx docs authoring/building-blocks/themes/generate-a-palette`.'},+ {type: 'prose', text: 'For the full palette config fields and CLI flags, run `{@command docs cli/commands/theme-palette-generate}`. For the integration-authoring walkthrough of connecting a palette to theme tokens, run `{@command docs authoring/building-blocks/themes/generate-a-palette}`.'},],},{@@ -60,8 +60,8 @@ export const docs = {['typography, motion, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],]},- {type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `astryx theme build` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},- {type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `astryx docs authoring/building-blocks/themes/define-the-theme`.'},+ {type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `{@command theme build}` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},+ {type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `{@command docs authoring/building-blocks/themes/define-the-theme}`.'},],},{@@ -69,15 +69,15 @@ export const docs = {content: [{type: 'prose', text: 'The `components` field in defineTheme uses semantic component keys and style keys, not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in {@link generic:styling-advanced}.'},{type: 'code', lang: 'tsx', label: 'Component overrides with standard CSS', code: "components: {\n card: {\n base: { borderRadius: '20px', padding: '24px' },\n },\n button: {\n base: {\n borderRadius: '9999px',\n textTransform: 'uppercase',\n '--button-focus-offset': '3px',\n },\n 'variant:ghost': { borderWidth: '2px', borderStyle: 'solid' },\n },\n}"},- {type: 'prose', text: "Run `astryx theme targets` for every themeable key in the system (`astryx theme targets <Name>` to scope it, `--json` to lint a theme against it), and `astryx component <Name>` for one component's theming targets, public CSS variables, and which standard CSS properties are supported."},+ {type: 'prose', text: "Run `{@command theme targets}` for every themeable key in the system (`{@command theme targets <Name>}` to scope it, `--json` to lint a theme against it), and `{@command component <Name>}` for one component's theming targets, public CSS variables, and which standard CSS properties are supported."},{type: 'list', style: 'do', items: ['Write standard CSS properties (borderRadius, padding); the pipeline expands them into internal vars.', 'Set public CSS vars directly when no standard property equivalent exists.']},- {type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `astryx theme build` will error.', 'Set a public CSS var the component does not define. It compiles to CSS that never applies, and the build does not warn. Take the names from `astryx component <Name>`.']},+ {type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `{@command theme build}` will error.', 'Set a public CSS var the component does not define. It compiles to CSS that never applies, and the build does not warn. Take the names from `{@command component <Name>}`.']},],},{title: 'Custom Variants',content: [- {type: 'prose', text: "Themes can add new prop values to any component. Any `prop:value` key where the value isn't a built-in gets treated as a new variant. Use `astryx theme build` to generate TypeScript augmentations for type safety."},+ {type: 'prose', text: "Themes can add new prop values to any component. Any `prop:value` key where the value isn't a built-in gets treated as a new variant. Use `{@command theme build}` to generate TypeScript augmentations for type safety."},{type: 'code', lang: 'tsx', label: 'Adding custom variants', code: "components: {\n button: {\n 'variant:secondary': { backgroundColor: 'rgba(0,0,0,0.06)' },\n 'variant:primary-muted': {\n backgroundColor: 'light-dark(#F2F4F6, #28292C)',\n color: 'var(--color-text-primary)',\n },\n },\n banner: {\n 'status:neutral': {\n backgroundColor: 'var(--color-background-muted)',\n color: 'var(--color-text-secondary)',\n },\n },\n}"},{type: 'code', lang: 'tsx', label: 'Using custom variants', code: "// TypeScript knows about 'primary-muted' after astryx theme build\n<Button variant=\"primary-muted\" label=\"Save draft\" />\n<Banner status=\"neutral\" title=\"Note\" />"},{type: 'prose', text: "Custom variants only work when the theme that defines them is active. The component's variant map is extended via module augmentation, with no changes to the component source needed."},@@ -104,15 +104,15 @@ export const docs = {{type: 'prose', text: "Precedence follows rule order. Root theme values apply first, then every matching rule in declaration order. A later rule may deliberately restore a root value. `onDark` and `onLight` media-surface overrides apply after adaptations and win on the same leaf."},{type: 'prose', text: "`extends` preserves the base rule order and appends child rules. Inherited conditions use the child's effective breakpoint map. An empty child rule is a no-op, not a removal operator."},{type: 'prose', text: "A rule may replace a theme-local token only when the exact name is already enrolled by root `localTokens` or an enrolled base. Component writes in a rule are validated exactly like root `components`: same targets, axes, and value domains. The one addition is that a rule may not be the only place a custom value is enrolled: a value that is valid only because a theme enrolls it generates unconditional type augmentation, so declare it on the root theme first and let rules restyle it. Built-in values need no root declaration. When rules can match together, their ordered portable and local token writes are validated as one effective graph; any reachable cycle fails before CSS is emitted."},- {type: 'prose', text: 'Adaptations compile to CSS media queries with no resize listener or styling rerender. Runtime and `astryx theme build` use the same compiler, but only a built theme is present at first paint in an SSR app.'},+ {type: 'prose', text: 'Adaptations compile to CSS media queries with no resize listener or styling rerender. Runtime and `{@command theme build}` use the same compiler, but only a built theme is present at first paint in an SSR app.'},],},{id: 'building-themes-for-production',title: 'Build a theme',content: [- {type: 'prose', text: '`astryx theme build` compiles a defineTheme file into production-ready artifacts. Recommended for SSR apps (Next.js, Remix) where styles must be present on first paint.'},- {type: 'code', lang: 'bash', label: 'Build a theme', code: 'astryx theme build ./src/themes/ocean.ts'},+ {type: 'prose', text: '`{@command theme build}` compiles a defineTheme file into production-ready artifacts. Recommended for SSR apps (Next.js, Remix) where styles must be present on first paint.'},+ {type: 'code', lang: 'bash', label: 'Build a theme', code: '{@command theme build ./src/themes/ocean.ts}'},{type: 'table', headers: ['File', 'Description'], rows: [['ocean.css', 'Pre-compiled CSS with token overrides, component overrides, and prose element styles in @scope rules'],['ocean.js', 'ES module exporting the theme object with `__built: true` and pre-resolved token values.'],@@ -121,7 +121,7 @@ export const docs = {]},{type: 'prose', text: 'The `__built: true` flag tells Theme to skip runtime `<style>` injection; the CSS file handles it. Load the generated CSS wherever you load the module.'},{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core/theme';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},- {type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:font-setup} for the full recipe."},+ {type: 'prose', text: "After upgrading Astryx, rerun `{@command theme build}` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:font-setup} for the full recipe."},{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},],},@@ -130,7 +130,7 @@ export const docs = {title: 'Built themes with an icon registry',content: [{type: 'prose', text: "`theme build` emits an icon import when it detects a named import used by the theme's `icons:` field. It does not compile that registry module. Move the registry to a separate module and use a named import."},- {type: 'code', lang: 'bash', label: 'Compiling the icon registry sidecar', code: "# Emit the built theme\nastryx theme build ./src/themes/ocean.ts -o dist/theme.css --icons-specifier ./icons.mjs\n\n# Compile the icon registry alongside it\nesbuild src/themes/icons.tsx --bundle --format=esm --outfile=dist/icons.mjs \\\n --external:react --external:lucide-react --jsx=automatic"},+ {type: 'code', lang: 'bash', label: 'Compiling the icon registry sidecar', code: "# Emit the built theme\n{@command theme build ./src/themes/ocean.ts -o dist/theme.css --icons-specifier ./icons.mjs}\n\n# Compile the icon registry alongside it\nesbuild src/themes/icons.tsx --bundle --format=esm --outfile=dist/icons.mjs \\\n --external:react --external:lucide-react --jsx=automatic"},{type: 'prose', text: 'In the example above, the generated theme imports `./icons.mjs` from `dist`. If the second command is skipped, `theme build` can still succeed, but loading or bundling the generated module fails because `dist/icons.mjs` is missing. `--icons-specifier` changes the emitted import; it does not create or verify the target file. Match the specifier to a module that resolves from the generated JS file.'},{type: 'prose', text: 'Without `--icons-specifier`, the detected source import specifier is emitted unchanged. In the default flow without `--out`, a bundler can resolve an extensionless `./icons` to the neighboring `icons.tsx` source, but Node ESM does not perform that lookup and reports `ERR_MODULE_NOT_FOUND`. Moving the output with `--out` also changes where relative imports resolve from.'},{type: 'prose', text: 'Keep `react` and the icon library external so the registry does not bundle its own copies of those dependencies.'},@@ -140,7 +140,7 @@ export const docs = {title: 'Building a Theme Family',content: [{type: 'prose', text: 'Use family mode when an app switches among one base theme and its selected descendants. The build writes one keyed CSS file containing every member, plus one keyed JavaScript module and one declaration file, beside the root source.'},- {type: 'code', lang: 'bash', label: 'Build one family', code: "astryx theme build --family \\\n ./src/themes/ocean.mjs \\\n ./src/themes/ocean-calm.mjs \\\n ./src/themes/ocean-calm-deep.mjs \\\n --family-key ocean-family"},+ {type: 'code', lang: 'bash', label: 'Build one family', code: "{@command theme build} --family \\\n ./src/themes/ocean.mjs \\\n ./src/themes/ocean-calm.mjs \\\n ./src/themes/ocean-calm-deep.mjs \\\n --family-key ocean-family"},{type: 'prose', text: 'The family stylesheet eagerly downloads every selected member so first paint is complete. Switching members changes only the theme identity; it does not add, remove, or reorder stylesheets.'},],},diff --git a/packages/cli/assets/docs/getting-started.doc.mjs b/packages/cli/assets/docs/getting-started.doc.mjsindex 7b6e3b26a4..3975c68849 100644--- a/packages/cli/assets/docs/getting-started.doc.mjs+++ b/packages/cli/assets/docs/getting-started.doc.mjs@@ -21,7 +21,7 @@ export const docs = {type: 'code',lang: 'text',label: 'Set up the design system',- code: 'Install @astryxdesign/core, @stylexjs/stylex, @astryxdesign/theme-neutral, and @astryxdesign/cli in this project, then run `astryx init` to set up agent docs. Read the generated files to learn the conventions.',+ code: 'Install @astryxdesign/core, @stylexjs/stylex, @astryxdesign/theme-neutral, and @astryxdesign/cli in this project, then run `{@command init}` to set up agent docs. Read the generated files to learn the conventions.',},{type: 'prose',@@ -31,7 +31,7 @@ export const docs = {type: 'code',lang: 'text',label: 'Give it a look',- code: 'Ask me what look and feel this app should have. Run `astryx theme list`, install the closest theme package, and run `theme add <slug>`; use `--package` when owners share a slug. Import `themes` and `defaultThemeSlug` from the generated module once and pass `themes[defaultThemeSlug]` to `<Theme>`. Customize with `defineTheme({extends: importedTheme, ...})`. Use `theme eject` only when I ask for an independent source fork. Default to neutral if I have no preference, and show me the result before moving on.',+ code: 'Ask me what look and feel this app should have. Run `{@command theme list}`, install the closest theme package, and run `theme add <slug>`; use `--package` when owners share a slug. Import `themes` and `defaultThemeSlug` from the generated module once and pass `themes[defaultThemeSlug]` to `<Theme>`. Customize with `defineTheme({extends: importedTheme, ...})`. Use `theme eject` only when I ask for an independent source fork. Default to neutral if I have no preference, and show me the result before moving on.',},],},@@ -50,17 +50,17 @@ export const docs = {type: 'code',lang: 'bash',label: 'Terminal',- code: `npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral @astryxdesign/cli`,+ code: `{@pm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral @astryxdesign/cli}`,},{type: 'prose',- text: "Then run `astryx init` to install the AI agent cheat sheet (AGENTS.md/CLAUDE.md). It's non-interactive; no prompts; so it's safe for AI agents, CI, and scripts. Add `--all` for pointers to the theme and page-building workflows.",+ text: "Then run `{@command init}` to install the AI agent cheat sheet (AGENTS.md/CLAUDE.md). It's non-interactive; no prompts; so it's safe for AI agents, CI, and scripts. Add `--all` for pointers to the theme and page-building workflows.",},{type: 'code',lang: 'bash',label: 'Terminal',- code: `astryx init`,+ code: `{@command init}`,},],},@@ -76,7 +76,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Terminal',- code: `npm i -g @astryxdesign/cli`,+ code: `{@pm install @astryxdesign/cli --global}`,},{type: 'prose',@@ -89,7 +89,7 @@ export const docs = {content: [{type: 'prose',- text: 'Import the reset and base styles in your global CSS. Then run `astryx theme add neutral`; the generated app module imports the theme’s production CSS and font CSS.',+ text: 'Import the reset and base styles in your global CSS. Then run `{@command theme add neutral}`; the generated app module imports the theme’s production CSS and font CSS.',},{type: 'code',@@ -100,7 +100,7 @@ export const docs = {},{type: 'prose',- text: 'Run `astryx theme list` to see every theme.',+ text: 'Run `{@command theme list}` to see every theme.',},{type: 'code',@@ -139,7 +139,7 @@ import {themes, defaultThemeSlug} from './astryx-themes';content: [{type: 'prose',- text: 'Import each component from its own entry, the path `astryx component <Name>` prints. This keeps bundles small and makes intent clear.',+ text: 'Import each component from its own entry, the path `{@command component <Name>}` prints. This keeps bundles small and makes intent clear.',},{type: 'code',@@ -218,8 +218,8 @@ const overrides = stylex.create({label: 'Clone and run an example',code: `git clone https://github.com/facebook/astryx.gitcd astryx/apps/example-nextjs-pnpm install-pnpm dev`,+{@pm install}+{@pm run dev}`,},],},@@ -246,11 +246,11 @@ pnpm dev`,type: 'code',lang: 'bash',label: 'Terminal',- code: `astryx component # list all components-astryx component Button # props, usage, theming for Button-astryx docs # list all doc topics-astryx template --list # available page templates-astryx docs tokens # spacing, color, radius reference`,+ code: `{@command component} # list all components+{@command component Button} # props, usage, theming for Button+{@command docs} # list all doc topics+{@command template --list} # available page templates+{@command docs tokens} # spacing, color, radius reference`,},],},diff --git a/packages/cli/assets/docs/is-my-code-good.doc.mjs b/packages/cli/assets/docs/is-my-code-good.doc.mjsindex 9c5c40d19b..7ad352833b 100644--- a/packages/cli/assets/docs/is-my-code-good.doc.mjs+++ b/packages/cli/assets/docs/is-my-code-good.doc.mjs@@ -41,7 +41,7 @@ export const docs = {'Trace where the surface sits: its route, entry point, navigation path, parent shell, and the page or block pattern it is meant to use.','Inspect sibling surfaces that do the same or adjacent jobs. Record their shared headers, actions, layout primitives, spacing, density, states, and narrow-screen behavior.','Read project guidance, including the root and relevant nested `AGENTS.md` files. Record app-owned wrapper components and intentional app conventions.',- 'Record the installed `@astryxdesign/core`, `@astryxdesign/cli`, and integration-package versions from the project manifest and lockfile. Run the installed invocation of `astryx component --list` to see core and integration components, then inspect app-owned wrappers that do not appear in that catalog.',+ 'Record the installed `@astryxdesign/core`, `@astryxdesign/cli`, and integration-package versions from the project manifest and lockfile. Run the installed invocation of `{@command component --list}` to see core and integration components, then inspect app-owned wrappers that do not appear in that catalog.','List the real data states, roles and permissions, supported locales and RTL behavior, and mobile or narrow-width needs that affect the task.',],},@@ -179,10 +179,10 @@ export const docs = {"Compare the route with sibling surfaces that do the same job. Identify the app's shared header, actions, shell, page pattern, spacing, and density before judging the target.",'Inspect every JSX opening tag. Moving raw HTML behind a PascalCase helper does not make the underlying pattern an Astryx component.','Count every raw SVG element used as an icon, including `svg`, `path`, `circle`, `rect`, `line`, `polyline`, `polygon`, `ellipse`, and `g`. For an inline SVG helper, count its raw SVG elements once in the helper definition, not again at each render. Count each icon-library component rendered directly outside an Astryx icon surface.',- 'Look up a possible replacement with `astryx component <Name> --dense`. Do not invent a component or prop that the installed version does not provide.',- 'Run the installed `astryx component --list` and inspect app-owned wrappers before rebuilding a pattern. Prefer the component the app or one of its installed integrations already uses for the job.',+ 'Look up a possible replacement with `{@command component <Name> --dense}`. Do not invent a component or prop that the installed version does not provide.',+ 'Run the installed `{@command component --list}` and inspect app-owned wrappers before rebuilding a pattern. Prefer the component the app or one of its installed integrations already uses for the job.','Inspect every `stylex.create` declaration, inline style, `className`, and `stylex.props` use. Look for a component prop or token first.',- "When replacing a literal spacing value, read `astryx docs spacing --full` for the matching step or token and the target component doc for the prop's accepted scale. Do not guess a pixel-to-step mapping.",+ "When replacing a literal spacing value, read `{@command docs spacing --full}` for the matching step or token and the target component doc for the prop's accepted scale. Do not guess a pixel-to-step mapping.",'Choose the root that matches the surface. Use `Layout` for a page, `Center` for centered content, and `AppShell` only when the surface owns global application chrome.','Render realistic empty, loading, error, long-content, and interactive states. Check narrow and wide widths plus each supported color mode.','Verify the target roles and permissions, supported locales and RTL behavior, and mobile needs. Follow the real task from entry to completion instead of judging only the static page.',@@ -205,11 +205,11 @@ export const docs = {items: ['Record the exact revision, named surface, route, and source files in scope. If the files are outside version control, record a content hash for each file and say that no project revision was available.',"Write down the app's purpose, target users, surface task, entry point, navigation path, parent shell, expected page pattern, and sibling surfaces used for comparison.",- 'Record project guidance, theme, density, installed Astryx and integration versions, the relevant output of `astryx component --list`, and app-owned wrappers or conventions.',+ 'Record project guidance, theme, density, installed Astryx and integration versions, the relevant output of `{@command component --list}`, and app-owned wrappers or conventions.','List the states and context that matter, including real data shapes, roles and permissions, empty, loading, error, long content, interaction, narrow width, wide width, supported color modes, locales, and RTL behavior when they apply.','Run the product and capture each named rendered state. Use screenshots or a live browser result for visible claims, and follow the target user task from entry to completion.','Run the build, type check, tests, and accessibility checks. Keep their commands and results with the review.',- 'For each Astryx component whose replacement, prop, or composition is in question, read `astryx component <Name> --dense`.',+ 'For each Astryx component whose replacement, prop, or composition is in question, read `{@command component <Name> --dense}`.',],},],diff --git a/packages/cli/assets/docs/styling-overview.doc.mjs b/packages/cli/assets/docs/styling-overview.doc.mjsindex a06892a58c..99c853dc24 100644--- a/packages/cli/assets/docs/styling-overview.doc.mjs+++ b/packages/cli/assets/docs/styling-overview.doc.mjs@@ -67,7 +67,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Install',- code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',+ code: '{@pm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral}',},{type: 'code',@@ -79,7 +79,7 @@ export const docs = {},{type: 'prose',- text: "Done. Components work out of the box \u2014 style them with `className`, `xstyle`, or `style`. Swap `theme-neutral` for any theme package (`astryx theme list` shows what's available).",+ text: "Done. Components work out of the box \u2014 style them with `className`, `xstyle`, or `style`. Swap `theme-neutral` for any theme package (`{@command theme list}` shows what's available).",},],},@@ -91,7 +91,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Install (add to an existing Tailwind v4 app)',- code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',+ code: '{@pm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral}',},{type: 'code',@@ -123,13 +123,13 @@ export const docs = {content: [{type: 'prose',- text: 'Only needed when you write your own StyleX (`stylex.create()`) or swizzle a component (`astryx swizzle <Component>`), which copies its StyleX source into your app. The plain path already supports `xstyle` overrides \u2014 this path is for your own StyleX code. Some built-in page templates also use StyleX for layout; if you scaffold one and see "Unexpected stylex.create call at runtime", add the compiler plugin for your bundler below.',+ text: 'Only needed when you write your own StyleX (`stylex.create()`) or swizzle a component (`{@command swizzle <Component>}`), which copies its StyleX source into your app. The plain path already supports `xstyle` overrides \u2014 this path is for your own StyleX code. Some built-in page templates also use StyleX for layout; if you scaffold one and see "Unexpected stylex.create call at runtime", add the compiler plugin for your bundler below.',},{type: 'code',lang: 'bash',label: 'Install',- code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',+ code: '{@pm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral}',},{type: 'code',diff --git a/packages/cli/assets/docs/theme.doc.mjs b/packages/cli/assets/docs/theme.doc.mjsindex d97ae11e97..f5b2c2288b 100644--- a/packages/cli/assets/docs/theme.doc.mjs+++ b/packages/cli/assets/docs/theme.doc.mjs@@ -39,11 +39,11 @@ export const docs = {type: 'code',lang: 'bash',label: 'Quick start',- code: 'astryx theme add stone # use an existing theme\nastryx theme eject stone # fork its source to customize\nastryx theme build src/themes/stone/stoneTheme.ts',+ code: '{@command theme add stone} # use an existing theme\n{@command theme eject stone} # fork its source to customize\n{@command theme build src/themes/stone/stoneTheme.ts}',},{type: 'prose',- text: 'For a new coordinated color system, run `astryx theme palette generate palette.config.json --out palette.generated.ts`. Review and commit the generated palette module and receipt, import its `palette` export, then reference stable stops from semantic tokens. Regenerating an accepted palette updates every mapped token that keeps those references; generation does not rewrite the theme.',+ text: 'For a new coordinated color system, run `{@command theme palette generate palette.config.json --out palette.generated.ts}`. Review and commit the generated palette module and receipt, import its `palette` export, then reference stable stops from semantic tokens. Regenerating an accepted palette updates every mapped token that keeps those references; generation does not rewrite the theme.',},{type: 'code',@@ -74,7 +74,7 @@ export const docs = {content: [{type: 'prose',- text: 'Install an integration and Astryx discovers its themes automatically. Import one with `astryx theme add <name> --package <integration>`. Use `theme eject` only for an independent source fork. For the full walkthrough, see {@link generic:use-a-theme}.',+ text: 'Install an integration and Astryx discovers its themes automatically. Import one with `{@command theme add <name> --package <integration>}`. Use `theme eject` only for an independent source fork. For the full walkthrough, see {@link generic:use-a-theme}.',},],},diff --git a/packages/cli/assets/docs/tree/add-a-component.doc.mjs b/packages/cli/assets/docs/tree/add-a-component.doc.mjsindex 49795799c4..f235f04f58 100644--- a/packages/cli/assets/docs/tree/add-a-component.doc.mjs+++ b/packages/cli/assets/docs/tree/add-a-component.doc.mjs@@ -45,7 +45,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add component AcmeCarousel',+ code: '{@command integration add component AcmeCarousel}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/add-a-theme.doc.mjs b/packages/cli/assets/docs/tree/add-a-theme.doc.mjsindex 844f53338d..0baa87391f 100644--- a/packages/cli/assets/docs/tree/add-a-theme.doc.mjs+++ b/packages/cli/assets/docs/tree/add-a-theme.doc.mjs@@ -26,7 +26,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add theme ocean',+ code: '{@command integration add theme ocean}',},{type: 'code',@@ -63,7 +63,7 @@ Declare theme root ./themes in astryx.integration.mjs.{type: 'code',lang: 'bash',- code: 'astryx integration add theme ocean --from neutral',+ code: '{@command integration add theme ocean --from neutral}',},{type: 'prose',diff --git a/packages/cli/assets/docs/tree/add-a-topic.doc.mjs b/packages/cli/assets/docs/tree/add-a-topic.doc.mjsindex 036a01b3ab..1e934404b8 100644--- a/packages/cli/assets/docs/tree/add-a-topic.doc.mjs+++ b/packages/cli/assets/docs/tree/add-a-topic.doc.mjs@@ -27,7 +27,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add doc deploying\n# Read it the way an app will\nastryx docs deploying',+ code: '{@command integration add doc deploying}\n# Read it the way an app will\n{@command docs deploying}',},{type: 'code',@@ -40,7 +40,7 @@ export const docs = {items: ['Name the topic in lowercase kebab-case, such as `deploying`. Readers type the name as a command argument, so it holds only letters, digits, `_`, and `-`.','Keep the name stable: readers and links find the topic by it.',- 'Pick a name `astryx docs` does not already list: no Core topic, and no section such as `tokens` or `layout`. To take over or add to a Core topic, see {@link generic:extend-or-replace}.',+ 'Pick a name `{@command docs}` does not already list: no Core topic, and no section such as `tokens` or `layout`. To take over or add to a Core topic, see {@link generic:extend-or-replace}.',],},],@@ -57,7 +57,7 @@ export const docs = {type: 'code',lang: 'javascript',label: 'docs/deploying.doc.mjs',- code: "/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */\nexport default {\n type: 'generic',\n name: 'deploying',\n title: 'Deploying',\n description: 'Ship an app built with Acme widgets.',\n sections: [{\n id: 'build-before-you-ship',\n title: 'Build before you ship',\n content: [\n {type: 'prose', text: 'Build the app, then upload the `dist` folder.'},\n {type: 'code', lang: 'bash', code: 'npm run build'},\n {type: 'list', style: 'unordered', items: ['Keep `dist` out of git.']},\n {type: 'table', headers: ['Variable', 'Value'], rows: [['`NODE_ENV`', '`production`']]},\n ],\n }],\n};",+ code: "/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */\nexport default {\n type: 'generic',\n name: 'deploying',\n title: 'Deploying',\n description: 'Ship an app built with Acme widgets.',\n sections: [{\n id: 'build-before-you-ship',\n title: 'Build before you ship',\n content: [\n {type: 'prose', text: 'Build the app, then upload the `dist` folder.'},\n {type: 'code', lang: 'bash', code: '{@@pm run build}'},\n {type: 'list', style: 'unordered', items: ['Keep `dist` out of git.']},\n {type: 'table', headers: ['Variable', 'Value'], rows: [['`NODE_ENV`', '`production`']]},\n ],\n }],\n};",},{type: 'prose',@@ -75,17 +75,17 @@ export const docs = {},{id: 'write-commands-without-a-runner',- title: 'Write commands without a runner',+ title: 'Write commands for every reader',content: [{type: 'prose',- text: 'Start every CLI command in a doc with the word astryx alone, with no runner such as npx or pnpm exec in front. The CLI prefixes each one when it prints the doc, with the command the reader runs: `pnpm exec astryx` or `yarn astryx` from their package manager, or the `cliCommand` an integration sets. See {@link generic:cli-command}. `doctor integration validate` (and so `integration check`) lists each command written with a runner as a `runner_command` note, with its file, line and the bare command to write. A note fails nothing. An install step, which runs before the CLI is installed, is the one exception: write the scoped package name, `@astryxdesign/cli`, after the download runner. The unscoped name after a download runner is always listed, because it fetches an unrelated package.',+ text: "Write an Astryx command as `{@@command doctor}` and a package-manager step as `{@@pm install @acme/widgets}`, never with a runner such as npx or pnpm exec, or a package manager's own command, in front. The CLI shows each one with the command the reader runs: `pnpm exec astryx doctor` or `yarn astryx doctor`, `pnpm add @acme/widgets` or `npm install @acme/widgets`, or the `cliCommand` an integration sets. {@link generic:doc-syntax} lists every token. A command written bare, the word astryx and a command, is shown the same way. `doctor integration validate` (and so `integration check`) names each command written another way, with the token that replaces it; {@link generic:doc-syntax} lists what it checks. An install step, which runs before the CLI is installed, is `{@@pm dlx @astryxdesign/cli init}`.",},{type: 'code',lang: 'javascript',label: 'docs/deploying.doc.mjs',- code: "{type: 'prose', text: 'Check the app with `astryx doctor` before you ship.'},\n{type: 'code', lang: 'bash', code: 'astryx doctor'},",+ code: "{type: 'prose', text: 'Check the app with {@@command doctor} before you ship.'},\n{type: 'code', lang: 'bash', code: '{@@command doctor}'},",},{type: 'code',diff --git a/packages/cli/assets/docs/tree/agent-guidance.doc.mjs b/packages/cli/assets/docs/tree/agent-guidance.doc.mjsindex a3d6b44497..815371713e 100644--- a/packages/cli/assets/docs/tree/agent-guidance.doc.mjs+++ b/packages/cli/assets/docs/tree/agent-guidance.doc.mjs@@ -27,7 +27,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: "astryx integration add agent-doc 'Use AcmeCarousel for rotating content.'",+ code: "{@command integration add agent-doc 'Use AcmeCarousel for rotating content.'}",},{type: 'prose',@@ -92,12 +92,12 @@ export default {content: [{type: 'prose',- text: "An app's `astryx init` writes your lines at the end of its managed agent block, each labeled with your package name. The CLI owns the heading, the labels, and the markers.",+ text: "An app's `{@command init}` writes your lines at the end of its managed agent block, each labeled with your package name. The CLI owns the heading, the labels, and the markers.",},{type: 'code',lang: 'bash',- code: 'astryx init --features agents',+ code: '{@command init --features agents}',},{type: 'code',@@ -123,9 +123,9 @@ export default {{type: 'code',lang: 'bash',- code: `astryx init --features agents+ code: `{@command init --features agents}# Or: --from takes the Core version the app had before-astryx upgrade --from <version> --apply`,+{@command upgrade --from <version> --apply}`,},{type: 'code',diff --git a/packages/cli/assets/docs/tree/authoring.doc.mjs b/packages/cli/assets/docs/tree/authoring.doc.mjsindex f2120fc731..b093b41ccd 100644--- a/packages/cli/assets/docs/tree/authoring.doc.mjs+++ b/packages/cli/assets/docs/tree/authoring.doc.mjs@@ -43,7 +43,7 @@ export const docs = {},{type: 'prose',- text: 'For example, ship a carousel as an integration. Any app that installs it can find it with `astryx search carousel`, and the CLI uses it like any Astryx Core component.',+ text: 'For example, ship a carousel as an integration. Any app that installs it can find it with `{@command search carousel}`, and the CLI uses it like any Astryx Core component.',},{type: 'prose',@@ -55,7 +55,7 @@ export const docs = {},{type: 'prose',- text: "Every integration runs `astryx integration check --strict` in its own build: it is required, not optional, so a doc, prop, or link that stops matching the code fails your build instead of your users' apps. See {@link generic:checks}.",+ text: "Every integration runs `{@command integration check --strict}` in its own build: it is required, not optional, so a doc, prop, or link that stops matching the code fails your build instead of your users' apps. See {@link generic:checks}.",},],};diff --git a/packages/cli/assets/docs/tree/block-template.doc.mjs b/packages/cli/assets/docs/tree/block-template.doc.mjsindex 571d72b2df..e86007fca9 100644--- a/packages/cli/assets/docs/tree/block-template.doc.mjs+++ b/packages/cli/assets/docs/tree/block-template.doc.mjs@@ -82,7 +82,7 @@ export default {},{type: 'prose',- text: 'Then check the package-scoped template list ({@link generic:template-doc-overview}) and confirm the entry carries the relationship you set. `astryx component` does not show integration blocks, so the list is where to check.',+ text: 'Then check the package-scoped template list ({@link generic:template-doc-overview}) and confirm the entry carries the relationship you set. `{@command component}` does not show integration blocks, so the list is where to check.',},],},diff --git a/packages/cli/assets/docs/tree/check-the-props.doc.mjs b/packages/cli/assets/docs/tree/check-the-props.doc.mjsindex 4cfeac2dbe..fb014b7d2c 100644--- a/packages/cli/assets/docs/tree/check-the-props.doc.mjs+++ b/packages/cli/assets/docs/tree/check-the-props.doc.mjs@@ -37,7 +37,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx doctor integration components',+ code: '{@command doctor integration components}',},{type: 'code',@@ -178,11 +178,11 @@ reason: AcmeCarousel depends on \`@acme/motion\` (imported in AcmeCarousel.ts],["It depends on a type the compiler can't work out",- 'Make the types compile with `npx tsc --noEmit`, then run the check again',+ 'Make the types compile with `{@pm exec tsc --noEmit}`, then run the check again',],["The package's TypeScript config has an error",- 'Fix `tsconfig.json` until `npx tsc -p .` reads it',+ 'Fix `tsconfig.json` until `{@pm exec tsc -p .}` reads it',],['Its props are typed `any`', 'Give the component a props type'],[diff --git a/packages/cli/assets/docs/tree/check-your-docs.doc.mjs b/packages/cli/assets/docs/tree/check-your-docs.doc.mjsindex 61a4b9efc3..7e6ceea0bc 100644--- a/packages/cli/assets/docs/tree/check-your-docs.doc.mjs+++ b/packages/cli/assets/docs/tree/check-your-docs.doc.mjs@@ -27,7 +27,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx doctor integration docs\n# In an app, check an installed package\nastryx doctor integration docs @acme/astryx-widgets',+ code: '{@command doctor integration docs}\n# In an app, check an installed package\n{@command doctor integration docs @acme/astryx-widgets}',},{type: 'code',@@ -44,7 +44,7 @@ export const docs = {},{type: 'prose',- text: "Point at another doc with a link, never by writing `astryx docs <name>` in prose: `{@link generic:<name>}` for one of your package's topics, or `{@link @astryxdesign/cli:generic:<name>}` for a Core doc (`namespace:` for a Core namespace). The CLI prints the link as the command that opens the doc, and doctor checks that the doc exists. The check lists each written pointer to a doc that exists as a `stray_doc_pointer` warning, with the link to write instead. A command with more words, or one in a code block, is a walkthrough and is not listed.",+ text: "Point at another doc with a link, never by writing `{@command docs <name>}` in prose: `{@link generic:<name>}` for one of your package's topics, or `{@link @astryxdesign/cli:generic:<name>}` for a Core doc (`namespace:` for a Core namespace). The CLI prints the link as the command that opens the doc, and doctor checks that the doc exists. The check lists each written pointer to a doc that exists as a `stray_doc_pointer` warning, with the link to write instead. A command with more words, or one in a code block, is a walkthrough and is not listed.",},{type: 'prose',@@ -109,7 +109,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx doctor integration validate',+ code: '{@command doctor integration validate}',},{type: 'code',@@ -144,12 +144,12 @@ fix: Remove \`summary\`: SingleComponentDoc has no field \`summary\`.`,content: [{type: 'prose',- text: '`astryx doctor` also measures every read and warns on one over 32 KB. Run it in your package or in an app that installs it; `doctor integration docs` does not check size.',+ text: '`{@command doctor}` also measures every read and warns on one over 32 KB. Run it in your package or in an app that installs it; `doctor integration docs` does not check size.',},{type: 'code',lang: 'bash',- code: 'astryx doctor',+ code: '{@command doctor}',},{type: 'code',@@ -173,7 +173,7 @@ fix: Remove \`summary\`: SingleComponentDoc has no field \`summary\`.`,{type: 'code',lang: 'bash',- code: 'astryx integration verify',+ code: '{@command integration verify}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/checks.doc.mjs b/packages/cli/assets/docs/tree/checks.doc.mjsindex 0e5d4045ff..f74b6a43a8 100644--- a/packages/cli/assets/docs/tree/checks.doc.mjs+++ b/packages/cli/assets/docs/tree/checks.doc.mjs@@ -29,37 +29,37 @@ export const docs = {headers: ['Command', 'Proves', 'Exits 1 when', 'Only warns when'],rows: [[- '`astryx doctor integration validate`',- 'The manifest loads, each root holds contributions the CLI can read, and each doc matches its authoring type. Notes, which fail nothing, list a malformed `cliCommand` and each command a topic writes with a package runner (`runner_command`)',+ '`{@command doctor integration validate}`',+ 'The manifest loads, each root holds contributions the CLI can read, and each doc matches its authoring type. Notes list a malformed `cliCommand` (`invalid_cli_command`) and, for each topic, a command written with a package runner (`runner_command`), bare (`plain_command`) or for one package manager (`package_manager_command`), and a token that does not parse (`doc_token`; see {@link generic:doc-syntax}). Notes fail nothing by default; `integration check --strict --next` fails on the ones marked `next`, and the next minor release counts them','A declared root is missing (`missing_root`), a contribution does not load (`invalid_doc`, `invalid_component`, `invalid_theme`), or two templates in the package replace one Core id (`ambiguous_template_replacement`)',"The manifest has a key this CLI does not know (`unknown_manifest_key`), or a doc field does not match the doc's authoring type: a field the type does not have, a missing required field, or a value outside the field's type. It also warns on what no reader can serve: a prop listed twice (`duplicate_prop`), a `propDescriptions` key that names no documented prop (`unknown_translated_prop`), a section with no content (`empty_section`), two sections of a topic with one key (`duplicate_section_key`), or a `.doc.zh.mjs` or `.doc.dense.mjs` overlay beside no topic file (`orphan_doc_overlay`). Since 0.7.3 it also lists, from source and without failing, what the package tells apps to import that they cannot: a component's import (the doc's `import`, or the one the CLI derives) or a template's public import whose subpath package.json `exports` does not declare (`component_import_not_exported`, `template_import_not_exported`) or that names another package (`component_import_other_package`); an example that imports an undeclared subpath (`example_import_not_exported`); a template that imports a path outside the templates root (`template_import_outside_root`) or a path its package or Core does not export (`template_private_import`). It lists the same way a component's import whose module does not export the component (`component_import_missing_name`), an example or a template that imports a name its package does not export (`example_import_missing_name`, `template_import_missing_name`), and a template source with no default export (`template_no_default_export`). Each is a note, printed with its fix, that fails `--strict` from the next minor; an import it cannot judge, such as an `exports` target not built yet or a deep path into a `dist/` not built yet, is listed under `publicImports` as not checked. It checks docs with your installed `typescript`, or, where that is missing or has no JavaScript compiler API (TypeScript 7), with an installed `@typescript/typescript6`; without either, it prints `[skip] Docs not type-checked`. With no `astryx.integration.mjs` it prints a hint and exits 0",],[- '`astryx doctor integration components`',+ '`{@command doctor integration components}`',"No component name clashes with a Core component, each `replaces` names one Core component, and each component doc's props match the component's TypeScript props",'Core is not installed (`core_not_found`). In a package that declares the CLI range that turns replacement on, a `replaces` target is missing (`missing_component_replacement_target`) or invalid (`invalid_component_replacement`), or two components replace one Core component (`ambiguous_component_replacement`)','A name clashes with Core, a component sets `replaces` in a package without that range (`inactive_component_replacement`, plus any missing, invalid, or duplicate `replaces` reported as a warning), or a documented prop differs from the code: it is missing there (`not_in_code`), the doc omits a prop the package declares (`not_in_doc`), or its `required` (`required_mismatch`), type (`type_mismatch`), or literal `default` (`default_mismatch`) disagrees, or a `{@link}` in a component doc names no doc (`invalid_doc_graph`). It reads props with your installed `typescript`; without it, it prints `[skip] Props not compared`',],[- '`astryx doctor integration templates`',+ '`{@command doctor integration templates}`','Each `replaces` names a Core template of the same type','A `replaces` target is missing (`missing_template_replacement_target`) or of the other type (`invalid_template_replacement`), or two templates replace one id (`ambiguous_template_replacement`)','A template id matches a Core id without `replaces`',],[- '`astryx doctor integration docs`',+ '`{@command doctor integration docs}`','Your docs tree, every link, topic names against Core, passages two topics repeat word for word, padding phrases and low-density topics, and written pointers to docs','A topic takes a Core topic name without `replaces` or `extends`, a doc is invalid (`invalid_doc`), or a namespace or placement fails, which hides the doc (`invalid_doc_graph`)',- 'A link names no doc (`invalid_doc_graph`), two topics repeat a passage word for word (`copied_passage`), prose pads with a listed phrase or falls under the density floor (`doc_fluff`), or prose, a description or summary, or the text of a component doc writes `astryx docs <name>` where a link would be checked (`stray_doc_pointer`)',+ 'A link names no doc (`invalid_doc_graph`), two topics repeat a passage word for word (`copied_passage`), prose pads with a listed phrase or falls under the density floor (`doc_fluff`), or prose, a description or summary, or the text of a component doc writes `{@command docs <name>}` where a link would be checked (`stray_doc_pointer`)',],[- '`astryx integration check`',+ '`{@command integration check}`','Everything the four `doctor integration` checks prove, in one command, for your build','Any of the four would exit 1 on its own. With `--strict`, also any warning, and any check that did not run, such as a package with no `astryx.integration.*`','Anything the four warn about, unless you pass `--strict`',],[- '`astryx integration verify`',+ '`{@command integration verify}`','The packed package holds every file, shows the same contributions, resolves every public import, and declares the CLI it needs','Anything `validate` fails on, no manifest, a file left out of the `.tgz` file, an import that does not resolve, or a missing CLI peer','Anything `validate` warns about, or a component sets `replaces` and the package does not declare the CLI range that turns it on (`component_replaces_needs_cli`)',@@ -68,7 +68,7 @@ export const docs = {},{type: 'prose',- text: 'Pass a package name, such as `astryx doctor integration validate @acme/astryx-widgets`, to check an installed copy from an app instead. To fix a props finding, see {@link generic:check-the-props}.',+ text: 'Pass a package name, such as `{@command doctor integration validate @acme/astryx-widgets}`, to check an installed copy from an app instead. To fix a props finding, see {@link generic:check-the-props}.',},],},@@ -93,7 +93,7 @@ export const docs = {'`--strict` also exits 1 on any warning and on any check that did not run. Without it, warnings keep exit code 0: use that while you fix the warnings a package already has.','Its exit codes and JSON are a contract for your build: a new check, or a new failure code, joins only in a minor release that names it in the release notes. A patch can still ship a Core component, template, or CLI topic whose name conflicts with one of yours.','`integration verify` runs `validate` but none of the other three: a Core name clash, a `replaces` that names no Core template, a topic that takes a Core name, or a hidden guide still passes it. Run both before you publish: `astryx integration check --strict && astryx integration verify`.',- 'Bare `astryx doctor` in the package also warns about a doc section over 32 KB, which no check above measures.',+ 'Bare `{@command doctor}` in the package also warns about a doc section over 32 KB, which no check above measures.',],},],@@ -110,7 +110,7 @@ export const docs = {type: 'list',style: 'ordered',items: [- 'It runs `npm pack` the way `npm publish` would, including your `prepack` script.',+ 'It runs `{@pm-only npm "the tarball the registry receives" pack}` the way `{@pm-only npm "npm is the client the registry publishes from" publish}` would, including your `prepack` script.','It checks that every contribution file is in the `.tgz` file. A root missing from `files` fails with `Add "templates" to "files" in package.json.`','It lists the components, templates, themes, docs, and codemods the temporary app sees, and compares them with your source.',"It resolves each component's `import`, and each template's public import, the way Node does, and checks that the module exports the component under the name its doc documents, or a default export for a template. A type-only export does not count.",diff --git a/packages/cli/assets/docs/tree/ci-and-containers.doc.mjs b/packages/cli/assets/docs/tree/ci-and-containers.doc.mjsindex 622ae4d76a..cdc7193a10 100644--- a/packages/cli/assets/docs/tree/ci-and-containers.doc.mjs+++ b/packages/cli/assets/docs/tree/ci-and-containers.doc.mjs@@ -83,7 +83,7 @@ export const docs = {content: [{type: 'prose',- text: 'Some agent machines keep the home folder across restarts but not system folders. A global install there disappears on restart while the agent guide in the home folder stays, so agents are told to run a global astryx command that is gone; the guide says to run the command that installed the CLI, such as `npm i -g @astryxdesign/cli`, when that command is not found, and `astryx doctor` names the same step. To keep the CLI across restarts, install it into a folder in your home and put its `bin` folder on your PATH, as for a permission error ({@link generic:install-once}), or run that command when the machine starts.',+ text: 'Some agent machines keep the home folder across restarts but not system folders. A global install there disappears on restart while the agent guide in the home folder stays, so agents are told to run a global astryx command that is gone; the guide says to run the command that installed the CLI, such as `{@pm install @astryxdesign/cli --global}`, when that command is not found, and `astryx doctor` names the same step. To keep the CLI across restarts, install it into a folder in your home and put its `bin` folder on your PATH, as for a permission error ({@link generic:install-once}), or run that command when the machine starts.',},],},diff --git a/packages/cli/assets/docs/tree/cli-command.doc.mjs b/packages/cli/assets/docs/tree/cli-command.doc.mjsindex 14b449efa3..8500640ef0 100644--- a/packages/cli/assets/docs/tree/cli-command.doc.mjs+++ b/packages/cli/assets/docs/tree/cli-command.doc.mjs@@ -29,7 +29,7 @@ export const docs = {content: [{type: 'prose',- text: "The CLI ends most answers with the next command to run: a hint, an error fix, a Doctor fix, or a doc example. By default each one starts with a command that reaches the release that answered: what the app's package manager runs, such as `pnpm exec astryx` or `yarn astryx`, when the app's own CLI answered, and otherwise the CLI package pinned to that release, such as `npx @astryxdesign/[email protected]`.",+ text: "The CLI ends most answers with the next command to run: a hint, an error fix, a Doctor fix, or a doc example. By default each one starts with a command that reaches the release that answered: what the app's package manager runs, such as `pnpm exec astryx` or `yarn astryx`, when the app's own CLI answered, and otherwise the CLI package pinned to that release, such as `{@pm dlx @astryxdesign/[email protected]}`.",},{type: 'prose',@@ -79,7 +79,7 @@ export default {items: ['The `cliCommand` of the packages the app loads, when they name one command.','The command a host tool names when it runs the CLI for the app. Nothing in a plain project names one.',- "A command that reaches the release that answered: what the app's package manager runs when the app's own CLI answered, such as `pnpm exec astryx` or `yarn astryx`; `astryx` outside a project when the CLI installed for the computer answered; otherwise the CLI package pinned to that release, such as `npx @astryxdesign/[email protected]` (see {@link generic:who-answers}).",+ "A command that reaches the release that answered: what the app's package manager runs when the app's own CLI answered, such as `pnpm exec astryx` or `yarn astryx`; `astryx` outside a project when the CLI installed for the computer answered; otherwise the CLI package pinned to that release, such as `{@pm dlx @astryxdesign/[email protected]}` (see {@link generic:who-answers}).",],},{@@ -94,7 +94,7 @@ export default {content: [{type: 'prose',- text: "If two packages an app loads set different commands, the CLI uses neither: it prints commands with what the app's package manager runs, even when a host tool named a command. `astryx doctor` warns in its `cli-command` check and names both packages:",+ text: "If two packages an app loads set different commands, the CLI uses neither: it prints commands with what the app's package manager runs, even when a host tool named a command. `{@command doctor}` warns in its `cli-command` check and names both packages:",},{type: 'code',@@ -115,16 +115,16 @@ message: Loaded integrations declare different CLI commands: @acme/astryx-widgetcontent: [{type: 'prose',- text: 'An invalid value is ignored, and the rest of your manifest still loads. `astryx doctor integration validate` reports it as `invalid_cli_command`. A valid `cliCommand` is one line of plain text without spaces at either end, at most 120 characters.',+ text: 'An invalid value is ignored, and the rest of your manifest still loads. `{@command doctor integration validate}` reports it as `invalid_cli_command`. A valid `cliCommand` is one line of plain text without spaces at either end, at most 120 characters.',},{type: 'prose',- text: "In an app that installs your package, `astryx doctor` passes its `cli-command` check and names your package as the one that set the command. A CLI released before this field reports `cliCommand` as an unknown key and prints the package manager's command.",+ text: "In an app that installs your package, `{@command doctor}` passes its `cli-command` check and names your package as the one that set the command. A CLI released before this field reports `cliCommand` as an unknown key and prints the package manager's command.",},{type: 'code',lang: 'bash',- code: 'astryx doctor integration validate\n# In an app that installs the package\nastryx doctor',+ code: '{@command doctor integration validate}\n# In an app that installs the package\n{@command doctor}',},],},diff --git a/packages/cli/assets/docs/tree/codemods.doc.mjs b/packages/cli/assets/docs/tree/codemods.doc.mjsindex 71a8278de1..9a2f8278a7 100644--- a/packages/cli/assets/docs/tree/codemods.doc.mjs+++ b/packages/cli/assets/docs/tree/codemods.doc.mjs@@ -14,7 +14,7 @@ export const docs = {category: 'guide',keywords: ['breaking change', 'migrate apps', 'integration codemod'],description:- 'Ship codemods that `astryx upgrade` runs to migrate app code, and know which of them an app runs.',+ 'Ship codemods that `{@command upgrade}` runs to migrate app code, and know which of them an app runs.',sections: [{id: 'add-a-codemod',@@ -22,12 +22,12 @@ export const docs = {content: [{type: 'prose',- text: '`integration add codemod` writes a codemod into a folder named after a version. Apps run it with `astryx upgrade` to migrate their code.',+ text: '`integration add codemod` writes a codemod into a folder named after a version. Apps run it with `{@command upgrade}` to migrate their code.',},{type: 'code',lang: 'bash',- code: 'astryx integration add codemod rename-delay --to 0.7.0',+ code: '{@command integration add codemod rename-delay --to 0.7.0}',},{type: 'code',@@ -92,7 +92,7 @@ export default {content: [{type: 'prose',- text: "Two rules decide whether an app's `astryx upgrade` runs your codemods: the app's Core versions, and whether the app names your package.",+ text: "Two rules decide whether an app's `{@command upgrade}` runs your codemods: the app's Core versions, and whether the app names your package.",},{type: 'list',@@ -110,15 +110,15 @@ export default {content: [{type: 'prose',- text: 'An app previews codemods with `astryx upgrade` and writes the changes with `--apply`. Without `--apply`, nothing on disk changes.',+ text: 'An app previews codemods with `{@command upgrade}` and writes the changes with `--apply`. Without `--apply`, nothing on disk changes.',},{type: 'code',lang: 'bash',code: `# Preview each codemod and the files it would change-astryx upgrade --from 0.6.3 --integration @acme/astryx-widgets+{@command upgrade --from 0.6.3 --integration @acme/astryx-widgets}# Write the changes-astryx upgrade --from 0.6.3 --integration @acme/astryx-widgets --apply`,+{@command upgrade --from 0.6.3 --integration @acme/astryx-widgets --apply}`,},{type: 'code',diff --git a/packages/cli/assets/docs/tree/component-family.doc.mjs b/packages/cli/assets/docs/tree/component-family.doc.mjsindex 9921ec8490..9fa4a78136 100644--- a/packages/cli/assets/docs/tree/component-family.doc.mjs+++ b/packages/cli/assets/docs/tree/component-family.doc.mjs@@ -93,7 +93,7 @@ export default {},{type: 'prose',- text: "The public module named by `import` must export every component or hook named by a full entry. Apps then list, search and open each component in the family by its own name. A full entry the module does not export is not listed, and `integration verify` does not report it: check the family with `astryx component --list`. When `import` names output your pack lifecycle builds (such as `dist`), the members are listed once that output exists, and `integration verify` compares them as they are listed after the pack builds it.",+ text: 'The public module named by `import` must export every component or hook named by a full entry. Apps then list, search and open each component in the family by its own name. A full entry the module does not export is not listed, and `integration verify` does not report it: check the family with `{@command component --list}`. When `import` names output your pack lifecycle builds (such as `dist`), the members are listed once that output exists, and `integration verify` compares them as they are listed after the pack builds it.',},{type: 'prose',diff --git a/packages/cli/assets/docs/tree/component-imports.doc.mjs b/packages/cli/assets/docs/tree/component-imports.doc.mjsindex 221ebde386..305868b08d 100644--- a/packages/cli/assets/docs/tree/component-imports.doc.mjs+++ b/packages/cli/assets/docs/tree/component-imports.doc.mjs@@ -41,7 +41,7 @@ export const docs = {},{type: 'prose',- text: "The file name still opens the doc. A name that Core or another doc's file already has stays theirs, and so does a Core name your package replaces: with `Badge.doc.mjs` naming `AcmeBadge`, `astryx component Badge` opens Core's `Badge`, and `--package` with your package name reaches yours.",+ text: "The file name still opens the doc. A name that Core or another doc's file already has stays theirs, and so does a Core name your package replaces: with `Badge.doc.mjs` naming `AcmeBadge`, `{@command component Badge}` opens Core's `Badge`, and `--package` with your package name reaches yours.",},],},@@ -56,7 +56,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration verify',+ code: '{@command integration verify}',},{type: 'list',diff --git a/packages/cli/assets/docs/tree/component-lookups.doc.mjs b/packages/cli/assets/docs/tree/component-lookups.doc.mjsindex 3914c7d314..3c92d2b5a3 100644--- a/packages/cli/assets/docs/tree/component-lookups.doc.mjs+++ b/packages/cli/assets/docs/tree/component-lookups.doc.mjs@@ -23,13 +23,13 @@ export const docs = {content: [{type: 'prose',- text: '`astryx component` accepts exact selectors as a variadic positional argument. With no selector it browses the catalog. With one selector it keeps the normal single-component response. With two or more it prints one complete ordered batch receipt.',+ text: '`{@command component}` accepts exact selectors as a variadic positional argument. With no selector it browses the catalog. With one selector it keeps the normal single-component response. With two or more it prints one complete ordered batch receipt.',},{type: 'code',lang: 'bash',label: 'Several component docs',- code: 'astryx component Button Badge Text\nastryx --json component Button Badge Text',+ code: '{@command component Button Badge Text}\nastryx --json component Button Badge Text',},{type: 'prose',@@ -47,7 +47,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Focused batch lookups',- code: 'astryx --json component Button Card --props\nastryx component Button Card --source\nastryx component Button Card --showcase\nastryx component Button Card --blocks\nastryx component Button Card --detail compact\nastryx component Button Card --lang dense\nastryx component Button Card --package @astryxdesign/core',+ code: 'astryx --json component Button Card --props\n{@command component Button Card --source}\n{@command component Button Card --showcase}\n{@command component Button Card --blocks}\n{@command component Button Card --detail compact}\n{@command component Button Card --lang dense}\n{@command component Button Card --package @astryxdesign/core}',},],},@@ -76,7 +76,7 @@ export const docs = {},{type: 'prose',- text: '`astryx discover` remains free-text package discovery. Its words form one query; they are not component batch selectors.',+ text: '`{@command discover}` remains free-text package discovery. Its words form one query; they are not component batch selectors.',},],},diff --git a/packages/cli/assets/docs/tree/computer-agent-guide.doc.mjs b/packages/cli/assets/docs/tree/computer-agent-guide.doc.mjsindex 03a2391a07..5324ae17d5 100644--- a/packages/cli/assets/docs/tree/computer-agent-guide.doc.mjs+++ b/packages/cli/assets/docs/tree/computer-agent-guide.doc.mjs@@ -32,7 +32,7 @@ export const docs = {'link skills',],description:- 'Your global install keeps one short Astryx skill in your home folder and links it into the folders agent tools read, so agents anywhere know Astryx is there. `astryx init --user` writes it now or turns it off.',+ 'Your global install keeps one short Astryx skill in your home folder and links it into the folders agent tools read, so agents anywhere know Astryx is there. `{@command init --user}` writes it now or turns it off.',sections: [{id: 'what',@@ -40,7 +40,7 @@ export const docs = {content: [{type: 'prose',- text: "A project's agent docs reach only agents working in that project. Your global install also keeps one skill file, `~/.agents/skills/astryx/SKILL.md`, which most coding agents read. It tells agents that Astryx is on this computer, when it is relevant (building or changing UI), and to start with `astryx search`. It names no version, so it never goes stale. Inside a project, the project's own agent docs come first.",+ text: "A project's agent docs reach only agents working in that project. Your global install also keeps one skill file, `~/.agents/skills/astryx/SKILL.md`, which most coding agents read. It tells agents that Astryx is on this computer, when it is relevant (building or changing UI), and to start with `{@command search}`. It names no version, so it never goes stale. Inside a project, the project's own agent docs come first.",},{type: 'prose',@@ -83,7 +83,7 @@ export const docs = {},{type: 'prose',- text: "Astryx never replaces anything it did not create at one of these folders, and never writes a folder another tool manages; `astryx doctor` names any it skipped, and any link whose skill folder is missing, as in a container that mounts only one agent's folder.",+ text: "Astryx never replaces anything it did not create at one of these folders, and never writes a folder another tool manages; `{@command doctor}` names any it skipped, and any link whose skill folder is missing, as in a container that mounts only one agent's folder.",},],},@@ -95,7 +95,7 @@ export const docs = {type: 'list',style: 'unordered',items: [- "Cloud and background agents read only the repository, so the project's own agent docs, the block `astryx init` writes into AGENTS.md or CLAUDE.md, are what reach them.",+ "Cloud and background agents read only the repository, so the project's own agent docs, the block `{@command init}` writes into AGENTS.md or CLAUDE.md, are what reach them.",'Apps that take an uploaded skill: upload `~/.agents/skills/astryx/SKILL.md`, or a zip of its folder.',],},@@ -132,16 +132,16 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx init --user\nastryx init --user --remove-agents',+ code: '{@command init --user}\n{@command init --user --remove-agents}',},{type: 'list',style: 'unordered',items: ['`init --user` writes the file and the links now.',- '`--remove-agents` removes the file and every link Astryx made, and turns it off until you run `astryx init --user` again.',+ '`--remove-agents` removes the file and every link Astryx made, and turns it off until you run `{@command init --user}` again.','A file you edited is never overwritten or removed; delete it to get the current text.',- 'Outside a project, `astryx doctor` says whether the skill is there, current, edited, or turned off, and where it is linked.',+ 'Outside a project, `{@command doctor}` says whether the skill is there, current, edited, or turned off, and where it is linked.',],},],diff --git a/packages/cli/assets/docs/tree/computer-integrations.doc.mjs b/packages/cli/assets/docs/tree/computer-integrations.doc.mjsindex 392e2cf1e4..05699f74c5 100644--- a/packages/cli/assets/docs/tree/computer-integrations.doc.mjs+++ b/packages/cli/assets/docs/tree/computer-integrations.doc.mjs@@ -37,7 +37,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm i -g @astryxdesign/cli @acme/widgets\n# or: pnpm add -g · yarn global add · bun add -g',+ code: '{@pm install @astryxdesign/cli @acme/widgets --global}',},{type: 'prose',@@ -51,7 +51,7 @@ export const docs = {content: [{type: 'prose',- text: 'In a folder outside any project, Astryx loads each integration installed next to your global install the way a project loads its own: its components, templates, docs, themes, and discover source show up, and a command name it declares starts the commands Astryx prints. One whose `@astryxdesign/core` or `@astryxdesign/cli` peer range leaves out your global version is skipped, and `astryx doctor` says why.',+ text: 'In a folder outside any project, Astryx loads each integration installed next to your global install the way a project loads its own: its components, templates, docs, themes, and discover source show up, and a command name it declares starts the commands Astryx prints. One whose `@astryxdesign/core` or `@astryxdesign/cli` peer range leaves out your global version is skipped, and `{@command doctor}` says why.',},],},@@ -61,7 +61,7 @@ export const docs = {content: [{type: 'prose',- text: "A project's answers must match what it installs: a component from a package it does not install would not build. So inside a project, an integration installed only globally adds nothing. `astryx discover` lists it among the packages the project could add, with the project's install command, when it supports the project's version and loads. When the project installs the same integration, the project's copy is the one used.",+ text: "A project's answers must match what it installs: a component from a package it does not install would not build. So inside a project, an integration installed only globally adds nothing. `{@command discover}` lists it among the packages the project could add, with the project's install command, when it supports the project's version and loads. When the project installs the same integration, the project's copy is the one used.",},],},@@ -73,8 +73,8 @@ export const docs = {type: 'list',style: 'unordered',items: [- 'Outside a project, `astryx doctor` lists the global integrations it uses and warns about each it skips.',- 'Inside a project, `astryx doctor` and `astryx discover` list the ones the project could add.',+ 'Outside a project, `{@command doctor}` lists the global integrations it uses and warns about each it skips.',+ 'Inside a project, `{@command doctor}` and `{@command discover}` list the ones the project could add.',],},],diff --git a/packages/cli/assets/docs/tree/debug-and-gap-reports.doc.mjs b/packages/cli/assets/docs/tree/debug-and-gap-reports.doc.mjsindex 643e9d281d..051d2b3a70 100644--- a/packages/cli/assets/docs/tree/debug-and-gap-reports.doc.mjs+++ b/packages/cli/assets/docs/tree/debug-and-gap-reports.doc.mjs@@ -85,7 +85,7 @@ export default {content: [{type: 'prose',- text: 'Export a `gapReport` handler, and `astryx gap-report` in an app sends it each gap report, such as a missing component or variant. The handler files the report and returns a receipt.',+ text: 'Export a `gapReport` handler, and `{@command gap-report}` in an app sends it each gap report, such as a missing component or variant. The handler files the report and returns a receipt.',},{type: 'code',@@ -127,7 +127,7 @@ export const gapReport = {{type: 'code',lang: 'bash',- code: "astryx gap-report AcmeCarousel --category missing_variant --reason 'Need a vertical layout'",+ code: "{@command gap-report AcmeCarousel --category missing_variant --reason 'Need a vertical layout'}",},{type: 'code',@@ -173,7 +173,7 @@ message: Rerun with --confirm-public to file this report.`,content: [{type: 'prose',- text: 'When an app loads packages naming their own `issuesUrl`, a report can go to the default (the handlers, or the fallback above) or to one of those packages. `astryx gap-report --list-categories` and the receipt of a report filed without `--to` list every destination, with a line telling the agent to ask the person.',+ text: 'When an app loads packages naming their own `issuesUrl`, a report can go to the default (the handlers, or the fallback above) or to one of those packages. `{@command gap-report --list-categories}` and the receipt of a report filed without `--to` list every destination, with a line telling the agent to ask the person.',},{type: 'list',diff --git a/packages/cli/assets/docs/tree/define-the-theme.doc.mjs b/packages/cli/assets/docs/tree/define-the-theme.doc.mjsindex 90f2715862..10f8bf993c 100644--- a/packages/cli/assets/docs/tree/define-the-theme.doc.mjs+++ b/packages/cli/assets/docs/tree/define-the-theme.doc.mjs@@ -45,7 +45,7 @@ export const oceanTheme = defineTheme({},{type: 'prose',- text: 'Local imports must stay inside the theme folder. One that leaves it, such as `../../shared/colors`, fails with `invalid_theme`, and every theme in the package disappears from `theme list`. `astryx theme template` writes a file that explains every `defineTheme` field. For the full token set and component theming, read {@link generic:author-a-theme}.',+ text: 'Local imports must stay inside the theme folder. One that leaves it, such as `../../shared/colors`, fails with `invalid_theme`, and every theme in the package disappears from `theme list`. `{@command theme template}` writes a file that explains every `defineTheme` field. For the full token set and component theming, read {@link generic:author-a-theme}.',},],},diff --git a/packages/cli/assets/docs/tree/describe-the-component.doc.mjs b/packages/cli/assets/docs/tree/describe-the-component.doc.mjsindex 3e7a5ceb88..96b0e7ee0b 100644--- a/packages/cli/assets/docs/tree/describe-the-component.doc.mjs+++ b/packages/cli/assets/docs/tree/describe-the-component.doc.mjs@@ -51,7 +51,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx component AcmeCarousel',+ code: '{@command component AcmeCarousel}',},],};diff --git a/packages/cli/assets/docs/tree/doc-syntax.doc.mjs b/packages/cli/assets/docs/tree/doc-syntax.doc.mjsnew file mode 100644index 0000000000..c0893e4dbd--- /dev/null+++ b/packages/cli/assets/docs/tree/doc-syntax.doc.mjs@@ -0,0 +1,219 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file `astryx docs authoring/building-blocks/docs/doc-syntax`: the+ * tokens a doc writes for what the CLI shows each reader differently: a link,+ * an Astryx command, a package-manager step, and a step only one package+ * manager can do.+ */++/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */+export const docs = {+ type: 'generic',+ name: 'doc-syntax',+ placement: {parent: 'namespace:docs', slot: 'guides', order: 15},+ title: 'Doc syntax',+ category: 'guide',+ description:+ 'The tokens a doc writes for links, Astryx commands and package-manager steps, which the CLI shows each reader in their own package manager.',+ keywords: [+ 'doc syntax',+ 'tokens',+ 'package manager',+ 'npm',+ 'pnpm',+ 'yarn',+ 'bun',+ 'install command',+ 'pm token',+ 'command token',+ ],+ sections: [+ {+ id: 'the-tokens',+ title: 'The tokens',+ content: [+ {+ type: 'prose',+ text: 'A doc never names a package manager or a runner: readers use npm, pnpm, Yarn or Bun, and run the CLI through their own. Write a token instead, and the CLI shows each reader the command they run. Tokens work in prose, list items, table cells and code blocks.',+ },+ {+ type: 'table',+ headers: ['Write', 'For', 'A pnpm reader sees'],+ rows: [+ [+ '`{@@link generic:deploying}`',+ 'another doc',+ 'the command that opens that doc',+ ],+ [+ '`{@@command docs theme}`',+ 'an Astryx command',+ '`pnpm exec astryx docs theme`',+ ],+ [+ '`{@@pm install @acme/widgets --dev}`',+ 'a package-manager step',+ '`pnpm add -D @acme/widgets`',+ ],+ [+ '`{@@pm-only npm "why" pkg set name=x}`',+ 'a step only one package manager can do',+ '`npm pkg set name=x` (only with npm: why)',+ ],+ [+ '`{@@@pm install x}`',+ 'a token shown as written',+ '`{@@pm install x}`',+ ],+ ],+ },+ {+ type: 'prose',+ text: 'In prose a token prints as a code span; in a code span or code block it prints as the command alone. `--json` carries the same commands, a `{@@command}` token as the bare command that starts with astryx, which a reader that shows the doc prefixes itself.',+ },+ ],+ },+ {+ id: 'package-manager-steps',+ title: 'Package-manager steps',+ content: [+ {+ type: 'prose',+ text: "A `{@@pm}` token is a verb, its names, and the flags it takes. Each row below runs the same way in every package manager; the CLI writes the reader's own.",+ },+ {+ type: 'table',+ headers: ['Token', 'npm', 'pnpm', 'Yarn', 'Bun'],+ rows: [+ [+ '`{@@pm install}`',+ '`npm install`',+ '`pnpm install`',+ '`yarn install`',+ '`bun install`',+ ],+ [+ '`{@@pm install x}`',+ '`npm install x`',+ '`pnpm add x`',+ '`yarn add x`',+ '`bun add x`',+ ],+ [+ '`{@@pm install x --dev}`',+ '`npm install -D x`',+ '`pnpm add -D x`',+ '`yarn add -D x`',+ '`bun add -d x`',+ ],+ [+ '`{@@pm install x --global}`',+ '`npm install -g x`',+ '`pnpm add -g x`',+ '`yarn global add x` (Yarn 1); npm on Yarn 2 and newer',+ '`bun add -g x`',+ ],+ [+ '`{@@pm remove x}`',+ '`npm uninstall x`',+ '`pnpm remove x`',+ '`yarn remove x`',+ '`bun remove x`',+ ],+ [+ '`{@@pm update x --latest}`',+ '`npm install x@latest`',+ '`pnpm update --latest x`',+ '`yarn up x`',+ '`bun update --latest x`',+ ],+ [+ '`{@@pm run build --watch}`',+ '`npm run build -- --watch`',+ '`pnpm run build --watch`',+ '`yarn run build --watch`',+ '`bun run build --watch`',+ ],+ [+ '`{@@pm exec tsc}`',+ '`npx tsc`',+ '`pnpm exec tsc`',+ '`yarn run tsc`',+ '`bunx tsc`',+ ],+ [+ '`{@@pm dlx @astryxdesign/cli init}`',+ '`npx @astryxdesign/cli init`',+ '`pnpm dlx @astryxdesign/cli init`',+ '`yarn dlx …` (`npx` on Yarn 1)',+ '`bunx @astryxdesign/cli init`',+ ],+ [+ '`{@@pm create vite}`',+ '`npm create vite`',+ '`pnpm create vite`',+ '`yarn create vite`',+ '`bun create vite`',+ ],+ ],+ },+ {+ type: 'list',+ style: 'unordered',+ items: [+ 'Flags: `--dev` and `--exact` with `install`, `--global` with `install` and `remove`, `--latest` with `update`. `--exact` takes one version, never a range: only npm pins a range.',+ 'Everything after the name of a script (`run`), a binary (`exec`) or a package (`dlx`, `create`) is passed to it as written.',+ '`{@@pm install x --global}` on pnpm needs `pnpm setup` once per computer.',+ ],+ },+ ],+ },+ {+ id: 'one-package-manager',+ title: 'A step only one package manager can do',+ content: [+ {+ type: 'prose',+ text: 'Some commands exist in one package manager only, such as `npm pkg set` or `pnpm setup`. Write `{@@pm-only <manager> "<reason>" <command>}`: the manager is one of npm, pnpm, yarn, yarn-classic or bun, and the reason, in double quotes, is shown to readers beside the command. Use it only when no `{@@pm}` step does the same: doctor names a one-manager step that every package manager can run, with the `{@@pm}` token to write.',+ },+ ],+ },+ {+ id: 'what-doctor-checks',+ title: 'What doctor checks',+ content: [+ {+ type: 'prose',+ text: '`doctor integration validate`, and so `integration check`, lists each of these as a note with its file, line and the token to write. A note fails nothing today; the next minor release turns them into warnings, so `integration check --strict --next` fails on them now. Run it to fix them ahead.',+ },+ {+ type: 'table',+ headers: ['Note', 'When'],+ rows: [+ [+ '`package_manager_command`',+ 'a code span or shell line written for one package manager, such as `npm install -D x`',+ ],+ [+ '`runner_command`',+ 'an Astryx command written with a runner, such as `pnpm exec astryx docs`',+ ],+ [+ '`plain_command`',+ 'an Astryx command written bare, where `{@@command docs}` checks that the command exists',+ ],+ [+ '`doc_token`',+ 'a token that does not parse, or a name that is not a doc token',+ ],+ ],+ },+ {+ type: 'prose',+ text: "In global mode: outside a project, a `{@@command}` token prints the way your global install prints every command, and a `{@@pm}` step prints for npm unless the CLI detects another package manager. In a project, the project's own runner and package manager decide. See {@link namespace:global}.",+ },+ ],+ },+ ],+};diff --git a/packages/cli/assets/docs/tree/export-template-assets.doc.mjs b/packages/cli/assets/docs/tree/export-template-assets.doc.mjsindex 04bd034f39..de53ea9c20 100644--- a/packages/cli/assets/docs/tree/export-template-assets.doc.mjs+++ b/packages/cli/assets/docs/tree/export-template-assets.doc.mjs@@ -106,7 +106,7 @@ export const docs = {items: ['`integration add` appends the manifest and templates directory when a `files` list already exists. Add the other directories yourself.','If `package.json` sets `sideEffects`, include CSS in it, as above, so bundlers keep side-effect stylesheet imports.',- 'Run `npm pack --dry-run` and read the real file list instead of reasoning from the workspace.',+ 'Run `{@pm-only npm "the tarball the registry receives" pack --dry-run}` and read the real file list instead of reasoning from the workspace.',],},],diff --git a/packages/cli/assets/docs/tree/extend-or-replace.doc.mjs b/packages/cli/assets/docs/tree/extend-or-replace.doc.mjsindex 6b5b3efd65..643c2b98df 100644--- a/packages/cli/assets/docs/tree/extend-or-replace.doc.mjs+++ b/packages/cli/assets/docs/tree/extend-or-replace.doc.mjs@@ -27,7 +27,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add doc acme-getting-started --replaces getting-started\n# The old name now opens your topic\nastryx docs getting-started',+ code: '{@command integration add doc acme-getting-started --replaces getting-started}\n# The old name now opens your topic\n{@command docs getting-started}',},{type: 'code',@@ -52,7 +52,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add doc acme-theming --extends theme\nastryx docs theme --index',+ code: '{@command integration add doc acme-theming --extends theme}\n{@command docs theme --index}',},{type: 'code',@@ -114,7 +114,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx doctor integration docs',+ code: '{@command doctor integration docs}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/font-setup.doc.mjs b/packages/cli/assets/docs/tree/font-setup.doc.mjsindex c8e71f87e4..e70f35af17 100644--- a/packages/cli/assets/docs/tree/font-setup.doc.mjs+++ b/packages/cli/assets/docs/tree/font-setup.doc.mjs@@ -60,7 +60,7 @@ export const docs = {content: [{type: 'prose',- text: 'Astryx never loads font files. defineTheme and the built CSS only set font-family: naming a webfont (Fraunces, JetBrains Mono, and so on) makes every browser look for it, and quietly fall back when the app has not loaded it. `astryx theme build` warns when a theme names families that are neither CSS generics nor common system fonts and prints the snippet to add; loading the font is always the app\'s job.',+ text: "Astryx never loads font files. defineTheme and the built CSS only set font-family: naming a webfont (Fraunces, JetBrains Mono, and so on) makes every browser look for it, and quietly fall back when the app has not loaded it. `{@command theme build}` warns when a theme names families that are neither CSS generics nor common system fonts and prints the snippet to add; loading the font is always the app's job.",},{type: 'code',diff --git a/packages/cli/assets/docs/tree/generate-a-palette.doc.mjs b/packages/cli/assets/docs/tree/generate-a-palette.doc.mjsindex 346d7c316c..685a7cd5e7 100644--- a/packages/cli/assets/docs/tree/generate-a-palette.doc.mjs+++ b/packages/cli/assets/docs/tree/generate-a-palette.doc.mjs@@ -40,7 +40,7 @@ export const docs = {type: 'code',lang: 'bash',code: `# Print the palette without writing files-astryx theme palette generate themes/ocean/palette.config.json+{@command theme palette generate themes/ocean/palette.config.json}# Write the palette and its receiptastryx theme palette generate themes/ocean/palette.config.json \\--out themes/ocean/tokens/ocean.palette.ts`,diff --git a/packages/cli/assets/docs/tree/global-integrations.doc.mjs b/packages/cli/assets/docs/tree/global-integrations.doc.mjsindex 3f07b2d42e..a70209a499 100644--- a/packages/cli/assets/docs/tree/global-integrations.doc.mjs+++ b/packages/cli/assets/docs/tree/global-integrations.doc.mjs@@ -37,11 +37,11 @@ export const docs = {content: [{type: 'prose',- text: 'Your `@astryxdesign/core` (and, if you use it, `@astryxdesign/cli`) `peerDependencies` ranges must include the version of the CLI installed globally. If they do not, Astryx skips your package outside projects, and `astryx doctor` warns and names the range.',+ text: 'Your `@astryxdesign/core` (and, if you use it, `@astryxdesign/cli`) `peerDependencies` ranges must include the version of the CLI installed globally. If they do not, Astryx skips your package outside projects, and `{@command doctor}` warns and names the range.',},{type: 'prose',- text: "Inside a project that does not install your package, `astryx discover` offers it, with the command that adds it to that project, once your peer range admits the project's release.",+ text: "Inside a project that does not install your package, `{@command discover}` offers it, with the command that adds it to that project, once your peer range admits the project's release.",},],},@@ -54,8 +54,8 @@ export const docs = {style: 'unordered',items: ["Installed in an app: it works in that app, as always, whichever `astryx` the person runs, because the app's version of Astryx answers there.",- 'Installed next to the global install (`npm i -g @astryxdesign/cli your-package`), or in the same folder as the CLI by a tool that installs them together: it works in every folder outside a project. People and agents there see its components, templates, docs, themes, codemods, and discover source.',- "Installed only globally, inside an app that does not install it: it adds nothing there. When it supports the app's version and loads, `astryx discover` lists it as one the app could add, with the app's install command.",+ 'Installed next to the global install (`{@pm install @astryxdesign/cli your-package --global}`), or in the same folder as the CLI by a tool that installs them together: it works in every folder outside a project. People and agents there see its components, templates, docs, themes, codemods, and discover source.',+ "Installed only globally, inside an app that does not install it: it adds nothing there. When it supports the app's version and loads, `{@command discover}` lists it as one the app could add, with the app's install command.","Installed both ways: the app's copy is the one used in that app. In your own package folder, your working copy is used.",],},@@ -73,7 +73,7 @@ export const docs = {type: 'list',style: 'unordered',items: [- 'Declare the `@astryxdesign/core` (and, if you use it, `@astryxdesign/cli`) `peerDependencies` range your package really supports. Outside a project, Astryx skips your package when that range leaves out the global version, and `astryx doctor` says why: too narrow, and global users lose it after an upgrade; too wide, and it loads against a Core it may not build with.',+ 'Declare the `@astryxdesign/core` (and, if you use it, `@astryxdesign/cli`) `peerDependencies` range your package really supports. Outside a project, Astryx skips your package when that range leaves out the global version, and `{@command doctor}` says why: too narrow, and global users lose it after an upgrade; too wide, and it loads against a Core it may not build with.','Keep imports in your docs and templates to packages an app installs with yours, since outside a project there is no app to check them against.',"If you set `cliCommand`, know that outside a project it starts every command Astryx prints, and that two global integrations naming different commands cancel out, falling back to `astryx` ({@link generic:cli-command}). Inside an app, only the app's integrations count.",'Try it globally before you publish, with the steps below.',@@ -92,21 +92,21 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm pack\nnpm i -g @astryxdesign/cli ./your-package-1.0.0.tgz\nmkdir -p /tmp/try-global && cd /tmp/try-global\nastryx discover\nastryx docs\nastryx doctor',+ code: '{@pm-only npm "the tarball the registry receives" pack}\n{@pm install @astryxdesign/cli ./your-package-1.0.0.tgz --global}\nmkdir -p /tmp/try-global && cd /tmp/try-global\n{@command discover}\n{@command docs}\n{@command doctor}',},{type: 'list',style: 'unordered',items: [- '`astryx discover` lists your package as installed, with what it adds.',- '`astryx docs` lists your topics, and `astryx search <one of your component names>` finds them.',- "`astryx doctor`'s `computer-integrations` check lists your package as used, with no warning.",- "In an app that does not install it, `astryx discover` lists it as one the app could add, with the app's install command, and none of its components or docs show up.",+ '`{@command discover}` lists your package as installed, with what it adds.',+ '`{@command docs}` lists your topics, and `{@command search <one of your component names>}` finds them.',+ "`{@command doctor}`'s `computer-integrations` check lists your package as used, with no warning.",+ "In an app that does not install it, `{@command discover}` lists it as one the app could add, with the app's install command, and none of its components or docs show up.",],},{type: 'prose',- text: 'Remove it again with `npm uninstall -g your-package`.',+ text: 'Remove it again with `{@pm remove your-package --global}`.',},],},diff --git a/packages/cli/assets/docs/tree/global.doc.mjs b/packages/cli/assets/docs/tree/global.doc.mjsindex 11afee6304..f1deccd141 100644--- a/packages/cli/assets/docs/tree/global.doc.mjs+++ b/packages/cli/assets/docs/tree/global.doc.mjs@@ -42,7 +42,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm i -g @astryxdesign/cli',+ code: '{@pm install @astryxdesign/cli --global}',},{type: 'heading',@@ -73,7 +73,7 @@ export const docs = {],['Outside any project', 'Your global version.'],[- 'Commands for your computer, such as `astryx init --user`',+ 'Commands for your computer, such as `{@command init --user}`','Your global version, in any folder.',],],diff --git a/packages/cli/assets/docs/tree/host-entry.doc.mjs b/packages/cli/assets/docs/tree/host-entry.doc.mjsindex d507c2148c..0aa14cbdbd 100644--- a/packages/cli/assets/docs/tree/host-entry.doc.mjs+++ b/packages/cli/assets/docs/tree/host-entry.doc.mjs@@ -82,7 +82,7 @@ export const docs = {['`discoverSources`','none',- "Your own discover sources. `astryx discover` reports each as the host's.",+ "Your own discover sources. `{@command discover}` reports each as the host's.",],],},diff --git a/packages/cli/assets/docs/tree/install-once.doc.mjs b/packages/cli/assets/docs/tree/install-once.doc.mjsindex 024456773b..b83f24269f 100644--- a/packages/cli/assets/docs/tree/install-once.doc.mjs+++ b/packages/cli/assets/docs/tree/install-once.doc.mjs@@ -44,11 +44,11 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm i -g @astryxdesign/cli\n# or: pnpm add -g @astryxdesign/cli · yarn global add @astryxdesign/cli · bun add -g @astryxdesign/cli · volta install @astryxdesign/cli',+ code: '{@pm install @astryxdesign/cli --global}\n# with Volta: volta install @astryxdesign/cli',},{type: 'prose',- text: "Keep the CLI installed in each project too: that pins its version for teammates and CI ({@link generic:project-global-or-both}). Inside a project, whichever astryx command you type, the project's version answers. Outside a project, your global install answers with its own version, and a version you name, such as `npx @astryxdesign/[email protected]`, answers as exactly that version.",+ text: "Keep the CLI installed in each project too: that pins its version for teammates and CI ({@link generic:project-global-or-both}). Inside a project, whichever astryx command you type, the project's version answers. Outside a project, your global install answers with its own version, and a version you name, such as `{@pm dlx @astryxdesign/[email protected]}`, answers as exactly that version.",},],},@@ -63,7 +63,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm config set prefix ~/.npm-global\nexport PATH="$HOME/.npm-global/bin:$PATH"\nnpm i -g @astryxdesign/cli',+ code: '{@pm-only npm "moves the npm global folder" config set prefix ~/.npm-global}\nexport PATH="$HOME/.npm-global/bin:$PATH"\n{@pm-only npm "installs into the npm global folder above" i -g @astryxdesign/cli}',},{type: 'prose',@@ -87,7 +87,7 @@ export const docs = {content: [{type: 'prose',- text: "Your global install answers offline in a project with only Core, and so does any project that installs its own CLI. Outside a project, commands that read components, such as `astryx component Button`, need your global version's Core: after any command you run online, your global install downloads it once into the cache in the background, so they work offline from then on (not in CI, where nothing downloads by itself: {@link generic:ci-and-containers}; and not on Windows, where the first component command downloads it). Only a project whose own CLI cannot start needs a version installed or cached; when it is neither and cannot be fetched, your global install answers with a one-line warning, and Astryx waits 2 minutes before trying to download it again (10 minutes after a second failure in a row). {@link generic:problems} has the exact message.",+ text: "Your global install answers offline in a project with only Core, and so does any project that installs its own CLI. Outside a project, commands that read components, such as `{@command component Button}`, need your global version's Core: after any command you run online, your global install downloads it once into the cache in the background, so they work offline from then on (not in CI, where nothing downloads by itself: {@link generic:ci-and-containers}; and not on Windows, where the first component command downloads it). Only a project whose own CLI cannot start needs a version installed or cached; when it is neither and cannot be fetched, your global install answers with a one-line warning, and Astryx waits 2 minutes before trying to download it again (10 minutes after a second failure in a row). {@link generic:problems} has the exact message.",},],},diff --git a/packages/cli/assets/docs/tree/layout.doc.mjs b/packages/cli/assets/docs/tree/layout.doc.mjsindex 8d52e44782..4325333135 100644--- a/packages/cli/assets/docs/tree/layout.doc.mjs+++ b/packages/cli/assets/docs/tree/layout.doc.mjs@@ -46,7 +46,7 @@ export const docs = {},{type: 'prose',- text: 'This guide decides layout, not component APIs. Run `astryx build "<idea>"` to start from the closest template for your app type, and `astryx component <Name>` for a component\'s props.',+ text: 'This guide decides layout, not component APIs. Run `{@command build "<idea>"}` to start from the closest template for your app type, and `{@command component <Name>}` for a component\'s props.',},],slots: {diff --git a/packages/cli/assets/docs/tree/links.doc.mjs b/packages/cli/assets/docs/tree/links.doc.mjsindex ea6412c77d..795cb58149 100644--- a/packages/cli/assets/docs/tree/links.doc.mjs+++ b/packages/cli/assets/docs/tree/links.doc.mjs@@ -38,7 +38,7 @@ export const docs = {style: 'unordered',items: ['The kind is `generic` for a topic or guide, `namespace` for a docs section, `command` or `function` for a CLI command or API function, `schema` or `enum` for a schema or a fixed set of values, `component` for a component, and `page` or `block` for a template.',- 'Name a component by its export name and a template by its id. Its link reads as the command that opens it, such as `astryx component AcmeCarousel --package @acme/widgets`.',+ 'Name a component by its export name and a template by its id. Its link reads as the command that opens it, such as `{@command component AcmeCarousel --package @acme/widgets}`.','Inside backticks or a code block, link syntax prints as written.',],},@@ -78,7 +78,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx doctor integration docs',+ code: '{@command doctor integration docs}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/migration-setup.doc.mjs b/packages/cli/assets/docs/tree/migration-setup.doc.mjsindex 07feb53ca6..9baa76a070 100644--- a/packages/cli/assets/docs/tree/migration-setup.doc.mjs+++ b/packages/cli/assets/docs/tree/migration-setup.doc.mjs@@ -46,7 +46,7 @@ export const docs = {type: 'list',style: 'ordered',items: [- 'Install the packages and run `astryx init` for agent docs, then add the reset, `astryx.css`, and theme CSS imports (see Theme and CSS Setup below).',+ 'Install the packages and run `{@command init}` for agent docs, then add the reset, `astryx.css`, and theme CSS imports (see Theme and CSS Setup below).','Wrap the app root with Theme and choose the initial light, dark, or system mode behavior.','Make Tailwind and design system CSS layer order explicit before replacing components.','Render the foundation smoke test page and confirm primitives keep their padding before migrating any surface.',@@ -70,18 +70,18 @@ export const docs = {type: 'code',lang: 'bash',label: 'Migration-oriented CLI pass',- code: `astryx docs migration-astryx docs theme-astryx docs styling-astryx template --list --type block-astryx template AppShellTopNavWithSideNav --skeleton-astryx template PopoverSettingsPanel --skeleton-astryx component AppShell-astryx component SideNav-astryx component TopNav-astryx component CommandPalette-astryx component Button-astryx component TextInput`,+ code: `{@command docs migration}+{@command docs theme}+{@command docs styling}+{@command template --list --type block}+{@command template AppShellTopNavWithSideNav --skeleton}+{@command template PopoverSettingsPanel --skeleton}+{@command component AppShell}+{@command component SideNav}+{@command component TopNav}+{@command component CommandPalette}+{@command component Button}+{@command component TextInput}`,},{type: 'prose',@@ -91,8 +91,8 @@ astryx component TextInput`,type: 'code',lang: 'bash',label: 'Short and JSON modes',- code: `astryx docs migration --full --detail brief-astryx component Button --json`,+ code: `{@command docs migration --full --detail brief}+{@command component Button --json}`,},],},diff --git a/packages/cli/assets/docs/tree/other-libraries.doc.mjs b/packages/cli/assets/docs/tree/other-libraries.doc.mjsindex 6db25ce5c0..ed5aa6550e 100644--- a/packages/cli/assets/docs/tree/other-libraries.doc.mjs+++ b/packages/cli/assets/docs/tree/other-libraries.doc.mjs@@ -205,7 +205,7 @@ tokens: {type: 'list',style: 'ordered',items: [- 'Import the reset/base CSS and a theme CSS file early enough for first paint. For production SSR, prefer built themes from `astryx theme build` or published `/built` theme imports plus `theme.css`.',+ 'Import the reset/base CSS and a theme CSS file early enough for first paint. For production SSR, prefer built themes from `{@command theme build}` or published `/built` theme imports plus `theme.css`.','Choose one owner for color mode. Theme uses `data-theme="light|dark"` and `color-scheme` to resolve `light-dark()` tokens.','Map the external library\'s semantic layer to system variables by intent, not by exact naming. For example, MUI `background.paper` maps to `--color-background-surface`.','Use {@link namespace:tokens} and focused token docs when building mappings. Keep mappings small at first: text, surface/body/card/popover, border, accent, status, spacing, radius, typography, shadow.',diff --git a/packages/cli/assets/docs/tree/page-template.doc.mjs b/packages/cli/assets/docs/tree/page-template.doc.mjsindex 7080638e4a..88f0e63776 100644--- a/packages/cli/assets/docs/tree/page-template.doc.mjs+++ b/packages/cli/assets/docs/tree/page-template.doc.mjs@@ -17,7 +17,7 @@ export const docs = {title: 'Page template',category: 'guide',description:- 'Help people find a page: give it a category for `astryx search` and template listings, and flag a sparse starting shell as a scaffold.',+ 'Help people find a page: give it a category for `{@command search}` and template listings, and flag a sparse starting shell as a scaffold.',sections: [{id: 'start-from-the-generated-page-doc',@@ -56,7 +56,7 @@ export default {type: 'list',style: 'unordered',items: [- 'Set `category` to the most specific supported `{Group} - {Variant}` value. Its words become search terms for `astryx search`, and it appears in the JSON template list.',+ 'Set `category` to the most specific supported `{Group} - {Variant}` value. Its words become search terms for `{@command search}`, and it appears in the JSON template list.','Set `scaffold: true` only for a deliberately sparse starting shell. The JSON template list reports it, so tools and galleries can tell a scaffold from a finished page.',"Fields that only Astryx's own gallery reads, such as `isHiddenFromOverview`, have no effect on integration templates.",],diff --git a/packages/cli/assets/docs/tree/problems.doc.mjs b/packages/cli/assets/docs/tree/problems.doc.mjsindex 3a3be3ec96..a8cbcce49b 100644--- a/packages/cli/assets/docs/tree/problems.doc.mjs+++ b/packages/cli/assets/docs/tree/problems.doc.mjs@@ -92,7 +92,7 @@ export const docs = {},{type: 'prose',- text: "The first astryx command on your PATH is a version from before global mode, so it ignores your projects' versions. Run the command shown, or remove that install. `astryx doctor` lists every astryx command on your PATH in its `cli-on-path` check.",+ text: "The first astryx command on your PATH is a version from before global mode, so it ignores your projects' versions. Run the command shown, or remove that install. `{@command doctor}` lists every astryx command on your PATH in its `cli-on-path` check.",},],},@@ -126,12 +126,12 @@ export const docs = {content: [{type: 'prose',- text: "Astryx treats a copy as installed for your computer only when your package manager's own settings name its folder: npm's global prefix, Bun's `BUN_INSTALL`, Yarn's `global-folder`, pnpm's `PNPM_HOME`, or their defaults. A folder chosen only with a one-off flag, such as `yarn global add --global-folder ~/mine`, is not in any setting, so Astryx treats that copy like a project's: no daily update check and no agent guide. Save the folder in your settings so Astryx knows it is a global install:",+ text: "Astryx treats a copy as installed for your computer only when your package manager's own settings name its folder: npm's global prefix, Bun's `BUN_INSTALL`, Yarn's `global-folder`, pnpm's `PNPM_HOME`, or their defaults. A folder chosen only with a one-off flag, such as `{@pm-only yarn-classic \"uses the Yarn 1 global folder\" global add --global-folder ~/mine}`, is not in any setting, so Astryx treats that copy like a project's: no daily update check and no agent guide. Save the folder in your settings so Astryx knows it is a global install:",},{type: 'code',lang: 'bash',- code: 'yarn config set global-folder ~/mine # writes ~/.yarnrc\nexport BUN_INSTALL=~/mybun # in your shell profile, for Bun',+ code: '{@pm-only yarn-classic "uses the Yarn 1 global folder" config set global-folder ~/mine} # writes ~/.yarnrc\nexport BUN_INSTALL=~/mybun # in your shell profile, for Bun',},],},@@ -145,7 +145,7 @@ export const docs = {},{type: 'prose',- text: "In a project with nothing installed yet, such as a fresh clone, the same commands use that Core too, and offline the error reads `This project has no Core installed, and Core <version> could not be downloaded`: install the project's dependencies (`npm install`, or your package manager's), and the project's own Core answers from then on.",+ text: "In a project with nothing installed yet, such as a fresh clone, the same commands use that Core too, and offline the error reads `This project has no Core installed, and Core <version> could not be downloaded`: install the project's dependencies (`{@pm install}`, or your package manager's), and the project's own Core answers from then on.",},],},@@ -182,11 +182,11 @@ export const docs = {type: 'list',style: 'unordered',items: [- '`npm i -g` fails with `EACCES` (permission denied): do not use `sudo`. Use a Node version manager, or give npm a global folder you own: `npm config set prefix ~/.npm-global`, then add `~/.npm-global/bin` to your PATH.',- "`astryx: command not found` after installing: your package manager's global bin folder is not on your PATH. `npm prefix -g` shows npm's (its `bin` folder on macOS and Linux); `pnpm setup` adds pnpm's.",- '`pnpm add -g` stops with `ERR_PNPM_NO_GLOBAL_BIN_DIR`, often with Corepack: run `pnpm setup`, open a new terminal, and try again. Yarn 2 and later have no `yarn global`; use `npm i -g` instead.',+ '`npm i -g` fails with `EACCES` (permission denied): do not use `sudo`. Use a Node version manager, or give npm a global folder you own: `{@pm-only npm "moves the npm global folder" config set prefix ~/.npm-global}`, then add `~/.npm-global/bin` to your PATH.',+ '`astryx: command not found` after installing: your package manager\'s global bin folder is not on your PATH. `{@pm-only npm "prints the npm global folder" prefix -g}` shows npm\'s (its `bin` folder on macOS and Linux); `{@pm-only pnpm "sets up the pnpm global folder" setup}` adds pnpm\'s.',+ '`pnpm add -g` stops with `ERR_PNPM_NO_GLOBAL_BIN_DIR`, often with Corepack: run `{@pm-only pnpm "sets up the pnpm global folder" setup}`, open a new terminal, and try again. Yarn 2 and later have no `yarn global`; use `npm i -g` instead.','Windows: npm puts `astryx.cmd` in `%APPDATA%\\npm`, which must be on your PATH. If PowerShell says running scripts is disabled, run `astryx.cmd`, or allow scripts for your user with `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`.',- 'Two installs, and the wrong one runs: `astryx doctor` outside a project lists every astryx command on your PATH, in the order your shell tries them.',+ 'Two installs, and the wrong one runs: `{@command doctor}` outside a project lists every astryx command on your PATH, in the order your shell tries them.',],},],diff --git a/packages/cli/assets/docs/tree/project-global-or-both.doc.mjs b/packages/cli/assets/docs/tree/project-global-or-both.doc.mjsindex 0a830dddcb..7c06e9a60e 100644--- a/packages/cli/assets/docs/tree/project-global-or-both.doc.mjs+++ b/packages/cli/assets/docs/tree/project-global-or-both.doc.mjs@@ -90,7 +90,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm install @astryxdesign/core @astryxdesign/cli\nastryx init',+ code: '{@pm install @astryxdesign/core @astryxdesign/cli}\n{@command init}',},{type: 'prose',@@ -99,7 +99,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm i -g @astryxdesign/cli',+ code: '{@pm install @astryxdesign/cli --global}',},{type: 'prose',diff --git a/packages/cli/assets/docs/tree/publishing.doc.mjs b/packages/cli/assets/docs/tree/publishing.doc.mjsindex 7d705412b5..a90d7007a9 100644--- a/packages/cli/assets/docs/tree/publishing.doc.mjs+++ b/packages/cli/assets/docs/tree/publishing.doc.mjs@@ -22,12 +22,12 @@ export const docs = {content: [{type: 'prose',- text: 'Publish only a package that passes every check, then preview the upload with `npm publish --dry-run`. The dry run lists the files and the tag without uploading.',+ text: 'Publish only a package that passes every check, then preview the upload with `{@pm-only npm "publishing goes through npm, which every Node install carries" publish --dry-run}`. The dry run lists the files and the tag without uploading.',},{type: 'code',lang: 'bash',- code: 'astryx doctor integration validate && astryx doctor integration components && astryx doctor integration templates && astryx doctor integration docs && astryx integration verify\nnpm publish --dry-run --access public',+ code: '{@command doctor integration validate} && {@command doctor integration components} && {@command doctor integration templates} && {@command doctor integration docs} && {@command integration verify}\n{@pm-only npm "publishing goes through npm, which every Node install carries" publish --dry-run --access public}',},{type: 'code',@@ -51,7 +51,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: "npm pkg set 'files[]=components' 'files[]=templates' 'files[]=themes' 'files[]=docs' 'files[]=codemods' 'files[]=astryx.integration.mjs'\nnpm pack --dry-run",+ code: "{@pm-only npm \"edits package.json\" pkg set 'files[]=components' 'files[]=templates' 'files[]=themes' 'files[]=docs' 'files[]=codemods' 'files[]=astryx.integration.mjs'}\n{@pm-only npm \"builds the tarball npm publishes\" pack --dry-run}",},{type: 'list',@@ -70,12 +70,12 @@ export const docs = {content: [{type: 'prose',- text: 'A scoped package is private by default, so publish it with `--access public`. Without `--tag`, npm tags the release `latest`, which is what `npm install @acme/astryx-widgets` installs.',+ text: 'A scoped package is private by default, so publish it with `--access public`. Without `--tag`, npm tags the release `latest`, which is what `{@pm install @acme/astryx-widgets}` installs.',},{type: 'code',lang: 'bash',- code: '# Publish a release\nnpm publish --access public\n\n# Or set the access once in package.json\nnpm pkg set publishConfig.access=public',+ code: '# Publish a release\n{@pm-only npm "publishing goes through npm, which every Node install carries" publish --access public}\n\n# Or set the access once in package.json\n{@pm-only npm "Yarn has no pkg command" pkg set publishConfig.access=public}',},{type: 'prose',@@ -84,7 +84,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: '# Only apps that ask for next get it: npm install @acme/astryx-widgets@next\nnpm publish --tag next\n\n# Make that version the default\nnpm dist-tag add @acme/[email protected] latest\nnpm dist-tag ls @acme/astryx-widgets',+ code: '# Only apps that ask for next get it: npm install @acme/astryx-widgets@next\n{@pm-only npm "publishing goes through npm, which every Node install carries" publish --tag next}\n\n# Make that version the default\n{@pm-only npm "dist-tags are set with npm, which every Node install carries" dist-tag add @acme/[email protected] latest}\n{@pm-only npm "dist-tags are set with npm, which every Node install carries" dist-tag ls @acme/astryx-widgets}',},],},@@ -99,7 +99,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'mkdir check-release && cd check-release\nnpm init -y\nnpm install @astryxdesign/core @astryxdesign/cli @acme/[email protected]\nastryx component AcmeCarousel\nastryx doctor integration validate @acme/astryx-widgets',+ code: 'mkdir check-release && cd check-release\n{@pm-only npm "npm, which every Node install carries, writes the package.json" init -y}\n{@pm install @astryxdesign/core @astryxdesign/cli @acme/[email protected]}\n{@command component AcmeCarousel}\n{@command doctor integration validate @acme/astryx-widgets}',},{type: 'prose',diff --git a/packages/cli/assets/docs/tree/quick-start.doc.mjs b/packages/cli/assets/docs/tree/quick-start.doc.mjsindex 707ed8e915..9ea27e2b9f 100644--- a/packages/cli/assets/docs/tree/quick-start.doc.mjs+++ b/packages/cli/assets/docs/tree/quick-start.doc.mjs@@ -39,13 +39,13 @@ export const docs = {{type: 'code',lang: 'bash',- code: "mkdir acme-widgets && cd acme-widgets\nnpm init -y\nnpm pkg set name=@acme/astryx-widgets type=module\nnpm pkg set 'exports={}' --json\nnpm install -D @astryxdesign/cli @astryxdesign/core typescript@6",+ code: 'mkdir acme-widgets && cd acme-widgets\n{@pm-only npm "writes package.json" init -y}\n{@pm-only npm "edits package.json" pkg set name=@acme/astryx-widgets type=module}\n{@pm-only npm "edits package.json" pkg set \'exports={}\' --json}\n{@pm install @astryxdesign/cli @astryxdesign/core typescript@6 --dev}',},{type: 'list',style: 'unordered',items: [- 'Set `"type": "module"`: the `.js` files the CLI generates, such as a built theme, are ES modules, and Node fails to load them in a package marked `"type": "commonjs"`, which `npm init -y` writes on npm 11.',+ 'Set `"type": "module"`: the `.js` files the CLI generates, such as a built theme, are ES modules, and Node fails to load them in a package marked `"type": "commonjs"`, which `{@pm-only npm "writes package.json" init -y}` writes on npm 11.','Start with `"exports": {}`: each component and template you add then writes the public import that `integration verify` resolves.','Run the CLI as `astryx`, which runs the `@astryxdesign/cli` you installed as a devDependency.','Component commands read Core, so they need `@astryxdesign/core` installed.',@@ -64,7 +64,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add component AcmeCarousel',+ code: '{@command integration add component AcmeCarousel}',},{type: 'code',@@ -82,7 +82,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx component AcmeCarousel',+ code: '{@command component AcmeCarousel}',},{type: 'prose',@@ -100,7 +100,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm pkg set scripts.typecheck="astryx integration check --strict"\nnpm run typecheck',+ code: '{@pm-only npm "edits package.json" pkg set scripts.typecheck="astryx integration check --strict"}\n{@pm run typecheck}',},{type: 'code',@@ -127,7 +127,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration verify\nnpm pack --pack-destination ..',+ code: '{@command integration verify}\n{@pm-only npm "builds the publish tarball" pack --pack-destination ..}',},{type: 'code',@@ -136,7 +136,7 @@ export const docs = {},{type: 'prose',- text: '`integration verify` installs the packed package in a temporary app and confirms the component resolves through its public import there ({@link generic:checks}). It publishes nothing and leaves no `.tgz` file, so `npm pack` writes `../acme-astryx-widgets-1.0.0.tgz` for the next step.',+ text: '`integration verify` installs the packed package in a temporary app and confirms the component resolves through its public import there ({@link generic:checks}). It publishes nothing and leaves no `.tgz` file, so `{@pm-only npm "builds the publish tarball" pack}` writes `../acme-astryx-widgets-1.0.0.tgz` for the next step.',},{type: 'heading',@@ -150,7 +150,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'cd ..\nmkdir my-app && cd my-app\nnpm init -y\nnpm install @astryxdesign/core @astryxdesign/cli ../acme-astryx-widgets-1.0.0.tgz\nastryx component AcmeCarousel',+ code: 'cd ..\nmkdir my-app && cd my-app\n{@pm-only npm "writes package.json" init -y}\n{@pm install @astryxdesign/core @astryxdesign/cli ../acme-astryx-widgets-1.0.0.tgz}\n{@command component AcmeCarousel}',},{type: 'code',@@ -290,7 +290,7 @@ export const docs = {content: [{type: 'prose',- text: 'In global mode: users can also install your package for their computer, beside the global CLI (`npm i -g @astryxdesign/cli your-package`). It then applies in folders outside any project, and inside a project only if the project installs it. See {@link namespace:global} and {@link generic:global-integrations}.',+ text: 'In global mode: users can also install your package for their computer, beside the global CLI (`{@pm install @astryxdesign/cli your-package --global}`). It then applies in folders outside any project, and inside a project only if the project installs it. See {@link namespace:global} and {@link generic:global-integrations}.',},],},diff --git a/packages/cli/assets/docs/tree/reference.doc.mjs b/packages/cli/assets/docs/tree/reference.doc.mjsindex 783fa2ac36..b325a59128 100644--- a/packages/cli/assets/docs/tree/reference.doc.mjs+++ b/packages/cli/assets/docs/tree/reference.doc.mjs@@ -62,7 +62,7 @@ export const docs = {'`%APPDATA%\\astryx`',],[- 'Update checks and notices, and why the last notice or check did not happen (for `astryx doctor` only)',+ 'Update checks and notices, and why the last notice or check did not happen (for `{@command doctor}` only)','`<settings>/state.json`','`<settings>/state.json`','`<settings>\\state.json`',@@ -128,7 +128,7 @@ export const docs = {style: 'unordered',items: ["`meta.answeredBy` on every successful `--json` result: `cli` (the version that answered), `core` (the Core it used, or `null`), and `copy`: `project` (the project's own CLI), `starting` (the astryx command you started, in a project with no CLI of its own), `matched` (the CLI version equal to the project's Core, when the project's own CLI cannot start), `carried` (outside a project), or `fallback` (that version could not be obtained, so the astryx command you started answered instead).",- '`meta.available` entries from `astryx discover` with `source: "installed for this computer"`: an integration installed next to your global install that the project could add, with its install command in `install`.',+ '`meta.available` entries from `{@command discover}` with `source: "installed for this computer"`: an integration installed next to your global install that the project could add, with its install command in `install`.',],},],diff --git a/packages/cli/assets/docs/tree/replace-a-core-component.doc.mjs b/packages/cli/assets/docs/tree/replace-a-core-component.doc.mjsindex 0e85f5f568..92a4dc767f 100644--- a/packages/cli/assets/docs/tree/replace-a-core-component.doc.mjs+++ b/packages/cli/assets/docs/tree/replace-a-core-component.doc.mjs@@ -103,7 +103,7 @@ export default {{type: 'code',lang: 'bash',- code: 'astryx doctor integration components\nastryx component SideNav\nastryx component AcmeSideNav\nastryx component SideNav --package @astryxdesign/core',+ code: '{@command doctor integration components}\n{@command component SideNav}\n{@command component AcmeSideNav}\n{@command component SideNav --package @astryxdesign/core}',},{type: 'list',diff --git a/packages/cli/assets/docs/tree/replace-a-core-template.doc.mjs b/packages/cli/assets/docs/tree/replace-a-core-template.doc.mjsindex 811a4a694c..85d2cb532e 100644--- a/packages/cli/assets/docs/tree/replace-a-core-template.doc.mjs+++ b/packages/cli/assets/docs/tree/replace-a-core-template.doc.mjs@@ -31,7 +31,7 @@ export const docs = {type: 'list',style: 'unordered',items: [- 'Sharing a Core id without `replaces` does not replace Core. It makes the bare id ambiguous, so `astryx template <id>` fails until the app adds `--package`, and `doctor integration templates` reports an accidental collision.',+ 'Sharing a Core id without `replaces` does not replace Core. It makes the bare id ambiguous, so `{@command template <id>}` fails until the app adds `--package`, and `doctor integration templates` reports an accidental collision.','A replacement can keep the Core id or use its own. `replaces` is what makes it the default.',],},@@ -113,10 +113,10 @@ export default {type: 'code',lang: 'bash',code: `# Receives the active replacement-astryx template shell-side-nav src/app+{@command template shell-side-nav src/app}# Receives the original Core template-astryx template shell-side-nav --package @astryxdesign/core src/app`,+{@command template shell-side-nav --package @astryxdesign/core src/app}`,},{type: 'prose',@@ -140,7 +140,7 @@ astryx template shell-side-nav --package @astryxdesign/core src/app`,{type: 'code',lang: 'bash',- code: 'astryx doctor integration templates',+ code: '{@command doctor integration templates}',},{type: 'table',diff --git a/packages/cli/assets/docs/tree/scaffold.doc.mjs b/packages/cli/assets/docs/tree/scaffold.doc.mjsindex e37eee99d4..777fc2d6e7 100644--- a/packages/cli/assets/docs/tree/scaffold.doc.mjs+++ b/packages/cli/assets/docs/tree/scaffold.doc.mjs@@ -132,7 +132,7 @@ export const docs = {},{type: 'prose',- text: 'Verify: you can state the reason in one sentence, and the choice still holds if the nav doubles in size. `astryx build "<idea>"` names the template to start from; scaffold it and the pairing is already wired up.',+ text: 'Verify: you can state the reason in one sentence, and the choice still holds if the nav doubles in size. `{@command build "<idea>"}` names the template to start from; scaffold it and the pairing is already wired up.',},],},diff --git a/packages/cli/assets/docs/tree/sections-and-placement.doc.mjs b/packages/cli/assets/docs/tree/sections-and-placement.doc.mjsindex a4187ee47b..95ac17c33e 100644--- a/packages/cli/assets/docs/tree/sections-and-placement.doc.mjs+++ b/packages/cli/assets/docs/tree/sections-and-placement.doc.mjs@@ -26,7 +26,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration add doc deploying --parent acme\n# Open your section\nastryx docs acme',+ code: '{@command integration add doc deploying --parent acme}\n# Open your section\n{@command docs acme}',},{type: 'code',@@ -69,7 +69,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx docs acme/deploying',+ code: '{@command docs acme/deploying}',},],},@@ -84,7 +84,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx doctor integration docs',+ code: '{@command doctor integration docs}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/see-it-in-an-app.doc.mjs b/packages/cli/assets/docs/tree/see-it-in-an-app.doc.mjsindex 5b6aaa35e6..1616681e55 100644--- a/packages/cli/assets/docs/tree/see-it-in-an-app.doc.mjs+++ b/packages/cli/assets/docs/tree/see-it-in-an-app.doc.mjs@@ -26,9 +26,9 @@ export const docs = {{type: 'code',lang: 'bash',- code: `astryx component AcmeCarousel-astryx component --list-astryx search carousel`,+ code: `{@command component AcmeCarousel}+{@command component --list}+{@command search carousel}`,},{type: 'code',diff --git a/packages/cli/assets/docs/tree/short-and-findable.doc.mjs b/packages/cli/assets/docs/tree/short-and-findable.doc.mjsindex 1784a6dfe9..d2e12d9d80 100644--- a/packages/cli/assets/docs/tree/short-and-findable.doc.mjs+++ b/packages/cli/assets/docs/tree/short-and-findable.doc.mjs@@ -21,7 +21,7 @@ export const docs = {content: [{type: 'prose',- text: 'Readers open one section at a time, so give each section one idea and keep it to about 30 lines. `astryx doctor` warns on any read over 32 KB.',+ text: 'Readers open one section at a time, so give each section one idea and keep it to about 30 lines. `{@command doctor}` warns on any read over 32 KB.',},{type: 'list',@@ -35,7 +35,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: '# The section list\nastryx docs acme/deploying\n# One section\nastryx docs acme/deploying check-before-you-ship\n# Everything\nastryx docs acme/deploying --full',+ code: '# The section list\n{@command docs acme/deploying}\n# One section\n{@command docs acme/deploying check-before-you-ship}\n# Everything\n{@command docs acme/deploying --full}',},],},@@ -93,7 +93,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx search "place a doc" --type doc',+ code: '{@command search "place a doc" --type doc}',},{type: 'list',diff --git a/packages/cli/assets/docs/tree/single-component.doc.mjs b/packages/cli/assets/docs/tree/single-component.doc.mjsindex 67f90988c3..bdccceb6fb 100644--- a/packages/cli/assets/docs/tree/single-component.doc.mjs+++ b/packages/cli/assets/docs/tree/single-component.doc.mjs@@ -88,12 +88,12 @@ export default {},{type: 'prose',- text: "Set `keywords` to the words people search for: synonyms and the task the component does, such as `keywords: ['slider', 'slideshow', 'rotating cards']`. `astryx search` ranks a match on a component's name or keywords above one in its description, so without keywords a search for the component's task can list Core components first. Check with the words a person would type:",+ text: "Set `keywords` to the words people search for: synonyms and the task the component does, such as `keywords: ['slider', 'slideshow', 'rotating cards']`. `{@command search}` ranks a match on a component's name or keywords above one in its description, so without keywords a search for the component's task can list Core components first. Check with the words a person would type:",},{type: 'code',lang: 'bash',- code: 'astryx search "rotating cards" --type component',+ code: '{@command search "rotating cards" --type component}',},],},@@ -130,7 +130,7 @@ export default {'Set `required: true` only when every caller must pass the prop.','Write `default` exactly as the value should appear in documentation.','Skip styling escape hatches such as `xstyle`, `className`, and `style`.',- '`astryx doctor integration components` lists a documented prop the code lacks, a public prop the doc misses, and a wrong `required`. See {@link generic:check-the-props}.',+ '`{@command doctor integration components}` lists a documented prop the code lacks, a public prop the doc misses, and a wrong `required`. See {@link generic:check-the-props}.',],},],@@ -166,7 +166,7 @@ export default {{type: 'code',lang: 'bash',- code: 'astryx component AcmeCarousel\nastryx doctor integration components\nastryx integration verify',+ code: '{@command component AcmeCarousel}\n{@command doctor integration components}\n{@command integration verify}',},],},diff --git a/packages/cli/assets/docs/tree/start-a-template.doc.mjs b/packages/cli/assets/docs/tree/start-a-template.doc.mjsindex 6da53a1af1..4968616201 100644--- a/packages/cli/assets/docs/tree/start-a-template.doc.mjs+++ b/packages/cli/assets/docs/tree/start-a-template.doc.mjs@@ -38,8 +38,8 @@ export const docs = {type: 'code',lang: 'bash',code: `# How an app finds a template and copies it-astryx template --list-astryx template acme-dashboard src/app/dashboard`,+{@command template --list}+{@command template acme-dashboard src/app/dashboard}`,},],},@@ -83,7 +83,7 @@ astryx template acme-dashboard src/app/dashboard`,content: [{type: 'prose',- text: 'Choose a stable lowercase kebab-case id, such as `acme-dashboard`. The id becomes the source and doc file name, the package export, and the value apps pass to `astryx template`. To change a label, edit the doc ({@link generic:template-doc-overview}); never rename the id.',+ text: 'Choose a stable lowercase kebab-case id, such as `acme-dashboard`. The id becomes the source and doc file name, the package export, and the value apps pass to `{@command template}`. To change a label, edit the doc ({@link generic:template-doc-overview}); never rename the id.',},{type: 'list',@@ -112,8 +112,8 @@ astryx template acme-dashboard src/app/dashboard`,{type: 'code',lang: 'bash',- code: `astryx integration add template acme-dashboard-astryx integration add template acme-stat-card --type block`,+ code: `{@command integration add template acme-dashboard}+{@command integration add template acme-stat-card --type block}`,},{type: 'code',diff --git a/packages/cli/assets/docs/tree/styling-advanced.doc.mjs b/packages/cli/assets/docs/tree/styling-advanced.doc.mjsindex 57eb724dab..3088af3553 100644--- a/packages/cli/assets/docs/tree/styling-advanced.doc.mjs+++ b/packages/cli/assets/docs/tree/styling-advanced.doc.mjs@@ -118,7 +118,7 @@ const overrides = stylex.create({content: [{type: 'prose',- text: 'Astryx 0.7 emits canonical `astryx-*` target classes and reflected `data-*` attributes only. Run `astryx upgrade --from <your 0.6 version> --apply --path .` to rename removed target keys inside theme `components` maps and to migrate CSS selectors. The CSS migration renames removed target classes and replaces target-qualified bare prop/value/state classes such as `.primary`, `.sm`, `.level-2`, and `.checked` with their reflected `data-*` selectors.',+ text: 'Astryx 0.7 emits canonical `astryx-*` target classes and reflected `data-*` attributes only. Run `{@command upgrade --from <your 0.6 version> --apply --path .}` to rename removed target keys inside theme `components` maps and to migrate CSS selectors. The CSS migration renames removed target classes and replaces target-qualified bare prop/value/state classes such as `.primary`, `.sm`, `.level-2`, and `.checked` with their reflected `data-*` selectors.',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/tailwind.doc.mjs b/packages/cli/assets/docs/tree/tailwind.doc.mjsindex 2303bdf47b..83aa31a9c6 100644--- a/packages/cli/assets/docs/tree/tailwind.doc.mjs+++ b/packages/cli/assets/docs/tree/tailwind.doc.mjs@@ -49,7 +49,7 @@ export const docs = {},{type: 'prose',- text: 'A layer\'s rank is set by the first stylesheet on the page that names it, so this order only holds when `globals.css` loads first. Make it the first import in the root layout or app entry, before any module that imports Astryx or theme CSS. That includes the `astryx-themes` module generated by `astryx theme add` and any root component that imports a theme\'s `theme.css`. If a theme stylesheet loads first, Tailwind preflight overrides Astryx base styles and theme overrides lose. If `globals.css` cannot come first, move the `@layer` line into its own `layers.css` and import that first instead.',+ text: "A layer's rank is set by the first stylesheet on the page that names it, so this order only holds when `globals.css` loads first. Make it the first import in the root layout or app entry, before any module that imports Astryx or theme CSS. That includes the `astryx-themes` module generated by `{@command theme add}` and any root component that imports a theme's `theme.css`. If a theme stylesheet loads first, Tailwind preflight overrides Astryx base styles and theme overrides lose. If `globals.css` cannot come first, move the `@layer` line into its own `layers.css` and import that first instead.",},{type: 'code',diff --git a/packages/cli/assets/docs/tree/test-in-an-app.doc.mjs b/packages/cli/assets/docs/tree/test-in-an-app.doc.mjsindex da4c8795ba..ecd42ec108 100644--- a/packages/cli/assets/docs/tree/test-in-an-app.doc.mjs+++ b/packages/cli/assets/docs/tree/test-in-an-app.doc.mjs@@ -27,14 +27,14 @@ export const docs = {{type: 'code',lang: 'bash',- code: '# In the package\nnpm pack --pack-destination ..\n\n# In an app folder beside it\nnpm install @astryxdesign/core @astryxdesign/cli ../acme-astryx-widgets-1.0.0.tgz',+ code: '# In the package\n{@pm-only npm "the tarball the registry receives" pack --pack-destination ..}\n\n# In an app folder beside it\n{@pm install @astryxdesign/core @astryxdesign/cli ../acme-astryx-widgets-1.0.0.tgz}',},{type: 'list',style: 'unordered',items: ["Install the CLI in the app too: `astryx` runs the CLI from the app's `node_modules`.",- 'The app holds a copy, not a link. After each change, pack again and run the same `npm install`.',+ 'The app holds a copy, not a link. After each change, pack again and run the same `{@pm install}`.','Reading your work inside the package shows your source. The app shows what npm would publish.',],},@@ -51,7 +51,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx component AcmeCarousel\nastryx template --list --package @acme/astryx-widgets\nastryx theme list --package @acme/astryx-widgets\nastryx docs acme\nastryx search deploying --type doc',+ code: '{@command component AcmeCarousel}\n{@command template --list --package @acme/astryx-widgets}\n{@command theme list --package @acme/astryx-widgets}\n{@command docs acme}\n{@command search deploying --type doc}',},{type: 'table',@@ -88,12 +88,12 @@ export const docs = {content: [{type: 'prose',- text: '`astryx doctor` checks the whole app, including every package it loaded. `doctor integration validate` checks your package as the app installed it.',+ text: '`{@command doctor}` checks the whole app, including every package it loaded. `doctor integration validate` checks your package as the app installed it.',},{type: 'code',lang: 'bash',- code: 'astryx doctor\nastryx doctor integration validate @acme/astryx-widgets',+ code: '{@command doctor}\n{@command doctor integration validate @acme/astryx-widgets}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/test-template-in-app.doc.mjs b/packages/cli/assets/docs/tree/test-template-in-app.doc.mjsindex f6ddc4d6c7..5ee21cf81b 100644--- a/packages/cli/assets/docs/tree/test-template-in-app.doc.mjs+++ b/packages/cli/assets/docs/tree/test-template-in-app.doc.mjs@@ -41,11 +41,11 @@ export const docs = {astryx --json template --list --package @acme/astryx-widgets# Inspect source without writing-astryx template acme-dashboard --package @acme/astryx-widgets+{@command template acme-dashboard --package @acme/astryx-widgets}# Copy a page and a block to their real app locations-astryx template acme-dashboard --package @acme/astryx-widgets src/app/acme-dashboard-astryx template acme-stat-card --package @acme/astryx-widgets src/components`,+{@command template acme-dashboard --package @acme/astryx-widgets src/app/acme-dashboard}+{@command template acme-stat-card --package @acme/astryx-widgets src/components}`,},{type: 'list',@@ -64,13 +64,13 @@ astryx template acme-stat-card --package @acme/astryx-widgets src/components`,content: [{type: 'prose',- text: "Run the type check (`npx tsc --noEmit`, or the app's own script) and the production build in every framework or bundler the integration supports. One toolchain passing does not prove another.",+ text: "Run the type check (`{@pm exec tsc --noEmit}`, or the app's own script) and the production build in every framework or bundler the integration supports. One toolchain passing does not prove another.",},{type: 'code',lang: 'bash',- code: `npx tsc --noEmit-npm run build`,+ code: `{@pm exec tsc --noEmit}+{@pm run build}`,},{type: 'list',diff --git a/packages/cli/assets/docs/tree/tokens-and-setup.doc.mjs b/packages/cli/assets/docs/tree/tokens-and-setup.doc.mjsindex 3720ce16d0..cf71521d48 100644--- a/packages/cli/assets/docs/tree/tokens-and-setup.doc.mjs+++ b/packages/cli/assets/docs/tree/tokens-and-setup.doc.mjs@@ -71,7 +71,7 @@ const styles = stylex.create({content: [{type: 'prose',- text: "Astryx components ship pre-compiled: `astryx.css` and each package's own stylesheet hold all of their styles, so consuming the published packages needs no StyleX setup. But `astryx swizzle <Component>` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one, importing the component throws an error that starts `Unexpected 'stylex.create' call at runtime`, and the page does not render. If a swizzled component throws that error, the app is missing a StyleX compiler. The same applies if you author your own StyleX with `stylex.create()`.",+ text: "Astryx components ship pre-compiled: `astryx.css` and each package's own stylesheet hold all of their styles, so consuming the published packages needs no StyleX setup. But `{@command swizzle <Component>}` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one, importing the component throws an error that starts `Unexpected 'stylex.create' call at runtime`, and the page does not render. If a swizzled component throws that error, the app is missing a StyleX compiler. The same applies if you author your own StyleX with `stylex.create()`.",},{type: 'table',diff --git a/packages/cli/assets/docs/tree/troubleshooting.doc.mjs b/packages/cli/assets/docs/tree/troubleshooting.doc.mjsindex 4a143f76e4..c2fe529c49 100644--- a/packages/cli/assets/docs/tree/troubleshooting.doc.mjs+++ b/packages/cli/assets/docs/tree/troubleshooting.doc.mjs@@ -31,11 +31,11 @@ export const docs = {rows: [['`No package.json found. Run this command inside an integration package.`',- 'Run `npm init -y` and `npm pkg set name=@acme/astryx-widgets` first, in the package folder.',+ 'Run `{@pm-only npm "writes package.json" init -y}` and `{@pm-only npm "edits package.json" pkg set name=@acme/astryx-widgets}` first, in the package folder.',],['`Error: Could not find @astryxdesign/core package`',- 'Component commands read Core. Run `npm install -D @astryxdesign/core` in the package.',+ 'Component commands read Core. Run `{@pm install @astryxdesign/core --dev}` in the package.',],['`core_not_found`: `Could not resolve @astryxdesign/core, so component names could not be checked.`',@@ -43,11 +43,11 @@ export const docs = {],["`Error: unknown subcommand 'integration verify'`, or `Error: Pass --check to verify the integration tarball.`",- 'Your CLI is older than `integration verify`. Run `npm install -D @astryxdesign/cli@latest`. On the older CLI, the same check is `integration pack --check`.',+ 'Your CLI is older than `integration verify`. Run `{@pm install @astryxdesign/cli@latest --dev}`. On the older CLI, the same check is `integration pack --check`.',],['Note: `integration pack --check` is deprecated.',- 'The old name still runs the same check. Switch to `astryx integration verify`; the old name will be removed in a later release.',+ 'The old name still runs the same check. Switch to `{@command integration verify}`; the old name will be removed in a later release.',],],},@@ -59,7 +59,7 @@ export const docs = {content: [{type: 'prose',- text: '`astryx integration verify` prints each failure as a `[fail]` line. Add `--json` to see its issue code, such as `component_export_missing`.',+ text: '`{@command integration verify}` prints each failure as a `[fail]` line. Add `--json` to see its issue code, such as `component_export_missing`.',},{type: 'table',@@ -67,15 +67,15 @@ export const docs = {rows: [['`component_export_missing`: `Component "AcmeCarousel" advertises import "@acme/astryx-widgets/components/AcmeCarousel", but that packed module does not export "AcmeCarousel".`',- "package.json has no `exports` map, or the module does not export the name. Keep `export function AcmeCarousel`, and add the entry: `npm pkg set 'exports[./components/AcmeCarousel]=./components/AcmeCarousel.tsx'`. When the quoted name is a file name, such as `acme-carousel`, set the doc's `name` to the component the file exports. A type-only export does not count.",+ "package.json has no `exports` map, or the module does not export the name. Keep `export function AcmeCarousel`, and add the entry: `{@pm-only npm \"edits package.json\" pkg set 'exports[./components/AcmeCarousel]=./components/AcmeCarousel.tsx'}`. When the quoted name is a file name, such as `acme-carousel`, set the doc's `name` to the component the file exports. A type-only export does not count.",],['`template_export_missing`: `Template "acme-dashboard" public import "@acme/astryx-widgets/templates/acme-dashboard" does not have a default export.`',- 'Run `npm pkg set \'exports[./templates/acme-dashboard]=./templates/acme-dashboard.tsx\'`, and keep `export default` in the source. Start new packages with `"exports": {}` so each add writes these.',+ 'Run `{@pm-only npm "edits package.json" pkg set \'exports[./templates/acme-dashboard]=./templates/acme-dashboard.tsx\'}`, and keep `export default` in the source. Start new packages with `"exports": {}` so each add writes these.',],['`component_import_unresolvable` or `template_import_unresolvable`: `…Package subpath \'./components/AcmeCarousel\' is not defined by "exports"…`',- "The `exports` map has no entry for it. Run `npm pkg set 'exports[./components/AcmeCarousel]=./components/AcmeCarousel.tsx'`, or `'exports[./templates/acme-dashboard]=./templates/acme-dashboard.tsx'` for a template.",+ "The `exports` map has no entry for it. Run `{@pm-only npm \"edits package.json\" pkg set 'exports[./components/AcmeCarousel]=./components/AcmeCarousel.tsx'}`, or `'exports[./templates/acme-dashboard]=./templates/acme-dashboard.tsx'` for a template.",],["`component_import_unresolvable`: `…but a consumer cannot resolve it: Cannot find package '@acme/old-name'`",@@ -83,32 +83,36 @@ export const docs = {],['`Declared templates root "templates" has 0 of 2 expected files in the pack list. Add "templates" to "files" in package.json.`',- "Run `npm pkg set 'files[]=templates'`.",+ 'Run `{@pm-only npm "edits package.json" pkg set \'files[]=templates\'}`.',],['`docs_tree_needs_cli`: `The package ships a namespace doc or a placed guide but declares no @astryxdesign/cli peer.`',- "Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.4'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json`.",+ 'Run `{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/cli=>=0.6.4\'}` and `{@pm-only npm "edits package.json" pkg set \'peerDependenciesMeta.@astryxdesign/cli.optional=true\' --json}`.',],['`replaces_needs_cli`: The package has a template that sets `replaces` but declares no @astryxdesign/cli peer.',- "Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.4'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json`. A stable CLI before 0.6.4 rejects `replaces`, drops that template, and hides your doc topics.",+ 'Run `{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/cli=>=0.6.4\'}` and `{@pm-only npm "edits package.json" pkg set \'peerDependenciesMeta.@astryxdesign/cli.optional=true\' --json}`. A stable CLI before 0.6.4 rejects `replaces`, drops that template, and hides your doc topics.',],['`component_replaces_needs_cli` (a warning): The package has a component that sets `replaces` but declares no @astryxdesign/cli peer, or a peer range that admits an earlier CLI.',- "Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.7'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json` to turn the replacement on. Until then apps see no change ({@link generic:replace-a-core-component}).",+ 'Run `{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/cli=>=0.6.7\'}` and `{@pm-only npm "edits package.json" pkg set \'peerDependenciesMeta.@astryxdesign/cli.optional=true\' --json}` to turn the replacement on. Until then apps see no change ({@link generic:replace-a-core-component}).',],['`keywords_needs_cli`: The package has a template that sets `keywords` but declares no @astryxdesign/cli peer.',- "Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.6'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json`. What an older CLI does with the field is in {@link generic:template-doc-overview}.",+ 'Run `{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/cli=>=0.6.6\'}` and `{@pm-only npm "edits package.json" pkg set \'peerDependenciesMeta.@astryxdesign/cli.optional=true\' --json}`. What an older CLI does with the field is in {@link generic:template-doc-overview}.',],['`themes_need_cli`: The package ships a theme but declares no @astryxdesign/cli peer.',- "Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.4'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json`. A CLI older than published 0.6.4 cannot read typed theme descriptors, so it drops your themes and can hide your doc topics.",+ 'Run `{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/cli=>=0.6.4\'}` and `{@pm-only npm "edits package.json" pkg set \'peerDependenciesMeta.@astryxdesign/cli.optional=true\' --json}`. A CLI older than published 0.6.4 cannot read typed theme descriptors, so it drops your themes and can hide your doc topics.',],['`section_ids_need_cli`: The package has a doc section that sets `id` but declares no @astryxdesign/cli peer.','The same fix as `themes_need_cli`, or drop the section `id`s: a CLI older than published 0.6.4 rejects them and hides your doc topics.',],+ [+ '`doc_tokens_need_cli`: The package writes doc tokens (`{@@command …}`, `{@@pm …}`, `{@@pm-only …}`) in its docs, but its @astryxdesign/cli peer admits a CLI before 0.7.4.',+ 'Run `{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/cli=>=0.7.4\'}` and `{@pm-only npm "edits package.json" pkg set \'peerDependenciesMeta.@astryxdesign/cli.optional=true\' --json}`. A CLI before 0.7.4 prints each token as written, so readers see raw tokens.',+ ],],},],@@ -130,20 +134,20 @@ export const docs = {"Its doc still names its file. Set `name` to the export, such as `name: 'AcmeCarousel'` in `acme-carousel.doc.mjs`. A family member is listed only when the module its family doc imports exports it ({@link generic:component-family}).",],[- "`astryx component Dialog` opens Core's `Dialog`, not yours.",- "A name that Core, a legacy docs package, or another package's file already has stays theirs. Run `astryx component Dialog --package @acme/astryx-widgets`, or give your component a name of its own.",+ "`{@command component Dialog}` opens Core's `Dialog`, not yours.",+ "A name that Core, a legacy docs package, or another package's file already has stays theirs. Run `{@command component Dialog --package @acme/astryx-widgets}`, or give your component a name of its own.",],['`Error: Template "dashboard" is ambiguous — narrow it with --type and/or --package.`',- "Your template id matches a Core id. Rename it, such as `acme-dashboard`, or set `replaces: 'dashboard'` to take its place. `astryx doctor integration templates` warns about this before you publish.",+ "Your template id matches a Core id. Rename it, such as `acme-dashboard`, or set `replaces: 'dashboard'` to take its place. `{@command doctor integration templates}` warns about this before you publish.",],['`invalid_doc_graph`: `placement.parent "namespace:nope" names no namespace; @acme/astryx-widgets declares "acme".`','The guide stays hidden until its `placement` names a namespace and slot your package declares. For `"…" names no doc`, fix the link target.',],[- 'Error: Unknown topic "acme". The docs of @acme/astryx-widgets did not load; run `astryx doctor integration docs` in that package to see why.',- 'One invalid doc hides all of your docs. Run `astryx doctor integration docs` in the package and fix the `invalid_doc` it names.',+ 'Error: Unknown topic "acme". The docs of @acme/astryx-widgets did not load; run `{@command doctor integration docs}` in that package to see why.',+ 'One invalid doc hides all of your docs. Run `{@command doctor integration docs}` in the package and fix the `invalid_doc` it names.',],['`cli-command` warns: `Loaded integrations declare different CLI commands`',@@ -154,7 +158,7 @@ export const docs = {'Your `cliCommand` is not one line of plain text of at most 120 characters, so it is ignored. Fix the value; the rest of the manifest still loads.',],[- '`astryx upgrade` runs none of your codemods',+ '`{@command upgrade}` runs none of your codemods','The app must list your package in `integrations` in `astryx.config`, or pass `--integration @acme/astryx-widgets`. It runs a codemod folder only when its version is after `--from` and at most the installed `@astryxdesign/core`.',],[diff --git a/packages/cli/assets/docs/tree/uninstall.doc.mjs b/packages/cli/assets/docs/tree/uninstall.doc.mjsindex fa36026973..e0938f4da4 100644--- a/packages/cli/assets/docs/tree/uninstall.doc.mjs+++ b/packages/cli/assets/docs/tree/uninstall.doc.mjs@@ -40,7 +40,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx init --user --remove-agents',+ code: '{@command init --user --remove-agents}',},{type: 'prose',@@ -55,7 +55,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm uninstall -g @astryxdesign/cli\n# or: pnpm remove -g @astryxdesign/cli · yarn global remove @astryxdesign/cli · bun remove -g @astryxdesign/cli · volta uninstall @astryxdesign/cli',+ code: '{@pm remove @astryxdesign/cli --global}\n# with Volta: volta uninstall @astryxdesign/cli',},{type: 'prose',diff --git a/packages/cli/assets/docs/tree/updates.doc.mjs b/packages/cli/assets/docs/tree/updates.doc.mjsindex 867c08fd2d..72e9f15c2f 100644--- a/packages/cli/assets/docs/tree/updates.doc.mjs+++ b/packages/cli/assets/docs/tree/updates.doc.mjs@@ -74,7 +74,7 @@ export const docs = {},{type: 'prose',- text: '`astryx doctor` shows the same thing at any time, in its `newest-release` check, along with why the last notice did not print, if one did not. When the last check ran, and when each notice printed, are kept in `state.json` in the settings folder ({@link generic:reference}).',+ text: '`{@command doctor}` shows the same thing at any time, in its `newest-release` check, along with why the last notice did not print, if one did not. When the last check ran, and when each notice printed, are kept in `state.json` in the settings folder ({@link generic:reference}).',},],},diff --git a/packages/cli/assets/docs/tree/upgrading.doc.mjs b/packages/cli/assets/docs/tree/upgrading.doc.mjsindex 96b972ba21..ca3cdcfe75 100644--- a/packages/cli/assets/docs/tree/upgrading.doc.mjs+++ b/packages/cli/assets/docs/tree/upgrading.doc.mjs@@ -28,7 +28,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: "# 1. Build and test against the new release\nnpm install -D @astryxdesign/cli@latest @astryxdesign/core@latest\n# 2. Rerun the checks\nastryx doctor integration validate\nastryx doctor integration docs\nastryx integration verify\n# 3. Admit the new Core once the checks pass\nnpm pkg set 'peerDependencies.@astryxdesign/core=^0.6.0 || ^0.7.0'\n# 4. Migrate apps across a change that breaks them\nastryx integration add codemod rename-delay --to 0.7.0",+ code: '# 1. Build and test against the new release\n{@pm install @astryxdesign/cli@latest @astryxdesign/core@latest --dev}\n# 2. Rerun the checks\n{@command doctor integration validate}\n{@command doctor integration docs}\n{@command integration verify}\n# 3. Admit the new Core once the checks pass\n{@pm-only npm "edits package.json" pkg set \'peerDependencies.@astryxdesign/core=^0.6.0 || ^0.7.0\'}\n# 4. Migrate apps across a change that breaks them\n{@command integration add codemod rename-delay --to 0.7.0}',},{type: 'list',@@ -47,12 +47,12 @@ export const docs = {content: [{type: 'prose',- text: 'After an app installs a new Core, `astryx upgrade` runs the codemods for the versions it crossed. It is a dry run by default; `--apply` writes the changes.',+ text: 'After an app installs a new Core, `{@command upgrade}` runs the codemods for the versions it crossed. It is a dry run by default; `--apply` writes the changes.',},{type: 'code',lang: 'bash',- code: '# Preview what would change; nothing is written\nastryx upgrade --from 0.6.3 --integration @acme/astryx-widgets\n# Write the changes\nastryx upgrade --from 0.6.3 --integration @acme/astryx-widgets --apply',+ code: '# Preview what would change; nothing is written\n{@command upgrade --from 0.6.3 --integration @acme/astryx-widgets}\n# Write the changes\n{@command upgrade --from 0.6.3 --integration @acme/astryx-widgets --apply}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/use-a-theme-in-an-app.doc.mjs b/packages/cli/assets/docs/tree/use-a-theme-in-an-app.doc.mjsindex b5d1d5bde6..a83d72eefe 100644--- a/packages/cli/assets/docs/tree/use-a-theme-in-an-app.doc.mjs+++ b/packages/cli/assets/docs/tree/use-a-theme-in-an-app.doc.mjs@@ -26,7 +26,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm install @acme/astryx-widgets\nastryx theme add ocean --package @acme/astryx-widgets',+ code: '{@pm install @acme/astryx-widgets}\n{@command theme add ocean --package @acme/astryx-widgets}',},{type: 'code',diff --git a/packages/cli/assets/docs/tree/verify-packed-template.doc.mjs b/packages/cli/assets/docs/tree/verify-packed-template.doc.mjsindex cc57781f91..6e2cb37bfc 100644--- a/packages/cli/assets/docs/tree/verify-packed-template.doc.mjs+++ b/packages/cli/assets/docs/tree/verify-packed-template.doc.mjs@@ -27,11 +27,11 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'astryx integration verify',+ code: '{@command integration verify}',},{type: 'prose',- text: '`integration verify` runs `npm pack`, including lifecycle scripts, unpacks the `.tgz` file into a temporary app without installing its dependencies, and checks the unpacked integration. It publishes nothing and removes the `.tgz` file and the temporary app.',+ text: '`integration verify` runs `{@pm-only npm "the tarball the registry receives" pack}`, including lifecycle scripts, unpacks the `.tgz` file into a temporary app without installing its dependencies, and checks the unpacked integration. It publishes nothing and removes the `.tgz` file and the temporary app.',},{type: 'list',@@ -67,7 +67,7 @@ export const docs = {'Whether the copied file type-checks in every supported app toolchain.','Whether package-owned CSS, fonts, icons, images, or media load in a browser.','Whether layout, color modes, keyboard and pointer input, and real content work.',- 'Whether a template id collides with Core, or whether a `replaces` target exists. Run `astryx doctor integration templates` for those.',+ 'Whether a template id collides with Core, or whether a `replaces` target exists. Run `{@command doctor integration templates}` for those.','How the template scores on quality.',],},diff --git a/packages/cli/assets/docs/tree/versioning.doc.mjs b/packages/cli/assets/docs/tree/versioning.doc.mjsindex 1043c34c8f..1295ec7e0d 100644--- a/packages/cli/assets/docs/tree/versioning.doc.mjs+++ b/packages/cli/assets/docs/tree/versioning.doc.mjs@@ -28,7 +28,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: '# 1.0.0 -> 2.0.0: a breaking change\nnpm version major\n# 1.0.0 -> 1.1.0: a new feature\nnpm version minor\n# 1.0.0 -> 1.0.1: a fix\nnpm version patch',+ code: '# 1.0.0 -> 2.0.0: a breaking change\n{@pm-only npm "npm, which every Node install carries, sets the version" version major}\n# 1.0.0 -> 1.1.0: a new feature\n{@pm-only npm "npm, which every Node install carries, sets the version" version minor}\n# 1.0.0 -> 1.0.1: a fix\n{@pm-only npm "npm, which every Node install carries, sets the version" version patch}',},{type: 'list',@@ -54,13 +54,13 @@ export const docs = {rows: [['A component name, such as `AcmeCarousel`',- 'Imports, and `astryx component AcmeCarousel`',+ 'Imports, and `{@command component AcmeCarousel}`',],['A template id, such as `acme-dashboard`',- '`astryx template acme-dashboard`',+ '`{@command template acme-dashboard}`',],- ['A theme slug, such as `ocean`', '`astryx theme add ocean`'],+ ['A theme slug, such as `ocean`', '`{@command theme add ocean}`'],['A topic name or route, such as `acme/deploying`','Reads of the old name, and links to it from other docs',diff --git a/packages/cli/assets/docs/tree/who-answers.doc.mjs b/packages/cli/assets/docs/tree/who-answers.doc.mjsindex 25a671d281..b150f4e611 100644--- a/packages/cli/assets/docs/tree/who-answers.doc.mjs+++ b/packages/cli/assets/docs/tree/who-answers.doc.mjs@@ -44,7 +44,7 @@ export const docs = {},{type: 'prose',- text: "Components come from `@astryxdesign/core`, and templates, docs, and agent guides come from the CLI. In a project, that Core is the one the project installs, so component commands work offline once the project's dependencies are installed. Outside a project, or in a project with nothing installed yet (a fresh clone), they use the answering version's own Core, from beside the CLI or the cache; when that Core cannot be downloaded, the error says to install the project's dependencies. When the project's CLI and Core are different versions, `astryx doctor` warns and prints the command that brings them to one version.",+ text: "Components come from `@astryxdesign/core`, and templates, docs, and agent guides come from the CLI. In a project, that Core is the one the project installs, so component commands work offline once the project's dependencies are installed. Outside a project, or in a project with nothing installed yet (a fresh clone), they use the answering version's own Core, from beside the CLI or the cache; when that Core cannot be downloaded, the error says to install the project's dependencies. When the project's CLI and Core are different versions, `{@command doctor}` warns and prints the command that brings them to one version.",},],},@@ -58,7 +58,7 @@ export const docs = {},{type: 'prose',- text: 'A few commands work on your computer rather than a folder, such as `astryx init --user`: your global install answers them in any folder.',+ text: 'A few commands work on your computer rather than a folder, such as `{@command init --user}`: your global install answers them in any folder.',},],},@@ -101,7 +101,7 @@ export const docs = {content: [{type: 'prose',- text: "Commands the CLI prints for you to run start with a name that reaches the same version: the project's runner (such as `pnpm exec astryx`) in a project, `astryx` outside a project when your global install answered, and otherwise the CLI pinned to the version, such as `npx @astryxdesign/[email protected]`. An integration can name its own command: {@link generic:cli-command}.",+ text: "Commands the CLI prints for you to run start with a name that reaches the same version: the project's runner (such as `pnpm exec astryx`) in a project, `astryx` outside a project when your global install answered, and otherwise the CLI pinned to the version, such as `{@pm dlx @astryxdesign/[email protected]}`. An integration can name its own command: {@link generic:cli-command}.",},],},@@ -111,7 +111,7 @@ export const docs = {content: [{type: 'prose',- text: 'This page is part of {@link namespace:global}, which explains what global mode is and how each part works. To check your computer, run `astryx doctor` outside any project ({@link command:doctor}). Monorepos: {@link generic:monorepos}.',+ text: 'This page is part of {@link namespace:global}, which explains what global mode is and how each part works. To check your computer, run `{@command doctor}` outside any project ({@link command:doctor}). Monorepos: {@link generic:monorepos}.',},],},diff --git a/packages/cli/assets/docs/tree/write-the-template-file.doc.mjs b/packages/cli/assets/docs/tree/write-the-template-file.doc.mjsindex f7593e7cd0..5ec3ea7492 100644--- a/packages/cli/assets/docs/tree/write-the-template-file.doc.mjs+++ b/packages/cli/assets/docs/tree/write-the-template-file.doc.mjs@@ -26,7 +26,7 @@ export const docs = {content: [{type: 'prose',- text: '`astryx template` copies exactly one source file. It does not copy sibling helpers, stylesheets, fonts, icons, images, or media. Plan for that before you add supporting files.',+ text: '`{@command template}` copies exactly one source file. It does not copy sibling helpers, stylesheets, fonts, icons, images, or media. Plan for that before you add supporting files.',},{type: 'table',@@ -44,13 +44,13 @@ export const docs = {type: 'code',lang: 'bash',code: `# Page: src/app/account/page.tsx-astryx template acme-account src/app/account+{@command template acme-account src/app/account}# Block: src/features/account/acme-stat-card.tsx-astryx template acme-stat-card src/features/account+{@command template acme-stat-card src/features/account}# Exact destination for either kind-astryx template acme-stat-card src/features/account/StatusCard.tsx`,+{@command template acme-stat-card src/features/account/StatusCard.tsx}`,},{type: 'prose',diff --git a/packages/cli/assets/docs/use-a-theme.doc.mjs b/packages/cli/assets/docs/use-a-theme.doc.mjsindex 2fe7cf9f7f..3c4e505f07 100644--- a/packages/cli/assets/docs/use-a-theme.doc.mjs+++ b/packages/cli/assets/docs/use-a-theme.doc.mjs@@ -19,7 +19,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Install and add a theme',- code: 'npm install @astryxdesign/theme-neutral\nastryx theme add neutral',+ code: '{@pm install @astryxdesign/theme-neutral}\n{@command theme add neutral}',},{type: 'code',@@ -54,7 +54,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Add descriptors to earlier copies',- code: 'astryx upgrade --from 0.6.4 --path . --apply',+ code: '{@command upgrade --from 0.6.4 --path . --apply}',},{type: 'prose',@@ -71,13 +71,13 @@ export const docs = {content: [{type: 'prose',- text: 'Install the theme package you want with `npm install @astryxdesign/theme-{name}`, then import its slug with `theme add <slug>`. The CLI imports the package\'s built outputs for you.',+ text: 'Install the theme package you want with `{@pm install @astryxdesign/theme-<name>}`, then import its slug with `theme add <slug>`. The CLI imports the package\'s built outputs for you.',},{type: 'table',headers: ['Theme', 'Add command', 'Description'],rows: [- ['Neutral', 'astryx theme add neutral', 'Muted, minimal aesthetic with Figtree typography. A good starting point.'],+ ['Neutral', '{@command theme add neutral}', 'Muted, minimal aesthetic with Figtree typography. A good starting point.'],['Butter', 'astryx theme add butter', 'Golden, buttery surfaces with blue accents; Sarina + Outfit type.'],['Chocolate', 'astryx theme add chocolate', 'Warm brown tones and cozy beige; Fraunces + Albert Sans type.'],['Gothic', 'astryx theme add gothic', 'Dark-only atmospheric theme; deep blue-gray surfaces, distressed display type.'],@@ -97,7 +97,7 @@ export const docs = {content: [{type: 'prose',- text: "`<Theme>` takes `theme` (required), `mode` (`'system'` by default, or `'light'`/`'dark'`), and `children`. For every prop, run `astryx component Theme`.",+ text: "`<Theme>` takes `theme` (required), `mode` (`'system'` by default, or `'light'`/`'dark'`), and `children`. For every prop, run `{@command component Theme}`.",},],},@@ -113,7 +113,7 @@ export const docs = {type: 'code',lang: 'bash',label: 'Install, inspect, and add',- code: 'npm install @astryxdesign/core @acme/brand-integration\nastryx theme list --package @acme/brand-integration\nastryx docs brand-theme\nastryx theme add ocean --package @acme/brand-integration',+ code: '{@pm install @astryxdesign/core @acme/brand-integration}\n{@command theme list --package @acme/brand-integration}\n{@command docs brand-theme}\n{@command theme add ocean --package @acme/brand-integration}',},{type: 'prose',@@ -175,11 +175,11 @@ export const docs = {headers: ['', 'Runtime (source)', 'Built'],rows: [['Import (published theme)', '@astryxdesign/theme-{name}', '@astryxdesign/theme-{name}/built + theme.css'],- ['Import (custom theme)', 'defineTheme() directly', 'Built .js + .css from `astryx theme build`'],+ ['Import (custom theme)', 'defineTheme() directly', 'Built .js + .css from `{@command theme build}`'],['How it works', 'useInsertionEffect injects <style> at hydration', 'Pre-compiled .css file loaded with the page'],['Component overrides', 'Injected client-only', 'In static CSS: present during SSR'],['SSR safe', 'Tokens yes, component overrides flash on hydration', 'Fully SSR safe: no flash'],- ['Best for', 'Authoring input for `astryx theme build`', 'App wiring, in development and production'],+ ['Best for', 'Authoring input for `{@command theme build}`', 'App wiring, in development and production'],],},{@@ -188,8 +188,8 @@ export const docs = {items: ['Use `theme add` for production apps; it wires the built module and CSS.','Import `themes` and `defaultThemeSlug` from the generated module once, and keep that wiring in development too.',- 'While you edit a local theme, run `astryx theme build --watch` so its built files stay current.',- 'Run `astryx theme build` for custom themes to get the built artifacts.',+ 'While you edit a local theme, run `{@command theme build --watch}` so its built files stay current.',+ 'Run `{@command theme build}` for custom themes to get the built artifacts.',],},{diff --git a/packages/cli/assets/docs/use-integrations.doc.mjs b/packages/cli/assets/docs/use-integrations.doc.mjsindex 097bacd486..d66681cf98 100644--- a/packages/cli/assets/docs/use-integrations.doc.mjs+++ b/packages/cli/assets/docs/use-integrations.doc.mjs@@ -55,7 +55,7 @@ export const docs = {{type: 'code',lang: 'bash',- code: 'npm install @acme/brand-integration',+ code: '{@pm install @acme/brand-integration}',},{type: 'prose',diff --git a/packages/cli/assets/docs/working-with-ai.doc.mjs b/packages/cli/assets/docs/working-with-ai.doc.mjsindex 213a6ddad4..f66a604210 100644--- a/packages/cli/assets/docs/working-with-ai.doc.mjs+++ b/packages/cli/assets/docs/working-with-ai.doc.mjs@@ -40,7 +40,7 @@ export const docs = {},{type: 'prose',- text: "That's it. The `init --features agents` command generates everything your AI needs (component index, behavioral rules, CLI reference, and package guidance from configured integrations) from the installed project. After a dependency bump, `astryx upgrade --from <old version>` reports a stale block and adding `--apply` refreshes it.",+ text: "That's it. The `init --features agents` command generates everything your AI needs (component index, behavioral rules, CLI reference, and package guidance from configured integrations) from the installed project. After a dependency bump, `{@command upgrade --from <old version>}` reports a stale block and adding `--apply` refreshes it.",},{type: 'prose',@@ -50,12 +50,12 @@ export const docs = {type: 'code',lang: 'bash',label: 'Manual options',- code: `astryx init --features agents --agent claude # CLAUDE.md if present, else .claude/CLAUDE.md-astryx init --features agents --agent cursor # .cursorrules if present, else AGENTS.md-astryx init --features agents --agent codex # AGENTS.md (Copilot, Codex, etc.)-astryx init --features agents --agent hermes # .hermes.md or HERMES.md if present, else AGENTS.md-astryx init --features agents --agent muse # AGENTS.md (Muse)-astryx init --features agents --agent all # every agent file present except GEMINI.md, else AGENTS.md and .claude/CLAUDE.md`,+ code: `{@command init --features agents --agent claude} # CLAUDE.md if present, else .claude/CLAUDE.md+{@command init --features agents --agent cursor} # .cursorrules if present, else AGENTS.md+{@command init --features agents --agent codex} # AGENTS.md (Copilot, Codex, etc.)+{@command init --features agents --agent hermes} # .hermes.md or HERMES.md if present, else AGENTS.md+{@command init --features agents --agent muse} # AGENTS.md (Muse)+{@command init --features agents --agent all} # every agent file present except GEMINI.md, else AGENTS.md and .claude/CLAUDE.md`,},{type: 'prose',@@ -63,7 +63,7 @@ astryx init --features agents --agent all # every agent file present excep},{type: 'prose',- text: "For agents that work outside any one project, your global install keeps one short Astryx skill, `~/.agents/skills/astryx/SKILL.md`, linked into the skill folders agent tools read, such as `~/.claude/skills/astryx`. It tells agents Astryx is there and when to use it; `astryx init --user` writes it now or, with `--remove-agents`, turns it off. Inside a project, agents follow that project's own agent docs. See {@link generic:computer-agent-guide}.",+ text: "For agents that work outside any one project, your global install keeps one short Astryx skill, `~/.agents/skills/astryx/SKILL.md`, linked into the skill folders agent tools read, such as `~/.claude/skills/astryx`. It tells agents Astryx is there and when to use it; `{@command init --user}` writes it now or, with `--remove-agents`, turns it off. Inside a project, agents follow that project's own agent docs. See {@link generic:computer-agent-guide}.",},],},@@ -78,9 +78,9 @@ astryx init --features agents --agent all # every agent file present exceptype: 'list',style: 'ordered',items: [- '`astryx build "<idea>"`: get the page template to start from (always one: the closest match, or the app shell), two other templates, and the blocks and components for the parts it lacks',- '`astryx template <name> <path>`: scaffold that template into the project, keep its frame and spacing, and replace its content',- '`astryx component <Name>`: read props and examples for every component used',+ '`{@command build "<idea>"}`: get the page template to start from (always one: the closest match, or the app shell), two other templates, and the blocks and components for the parts it lacks',+ '`{@command template <name> <path>}`: scaffold that template into the project, keep its frame and spacing, and replace its content',+ '`{@command component <Name>}`: read props and examples for every component used',],},{@@ -100,7 +100,7 @@ astryx init --features agents --agent all # every agent file present exceptype: 'code',lang: 'bash',label: 'Install as a Cursor project rule',- code: `astryx init --features agents --agent-docs-path .cursor/rules/astryx.mdc`,+ code: `{@command init --features agents --agent-docs-path .cursor/rules/astryx.mdc}`,},{type: 'prose',@@ -171,9 +171,9 @@ npm run astryx -- docs tokens --dense`,type: 'code',lang: 'bash',label: 'Short output for pasting into AI conversations',- code: `astryx docs styling --full --detail brief-astryx component Dialog --detail compact-astryx docs principles --dense`,+ code: `{@command docs styling --full --detail brief}+{@command component Dialog --detail compact}+{@command docs principles --dense}`,},],},diff --git a/packages/cli/authoring/codemod/codemod.doc.mjs b/packages/cli/authoring/codemod/codemod.doc.mjsindex 4a46ae53a4..d23cd0dea6 100644--- a/packages/cli/authoring/codemod/codemod.doc.mjs+++ b/packages/cli/authoring/codemod/codemod.doc.mjs@@ -14,7 +14,7 @@ export const doc = {displayName: 'Astryx Codemod',namespace: 'authoring',description:- 'A codemod module the CLI runs during `astryx upgrade`. Default-export a ' ++ 'A codemod module the CLI runs during `{@command upgrade}`. Default-export a ' +"plain object with a `type` discriminant: 'code' rewrites source files, " +"'config' rewrites the astryx.config.* file. There is no factory to call.",appliesTo:diff --git a/packages/cli/authoring/config/config.doc.mjs b/packages/cli/authoring/config/config.doc.mjsindex e0fe98fbcf..e7bce3a084 100644--- a/packages/cli/authoring/config/config.doc.mjs+++ b/packages/cli/authoring/config/config.doc.mjs@@ -30,7 +30,7 @@ export const doc = {name: 'issuesUrl',type: 'string',description:- "Where reports about Core go: `astryx gap-report` routes a Core report here when no handler is loaded, gapReport handlers receive it as `report.target.issuesUrl`, and `astryx swizzle` prints it as the feedback link for a Core component. A report or swizzle for an integration's component uses that integration's own issuesUrl, never this one. An absolute URL; a value that is not a URL makes the config invalid.",+ "Where reports about Core go: `{@command gap-report}` routes a Core report here when no handler is loaded, gapReport handlers receive it as `report.target.issuesUrl`, and `{@command swizzle}` prints it as the feedback link for a Core component. A report or swizzle for an integration's component uses that integration's own issuesUrl, never this one. An absolute URL; a value that is not a URL makes the config invalid.",default: "'https://github.com/facebook/astryx/issues/new'",},{@@ -42,7 +42,7 @@ export const doc = {name: 'hooks.postCodemod',type: 'PostCodemodHook[]',description:- 'Commands to run after `astryx upgrade` changes files (e.g. re-run your formatter). Each hook is an object `{name?, buildCommand}`: buildCommand gets `{packageDir, files}` and returns `{command, args?, options?}` to run, or null to skip. A dry run prints each command instead of running it.',+ 'Commands to run after `{@command upgrade}` changes files (e.g. re-run your formatter). Each hook is an object `{name?, buildCommand}`: buildCommand gets `{packageDir, files}` and returns `{command, args?, options?}` to run, or null to skip. A dry run prints each command instead of running it.',},],},@@ -66,7 +66,7 @@ export const doc = {name: 'discover',type: 'DiscoverSource',description:- 'Tell `astryx discover` which integrations this project could add: an async function that returns a catalog. An integration can provide one too, as a `discover` named export from its manifest. Discover calls every source, yours first, and one that fails never hides the others. Discover only reads; your package manager installs.',+ 'Tell `{@command discover}` which integrations this project could add: an async function that returns a catalog. An integration can provide one too, as a `discover` named export from its manifest. Discover calls every source, yours first, and one that fails never hides the others. Discover only reads; your package manager installs.',example:"async ({signal, package: name, version}) => fetchCatalog({signal, name, version})",},@@ -101,7 +101,7 @@ export const doc = {notes: [{type: 'prose',- text: 'The config is validated at load with a strict schema: an unknown key, a misspelled one included, or a value of the wrong type makes the whole file invalid. `astryx gap-report`, `astryx discover`, and `astryx upgrade` stop with the error, and `astryx doctor` fails its `config` check (exit 1). Reads such as `component`, `docs`, `search`, `template`, and `theme` carry on silently as if there were no config and no integrations, and no debug handler runs, so run `astryx doctor` after editing the file.',+ text: 'The config is validated at load with a strict schema: an unknown key, a misspelled one included, or a value of the wrong type makes the whole file invalid. `{@command gap-report}`, `{@command discover}`, and `{@command upgrade}` stop with the error, and `{@command doctor}` fails its `config` check (exit 1). Reads such as `component`, `docs`, `search`, `template`, and `theme` carry on silently as if there were no config and no integrations, and no debug handler runs, so run `{@command doctor}` after editing the file.',},],};diff --git a/packages/cli/authoring/discover/discover.doc.mjs b/packages/cli/authoring/discover/discover.doc.mjsindex c7b0d6d2ff..b0b4560f42 100644--- a/packages/cli/authoring/discover/discover.doc.mjs+++ b/packages/cli/authoring/discover/discover.doc.mjs@@ -16,7 +16,7 @@ export const doc = {displayName: 'DiscoverSource',namespace: 'authoring',description:- 'A source for `astryx discover`: an async function that returns a catalog of packages a project could add, their versions, and what each version adds. Set it as `discover` in astryx.config, or export it as `discover` from an integration manifest. Discover calls every source, the project one first, and then reads the official list the CLI carries; another source\'s entry for an official package is kept. A source that throws, runs past 30 seconds, or returns an invalid catalog never hides the others; discover then uses the last good answer that source gave for the same request, or reports the source as failed when it saved none. Discover only reads: it prints the command that adds a package and never runs it.',+ "A source for `{@command discover}`: an async function that returns a catalog of packages a project could add, their versions, and what each version adds. Set it as `discover` in astryx.config, or export it as `discover` from an integration manifest. Discover calls every source, the project one first, and then reads the official list the CLI carries; another source's entry for an official package is kept. A source that throws, runs past 30 seconds, or returns an invalid catalog never hides the others; discover then uses the last good answer that source gave for the same request, or reports the source as failed when it saved none. Discover only reads: it prints the command that adds a package and never runs it.",appliesTo:'`discover` in astryx.config.*, or the `discover` named export of astryx.integration.*',fields: [diff --git a/packages/cli/authoring/gap-report/gap-report.doc.mjs b/packages/cli/authoring/gap-report/gap-report.doc.mjsindex f1f57e8b52..859cbf16dd 100644--- a/packages/cli/authoring/gap-report/gap-report.doc.mjs+++ b/packages/cli/authoring/gap-report/gap-report.doc.mjs@@ -15,7 +15,7 @@ export const doc = {displayName: 'GapReportHandler',namespace: 'authoring',description:- "A handler for `astryx gap-report`: a plain object with an `audience` and a `handle` function. Set it as `gapReport` in astryx.config, or export it as `gapReport` from an integration manifest. Handlers add up rather than replace each other: the project handler first, then each loaded integration's in load order (the `integrations` list, then autolinked ones), whichever package the report is about.",+ "A handler for `{@command gap-report}`: a plain object with an `audience` and a `handle` function. Set it as `gapReport` in astryx.config, or export it as `gapReport` from an integration manifest. Handlers add up rather than replace each other: the project handler first, then each loaded integration's in load order (the `integrations` list, then autolinked ones), whichever package the report is about.",appliesTo:'`gapReport` in astryx.config.*, or the `gapReport` named export of astryx.integration.*',fields: [diff --git a/packages/cli/authoring/integration/integration.doc.mjs b/packages/cli/authoring/integration/integration.doc.mjsindex 4932e23df4..9cb9ef6aef 100644--- a/packages/cli/authoring/integration/integration.doc.mjs+++ b/packages/cli/authoring/integration/integration.doc.mjs@@ -51,14 +51,14 @@ export const doc = {name: 'docs',type: 'string',description:- 'The folder that holds your doc topics, relative to package.json. Every {topic}.doc.{ts,mjs,js} under it shows up in `astryx docs`: a flat topic next to the built-in topics, where it can set `replaces` or `extends` to take over a built-in topic or add to it, and a guide with `placement` at its own route in the docs tree, under a namespace doc of the same package.',+ 'The folder that holds your doc topics, relative to package.json. Every {topic}.doc.{ts,mjs,js} under it shows up in `{@command docs}`: a flat topic next to the built-in topics, where it can set `replaces` or `extends` to take over a built-in topic or add to it, and a guide with `placement` at its own route in the docs tree, under a namespace doc of the same package.',example: "'./docs'",},{name: 'themes',type: 'string',description:- 'The folder that holds your themes, relative to package.json, with one folder per theme. Each theme folder has the theme source and a matching .doc.mjs file with the same name. Installed themes show up in `astryx theme list`; `theme add` imports their built package exports, and `theme eject` creates an editable local fork.',+ 'The folder that holds your themes, relative to package.json, with one folder per theme. Each theme folder has the theme source and a matching .doc.mjs file with the same name. Installed themes show up in `{@command theme list}`; `theme add` imports their built package exports, and `theme eject` creates an editable local fork.',example: "'./themes'",},{@@ -72,7 +72,7 @@ export const doc = {name: 'issuesUrl',type: 'string',description:- "Where people file issues for this package: an absolute URL, such as its GitHub issues page. A value that is not a URL fails the whole manifest; the scheme is not checked. Nothing warns when it is missing, but without it `astryx gap-report` about this package fails unless the project or a loaded integration has a gapReport handler, and `astryx swizzle` prints no feedback link for this package's components. When no handler is loaded, a github.com issues URL is filed with the GitHub CLI once the reporter passes `--confirm-public`; any other URL is returned for the reporter to open.",+ "Where people file issues for this package: an absolute URL, such as its GitHub issues page. A value that is not a URL fails the whole manifest; the scheme is not checked. Nothing warns when it is missing, but without it `{@command gap-report}` about this package fails unless the project or a loaded integration has a gapReport handler, and `{@command swizzle}` prints no feedback link for this package's components. When no handler is loaded, a github.com issues URL is filed with the GitHub CLI once the reporter passes `--confirm-public`; any other URL is returned for the reporter to open.",example: "'https://github.com/acme/widgets/issues'",},{@@ -86,7 +86,7 @@ export const doc = {name: 'cliCommand',type: 'string',description:- 'The command your users run the Astryx CLI with, when it is not their package manager, such as a wrapper your company ships. Every command the CLI prints in an app that loads your package starts with it, in place of `pnpm exec astryx` or `yarn astryx`: hints, errors, Doctor fixes, and doc text. One line, without a subcommand. If two loaded packages set different commands, neither is used and `astryx doctor` warns. An invalid value is ignored with an `invalid_cli_command` warning, and the rest of the manifest still loads. JSON output keeps commands bare.',+ 'The command your users run the Astryx CLI with, when it is not their package manager, such as a wrapper your company ships. Every command the CLI prints in an app that loads your package starts with it, in place of `pnpm exec astryx` or `yarn astryx`: hints, errors, Doctor fixes, and doc text. One line, without a subcommand. If two loaded packages set different commands, neither is used and `{@command doctor}` warns. An invalid value is ignored with an `invalid_cli_command` warning, and the rest of the manifest still loads. JSON output keeps commands bare.',example: "'acme astryx'",},],@@ -131,7 +131,7 @@ export const doc = {},{type: 'prose',- text: "Set `cliCommand` only when your users run the CLI with a command other than their package manager's, such as `acme astryx`. The CLI picks the command it prints in this order: the `cliCommand` of the loaded integrations when they name one command, then the command a host tool names, then the package manager's. Two different `cliCommand` values cancel out, and `astryx doctor` warns in its `cli-command` check. See `astryx docs authoring/building-blocks/configuration/cli-command`.",+ text: "Set `cliCommand` only when your users run the CLI with a command other than their package manager's, such as `acme astryx`. The CLI picks the command it prints in this order: the `cliCommand` of the loaded integrations when they name one command, then the command a host tool names, then the package manager's. Two different `cliCommand` values cancel out, and `{@command doctor}` warns in its `cli-command` check. See `{@command docs authoring/building-blocks/configuration/cli-command}`.",},{type: 'prose',@@ -140,7 +140,7 @@ export const doc = {{type: 'prose',text:- 'Validate the manifest with `astryx doctor integration validate`. At the ' ++ 'Validate the manifest with `{@command doctor integration validate}`. At the ' +'load boundary, a known field of the wrong type is an error, issuesUrl ' +'and docsiteUrl must be valid URLs, and unknown fields become warnings so an older CLI ' +'can still load the fields it understands. Before publishing, also run ' +diff --git a/packages/cli/clients/cli/commands/docs.doc.mjs b/packages/cli/clients/cli/commands/docs.doc.mjsindex 5d4d81683d..804ce81f17 100644--- a/packages/cli/clients/cli/commands/docs.doc.mjs+++ b/packages/cli/clients/cli/commands/docs.doc.mjs@@ -23,7 +23,7 @@ export const doc = {'opens a node of the docs tree: `cli` lists its guides and reference, ' +'`cli/api/functions` lists every API function, and `cli/api/functions/search` prints ' +'one. A namespace plus a section prints that section from the one guide below it ' +- 'that has it (`astryx docs layout side-panels`). `--depth` reads as far down the tree as you ask, from the doc alone (0) to ' ++ 'that has it (`{@command docs layout side-panels}`). `--depth` reads as far down the tree as you ask, from the doc alone (0) to ' +'everything below it (all), and with it `--detail` sets how much of each doc below ' +'shows: one line (brief, the default), its sections (compact), or all of it (full).',fn: 'docs',diff --git a/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs b/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjsindex a51855da65..257beebe94 100644--- a/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs+++ b/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs@@ -17,7 +17,7 @@ export const doc = {'and fails until the author declares the relationship or renames it. ' +'It also lists each pair of topics (two of the package, or one of them and a Core topic other than the one it replaces) ' +'that repeat 10 or more words of prose word for word, each padding phrase and low-density topic, ' +- 'and each written `astryx docs <name>` that should be a link, ' ++ 'and each written `{@command docs <name>}` that should be a link, ' +'each as a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`; exit 0, and `integration check --strict` fails on it). See {@link generic:check-your-docs}.',fn: 'integrationDocConflicts',args: [diff --git a/packages/cli/clients/cli/commands/doctor.doc.mjs b/packages/cli/clients/cli/commands/doctor.doc.mjsindex 7c163cfad7..0fdb09d07c 100644--- a/packages/cli/clients/cli/commands/doctor.doc.mjs+++ b/packages/cli/clients/cli/commands/doctor.doc.mjs@@ -21,7 +21,7 @@ export const doc = {"the docs the CLI reads, the newest release the computer knows of, with the install and upgrade commands when the project's release is older, and every `astryx` command on the search path, warning when the first one is not the Astryx CLI or predates the hand-off. It writes nothing, but loading astryx.config runs that file's code. " +'The `integration` subcommands provide authoring checks for one integration package. ' +'Outside a project it checks the computer instead: the Node version, the release that answered, ' +- "the newest release this computer knows of, with the command that upgrades the CLI installed for the computer when it is older, the astryx commands on the search path, the integrations installed for the computer (warning about one it skips), and whether the computer-level agent text (`astryx init --user`) is present, matches this release, was edited, or is turned off (info only); when that text names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, it says so and names the install step the text records, or npm's when it records none. " ++ "the newest release this computer knows of, with the command that upgrades the CLI installed for the computer when it is older, the astryx commands on the search path, the integrations installed for the computer (warning about one it skips), and whether the computer-level agent text (`{@command init --user}`) is present, matches this release, was edited, or is turned off (info only); when that text names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, it says so and names the install step the text records, or npm's when it records none. " +'It never fails a check because the folder has no project.',fn: 'doctor',subcommands: ['integration'],diff --git a/packages/cli/clients/cli/commands/doctor.mjs b/packages/cli/clients/cli/commands/doctor.mjsindex 9ec7c8b8de..2e740be8a4 100644--- a/packages/cli/clients/cli/commands/doctor.mjs+++ b/packages/cli/clients/cli/commands/doctor.mjs@@ -225,7 +225,8 @@ function printIntegrationValidation(data) {]: [text('[ok] No integration issues found.')]),...(data.notes ?? []).map(note =>- text(`note (${note.code}): ${note.message}`),+ // A note marked next fails --strict from the next minor release.+ text(`note (${note.code}): ${note.next ? '[next minor] ' : ''}${note.message}`),),text(`Summary: ${errors} error${errors === 1 ? '' : 's'}, ` +diff --git a/packages/cli/clients/cli/commands/integration-check.doc.mjs b/packages/cli/clients/cli/commands/integration-check.doc.mjsindex 1cee420f00..a29634ab00 100644--- a/packages/cli/clients/cli/commands/integration-check.doc.mjs+++ b/packages/cli/clients/cli/commands/integration-check.doc.mjs@@ -45,6 +45,12 @@ export const doc = {description:'Also exit 1 on any warning and on any check that did not run. A new check or failure code joins only in a minor release, named in the release notes; until then, a malformed `cliCommand` is reported as a note (`invalid_cli_command`) that fails nothing.',},+ {+ flag: '--next',+ param: 'options.next',+ description:+ 'Also count the findings the next minor release turns into warnings (the notes marked `next`) as warnings now, so `--strict --next` fails on them. Run it to fix them ahead of the release; every run says how many there are.',+ },],examples: [{@@ -56,6 +62,11 @@ export const doc = {label: 'Errors only, while you fix the warnings a package already has',cli: 'integration check',},+ {+ label:+ 'Fix ahead: fail on the findings the next minor release will fail on',+ cli: 'integration check --strict --next',+ },{label: 'Read the result as JSON',cli: 'integration check --strict --json',diff --git a/packages/cli/clients/cli/commands/integration-check.test.mjs b/packages/cli/clients/cli/commands/integration-check.test.mjsindex a2d88ce46b..6cc72a169c 100644--- a/packages/cli/clients/cli/commands/integration-check.test.mjs+++ b/packages/cli/clients/cli/commands/integration-check.test.mjs@@ -289,7 +289,7 @@ describe('astryx integration check', () => {'invalid_cli_command',);expect(validate.notes).toEqual([- {code: 'invalid_cli_command', message: expect.any(String)},+ {code: 'invalid_cli_command', message: expect.any(String), next: true},]);expect(envelope.data.failed).toBe(false);expect(json.status).toBe(0);@@ -302,6 +302,39 @@ describe('astryx integration check', () => {).toHaveLength(1);});+ it('--next counts next notes as warnings, and --strict --next fails on them', async () => {+ writePackage({+ id: 'acme-next-fixture',+ extraManifest: ", cliCommand: ' acme astryx\\n'",+ });++ const plain = JSON.parse(+ (await runCli(['--json', 'integration', 'check'], tmpDir)).stdout,+ ).data;+ expect(plain).toMatchObject({next: false, upcoming: 1, warnings: 0});++ const next = await runCli(['--json', 'integration', 'check', '--next'], tmpDir);+ const nextData = JSON.parse(next.stdout).data;+ expect(nextData).toMatchObject({next: true, upcoming: 1, warnings: 1, failed: false});+ expect(nextData.checks[0].warnings).toBe(1);+ expect(next.status).toBe(0);++ const strict = await runCli(+ ['--json', 'integration', 'check', '--strict', '--next'],+ tmpDir,+ );+ const strictData = JSON.parse(strict.stdout).data;+ expect(strictData.failed).toBe(true);+ expect(strictData.failures).toContainEqual(+ expect.objectContaining({check: 'validate', code: 'invalid_cli_command'}),+ );+ expect(strict.status).toBe(1);++ const text = await runCli(['integration', 'check', '--next'], tmpDir);+ expect(text.stdout).toContain('note (invalid_cli_command): [next minor] ');+ expect(text.stdout).toContain('(next)');+ });+it('takes no package name: one passed is an error, not a check of the current folder', async () => {writePackage({id: 'acme-page'});@@ -470,9 +503,9 @@ describe('a command written with a runner', () => {const doctor = await runCli(['doctor', 'integration', 'validate'], tmpDir);expect(doctor.status).toBe(0);expect(doctor.stdout).toContain(- 'note (runner_command): docs/acme-setup.doc.mjs:',+ 'note (runner_command): [next minor] docs/acme-setup.doc.mjs:',);- expect(doctor.stdout).toContain('Write `astryx doctor`');+ expect(doctor.stdout).toContain('Write the token `{@command doctor}`');const strict = await runCli(['--json', 'integration', 'check', '--strict'],diff --git a/packages/cli/clients/cli/commands/integration-pack.doc.mjs b/packages/cli/clients/cli/commands/integration-pack.doc.mjsindex 2fe47038fd..2875127b93 100644--- a/packages/cli/clients/cli/commands/integration-pack.doc.mjs+++ b/packages/cli/clients/cli/commands/integration-pack.doc.mjs@@ -8,7 +8,7 @@ export const doc = {namespace: 'cli/commands',summary: 'Deprecated: the old name of `integration verify`',description:- '`astryx integration pack --check` is the name this check had before {@link command:integration verify}. It still runs the same check, with the same output, JSON, and exit codes, and prints a note that names `integration verify`. It will be removed in a later release. Outside a package it writes nothing and reports one failed check, no_package, naming the integration package it needs (exit 1).',+ '`{@command integration pack --check}` is the name this check had before {@link command:integration verify}. It still runs the same check, with the same output, JSON, and exit codes, and prints a note that names `integration verify`. It will be removed in a later release. Outside a package it writes nothing and reports one failed check, no_package, naming the integration package it needs (exit 1).',fn: 'integrationPackCheck',options: [{diff --git a/packages/cli/clients/cli/commands/integration-verify.doc.mjs b/packages/cli/clients/cli/commands/integration-verify.doc.mjsindex c177463edf..3d21ab4072 100644--- a/packages/cli/clients/cli/commands/integration-verify.doc.mjs+++ b/packages/cli/clients/cli/commands/integration-verify.doc.mjs@@ -8,7 +8,7 @@ export const doc = {namespace: 'cli/commands',summary: 'Check the package the way npm will publish it, before you publish',description:- 'Packs the package with npm, unpacks the tarball into a temporary app without installing its dependencies, and checks that the app sees the same components, templates, themes, docs, and codemods as the package, that every public import resolves, and that the package declares a CLI new enough to read it. It publishes nothing and leaves no tarball behind. It runs the package\'s own pack lifecycle scripts, as `npm pack` does. Outside a package it writes nothing and reports one failed check, no_package, naming the integration package it needs (exit 1).',+ 'Packs the package with npm, unpacks the tarball into a temporary app without installing its dependencies, and checks that the app sees the same components, templates, themes, docs, and codemods as the package, that every public import resolves, and that the package declares a CLI new enough to read it. It publishes nothing and leaves no tarball behind. It runs the package\'s own pack lifecycle scripts, as `{@pm-only npm "the tarball the registry receives" pack}` does. Outside a package it writes nothing and reports one failed check, no_package, naming the integration package it needs (exit 1).',fn: 'integrationPackCheck',examples: [{label: 'Check before publishing', cli: 'astryx integration verify'},diff --git a/packages/cli/clients/cli/commands/integration.mjs b/packages/cli/clients/cli/commands/integration.mjsindex 4d04fb1771..f7270798a8 100644--- a/packages/cli/clients/cli/commands/integration.mjs+++ b/packages/cli/clients/cli/commands/integration.mjs@@ -104,10 +104,13 @@ async function verifyPackage(program) {* it, then one summary: each check's errors, warnings and skipped work, and* what decided the exit code.* @param {import('commander').Command} program- * @param {{strict?: boolean}} options+ * @param {{strict?: boolean, next?: boolean}} options*/async function checkPackage(program, options) {- const result = await integrationCheck({strict: options.strict === true});+ const result = await integrationCheck({+ strict: options.strict === true,+ next: options.next === true,+ });if (program.opts().json) {jsonOut(result);} else {@@ -182,12 +185,21 @@ async function checkPackage(program, options) {]: []),section(- `Integration check: ${identity ?? '(local package)'}${data.strict ? ' (strict)' : ''}`,+ `Integration check: ${identity ?? '(local package)'}${data.strict ? ' (strict)' : ''}${data.next ? ' (next)' : ''}`,),records(data.checks, {fields: ['check', 'failed', 'errors', 'warnings', 'skipped'],}),text(closing),+ // Every build runs this check, so this is where a package learns what+ // the next minor release will fail.+ ...(data.upcoming > 0 && !data.next+ ? [+ text(+ `${plural(data.upcoming, 'finding')} above (the notes) will fail --strict from the next minor release. Fix ${data.upcoming === 1 ? 'it' : 'them'} ahead: ${formatCliCommand('astryx integration check --strict --next')}`,+ ),+ ]+ : []),);}if (result.data.failed) process.exitCode = 1;diff --git a/packages/cli/clients/cli/commands/theme-targets.doc.mjs b/packages/cli/clients/cli/commands/theme-targets.doc.mjsindex fed9b3ffca..6b0f16402f 100644--- a/packages/cli/clients/cli/commands/theme-targets.doc.mjs+++ b/packages/cli/clients/cli/commands/theme-targets.doc.mjs@@ -19,7 +19,7 @@ export const doc = {'Prints every `defineTheme` components key across the system: the stable class it paints, ' +'the component that declares it, and the props and states that are legal override keys ' +'under it. This is the whole themeable surface in one command: what auditing a theme, or ' +- 'answering "which key paints this pixel?", used to need one `astryx component <Name>` per ' ++ 'answering "which key paints this pixel?", used to need one `{@command component <Name>}` per ' +'component to assemble. Pass a component name to scope it; pass any other text to search ' +'target keys, classes, and components. `--json` for a list a repo can lint its own theme against.',fn: 'themeTargets',diff --git a/packages/cli/clients/cli/commands/upgrade.doc.mjs b/packages/cli/clients/cli/commands/upgrade.doc.mjsindex 1cbf87f4c4..1ee6568186 100644--- a/packages/cli/clients/cli/commands/upgrade.doc.mjs+++ b/packages/cli/clients/cli/commands/upgrade.doc.mjs@@ -123,7 +123,7 @@ export const doc = {notes: [{type: 'prose',- text: "In global mode: in a project, upgrade runs the codemods of the project's own CLI, whichever astryx command you start; in a project with no CLI of its own, the astryx command you started runs them, so install the CLI at the new Core's version first (`astryx doctor` prints the command). Outside a project, `--list` lists this version's codemods, `--registry` finds no copied compositions, and a migration writes nothing and stops with `ERR_VERSION_DETECT`. See {@link namespace:global} and {@link generic:who-answers}.",+ text: "In global mode: in a project, upgrade runs the codemods of the project's own CLI, whichever astryx command you start; in a project with no CLI of its own, the astryx command you started runs them, so install the CLI at the new Core's version first (`{@command doctor}` prints the command). Outside a project, `--list` lists this version's codemods, `--registry` finds no copied compositions, and a migration writes nothing and stops with `ERR_VERSION_DETECT`. See {@link namespace:global} and {@link generic:who-answers}.",},{type: 'heading', level: 3, text: 'A CLI older than your Core'},{@@ -180,7 +180,7 @@ export const doc = {text:'When a codemod would change a protected file, upgrade makes the change only in memory and leaves the file as it is. ' +'The rest of the upgrade goes ahead. With --apply, your other files are written, then upgrade runs the ' +- '`hooks.postCodemod` commands from astryx.config (see `astryx docs authoring config`) and checks the protected ' ++ '`hooks.postCodemod` commands from astryx.config (see `{@command docs authoring config}`) and checks the protected ' +'files again. If one still needs the change, the run is incomplete: it exits 1, prints ' +'ERR_CODEMOD_PROTECTED with each file and the rule that protects it, and does not refresh the agent docs. ' +'Regenerate or edit those files, then run the same upgrade again. A dry run reports the same files and writes nothing.',diff --git a/packages/cli/clients/cli/lib/define-command.mjs b/packages/cli/clients/cli/lib/define-command.mjsindex 05d046e0be..a4131ed435 100644--- a/packages/cli/clients/cli/lib/define-command.mjs+++ b/packages/cli/clients/cli/lib/define-command.mjs@@ -27,6 +27,7 @@import {recordCommandResult} from '../../../foundation/debug/index.mjs';import {routeSegment} from '../../../foundation/discovery/docs-section-key.mjs';import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';+import {renderTokens} from '../../../foundation/doc-compiler/links.mjs';import {text} from '../formatters/index.mjs';/**@@ -126,7 +127,8 @@ export function defineCommand(parent, doc, {fn, action, hidden} = {}) {hidden ? {hidden: true} : {},);Object.defineProperty(cmd, COMMAND_DOCS, {value: {doc, fn}, configurable: true});- if (doc.summary) cmd.description(doc.summary);+ // Help shows doc tokens as commands, the way `astryx docs` does.+ if (doc.summary) cmd.description(renderTokens(doc.summary));if (doc.deprecated) {const base = cmd.description() || '';cmd.description(`${base} [DEPRECATED: ${doc.deprecated}]`);@@ -143,13 +145,13 @@ export function defineCommand(parent, doc, {fn, action, hidden} = {}) {// its description instead.)if (arg.description) {const argument = cmd.registeredArguments?.find(a => a.name() === arg.name);- if (argument) argument.description = arg.description;+ if (argument) argument.description = renderTokens(arg.description);}}for (const o of doc.options ?? []) {const desc = o.description ?? (o.param ? paramDesc(o.param) : '');- const option = cmd.createOption(o.flag, desc);+ const option = cmd.createOption(o.flag, renderTokens(desc));if (o.default != null) option.default(o.default);cmd.addOption(option);}diff --git a/packages/cli/foundation/agent-docs/agent-docs.mjs b/packages/cli/foundation/agent-docs/agent-docs.mjsindex b2ec61b99c..3c6b0f10d4 100644--- a/packages/cli/foundation/agent-docs/agent-docs.mjs+++ b/packages/cli/foundation/agent-docs/agent-docs.mjs@@ -36,7 +36,11 @@ import * as path from 'node:path';import {findCoreDir, findInstalledPackage, CLI_ROOT} from '../fs/paths.mjs';import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';import {createFileProtectionResolver} from '../fs/file-protection.mjs';-import {getCliInvocation} from '../env/package-manager.mjs';+import {+ docPackageManager,+ getCliInvocation,+} from '../env/package-manager.mjs';+import {renderCommandTokens} from '../doc-compiler/doc-syntax.mjs';import {isValidSemver, semverGte} from '../env/semver.mjs';import {discoverComponents} from '../discovery/component-discovery.mjs';import {Project} from '../config/project.mjs';@@ -944,8 +948,13 @@ export async function renderAgentDocsBlock(.map(input => input.doc.name),),];+ // Doc tokens in an integration's lines render here, for the project's+ // package manager; the block's header names the runner for bare commands.+ const tokenOptions = {stem: 'astryx', pm: docPackageManager(targetDir)};const agentDocs = project.loadedIntegrations.flatMap(integration => {- const append = integration.agentDocs?.append ?? [];+ const append = (integration.agentDocs?.append ?? []).map(line =>+ renderCommandTokens(line, tokenOptions),+ );if (append.length === 0) return [];return [{diff --git a/packages/cli/foundation/agent-docs/agent-docs.test.mjs b/packages/cli/foundation/agent-docs/agent-docs.test.mjsindex 431f0d8b4d..54dc8ab8da 100644--- a/packages/cli/foundation/agent-docs/agent-docs.test.mjs+++ b/packages/cli/foundation/agent-docs/agent-docs.test.mjs@@ -431,6 +431,52 @@ describe('renderAgentDocsBlock', () => {fs.rmSync(projectDir, {recursive: true, force: true});}});+ it('renders doc tokens in an integration line for the project', async () => {+ const projectDir = fs.mkdtempSync(+ path.join(process.cwd(), '.astryx-agent-doc-tokens-'),+ );+ try {+ fs.writeFileSync(+ path.join(projectDir, 'package.json'),+ JSON.stringify({name: 'consumer'}),+ );+ fs.writeFileSync(path.join(projectDir, 'bun.lock'), '{}\n');+ fs.writeFileSync(+ path.join(projectDir, 'astryx.config.mjs'),+ `export default {integrations: ['@acme/kit']};\n`,+ );+ const coreDir = path.join(+ projectDir,+ 'node_modules',+ '@astryxdesign',+ 'core',+ );+ fs.mkdirSync(coreDir, {recursive: true});+ fs.writeFileSync(+ path.join(coreDir, 'package.json'),+ JSON.stringify({name: '@astryxdesign/core', version: '1.0.0'}),+ );+ const packageDir = path.join(projectDir, 'node_modules', '@acme', 'kit');+ fs.mkdirSync(packageDir, {recursive: true});+ fs.writeFileSync(+ path.join(packageDir, 'package.json'),+ JSON.stringify({name: '@acme/kit'}),+ );+ fs.writeFileSync(+ path.join(packageDir, 'astryx.integration.mjs'),+ `export default {agentDocs: {append: ['Add it with {@pm install @acme/kit}, then run {@command doctor}.']}};\n`,+ );++ const block = await renderAgentDocsBlock(projectDir);+ expect(block).toContain(+ '- `@acme/kit`: Add it with `bun add @acme/kit`, then run `astryx doctor`.',+ );+ expect(block).not.toContain('{@');+ } finally {+ fs.rmSync(projectDir, {recursive: true, force: true});+ }+ });+it('rejects a package label that could alter managed block structure', async () => {const projectDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-agent-doc-label-'),diff --git a/packages/cli/foundation/discovery/docs-discovery.mjs b/packages/cli/foundation/discovery/docs-discovery.mjsindex 0a66028cc3..10ee1f90e5 100644--- a/packages/cli/foundation/discovery/docs-discovery.mjs+++ b/packages/cli/foundation/discovery/docs-discovery.mjs@@ -617,6 +617,7 @@ export async function discoverIntegrationDocs(integration) {kind: 'generic',name: parsed.name,title: parsed.title,+ // Rendered once, where the tree is built (api/docs/_adapter.mjs).summary: parsed.description,group: null,placement: parsed.placement,diff --git a/packages/cli/foundation/discovery/runner-allowlist.mjs b/packages/cli/foundation/discovery/runner-allowlist.mjsindex 06216fc3a0..2625ad90ba 100644--- a/packages/cli/foundation/discovery/runner-allowlist.mjs+++ b/packages/cli/foundation/discovery/runner-allowlist.mjs@@ -45,6 +45,10 @@ export const RUNNER_COMMAND_ALLOWLIST = Object.freeze({'compares running the CLI with npx to installing it, and is found by searching for that command','packages/cli/assets/docs/tree/install-once.doc.mjs':'names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version',+ 'packages/cli/assets/docs/tree/doc-syntax.doc.mjs':+ 'shows what each doc token renders as, in every package manager',+ 'packages/cli/assets/docs/tree/add-a-topic.doc.mjs':+ 'shows what a reader sees for a command token, with their runner','packages/cli/clients/cli/commands/upgrade.doc.mjs':'quotes the command upgrade prints when the CLI is older than Core, pinned to the matching release',}),diff --git a/packages/cli/foundation/discovery/runner-commands.mjs b/packages/cli/foundation/discovery/runner-commands.mjsindex bb76ad6c72..6bc43b5ba9 100644--- a/packages/cli/foundation/discovery/runner-commands.mjs+++ b/packages/cli/foundation/discovery/runner-commands.mjs@@ -24,6 +24,12 @@import fs from 'node:fs';import {loadTopicModule} from './docs-discovery.mjs';+import {+ commandTokensIn,+ tokenForCommand,+ unclosedTokensIn,+ unknownTokensIn,+} from '../doc-compiler/doc-syntax.mjs';/*** @param {string} file@@ -133,20 +139,22 @@ export function runnerCommandsIn(text) {* most commands sit in code blocks.** @param {unknown} doc- * @returns {{text: string, section: string | null}[]}+ * @returns {{text: string, section: string | null, lang: string | null}[]}*/function allStrings(doc) {- /** @type {{text: string, section: string | null}[]} */+ /** @type {{text: string, section: string | null, lang: string | null}[]} */const strings = [];// A doc that refers back to itself is walked once.const visited = new WeakSet();/*** @param {unknown} value* @param {string | null} section+ * @param {string | null} lang the code block's language when `value` is+ * its code; null for text*/- const walk = (value, section) => {+ const walk = (value, section, lang = null) => {if (typeof value === 'string') {- strings.push({text: value, section});+ strings.push({text: value, section, lang});} else if (value != null && typeof value === 'object') {if (visited.has(value)) return;visited.add(value);@@ -160,6 +168,12 @@ function allStrings(doc) {for (const each of field) {walk(each, typeof each?.title === 'string' ? each.title : section);}+ } else if (key === 'code' && typeof field === 'string') {+ walk(+ field,+ section,+ typeof record.lang === 'string' ? record.lang : '',+ );} else {walk(field, section);}@@ -196,25 +210,213 @@ function locate(lines, written, cursor) {}/**- * An Astryx command a topic writes with a package runner in front.+ * A command a topic writes that the doc syntax writes another way: with a+ * runner in front (`runner_command`), a package-manager command written for+ * one package manager (`package_manager_command`), a bare Astryx command+ * (`plain_command`), or a doc token that does not parse (`doc_token`).** @typedef {object} RunnerCommand+ * @property {string} code* @property {string} topic* @property {string | null} section the title of the section it is in* @property {string} file the doc file* @property {number | null} line the file line that holds it, when found* @property {string} command the command as written- * @property {string} message the bare command to write instead+ * @property {string} message what to write instead+ */++/** Code-block languages whose lines are shell commands. */+/**+ * Whether a package-manager command names a verb without what it acts on, so+ * prose mentions the verb rather than giving a step: `npm run`, `pnpm dlx`,+ * `npm i -g`, `yarn global add`, `npm pkg set`. Flags alone are not an+ * argument.+ * @param {string} command+ */+function isMention(command) {+ const [, verb = '', ...rest] = command.trim().split(/\s+/);+ const args = rest.filter(word => !word.startsWith('-'));+ const global = rest.some(word => word === '-g' || word === '--global');+ if (MENTION_VERBS.has(verb) && args.length === 0) return true;+ if ((verb === 'i' || verb === 'install') && global && args.length === 0) {+ return true;+ }+ if (verb === 'global' && args.length <= 1 && (args[0] ?? 'add') === 'add') {+ return true;+ }+ return (+ (verb === 'pkg' || verb === 'config') &&+ args.length <= 1 &&+ (args[0] ?? 'set') === 'set'+ );+}++/** Package-manager verbs that take an argument: named alone, a mention. */+const MENTION_VERBS = new Set([+ 'run',+ 'dlx',+ 'exec',+ 'x',+ 'add',+ 'remove',+ 'rm',+ 'uninstall',+ 'create',+ 'up',+ 'upgrade',+]);++const SHELL_LANGS = new Set(['', 'bash', 'sh', 'shell', 'zsh', 'console']);++/** Package-manager binaries a written command may start with. */+const PM_START = /^(?:npm|npx|pnpm|yarn|bun|bunx)[ \t]+\S/;++/** A bare Astryx command: `astryx` and one of the CLI's commands. */+const PLAIN_START = new RegExp(+ `^astryx${BLANK}(?:${alternatives(CLI_COMMANDS)})(?![\\w-])`,+);++/**+ * The commands a code span or a shell line holds, each as written: split at+ * `&&`, `||`, `;` and `|`, without a leading `$ ` or a trailing comment. A+ * line with a quote holds one command, its first: a quoted value can hold+ * `&&` that is not the shell's.+ * @param {string} line+ * @returns {string[]}*/+function commandsOf(line) {+ const body = line.replace(/^\s*\$\s+/, '').replace(/\s+#\s.*$/, '');+ const parts = /["']/.test(body) ? [body] : body.split(/&&|\|\||;|\|/);+ return parts.map(each => each.trim()).filter(Boolean);+}/**- * Runner commands in a package's topics.+ * The doc-syntax findings in one string of a doc, in order: runner commands,+ * package-manager commands, bare Astryx commands and tokens that do not+ * parse, each with what to write instead.+ * @param {string} text+ * @param {string | null} lang the code block's language; null for text+ * @returns {{at: number, written: string, code: string, fix: string}[]}+ */+export function docCommandsIn(text, lang) {+ /** @type {{at: number, written: string, code: string, fix: string}[]} */+ const found = [];+ const source = String(text);+ for (const each of runnerCommandsIn(source)) {+ found.push({+ at: source.indexOf(each.written),+ written: each.written,+ code: 'runner_command',+ fix:+ `Write the token \`{@command ${each.bare.slice('astryx '.length) || '…'}}\`; the CLI shows it with your project's runner` ++ (each.download+ ? ', and a download runner with the bare name fetches an unrelated package called astryx.'+ : '.'),+ });+ }+ // The commands a reader runs: code spans in text, lines in a shell block.+ /** @type {{at: number, command: string}[]} */+ const commands = [];+ if (lang == null) {+ for (const match of source.matchAll(/`([^`\n]+)`/g)) {+ // A span that is only `astryx docs <name>` points at a doc: the+ // stray-pointer check names the {@link} to write for it.+ if (/^astryx docs [\w-]+$/.test(match[1].trim())) continue;+ for (const command of commandsOf(match[1])) {+ commands.push({at: /** @type {number} */ (match.index), command});+ }+ }+ } else if (SHELL_LANGS.has(lang.toLowerCase())) {+ let offset = 0;+ for (const line of source.split('\n')) {+ for (const command of commandsOf(line)) {+ commands.push({at: offset, command});+ }+ offset += line.length + 1;+ }+ }+ for (const {at, command} of commands) {+ if (found.some(each => command.includes(each.written))) continue;+ if (isMention(command)) continue;+ if (PM_START.test(command)) {+ const token = tokenForCommand(command);+ if (token == null || token.startsWith('{@command')) continue;+ found.push({+ at,+ written: command,+ code: 'package_manager_command',+ fix: token.startsWith('{@pm-only')+ ? `Only ${command.split(/\s+/)[0]} runs this; write \`${token}\` with the reason readers see, or the \`{@pm …}\` step every package manager runs`+ : `Write \`${token}\`; the CLI shows it in your reader's package manager`,+ });+ } else if (PLAIN_START.test(command)) {+ found.push({+ at,+ written: command,+ code: 'plain_command',+ fix: `Write \`{@command ${command.slice('astryx'.length).trim()}}\`; the CLI shows it with your reader's runner and checks that the command exists`,+ });+ }+ }+ for (const {token, step} of commandTokensIn(source)) {+ if ('error' in step) {+ found.push({+ at: source.indexOf(token),+ written: token,+ code: 'doc_token',+ fix: step.error,+ });+ } else if (+ step.kind === 'command' &&+ !CLI_COMMANDS.includes(commandWord(step.args)) &&+ // `astryx --version` and `astryx --help` stand alone.+ !(step.args.length === 1 && STANDALONE_FLAGS.has(step.args[0]))+ ) {+ const word = commandWord(step.args);+ found.push({+ at: source.indexOf(token),+ written: token,+ code: 'doc_token',+ fix:+ word === ''+ ? `This token names no Astryx command: write the command first, then its flags; the commands are ${CLI_COMMANDS.join(', ')}`+ : `\`${word}\` is not an Astryx command; the commands are ${CLI_COMMANDS.join(', ')}`,+ });+ }+ }+ // A sample in another language has tokens of its own, such as TSDoc's+ // `{@inheritDoc}`: only prose and shell blocks are read for doc tokens.+ const readsTokens = lang == null || SHELL_LANGS.has(lang.toLowerCase());+ // An unclosed doc token prints as written in any block: only the three+ // doc token names are looked for, so another language's tags never match.+ for (const opening of unclosedTokensIn(source)) {+ found.push({+ at: source.indexOf(opening),+ written: opening,+ code: 'doc_token',+ fix: 'This token never closes, so it prints as written: end it with `}`, and close any quote inside it',+ });+ }+ for (const token of readsTokens ? unknownTokensIn(source) : []) {+ found.push({+ at: source.indexOf(token),+ written: token,+ code: 'doc_token',+ fix: 'Doc tokens are `{@link}`, `{@command}`, `{@pm}` and `{@pm-only}`; write `{@@…}` to show a token as written',+ });+ }+ return found.sort((a, b) => a.at - b.at);+}++/**+ * The doc-syntax findings in a package's topics, each placed on the file line+ * that holds it.** @param {{records: {name: string, path: string}[], guides?: {name: string, ref?: {topicFile?: string}}[]}} discovered* the package's docs, as discoverIntegrationDocs returns them* @returns {Promise<RunnerCommand[]>}*/-export async function findRunnerCommands(discovered) {+export async function findDocCommands(discovered) {const topics = [...discovered.records.map(record => ({name: record.name,@@ -238,8 +440,8 @@ export async function findRunnerCommands(discovered) {// The doc loaded, so only the line number is lost.}let cursor = {line: 0, column: 0};- for (const {text, section} of allStrings(doc)) {- const commands = runnerCommandsIn(text);+ for (const {text, section, lang} of allStrings(doc)) {+ const commands = docCommandsIn(text, lang);if (commands.length === 0) continue;// A one-line string's own literal places it, wherever the walk reached// it (a section in a constant above the doc object, say); else the@@ -261,7 +463,7 @@ export async function findRunnerCommands(discovered) {after >= 0 || text.includes('\n') ? after : lines.findIndex(holds);const column = after >= 0 && after === cursor.line ? cursor.column : 0;let from = literal >= 0 ? {line: literal, column} : cursor;- for (const {written, bare, download} of commands) {+ for (const {written, code, fix} of commands) {const place = locate(lines, written, from);if (place) {from = {line: place.line, column: place.column + written.length};@@ -275,20 +477,54 @@ export async function findRunnerCommands(discovered) {const line = place ? place.line + 1 : null;const where = section ? ` (section "${section}")` : '';found.push({+ code,topic: name,section,file,line,command: written,- message:- `"${name}"${where} writes \`${written}\`${line == null ? '' : ` (line ${line})`}. ` +- `Write \`${bare}\`; the CLI shows it with your project's runner` +- (download- ? ', and a download runner with the bare name fetches an unrelated package called astryx.'- : '.'),+ message: `"${name}"${where} writes \`${written}\`${line == null ? '' : ` (line ${line})`}. ${fix}`,});}}}return found;}++/**+ * Runner commands in a package's topics: the `runner_command` findings of+ * {@link findDocCommands}.+ *+ * @param {Parameters<typeof findDocCommands>[0]} discovered+ * @returns {Promise<RunnerCommand[]>}+ */+export async function findRunnerCommands(discovered) {+ return (await findDocCommands(discovered)).filter(+ each => each.code === 'runner_command',+ );+}++/** Flags the CLI answers on their own, with no command. */+const STANDALONE_FLAGS = new Set(['--version', '-V', '--help', '-h']);++/** The CLI's global flags that take a value (`--detail full`). */+const VALUED_GLOBAL_FLAGS = new Set(['--detail', '--lang']);++/**+ * The word a `{@command}` token names as its command: the first word that is+ * not a global flag or the value of one (`--json component Button`,+ * `--detail full docs acme`).+ * @param {string[]} args+ * @returns {string}+ */+function commandWord(args) {+ for (let i = 0; i < args.length; i++) {+ const arg = args[i];+ if (VALUED_GLOBAL_FLAGS.has(arg)) {+ i++;+ continue;+ }+ if (!arg.startsWith('-')) return arg;+ }+ return '';+}diff --git a/packages/cli/foundation/discovery/stray-pointers.mjs b/packages/cli/foundation/discovery/stray-pointers.mjsindex 669d6e8c42..be88fde4a2 100644--- a/packages/cli/foundation/discovery/stray-pointers.mjs+++ b/packages/cli/foundation/discovery/stray-pointers.mjs@@ -2,7 +2,8 @@/*** @file Stray doc pointers (architecture:cli-surface DEC-8): a code span in- * prose that is exactly `astryx docs <name>` for a doc that exists. The doc's+ * prose that is exactly `astryx docs <name>`, or its `{@command docs <name>}`+ * token, for a doc that exists. The doc's* `{@link}` prints the command that opens the doc and is checked by doctor's* link check, so a written command is a pointer nothing checks.*@@ -28,7 +29,8 @@ import {* more words, a flag, or a route is a walkthrough, not a pointer. A name holds* what a topic name may (letters, digits, `_` and `-`), never opening with `-`.*/-const POINTER = /`astryx docs ([A-Za-z0-9_][A-Za-z0-9_-]*)`/g;+const POINTER =+ /`astryx docs ([A-Za-z0-9_][A-Za-z0-9_-]*)`|`?\{@command docs ([A-Za-z0-9_][A-Za-z0-9_-]*)\}`?/g;/** @type {Promise<Map<string, string>> | undefined} */let coreKinds;@@ -126,7 +128,7 @@ export function linkableStrings(doc) {* @returns {string[]} the doc name each one points at*/export function pointersIn(text) {- return [...text.matchAll(POINTER)].map(match => match[1]);+ return [...text.matchAll(POINTER)].map(match => match[1] ?? match[2]);}/**@@ -253,10 +255,14 @@ export async function findStrayPointers(discovered) {const index = locateString(lines, source, text, words, cursor);if (index >= 0) cursor = index + words.length;for (const match of text.matchAll(POINTER)) {- const target = match[1];+ const target = match[1] ?? match[2];const link = linkFor(target);if (!link) continue;- const command = `astryx docs ${target}`;+ // As written: the bare command, or its `{@command}` token.+ const command =+ match[1] != null+ ? `astryx docs ${target}`+ : match[0].replace(/`/g, '');const line =index < 0? nulldiff --git a/packages/cli/foundation/discovery/stray-pointers.test.mjs b/packages/cli/foundation/discovery/stray-pointers.test.mjsindex 12432ab348..20a44eed1c 100644--- a/packages/cli/foundation/discovery/stray-pointers.test.mjs+++ b/packages/cli/foundation/discovery/stray-pointers.test.mjs@@ -21,6 +21,12 @@ describe('pointersIn', () => {).toEqual([]);});+ it('finds the {@command docs <name>} token too, with or without ticks', () => {+ expect(+ pointersIn('Read {@command docs theme}, then `{@command docs layout}`.'),+ ).toEqual(['theme', 'layout']);+ });+it('leaves the bare name and a runner-written command alone', () => {expect(pointersIn('See astryx docs theme, or `pnpm astryx docs theme`.'),diff --git a/packages/cli/foundation/doc-compiler/doc-syntax.mjs b/packages/cli/foundation/doc-compiler/doc-syntax.mjsnew file mode 100644index 0000000000..4cea0ce348--- /dev/null+++ b/packages/cli/foundation/doc-compiler/doc-syntax.mjs@@ -0,0 +1,739 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file The doc syntax for commands a reader runs: `{@command …}` for an+ * Astryx command, `{@pm …}` for a package-manager step, `{@pm-only <manager>+ * "<reason>" …}` for a step only one package manager can do, and `{@@…}` to+ * show a token as written. Each token is rendered for the reader: an Astryx+ * command with the reader's runner, a package-manager step in the reader's+ * package manager.+ *+ * @input Doc text, the reader's CLI invocation and package manager.+ * @output The text with each token rendered; each token's parse, for doctor;+ * the token a plain-text command should be written as, for doctor's fix.+ * @position foundation/doc-compiler — pure; the env lookup lives in+ * foundation/env/package-manager.mjs.+ */++/**+ * The package managers a `{@pm}` token renders for. `yarn-classic` is Yarn 1;+ * `yarn` is Yarn 2 and newer.+ * @typedef {'npm' | 'pnpm' | 'yarn' | 'yarn-classic' | 'bun'} DocPackageManager+ */++/** Every package manager a token renders for, in the order docs list them. */+export const DOC_PACKAGE_MANAGERS = /** @type {const} */ ([+ 'npm',+ 'pnpm',+ 'yarn',+ 'yarn-classic',+ 'bun',+]);++/** The binary each package manager runs as. */+const BINARY = {+ npm: 'npm',+ pnpm: 'pnpm',+ yarn: 'yarn',+ 'yarn-classic': 'yarn',+ bun: 'bun',+};++/** The verbs `{@pm}` takes, each portable across every package manager. */+export const PM_VERBS = /** @type {const} */ ([+ 'install',+ 'remove',+ 'update',+ 'run',+ 'exec',+ 'dlx',+ 'create',+]);++/** The flags `{@pm}` takes, and the verbs each applies to. */+export const PM_FLAGS = {+ '--dev': ['install'],+ '--exact': ['install'],+ '--global': ['install', 'remove'],+ '--latest': ['update'],+};++/**+ * A token: `{@name body}`, or one written with more `@`s, which shows with one+ * `@` fewer (`{@@pm …}` shows as `{@pm …}`). The body may hold quoted text+ * and balanced braces (`pkg set 'exports={}'`), but never a line break or a+ * backtick: a token sits on one line of one code span or block, and one that+ * does not is an unclosed opening doctor names.+ */+const TOKEN =+ /\{@(@*)([a-z][\w-]*)(?:[ \t]+((?:'[^'\n`]*'|"[^"\n`]*"|\{[^{}\n`]*\}|[^{}'"\n`])*?))?[ \t]*\}/g;++/** The token names this module renders (`{@link}` resolves elsewhere). */+const COMMAND_TOKENS = new Set(['command', 'pm', 'pm-only']);++/** A version range: anything after `@` that is not one exact version. */+const RANGE = /[\^~<>*| ]|(?:^|\.)x(?:\.|$)|^latest$|^next$/i;++/**+ * Split a token body into words, keeping a double-quoted run as one word.+ * @param {string} body+ * @returns {string[]}+ */+export function splitWords(body) {+ const words = [];+ const pattern = /"([^"]*)"|(\S+)/g;+ for (const match of String(body).matchAll(pattern)) {+ words.push(match[1] !== undefined ? `"${match[1]}"` : match[2]);+ }+ return words;+}++/**+ * @typedef {object} PmStep+ * @property {'pm'} kind+ * @property {typeof PM_VERBS[number]} verb+ * @property {string[]} args packages, a script or binary and its arguments+ * @property {Set<string>} flags+ */++/**+ * @typedef {object} PmOnlyStep+ * @property {'pm-only'} kind+ * @property {DocPackageManager} manager+ * @property {string} reason+ * @property {string[]} args the command after the manager's name+ */++/**+ * @typedef {object} CliStep+ * @property {'command'} kind+ * @property {string[]} args the command after `astryx`+ */++/**+ * @typedef {PmStep | PmOnlyStep | CliStep} DocStep+ */++/**+ * Read one token. Returns the step, or `{error}` saying what is wrong and how+ * to write it.+ * @param {string} name the token name, `pm` in `{@pm install x}`+ * @param {string} body what follows the name+ * @returns {DocStep | {error: string}}+ */+export function parseCommandToken(name, body = '') {+ const words = splitWords(body);+ if (name === 'command') {+ if (words.length === 0) {+ return {error: '`{@command}` needs a command: `{@command docs theme}`'};+ }+ if (words[0] === 'astryx') {+ return {+ error: `\`{@command}\` takes the command without \`astryx\`: \`{@command ${words.slice(1).join(' ')}}\``,+ };+ }+ return {kind: 'command', args: words};+ }+ if (name === 'pm-only') {+ const [manager, reason, ...args] = words;+ if (!DOC_PACKAGE_MANAGERS.includes(/** @type {any} */ (manager))) {+ return {+ error: `\`{@pm-only}\` starts with the package manager, one of ${DOC_PACKAGE_MANAGERS.join(', ')}: \`{@pm-only npm "<why only npm>" pkg set name=x}\``,+ };+ }+ if (!reason || !/^".+"$/.test(reason)) {+ return {+ error: `\`{@pm-only ${manager}}\` needs a reason in double quotes after the package manager, which readers see: \`{@pm-only ${manager} "<why only ${manager}>" ${args.join(' ') || '<command>'}}\``,+ };+ }+ if (args.length === 0) {+ return {error: `\`{@pm-only ${manager} ${reason}}\` needs a command`};+ }+ return {+ kind: 'pm-only',+ manager: /** @type {DocPackageManager} */ (manager),+ reason: reason.slice(1, -1),+ args,+ };+ }+ if (name === 'pm') {+ const [verb, ...rest] = words;+ if (!PM_VERBS.includes(/** @type {any} */ (verb))) {+ return {+ error: `\`{@pm}\` starts with a verb, one of ${PM_VERBS.join(', ')}: \`{@pm install @acme/widgets}\``,+ };+ }+ const flags = new Set();+ const args = [];+ for (const word of rest) {+ if (+ word.startsWith('--') &&+ word in PM_FLAGS &&+ verb !== 'run' &&+ verb !== 'exec' &&+ verb !== 'dlx'+ ) {+ const allowed = /** @type {Record<string, readonly string[]>} */ (+ PM_FLAGS+ )[word];+ if (!allowed.includes(verb)) {+ return {+ error: `\`${word}\` applies to ${allowed.map(each => `\`{@pm ${each}}\``).join(' and ')}, not \`{@pm ${verb}}\``,+ };+ }+ flags.add(word);+ } else if (+ word.startsWith('-') &&+ verb !== 'run' &&+ verb !== 'exec' &&+ verb !== 'dlx' &&+ verb !== 'create'+ ) {+ return {+ error: `\`{@pm ${verb}}\` takes the flags ${+ Object.keys(PM_FLAGS)+ .filter(flag =>+ /** @type {Record<string, readonly string[]>} */ (PM_FLAGS)[+ flag+ ].includes(verb),+ )+ .join(', ') || 'none'+ }, not \`${word}\`, so it reads the same in every package manager`,+ };+ } else {+ args.push(word);+ }+ }+ if (['run', 'exec', 'dlx', 'create'].includes(verb) && args.length === 0) {+ return {+ error: `\`{@pm ${verb}}\` needs a name: \`{@pm ${verb} <name>}\``,+ };+ }+ if (verb === 'remove' && args.length === 0) {+ return {error: '`{@pm remove}` needs a package'};+ }+ if (flags.has('--exact')) {+ const ranged = args.find(arg => {+ const at = arg.lastIndexOf('@');+ return at > 0 && RANGE.test(arg.slice(at + 1));+ });+ if (ranged) {+ return {+ error: `\`--exact\` with a range (\`${ranged}\`) keeps the range in every package manager but npm: write one version, or drop \`--exact\``,+ };+ }+ }+ if (flags.has('--latest') && args.length === 0) {+ return {error: '`{@pm update --latest}` needs the packages to move'};+ }+ return {+ kind: 'pm',+ verb: /** @type {PmStep['verb']} */ (verb),+ args,+ flags,+ };+ }+ return {error: `\`{@${name}}\` is not a doc token`};+}++/**+ * The command a package-manager step runs in one package manager.+ * @param {PmStep} step+ * @param {DocPackageManager} pm+ * @returns {string}+ */+export function renderPmStep(step, pm) {+ const {verb, args, flags} = step;+ const join = (/** @type {Array<string | string[]>} */ ...parts) =>+ parts.flat().filter(Boolean).join(' ');+ const global = flags.has('--global');+ // Yarn 2 and newer has no global install: npm, which every Node carries.+ const manager = global && pm === 'yarn' ? 'npm' : pm;+ switch (verb) {+ case 'install': {+ if (args.length === 0 && !global) return join(BINARY[manager], 'install');+ const dev = flags.has('--dev') ? (manager === 'bun' ? '-d' : '-D') : '';+ const exact = flags.has('--exact')+ ? manager === 'bun'+ ? '--exact'+ : '-E'+ : '';+ if (global) {+ return {+ npm: join('npm install -g', exact, args),+ pnpm: join('pnpm add -g', exact, args),+ yarn: join('npm install -g', exact, args),+ 'yarn-classic': join('yarn global add', exact, args),+ bun: join('bun add -g', exact, args),+ }[manager];+ }+ const add = manager === 'npm' ? 'npm install' : `${BINARY[manager]} add`;+ return join(add, dev, exact, args);+ }+ case 'remove': {+ if (global) {+ return {+ npm: join('npm uninstall -g', args),+ pnpm: join('pnpm remove -g', args),+ yarn: join('npm uninstall -g', args),+ 'yarn-classic': join('yarn global remove', args),+ bun: join('bun remove -g', args),+ }[manager];+ }+ return join(+ manager === 'npm' ? 'npm uninstall' : `${BINARY[manager]} remove`,+ args,+ );+ }+ case 'update': {+ if (flags.has('--latest')) {+ return {+ npm: join(+ 'npm install',+ args.map(arg => `${arg}@latest`),+ ),+ pnpm: join('pnpm update --latest', args),+ yarn: join('yarn up', args),+ 'yarn-classic': join('yarn upgrade --latest', args),+ bun: join('bun update --latest', args),+ }[pm];+ }+ return {+ npm: join('npm update', args),+ pnpm: join('pnpm update', args),+ // `yarn up` moves to the newest release; -R stays in the range.+ yarn: join('yarn up -R', args),+ 'yarn-classic': join('yarn upgrade', args),+ bun: join('bun update', args),+ }[pm];+ }+ case 'run': {+ const [script, ...rest] = args;+ // npm passes arguments to a script after `--`; pnpm and Yarn 2 pass a+ // `--` on to the script itself, so only npm writes one.+ if (pm === 'npm') {+ return join('npm run', script, rest.length > 0 ? ['--', ...rest] : []);+ }+ return join(BINARY[pm], 'run', script, rest);+ }+ case 'exec':+ return join(+ {+ npm: 'npx',+ pnpm: 'pnpm exec',+ yarn: 'yarn run',+ 'yarn-classic': 'yarn run',+ bun: 'bunx',+ }[pm],+ args,+ );+ case 'dlx':+ return join(+ {+ npm: 'npx',+ pnpm: 'pnpm dlx',+ yarn: 'yarn dlx',+ // Yarn 1 has no dlx: npx, which every Node carries.+ 'yarn-classic': 'npx',+ bun: 'bunx',+ }[pm],+ args,+ );+ case 'create': {+ // npm passes flags to the initializer only after `--`.+ const flagAt = args.findIndex(arg => arg.startsWith('-'));+ if (pm === 'npm' && flagAt > 0) {+ return join('npm create', [+ ...args.slice(0, flagAt),+ '--',+ ...args.slice(flagAt),+ ]);+ }+ return join(BINARY[pm], 'create', args);+ }+ default:+ return join(BINARY[pm], verb, args);+ }+}++/**+ * @typedef {object} RenderOptions+ * @property {string} stem how the reader runs the CLI, e.g. `pnpm exec astryx`+ * @property {DocPackageManager} pm the reader's package manager+ */++/**+ * One step as the reader runs it, and, for a one-manager step, the line+ * readers see beside it.+ * @param {DocStep} step+ * @param {RenderOptions} options+ * @returns {{command: string, note: string | null}}+ */+export function renderStep(step, {stem, pm}) {+ if (step.kind === 'command') {+ return {command: [stem, ...step.args].join(' '), note: null};+ }+ if (step.kind === 'pm-only') {+ return {+ command: [BINARY[step.manager], ...step.args].join(' '),+ note: `only with ${managerName(step.manager)}: ${step.reason}`,+ };+ }+ return {command: renderPmStep(step, pm), note: null};+}++/**+ * A package manager's name as readers read it.+ * @param {DocPackageManager} pm+ * @returns {string}+ */+export function managerName(pm) {+ return {+ npm: 'npm',+ pnpm: 'pnpm',+ yarn: 'Yarn',+ 'yarn-classic': 'Yarn 1',+ bun: 'Bun',+ }[pm];+}++/** Code-fence languages whose lines are shell commands. */+const SHELL_LANGS = new Set(['', 'bash', 'sh', 'shell', 'zsh', 'console']);++/**+ * Text with each `{@command}`, `{@pm}` and `{@pm-only}` token rendered for the+ * reader, and each `{@@…}` shown as `{@…}`. A token in prose prints as a code+ * span; in a code span or code block, as the bare command. A one-manager+ * step's reason follows it: in prose right after the command, after a code+ * span, in parentheses; in a shell block as a comment. A Markdown fence in+ * prose is a code block in its language. A token that does not parse prints+ * as written, and doctor names it.+ * @param {string} text+ * @param {RenderOptions} options+ * @param {string | null} [lang] the code block's language when `text` is one+ * block's body; omit for prose+ * @returns {string}+ */+export function renderCommandTokens(text, options, lang = null) {+ const source = String(text);+ if (!source.includes('{@')) return source;+ const inBlock = lang != null;+ const shell = inBlock && SHELL_LANGS.has(lang.toLowerCase());+ /**+ * @param {string} part+ * @param {string[]} notes where a one-manager step's reason goes+ * @param {boolean} wrap print a rendered command as a code span+ */+ const render = (part, notes, wrap) =>+ part.replace(TOKEN, (whole, escaped, name, body = '') => {+ if (escaped) return whole.replace('{@@', '{@');+ if (!COMMAND_TOKENS.has(name)) return whole;+ const step = parseCommandToken(name, body);+ if ('error' in step) return whole;+ const {command, note} = renderStep(step, options);+ // In prose the reason follows its own command, inside the sentence.+ if (note != null && wrap) return `\`${command}\` (${note})`;+ if (note != null) notes.push(note);+ return wrap ? `\`${command}\`` : command;+ });+ if (inBlock) {+ return source+ .split('\n')+ .map(line => {+ /** @type {string[]} */+ const notes = [];+ const out = render(line, notes, false);+ if (notes.length === 0) return out;+ return shell+ ? `${out} # ${notes.join('; ')}`+ : `${out} (${notes.join('; ')})`;+ })+ .join('\n');+ }+ /** @param {string} line */+ const prose = line =>+ line+ .split(/(`[^`\n]*`)/)+ .map(part => {+ /** @type {string[]} */+ const notes = [];+ const isSpan =+ part.length > 1 && part.startsWith('`') && part.endsWith('`');+ const out = render(part, notes, !isSpan);+ return notes.length === 0 ? out : `${out} (${notes.join('; ')})`;+ })+ .join('');+ // A fence inside prose is a code block: its lines render as one, in the+ // fence's language.+ /** @type {{marker: string, lang: string} | null} */+ let fence = null;+ return source+ .split('\n')+ .map(line => {+ const marker = /^\s*(`{3,}|~{3,})\s*([\w-]*)/.exec(line);+ if (marker) {+ if (fence == null) {+ fence = {marker: marker[1], lang: marker[2].toLowerCase()};+ } else if (marker[1].startsWith(fence.marker)) {+ fence = null;+ }+ return line;+ }+ return fence == null+ ? prose(line)+ : renderCommandTokens(line, options, fence.lang);+ })+ .join('\n');+}++/**+ * Every command token in a text, with its parse, for doctor.+ * @param {string} text+ * @returns {Array<{token: string, name: string, step: DocStep | {error: string}}>}+ */+export function commandTokensIn(text) {+ const found = [];+ for (const match of String(text).matchAll(TOKEN)) {+ if (match[1] || !COMMAND_TOKENS.has(match[2])) continue;+ found.push({+ token: match[0],+ name: match[2],+ step: parseCommandToken(match[2], match[3] ?? ''),+ });+ }+ return found;+}++/** The token names a doc may write: these and `{@link}`. */+export const DOC_TOKEN_NAMES = new Set([...COMMAND_TOKENS, 'link']);++/**+ * Every `{@name …}` whose name is not a doc token, for doctor.+ * @param {string} text+ * @returns {string[]}+ */+export function unknownTokensIn(text) {+ const found = [];+ for (const match of String(text).matchAll(TOKEN)) {+ if (!match[1] && !DOC_TOKEN_NAMES.has(match[2])) found.push(match[0]);+ }+ return found;+}++/**+ * Each `{@command`, `{@pm` or `{@pm-only` opening (escaped with more `@`s+ * too) that no whole token starts at: one with no closing brace, or with a+ * quote it never closes. It prints as written, so doctor names it.+ * @param {string} text+ * @returns {string[]} the opening and the rest of its line+ */+export function unclosedTokensIn(text) {+ const source = String(text);+ const starts = new Set(+ [...source.matchAll(TOKEN)].map(+ match => /** @type {number} */ (match.index),+ ),+ );+ const found = [];+ for (const match of source.matchAll(/\{@@*(?:command|pm-only|pm)\b/g)) {+ const at = /** @type {number} */ (match.index);+ if (starts.has(at)) continue;+ const end = source.indexOf('\n', at);+ found.push(source.slice(at, end < 0 ? undefined : end).slice(0, 80));+ }+ return found;+}++/** Package-manager binaries a plain-text command may start with. */+const PM_BINARIES = new Set(['npm', 'npx', 'pnpm', 'yarn', 'bun', 'bunx']);++/**+ * The token a plain-text package-manager command should be written as, for+ * doctor's fix: `{@pm …}` when every package manager can run it, `{@pm-only+ * <manager> "<why>" …}` when only that one can, or null when the text is not+ * a package-manager command. A runner in front of `astryx` is an Astryx+ * command: `{@command …}`.+ * @param {string} command one command, such as `npm install -D @acme/x`+ * @returns {string | null}+ */+export function tokenForCommand(command) {+ const words = String(command).trim().split(/\s+/);+ const [bin, ...rest] = words;+ if (bin === 'astryx')+ return `{@command ${rest.join(' ')}}`.replace(' }', '}');+ if (!PM_BINARIES.has(bin)) return null;+ // A runner in front of astryx.+ const astryxAt = rest.indexOf('astryx');+ const runnerWords =+ bin === 'npx' || bin === 'bunx'+ ? 0+ : bin === 'pnpm' && (rest[0] === 'exec' || rest[0] === 'dlx')+ ? 1+ : bin === 'yarn' &&+ (rest[0] === 'run' || rest[0] === 'dlx' || rest[0] === 'exec')+ ? 1+ : bin === 'npm' && (rest[0] === 'exec' || rest[0] === 'x')+ ? 1+ : bin === 'bun' && rest[0] === 'x'+ ? 1+ : 0;+ if (+ astryxAt === runnerWords ||+ (astryxAt >= 0 &&+ rest.slice(runnerWords, astryxAt).every(w => w.startsWith('-')))+ ) {+ const after = rest.slice(astryxAt + 1).filter(w => w !== '--');+ return after.length > 0 ? `{@command ${after.join(' ')}}` : null;+ }+ if (bin === 'npm' && rest[0] === 'run' && rest[1] === 'astryx') {+ const after = rest.slice(2).filter(w => w !== '--');+ return after.length > 0 ? `{@command ${after.join(' ')}}` : null;+ }+ const flags = [];+ const args = [];+ const pmOnly = (/** @type {string} */ manager) =>+ `{@pm-only ${manager} "<why only ${manager}>" ${rest.join(' ')}}`;+ if (bin === 'npx' || bin === 'bunx') {+ const plain = rest.filter(w => w !== '-y' && w !== '--yes');+ // npx runs the project's own binary when it has one: an unscoped,+ // unversioned name such as `tsc` is that, so it is `exec`. A scoped or+ // versioned package, or `--yes`, downloads one: `dlx`.+ const target = plain.find(w => !w.startsWith('-')) ?? '';+ const downloads =+ plain.length < rest.length ||+ target.startsWith('@') ||+ /^[^@]+@/.test(target);+ return `{@pm ${downloads ? 'dlx' : 'exec'} ${plain.join(' ')}}`;+ }+ let verb = rest[0];+ let tail = rest.slice(1);+ if (bin === 'yarn' && verb === 'global') {+ if (tail[0] === 'add' || tail[0] === 'remove') {+ flags.push('--global');+ verb = tail[0];+ tail = tail.slice(1);+ } else {+ return pmOnly('yarn-classic');+ }+ }+ if (verb === undefined) return '{@pm install}';+ const VERBS = {+ install: 'install',+ i: 'install',+ add: 'install',+ uninstall: 'remove',+ un: 'remove',+ rm: 'remove',+ remove: 'remove',+ update: 'update',+ up: 'update',+ upgrade: 'update',+ run: 'run',+ 'run-script': 'run',+ exec: 'exec',+ dlx: 'dlx',+ create: 'create',+ x: 'exec',+ };+ const mapped = /** @type {Record<string, string>} */ (VERBS)[verb];+ // npm's script shortcuts run a script every package manager can run.+ if (+ !mapped &&+ bin === 'npm' &&+ ['test', 'start', 'stop', 'restart'].includes(verb)+ ) {+ // The token puts npm's `--` back itself, as for `run`.+ return `{@pm run ${[verb, ...tail.filter(word => word !== '--')].join(' ')}}`;+ }+ if (!mapped) {+ // `pnpm build`, `yarn test`: a script run without `run`.+ if (+ bin !== 'npm' &&+ bin !== 'bun' &&+ /^[\w:.-]+$/.test(verb) &&+ !NPM_TOOLS.has(verb)+ ) {+ return `{@pm run ${[verb, ...tail].join(' ')}}`;+ }+ return pmOnly(bin === 'yarn' ? 'yarn' : /** @type {string} */ (bin));+ }+ // A script, a binary or an initializer takes every word after it as its+ // own, flags included; the token puts back any `--` npm needs.+ const passesThrough = ['run', 'exec', 'dlx', 'create'].includes(mapped);+ for (const word of tail) {+ if (passesThrough) {+ if (word !== '--') args.push(word);+ continue;+ }+ if (['-D', '-d', '--save-dev', '--dev', '-DE', '-ED'].includes(word))+ flags.push('--dev');+ if (['-E', '--exact', '--save-exact', '-DE', '-ED'].includes(word))+ flags.push('--exact');+ if (['-g', '--global'].includes(word)) flags.push('--global');+ if (word === '--latest' || word === '-L') flags.push('--latest');+ if (!word.startsWith('-')) args.push(word);+ }+ const unique = [...new Set(flags)];+ // A flag no other package manager shares: one manager only.+ const known = new Set([+ '-D',+ '-d',+ '--save-dev',+ '--dev',+ '-E',+ '--exact',+ '--save-exact',+ '-g',+ '--global',+ '--latest',+ '-L',+ '-DE',+ '-ED',+ '--',+ ]);+ if (+ mapped !== 'run' &&+ mapped !== 'exec' &&+ mapped !== 'dlx' &&+ mapped !== 'create' &&+ tail.some(w => w.startsWith('-') && !known.has(w))+ ) {+ return pmOnly(bin === 'yarn' ? 'yarn' : /** @type {string} */ (bin));+ }+ const token = `{@pm ${[mapped, ...args, ...unique].join(' ')}}`;+ const parsed = parseCommandToken(+ 'pm',+ [mapped, ...args, ...unique].join(' '),+ );+ return 'error' in parsed+ ? pmOnly(bin === 'yarn' ? 'yarn' : /** @type {string} */ (bin))+ : token;+}++/** Commands only npm itself runs: `npm pkg`, `npm pack` and the rest. */+const NPM_TOOLS = new Set([+ 'pkg',+ 'pack',+ 'publish',+ 'version',+ 'view',+ 'info',+ 'config',+ 'prefix',+ 'setup',+ 'link',+ 'why',+ 'ls',+ 'list',+ 'outdated',+ 'cache',+ 'init',+ 'dist-tag',+ 'login',+ 'whoami',+ 'audit',+ 'ci',+ 'store',+ 'global',+ 'dedupe',+]);diff --git a/packages/cli/foundation/doc-compiler/doc-syntax.test.mjs b/packages/cli/foundation/doc-compiler/doc-syntax.test.mjsnew file mode 100644index 0000000000..78422c92f5--- /dev/null+++ b/packages/cli/foundation/doc-compiler/doc-syntax.test.mjs@@ -0,0 +1,383 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, expect, it} from 'vitest';++import {+ commandTokensIn,+ DOC_PACKAGE_MANAGERS,+ parseCommandToken,+ renderCommandTokens,+ renderPmStep,+ tokenForCommand,+ unknownTokensIn,+ unclosedTokensIn,+} from './doc-syntax.mjs';++/** @param {string} body */+function pm(body) {+ const step = parseCommandToken('pm', body);+ if ('error' in step) throw new Error(step.error);+ if (step.kind !== 'pm') throw new Error('not a pm step');+ return step;+}++/** @param {string} body */+const everyManager = body =>+ Object.fromEntries(+ DOC_PACKAGE_MANAGERS.map(each => [each, renderPmStep(pm(body), each)]),+ );++describe('renderPmStep', () => {+ // Each row was run on npm 10.9, pnpm 11.10, Yarn 4.18, Yarn 1.22 and Bun+ // 1.4 in a throwaway project, and did what the token says.+ it('adds packages, as dependencies or dev dependencies', () => {+ expect(everyManager('install @acme/x')).toEqual({+ npm: 'npm install @acme/x',+ pnpm: 'pnpm add @acme/x',+ yarn: 'yarn add @acme/x',+ 'yarn-classic': 'yarn add @acme/x',+ bun: 'bun add @acme/x',+ });+ expect(everyManager('install @acme/x --dev')).toEqual({+ npm: 'npm install -D @acme/x',+ pnpm: 'pnpm add -D @acme/x',+ yarn: 'yarn add -D @acme/x',+ 'yarn-classic': 'yarn add -D @acme/x',+ bun: 'bun add -d @acme/x',+ });+ expect(everyManager('install')).toEqual({+ npm: 'npm install',+ pnpm: 'pnpm install',+ yarn: 'yarn install',+ 'yarn-classic': 'yarn install',+ bun: 'bun install',+ });+ });++ it('installs for the computer, with npm where Yarn 2 has no global install', () => {+ expect(everyManager('install @astryxdesign/cli --global')).toEqual({+ npm: 'npm install -g @astryxdesign/cli',+ pnpm: 'pnpm add -g @astryxdesign/cli',+ yarn: 'npm install -g @astryxdesign/cli',+ 'yarn-classic': 'yarn global add @astryxdesign/cli',+ bun: 'bun add -g @astryxdesign/cli',+ });+ expect(everyManager('remove @astryxdesign/cli --global')).toEqual({+ npm: 'npm uninstall -g @astryxdesign/cli',+ pnpm: 'pnpm remove -g @astryxdesign/cli',+ yarn: 'npm uninstall -g @astryxdesign/cli',+ 'yarn-classic': 'yarn global remove @astryxdesign/cli',+ bun: 'bun remove -g @astryxdesign/cli',+ });+ });++ it('passes script arguments with `--` only where the package manager needs it', () => {+ // pnpm and Yarn 2 hand a `--` on to the script; npm needs one.+ expect(everyManager('run build --watch')).toEqual({+ npm: 'npm run build -- --watch',+ pnpm: 'pnpm run build --watch',+ yarn: 'yarn run build --watch',+ 'yarn-classic': 'yarn run build --watch',+ bun: 'bun run build --watch',+ });+ });++ it('runs an installed binary, and a package without installing it', () => {+ expect(everyManager('exec tsc --noEmit')).toEqual({+ npm: 'npx tsc --noEmit',+ pnpm: 'pnpm exec tsc --noEmit',+ yarn: 'yarn run tsc --noEmit',+ 'yarn-classic': 'yarn run tsc --noEmit',+ bun: 'bunx tsc --noEmit',+ });+ expect(everyManager('dlx @astryxdesign/cli init')).toEqual({+ npm: 'npx @astryxdesign/cli init',+ pnpm: 'pnpm dlx @astryxdesign/cli init',+ yarn: 'yarn dlx @astryxdesign/cli init',+ 'yarn-classic': 'npx @astryxdesign/cli init',+ bun: 'bunx @astryxdesign/cli init',+ });+ });++ it('updates packages, to the latest release when asked', () => {+ expect(everyManager('update @acme/x --latest')).toEqual({+ npm: 'npm install @acme/x@latest',+ pnpm: 'pnpm update --latest @acme/x',+ yarn: 'yarn up @acme/x',+ 'yarn-classic': 'yarn upgrade --latest @acme/x',+ bun: 'bun update --latest @acme/x',+ });+ });++ it('updates within the declared range unless asked for the latest', () => {+ expect(everyManager('update @acme/x')).toEqual({+ npm: 'npm update @acme/x',+ pnpm: 'pnpm update @acme/x',+ yarn: 'yarn up -R @acme/x',+ 'yarn-classic': 'yarn upgrade @acme/x',+ bun: 'bun update @acme/x',+ });+ });++ it('passes an initializer its flags, after `--` on npm', () => {+ expect(everyManager('create vite my-app --template react')).toEqual({+ npm: 'npm create vite my-app -- --template react',+ pnpm: 'pnpm create vite my-app --template react',+ yarn: 'yarn create vite my-app --template react',+ 'yarn-classic': 'yarn create vite my-app --template react',+ bun: 'bun create vite my-app --template react',+ });+ });+});++describe('a token whose body holds braces or quotes', () => {+ it('renders and is found by doctor', () => {+ const text =+ 'Run {@pm-only npm "edits package.json" pkg set \'exports={}\' --json} first.';+ expect(renderCommandTokens(text, {stem: 'astryx', pm: 'pnpm'})).toBe(+ "Run `npm pkg set 'exports={}' --json` (only with npm: edits package.json) first.",+ );+ expect(commandTokensIn(text).map(each => each.name)).toEqual(['pm-only']);+ });+});++describe('the token for a script, binary or initializer', () => {+ it('keeps every word after the name, flags included', () => {+ expect(tokenForCommand('pnpm exec tsc --noEmit')).toBe(+ '{@pm exec tsc --noEmit}',+ );+ expect(+ tokenForCommand('pnpm dlx create-vite my-app --template react'),+ ).toBe('{@pm dlx create-vite my-app --template react}');+ expect(tokenForCommand('pnpm run build -d')).toBe('{@pm run build -d}');+ expect(tokenForCommand('npm run test -- -g smoke')).toBe(+ '{@pm run test -g smoke}',+ );+ });+});++describe('npm script shortcuts', () => {+ it('suggest {@pm run …}, which every package manager runs', () => {+ expect(tokenForCommand('npm test')).toBe('{@pm run test}');+ expect(tokenForCommand('npm start -- --port 3000')).toBe(+ '{@pm run start --port 3000}',+ );+ expect(tokenForCommand('npm test -- --watch')).toBe(+ '{@pm run test --watch}',+ );+ expect(tokenForCommand('npm run-script build')).toBe('{@pm run build}');+ });+});++describe('a token that never closes', () => {+ it('counts a token broken across lines, or holding a backtick, as unclosed', () => {+ expect(+ unclosedTokensIn(+ '{@command theme palette generate palette.config.json \\\n --out src/acme.palette.ts}',+ ),+ ).toEqual(['{@command theme palette generate palette.config.json \\']);+ expect(+ unclosedTokensIn(+ 'Run {@pm-only npm "edits `package.json`" pkg set name=acme}.',+ ),+ ).toHaveLength(1);+ });++ it('is found, with the rest of its line', () => {+ expect(+ unclosedTokensIn(+ 'Run {@pm install @acme/widgets --dev and go.\nNext {@command doctor}.',+ ),+ ).toEqual(['{@pm install @acme/widgets --dev and go.']);+ expect(+ unclosedTokensIn('Run {@pm-only npm "never closes pkg set x}.'),+ ).toEqual(['{@pm-only npm "never closes pkg set x}.']);+ });+});++describe('parseCommandToken', () => {+ it('names what is wrong and how to write it', () => {+ expect(parseCommandToken('pm', 'install -D x')).toMatchObject({+ error: expect.stringContaining('--dev'),+ });+ expect(parseCommandToken('pm', 'add x')).toMatchObject({+ error: expect.stringContaining('install'),+ });+ expect(parseCommandToken('pm', 'install x@^1.2.0 --exact')).toMatchObject({+ error: expect.stringContaining('range'),+ });+ expect(parseCommandToken('pm', 'update --latest')).toMatchObject({+ error: expect.stringContaining('packages'),+ });+ expect(parseCommandToken('pm-only', 'npm pkg set name=x')).toMatchObject({+ error: expect.stringContaining('reason'),+ });+ expect(parseCommandToken('pm-only', 'npmx "why" pkg')).toMatchObject({+ error: expect.stringContaining('package manager'),+ });+ expect(parseCommandToken('command', 'astryx docs')).toMatchObject({+ error: expect.stringContaining('{@command docs}'),+ });+ });++ it('reads a one-manager step with its reason', () => {+ expect(+ parseCommandToken(+ 'pm-only',+ 'npm "no other manager has it" pkg set name=x',+ ),+ ).toEqual({+ kind: 'pm-only',+ manager: 'npm',+ reason: 'no other manager has it',+ args: ['pkg', 'set', 'name=x'],+ });+ });+});++describe('renderCommandTokens', () => {+ const reader = {stem: 'pnpm exec astryx', pm: /** @type {const} */ ('pnpm')};++ it('renders each token for the reader, as a code span in prose', () => {+ expect(+ renderCommandTokens(+ 'Add it with {@pm install @acme/x}, then run {@command docs acme}.',+ reader,+ ),+ ).toBe(+ 'Add it with `pnpm add @acme/x`, then run `pnpm exec astryx docs acme`.',+ );+ });++ it('renders a fence inside prose as a code block in its language', () => {+ expect(+ renderCommandTokens(+ [+ 'Install it with {@pm install @acme/fence --dev}:',+ '',+ '```bash',+ '{@pm install @acme/fence --dev}',+ '{@command doctor}',+ '{@pm-only npm "edits package.json" pkg set x=1}',+ '```',+ '',+ '~~~text',+ '{@command doctor}',+ '~~~',+ 'Then {@command doctor}.',+ ].join('\n'),+ reader,+ ),+ ).toBe(+ [+ 'Install it with `pnpm add -D @acme/fence`:',+ '',+ '```bash',+ 'pnpm add -D @acme/fence',+ 'pnpm exec astryx doctor',+ 'npm pkg set x=1 # only with npm: edits package.json',+ '```',+ '',+ '~~~text',+ 'pnpm exec astryx doctor',+ '~~~',+ 'Then `pnpm exec astryx doctor`.',+ ].join('\n'),+ );+ });++ it('renders inside a code span and a code block without extra ticks', () => {+ expect(renderCommandTokens('Run `{@pm run build}`.', reader)).toBe(+ 'Run `pnpm run build`.',+ );+ expect(+ renderCommandTokens(+ '{@pm install}\n{@command integration check --strict}',+ reader,+ 'bash',+ ),+ ).toBe('pnpm install\npnpm exec astryx integration check --strict');+ });++ it('shows a one-manager step with its reason, as a comment in a shell block', () => {+ expect(+ renderCommandTokens(+ '{@pm-only npm "pnpm and Yarn have no pkg" pkg set name=x}',+ reader,+ ),+ ).toBe('`npm pkg set name=x` (only with npm: pnpm and Yarn have no pkg)');+ expect(+ renderCommandTokens(+ '{@pm-only pnpm "once per computer" setup}',+ reader,+ 'sh',+ ),+ ).toBe('pnpm setup # only with pnpm: once per computer');+ });++ it('shows {@@…} as written, and leaves a token that does not parse as it was', () => {+ expect(renderCommandTokens('Write {@@pm install x}.', reader)).toBe(+ 'Write {@pm install x}.',+ );+ expect(+ renderCommandTokens('{@pm add x} and {@link generic:x}', reader),+ ).toBe('{@pm add x} and {@link generic:x}');+ });+});++describe('tokenForCommand', () => {+ it.each([+ [+ 'npm install -D @astryxdesign/cli',+ '{@pm install @astryxdesign/cli --dev}',+ ],+ [+ 'pnpm add -g @astryxdesign/cli',+ '{@pm install @astryxdesign/cli --global}',+ ],+ [+ 'yarn global add @astryxdesign/cli',+ '{@pm install @astryxdesign/cli --global}',+ ],+ [+ 'npm uninstall -g @astryxdesign/cli',+ '{@pm remove @astryxdesign/cli --global}',+ ],+ ['npm install', '{@pm install}'],+ ['yarn typecheck', '{@pm run typecheck}'],+ ['npx tsc --noEmit', '{@pm exec tsc --noEmit}'],+ ['npx @astryxdesign/cli init', '{@pm dlx @astryxdesign/cli init}'],+ ['pnpm exec astryx docs theme', '{@command docs theme}'],+ ['yarn astryx integration verify', '{@command integration verify}'],+ ['npm run astryx -- docs tokens', '{@command docs tokens}'],+ ['astryx docs theme', '{@command docs theme}'],+ ['npm pkg set name=x', '{@pm-only npm "<why only npm>" pkg set name=x}'],+ ['pnpm setup', '{@pm-only pnpm "<why only pnpm>" setup}'],+ ])('%s is written %s', (command, token) => {+ expect(tokenForCommand(command)).toBe(token);+ });++ it('leaves a command that is not a package manager or the CLI', () => {+ expect(tokenForCommand('git status')).toBeNull();+ });++ it('suggests a token that renders back to the command in its own package manager', () => {+ const step = pm('install @astryxdesign/cli --dev');+ expect(renderPmStep(step, 'npm')).toBe('npm install -D @astryxdesign/cli');+ });+});++describe('commandTokensIn and unknownTokensIn', () => {+ it('finds each token with its parse, and names the ones that are not doc tokens', () => {+ const text =+ '{@pm install x} {@command docs} {@pm add y} {@@pm z} {@cmd docs} {@link generic:a}';+ expect(+ commandTokensIn(text).map(each => [each.name, 'error' in each.step]),+ ).toEqual([+ ['pm', false],+ ['command', false],+ ['pm', true],+ ]);+ expect(unknownTokensIn(text)).toEqual(['{@cmd docs}']);+ });+});diff --git a/packages/cli/foundation/doc-compiler/links.mjs b/packages/cli/foundation/doc-compiler/links.mjsindex 5fb08431cb..a23c166b99 100644--- a/packages/cli/foundation/doc-compiler/links.mjs+++ b/packages/cli/foundation/doc-compiler/links.mjs@@ -11,10 +11,17 @@* with the doc's identity, route, title, summary, and command. A reference* block in a topic section also carries the `content` it includes. A link* that names no doc is a problem, never a guess.- * @position Pure. The docs adapter owns the resolver (the project's docs tree- * and topic catalog) and applies this to every read and every doctor check.+ * Doc tokens render here too (renderTokens), so text and JSON carry the+ * same commands.+ * @position Pure, apart from reading which package manager the working+ * directory's project uses, for `{@pm}` tokens. The docs adapter owns the+ * resolver (the project's docs tree and topic catalog) and applies this to+ * every read and every doctor check.*/+import {renderCommandTokens} from './doc-syntax.mjs';+import {docPackageManager} from '../env/package-manager.mjs';+/** The kinds a link can name: every authored doc kind. */export const LINK_KINDS = new Set(['generic',@@ -114,13 +121,13 @@ export function parseLinkTarget(target) {}/**- * Text with each inline link replaced by its name, for indexes that must not- * read the link syntax as words.+ * Text with each inline link replaced by its name and each doc token by its+ * command, for indexes that must not read the syntax as words.* @param {string} text* @returns {string}*/export function unlinkText(text) {- return text+ return String(renderTokens(text)).split(CODE_SPAN).map(part =>part.startsWith('`')@@ -133,6 +140,25 @@ export function unlinkText(text) {.join('');}+/**+ * Text with its doc tokens rendered (doc-syntax.mjs): `{@command …}` as the+ * bare `astryx …` command, which text output then starts with the reader's+ * runner the way it starts every command, and `{@pm …}` in the package+ * manager of the project the CLI runs in. JSON readers get runnable commands,+ * the way they did before docs wrote tokens.+ * @param {unknown} text+ * @param {string | null} [lang] the code block's language for a block's body+ * @returns {any}+ */+export function renderTokens(text, lang = null) {+ if (typeof text !== 'string' || !text.includes('{@')) return text;+ return renderCommandTokens(+ text,+ {stem: 'astryx', pm: docPackageManager(process.cwd())},+ lang,+ );+}+/*** Text with each inline link replaced by the command that opens its doc. A* link written inside code ticks is shown as written: it documents the syntax,@@ -143,7 +169,8 @@ export function unlinkText(text) {* @returns {Promise<any>}*/async function resolveInline(text, find) {- if (typeof text !== 'string' || !text.includes('{@link')) return text;+ if (typeof text !== 'string') return text;+ if (!text.includes('{@link')) return renderTokens(text);let out = '';for (const part of text.split(CODE_SPAN)) {if (part.startsWith('`')) {@@ -160,7 +187,7 @@ async function resolveInline(text, find) {}out += part.slice(last);}- return out;+ return renderTokens(out);}/**@@ -396,6 +423,12 @@ export async function linkBlocks(blocks, resolve, at = {}, include) {content.push({...block, steps});break;}+ case 'code':+ content.push({+ ...block,+ code: renderTokens(block.code, block.lang ?? ''),+ });+ break;case 'collection':problems.push({target: `collection:${block.source?.slot ?? ''}`,diff --git a/packages/cli/foundation/doc-compiler/tree.mjs b/packages/cli/foundation/doc-compiler/tree.mjsindex 07fc58dc3d..68c2dcfa55 100644--- a/packages/cli/foundation/doc-compiler/tree.mjs+++ b/packages/cli/foundation/doc-compiler/tree.mjs@@ -25,6 +25,7 @@ import {routeSegment} from '../discovery/docs-section-key.mjs';import {diagnostic, sortDiagnostics} from './diagnostics.mjs';import {readDocView} from './read.mjs';import {packageSource} from './source.mjs';+import {renderTokens} from './links.mjs';import {createDocId} from '../identity/provider-identity.mjs';import {CLI_PROVIDER_ID} from '../identity/providers.mjs';@@ -955,6 +956,11 @@ export function loadDocsTree({selfDocs = true, fresh = false} = {}) {if (!tree) {tree = loadTreeInputs({selfDocs}).then(inputs => {const result = buildDocsTree(inputs);+ // Tree inputs carry authored summaries; each renders its doc tokens+ // once, here or where the project tree is built.+ for (const node of result.nodes.values()) {+ node.summary = renderTokens(node.summary);+ }return {...result,diagnostics: sortDiagnostics([diff --git a/packages/cli/foundation/env/package-manager.mjs b/packages/cli/foundation/env/package-manager.mjsindex a4fc556f14..56efabe3fb 100644--- a/packages/cli/foundation/env/package-manager.mjs+++ b/packages/cli/foundation/env/package-manager.mjs@@ -12,6 +12,7 @@* a host's door name, come first (see cli-command.mjs).*/+import {AsyncLocalStorage} from 'node:async_hooks';import * as fs from 'node:fs';import * as path from 'node:path';import {cliDoor, declaredCliCommand} from './cli-command.mjs';@@ -637,6 +638,45 @@ export function prefixCliCommands(text, stem, lang = null) {.join('\n');}+/** @type {AsyncLocalStorage<{pm: import('../doc-compiler/doc-syntax.mjs').DocPackageManager}>} */+const docPackageManagerScope = new AsyncLocalStorage();++/**+ * Run `fn` with doc `{@pm}` steps rendered for `pm`, whatever the working+ * directory's project uses: a host that shows docs to readers of every+ * package manager, such as the docsite, picks one.+ * @template T+ * @param {import('../doc-compiler/doc-syntax.mjs').DocPackageManager} pm+ * @param {() => T} fn+ * @returns {T}+ */+export function runWithDocPackageManager(pm, fn) {+ return docPackageManagerScope.run({pm}, fn);+}++/**+ * The package manager a doc's `{@pm}` steps render for, from the project in+ * `targetDir`: npm when nothing is detected, and Yarn 1 told apart from Yarn+ * 2 and newer; the one a host chose with runWithDocPackageManager wins.+ * @param {string} [targetDir]+ * @returns {import('../doc-compiler/doc-syntax.mjs').DocPackageManager}+ */+export function docPackageManager(targetDir) {+ const chosen = docPackageManagerScope.getStore()?.pm;+ if (chosen) return chosen;+ const resolution = explainPackageManager(targetDir);+ switch (resolution.pm) {+ case 'yarn':+ return isYarnClassic(resolution) ? 'yarn-classic' : 'yarn';+ case 'pnpm':+ return 'pnpm';+ case 'bun':+ return 'bun';+ default:+ return 'npm';+ }+}+/*** Quote one argument of a printed command so the shell it is pasted into* passes it on unchanged. Printed commands target a POSIX shell (sh, bash,diff --git a/packages/cli/foundation/integrations/cli-requirement.mjs b/packages/cli/foundation/integrations/cli-requirement.mjsindex cfcac7a595..2b0ed25e17 100644--- a/packages/cli/foundation/integrations/cli-requirement.mjs+++ b/packages/cli/foundation/integrations/cli-requirement.mjs@@ -78,6 +78,13 @@ export const SECTION_IDS_CLI = '0.6.4';*/export const SECTION_POSITION_CLI = '0.7.4';+/**+ * The first stable CLI release that renders doc tokens (`{@command …}`,+ * `{@pm …}`, `{@pm-only …}`) for the reader. Every earlier release prints+ * them as written, so readers see raw tokens.+ */+export const DOC_TOKENS_CLI = '0.7.4';+const VERSION_RE = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;/**@@ -249,6 +256,23 @@ export function sectionPositionCliProblem(pkg) {);}+/**+ * Why a package whose docs write doc tokens would show them raw on an older+ * CLI, or null when its declared CLI range admits only CLIs that render+ * them. Every release before the first that renders them prints a token as+ * written.+ * @param {any} pkg package.json+ * @returns {string | null}+ */+export function docTokensCliProblem(pkg) {+ return cliRangeProblem(+ pkg,+ 'writes doc tokens (`{@command …}`, `{@pm …}` or `{@pm-only …}`) in its docs',+ 'prints each token as written, so readers see raw tokens instead of commands',+ DOC_TOKENS_CLI,+ );+}+/*** Why a package that ships a theme would lose its themes and doc topics on an* older CLI, or null when its declared CLI range admits only CLIs that readdiff --git a/packages/cli/foundation/integrations/cli-requirement.test.mjs b/packages/cli/foundation/integrations/cli-requirement.test.mjsindex 2b35469bd5..793860596a 100644--- a/packages/cli/foundation/integrations/cli-requirement.test.mjs+++ b/packages/cli/foundation/integrations/cli-requirement.test.mjs@@ -9,6 +9,7 @@ import {KEYWORDS_CLI,NAMESPACE_DOCS_CLI,SECTION_IDS_CLI,+ DOC_TOKENS_CLI,TEMPLATE_REPLACES_CLI,cliRangeProblem,componentReplacesCliProblem,@@ -18,6 +19,7 @@ import {keywordsCliProblem,replacesCliProblem,sectionIdsCliProblem,+ docTokensCliProblem,themesCliProblem,withCliPeer,withDocsTreeCli,@@ -162,7 +164,9 @@ describe('template replaces and keywords floors in the shipped docs', () => {])('gives the %s fix the floor the check asks for', (code, floor) => {const row = read('../../assets/docs/tree/troubleshooting.doc.mjs').split('],')- .find(part => part.includes(`${code}:`));+ .find(part => part.includes(`${code}:`))+ // The doc's single-quoted string escapes the command's own quotes.+ ?.replaceAll("\\'", "'");expect(row).toContain(`@astryxdesign/cli=>=${floor}'`);});});@@ -222,7 +226,8 @@ describe('componentReplacesCliProblem', () => {);const row = troubleshooting.split('],')- .find(part => part.includes('`component_replaces_needs_cli`'));+ .find(part => part.includes('`component_replaces_needs_cli`'))+ ?.replaceAll("\\'", "'");expect(row).toContain(`@astryxdesign/cli=>=${COMPONENT_REPLACES_CLI}'`);// Every version that row names is the floor.expect(new Set(row?.match(/\d+\.\d+\.\d+/g))).toEqual(@@ -252,6 +257,18 @@ describe('themesCliProblem and sectionIdsCliProblem', () => {}});+ it('asks for a CLI from 0.7.4 for doc tokens', () => {+ expect(docTokensCliProblem({name: '@acme/kit'})).toContain('writes doc tokens');+ for (const range of ['>=0.7.4', '^0.7.4', '>=0.8.0']) {+ expect(docTokensCliProblem({peerDependencies: {'@astryxdesign/cli': range}})).toBeNull();+ }+ for (const range of ['>=0.6.4', '^0.7.0', '>=0.7.3']) {+ expect(+ docTokensCliProblem({peerDependencies: {'@astryxdesign/cli': range}}),+ ).toContain('admits a stable CLI before 0.7.4');+ }+ });+it('gives replaces and keywords their own floors', () => {// `>=0.6.4` admits published 0.6.4 and 0.6.5, which drop a template that// sets `keywords` but apply one that sets `replaces`.@@ -274,6 +291,7 @@ describe('themesCliProblem and sectionIdsCliProblem', () => {NAMESPACE_DOCS_CLI,THEMES_CLI,SECTION_IDS_CLI,+ DOC_TOKENS_CLI,TEMPLATE_REPLACES_CLI,KEYWORDS_CLI,]) {@@ -322,6 +340,8 @@ describe('every feature check names its CLI floor', () => {sectionIdsCliProblem: '0.6.4',sectionPositionCliProblem: '0.7.4',themesCliProblem: '0.6.4',+ // The release doc tokens ship in.+ docTokensCliProblem: '0.7.4',};it('asks each feature for the CLI release this table names', () => {diff --git a/packages/cli/foundation/response/response-types.doc.mjs b/packages/cli/foundation/response/response-types.doc.mjsindex aec4c91609..f645d77c70 100644--- a/packages/cli/foundation/response/response-types.doc.mjs+++ b/packages/cli/foundation/response/response-types.doc.mjs@@ -338,7 +338,7 @@ export const doc = {{value: 'integration.validate',description:- 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message} information that fails nothing, such as invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. A runner_command note lists each Astryx command a topic writes with a package runner (its file, line and the bare command to write). A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on.',+ 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message, next?} information beside the issues (text output marks a next note [next minor]); a note fails nothing by default, and one with next: true counts as a warning under integration check --next, fails integration check --strict --next, and fails --strict from the next minor release. Notes include invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. For the commands a topic writes, runner_command (written with a package runner), plain_command (written bare), package_manager_command (written for one package manager) and doc_token (a token that does not parse) notes each give the file, line and the token to write. A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on.',},{value: 'integration.template-conflicts',@@ -358,7 +358,7 @@ export const doc = {{value: 'integration.check',description:- 'Every source check of an integration package in one result: validated (false when no integration manifest was found, so nothing was checked), the package name and version, strict, and checks, one entry per check (validate, components, templates, docs), each with check, errors, warnings, skipped, failed, and response, the envelope that check returns on its own. The totals are errors, warnings, and skipped; unchecked counts what the checks could not compare. With --strict, failures lists each warning and each piece of skipped work again as an error, in the issue format the checks use; it is empty without --strict. failed decides the exit code.',+ 'Every source check of an integration package in one result: validated (false when no integration manifest was found, so nothing was checked), the package name and version, strict, next (true with --next), and checks, one entry per check (validate, components, templates, docs), each with check, errors, warnings, skipped, failed, and response, the envelope that check returns on its own. The totals are errors, warnings, and skipped; unchecked counts what the checks could not compare, and upcoming how many of the validate notes carry next: true. With --next those notes count as warnings in the validate row and the totals. With --strict, failures lists each warning and each piece of skipped work again as an error, in the issue format the checks use, and with --strict --next each next note too; it is empty without --strict. failed decides the exit code.',},],};diff --git a/packages/cli/test/doc-tokens-compile.test.mjs b/packages/cli/test/doc-tokens-compile.test.mjsnew file mode 100644index 0000000000..5583acc61d--- /dev/null+++ b/packages/cli/test/doc-tokens-compile.test.mjs@@ -0,0 +1,85 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * Every doc token in Astryx's shipped docs compiles: rendering a doc leaves no+ * `{@command}`, `{@pm}` or `{@pm-only}` token behind except the ones a `{@@…}`+ * escape writes on purpose, and doctor finds no token fault in them.+ */++import * as fs from 'node:fs';+import * as path from 'node:path';+import {describe, expect, it} from 'vitest';+import {renderCommandTokens} from '../foundation/doc-compiler/doc-syntax.mjs';+import {findDocCommands} from '../foundation/discovery/runner-commands.mjs';++const CLI = path.resolve(import.meta.dirname, '..');+const ROOTS = ['assets/docs', 'clients/cli/commands', 'api'];+const TOKEN_LEFT = /\{@(?:command|pm-only|pm)\b/g;+const ESCAPE = /\{@@(?:command|pm-only|pm)\b/g;++/** @param {string} dir @returns {string[]} */+function docFiles(dir) {+ return fs.readdirSync(dir, {withFileTypes: true}).flatMap(entry => {+ const full = path.join(dir, entry.name);+ if (entry.isDirectory()) {+ return entry.name === '__tests__' ? [] : docFiles(full);+ }+ return entry.name.endsWith('.doc.mjs') ? [full] : [];+ });+}++/**+ * Each string in a doc, with the code block language it sits in.+ * @param {unknown} value+ * @param {string | null} lang+ * @returns {Array<{text: string, lang: string | null}>}+ */+function stringsOf(value, lang = null) {+ if (typeof value === 'string') return [{text: value, lang}];+ if (Array.isArray(value)) return value.flatMap(each => stringsOf(each, lang));+ if (value && typeof value === 'object') {+ const record = /** @type {Record<string, unknown>} */ (value);+ const blockLang = record.type === 'code' ? String(record.lang ?? '') : lang;+ return Object.entries(record).flatMap(([key, each]) =>+ stringsOf(each, key === 'code' ? blockLang : lang),+ );+ }+ return [];+}++const files = ROOTS.flatMap(root => docFiles(path.join(CLI, root)));++describe("Astryx's shipped docs", () => {+ it('render with no token left but the escaped examples', async () => {+ /** @type {string[]} */+ const left = [];+ for (const file of files) {+ const module = await import(file);+ for (const {text, lang} of stringsOf(Object.values(module))) {+ const rendered = renderCommandTokens(+ text,+ {stem: 'astryx', pm: 'npm'},+ lang,+ );+ const remaining = (rendered.match(TOKEN_LEFT) ?? []).length;+ const escaped = (text.match(ESCAPE) ?? []).length;+ if (remaining !== escaped) {+ left.push(`${path.relative(CLI, file)}: ${text.slice(0, 120)}`);+ }+ }+ }+ expect(left).toEqual([]);+ }, 120_000);++ it('hold no doc token doctor would report', async () => {+ const found = await findDocCommands({+ records: files.map(file => ({+ name: path.basename(file, '.doc.mjs'),+ path: file,+ })),+ });+ expect(+ found.filter(each => each.code === 'doc_token').map(each => each.message),+ ).toEqual([]);+ }, 120_000);+});diff --git a/packages/cli/test/integration-check-failures.json b/packages/cli/test/integration-check-failures.jsonindex 56652fec0b..907e3a60eb 100644--- a/packages/cli/test/integration-check-failures.json+++ b/packages/cli/test/integration-check-failures.json@@ -30,6 +30,7 @@"default_mismatch","doc_fluff","doc_names_skipped",+ "doc_token","doc_types_skipped","duplicate_doc","duplicate_prop",@@ -64,7 +65,9 @@"not_in_code","not_in_doc","orphan_doc_overlay",+ "package_manager_command","package_not_found",+ "plain_command","prop_drift_skipped","prop_types_skipped","public_imports_skipped",