@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.88ec018

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +63 -63
  2. package/api/docs/_adapter.d.mts +80 -0
  3. package/api/docs/_adapter.mjs +248 -5
  4. package/api/docs/detail/detail.mjs +8 -0
  5. package/api/docs/docs.doc.mjs +1 -1
  6. package/api/docs/docs.type.d.mts +28 -2
  7. package/api/docs/docs.type.mjs +13 -3
  8. package/api/docs/guide-route-targets.test.mjs +998 -0
  9. package/api/docs/index/index.mjs +9 -0
  10. package/api/docs/list/list.mjs +7 -1
  11. package/api/docs/node/node.mjs +9 -1
  12. package/api/doctor/built-checks.mjs +43 -13
  13. package/api/doctor/built-checks.test.mjs +29 -0
  14. package/api/doctor/doctor.doc.mjs +1 -1
  15. package/api/integration/_adapter.d.mts +8 -0
  16. package/api/integration/_adapter.mjs +25 -0
  17. package/api/integration/authoring-checks.mjs +29 -2
  18. package/api/integration/pack-check.mjs +32 -1
  19. package/api/integration/pack-check.test.mjs +33 -0
  20. package/api/integration/validate-integration.mjs +66 -1
  21. package/api/integration/validateIntegration.doc.mjs +1 -1
  22. package/api/search/_candidate-score.d.mts +3 -2
  23. package/api/search/_candidate-score.mjs +66 -3
  24. package/api/search/_gather-docs.mjs +12 -2
  25. package/api/search/_priority.mjs +2 -1
  26. package/api/search/_score.d.mts +2 -1
  27. package/api/search/_score.mjs +2 -2
  28. package/api/search/search.family-members.test.mjs +124 -0
  29. package/assets/discover/official-packages.json +16 -0
  30. package/assets/docs/tree/extend-or-replace.doc.mjs +36 -4
  31. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  32. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  33. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  34. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  35. package/assets/templates/themes/butter/palette.config.json +484 -0
  36. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  37. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  38. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  39. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  40. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  41. package/assets/templates/themes/matcha/palette.config.json +448 -0
  42. package/assets/templates/themes/y2k/palette.config.json +166 -0
  43. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  44. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  45. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  46. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  47. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  48. package/authoring/doctypes/_schema.d.mts +4 -0
  49. package/authoring/doctypes/_schema.mjs +4 -0
  50. package/authoring/doctypes/reference/type.ts +14 -2
  51. package/clients/cli/commands/docs.mjs +27 -2
  52. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  53. package/foundation/agent-docs/agent-docs.mjs +54 -2
  54. package/foundation/agent-docs/agent-docs.test.mjs +61 -0
  55. package/foundation/discovery/docs-discovery.d.mts +93 -2
  56. package/foundation/discovery/docs-discovery.mjs +236 -8
  57. package/foundation/doc-compiler/compile.mjs +8 -1
  58. package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
  59. package/foundation/doc-compiler/tree.d.mts +5 -0
  60. package/foundation/doc-compiler/tree.mjs +3 -0
  61. package/foundation/integrations/cli-requirement.d.mts +14 -0
  62. package/foundation/integrations/cli-requirement.mjs +23 -0
  63. package/foundation/integrations/cli-requirement.test.mjs +1 -0
  64. package/foundation/response/response-types.doc.mjs +5 -5
  65. package/package.json +9 -9
