Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(cli): a written astryx docs <name> pointer to a doc that exists is a warning, with the {@link} to write instead (#7769)

Joeycad9f7b4b56e
diff --git a/.changeset/stray-doc-pointers.md b/.changeset/stray-doc-pointers.md
new file mode 100644
index 0000000000..ee3e971c8f
--- /dev/null
+++ b/.changeset/stray-doc-pointers.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[feat] `astryx doctor integration docs` lists each code span in an integration's prose that is exactly `astryx docs <name>` for a doc that exists, and says which `{@link}` to write instead: `{@link generic:<name>}` for the package's own topic, `{@link @astryxdesign/cli:generic:<name>}` for Core's. The link prints the command that opens the doc, and doctor's link check fails it if the doc goes away. A command with more words, a route, or a code block is not listed. Each is a `stray_doc_pointer` warning, so `astryx integration check --strict` fails on it, and is in the new `strayPointers` field; `doctor integration docs` keeps exit 0. Core's own guides point with links, and a test keeps them that way.
+
+@josephfarina
diff --git a/docs/architecture/cli-surface.md b/docs/architecture/cli-surface.md
index fa4fabca6f..1f2aa2a7a9 100644
--- a/docs/architecture/cli-surface.md
+++ b/docs/architecture/cli-surface.md
@@ -208,13 +208,15 @@ validate` MUST warn on a PascalCase `.tsx` at the top of the components root
reporting each as an error from the same findings the default run reports
(INV32). An item a comparison lists as unchecked,
such as a prop type it cannot read, does not fail `--strict`. `--strict` also
- fails on two exact doc faults the `docs` check finds in prose (DEC-8): a
+ fails on three doc faults the `docs` check finds in prose (DEC-8): a
copied passage, where two topics repeat 10 or more words word for word (a
run of mostly function words, or one that three or more topics share, is not
- a copy), and fluff, a listed padding phrase or a topic whose share of content
- words is under the published floor; it also fails on doc structure a reader
- silently drops: a prop documented twice, an overlay key that names no prop,
- two sections with one key, an overlay beside no topic, and an empty section.
+ a copy); fluff, a listed padding phrase or a topic whose share of content
+ words is under the published floor; and a stray pointer, a code span that is
+ exactly `astryx docs <name>` for a doc that exists, where a `{@link}` to that
+ doc would be checked. It also fails on doc structure a reader silently
+ drops: a prop documented twice, an overlay key that names no prop, two
+ sections with one key, an overlay beside no topic, and an empty section.
Its exit codes and JSON shape are a compatibility
contract for the builds that run it, from the first stable release that
ships `integration check`: from then on, a new check, or a new failure code,
@@ -738,7 +740,7 @@ checked, which `--strict` does not fail. The one exception is the doc-quality
findings of DEC-8.
Rejected: reporting a doubtful item as a warning (`--strict` fails it).
-### DEC-8 — The strict check fails on copied passages and fluff in docs
+### DEC-8 — The strict check fails on copied passages, fluff and stray pointers in docs
**Decider:** `josephfarina`, `2026-10-20`
@@ -755,7 +757,11 @@ key that names no prop, two sections with one key, and an overlay beside no
topic. The phrase
list and the floor are published in the check's docs, and every finding
names the phrase, or the measured density and the floor, so its fix is
-mechanical. Each is a warning, so `integration check --strict` fails on it and
+mechanical. A stray pointer (a code span in prose that is exactly
+`astryx docs <name>` for a doc that exists) is exact as well: the `{@link}`
+that replaces it prints the command that opens the doc, and doctor's link
+check then fails it when the doc goes away. A command with more words, or one
+in a code block, is a walkthrough, not a pointer. Each is a warning, so `integration check --strict` fails on it and
an agent that runs the build fixes it, while `doctor integration docs` keeps
exit 0. `integration check` first ships with these rules, so no build that
passed before can newly fail.
@@ -803,7 +809,7 @@ the destination.
| 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` | 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. |
+| 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` | 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. |
| 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/packages/cli/README.md b/packages/cli/README.md
index 6a7344d5c6..ad63f6075f 100644
--- a/packages/cli/README.md
+++ b/packages/cli/README.md
@@ -419,68 +419,68 @@ 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. |
-| `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?}), 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). |
-| `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). |
-| `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) 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 (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 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: 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. |
-| `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. |
-| `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). |
-| `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 candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
-| `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}], subcommands?), jsonSupported, 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). 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). |
-| `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, line, density, and message (what to cut or write instead); each is also a doc_fluff 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. |
+| `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?}), 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). |
+| `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). |
+| `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) 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 (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 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: 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. |
+| `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. |
+| `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). |
+| `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 candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
+| `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}], subcommands?), jsonSupported, 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). 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). |
+| `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 in prose that is exactly `astryx docs <name>` for a doc that exists: topic, section, 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. |
<!-- 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/integration/_adapter.mjs b/packages/cli/api/integration/_adapter.mjs
index 9b3fc1b63d..63dbe6e47d 100644
--- a/packages/cli/api/integration/_adapter.mjs
+++ b/packages/cli/api/integration/_adapter.mjs
@@ -17,6 +17,7 @@ import {
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 {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';
/**
* Each component doc's props compared with the component's TypeScript props,
@@ -78,3 +79,16 @@ export function integrationCopiedPassages(discovered) {
export function integrationFluff(discovered) {
return findFluff(discovered);
}
+
+/**
+ * Code spans in a package's prose that write `astryx docs <name>` for a doc
+ * that exists, where `{@link generic:<name>}` would be checked
+ * (architecture:cli-surface DEC-8). Reads the package's topics and the names
+ * of Core's docs.
+ *
+ * @param {Parameters<typeof findStrayPointers>[0]} discovered the package's
+ * docs, as discoverIntegrationDocs returns them
+ */
+export function integrationStrayPointers(discovered) {
+ return findStrayPointers(discovered);
+}
diff --git a/packages/cli/api/integration/authoring-checks.mjs b/packages/cli/api/integration/authoring-checks.mjs
index ea2986c5f7..29b88f84c5 100644
--- a/packages/cli/api/integration/authoring-checks.mjs
+++ b/packages/cli/api/integration/authoring-checks.mjs
@@ -18,6 +18,7 @@
* @position Public integration-authoring API over private discovery adapters.
*/
+import path from 'node:path';
import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
import {
packageDocsProblems,
@@ -33,6 +34,7 @@ import {
integrationCopiedPassages,
integrationFluff,
integrationPropDrift,
+ integrationStrayPointers,
} from './_adapter.mjs';
import {
discoverBuiltinTopics,
@@ -331,6 +333,8 @@ export async function integrationDocConflicts(pkg, options = {}) {
const copiedPassages = [];
/** @type {import('./authoring-checks.type.mjs').DocFluff[]} */
const fluff = [];
+ /** @type {import('./authoring-checks.type.mjs').StrayPointer[]} */
+ const strayPointers = [];
if (!resolved.integration?.docs || name == null) {
return {
type: 'integration.doc-conflicts',
@@ -341,6 +345,7 @@ export async function integrationDocConflicts(pkg, options = {}) {
findings: [],
copiedPassages,
fluff,
+ strayPointers,
issues,
},
};
@@ -443,14 +448,45 @@ export async function integrationDocConflicts(pkg, options = {}) {
}
// Docs should be dense: padding phrases and mostly-glue topics, listed
// and warned about the same way (DEC-8).
- fluff.push(...(await integrationFluff(discovered)));
+ // Like the other findings' `doc`, a fluff or stray-pointer `file` is
+ // relative to the package root.
+ const packageDir = /** @type {any} */ (resolved.integration).__packageDir;
+ const fromPackage = (/** @type {string} */ file) =>
+ typeof packageDir === 'string'
+ ? path.relative(packageDir, file).split(path.sep).join('/')
+ : file;
+ fluff.push(
+ ...(await integrationFluff(discovered)).map(each => ({
+ ...each,
+ file: fromPackage(each.file),
+ })),
+ );
for (const {message} of fluff) {
issues.push({code: 'doc_fluff', severity: 'warning', message});
}
+ // A pointer to a doc is a link, so doctor checks it (DEC-8).
+ strayPointers.push(
+ ...(await integrationStrayPointers(discovered)).map(each => ({
+ ...each,
+ file: fromPackage(each.file),
+ })),
+ );
+ for (const {message} of strayPointers) {
+ issues.push({code: 'stray_doc_pointer', severity: 'warning', message});
+ }
}
return {
type: 'integration.doc-conflicts',
- data: {validated, name, version, findings, copiedPassages, fluff, issues},
+ data: {
+ validated,
+ name,
+ version,
+ findings,
+ copiedPassages,
+ fluff,
+ strayPointers,
+ issues,
+ },
};
}
diff --git a/packages/cli/api/integration/authoring-checks.test.mjs b/packages/cli/api/integration/authoring-checks.test.mjs
index 0a407eb139..c565d511a7 100644
--- a/packages/cli/api/integration/authoring-checks.test.mjs
+++ b/packages/cli/api/integration/authoring-checks.test.mjs
@@ -912,7 +912,7 @@ describe('integrationDocConflicts fluff', () => {
kind: 'phrase',
phrase: 'in order to',
section: 'Overview',
- file: expect.stringMatching(/acme-setup\.doc\.mjs$/),
+ file: 'docs/acme-setup.doc.mjs',
line: 1,
density: null,
});
@@ -1038,3 +1038,153 @@ describe('integrationDocConflicts fluff', () => {
expect(found[0].message).toContain('under the 50% floor');
});
});
+
+describe('integrationDocConflicts stray doc pointers', () => {
+ const stray = (/** @type {any} */ result) => result.data.strayPointers;
+
+ it('lists a pointer to a topic whose name holds an underscore or capitals', async () => {
+ writeTopics([
+ {name: 'acme_setup', text: 'Install it first.'},
+ {name: 'AcmeGuide', text: 'Read on.'},
+ {
+ name: 'acme-menus',
+ text: 'Set it up as `astryx docs acme_setup` says, then `astryx docs AcmeGuide`; flags such as `astryx docs -h` are not pointers.',
+ },
+ ]);
+
+ const found = stray(
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
+ );
+
+ expect(found.map((/** @type {any} */ each) => each.link)).toEqual([
+ '{@link generic:acme_setup}',
+ '{@link generic:AcmeGuide}',
+ ]);
+ });
+
+ it('links a pointer to an extension topic to the page it extends', async () => {
+ writeTopics([
+ {name: 'acme-theme', text: 'Acme colors.', extendsTopic: 'theme'},
+ {name: 'acme-menus', text: 'Colors are in `astryx docs acme-theme`.'},
+ ]);
+
+ const [hit, ...rest] = stray(
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
+ );
+
+ expect(rest).toEqual([]);
+ expect(hit).toMatchObject({
+ topic: 'acme-menus',
+ link: '{@link @astryxdesign/cli:generic:theme}',
+ });
+ });
+
+ it('places a pointer-only list item on its own line, not an earlier summary or code block', async () => {
+ writeTopics([{name: 'acme-menus', text: 'Menus.'}]);
+ fs.writeFileSync(
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
+ [
+ 'export default {',
+ " type: 'generic',",
+ " name: 'acme-setup',",
+ " title: 'Fixture',",
+ " summary: 'See `astryx docs acme-menus`.',",
+ " description: 'Fixture topic.',",
+ " sections: [{title: 'Overview', content: [",
+ " {type: 'code', lang: 'bash', code: 'astryx docs acme-menus'},",
+ " {type: 'list', style: 'unordered', items: ['`astryx docs acme-menus`']},",
+ ' ]}],',
+ '};',
+ '',
+ ].join('\n'),
+ );
+
+ const found = stray(
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
+ ).filter((/** @type {any} */ each) => each.topic === 'acme-setup');
+
+ expect(found.map((/** @type {any} */ each) => each.line)).toEqual([9]);
+ });
+
+ it('lists a written pointer to a doc with the link that replaces it, and warns', async () => {
+ writeTopics([
+ {name: 'acme-setup', text: 'Install it first.'},
+ {
+ name: 'acme-menus',
+ text: 'Set it up as `astryx docs acme-setup` says; the theme is in `astryx docs theme`.',
+ },
+ ]);
+
+ const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
+ const [own, core, ...rest] = stray(result);
+
+ expect(rest).toEqual([]);
+ expect(own).toMatchObject({
+ topic: 'acme-menus',
+ section: 'Overview',
+ file: 'docs/acme-menus.doc.mjs',
+ line: 1,
+ pointer: 'astryx docs acme-setup',
+ link: '{@link generic:acme-setup}',
+ });
+ expect(own.message).toContain(
+ 'Replace `astryx docs acme-setup`, code ticks included, with {@link generic:acme-setup}',
+ );
+ expect(core.link).toBe('{@link @astryxdesign/cli:generic:theme}');
+ expect(result.data.issues).toEqual([
+ {code: 'stray_doc_pointer', severity: 'warning', message: own.message},
+ {code: 'stray_doc_pointer', severity: 'warning', message: core.message},
+ ]);
+ });
+
+ it('names a namespace doc by its kind', async () => {
+ writeTopics([
+ {name: 'acme-setup', text: 'Lay it out as `astryx docs layout` says.'},
+ ]);
+
+ const [hit] = stray(
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
+ );
+
+ expect(hit.link).toBe('{@link @astryxdesign/cli:namespace:layout}');
+ });
+
+ it('finds the line in the string that holds the pointer, not in the summary or code', async () => {
+ writeTopics([]);
+ fs.writeFileSync(
+ path.join(tmpDir, 'docs', 'acme-lines.doc.mjs'),
+ [
+ 'export default {',
+ " type: 'generic',",
+ " name: 'acme-lines',",
+ " title: 'Fixture',",
+ " description: 'Read `astryx docs theme` first.',",
+ " sections: [{title: 'Overview', content: [",
+ " {type: 'code', lang: 'bash', code: 'astryx docs theme'},",
+ " {type: 'prose', text: 'The colors your package sets show up in `astryx docs theme` for every app.'},",
+ ' ]}],',
+ '};',
+ '',
+ ].join('\n'),
+ );
+
+ const found = stray(
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
+ );
+
+ expect(found.map((/** @type {any} */ each) => each.line)).toEqual([8]);
+ });
+
+ it('leaves a command for a doc that does not exist, and a walkthrough', async () => {
+ writeTopics([
+ {
+ name: 'acme-setup',
+ text: 'Run `astryx docs acme-nothing`, or `astryx docs acme-setup overview`.',
+ },
+ ]);
+
+ expect(
+ stray(await integrationDocConflicts(undefined, {cwd: tmpDir})),
+ ).toEqual([]);
+ });
+});
diff --git a/packages/cli/api/integration/authoring-checks.type.mjs b/packages/cli/api/integration/authoring-checks.type.mjs
index 67b0100d94..e594711272 100644
--- a/packages/cli/api/integration/authoring-checks.type.mjs
+++ b/packages/cli/api/integration/authoring-checks.type.mjs
@@ -80,12 +80,28 @@
* @property {'phrase' | 'density'} kind
* @property {string | null} phrase the padding phrase, for `kind: 'phrase'`
* @property {string | null} section the title of the section it is in
- * @property {string} file the doc file
+ * @property {string} file the doc file, relative to the package root
* @property {number | null} line the file line that holds the phrase, when one line does
* @property {number | null} density the share of content words, for `kind: 'density'`
* @property {string} message what to cut or write instead
*/
+/**
+ * A code span in prose that is exactly `astryx docs <name>` for a doc that
+ * exists, where the doc's `{@link generic:<name>}` would be checked. Each is
+ * also a `stray_doc_pointer` warning, so `integration check --strict` fails on
+ * it (architecture:cli-surface DEC-8).
+ *
+ * @typedef {object} StrayPointer
+ * @property {string} topic the package topic that has it
+ * @property {string | null} section the title of the section it is in
+ * @property {string} file the doc file, relative to the package root
+ * @property {number | null} line the file line that holds it, when found
+ * @property {string} pointer the written command, `astryx docs <name>`
+ * @property {string} link the link that replaces it
+ * @property {string} message the exact replacement
+ */
+
/**
* Each of the three authoring checks reports `validated`: false means no
* integration manifest was found, so nothing was inspected and the empty
@@ -118,7 +134,7 @@
/**
* @typedef {object} IntegrationDocConflictResponse
* @property {'integration.doc-conflicts'} type
- * @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], copiedPassages: CopiedPassage[], fluff: DocFluff[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
+ * @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], copiedPassages: CopiedPassage[], fluff: DocFluff[], strayPointers: StrayPointer[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
*/
export {};
diff --git a/packages/cli/api/integration/integrationDocConflicts.doc.mjs b/packages/cli/api/integration/integrationDocConflicts.doc.mjs
index d78895fb8c..5028f19884 100644
--- a/packages/cli/api/integration/integrationDocConflicts.doc.mjs
+++ b/packages/cli/api/integration/integrationDocConflicts.doc.mjs
@@ -19,7 +19,9 @@ 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. ' +
- 'Each entry of either list is also a warning (`copied_passage`, `doc_fluff`), so ' +
+ '`strayPointers` lists each code span in prose that is exactly `astryx docs <name>` for a ' +
+ 'doc that exists, with the `{@link}` that replaces it. ' +
+ 'Each entry of these lists is also a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`), so ' +
'`integration check --strict` fails on it; the check itself still fails only on errors.',
importPath: '@astryxdesign/cli/api',
signature:
@@ -37,7 +39,7 @@ export const doc = {
{
type: 'integration.doc-conflicts',
description:
- '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, classified Core doc relationships, `copiedPassages`, and `fluff`.',
+ '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, classified Core doc relationships, `copiedPassages`, `fluff`, and `strayPointers`.',
},
],
examples: [
diff --git a/packages/cli/assets/docs/tree/add-a-topic.doc.mjs b/packages/cli/assets/docs/tree/add-a-topic.doc.mjs
index c8ad3168c6..b2ff1d6372 100644
--- a/packages/cli/assets/docs/tree/add-a-topic.doc.mjs
+++ b/packages/cli/assets/docs/tree/add-a-topic.doc.mjs
@@ -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 that `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 `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}.',
],
},
],
@@ -67,7 +67,7 @@ export const docs = {
type: 'list',
style: 'unordered',
items: [
- 'Replace the `Overview` placeholder that `integration add` writes.',
+ 'Replace the `Overview` placeholder `integration add` writes.',
'Every field is in {@link schema:reference-doc}.',
],
},
diff --git a/packages/cli/assets/docs/tree/check-your-docs.doc.mjs b/packages/cli/assets/docs/tree/check-your-docs.doc.mjs
index e5056e8e4b..90a95b80eb 100644
--- a/packages/cli/assets/docs/tree/check-your-docs.doc.mjs
+++ b/packages/cli/assets/docs/tree/check-your-docs.doc.mjs
@@ -42,6 +42,10 @@ export const docs = {
type: 'prose',
text: "Keep docs dense. The check lists, as a `doc_fluff` warning, each padding phrase in your prose, with its file line and what to write instead, and each topic of 80 or more prose words in which fewer than half the words carry content (words other than function words such as the, and, in), with its measured share and the floor of 0.5. `doctor integration docs` still exits 0, and `integration check --strict` fails until you cut it. Code, examples, and quoted text are not read. The phrases: `it\'s important to note`, `it is important to note`, `important to note that`, `it\'s worth noting`, `it is worth noting`, `worth noting that`, `it should be noted`, `please note`, `note that` (opening a sentence), `as mentioned above`, `as mentioned earlier`, `as mentioned before`, `as noted above`, `as you can see`, `needless to say`, `in order to`, `due to the fact that`, `for the purpose of`, `at this point in time`, `in other words`, `basically`, `essentially`, `obviously`.",
},
+ {
+ 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.",
+ },
{
type: 'prose',
text: 'Its arguments and exit codes are in {@link command:doctor integration docs}.',
@@ -129,7 +133,7 @@ fix: Remove \`summary\`: SingleComponentDoc has no field \`summary\`.`,
"The folder decides the type: `ComponentDoc` in your components root, `IntegrationTemplateDoc` in your templates root, `ThemeDoc` in your themes root, and in your docs root the type the doc's `type` names. Keep the `@type` comment above each doc's export too, so your editor shows the same problems as you type.",
'Every finding is a warning, so the exit code stays 0. With `--json`, they are in `data.docTypes.findings`.',
'It uses the `typescript` your package installs. Where `typescript` is missing or has no JavaScript compiler API, as TypeScript 7 does, it uses `@typescript/typescript6`, the TypeScript 6 API package, if your package installs it. Without either, it prints `[skip] Docs not type-checked` and the reason.',
- 'Every field of every doc type is in `astryx docs authoring`.',
+ 'Every field of every doc type is in {@link generic:authoring}.',
],
},
],
diff --git a/packages/cli/assets/docs/tree/checks.doc.mjs b/packages/cli/assets/docs/tree/checks.doc.mjs
index 062601cb32..b129afef1e 100644
--- a/packages/cli/assets/docs/tree/checks.doc.mjs
+++ b/packages/cli/assets/docs/tree/checks.doc.mjs
@@ -48,9 +48,9 @@ export const docs = {
],
[
'`npx astryx doctor integration docs`',
- 'Your docs tree, every link, topic names against Core, passages two topics repeat word for word, and padding phrases and low-density topics',
+ '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`), or prose pads with a listed phrase or falls under the density floor (`doc_fluff`)',
+ '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 writes `astryx docs <name>` where a link would be checked (`stray_doc_pointer`)',
],
[
'`npx astryx integration check`',
diff --git a/packages/cli/assets/docs/tree/document-the-theme.doc.mjs b/packages/cli/assets/docs/tree/document-the-theme.doc.mjs
index 26f5345c8a..d14900ac00 100644
--- a/packages/cli/assets/docs/tree/document-the-theme.doc.mjs
+++ b/packages/cli/assets/docs/tree/document-the-theme.doc.mjs
@@ -21,7 +21,7 @@ export const docs = {
content: [
{
type: 'prose',
- text: "Give your theme a doc topic that extends the core `theme` topic, so an app that lists your package sees your theme at the end of `astryx docs theme`. Add it with `extends: 'theme'` ({@link generic:extend-or-replace}).",
+ text: "Give your theme a doc topic that extends the core `theme` topic, so an app that lists your package sees your theme at the end of {@link generic:theme}. Add it with `extends: 'theme'` ({@link generic:extend-or-replace}).",
},
{
type: 'code',
diff --git a/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs b/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs
index bde2202bd2..f80d570320 100644
--- a/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs
+++ b/packages/cli/clients/cli/commands/doctor-integration-docs.doc.mjs
@@ -16,8 +16,9 @@ export const doc = {
'A same-name topic without `replaces` or `extends` is an accidental conflict ' +
'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, and each padding phrase and low-density topic, ' +
- 'each as a warning (`copied_passage`, `doc_fluff`; exit 0, and `integration check --strict` fails on it). See {@link generic:check-your-docs}.',
+ '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, ' +
+ '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.mjs b/packages/cli/clients/cli/commands/doctor.mjs
index c204f47c89..f93142bca9 100644
--- a/packages/cli/clients/cli/commands/doctor.mjs
+++ b/packages/cli/clients/cli/commands/doctor.mjs
@@ -397,7 +397,10 @@ function printDocConflicts(data) {
// issue is not printed twice.
...issueBlocks(
data.issues.filter(
- issue => issue.code !== 'copied_passage' && issue.code !== 'doc_fluff',
+ issue =>
+ issue.code !== 'copied_passage' &&
+ issue.code !== 'doc_fluff' &&
+ issue.code !== 'stray_doc_pointer',
),
),
];
@@ -472,6 +475,29 @@ function printDocConflicts(data) {
}),
);
}
+ const stray = data.strayPointers ?? [];
+ if (stray.length === 0) {
+ if (!data.issues.some(issue => issue.severity === 'error')) {
+ output.push(text('[ok] Every pointer to a doc is a link.'));
+ }
+ } else {
+ output.push(
+ text(
+ `[warn] ${stray.length} stray doc pointer(s) (stray_doc_pointer): a written \`astryx docs <name>\` where a link would be checked. Replace each with the link shown.`,
+ ),
+ records(stray, {
+ fields: [
+ 'topic',
+ 'section',
+ 'file',
+ 'line',
+ 'pointer',
+ 'link',
+ 'message',
+ ],
+ }),
+ );
+ }
emit(...output);
}
diff --git a/packages/cli/clients/cli/commands/integration-check.test.mjs b/packages/cli/clients/cli/commands/integration-check.test.mjs
index 8dadbd0fd5..e9e7022f4a 100644
--- a/packages/cli/clients/cli/commands/integration-check.test.mjs
+++ b/packages/cli/clients/cli/commands/integration-check.test.mjs
@@ -368,3 +368,44 @@ describe('a padding phrase', () => {
expect(strict.stdout).toContain('doc_fluff');
});
});
+
+describe('a stray doc pointer', () => {
+ it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
+ fs.writeFileSync(
+ path.join(tmpDir, 'package.json'),
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
+ );
+ fs.writeFileSync(
+ path.join(tmpDir, 'astryx.integration.mjs'),
+ `export default {docs: './docs'};\n`,
+ );
+ fs.mkdirSync(path.join(tmpDir, 'docs'));
+ const doc = {
+ type: 'generic',
+ name: 'acme-setup',
+ title: 'Fixture',
+ description: 'Fixture topic.',
+ sections: [
+ {
+ title: 'Overview',
+ content: [
+ {type: 'prose', text: 'The theme is in `astryx docs theme`.'},
+ ],
+ },
+ ],
+ };
+ fs.writeFileSync(
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
+ `export default ${JSON.stringify(doc)};\n`,
+ );
+
+ const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
+ expect(doctor.status).toBe(0);
+ expect(doctor.stdout).toContain('1 stray doc pointer(s)');
+ expect(doctor.stdout).toContain('{@link @astryxdesign/cli:generic:theme}');
+
+ const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
+ expect(strict.status).toBe(1);
+ expect(strict.stdout).toContain('stray_doc_pointer');
+ });
+});
diff --git a/packages/cli/foundation/discovery/stray-pointers.mjs b/packages/cli/foundation/discovery/stray-pointers.mjs
new file mode 100644
index 0000000000..1cfe033250
--- /dev/null
+++ b/packages/cli/foundation/discovery/stray-pointers.mjs
@@ -0,0 +1,255 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @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
+ * `{@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.
+ *
+ * @input the docs a package ships, as discoverIntegrationDocs returns them
+ * @output each stray pointer, with the link that replaces it
+ * @position foundation/discovery, called through api/integration/_adapter.mjs
+ */
+
+import fs from 'node:fs';
+
+import {builtinGuideFiles} from './docs-discovery.mjs';
+import {
+ fileWords,
+ lineAtOffset,
+ loadQuietly,
+ locateWords,
+ textWords,
+} from './copied-passages.mjs';
+
+/**
+ * A code span that is exactly the command opening one doc. A command with
+ * 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;
+
+/** @type {Promise<Map<string, string>> | undefined} */
+let coreKinds;
+
+/**
+ * The CLI's own docs by name, each with the kind a link names it by: a
+ * namespace doc as `namespace`, a topic or guide as `generic`.
+ * @returns {Promise<Map<string, string>>}
+ */
+function loadCoreKinds() {
+ coreKinds ??= (async () => {
+ const kinds = new Map();
+ for (const file of builtinGuideFiles()) {
+ const doc = await loadQuietly(file);
+ if (typeof doc?.name === 'string') {
+ kinds.set(doc.name, doc.type === 'namespace' ? 'namespace' : 'generic');
+ }
+ }
+ return kinds;
+ })();
+ return coreKinds;
+}
+
+/**
+ * The strings of a doc the compiler resolves links in: the text of prose and
+ * heading blocks, list items, and table cells, in each section's content, with
+ * the section's title. A summary or other field prints a link as written, so
+ * it is not read.
+ *
+ * @param {unknown} doc an authored doc object
+ * @returns {{text: string, section: string | null}[]}
+ */
+export function linkableStrings(doc) {
+ /** @type {{text: string, section: string | null}[]} */
+ const strings = [];
+ /**
+ * @param {unknown} value
+ * @param {string | null} section
+ */
+ const walk = (value, section) => {
+ if (Array.isArray(value)) {
+ for (const item of value) walk(item, section);
+ return;
+ }
+ if (value == null || typeof value !== 'object') return;
+ const record = /** @type {Record<string, any>} */ (value);
+ const title = typeof record.title === 'string' ? record.title : section;
+ if (Array.isArray(record.sections)) walk(record.sections, section);
+ if (!Array.isArray(record.content)) return;
+ for (const block of record.content) {
+ const add = (/** @type {unknown} */ text) => {
+ if (typeof text === 'string') strings.push({text, section: title});
+ };
+ switch (block?.type) {
+ case 'prose':
+ case 'heading':
+ add(block.text);
+ break;
+ case 'list':
+ (block.items ?? []).forEach(add);
+ break;
+ case 'table':
+ (block.headers ?? []).forEach(add);
+ for (const row of block.rows ?? []) row.forEach(add);
+ break;
+ default:
+ walk(block, title);
+ }
+ }
+ };
+ walk(doc, null);
+ return strings;
+}
+
+/**
+ * Every pointer span in one prose string, in order.
+ * @param {string} text
+ * @returns {string[]} the doc name each one points at
+ */
+export function pointersIn(text) {
+ return [...text.matchAll(POINTER)].map(match => match[1]);
+}
+
+/**
+ * Where a string's words start among a file's words, from `from` on. A
+ * one-line string the file holds as a quoted literal is found at that
+ * literal, so a list item that is only `astryx docs theme` is not placed at a
+ * summary or code block that writes the same words.
+ *
+ * @param {string[]} lines the file's lines
+ * @param {{word: string, line: number}[]} file the file's words
+ * @param {string} text
+ * @param {{word: string}[]} words the string's words
+ * @param {number} from
+ * @returns {number}
+ */
+function locateString(lines, file, text, words, from) {
+ /** @type {number[]} */
+ const starts = [];
+ for (let at = locateWords(file, words); at >= 0;) {
+ starts.push(at);
+ at = locateWords(file, words, at + 1);
+ }
+ if (starts.length === 0) return -1;
+ const literals = text.includes('\n')
+ ? []
+ : [`'${text}'`, `"${text}"`, `'${text.replace(/'/g, "\\'")}'`];
+ const quoted = starts.filter(at =>
+ literals.some(literal => lines[file[at].line - 1]?.includes(literal)),
+ );
+ const pool = quoted.length > 0 ? quoted : starts;
+ return pool.find(at => at >= from) ?? pool[0];
+}
+
+/**
+ * Each stray pointer in a package's topics.
+ *
+ * @param {{records: {name: string, path: string}[], guides?: {name: string, ref?: {topicFile?: string}}[], namespaces?: {doc?: {name?: string}}[]}} discovered
+ * @returns {Promise<import('../../api/integration/authoring-checks.type.mjs').StrayPointer[]>}
+ */
+export async function findStrayPointers(discovered) {
+ const topics = [
+ ...discovered.records.map(record => ({
+ name: record.name,
+ file: record.path,
+ })),
+ ...(discovered.guides ?? []).map(guide => ({
+ name: guide.name,
+ file: guide.ref?.topicFile,
+ })),
+ ];
+ /** @type {Map<string, string>} */
+ const own = new Map(topics.map(topic => [topic.name, 'generic']));
+ for (const namespace of discovered.namespaces ?? []) {
+ const name = namespace?.doc?.name;
+ if (typeof name === 'string' && !own.has(name)) own.set(name, 'namespace');
+ }
+ const core = await loadCoreKinds();
+ // A topic that extends another has no route of its own: a link to it names
+ // the page it shows on, the topic it extends.
+ /** @type {Map<string, string>} */
+ const extendsOf = new Map();
+ for (const topic of topics) {
+ if (!topic.file) continue;
+ const doc = /** @type {any} */ (await loadQuietly(topic.file));
+ if (typeof doc?.extends === 'string')
+ extendsOf.set(topic.name, doc.extends);
+ }
+ /** @param {string} target */
+ const linkFor = target => {
+ const page = extendsOf.get(target);
+ if (page != null) {
+ if (own.has(page) && !extendsOf.has(page)) {
+ return `{@link ${own.get(page)}:${page}}`;
+ }
+ return core.has(page)
+ ? `{@link @astryxdesign/cli:${core.get(page)}:${page}}`
+ : null;
+ }
+ return own.has(target)
+ ? `{@link ${own.get(target)}:${target}}`
+ : core.has(target)
+ ? `{@link @astryxdesign/cli:${core.get(target)}:${target}}`
+ : null;
+ };
+ /** @type {import('../../api/integration/authoring-checks.type.mjs').StrayPointer[]} */
+ const found = [];
+ for (const topic of topics) {
+ if (!topic.file) continue;
+ const doc = await loadQuietly(topic.file);
+ if (!doc) continue;
+ /** @type {{word: string, line: number}[]} */
+ let source = [];
+ /** @type {string[]} */
+ let lines = [];
+ try {
+ const raw = fs.readFileSync(topic.file, 'utf8');
+ source = fileWords(raw);
+ lines = raw.split('\n');
+ } catch {
+ // No line numbers; the finding still names the section.
+ }
+ // Each string is found by its whole run of words, from where the last
+ // one was found, so two strings that open alike keep their own lines.
+ let cursor = 0;
+ for (const {text, section} of linkableStrings(doc)) {
+ const words = textWords(text);
+ 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 link = linkFor(target);
+ if (!link) continue;
+ const command = `astryx docs ${target}`;
+ const line =
+ index < 0
+ ? null
+ : lineAtOffset(
+ source,
+ index,
+ words,
+ /** @type {number} */ (match.index) + 1,
+ );
+ const where = [
+ section ? `section "${section}"` : null,
+ line == null ? null : `line ${line}`,
+ ]
+ .filter(Boolean)
+ .join(', ');
+ found.push({
+ topic: topic.name,
+ section,
+ file: topic.file,
+ line,
+ pointer: command,
+ link,
+ message:
+ `"${topic.name}"${where ? ` (${where})` : ''} points at a doc with the written command \`${command}\`. ` +
+ `Replace \`${command}\`, code ticks included, with ${link}: the CLI prints the command that opens the doc, and doctor checks the link.`,
+ });
+ }
+ }
+ }
+ return found;
+}
diff --git a/packages/cli/foundation/discovery/stray-pointers.test.mjs b/packages/cli/foundation/discovery/stray-pointers.test.mjs
new file mode 100644
index 0000000000..0fec23fb37
--- /dev/null
+++ b/packages/cli/foundation/discovery/stray-pointers.test.mjs
@@ -0,0 +1,57 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, expect, it} from 'vitest';
+
+import {linkableStrings, pointersIn} from './stray-pointers.mjs';
+
+describe('pointersIn', () => {
+ it('finds a code span that is exactly the command opening one doc', () => {
+ expect(
+ pointersIn(
+ 'Read `astryx docs theme`, then `astryx docs layout-spacing`.',
+ ),
+ ).toEqual(['theme', 'layout-spacing']);
+ });
+
+ it('leaves a walkthrough alone: more words, a flag, or a route', () => {
+ expect(
+ pointersIn(
+ 'Run `astryx docs theme overview`, `astryx docs --json`, `astryx docs cli/integrations`, or `astryx docs`.',
+ ),
+ ).toEqual([]);
+ });
+
+ it('leaves the bare name and a runner-written command alone', () => {
+ expect(
+ pointersIn('See astryx docs theme, or `pnpm astryx docs theme`.'),
+ ).toEqual([]);
+ });
+});
+
+describe('linkableStrings', () => {
+ it('reads prose, headings, list items and table cells, not the summary or code', () => {
+ const strings = linkableStrings({
+ name: 'acme',
+ description: 'Read `astryx docs theme`.',
+ sections: [
+ {
+ title: 'Use it',
+ content: [
+ {type: 'prose', text: 'prose'},
+ {type: 'heading', level: 3, text: 'heading'},
+ {type: 'list', style: 'unordered', items: ['item']},
+ {type: 'table', headers: ['head'], rows: [['cell']]},
+ {type: 'code', lang: 'bash', code: 'astryx docs theme'},
+ ],
+ },
+ ],
+ });
+ expect(strings).toEqual([
+ {text: 'prose', section: 'Use it'},
+ {text: 'heading', section: 'Use it'},
+ {text: 'item', section: 'Use it'},
+ {text: 'head', section: 'Use it'},
+ {text: 'cell', section: 'Use it'},
+ ]);
+ });
+});
diff --git a/packages/cli/foundation/doc-compiler/doc-loads.test.mjs b/packages/cli/foundation/doc-compiler/doc-loads.test.mjs
index 72135b0571..02d4987d5a 100644
--- a/packages/cli/foundation/doc-compiler/doc-loads.test.mjs
+++ b/packages/cli/foundation/doc-compiler/doc-loads.test.mjs
@@ -268,6 +268,10 @@ const RUNNERS = {
runs: 'a contributed topic, for its catalog fields: name, title, description, category, and relationships',
sites: ['importDocModule'],
},
+ 'foundation/discovery/stray-pointers.mjs': {
+ runs: "the CLI's own guides, for their names, to tell which written `astryx docs <name>` points at a doc that exists",
+ sites: ['builtinGuideFiles'],
+ },
'foundation/discovery/project-typescript.mjs': {
runs: "the project's own typescript, for the author checks that read source and docs with it, and its package.json for the version of one they cannot use; beside TypeScript 7, which has no compiler API, the TypeScript 6 API package @typescript/typescript6",
sites: [
diff --git a/packages/cli/foundation/response/response-types.doc.mjs b/packages/cli/foundation/response/response-types.doc.mjs
index f841481cb7..c6aa5329ab 100644
--- a/packages/cli/foundation/response/response-types.doc.mjs
+++ b/packages/cli/foundation/response/response-types.doc.mjs
@@ -348,7 +348,7 @@ export const doc = {
{
value: 'integration.doc-conflicts',
description:
- '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, line, density, and message (what to cut or write instead); each is also a doc_fluff warning in issues.',
+ '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 in prose that is exactly `astryx docs <name>` for a doc that exists: topic, section, 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.',
},
{
value: 'integration.check',
diff --git a/packages/cli/test/core-doc-quality.test.mjs b/packages/cli/test/core-doc-quality.test.mjs
index ee76cd2710..c3b55df377 100644
--- a/packages/cli/test/core-doc-quality.test.mjs
+++ b/packages/cli/test/core-doc-quality.test.mjs
@@ -3,7 +3,8 @@
/**
* Core's own guides pass the doc-quality checks `integration check --strict`
* holds every integration to (architecture:cli-surface DEC-8): no two guides
- * repeat a passage word for word, and none pads its prose.
+ * repeat a passage word for word, none pads its prose, and every pointer to
+ * a doc is a link.
*/
import {describe, expect, it} from 'vitest';
@@ -19,6 +20,10 @@ import {
densityWords,
fillerIn,
} from '../foundation/discovery/doc-fluff.mjs';
+import {
+ pointersIn,
+ linkableStrings,
+} from '../foundation/discovery/stray-pointers.mjs';
import {
BOILERPLATE_TOPICS,
MIN_CONTENT_WORDS,
@@ -106,4 +111,19 @@ describe("Core's guides", () => {
}
expect(fluff, 'Cut the phrase, or write the shorter word.').toEqual([]);
});
+
+ it('point at other docs with links, not written commands', async () => {
+ const guides = await coreGuides();
+ const names = new Set(guides.map(guide => guide.name));
+ const stray = [];
+ for (const {name, doc} of guides) {
+ for (const {text} of linkableStrings(doc)) {
+ for (const target of pointersIn(text)) {
+ if (names.has(target))
+ stray.push(`${name}: \`astryx docs ${target}\``);
+ }
+ }
+ }
+ expect(stray, 'Write {@link generic:<name>} instead.').toEqual([]);
+ });
});
diff --git a/packages/cli/test/integration-check-failures.json b/packages/cli/test/integration-check-failures.json
index da3c4d83d3..d5a9addaa6 100644
--- a/packages/cli/test/integration-check-failures.json
+++ b/packages/cli/test/integration-check-failures.json
@@ -4,7 +4,7 @@
"validate": ["docTypes", "issues"],
"components": ["conflicts", "issues", "propDrift"],
"templates": ["conflicts", "issues"],
- "docs": ["copiedPassages", "findings", "fluff", "issues"]
+ "docs": ["copiedPassages", "findings", "fluff", "issues", "strayPointers"]
},
"reports": {
"docTypes": "doc_types_skipped",
@@ -60,6 +60,7 @@
"shadowed_component_name",
"source_without_component_doc",
"source_without_template_doc",
+ "stray_doc_pointer",
"template_id_conflict",
"type_mismatch",
"unknown_field",