An open source design system that's fully customizable and agent ready
TypeScript
feat(cli): integration docs replace or extend a CLI guide by its route, and place sections with before/after (#7936)
Joeyac8260d33687
diff --git a/.changeset/docs-replace-extend-placed-guides.md b/.changeset/docs-replace-extend-placed-guides.mdnew file mode 100644index 0000000000..35825ce262--- /dev/null+++ b/.changeset/docs-replace-extend-placed-guides.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[feat] An integration's doc can now replace or extend one of the CLI's guides by its route, such as `replaces: 'authoring/quick-start'` or `extends: 'authoring/quick-start'`, so a package changes the guide agents already read for every app that installs it. An extension's section can set `before` or `after` to a section's key to go there instead of at the end; an older CLI rejects those fields, so `integration verify` warns when the package's `@astryxdesign/cli` peer range admits one. Every read names the replacing or extending package: `package` on the guide and on each section, and a replaced topic or guide now also carries `replacedPackage` beside `replaces` (in `docs`, `docs --index`, the topic list, and a namespace's children), with a `replaces <package>'s <topic>` line in text. A name that holds no topic or guide (such as a namespace) changes nothing, and a `before` or `after` key that names no section adds the section at the end: `integration validate` lists each as a note (`doc_target_not_found`, `doc_section_unplaced`), and two docs of one package that replace one guide as `duplicate_guide_replacement`; none fails anything until the next minor release.++@josephfarinadiff --git a/docs/specs/AST-046-docs-tree/spec.md b/docs/specs/AST-046-docs-tree/spec.mdindex 3a549a0660..761225eba2 100644--- a/docs/specs/AST-046-docs-tree/spec.md+++ b/docs/specs/AST-046-docs-tree/spec.md@@ -7,7 +7,7 @@ authority: currentarchive_reason: nullsuperseded_by: nullapproved_by: josephfarina-approved_at: 2026-10-21+approved_at: 2026-10-22phase: implementingowners: [josephfarina]affects_architecture: [architecture:cli-surface]@@ -168,7 +168,20 @@ and references from other packages are an open question (OQ2).MUST read them beside the CLI's own, identify each node by the integration'sprovider id (FR1) and name its `package` by the integration's npm name, andhold them to FR2–FR8. A placed guide MUST NOT also `replaces` or `extends` a- topic. When two providers claim one route, the CLI's own docs MUST keep it,+ topic. A flat topic MAY name a placed guide by its route, or by a route it+ moved from, in `replaces` or `extends`; this claims no route, so the guide+ keeps its place and route, and a read of a moved route still fails as FR9+ states. A replacement MUST be read at that route as its own package's doc,+ and an extension's sections MUST merge onto the guide as they merge onto a+ topic; docs that name one guide by its old and its new route apply in+ configured order. An extension's section MAY set `before` or `after` to the+ key of a section of the doc it extends, and MUST be placed there, in+ authored order; with neither, or with a key that names no section, it MUST+ be added at the end, and neither field is read back. A replaced topic or+ guide MUST name the package it replaced as `replacedPackage`, beside+ `replaces`. A `replaces` or `extends` that names no topic and no guide,+ such as a namespace, changes nothing.+ When two providers claim one route, the CLI's own docs MUST keep it,including its flat topics' names and the generated topic levels, then integrationsin configured order; between integrations a namespace keeps its route over atopic, and a name a topic answers to through `replaces` is that topic's route.@@ -189,6 +202,8 @@ and references from other packages are an open question (OQ2).covers a template that sets `replaces` (`spec:AST-035`), a doc section thatsets `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.- **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 foundations@@ -291,18 +306,18 @@ Phase 1 changes these surfaces:## Verification-| Contract | Verification | Representative states | Mutation or failure expectation |-| ------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| FR1, FR3, FR4 | Tree builder fixture tests | three authored levels; adoption with and without `groupBy`; reversed input order; order and title sort | A route that ignores the parent, a folder that implies a parent, or a tree that depends on input order |-| FR2 | Tree builder failure fixtures | no slot; unknown slot; a slot that refuses the kind; another package's parent; not a reference; two adopters; a cycle | A failed placement that falls back to adoption, or a failure without a diagnostic |-| FR5, FR6, FR7 | `docs()` dispatcher tests and CLI runs | `cli`, `cli/api`, one function, the placed guide and its sections, the old name, a typo route; a section on a namespace that one guide, no guide, and two guides hold | A namespace that inlines grandchildren, a lost section read, a section read that picks one of two guides, or a wrong error code |-| FR8 | Doctor tests | this repo; a fixture tree with a broken placement | A broken tree or an unplaced CLI doc that passes |-| FR9 | Real-tree tests and the route inventory | every command, function, schema, and enum doc; every exported API function | A CLI typed doc without its route, or a route inventory row the tree contradicts |-| FR10 | Search tests and CLI runs | a guide section; a typed doc by its own name; an error code; a topic hit; no core installed | A section hit whose command reads the whole topic, or a docs-only search that needs core |-| FR11 | Integration tree tests | a namespace and two placed guides from a package whose provider id differs from its name; a broken link; a claim on the `cli` route | A node named by the package name, a broken link that passes either doctor, or an integration that takes a CLI route |-| FR12 | `docs()` tests, the graph walk, and search tests | the level and its children in list order; a topic's Up, Previous, and Next; a flat topic hit's parent; an integration's flat topic | A flat topic without a home, a topic whose name changes, or a level that lists a placed guide |-| FR13 | Split tests over the topic before and after, the graph walk, and search tests | each old section key read through the namespace; a link and a token reference to the old topic; a `--dense` read; the topic list and a search for one section | A dropped, merged, or copied section; a changed title or `id`; a reference left on the old identity; a name listed twice; a section found twice |-| FR14 | Docsite page-generation and route-resolution tests | a split namespace; a nested namespace; a package-page namespace; a namespace with a `category`, and one whose guides are all foundations docs; a generated topic level | An old address that stops resolving or lands in another sidebar group, a permanent guide redirect, a guide page on a non-package namespace, or a slug that is both a page and a redirect |+| Contract | Verification | Representative states | Mutation or failure expectation |+| ------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| FR1, FR3, FR4 | Tree builder fixture tests | three authored levels; adoption with and without `groupBy`; reversed input order; order and title sort | A route that ignores the parent, a folder that implies a parent, or a tree that depends on input order |+| FR2 | Tree builder failure fixtures | no slot; unknown slot; a slot that refuses the kind; another package's parent; not a reference; two adopters; a cycle | A failed placement that falls back to adoption, or a failure without a diagnostic |+| FR5, FR6, FR7 | `docs()` dispatcher tests and CLI runs | `cli`, `cli/api`, one function, the placed guide and its sections, the old name, a typo route; a section on a namespace that one guide, no guide, and two guides hold | A namespace that inlines grandchildren, a lost section read, a section read that picks one of two guides, or a wrong error code |+| FR8 | Doctor tests | this repo; a fixture tree with a broken placement | A broken tree or an unplaced CLI doc that passes |+| FR9 | Real-tree tests and the route inventory | every command, function, schema, and enum doc; every exported API function | A CLI typed doc without its route, or a route inventory row the tree contradicts |+| FR10 | Search tests and CLI runs | a guide section; a typed doc by its own name; an error code; a topic hit; no core installed | A section hit whose command reads the whole topic, or a docs-only search that needs core |+| FR11 | Integration tree tests; guide route target tests | a namespace and two placed guides from a package whose provider id differs from its name; a broken link; a claim on the `cli` route; a flat topic that replaces or extends a CLI guide by its route, with `before` and `after` | A node named by the package name, a broken link that passes either doctor, an integration that takes a CLI route, a replaced guide or added section that names the wrong package, or a section out of place |+| FR12 | `docs()` tests, the graph walk, and search tests | the level and its children in list order; a topic's Up, Previous, and Next; a flat topic hit's parent; an integration's flat topic | A flat topic without a home, a topic whose name changes, or a level that lists a placed guide |+| FR13 | Split tests over the topic before and after, the graph walk, and search tests | each old section key read through the namespace; a link and a token reference to the old topic; a `--dense` read; the topic list and a search for one section | A dropped, merged, or copied section; a changed title or `id`; a reference left on the old identity; a name listed twice; a section found twice |+| FR14 | Docsite page-generation and route-resolution tests | a split namespace; a nested namespace; a package-page namespace; a namespace with a `category`, and one whose guides are all foundations docs; a generated topic level | An old address that stops resolving or lands in another sidebar group, a permanent guide redirect, a guide page on a non-package namespace, or a slug that is both a page and a redirect |## Decision logdiff --git a/packages/cli/README.md b/packages/cli/README.mdindex 0dded723a1..11fce3564e 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?}), 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 (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). 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} 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. |<!-- 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/docs/_adapter.mjs b/packages/cli/api/docs/_adapter.mjsindex 54195710df..9cb1cd44f2 100644--- a/packages/cli/api/docs/_adapter.mjs+++ b/packages/cli/api/docs/_adapter.mjs@@ -19,7 +19,11 @@import * as path from 'node:path';import {Project} from '../../foundation/config/project.mjs';-import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';+import {+ DocsCatalog,+ isGuideRoute,+ mergeTopicReport,+} from '../../foundation/discovery/docs-discovery.mjs';import {checkDocTypes} from '../../foundation/discovery/doc-types.mjs';import {integrationDocFiles} from '../../foundation/discovery/integration-doc-files.mjs';import {@@ -437,14 +441,61 @@ async function buildProjectTree(catalog, fresh) {docs: [...cli.docs, ...added.flatMap(each => each.guides)],topics: await flatTopicInputs(catalog),});+ // A guide the tree places that an integration replaces or extends by its+ // route, or by the route it had before it moved: reads apply what it does,+ // and a replacement lists under its own title and summary.+ // Each doc applies in configured order to the guide its route names, so a+ // doc naming a guide's old route and one naming its new route stack as if+ // both named the same one.+ for (const record of catalog.guideTargeters) {+ const node = placedGuideAt(+ result,+ /** @type {string} */ (record.replaces ?? record.extendsTopic),+ );+ if (!node) continue;+ /** @type {import('../../foundation/discovery/docs-discovery.mjs').GuideOverlay} */+ const overlay = node.guideOverlay ?? {replacement: null, extensions: []};+ if (record.replaces != null) {+ node.guideOverlay = {+ replacement: record,+ // Extensions were authored against the content that just went away.+ extensions: [],+ ...(overlay.replacement+ ? {replacedPackage: overlay.replacement.package}+ : {}),+ };+ } else {+ node.guideOverlay = {+ ...overlay,+ extensions: [+ ...overlay.extensions,+ {+ package: record.package,+ path: record.path,+ ...(record.providerId ? {providerId: record.providerId} : {}),+ },+ ],+ };+ }+ }+ for (const node of result.nodes.values()) {+ const replacement = node.guideOverlay?.replacement;+ if (replacement) {+ node.title = replacement.title ?? node.title;+ node.summary = replacement.description ?? node.summary;+ }+ }// 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')) {+ const replacement = node.guideOverlay?.replacement;node.summary = await linkSummary(catalog,result,- node.providerId,+ replacement+ ? (replacement.providerId ?? replacement.package)+ : node.providerId,node.summary,);}@@ -1103,7 +1154,16 @@ export async function docsLinkProblems(}}for (const node of tree.nodes.values()) {- if (owner != null && node.provider !== owner) continue;+ // A package owns a guide it placed, and a guide it replaces or extends by+ // its route.+ if (+ owner != null &&+ node.provider !== owner &&+ node.guideOverlay?.replacement?.package !== owner &&+ !node.guideOverlay?.extensions.some(each => each.package === owner)+ ) {+ continue;+ }if (node.kind === 'generic' && node.ref?.topicFile) {try {note(node.route, await topicLinkProblems(catalog, guideEntry(node)));@@ -1234,6 +1294,168 @@ export async function packageDocsProblems(integration, discovered) {return problems;}+/**+ * The guide the docs tree places at a route, compared without case, or at the+ * route it moved to; null when the route holds no placed guide.+ * @param {DocsTree} tree+ * @param {string} route+ * @returns {TreeNode | null}+ */+function placedGuideAt(tree, route) {+ const node =+ tree.get(route) ?? tree.getFolded(route) ?? movedRoute(route, tree);+ return node?.kind === 'generic' && node.ref?.topicFile ? node : null;+}++/**+ * The routes of every guide the tree places below a namespace, nearest first,+ * in reading order.+ * @param {DocsTree} tree+ * @param {TreeNode} namespace+ * @returns {string[]}+ */+function placedGuidesBelow(tree, namespace) {+ /** @type {string[]} */+ const routes = [];+ /** @type {TreeNode[]} */+ let level = [namespace];+ while (level.length > 0) {+ /** @type {TreeNode[]} */+ const next = [];+ for (const parent of level) {+ for (const slot of parent.slots) {+ for (const route of slot.children) {+ const child = tree.get(route);+ if (!child || child.parent !== parent.route) continue;+ if (child.kind === 'generic' && child.ref?.topicFile) {+ routes.push(child.route);+ }+ if (child.slots.length > 0) next.push(child);+ }+ }+ }+ level = next;+ }+ return routes;+}++/**+ * What one doc that replaces or extends another does, as a package's own+ * check sees it.+ * @typedef {object} DocTarget+ * @property {string} topic the doc's own name+ * @property {'replaces' | 'extends'} relationship+ * @property {string} target the topic name or route it names+ * @property {'topic' | 'guide' | 'namespace' | null} kind what the target+ * is: a flat topic, a guide the docs tree places, a namespace (which neither+ * takes), or null when it names nothing+ * @property {string | null} guide for a guide, the route it is placed at now,+ * which an old route resolves to+ * @property {string[]} guidesBelow for a namespace, the routes of the guides+ * placed below it, any of which the doc could name instead+ * @property {string | null} owner the package whose topic or guide it is+ * @property {Array<{section: string, field: 'before' | 'after', key: string}>} unplaced+ * each section whose `before` or `after` names no section of the target, so+ * it is added at the end instead+ */++/**+ * Each doc in one integration's docs that replaces or extends a topic, or a+ * guide the docs tree places by its route, read against the CLI's docs and the+ * package's own: what it names and whether that exists, and each section an+ * extension places with `before` or `after` that finds no section there.+ * @param {any} integration+ * @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered+ * @returns {Promise<DocTarget[]>}+ */+export async function packageDocTargets(integration, discovered) {+ const catalog = packageCatalog(integration, discovered);+ const tree = await projectTree(catalog);+ /** @type {DocTarget[]} */+ const targets = [];+ for (const record of discovered.records) {+ const relationship = record.replaces != null ? 'replaces' : 'extends';+ const target =+ relationship === 'replaces' ? record.replaces : record.extendsTopic;+ if (target == null) continue;+ /** @type {DocTarget['kind']} */+ let kind = null;+ /** @type {string | null} */+ let owner = null;+ /** @type {string | null} */+ let basePath = null;+ /** @type {ReadonlyArray<{path: string}>} every extension of the target, in configured order */+ let extensions = [];+ /** @type {string[]} */+ let guidesBelow = [];+ /** @type {string | null} */+ let guide = null;+ if (isGuideRoute(target)) {+ const node = placedGuideAt(tree, target);+ if (node) {+ kind = 'guide';+ guide = node.route;+ owner = node.provider;+ basePath = node.guideOverlay?.replacement?.path ?? node.ref.topicFile;+ extensions = node.guideOverlay?.extensions ?? [];+ }+ } else {+ // A replacement already holds the topic's place in the catalog, and+ // names the package it took it from.+ const entry = catalog.resolve(target);+ if (entry?.path === record.path) {+ kind = 'topic';+ owner = entry.replacedPackage ?? null;+ } else if (entry) {+ kind = 'topic';+ owner = entry.package;+ basePath = entry.path;+ extensions = entry.extensions;+ }+ }+ if (kind == null) {+ // A namespace holds no sections to take over or merge onto; the guides+ // below it do.+ const node =+ tree.get(target) ?? tree.getFolded(target) ?? movedRoute(target, tree);+ if (node?.kind === 'namespace') {+ kind = 'namespace';+ owner = node.provider;+ guidesBelow = placedGuidesBelow(tree, node);+ }+ }+ /** @type {DocTarget['unplaced']} */+ let unplaced = [];+ if (relationship === 'extends' && basePath != null) {+ // Merge every extension in configured order, as a read does, so a key+ // an earlier extension adds counts as a section of the target.+ let doc = (await loadTopicFile(basePath, null)).doc;+ for (const extension of extensions) {+ if (doc == null) break;+ const file = (await loadTopicFile(extension.path, null)).doc;+ if (file == null) continue;+ const merged = mergeTopicReport(doc, file);+ if (extension.path === record.path) {+ unplaced = merged.unplaced;+ break;+ }+ doc = merged.doc;+ }+ }+ targets.push({+ topic: record.name,+ relationship,+ target,+ kind,+ owner,+ guide,+ guidesBelow,+ unplaced,+ });+ }+ return targets;+}+/*** How a token reference finds its target: the topic it names in `catalog`,* lowered for the same language.@@ -1335,20 +1557,41 @@ export async function compileTopic(catalog, entry, lang = null) {/*** A guide the docs tree places, as a topic entry the topic readers open by its* route. It is never a flat topic: `astryx docs <route>` is its only name.+ * What integrations do to it by its route applies: a replacement is read in+ * its place and names its own package, and each extension's sections merge+ * onto it, each naming the package that wrote it (INV28).* @param {import('../../foundation/doc-compiler/tree.mjs').TreeNode} node* @returns {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}*/export function guideEntry(node) {- return {+ const base = {name: node.route,route: node.route,package: node.provider,providerId: node.providerId,path: node.ref.topicFile,extensions: [],- tree: true,+ tree: /** @type {const} */ (true),parent: node.parent ?? undefined,};+ const overlay = node.guideOverlay;+ if (!overlay) return base;+ const replacement = overlay.replacement;+ return {+ ...base,+ ...(replacement+ ? {+ package: replacement.package,+ providerId: replacement.providerId ?? replacement.package,+ path: replacement.path,+ replaces: node.route,+ // The package whose guide it took over: an earlier replacement's,+ // when the guide was already replaced.+ replacedPackage: overlay.replacedPackage ?? node.provider,+ }+ : {}),+ extensions: [...overlay.extensions],+ };}/** @type {WeakMap<DocsTree, ReturnType<typeof cliDocIndex>>} */diff --git a/packages/cli/api/docs/detail/detail.mjs b/packages/cli/api/docs/detail/detail.mjsindex e384b33869..1171e01636 100644--- a/packages/cli/api/docs/detail/detail.mjs+++ b/packages/cli/api/docs/detail/detail.mjs@@ -52,6 +52,14 @@ export async function detail(topic, options = {}) {),// A guide the docs tree places is read by its route, not its doc name....(entry.tree ? {name: entry.name} : {}),+ // Whose topic or guide it took the place of, beside `replaces` (INV28).+ // What it took the place of, as the list, the index and the listing+ // name it: a guide's route, even when the doc named a route the guide+ // moved from, and a topic replaced twice by the earlier replacement.+ ...(entry.replaces != null ? {replaces: entry.replaces} : {}),+ ...(entry.replaces != null && entry.replacedPackage != null+ ? {replacedPackage: entry.replacedPackage}+ : {}),links: await topicLinks(catalog, entry),},};diff --git a/packages/cli/api/docs/docs.doc.mjs b/packages/cli/api/docs/docs.doc.mjsindex b53bed94bd..5e0a86f2c8 100644--- a/packages/cli/api/docs/docs.doc.mjs+++ b/packages/cli/api/docs/docs.doc.mjs@@ -107,7 +107,7 @@ export const doc = {{type: 'docs.list',description:- "Every reference-doc topic in read order, as DocsListEntry[] ({topic, description, package, replaces?}), each readable with docs(topic). meta.namespaces lists the docs tree's top-level namespaces ({topic, description, package}), and meta.notLoaded each package whose docs did not load ({package, message}).",+ "Every reference-doc topic in read order, as DocsListEntry[] ({topic, description, package, replaces?, replacedPackage?}), each readable with docs(topic). meta.namespaces lists the docs tree's top-level namespaces ({topic, description, package}), and meta.notLoaded each package whose docs did not load ({package, message}).",},{type: 'docs.detail',diff --git a/packages/cli/api/docs/docs.type.mjs b/packages/cli/api/docs/docs.type.mjsindex 8038edb790..61bdd9cc2c 100644--- a/packages/cli/api/docs/docs.type.mjs+++ b/packages/cli/api/docs/docs.type.mjs@@ -34,6 +34,8 @@* '@astryxdesign/cli' for a built-in one, else the contributing integration* @property {string} [replaces] the topic this one took the place of, when it* was contributed as a replacement+ * @property {string} [replacedPackage] the package whose topic it took the+ * place of, with `replaces`*//**@@ -58,16 +60,17 @@* @typedef {object} DocsDetailResponse* @property {'docs.detail'} type* @property {string} package the npm package that owns the topic- * @property {Omit<DocsReadDoc, 'sections'> & {sections: DocsDetailSection[], links: DocsLinks}} data+ * @property {Omit<DocsReadDoc, 'sections'> & {sections: DocsDetailSection[], links: DocsLinks, replacedPackage?: string}} data* the whole doc, each section naming the package that wrote it, and the- * moves from it+ * moves from it; `replacedPackage` names the package whose topic or guide+ * it took the place of, with `replaces`*//*** A topic section as a read returns it. A read inlines each token reference* and each `reference` block the author wrote, so its content holds only the* stable ReferenceContentBlock kinds.- * @typedef {Omit<import('@astryxdesign/cli/authoring').ReferenceSection, 'content'>+ * @typedef {Omit<import('@astryxdesign/cli/authoring').ReferenceSection, 'content' | 'before' | 'after'>* & {content: import('@astryxdesign/cli/authoring').ReferenceContentBlock[]}} DocsReadSection*/@@ -119,6 +122,9 @@* @property {string} name the topic* @property {string} title* @property {string} description+ * @property {string} [replaces] the topic or guide this one took the place of+ * @property {string} [replacedPackage] the package whose topic or guide it+ * took the place of* @property {DocsIndexSection[]} sections* @property {DocsLinks} links the moves from the index*/@@ -200,6 +206,10 @@* @property {string} route pass it to `astryx docs` to go one level down* @property {string} name the last segment of its route* @property {string} package the package that owns the child+ * @property {string} [replaces] the guide's own route, when an integration's+ * doc took its place+ * @property {string} [replacedPackage] the package whose guide it took the+ * place of, with `replaces`* @property {string} kind* @property {string} title* @property {string} summarydiff --git a/packages/cli/api/docs/guide-route-targets.test.mjs b/packages/cli/api/docs/guide-route-targets.test.mjsnew file mode 100644index 0000000000..ea61b8395e--- /dev/null+++ b/packages/cli/api/docs/guide-route-targets.test.mjs@@ -0,0 +1,998 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file An integration's flat topic replaces or extends a guide the docs tree+ * places, by its route, and an extension places its sections with `before` or+ * `after`. Every read names the package of the guide and of each section, in+ * text and JSON (architecture:cli-surface INV28). A route that holds no guide,+ * and a `before`/`after` that names no section, fail nothing: they are listed+ * notes (INV35).+ */++import * as fs from 'node:fs';+import * as path from 'node:path';+import {afterEach, beforeEach, describe, expect, it} from 'vitest';+import {docs} from './docs.mjs';+import {integrationDocConflicts} from '../integration/authoring-checks.mjs';+import {validateIntegration} from '../integration/validate-integration.mjs';+import {integrationCheck} from '../integration/check/check.mjs';+import {runCli} from '../../test-utils/run-cli.mjs';+import {search} from '../search/search.mjs';+import {sectionPositionCliProblem} from '../../foundation/integrations/cli-requirement.mjs';+import {+ DocsCatalog,+ mergeTopic,+} from '../../foundation/discovery/docs-discovery.mjs';++const SLOW = 60_000;+const CLI = '@astryxdesign/cli';+const KIT = '@acme/kit';+const GUIDE = 'authoring/quick-start';++/** @type {string} */+let tmpDir;++/**+ * A flat topic of the kit.+ * @param {string} name+ * @param {object} fields+ */+function topic(name, fields) {+ return {+ type: 'generic',+ name,+ title: `Acme ${name}`,+ description: `The Acme ${name}.`,+ sections: [+ {+ id: `acme-${name}`,+ title: `Acme ${name}`,+ content: [{type: 'prose', text: `Acme ${name}.`}],+ },+ ],+ ...fields,+ };+}++/**+ * One section of an extension.+ * @param {string} id+ * @param {object} [fields]+ */+function section(id, fields = {}) {+ return {+ id,+ title: id.replace(/-/g, ' '),+ content: [{type: 'prose', text: `Acme ${id}.`}],+ ...fields,+ };+}++/** The installed kit's folder. */+const kitDir = () => path.join(tmpDir, 'node_modules', '@acme', 'kit');++/**+ * A project that configures `@acme/kit`, which ships these docs.+ * @param {Record<string, object>} files+ */+function scaffold(files) {+ fs.writeFileSync(+ path.join(tmpDir, 'package.json'),+ JSON.stringify({name: 'consumer'}),+ );+ fs.writeFileSync(+ path.join(tmpDir, 'astryx.config.mjs'),+ `export default {integrations: ['${KIT}']};\n`,+ );+ fs.mkdirSync(path.join(kitDir(), 'docs'), {recursive: true});+ fs.writeFileSync(+ path.join(kitDir(), 'package.json'),+ JSON.stringify({name: KIT, version: '1.0.0', type: 'module'}),+ );+ fs.writeFileSync(+ path.join(kitDir(), 'astryx.integration.mjs'),+ "export default {docs: './docs'};\n",+ );+ for (const [file, doc] of Object.entries(files)) {+ fs.writeFileSync(+ path.join(kitDir(), 'docs', file),+ `export default ${JSON.stringify(doc, null, 2)};\n`,+ );+ }+}++/** @param {string[]} args */+async function cliText(args) {+ const {status, stdout} = await runCli(args, tmpDir);+ return {status, stdout};+}++/** @param {string[]} args */+async function cliJson(args) {+ const {status, stdout} = await runCli(['--json', ...args], tmpDir);+ return {status, json: JSON.parse(stdout)};+}++beforeEach(() => {+ tmpDir = fs.mkdtempSync(+ path.join(process.cwd(), '.astryx-guide-route-targets-'),+ );+});++afterEach(() => {+ fs.rmSync(tmpDir, {recursive: true, force: true});+});++describe('a flat topic that replaces a placed guide by its route', () => {+ beforeEach(() => {+ scaffold({+ 'quick-start.doc.mjs': topic('quick-start', {replaces: GUIDE}),+ });+ });++ it(+ 'is read at the route, naming its package and the one it replaced',+ async () => {+ const read = await docs(GUIDE, undefined, {cwd: tmpDir});+ expect(Object.keys(read).slice(0, 2)).toEqual(['type', 'package']);+ expect(read).toMatchObject({type: 'docs.detail', package: KIT});+ expect(read.data).toMatchObject({+ name: GUIDE,+ title: 'Acme quick-start',+ replaces: GUIDE,+ replacedPackage: CLI,+ });+ expect(read.data.sections.map(s => [s.id, s.package])).toEqual([+ ['acme-quick-start', KIT],+ ]);++ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index).toMatchObject({type: 'docs.index', package: KIT});+ expect(index.data).toMatchObject({replaces: GUIDE, replacedPackage: CLI});+ expect(index.data.sections.every(s => s.package === KIT)).toBe(true);+ },+ SLOW,+ );++ it(+ 'lists under its own package where its namespace lists the guide',+ async () => {+ const parent = await docs('authoring', undefined, {cwd: tmpDir});+ const child = parent.data.slots+ .flatMap(slot => slot.children)+ .find(each => each.route === GUIDE);+ expect(child).toMatchObject({+ package: KIT,+ replaces: GUIDE,+ replacedPackage: CLI,+ title: 'Acme quick-start',+ });+ const text = await cliText(['docs', 'authoring']);+ expect(text.stdout).toContain(`quick-start (${KIT})`);+ },+ SLOW,+ );++ it(+ 'names both packages in text, the replaced one right after package:',+ async () => {+ for (const args of [+ ['docs', GUIDE],+ ['docs', GUIDE, '--full'],+ ]) {+ const {status, stdout} = await cliText(args);+ expect(status).toBe(0);+ expect(stdout).toMatch(+ new RegExp(+ `package: +${KIT.replace('/', '\\/')}\\s*\\n+replaces ${CLI.replace('/', '\\/')}'s ${GUIDE.replace('/', '\\/')}`,+ ),+ );+ }+ const {json} = await cliJson(['docs', GUIDE, '--full']);+ expect(json).toMatchObject({package: KIT, data: {replacedPackage: CLI}});+ },+ SLOW,+ );++ it(+ 'is an intentional override to doctor integration docs, with no issue',+ async () => {+ const result = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(result.data.findings).toContainEqual(+ expect.objectContaining({+ topic: 'quick-start',+ severity: 'info',+ relationship: 'replaces',+ coreTopic: GUIDE,+ }),+ );+ expect(result.data.issues).toEqual([]);+ },+ SLOW,+ );+});++describe('a flat topic that extends a placed guide by its route', () => {+ /** @param {object[]} sections */+ const extend = sections =>+ scaffold({+ 'quick-start-acme.doc.mjs': topic('quick-start-acme', {+ extends: GUIDE,+ sections,+ }),+ });++ it(+ 'places each section before or after a key, or at the end, naming its package',+ async () => {+ extend([+ section('acme-registry', {before: 'fill-in-package-json'}),+ section('acme-login', {after: 'quick-start'}),+ section('acme-support'),+ // Replaces the guide's section in place, by its key.+ {...section('global-mode'), title: 'In global mode, at Acme'},+ ]);+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index.package).toBe(CLI);+ expect(index.data.replaces).toBeUndefined();+ expect(index.data.sections.map(s => [s.id, s.package])).toEqual([+ ['quick-start', CLI],+ ['acme-login', KIT],+ ['acme-registry', KIT],+ ['fill-in-package-json', CLI],+ ['the-integration-file', CLI],+ ['global-mode', KIT],+ ['acme-support', KIT],+ ]);++ const read = await docs(GUIDE, undefined, {cwd: tmpDir});+ expect(read.package).toBe(CLI);+ expect(read.data.replacedPackage).toBeUndefined();+ // Readers never see the placing fields.+ for (const each of read.data.sections) {+ expect(each).not.toHaveProperty('before');+ expect(each).not.toHaveProperty('after');+ }+ expect(read.data.sections.find(s => s.id === 'acme-login').package).toBe(+ KIT,+ );+ },+ SLOW,+ );++ it(+ 'labels each section it adds once, in text',+ async () => {+ extend([+ section('acme-login', {after: 'quick-start', title: `Log in (${KIT})`}),+ section('acme-support', {title: 'Acme support'}),+ ]);+ const index = await cliText(['docs', GUIDE]);+ expect(index.stdout).toContain(`package: ${CLI}`);+ expect(index.stdout).not.toContain(`replaces ${CLI}`);+ expect(index.stdout).toContain(`Acme support (${KIT})`);+ expect(index.stdout).toContain(`Log in (${KIT})`);+ expect(index.stdout).not.toContain(`(${KIT}) (${KIT})`);+ const full = await cliText(['docs', GUIDE, '--full']);+ expect(full.stdout).toContain(`Acme support (${KIT})`);+ expect(full.stdout).not.toContain(`(${KIT}) (${KIT})`);+ const one = await cliJson(['docs', GUIDE, 'acme-support']);+ expect(one.json).toMatchObject({package: KIT});+ },+ SLOW,+ );++ it(+ 'adds a section whose key names no section at the end, as a listed note',+ async () => {+ extend([section('acme-registry', {before: 'no-such-section'})]);+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index.data.sections.at(-1)).toMatchObject({+ id: 'acme-registry',+ package: KIT,+ });+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(validated.data.issues).toEqual([]);+ expect(validated.data.notes).toContainEqual({+ code: 'doc_section_unplaced',+ message: expect.stringContaining('"no-such-section"'),+ });+ const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(docsCheck.data.issues).toEqual([]);+ expect(docsCheck.data.findings).toContainEqual(+ expect.objectContaining({relationship: 'extends', coreTopic: GUIDE}),+ );+ },+ SLOW,+ );++ it(+ 'places sections in a flat topic it extends the same way',+ async () => {+ scaffold({+ 'theme-acme.doc.mjs': topic('theme-acme', {+ extends: 'theme',+ sections: [+ section('acme-theme', {before: 'creating-a-custom-theme'}),+ ],+ }),+ });+ const index = await docs('theme', undefined, {cwd: tmpDir, index: true});+ const ids = index.data.sections.map(s => s.id);+ expect(ids.indexOf('acme-theme')).toBe(+ ids.indexOf('creating-a-custom-theme') - 1,+ );+ expect(index.data.sections.find(s => s.id === 'acme-theme').package).toBe(+ KIT,+ );+ },+ SLOW,+ );++ it(+ 'refuses a section that sets both before and after, as before',+ async () => {+ extend([+ section('acme-x', {before: 'quick-start', after: 'quick-start'}),+ ]);+ const result = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(result.data.issues).toContainEqual(+ expect.objectContaining({code: 'invalid_doc', severity: 'error'}),+ );+ },+ SLOW,+ );+});++describe('a route that holds no guide', () => {+ it(+ 'changes nothing and fails nothing, as a listed note',+ async () => {+ scaffold({+ 'quick-start.doc.mjs': topic('quick-start', {+ replaces: 'authoring/no-such-guide',+ }),+ });+ const read = await docs(GUIDE, undefined, {cwd: tmpDir});+ expect(read.package).toBe(CLI);++ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(validated.data.issues).toEqual([]);+ expect(validated.data.notes).toContainEqual({+ code: 'doc_target_not_found',+ message: expect.stringContaining('"authoring/no-such-guide"'),+ });+ const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(docsCheck.data.issues).toEqual([]);++ const check = await integrationCheck({cwd: kitDir(), strict: true});+ expect(check.data.failed).toBe(false);+ },+ SLOW,+ );+});++describe('a flat topic that replaces a flat topic', () => {+ it(+ 'names the package it replaced in the list, the index, and text',+ async () => {+ scaffold({+ 'acme-start.doc.mjs': topic('acme-start', {+ replaces: 'getting-started',+ }),+ });+ const listed = await docs(undefined, undefined, {cwd: tmpDir});+ expect(listed.data.find(t => t.topic === 'acme-start')).toMatchObject({+ package: KIT,+ replaces: 'getting-started',+ replacedPackage: CLI,+ });+ const index = await docs('acme-start', undefined, {+ cwd: tmpDir,+ index: true,+ });+ expect(index.data).toMatchObject({+ replaces: 'getting-started',+ replacedPackage: CLI,+ });+ const {stdout} = await cliText(['docs', 'getting-started']);+ expect(stdout).toContain(`replaces ${CLI}'s getting-started`);+ },+ SLOW,+ );+});++describe('a doc that names a namespace instead of a guide', () => {+ it.each(['extends', 'replaces'])(+ 'changes nothing with %s, as a note naming the guides below it',+ async relationship => {+ scaffold({+ 'authoring-acme.doc.mjs': topic('authoring-acme', {+ [relationship]: 'authoring',+ sections: [section('make-it-at-acme')],+ }),+ });+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(validated.data.issues).toEqual([]);+ const note = validated.data.notes?.find(+ each => each.code === 'doc_target_not_found',+ );+ expect(note?.message).toContain('"authoring", which is a namespace');+ expect(note?.message).toContain('authoring/field-reference');+ const check = await integrationCheck({cwd: kitDir(), strict: true});+ expect(check.data.failed).toBe(false);+ },+ SLOW,+ );++ it(+ 'extends a guide below it by its route, labeled with its package',+ async () => {+ scaffold({+ 'authoring-acme.doc.mjs': topic('authoring-acme', {+ extends: 'authoring/field-reference',+ sections: [+ section('make-it-at-acme', {title: 'At Acme: make it in the kit'}),+ ],+ }),+ });+ const read = await docs('authoring/field-reference', 'make-it-at-acme', {+ cwd: tmpDir,+ });+ expect(read).toMatchObject({type: 'docs.detail.section', package: KIT});+ const {stdout} = await cliText(['docs', 'authoring/field-reference']);+ expect(stdout).toContain(`At Acme: make it in the kit (${KIT})`);+ const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(docsCheck.data.findings).toContainEqual(+ expect.objectContaining({+ relationship: 'extends',+ coreTopic: 'authoring/field-reference',+ }),+ );+ },+ SLOW,+ );+});++describe('a route that moved', () => {+ it(+ 'applies to the guide at the route it moved to',+ async () => {+ scaffold({+ 'quick-start.doc.mjs': topic('quick-start', {+ replaces: 'cli/integrations/quick-start',+ }),+ });+ const read = await docs(GUIDE, undefined, {cwd: tmpDir});+ expect(read).toMatchObject({+ package: KIT,+ data: {replaces: GUIDE, replacedPackage: CLI},+ });+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index.data.replaces).toBe(GUIDE);+ const {stdout} = await cliText(['docs', GUIDE, '--full']);+ expect(stdout).toContain(`replaces ${CLI}'s ${GUIDE}`);+ expect(stdout).not.toContain('cli/integrations');+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(+ (validated.data.notes ?? []).filter(n => n.code.startsWith('doc_')),+ ).toEqual([]);+ },+ SLOW,+ );+});++describe('review follow-ups', () => {+ it('keeps the authored order of sections placed after one key', () => {+ const merged = mergeTopic(+ {+ sections: [+ {id: 'a', title: 'A', content: []},+ {id: 'b', title: 'B', content: []},+ ],+ },+ {+ sections: [+ {id: 'first', title: 'First', after: 'a', content: []},+ {id: 'second', title: 'Second', after: 'a', content: []},+ {id: 'zero', title: 'Zero', before: 'b', content: []},+ ],+ },+ );+ expect(merged.sections.map(each => each.id)).toEqual([+ 'a',+ 'first',+ 'second',+ 'zero',+ 'b',+ ]);+ });++ it(+ 'never reads back before or after, on a doc that extends nothing',+ async () => {+ scaffold({+ 'plain.doc.mjs': topic('plain', {+ sections: [section('only', {after: 'nothing'})],+ }),+ });+ const read = await docs('plain', undefined, {cwd: tmpDir});+ expect(read.data.sections[0]).not.toHaveProperty('after');+ },+ SLOW,+ );++ it(+ 'names the replacing and extending packages in search, as reads do',+ async () => {+ scaffold({+ 'quick-start.doc.mjs': topic('quick-start', {+ replaces: GUIDE,+ sections: [section('acme-zebra-registry')],+ }),+ 'field-ref.doc.mjs': topic('field-ref', {+ extends: 'authoring/field-reference',+ sections: [section('acme-walrus-login')],+ }),+ });+ for (const [query, route] of [+ ['acme zebra registry', GUIDE],+ ['acme walrus login', 'authoring/field-reference'],+ ]) {+ const found = await search(query, {cwd: tmpDir, type: 'doc'});+ // The best hit is the integration's text, at the guide's route.+ expect(found.data.results[0]).toMatchObject({+ name: route,+ package: KIT,+ });+ }+ },+ SLOW,+ );++ it(+ 'checks the links in a doc that targets a guide by its route',+ async () => {+ scaffold({+ 'field-ref.doc.mjs': topic('field-ref', {+ extends: 'authoring/field-reference',+ sections: [+ {+ id: 'acme-link',+ title: 'Acme link',+ content: [+ {type: 'prose', text: 'See {@link generic:no-such-acme-doc}.'},+ ],+ },+ ],+ }),+ });+ const result = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(result.data.issues).toContainEqual(+ expect.objectContaining({+ code: 'invalid_doc_graph',+ message: expect.stringContaining('no-such-acme-doc'),+ }),+ );+ },+ SLOW,+ );++ it(+ 'lets the later of two replacements of one guide win, failing nothing',+ async () => {+ const catalog = DocsCatalog.fromBuiltins();+ const record = (/** @type {string} */ pkg) => ({+ name: `${pkg.split('/')[1]}-start`,+ package: pkg,+ path: `/x/${pkg}.doc.mjs`,+ replaces: GUIDE,+ });+ expect(catalog.add(record('@acme/one'))).toBeNull();+ expect(catalog.add(record('@acme/two'))).toBeNull();+ expect(catalog.guideOverlay(GUIDE)).toMatchObject({+ replacement: {package: '@acme/two'},+ replacedPackage: '@acme/one',+ });++ scaffold({+ 'a.doc.mjs': topic('acme-a', {replaces: GUIDE}),+ 'b.doc.mjs': topic('acme-b', {replaces: GUIDE}),+ });+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(validated.data.issues).toEqual([]);+ expect(validated.data.notes).toContainEqual({+ code: 'duplicate_guide_replacement',+ message: expect.stringContaining('"acme-b", is read'),+ });+ const check = await integrationCheck({cwd: kitDir(), strict: true});+ expect(check.data.failed).toBe(false);+ },+ SLOW,+ );+});++describe('second review follow-ups', () => {+ it(+ 'names the earlier replacer in the namespace listing too',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {replaces: GUIDE}),+ 'b.doc.mjs': topic('acme-b', {replaces: GUIDE}),+ });+ const parent = await docs('authoring', undefined, {cwd: tmpDir});+ const child = parent.data.slots+ .flatMap(slot => slot.children)+ .find(each => each.route === GUIDE);+ const read = await docs(GUIDE, undefined, {cwd: tmpDir});+ expect(child?.replacedPackage).toBe(read.data.replacedPackage);+ expect(child?.title).toBe('Acme acme-b');+ },+ SLOW,+ );++ it(+ 'stacks docs that name a guide by its old and its new route, in order',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ replaces: 'cli/integrations/quick-start',+ }),+ 'b.doc.mjs': topic('acme-b', {+ extends: GUIDE,+ sections: [section('acme-extra')],+ }),+ });+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index.data.sections.map(each => each.id)).toEqual([+ 'acme-acme-a',+ 'acme-extra',+ ]);+ },+ SLOW,+ );++ it(+ 'lets a later replacement by the old route drop an earlier extension',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ extends: GUIDE,+ sections: [section('acme-extra')],+ }),+ 'b.doc.mjs': topic('acme-b', {+ replaces: 'cli/integrations/quick-start',+ }),+ });+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index.data.sections.map(each => each.id)).toEqual(['acme-acme-b']);+ },+ SLOW,+ );++ it('asks a package that places sections for a CLI that reads before and after', () => {+ expect(+ sectionPositionCliProblem({+ peerDependencies: {'@astryxdesign/cli': '>=0.6.0'},+ }),+ ).toContain('`before` or `after`');+ expect(+ sectionPositionCliProblem({+ peerDependencies: {'@astryxdesign/cli': '>=0.7.4'},+ }),+ ).toBeNull();+ });+});++describe('third review follow-ups', () => {+ /**+ * A project that configures two kits, each with these docs.+ * @param {Record<string, object>} one+ * @param {Record<string, object>} two+ */+ function scaffoldTwo(one, two) {+ scaffold(one);+ fs.writeFileSync(+ path.join(tmpDir, 'astryx.config.mjs'),+ `export default {integrations: ['${KIT}', '@acme/more']};\n`,+ );+ const dir = path.join(tmpDir, 'node_modules', '@acme', 'more');+ fs.mkdirSync(path.join(dir, 'docs'), {recursive: true});+ fs.writeFileSync(+ path.join(dir, 'package.json'),+ JSON.stringify({name: '@acme/more', version: '1.0.0', type: 'module'}),+ );+ fs.writeFileSync(+ path.join(dir, 'astryx.integration.mjs'),+ "export default {docs: './docs'};\n",+ );+ for (const [file, doc] of Object.entries(two)) {+ fs.writeFileSync(+ path.join(dir, 'docs', file),+ `export default ${JSON.stringify(doc, null, 2)};\n`,+ );+ }+ }++ it(+ 'keeps configured order for sections two packages place after one key',+ async () => {+ scaffoldTwo(+ {+ 'a.doc.mjs': topic('acme-a', {+ extends: GUIDE,+ sections: [section('acme-first', {after: 'quick-start'})],+ }),+ },+ {+ 'b.doc.mjs': topic('acme-b', {+ extends: GUIDE,+ sections: [section('acme-second', {after: 'quick-start'})],+ }),+ },+ );+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(+ index.data.sections.slice(0, 3).map(s => [s.id, s.package]),+ ).toEqual([+ ['quick-start', CLI],+ ['acme-first', KIT],+ ['acme-second', '@acme/more'],+ ]);+ },+ SLOW,+ );++ it(+ 'notes one package replacing a guide by its old and its new route',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ replaces: 'cli/integrations/quick-start',+ }),+ 'b.doc.mjs': topic('acme-b', {replaces: GUIDE}),+ });+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(validated.data.notes).toContainEqual({+ code: 'duplicate_guide_replacement',+ message: expect.stringContaining('"acme-b", is read'),+ });+ },+ SLOW,+ );+});++describe('fourth review follow-ups', () => {+ /**+ * Add another configured package that ships these docs.+ * @param {string} pkg+ * @param {Record<string, object>} files+ */+ function addPackage(pkg, files) {+ const config = path.join(tmpDir, 'astryx.config.mjs');+ const listed = fs.readFileSync(config, 'utf8').match(/\[(.*)\]/)?.[1] ?? '';+ fs.writeFileSync(+ config,+ `export default {integrations: [${listed}, '${pkg}']};\n`,+ );+ const dir = path.join(tmpDir, 'node_modules', ...pkg.split('/'));+ fs.mkdirSync(path.join(dir, 'docs'), {recursive: true});+ fs.writeFileSync(+ path.join(dir, 'package.json'),+ JSON.stringify({name: pkg, version: '1.0.0', type: 'module'}),+ );+ fs.writeFileSync(+ path.join(dir, 'astryx.integration.mjs'),+ "export default {docs: './docs'};\n",+ );+ for (const [file, doc] of Object.entries(files)) {+ fs.writeFileSync(+ path.join(dir, 'docs', file),+ `export default ${JSON.stringify(doc, null, 2)};\n`,+ );+ }+ }++ it(+ 'keeps the place of a placed section that a later package replaces',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ extends: GUIDE,+ sections: [section('acme-first', {after: 'quick-start'})],+ }),+ });+ addPackage('@acme/two', {+ 'b.doc.mjs': topic('acme-b', {+ extends: GUIDE,+ sections: [{...section('acme-first'), title: 'First, revised'}],+ }),+ });+ addPackage('@acme/three', {+ 'c.doc.mjs': topic('acme-c', {+ extends: GUIDE,+ sections: [section('acme-third', {after: 'quick-start'})],+ }),+ });+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(+ index.data.sections.slice(0, 3).map(s => [s.id, s.package]),+ ).toEqual([+ ['quick-start', CLI],+ ['acme-first', '@acme/two'],+ ['acme-third', '@acme/three'],+ ]);+ },+ SLOW,+ );+});++describe('fifth review follow-ups', () => {+ it(+ 'does not call a route replacement named like a CLI topic an accidental conflict',+ async () => {+ scaffold({+ 'getting-started.doc.mjs': topic('getting-started', {replaces: GUIDE}),+ });+ const result = await integrationDocConflicts(KIT, {cwd: tmpDir});+ expect(result.data.issues).toEqual([]);+ expect(+ result.data.findings.filter(each => each.relationship === 'accidental'),+ ).toEqual([]);+ const listed = await docs(undefined, undefined, {cwd: tmpDir});+ expect(+ listed.data.find(each => each.topic === 'getting-started')?.package,+ ).toBe(CLI);+ },+ SLOW,+ );++ it(+ 'names what a topic replaced twice took over the same way in every read',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {replaces: 'getting-started'}),+ 'b.doc.mjs': topic('acme-b', {replaces: 'getting-started'}),+ });+ const listed = await docs(undefined, undefined, {cwd: tmpDir});+ const item = listed.data.find(each => each.topic === 'acme-b');+ const index = await docs('acme-b', undefined, {cwd: tmpDir, index: true});+ const read = await docs('acme-b', undefined, {cwd: tmpDir});+ expect(index.data.replaces).toBe(item?.replaces);+ expect(read.data.replaces).toBe(item?.replaces);+ expect(read.data.replacedPackage).toBe(item?.replacedPackage);+ },+ SLOW,+ );+});++describe('whole-diff self-review', () => {+ it('keeps a chain of after placements in order across packages', () => {+ let doc = {+ sections: [+ {id: 'x', title: 'X', content: []},+ {id: 'y', title: 'Y', content: []},+ ],+ };+ for (const overlay of [+ {sections: [{id: 'first', title: 'First', after: 'x', content: []}]},+ {sections: [{id: 'second', title: 'Second', after: 'x', content: []}]},+ {+ sections: [+ {+ id: 'under-first',+ title: 'Under first',+ after: 'first',+ content: [],+ },+ ],+ },+ {+ sections: [+ {+ id: 'before-second',+ title: 'Before second',+ before: 'second',+ content: [],+ },+ ],+ },+ {sections: [{id: 'last', title: 'Last', after: 'x', content: []}]},+ ]) {+ doc = mergeTopic(doc, overlay);+ }+ expect(doc.sections.map((/** @type {any} */ each) => each.id)).toEqual([+ 'x',+ 'first',+ 'under-first',+ 'before-second',+ 'second',+ 'last',+ 'y',+ ]);+ });++ it(+ 'counts a key an earlier doc of the package adds as a section of the guide',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ extends: GUIDE,+ sections: [section('acme-x', {after: 'quick-start'})],+ }),+ 'b.doc.mjs': topic('acme-b', {+ extends: GUIDE,+ sections: [section('acme-y', {after: 'acme-x'})],+ }),+ });+ const index = await docs(GUIDE, undefined, {cwd: tmpDir, index: true});+ expect(index.data.sections.slice(0, 3).map(s => s.id)).toEqual([+ 'quick-start',+ 'acme-x',+ 'acme-y',+ ]);+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(+ (validated.data.notes ?? []).filter(+ n => n.code === 'doc_section_unplaced',+ ),+ ).toEqual([]);+ },+ SLOW,+ );++ it(+ 'still notes a key no doc of the target adds, with earlier extensions merged',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ extends: GUIDE,+ sections: [section('acme-x', {after: 'quick-start'})],+ }),+ 'b.doc.mjs': topic('acme-b', {+ extends: GUIDE,+ sections: [section('acme-y', {after: 'acme-nope'})],+ }),+ });+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ expect(+ (validated.data.notes ?? []).filter(+ n => n.code === 'doc_section_unplaced',+ ),+ ).toEqual([+ expect.objectContaining({+ message: expect.stringContaining('"acme-nope"'),+ }),+ ]);+ },+ SLOW,+ );+});++describe('old routes in messages', () => {+ it(+ 'names the guide at its route now in notes and doctor findings',+ async () => {+ scaffold({+ 'a.doc.mjs': topic('acme-a', {+ extends: 'cli/integrations/quick-start',+ sections: [section('acme-x', {after: 'acme-nope'})],+ }),+ });+ const validated = await validateIntegration(KIT, {cwd: tmpDir});+ const note = (validated.data.notes ?? []).find(+ n => n.code === 'doc_section_unplaced',+ );+ expect(note?.message).toContain(`docs ${GUIDE} --index`);+ expect(note?.message).not.toContain('cli/integrations');+ const result = await integrationDocConflicts(KIT, {cwd: tmpDir});+ const finding = result.data.findings.find(f => f.topic === 'acme-a');+ expect(finding).toMatchObject({+ relationship: 'extends',+ coreTopic: GUIDE,+ });+ expect(finding?.message).not.toContain('cli/integrations');+ },+ SLOW,+ );+});diff --git a/packages/cli/api/docs/index/index.mjs b/packages/cli/api/docs/index/index.mjsindex 9595d20686..51bb61c000 100644--- a/packages/cli/api/docs/index/index.mjs+++ b/packages/cli/api/docs/index/index.mjs@@ -35,6 +35,15 @@ export async function index(topic, options = {}) {...view,// A guide the docs tree places is read by its route, not its doc name.name: entry.tree ? entry.name : view.name,+ // What it took the place of, and whose that was (INV28).+ ...(entry.replaces != null+ ? {+ replaces: entry.replaces,+ ...(entry.replacedPackage != null+ ? {replacedPackage: entry.replacedPackage}+ : {}),+ }+ : {}),// Each section names the package that wrote it: the topic's own, or an// extension's.sections: view.sections.map(s => ({diff --git a/packages/cli/api/docs/list/list.mjs b/packages/cli/api/docs/list/list.mjsindex 39d5c6fa23..c1b6aa288c 100644--- a/packages/cli/api/docs/list/list.mjs+++ b/packages/cli/api/docs/list/list.mjs@@ -52,7 +52,13 @@ export async function list({cwd} = {}) {),package: entry.package,};- if (entry.replaces != null) listed.replaces = entry.replaces;+ if (entry.replaces != null) {+ listed.replaces = entry.replaces;+ // INV28: the package whose topic it replaced, beside its own.+ if (entry.replacedPackage != null) {+ listed.replacedPackage = entry.replacedPackage;+ }+ }entries.push(listed);}// The docs tree's top-level namespaces, the CLI's and each integration's,diff --git a/packages/cli/api/docs/node/node.mjs b/packages/cli/api/docs/node/node.mjsindex 3c4219e77f..65810eda45 100644--- a/packages/cli/api/docs/node/node.mjs+++ b/packages/cli/api/docs/node/node.mjs@@ -94,7 +94,15 @@ function childIdentity(child) {return {route: child.route,name: child.route.slice(child.route.lastIndexOf('/') + 1),- package: child.provider,+ package: child.guideOverlay?.replacement?.package ?? child.provider,+ // A guide an integration's doc took the place of names whose it was.+ ...(child.guideOverlay?.replacement+ ? {+ replaces: child.route,+ replacedPackage:+ child.guideOverlay.replacedPackage ?? child.provider,+ }+ : {}),kind: child.kind,title: child.title,summary: child.summary,diff --git a/packages/cli/api/integration/_adapter.mjs b/packages/cli/api/integration/_adapter.mjsindex 21a87b78cd..ffabbfcb6d 100644--- a/packages/cli/api/integration/_adapter.mjs+++ b/packages/cli/api/integration/_adapter.mjs@@ -16,6 +16,7 @@ import {integrationSourceForDoc,} from '../../foundation/discovery/component-discovery.mjs';import {discoverIntegrationDocs} from '../../foundation/discovery/docs-discovery.mjs';+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';@@ -114,6 +115,30 @@ export async function integrationStrayPointers(discovered, integration) {return findStrayPointers({...discovered, components});}+/**+ * What each doc in one integration's docs replaces or extends, read against+ * the CLI's docs and the package's own (see `packageDocTargets`); empty when+ * the docs do not load, which other checks report.+ * @param {any} integration a loaded integration+ * @returns {Promise<import('../docs/_adapter.mjs').DocTarget[]>}+ */+export async function integrationDocTargets(integration) {+ let discovered;+ try {+ discovered = await discoverIntegrationDocs(integration);+ } catch {+ return [];+ }+ // A doc that does not load is an issue already; its targets are not read.+ if (discovered.errors.length > 0) return [];+ try {+ return await packageDocTargets(integration, discovered);+ } catch {+ // A package whose docs cannot form a tree is reported by the docs check.+ return [];+ }+}+/*** Each Astryx command a package's topics write with a package runner. A* package whose topics cannot be discovered has none here: the other checksdiff --git a/packages/cli/api/integration/authoring-checks.mjs b/packages/cli/api/integration/authoring-checks.mjsindex 81866b02c5..12549a0e3a 100644--- a/packages/cli/api/integration/authoring-checks.mjs+++ b/packages/cli/api/integration/authoring-checks.mjs@@ -22,6 +22,7 @@ import path from 'node:path';import {getCliInvocation} from '../../foundation/env/package-manager.mjs';import {packageComponentLinkProblems,+ packageDocTargets,packageDocsProblems,packageReferenceProblems,} from '../docs/_adapter.mjs';@@ -38,8 +39,10 @@ import {integrationStrayPointers,} from './_adapter.mjs';import {+ BUILTIN_DOCS_PACKAGE,discoverBuiltinTopics,discoverIntegrationDocs,+ isGuideRoute,} from '../../foundation/discovery/docs-discovery.mjs';import {applyTemplateReplacements,@@ -489,11 +492,14 @@ export async function integrationDocConflicts(pkg, options = {}) {});}- // An extension never owns its own name. A replacement does, so it may only- // reuse a Core name when that is the Core topic it explicitly replaces.+ // An extension never owns its own name, and neither does a doc that+ // replaces a guide by its route: readers open the route. A topic+ // replacement does, so it may only reuse a Core name when that is the+ // Core topic it explicitly replaces.if (sameNameCore != null &&record.extendsTopic == null &&+ !isGuideRoute(record.replaces) &&replacedCore !== sameNameCore) {findings.push({@@ -507,6 +513,27 @@ export async function integrationDocConflicts(pkg, options = {}) {});}}+ // A doc that replaces or extends one of the CLI's guides by its route is+ // as intentional as one that names a Core topic.+ if (errors.length === 0) {+ for (const target of await packageDocTargets(+ /** @type {{name: string}} */ (docsIntegration),+ discovered,+ )) {+ if (target.kind !== 'guide' || target.owner !== BUILTIN_DOCS_PACKAGE) {+ continue;+ }+ // A route the guide moved from names the guide at its route now.+ const route = target.guide ?? target.target;+ findings.push({+ topic: target.topic,+ severity: 'info',+ relationship: target.relationship,+ coreTopic: route,+ message: `Intentional ${target.relationship === 'replaces' ? 'override' : 'extension'}: "${target.topic}" ${target.relationship} the CLI guide "${route}".`,+ });+ }+ }findings.sort((a, b) =>`${a.topic}:${a.relationship}`.localeCompare(`${b.topic}:${b.relationship}`,diff --git a/packages/cli/api/integration/pack-check.mjs b/packages/cli/api/integration/pack-check.mjsindex 604fdd2c6c..ee3f8d942d 100644--- a/packages/cli/api/integration/pack-check.mjs+++ b/packages/cli/api/integration/pack-check.mjs@@ -37,6 +37,7 @@ import {keywordsCliProblem,replacesCliProblem,sectionIdsCliProblem,+ sectionPositionCliProblem,themesCliProblem,} from '../../foundation/integrations/cli-requirement.mjs';import {@@ -328,13 +329,27 @@ function extractTarball(tgzPath, extractDir) {* @returns {Promise<boolean>}*/async function setsSectionIds(files) {+ return setsSectionField(files, ['id']);+}++/**+ * Whether any of these doc files has a section that sets one of `fields`.+ * @param {string[]} files+ * @param {string[]} fields+ * @returns {Promise<boolean>}+ */+async function setsSectionField(files, fields) {for (const file of files) {if (typeof file !== 'string') continue;const doc = /** @type {any} */ (await loadTopicModule(file).catch(() => null));const sections = Array.isArray(doc?.sections) ? doc.sections : [];- if (sections.some((/** @type {any} */ section) => section?.id != null)) {+ if (+ sections.some((/** @type {any} */ section) =>+ fields.some(field => section?.[field] != null),+ )+ ) {return true;}}@@ -1383,6 +1398,22 @@ export async function integrationPackCheck(options = {}) {issues.push(error('section_ids_need_cli', idProblem));}}+ // `before` and `after` need a newer CLI than any field above. Added in a+ // patch release, it warns and never fails the check (INV35).+ if (+ await setsSectionField(+ [+ ...records.map(record => record.path),+ ...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),+ ],+ ['before', 'after'],+ )+ ) {+ const positionProblem = sectionPositionCliProblem(pkg);+ if (positionProblem != null) {+ issues.push(warning('section_position_needs_cli', positionProblem));+ }+ }}// 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 f83a16476a..46f471daca 100644--- a/packages/cli/api/integration/pack-check.test.mjs+++ b/packages/cli/api/integration/pack-check.test.mjs@@ -1724,6 +1724,39 @@ describe('integrationPackCheck', () => {expect(await codes()).not.toContain('section_ids_need_cli');}, 120_000);+ it('warns, without failing, when a doc section sets before or after on a CLI range that rejects them', async () => {+ writePackage({+ manifest: "export default {docs: './docs'};\n",+ themes: false,+ });+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});+ const pkgFile = path.join(tmpDir, 'package.json');+ const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);+ const issues = async () =>+ (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(+ (/** @type {{code: string}} */ issue) =>+ issue.code === 'section_position_needs_cli',+ );+ // A placed guide's section counts too: an older CLI rejects the field in+ // any doc and hides the package's topics.+ fs.writeFileSync(+ path.join(tmpDir, 'docs', 'acme.doc.mjs'),+ "export default {type: 'namespace', name: 'acme', title: 'Acme', summary: 'Acme.', slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}}};\n",+ );+ fs.writeFileSync(+ path.join(tmpDir, 'docs', 'setup.doc.mjs'),+ "export default {type: 'generic', name: 'setup', title: 'Setup', description: 'Set up.', placement: {parent: 'namespace:acme', slot: 'guides'}, sections: [{id: 'overview', title: 'Overview', after: 'nothing', content: [{type: 'prose', text: 'Set up.'}]}]};\n",+ );+ expect(await issues()).toEqual([+ expect.objectContaining({severity: 'warning'}),+ ]);+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);+ expect(await issues()).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.mjs b/packages/cli/api/integration/validate-integration.mjsindex f80348b67c..175ec4e261 100644--- a/packages/cli/api/integration/validate-integration.mjs+++ b/packages/cli/api/integration/validate-integration.mjs@@ -37,7 +37,10 @@ import {assertWithin} from '../../foundation/fs/path-safety.mjs';import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';import {integrationDocTypes} from '../docs/_adapter.mjs';import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';-import {integrationRunnerCommands} from './_adapter.mjs';+import {+ integrationDocTargets,+ integrationRunnerCommands,+} from './_adapter.mjs';import {THEME_SLUG_RE,unreadThemeFolders,@@ -77,6 +80,15 @@ import {runChoice} from '../../foundation/release/run-context.mjs';/** The running CLI is outside the package's `@astryxdesign/cli` peer range. */const CLI_PEER_VERSION = 'cli_peer_version';+/** A doc replaces or extends a name that holds no topic and no guide. */+const DOC_TARGET_NOT_FOUND = 'doc_target_not_found';++/** An extension section's `before` or `after` names no section of the base. */+const DOC_SECTION_UNPLACED = 'doc_section_unplaced';++/** Two docs of one package replace one guide; only the last one is read. */+const DUPLICATE_GUIDE_REPLACEMENT = 'duplicate_guide_replacement';+export {validateLoadedIntegration, isListedIssue};/**@@ -703,6 +715,58 @@ async function runnerCommandNotes(integration) {}));}+/**+ * The notes for docs that replace or extend a topic or a guide the docs tree+ * places, or place an extension's section with `before` or `after`: a name+ * that holds neither (such as a namespace) applies nothing, and a key that+ * names no section adds the section at the end. Each is listed, failing nothing, until+ * the next minor release (architecture:cli-surface INV35).+ * @param {any} integration a loaded integration+ * @returns {Promise<Array<{code: string, message: string}>>}+ */+async function docTargetNotes(integration) {+ /** @type {Array<{code: string, message: string}>} */+ const notes = [];+ const targets = await integrationDocTargets(integration);+ /** @type {Map<string, string[]>} lowercased route → the docs replacing it */+ const replacers = new Map();+ for (const each of targets) {+ if (each.kind !== 'guide' || each.relationship !== 'replaces') continue;+ // An old route and the new one name one guide.+ const key = each.guide ?? each.target.toLowerCase();+ replacers.set(key, [...(replacers.get(key) ?? []), each.topic]);+ }+ for (const [route, topics] of replacers) {+ if (topics.length < 2) continue;+ notes.push({+ code: DUPLICATE_GUIDE_REPLACEMENT,+ message: `"${topics.join('", "')}" all replace the guide "${route}", and only the last, "${topics.at(-1)}", is read. Fix: keep one replacement, or make the others extend it.`,+ });+ }+ for (const each of targets) {+ if (each.kind === 'namespace') {+ const shown = each.guidesBelow.slice(0, 8);+ const more = each.guidesBelow.length - shown.length;+ notes.push({+ code: DOC_TARGET_NOT_FOUND,+ message: `"${each.topic}" ${each.relationship} "${each.target}", which is a namespace of the docs tree: it holds no sections to ${each.relationship === 'replaces' ? 'replace' : 'extend'}, so this changes nothing. Fix: name the route of a guide below it${shown.length > 0 ? `: ${shown.join(', ')}${more > 0 ? `, and ${more} more` : ''}` : ''}.`,+ });+ } else if (each.kind == null) {+ notes.push({+ code: DOC_TARGET_NOT_FOUND,+ message: `"${each.topic}" ${each.relationship} "${each.target}", which is neither a topic nor a guide of the CLI's docs or this package's own: it changes nothing unless an app also installs a package that provides it. Fix: if it should name one of those, name a topic as \`${formatCliCommand('docs')}\` lists it, or a guide's route as \`${formatCliCommand('docs authoring --depth all')}\` or \`${formatCliCommand('docs cli --depth all')}\` lists it.`,+ });+ }+ for (const {section, field, key} of each.unplaced) {+ notes.push({+ code: DOC_SECTION_UNPLACED,+ message: `Section "${section}" of "${each.topic}" goes ${field} "${key}", which is no section of "${each.guide ?? each.target}", so it is added at the end. Fix: use a key \`${formatCliCommand(`docs ${each.guide ?? each.target} --index`)}\` lists.`,+ });+ }+ }+ return notes;+}+/*** Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one* (`pkg` given) and return the `integration.validate` envelope. The no-manifest@@ -757,6 +821,7 @@ export async function validateIntegration(pkg, options = {}) {// `runner_command` note with its fix, the same way.if (integration?.docs) {notes.push(...(await runnerCommandNotes(integration)));+ notes.push(...(await docTargetNotes(integration)));}return {type: 'integration.validate',diff --git a/packages/cli/api/integration/validateIntegration.doc.mjs b/packages/cli/api/integration/validateIntegration.doc.mjsindex d03876794b..6981dc5403 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. 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} 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.",},],examples: [diff --git a/packages/cli/api/search/_gather-docs.mjs b/packages/cli/api/search/_gather-docs.mjsindex 07d150bf43..e3ccafba08 100644--- a/packages/cli/api/search/_gather-docs.mjs+++ b/packages/cli/api/search/_gather-docs.mjs@@ -7,6 +7,7 @@import {guideEntry,+ sectionPackageOf,loadDocsCatalog,lowerTopic,projectTree,@@ -104,9 +105,17 @@ export async function gatherDocs(cwd) {// A tree hit names where it lives: its ancestors' titles, then its own.const path = [...tree.ancestors(node).map(a => a.title), node.title];if (node.kind === 'generic') {+ // A guide an integration replaced or extended names the package that+ // wrote it, and each section the package that wrote that section, as+ // reads do (INV28).+ const entry = guideEntry(node);let doc = null;+ /** @type {((key: string) => string) | undefined} */+ let sectionPackage;try {- doc = (await lowerTopic(catalog, guideEntry(node))).doc;+ const lowered = await lowerTopic(catalog, entry);+ doc = lowered.doc;+ sectionPackage = sectionPackageOf(entry, lowered);} catch {// As above: the owning commands report it.}@@ -118,7 +127,8 @@ export async function gatherDocs(cwd) {node.summary,path.join(' › '),node.parent == null ? undefined : `astryx docs ${node.parent}`,- node.provider,+ entry.package,+ sectionPackage,),);continue;diff --git a/packages/cli/assets/docs/tree/extend-or-replace.doc.mjs b/packages/cli/assets/docs/tree/extend-or-replace.doc.mjsindex fc45c193ce..6b5b3efd65 100644--- a/packages/cli/assets/docs/tree/extend-or-replace.doc.mjs+++ b/packages/cli/assets/docs/tree/extend-or-replace.doc.mjs@@ -2,8 +2,9 @@/*** @file `astryx docs authoring/building-blocks/docs/extend-or-replace`:- * take over an existing topic with `replaces`, merge sections into one with- * `extends`, and check overlaps with Core topics.+ * take over an existing topic or guide with `replaces`, merge sections into+ * one with `extends` (placing each with `before` or `after`), and check+ * overlaps with Core topics.*//** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */@@ -13,7 +14,7 @@ export const docs = {placement: {parent: 'namespace:docs', slot: 'guides', order: 40},title: 'Extend or replace a topic',category: 'guide',- description: 'Take over a topic, or merge sections into it.',+ description: 'Take over a topic or guide, or merge sections into it.',sections: [{id: 'replace-a-topic',@@ -63,7 +64,8 @@ export const docs = {type: 'list',style: 'unordered',items: [- "Read the base topic's keys with `--index`, and give a section that replaces one that key as its `id`. A section without an `id` matches only a base section with exactly its title, or one whose `id` is the key its title makes, so `Integration Themes` is added beside a base `Integration themes` that has no `id`.",+ "Read the base topic's keys with `--index`, and give a section that replaces one that key as its `id`. A section that replaces one keeps its place. A section without an `id` matches only a base section with exactly its title, or one whose `id` is the key its title makes, so `Integration Themes` is added beside a base `Integration themes` that has no `id`.",+ "Set `before` or `after` to a base section's key to add a new section there instead of at the end. A key that names no section adds it at the end, and `astryx doctor integration validate` lists a note. An older CLI rejects these fields, so declare an `@astryxdesign/cli` peer range that starts at the release that reads them; `astryx integration verify` warns without it.","The topic keeps the base's title and description, and readers open it by the base's name.",'Replace the `Overview` placeholder that `integration add` writes, or it is added to the base topic.',"Extend a topic to correct or add to it. A copy made with `replaces` stops getting the owner's fixes.",@@ -71,6 +73,36 @@ export const docs = {},],},+ {+ id: 'replace-or-extend-a-cli-guide',+ title: 'Replace or extend a CLI guide',+ content: [+ {+ type: 'prose',+ text: "A guide in the CLI's docs tree has a route rather than a topic name. Set `replaces` or `extends` to that route to change the guide for every app that installs your package: say what differs for your users on the page agents already read.",+ },+ {+ type: 'code',+ lang: 'javascript',+ label: 'docs/acme-quick-start.doc.mjs',+ code: "export default {\n type: 'generic',\n name: 'acme-quick-start',\n extends: 'authoring/quick-start',\n title: 'Acme quick start',\n description: 'What differs when you build integrations at Acme.',\n sections: [\n {id: 'use-the-acme-registry', title: 'Use the Acme registry', before: 'fill-in-package-json', content: [/* ... */]},\n ],\n};",+ },+ {+ type: 'list',+ style: 'unordered',+ items: [+ 'Your doc stays a flat topic: do not give it a `placement`. Readers open the guide by its route, never by your `name`.',+ 'With `replaces`, readers of the route get your doc, under your package. With `extends`, each section you add or replace names your package.',+ 'A name that holds no topic or guide, such as a namespace, changes nothing; `astryx doctor integration validate` lists it as a note, with the guides below a namespace.',+ ],+ },+ {+ type: 'code',+ lang: 'bash',+ code: '# Every guide route, by namespace\nastryx docs authoring --depth all\nastryx docs cli --depth all\n# The keys to place sections by\nastryx docs authoring/quick-start --index',+ },+ ],+ },{id: 'check-overlaps-with-core-topics',title: 'Check overlaps with Core topics',diff --git a/packages/cli/authoring/doctypes/_schema.mjs b/packages/cli/authoring/doctypes/_schema.mjsindex bb332cef97..1a17ce4b53 100644--- a/packages/cli/authoring/doctypes/_schema.mjs+++ b/packages/cli/authoring/doctypes/_schema.mjs@@ -240,6 +240,10 @@ const ReferenceSectionSchema = ztitle: nonEmptyString,category: z.string().optional(),content: z.array(SectionContentBlockSchema),+ // Where an extension adds this section to the topic it extends: before+ // or after the section with this key. Ignored on any other section.+ before: nonEmptyString.optional(),+ after: nonEmptyString.optional(),previewType: z.enum(['swatch',diff --git a/packages/cli/authoring/doctypes/reference/type.ts b/packages/cli/authoring/doctypes/reference/type.tsindex f1a064af37..96e8291ed6 100644--- a/packages/cli/authoring/doctypes/reference/type.ts+++ b/packages/cli/authoring/doctypes/reference/type.ts@@ -137,12 +137,16 @@ export interface ReferenceDoc extends AuthoredDocGraphFields {* `replaces: 'getting-started'` on a doc named `getting-started` swaps the* content, and on a doc named something else swaps it and leaves the old* name as an alias, so `astryx docs getting-started` still resolves.+ * A route (`'authoring/quick-start'`) names a guide the docs tree+ * places: readers who open that route get this doc.* Ignored on a built-in topic (there is nothing above it to replace). */replaces?: string;/** Name of an existing topic this doc merges onto, section by section: a* section whose title matches one in the base replaces it, and a section- * the base does not have is appended. For correcting or adding to a topic- * rather than owning it — `replaces` and `extends` are exclusive. */+ * the base does not have is added where its `before` or `after` says, else+ * at the end. A route (`'authoring/quick-start'`) names a guide the+ * docs tree places. For correcting or adding to a topic rather than owning+ * it — `replaces` and `extends` are exclusive. */extends?: string;/** Ordered sections that make up the doc. */sections: ReferenceSection[];@@ -170,6 +174,14 @@ export interface ReferenceSection {* `reference` block includes another doc from its canonical source, so a* guide never copies a schema's fields or a command's options. */content: (ReferenceContentBlock | ReferenceDocBlock)[];+ /** In a doc that `extends` a topic, the key of the base section (as+ * `astryx docs <topic> --index` shows it) to add this section before,+ * when it replaces none. Set `before` or `after`, not both; with neither,+ * the section is added at the end. Ignored on any other doc. */+ before?: string;+ /** In a doc that `extends` a topic, the key of the base section to add this+ * section after, when it replaces none. */+ after?: string;/** Preview type for token tables in this section. When set, the docsite* renders a visual preview column using the token's computed CSS value* from the current theme. Omit for non-token sections. */diff --git a/packages/cli/clients/cli/commands/docs.mjs b/packages/cli/clients/cli/commands/docs.mjsindex e2ff73d7e8..bdaae5f6da 100644--- a/packages/cli/clients/cli/commands/docs.mjs+++ b/packages/cli/clients/cli/commands/docs.mjs@@ -431,6 +431,29 @@ function linkLines(links) {];}+/**+ * A section title naming the package that wrote it, once: a title an author+ * already ended with that package keeps its own.+ * @param {string} title+ * @param {string} pkg+ * @returns {string}+ */+function titledWithPackage(title, pkg) {+ const label = `(${pkg})`;+ return title.endsWith(label) ? title : `${title} ${label}`;+}++/**+ * What a topic or guide took the place of, and whose it was, as the line+ * read right after its `package:` line (INV28); nothing for any other read.+ * @param {{replaces?: string, replacedPackage?: string}} data+ * @returns {ReturnType<typeof text>[]}+ */+function replacedLine(data) {+ if (data.replaces == null || data.replacedPackage == null) return [];+ return [text(`replaces ${data.replacedPackage}'s ${data.replaces}`)];+}+/*** A topic's section index: what the topic is, one line per section with the* key to read it by, and how to read further.@@ -445,6 +468,7 @@ function emitIndex(index, owner, run) {index.description ? wrapText(index.description) : undefined,),record({package: owner}),+ ...replacedLine(index),// Summaries wrap rather than being cut: the summary is how a reader picks// the one section to open. A section another package wrote says which one.records(@@ -452,7 +476,7 @@ function emitIndex(index, owner, run) {const shown = {...s, summary: prefixCliCommands(s.summary ?? '', run)};return s.package === owner? shown- : {...shown, title: `${s.title} (${s.package})`};+ : {...shown, title: titledWithPackage(s.title, s.package)};}),{fields: ['id', 'title', 'summary'],@@ -717,6 +741,7 @@ export function registerDocs(program) {const owner = result.package;emit(record({package: owner}),+ ...replacedLine(result.data),code(formatReferenceFull({@@ -725,7 +750,7 @@ export function registerDocs(program) {sections: result.data.sections.map(s =>s.package === owner? s- : {...s, title: `${s.title} (${s.package})`},+ : {...s, title: titledWithPackage(s.title, s.package)},),},detail,diff --git a/packages/cli/foundation/discovery/docs-discovery.mjs b/packages/cli/foundation/discovery/docs-discovery.mjsindex 656db0fce1..0a66028cc3 100644--- a/packages/cli/foundation/discovery/docs-discovery.mjs+++ b/packages/cli/foundation/discovery/docs-discovery.mjs@@ -67,6 +67,29 @@ const INTEGRATION_DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];/** A topic name is a CLI argument and a URL segment; keep it to both. */const TOPIC_NAME_RE = /^[\w-]+$/;+/**+ * Whether a `replaces` or `extends` names a route of the docs tree rather than+ * a flat topic: a topic name never holds a `/`, and a guide the tree places is+ * always read by a route that does.+ * @param {unknown} target+ * @returns {target is string}+ */+export function isGuideRoute(target) {+ return typeof target === 'string' && target.includes('/');+}++/**+ * What the integrations do to one guide the docs tree places, in configured+ * order: a replacement, and the extensions merged onto whatever is there.+ * @typedef {object} GuideOverlay+ * @property {DocsTopicRecord | null} replacement the doc readers get at the+ * route instead of the guide; the last package configured wins+ * @property {Array<{package: string, path: string, providerId?: string}>} extensions+ * extensions authored after the replacement, if any, in configured order+ * @property {string} [replacedPackage] the package of the replacement this one+ * took over from, when the guide was replaced twice+ */+/*** @typedef {object} DocsTopicRecord A doc file discovered under a docs root.* @property {string} name@@ -92,6 +115,8 @@ const TOPIC_NAME_RE = /^[\w-]+$/;* @property {string} [description]* @property {string|null} [category]* @property {string} [replaces] the topic this one took the place of+ * @property {string} [replacedPackage] the package whose topic or guide this+ * one took the place of* @property {Array<{package: string, path: string, providerId?: string}>} extensions* overlays to merge onto the base doc, in the order their integrations were* configured; each section an extension adds resolves its links against the@@ -205,7 +230,21 @@ const BLOCK_FIELD_VALUES = {const PROJECTION_FIELDS = ['fields', 'sections'];/** Keys a section may carry. */-const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];+const SECTION_FIELDS = [+ 'id',+ 'title',+ 'category',+ 'content',+ 'previewType',+ 'before',+ 'after',+];++/**+ * The fields an extension section places itself with: the key of the base+ * section it goes before or after. Read only by a merge, never by a reader.+ */+export const SECTION_POSITION_FIELDS = ['before', 'after'];/*** Check the fields the docs surfaces actually read. `parseDoc` is the outer@@ -265,6 +304,19 @@ export function problemsInTopic(doc, {placement = false} = {}) {problems.push(`${at}.${key}: not a field of a section`);}}+ for (const field of SECTION_POSITION_FIELDS) {+ const value = section?.[field];+ if (value != null && (typeof value !== 'string' || value === '')) {+ problems.push(+ `${at}.${field}: expected the key of a section, as \`--index\` shows it`,+ );+ }+ }+ if (section?.before != null && section?.after != null) {+ problems.push(+ `${at}: sets both \`before\` and \`after\`; a section goes in one place`,+ );+ }if (!Array.isArray(section?.content)) {problems.push(`${at}.content: expected an array of blocks`);return;@@ -599,8 +651,9 @@ export async function discoverIntegrationDocs(integration) {/*** Merge an extension onto a base topic: a section with a stable `id` replaces* the base section with the same `id`; legacy sections without IDs fall back to- * title matching. A section with no match is appended. The title and- * description stay the base topic's: an extension adds to a topic, it never+ * title matching. A section with no match is added: before or after the+ * section whose key its `before` or `after` names, else at the end. The title+ * and description stay the base topic's: an extension adds to a topic, it never* renames it. A topic that `replaces` another is the one that renames.** Keyed by section TITLE rather than by position, the way the localization@@ -613,22 +666,123 @@ export async function discoverIntegrationDocs(integration) {* @returns {any} a new doc; neither input is mutated*/export function mergeTopic(base, overlay) {+ return mergeTopicReport(base, overlay).doc;+}++/**+ * {@link mergeTopic}, also naming each `before` or `after` that found no+ * section: that section was added at the end instead.+ *+ * @param {any} base+ * @param {any} overlay+ * @returns {{doc: any, unplaced: Array<{section: string, field: 'before' | 'after', key: string}>}}+ */+export function mergeTopicReport(base, overlay) {const sections = [...(base.sections ?? [])];- for (const section of overlay.sections ?? []) {+ /** @type {Array<{section: string, field: 'before' | 'after', key: string}>} */+ const unplaced = [];++ for (const authored of overlay.sections ?? []) {+ const section = withoutPosition(authored);const at = findMergeTarget(sections, section);if (at === -1) {- sections.push(section);+ const field = authored.before != null ? 'before' : 'after';+ const key = authored[field];+ if (typeof key !== 'string') {+ sections.push(section);+ continue;+ }+ const anchor = sections.findIndex(+ candidate => sectionKey(candidate) === key || candidate.id === key,+ );+ if (anchor === -1) {+ unplaced.push({section: sectionKey(section), field, key});+ sections.push(section);+ } else if (field === 'before') {+ // Placed just before a section another was placed `after`, it joins+ // that section's group, so later sections placed there follow both.+ if (sections[anchor][PLACED_AFTER] != null) {+ Object.defineProperty(section, PLACED_AFTER, {+ value: sections[anchor][PLACED_AFTER],+ configurable: true,+ });+ }+ sections.splice(anchor, 0, section);+ } else {+ // Sections placed after one key keep their order, across every+ // extension merged onto the topic: each goes after every section+ // placed there before it, and after the sections placed after those.+ const group = new Set([key]);+ let at = anchor + 1;+ while (at < sections.length && group.has(sections[at][PLACED_AFTER])) {+ group.add(sectionKey(sections[at]));+ at += 1;+ }+ Object.defineProperty(section, PLACED_AFTER, {+ value: key,+ configurable: true,+ });+ sections.splice(at, 0, section);+ }} else {// A legacy extension that replaces a section which has since gained a- // stable ID keeps that ID, so readers addressing it keep working.+ // stable ID keeps that ID, so readers addressing it keep working. A+ // replacing section keeps the place of the one it replaces.const replaced = sections[at];- sections[at] =+ const replacing =section.id == null && replaced.id != null? withSourceTitle({...section, id: replaced.id}, sourceTitle(section)): section;+ // It also keeps the place an earlier `after` gave the one it replaces,+ // so sections placed after that key later still follow it.+ if (replaced[PLACED_AFTER] != null) {+ const placed = replacing === section ? withoutPosition({...section}) : replacing;+ for (const symbol of Object.getOwnPropertySymbols(section)) {+ if (!(symbol in placed)) {+ Object.defineProperty(+ placed,+ symbol,+ /** @type {PropertyDescriptor} */ (+ Object.getOwnPropertyDescriptor(section, symbol)+ ),+ );+ }+ }+ Object.defineProperty(placed, PLACED_AFTER, {+ value: replaced[PLACED_AFTER],+ configurable: true,+ });+ sections[at] = placed;+ } else {+ sections[at] = replacing;+ }}}- return {...base, sections};+ return {doc: {...base, sections}, unplaced};+}++/** The key a merged section was placed `after`, so later ones follow it. */+const PLACED_AFTER = Symbol('astryx.docs.placedAfter');++/**+ * A section without the fields that place it; readers never see them.+ * @param {any} section+ * @returns {any}+ */+export function withoutPosition(section) {+ if (section?.before == null && section?.after == null) return section;+ const {before: _before, after: _after, ...rest} = section;+ // Copy every own symbol (the provider and authored-title marks) too.+ for (const symbol of Object.getOwnPropertySymbols(section)) {+ Object.defineProperty(+ rest,+ symbol,+ /** @type {PropertyDescriptor} */ (+ Object.getOwnPropertyDescriptor(section, symbol)+ ),+ );+ }+ return rest;}/**@@ -723,6 +877,71 @@ export class DocsCatalog {#treeInputs = [];/** @type {Array<{package: string, message: string}>} */#issues = [];+ /** @type {Map<string, GuideOverlay>} lowercased route → what applies there */+ #guideOverlays = new Map();+ /** @type {DocsTopicRecord[]} every doc that targets a route, in order */+ #guideTargeters = [];++ /**+ * Record a doc that replaces or extends a guide the docs tree places, by+ * its route. Whether the route holds such a guide is known only once the+ * tree is built: {@link guideOverlay} applies the record there, and a route+ * that holds none applies nothing.+ * @param {DocsTopicRecord} record+ * @returns {import('../integrations/issue').AstryxIntegrationIssue | null}+ */+ #targetGuide(record) {+ const route = /** @type {string} */ (+ record.replaces ?? record.extendsTopic+ );+ const key = route.toLowerCase();+ const overlay = this.#guideOverlays.get(key) ?? {+ replacement: null,+ extensions: [],+ };+ if (record.replaces != null) {+ const earlier = overlay.replacement;+ if (earlier) {+ // As with a flat topic, the later-configured doc wins, and reads name+ // the replacement it took over from. Unlike a flat topic's, this is+ // no warning: a new failing finding joins only in a minor release+ // (architecture:cli-surface INV35); `integration validate` lists one+ // package's two replacements of a guide as a note.+ overlay.replacedPackage = earlier.package;+ }+ // Extensions were authored against the content that just went away.+ overlay.replacement = record;+ overlay.extensions = [];+ } else {+ overlay.extensions.push({+ package: record.package,+ path: record.path,+ ...(record.providerId ? {providerId: record.providerId} : {}),+ });+ }+ this.#guideOverlays.set(key, overlay);+ this.#guideTargeters.push(record);+ return null;+ }++ /**+ * What the integrations do to the guide the docs tree places at `route`, or+ * null when they leave it as it is.+ * @param {string} route+ * @returns {GuideOverlay | null}+ */+ guideOverlay(route) {+ return this.#guideOverlays.get(route.toLowerCase()) ?? null;+ }++ /**+ * Every doc that replaces or extends a guide by its route, in configured+ * order, so a check can name a route that holds no guide.+ * @returns {ReadonlyArray<DocsTopicRecord>}+ */+ get guideTargeters() {+ return this.#guideTargeters;+ }/*** Record a doc file a package ships that did not load. Its package's docs@@ -810,6 +1029,9 @@ export class DocsCatalog {add(record) {if (record.extendsTopic != null) {const target = this.resolve(record.extendsTopic);+ if (!target && isGuideRoute(record.extendsTopic)) {+ return this.#targetGuide(record);+ }if (!target) {return {code: 'invalid_doc',@@ -827,6 +1049,9 @@ export class DocsCatalog {if (record.replaces != null) {const target = this.resolve(record.replaces);+ if (!target && isGuideRoute(record.replaces)) {+ return this.#targetGuide(record);+ }if (!target) {return {code: 'invalid_doc',@@ -859,6 +1084,9 @@ export class DocsCatalog {description: record.description,category: record.category,replaces: replaced,+ // The package whose topic it took over: an earlier replacement's, when+ // the topic was already replaced.+ replacedPackage: target.package,...(record.providerId ? {providerId: record.providerId} : {}),// Extensions were authored against the content that just went away.extensions: [],diff --git a/packages/cli/foundation/doc-compiler/compile.mjs b/packages/cli/foundation/doc-compiler/compile.mjsindex e74f4c6bbc..abb8530b2c 100644--- a/packages/cli/foundation/doc-compiler/compile.mjs+++ b/packages/cli/foundation/doc-compiler/compile.mjs@@ -23,7 +23,11 @@import {parseTemplate} from '../../authoring/doctypes/template/parse.mjs';import {parseTheme} from '../../authoring/doctypes/theme/parse.mjs';-import {mergeTopic, problemsInTopic} from '../discovery/docs-discovery.mjs';+import {+ mergeTopic,+ problemsInTopic,+ withoutPosition,+} from '../discovery/docs-discovery.mjs';import {sectionKey,sectionKeyErrors,@@ -179,6 +183,9 @@ export function lowerReferenceTopic(input) {);}}+ // `before` and `after` place an extension's sections while it merges; no+ // read carries them, whether or not the doc extends anything.+ doc = {...doc, sections: doc.sections.map(withoutPosition)};// Derived keys are stamped only now, so they never take part in merging.const keyed = withSectionKeys(doc);/** @type {Record<string, string>} */diff --git a/packages/cli/foundation/doc-compiler/doc-loads.test.mjs b/packages/cli/foundation/doc-compiler/doc-loads.test.mjsindex 2b18a26663..aab6cfa123 100644--- a/packages/cli/foundation/doc-compiler/doc-loads.test.mjs+++ b/packages/cli/foundation/doc-compiler/doc-loads.test.mjs@@ -389,8 +389,11 @@ const LOADER_MODULES = {'discoverIntegrationDocs','GRAPH_BLOCK_TYPES','GRAPH_ONLY_FIELDS',+ 'isGuideRoute','mergeTopic',+ 'mergeTopicReport','problemsInTopic',+ 'withoutPosition','withSourceTitle',],};diff --git a/packages/cli/foundation/doc-compiler/tree.mjs b/packages/cli/foundation/doc-compiler/tree.mjsindex 033fa379db..07fc58dc3d 100644--- a/packages/cli/foundation/doc-compiler/tree.mjs+++ b/packages/cli/foundation/doc-compiler/tree.mjs@@ -178,6 +178,9 @@ export const topicLevel = category =>* @property {TreeSlot[]} slots a namespace's slots; empty for a leaf* @property {string} source* @property {any} [ref]+ * @property {import('../discovery/docs-discovery.mjs').GuideOverlay} [guideOverlay]+ * what integrations do to a guide the tree places, by its route: set by the+ * project's tree, absent when nothing replaces or extends it*//**diff --git a/packages/cli/foundation/integrations/cli-requirement.mjs b/packages/cli/foundation/integrations/cli-requirement.mjsindex 0c4212edce..cfcac7a595 100644--- a/packages/cli/foundation/integrations/cli-requirement.mjs+++ b/packages/cli/foundation/integrations/cli-requirement.mjs@@ -71,6 +71,13 @@ export const THEMES_CLI = '0.6.4';*/export const SECTION_IDS_CLI = '0.6.4';+/**+ * The first CLI release that reads a doc section's `before` and `after`.+ * Earlier releases reject the fields and hide every doc topic the package+ * ships.+ */+export const SECTION_POSITION_CLI = '0.7.4';+const VERSION_RE = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;/**@@ -226,6 +233,22 @@ export function sectionIdsCliProblem(pkg) {);}+/**+ * Why a package with a doc section that sets `before` or `after` would lose+ * its doc topics on an older CLI, or null when its declared CLI range admits+ * only CLIs that read the fields (spec:AST-046 FR11).+ * @param {any} pkg package.json+ * @returns {string | null}+ */+export function sectionPositionCliProblem(pkg) {+ return cliRangeProblem(+ pkg,+ 'has a doc section that sets `before` or `after`',+ 'rejects the fields, and can hide every doc topic the package ships',+ SECTION_POSITION_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 21ba88f53b..2b35469bd5 100644--- a/packages/cli/foundation/integrations/cli-requirement.test.mjs+++ b/packages/cli/foundation/integrations/cli-requirement.test.mjs@@ -320,6 +320,7 @@ describe('every feature check names its CLI floor', () => {replacesCliProblem: TEMPLATE_REPLACES_CLI,keywordsCliProblem: KEYWORDS_CLI,sectionIdsCliProblem: '0.6.4',+ sectionPositionCliProblem: '0.7.4',themesCliProblem: '0.6.4',};diff --git a/packages/cli/foundation/response/response-types.doc.mjs b/packages/cli/foundation/response/response-types.doc.mjsindex d51269ff14..aec4c91609 100644--- a/packages/cli/foundation/response/response-types.doc.mjs+++ b/packages/cli/foundation/response/response-types.doc.mjs@@ -78,17 +78,17 @@ export const doc = {{value: 'docs.list',description:- "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.",+ "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.",},{value: 'docs.detail',description:- "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).",+ "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.",},{value: 'docs.index',description:- "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).",+ "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.",},{value: 'docs.detail.section',@@ -98,7 +98,7 @@ export const doc = {{value: 'docs.node',description:- "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).",+ "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 (read from the published RSS feed)@@ -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). 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} 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.',},{value: 'integration.template-conflicts',