@@ -137,12 +137,16 @@ export interface ReferenceDoc extends AuthoredDocGraphFields {
137
137
  * `replaces: 'getting-started'` on a doc named `getting-started` swaps the
138
138
  * content, and on a doc named something else swaps it and leaves the old
139
139
  * name as an alias, so `astryx docs getting-started` still resolves.
140
+ * A route (`'authoring/quick-start'`) names a guide the docs tree
141
+ * places: readers who open that route get this doc.
140
142
  * Ignored on a built-in topic (there is nothing above it to replace). */
141
143
  replaces?: string;
142
144
  /** Name of an existing topic this doc merges onto, section by section: a
143
145
  * section whose title matches one in the base replaces it, and a section
144
- * the base does not have is appended. For correcting or adding to a topic
145
- * rather than owning it — `replaces` and `extends` are exclusive. */
146
+ * the base does not have is added where its `before` or `after` says, else
147
+ * at the end. A route (`'authoring/quick-start'`) names a guide the
148
+ * docs tree places. For correcting or adding to a topic rather than owning
149
+ * it — `replaces` and `extends` are exclusive. */
146
150
  extends?: string;
147
151
  /** Ordered sections that make up the doc. */
148
152
  sections: ReferenceSection[];
@@ -170,6 +174,14 @@ export interface ReferenceSection {
170
174
  * `reference` block includes another doc from its canonical source, so a
171
175
  * guide never copies a schema's fields or a command's options. */
172
176
  content: (ReferenceContentBlock | ReferenceDocBlock)[];
177
+ /** In a doc that `extends` a topic, the key of the base section (as
178
+ * `astryx docs <topic> --index` shows it) to add this section before,
179
+ * when it replaces none. Set `before` or `after`, not both; with neither,
180
+ * the section is added at the end. Ignored on any other doc. */
181
+ before?: string;
182
+ /** In a doc that `extends` a topic, the key of the base section to add this
183
+ * section after, when it replaces none. */
184
+ after?: string;
173
185
  /** Preview type for token tables in this section. When set, the docsite
174
186
  * renders a visual preview column using the token's computed CSS value
175
187
  * from the current theme. Omit for non-token sections. */
@@ -431,6 +431,29 @@ function linkLines(links) {
431
431
  ];
432
432
  }
433
433
 
434
+ /**
435
+ * A section title naming the package that wrote it, once: a title an author
436
+ * already ended with that package keeps its own.
437
+ * @param {string} title
438
+ * @param {string} pkg
439
+ * @returns {string}
440
+ */
441
+ function titledWithPackage(title, pkg) {
442
+ const label = `(${pkg})`;
443
+ return title.endsWith(label) ? title : `${title} ${label}`;
444
+ }
445
+
446
+ /**
447
+ * What a topic or guide took the place of, and whose it was, as the line
448
+ * read right after its `package:` line (INV28); nothing for any other read.
449
+ * @param {{replaces?: string, replacedPackage?: string}} data
450
+ * @returns {ReturnType<typeof text>[]}
451
+ */
452
+ function replacedLine(data) {
453
+ if (data.replaces == null || data.replacedPackage == null) return [];
454
+ return [text(`replaces ${data.replacedPackage}'s ${data.replaces}`)];
455
+ }
456
+
434
457
  /**
435
458
  * A topic's section index: what the topic is, one line per section with the
436
459
  * key to read it by, and how to read further.
@@ -445,6 +468,7 @@ function emitIndex(index, owner, run) {
445
468
  index.description ? wrapText(index.description) : undefined,
446
469
  ),
447
470
  record({package: owner}),
471
+ ...replacedLine(index),
448
472
  // Summaries wrap rather than being cut: the summary is how a reader picks
449
473
  // the one section to open. A section another package wrote says which one.
450
474
  records(
@@ -452,7 +476,7 @@ function emitIndex(index, owner, run) {
452
476
  const shown = {...s, summary: prefixCliCommands(s.summary ?? '', run)};
453
477
  return s.package === owner
454
478
  ? shown
455
- : {...shown, title: `${s.title} (${s.package})`};
479
+ : {...shown, title: titledWithPackage(s.title, s.package)};
456
480
  }),
457
481
  {
458
482
  fields: ['id', 'title', 'summary'],
@@ -717,6 +741,7 @@ export function registerDocs(program) {
717
741
  const owner = result.package;
718
742
  emit(
719
743
  record({package: owner}),
744
+ ...replacedLine(result.data),
720
745
  code(
721
746
  formatReferenceFull(
722
747
  {
@@ -725,7 +750,7 @@ export function registerDocs(program) {
725
750
  sections: result.data.sections.map(s =>
726
751
  s.package === owner
727
752
  ? s
728
- : {...s, title: `${s.title} (${s.package})`},
753
+ : {...s, title: titledWithPackage(s.title, s.package)},
729
754
  ),
730
755
  },
731
756
  detail,
@@ -101,6 +101,17 @@ export function resolveAgentPaths(targetDir: string, agent: string): {
101
101
  * @returns {'stylex' | 'tailwind' | 'css'}
102
102
  */
103
103
  export function detectStylingSystem(targetDir: string): "stylex" | "tailwind" | "css";
104
+ /**
105
+ * Whether the project at `dir` can run `astryx doctor --built`: the CLI it
106
+ * installs, which answers it whatever the running copy is, has the option.
107
+ * Read from the installed CLI (the folder's own, or its workspace's), never
108
+ * from declared ranges or the running copy, so a block written before
109
+ * install, or by a newer copy, never names an option the project's CLI
110
+ * rejects; the next `init` or `upgrade --apply` after install adds it.
111
+ * @param {string} dir
112
+ * @returns {boolean}
113
+ */
114
+ export function projectHasBuiltCheck(dir: string): boolean;
104
115
  /**
105
116
  * Generate the agent cheat sheet from live CLI metadata.
106
117
  *
@@ -125,10 +136,10 @@ export function detectStylingSystem(targetDir: string): "stylex" | "tailwind" |
125
136
  * `getting-started` is the one it should reach for first.
126
137
  *
127
138
  * @param {string | null} version the Core version
128
- * @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}>}} [options]
139
+ * @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}>, builtCheck?: boolean}} [options]
129
140
  * @returns {string}
130
141
  */
131
- export function generateCompressedIndex(version: string | null, { coreDir, invocation, stylingSystem, topics, agentDocs, }?: {
142
+ export function generateCompressedIndex(version: string | null, { coreDir, invocation, stylingSystem, topics, agentDocs, builtCheck, }?: {
132
143
  coreDir?: string | null;
133
144
  invocation?: string;
134
145
  stylingSystem?: "stylex" | "tailwind" | "css";
@@ -139,6 +150,7 @@ export function generateCompressedIndex(version: string | null, { coreDir, invoc
139
150
  package: string;
140
151
  append: readonly string[];
141
152
  }>;
153
+ builtCheck?: boolean;
142
154
  }): string;
143
155
  /**
144
156
  * Resolve the complete expected block for one installed project.
@@ -33,10 +33,11 @@ import {spawnSync} from 'node:child_process';
33
33
  import * as fs from 'node:fs';
34
34
  import * as os from 'node:os';
35
35
  import * as path from 'node:path';
36
- import {findCoreDir, CLI_ROOT} from '../fs/paths.mjs';
36
+ import {findCoreDir, findInstalledPackage, CLI_ROOT} from '../fs/paths.mjs';
37
37
  import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';
38
38
  import {createFileProtectionResolver} from '../fs/file-protection.mjs';
39
39
  import {getCliInvocation} from '../env/package-manager.mjs';
40
+ import {isValidSemver, semverGte} from '../env/semver.mjs';
40
41
  import {discoverComponents} from '../discovery/component-discovery.mjs';
41
42
  import {Project} from '../config/project.mjs';
42
43
  import {cliRootNamespaceNames} from '../doc-compiler/tree.mjs';
@@ -683,6 +684,45 @@ export function detectStylingSystem(targetDir) {
683
684
  }
684
685
  }
685
686
 
687
+ /** The first release whose `doctor` takes `--built`. */
688
+ const BUILT_CHECK_SINCE = '0.7.4';
689
+
690
+ /**
691
+ * Whether a project on this Core release can run `astryx doctor --built`. A
692
+ * prerelease of the first release is below it: its canaries predate the
693
+ * option.
694
+ * @param {string | null | undefined} version
695
+ */
696
+ function hasBuiltCheck(version) {
697
+ if (typeof version !== 'string' || !isValidSemver(version)) return false;
698
+ const [release, prerelease] = version.split('-', 2);
699
+ if (prerelease !== undefined && release === BUILT_CHECK_SINCE) return false;
700
+ return semverGte(release, BUILT_CHECK_SINCE);
701
+ }
702
+
703
+ /**
704
+ * Whether the project at `dir` can run `astryx doctor --built`: the CLI it
705
+ * installs, which answers it whatever the running copy is, has the option.
706
+ * Read from the installed CLI (the folder's own, or its workspace's), never
707
+ * from declared ranges or the running copy, so a block written before
708
+ * install, or by a newer copy, never names an option the project's CLI
709
+ * rejects; the next `init` or `upgrade --apply` after install adds it.
710
+ * @param {string} dir
711
+ * @returns {boolean}
712
+ */
713
+ export function projectHasBuiltCheck(dir) {
714
+ const installed = findInstalledPackage(dir, '@astryxdesign/cli');
715
+ if (!installed) return false;
716
+ try {
717
+ const {version} = JSON.parse(
718
+ fs.readFileSync(path.join(installed, 'package.json'), 'utf8'),
719
+ );
720
+ return hasBuiltCheck(version);
721
+ } catch {
722
+ return false;
723
+ }
724
+ }
725
+
686
726
  /**
687
727
  * Generate the agent cheat sheet from live CLI metadata.
688
728
  *
@@ -707,7 +747,7 @@ export function detectStylingSystem(targetDir) {
707
747
  * `getting-started` is the one it should reach for first.
708
748
  *
709
749
  * @param {string | null} version the Core version
710
- * @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}>}} [options]
750
+ * @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}>, builtCheck?: boolean}} [options]
711
751
  * @returns {string}
712
752
  */
713
753
  export function generateCompressedIndex(
@@ -718,6 +758,7 @@ export function generateCompressedIndex(
718
758
  stylingSystem = 'css',
719
759
  topics,
720
760
  agentDocs = [],
761
+ builtCheck = false,
721
762
  } = {},
722
763
  ) {
723
764
  const run = invocation;
@@ -767,6 +808,13 @@ export function generateCompressedIndex(
767
808
  // intentionally omitted from the command reference below.
768
809
  lines.push(WORKFLOW_TITLE, ...WORKFLOW_STEPS);
769
810
  lines.push('Changing an existing page? Keep it: skip step 2 and add blocks/components inside its sections.');
811
+ // Only for a project whose recorded releases have `doctor --built`
812
+ // (projectHasBuiltCheck): a newer copy may write this block in a project
813
+ // whose install then brings an older CLI, which rejects the option. The computer-level
814
+ // skill names only entry points every release keeps (AST-081 FR8).
815
+ if (builtCheck) {
816
+ lines.push("Before you deliver a build, run `astryx doctor --built <dir>`; don't deliver it if it fails.");
817
+ }
770
818
  lines.push('');
771
819
 
772
820
  // Rules — the top error-preventers.
@@ -911,6 +959,7 @@ export async function renderAgentDocsBlock(
911
959
 
912
960
  return generateCompressedIndex(version, {
913
961
  coreDir,
962
+ builtCheck: projectHasBuiltCheck(targetDir),
914
963
  invocation: getCliInvocation(targetDir),
915
964
  stylingSystem: detectStylingSystem(targetDir),
916
965
  topics,
@@ -999,6 +1048,7 @@ export function injectAgentsMd(targetDir, version) {
999
1048
  const agentsPath = path.join(targetDir, AGENTS_MD);
1000
1049
  const compressedIndex = generateCompressedIndex(version, {
1001
1050
  coreDir: findCoreDir(targetDir),
1051
+ builtCheck: projectHasBuiltCheck(targetDir),
1002
1052
  stylingSystem: detectStylingSystem(targetDir),
1003
1053
  });
1004
1054
  injectXdsBlock(agentsPath, compressedIndex, {
@@ -1019,6 +1069,7 @@ export function injectClaudeMd(targetDir, version) {
1019
1069
  const claudePath = path.join(targetDir, CLAUDE_MD);
1020
1070
  const compressedIndex = generateCompressedIndex(version, {
1021
1071
  coreDir: findCoreDir(targetDir),
1072
+ builtCheck: projectHasBuiltCheck(targetDir),
1022
1073
  stylingSystem: detectStylingSystem(targetDir),
1023
1074
  });
1024
1075
  return injectXdsBlock(claudePath, compressedIndex);
@@ -1743,6 +1794,7 @@ export function installAgentDocs(
1743
1794
  renderedBlock ??
1744
1795
  generateCompressedIndex(version, {
1745
1796
  coreDir,
1797
+ builtCheck: projectHasBuiltCheck(targetDir),
1746
1798
  zh,
1747
1799
  lang,
1748
1800
  invocation,
@@ -4,8 +4,10 @@ import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
4
4
  import * as fs from 'node:fs';
5
5
  import * as path from 'node:path';
6
6
  import * as os from 'node:os';
7
+ import {renderComputerAgentText} from './computer-agent-text.mjs';
7
8
  import {
8
9
  generateCompressedIndex,
10
+ projectHasBuiltCheck,
9
11
  detectStylingSystem,
10
12
  getXdsVersion,
11
13
  installAgentDocs,
@@ -95,6 +97,65 @@ describe('generateCompressedIndex', () => {
95
97
  expect(result).toContain('<!-- ASTRYX:END -->');
96
98
  });
97
99
 
100
+ it('tells agents to check a build with doctor --built; the computer-level skill does not', () => {
101
+ const line =
102
+ "Before you deliver a build, run `astryx doctor --built <dir>`; don't deliver it if it fails.";
103
+ expect(generateCompressedIndex('0.7.4', {builtCheck: true})).toContain(line);
104
+ expect(generateCompressedIndex('0.7.4')).not.toContain('doctor --built');
105
+ expect(renderComputerAgentText({command: 'astryx'})).not.toContain(
106
+ 'doctor --built',
107
+ );
108
+ });
109
+
110
+ describe('projectHasBuiltCheck reads the CLI the project installs', () => {
111
+ /**
112
+ * @param {string | null} cliVersion the installed CLI, or none
113
+ * @param {{workspace?: boolean}} [options] install it at a workspace root
114
+ */
115
+ const project = (cliVersion, {workspace = false} = {}) => {
116
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-built-check-'));
117
+ const app = workspace ? path.join(root, 'apps', 'web') : root;
118
+ fs.mkdirSync(app, {recursive: true});
119
+ if (workspace) {
120
+ fs.writeFileSync(
121
+ path.join(root, 'package.json'),
122
+ JSON.stringify({name: 'repo', private: true, workspaces: ['apps/*'], devDependencies: {'@astryxdesign/cli': cliVersion ?? '0.7.3'}}),
123
+ );
124
+ }
125
+ fs.writeFileSync(
126
+ path.join(app, 'package.json'),
127
+ JSON.stringify({name: 'web', dependencies: {'@astryxdesign/core': '0.7.4'}}),
128
+ );
129
+ if (cliVersion) {
130
+ const cliDir = path.join(root, 'node_modules', '@astryxdesign', 'cli');
131
+ fs.mkdirSync(cliDir, {recursive: true});
132
+ fs.writeFileSync(
133
+ path.join(cliDir, 'package.json'),
134
+ JSON.stringify({name: '@astryxdesign/cli', version: cliVersion}),
135
+ );
136
+ }
137
+ return {root, app};
138
+ };
139
+ it.each([
140
+ ['an installed CLI 0.7.4', '0.7.4', {}, true],
141
+ ['an installed CLI 0.8.0', '0.8.0', {}, true],
142
+ ['an installed CLI 0.7.3', '0.7.3', {}, false],
143
+ ['an installed 0.7.4 canary', '0.7.4-canary.b25f95e', {}, false],
144
+ ['no installed CLI (before install, or Core only)', null, {}, false],
145
+ ['a workspace root that installs CLI 0.7.3', '0.7.3', {workspace: true}, false],
146
+ ['a workspace root that installs CLI 0.7.4', '0.7.4', {workspace: true}, true],
147
+ ])('%s', (_label, cliVersion, options, expected) => {
148
+ const {root, app} = project(cliVersion, options);
149
+ try {
150
+ expect(projectHasBuiltCheck(app)).toBe(expected);
151
+ } finally {
152
+ fs.rmSync(root, {recursive: true, force: true});
153
+ }
154
+ });
155
+ });
156
+
157
+
158
+
98
159
  it('includes theme nudge rule', () => {
99
160
  const result = generateCompressedIndex('1.0.0');
100
161
  expect(result).toMatch(/astryx docs theme/);
@@ -1,6 +1,25 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * Whether a `replaces` or `extends` names a route of the docs tree rather than
6
+ * a flat topic: a topic name never holds a `/`, and a guide the tree places is
7
+ * always read by a route that does.
8
+ * @param {unknown} target
9
+ * @returns {target is string}
10
+ */
11
+ export function isGuideRoute(target: unknown): target is string;
12
+ /**
13
+ * What the integrations do to one guide the docs tree places, in configured
14
+ * order: a replacement, and the extensions merged onto whatever is there.
15
+ * @typedef {object} GuideOverlay
16
+ * @property {DocsTopicRecord | null} replacement the doc readers get at the
17
+ * route instead of the guide; the last package configured wins
18
+ * @property {Array<{package: string, path: string, providerId?: string}>} extensions
19
+ * extensions authored after the replacement, if any, in configured order
20
+ * @property {string} [replacedPackage] the package of the replacement this one
21
+ * took over from, when the guide was replaced twice
22
+ */
4
23
  /**
5
24
  * @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
6
25
  * @property {string} name
@@ -25,6 +44,8 @@
25
44
  * @property {string} [description]
26
45
  * @property {string|null} [category]
27
46
  * @property {string} [replaces] the topic this one took the place of
47
+ * @property {string} [replacedPackage] the package whose topic or guide this
48
+ * one took the place of
28
49
  * @property {Array<{package: string, path: string, providerId?: string}>} extensions
29
50
  * overlays to merge onto the base doc, in the order their integrations were
30
51
  * configured; each section an extension adds resolves its links against the
@@ -108,8 +129,9 @@ export function discoverIntegrationDocs(integration: {
108
129
  /**
109
130
  * Merge an extension onto a base topic: a section with a stable `id` replaces
110
131
  * the base section with the same `id`; legacy sections without IDs fall back to
111
- * title matching. A section with no match is appended. The title and
112
- * description stay the base topic's: an extension adds to a topic, it never
132
+ * title matching. A section with no match is added: before or after the
133
+ * section whose key its `before` or `after` names, else at the end. The title
134
+ * and description stay the base topic's: an extension adds to a topic, it never
113
135
  * renames it. A topic that `replaces` another is the one that renames.
114
136
  *
115
137
  * Keyed by section TITLE rather than by position, the way the localization
@@ -122,6 +144,28 @@ export function discoverIntegrationDocs(integration: {
122
144
  * @returns {any} a new doc; neither input is mutated
123
145
  */
124
146
  export function mergeTopic(base: any, overlay: any): any;
147
+ /**
148
+ * {@link mergeTopic}, also naming each `before` or `after` that found no
149
+ * section: that section was added at the end instead.
150
+ *
151
+ * @param {any} base
152
+ * @param {any} overlay
153
+ * @returns {{doc: any, unplaced: Array<{section: string, field: 'before' | 'after', key: string}>}}
154
+ */
155
+ export function mergeTopicReport(base: any, overlay: any): {
156
+ doc: any;
157
+ unplaced: Array<{
158
+ section: string;
159
+ field: "before" | "after";
160
+ key: string;
161
+ }>;
162
+ };
163
+ /**
164
+ * A section without the fields that place it; readers never see them.
165
+ * @param {any} section
166
+ * @returns {any}
167
+ */
168
+ export function withoutPosition(section: any): any;
125
169
  export { withSourceTitle };
126
170
  /**
127
171
  * Owner package recorded for the built-in topics. They ship inside the CLI
@@ -139,6 +183,11 @@ export const GRAPH_BLOCK_TYPES: Set<string>;
139
183
  * load; a guide the tree places may set `placement` (spec:AST-046).
140
184
  */
141
185
  export const GRAPH_ONLY_FIELDS: string[];
186
+ /**
187
+ * The fields an extension section places itself with: the key of the base
188
+ * section it goes before or after. Read only by a merge, never by a reader.
189
+ */
190
+ export const SECTION_POSITION_FIELDS: string[];
142
191
  /**
143
192
  * A component a link can name: its owner's provider id, package, and name,
144
193
  * and the doc file that describes it.
@@ -183,6 +232,19 @@ export class DocsCatalog {
183
232
  * @returns {DocsCatalog}
184
233
  */
185
234
  static fromBuiltins(builtins?: Record<string, string>): DocsCatalog;
235
+ /**
236
+ * What the integrations do to the guide the docs tree places at `route`, or
237
+ * null when they leave it as it is.
238
+ * @param {string} route
239
+ * @returns {GuideOverlay | null}
240
+ */
241
+ guideOverlay(route: string): GuideOverlay | null;
242
+ /**
243
+ * Every doc that replaces or extends a guide by its route, in configured
244
+ * order, so a check can name a route that holds no guide.
245
+ * @returns {ReadonlyArray<DocsTopicRecord>}
246
+ */
247
+ get guideTargeters(): ReadonlyArray<DocsTopicRecord>;
186
248
  /**
187
249
  * Record a doc file a package ships that did not load. Its package's docs
188
250
  * are withdrawn; readers name the package so an author knows where to look.
@@ -259,6 +321,30 @@ export class DocsCatalog {
259
321
  entries(): DocsTopicEntry[];
260
322
  #private;
261
323
  }
324
+ /**
325
+ * What the integrations do to one guide the docs tree places, in configured
326
+ * order: a replacement, and the extensions merged onto whatever is there.
327
+ */
328
+ export type GuideOverlay = {
329
+ /**
330
+ * the doc readers get at the
331
+ * route instead of the guide; the last package configured wins
332
+ */
333
+ replacement: DocsTopicRecord | null;
334
+ /**
335
+ * extensions authored after the replacement, if any, in configured order
336
+ */
337
+ extensions: Array<{
338
+ package: string;
339
+ path: string;
340
+ providerId?: string;
341
+ }>;
342
+ /**
343
+ * the package of the replacement this one
344
+ * took over from, when the guide was replaced twice
345
+ */
346
+ replacedPackage?: string | undefined;
347
+ };
262
348
  /**
263
349
  * A doc file discovered under a docs root.
264
350
  */
@@ -314,6 +400,11 @@ export type DocsTopicEntry = {
314
400
  * the topic this one took the place of
315
401
  */
316
402
  replaces?: string | undefined;
403
+ /**
404
+ * the package whose topic or guide this
405
+ * one took the place of
406
+ */
407
+ replacedPackage?: string | undefined;
317
408
  /**
318
409
  * overlays to merge onto the base doc, in the order their integrations were
319
410
  * configured; each section an extension adds resolves its links against the