@astryxdesign/cli 0.7.3-canary.06872b4 → 0.7.3-canary.0bf23bd

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 (149) hide show
  1. package/README.md +68 -68
  2. package/api/component/component.mjs +1 -1
  3. package/api/component/doc-links.test.mjs +2 -2
  4. package/api/docs/_adapter.d.mts +2 -2
  5. package/api/docs/_adapter.mjs +61 -18
  6. package/api/docs/docs-homes.test.mjs +127 -0
  7. package/api/docs/docs.doc.mjs +3 -3
  8. package/api/docs/docs.test.mjs +28 -18
  9. package/api/docs/integration-tree.test.mjs +20 -20
  10. package/api/docs/integrationDocs.test.mjs +1 -1
  11. package/api/docs/namespace-section.test.mjs +6 -6
  12. package/api/docs/reference-blocks.test.mjs +2 -2
  13. package/api/doctor/doctor.mjs +16 -12
  14. package/api/doctor/doctor.test.mjs +9 -9
  15. package/api/hook/hook.mjs +1 -1
  16. package/api/integration/_adapter.d.mts +8 -0
  17. package/api/integration/_adapter.mjs +21 -1
  18. package/api/integration/authoring-checks.test.mjs +220 -0
  19. package/api/integration/validate-integration.mjs +24 -0
  20. package/api/integration/validate-integration.type.d.mts +2 -1
  21. package/api/integration/validate-integration.type.mjs +2 -1
  22. package/api/integration/validateIntegration.doc.mjs +1 -1
  23. package/api/search/_adapter.d.mts +16 -0
  24. package/api/search/_adapter.mjs +39 -0
  25. package/api/search/_adapter.test.mjs +173 -0
  26. package/api/search/_candidate-score.mjs +1 -1
  27. package/api/search/_entries.mjs +57 -1
  28. package/api/search/_gather-docs.mjs +3 -3
  29. package/api/search/search.doc.mjs +1 -1
  30. package/api/search/search.mjs +6 -2
  31. package/api/search/search.test.mjs +14 -14
  32. package/assets/docs/author-a-theme.doc.mjs +2 -2
  33. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  34. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  35. package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
  36. package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
  37. package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
  38. package/assets/docs/tree/block-template.doc.mjs +1 -1
  39. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  40. package/assets/docs/tree/building-blocks.doc.mjs +2 -2
  41. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  42. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  43. package/assets/docs/tree/checks.doc.mjs +2 -2
  44. package/assets/docs/tree/cli-command.doc.mjs +1 -1
  45. package/assets/docs/tree/cli.doc.mjs +1 -1
  46. package/assets/docs/tree/codemods.doc.mjs +1 -1
  47. package/assets/docs/tree/component-family.doc.mjs +1 -1
  48. package/assets/docs/tree/component-imports.doc.mjs +1 -1
  49. package/assets/docs/tree/components.doc.mjs +1 -1
  50. package/assets/docs/tree/configuration.doc.mjs +1 -1
  51. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  52. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  53. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  54. package/assets/docs/tree/docs.doc.mjs +1 -1
  55. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  56. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  57. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  58. package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
  59. package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
  60. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  61. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  62. package/assets/docs/tree/global-integrations.doc.mjs +2 -2
  63. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  64. package/assets/docs/tree/help.doc.mjs +2 -2
  65. package/assets/docs/tree/links.doc.mjs +1 -1
  66. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  67. package/assets/docs/tree/page-template.doc.mjs +1 -1
  68. package/assets/docs/tree/publishing.doc.mjs +1 -1
  69. package/assets/docs/tree/quick-start.doc.mjs +1 -1
  70. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  71. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  72. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  73. package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
  74. package/assets/docs/tree/ship.doc.mjs +2 -2
  75. package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
  76. package/assets/docs/tree/single-component.doc.mjs +1 -1
  77. package/assets/docs/tree/start-a-template.doc.mjs +1 -1
  78. package/assets/docs/tree/subcomponent.doc.mjs +1 -1
  79. package/assets/docs/tree/template-assets.doc.mjs +1 -1
  80. package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
  81. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  82. package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
  83. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  84. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  85. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  86. package/assets/docs/tree/templates.doc.mjs +1 -1
  87. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  88. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  89. package/assets/docs/tree/themes.doc.mjs +1 -1
  90. package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
  91. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  92. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  93. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  94. package/assets/docs/tree/versioning.doc.mjs +1 -1
  95. package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
  96. package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
  97. package/assets/docs/use-integrations.doc.mjs +120 -0
  98. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  99. package/authoring/integration/integration.doc.mjs +1 -1
  100. package/authoring/integration/type.ts +1 -1
  101. package/clients/cli/command-result-coverage.test.mjs +6 -5
  102. package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
  103. package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
  104. package/clients/cli/commands/component.test.mjs +6 -6
  105. package/clients/cli/commands/docs.doc.mjs +2 -2
  106. package/clients/cli/commands/docs.mjs +1 -1
  107. package/clients/cli/commands/docs.test.mjs +14 -14
  108. package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
  109. package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
  110. package/clients/cli/commands/integration-check.test.mjs +48 -0
  111. package/clients/cli/commands/integration.doc.mjs +1 -1
  112. package/clients/cli/commands/manifest.doc.mjs +1 -1
  113. package/clients/cli/commands/manifest.mjs +67 -0
  114. package/clients/cli/commands/postinstall.doc.mjs +23 -0
  115. package/clients/cli/commands/postinstall.mjs +31 -0
  116. package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
  117. package/clients/cli/index.mjs +10 -85
  118. package/clients/cli/lib/component-format.mjs +1 -1
  119. package/clients/cli/lib/define-command.mjs +12 -7
  120. package/clients/cli/lib/exit-codes.test.mjs +5 -0
  121. package/clients/cli/lib/manifest.test.mjs +12 -0
  122. package/clients/cli/lib/welcome-box.mjs +50 -0
  123. package/foundation/agent-docs/agent-docs.mjs +2 -1
  124. package/foundation/agent-docs/agent-docs.test.mjs +5 -4
  125. package/foundation/discovery/authoring-self-docs.d.mts +7 -0
  126. package/foundation/discovery/authoring-self-docs.mjs +16 -4
  127. package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
  128. package/foundation/discovery/authoring-surface.d.mts +1 -1
  129. package/foundation/discovery/authoring-surface.mjs +2 -2
  130. package/foundation/discovery/authoring-surface.test.mjs +1 -1
  131. package/foundation/discovery/cli-self-docs.d.mts +2 -1
  132. package/foundation/discovery/cli-self-docs.mjs +4 -3
  133. package/foundation/discovery/cli-self-docs.test.mjs +2 -2
  134. package/foundation/discovery/runner-allowlist.d.mts +2 -4
  135. package/foundation/discovery/runner-allowlist.mjs +2 -4
  136. package/foundation/discovery/runner-commands.d.mts +77 -0
  137. package/foundation/discovery/runner-commands.mjs +294 -0
  138. package/foundation/discovery/runner-commands.test.mjs +128 -0
  139. package/foundation/discovery/stray-pointers.test.mjs +1 -1
  140. package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
  141. package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
  142. package/foundation/doc-compiler/tree.d.mts +32 -6
  143. package/foundation/doc-compiler/tree.mjs +77 -43
  144. package/foundation/doc-compiler/tree.test.mjs +7 -7
  145. package/foundation/fs/read-record.d.mts +18 -0
  146. package/foundation/fs/read-record.mjs +131 -0
  147. package/foundation/fs/read-record.test.mjs +77 -0
  148. package/foundation/response/response-types.doc.mjs +1 -1
  149. package/package.json +9 -9
@@ -293,7 +293,7 @@ async function componentRead(name, options = {}) {
293
293
  const selectorList = Array.isArray(name) ? name : null;
294
294
  const noName = selectorList == null && !name;
295
295
 
296
- // Default detail level mirrors the CLI (see commands/component/index.mjs):
296
+ // Default detail level mirrors the CLI (see commands/component.mjs):
297
297
  // single-component views default to 'full', list-style views (--list,
298
298
  // --category, or no name) default to 'brief' (scannable name lists).
299
299
  // An explicit array remains a batch even when it is empty or a caller also
@@ -250,14 +250,14 @@ describe("a link in a guide's description, as the docs tree shows it", () => {
250
250
  'Document a theme by extending the core theme topic, so an app reads it in `astryx docs theme`.';
251
251
  const guide = /** @type {any} */ (
252
252
  await docs(
253
- 'cli/integrations/building-blocks/themes/document-the-theme',
253
+ 'authoring/building-blocks/themes/document-the-theme',
254
254
  undefined,
255
255
  {cwd: tmpDir, full: true},
256
256
  )
257
257
  );
258
258
  expect(guide.data.description).toBe(expected);
259
259
  const namespace = /** @type {any} */ (
260
- await docs('cli/integrations/building-blocks/themes', undefined, {
260
+ await docs('authoring/building-blocks/themes', undefined, {
261
261
  cwd: tmpDir,
262
262
  })
263
263
  );
@@ -226,7 +226,7 @@ export function topicUp(entry: import("../../foundation/discovery/docs-discovery
226
226
  export function placeLinks(tree: DocsTree, node: TreeNode): import("./docs.type.mjs").DocsLinks;
227
227
  /**
228
228
  * The moves a topic read offers: from its place in the tree, where a guide
229
- * sits in its namespace and a flat topic in the Unorganized level.
229
+ * sits in its namespace and a flat topic in its topic level.
230
230
  * @param {DocsCatalog} catalog
231
231
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
232
232
  * @returns {Promise<import('./docs.type.mjs').DocsLinks>}
@@ -290,7 +290,7 @@ export function holdsOwnName(tree: DocsTree, catalog: DocsCatalog, entry: import
290
290
  /**
291
291
  * The doc that took a flat topic's route in the docs tree, when it is not
292
292
  * that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
293
- * and `unorganized`, and a namespace keeps its route over a topic of the same
293
+ * and `guides`, and a namespace keeps its route over a topic of the same
294
294
  * name. Null when the topic owns its route, or the tree has no node there.
295
295
  * @param {DocsTree} tree
296
296
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
@@ -52,6 +52,7 @@ import {
52
52
  cliDocSection,
53
53
  } from '../../foundation/discovery/cli-self-docs.mjs';
54
54
  import {
55
+ AUTHORING_REFERENCE_ROUTE,
55
56
  loadAuthoringSelfDocs,
56
57
  schemaFieldTable,
57
58
  selfDocSection,
@@ -385,7 +386,7 @@ export function projectTree(catalog, {fresh = false} = {}) {
385
386
  let cliTreeInputs;
386
387
 
387
388
  /**
388
- * Every flat topic in the catalog, as the tree's Unorganized level reads it.
389
+ * Every flat topic in the catalog, as the tree's topic levels read it.
389
390
  * @param {DocsCatalog} catalog
390
391
  * @returns {Promise<import('../../foundation/doc-compiler/tree.mjs').TreeTopicInput[]>}
391
392
  */
@@ -394,12 +395,13 @@ async function flatTopicInputs(catalog) {
394
395
  const topics = [];
395
396
  for (const entry of catalog.entries()) {
396
397
  const aliases = catalog.aliasesOf(entry);
397
- let {title, description} = entry;
398
- if (title == null || description == null) {
398
+ let {title, description, category} = entry;
399
+ if (title == null || description == null || category === undefined) {
399
400
  try {
400
401
  const file = await loadTopicFile(entry.path, null);
401
402
  title ??= file.doc?.title;
402
403
  description ??= file.doc?.description;
404
+ category ??= file.doc?.category;
403
405
  } catch {
404
406
  // A topic that does not load is reported where it is read.
405
407
  }
@@ -410,6 +412,7 @@ async function flatTopicInputs(catalog) {
410
412
  name: entry.name,
411
413
  title: title ?? entry.name,
412
414
  summary: description ?? '',
415
+ category: category ?? null,
413
416
  source: `${entry.package}:${entry.name}`,
414
417
  ...(aliases.length > 0 ? {aliases} : {}),
415
418
  });
@@ -419,7 +422,7 @@ async function flatTopicInputs(catalog) {
419
422
 
420
423
  /**
421
424
  * The CLI's tree, each configured integration's namespaces and guides, and
422
- * every flat topic in the generated Unorganized level.
425
+ * every flat topic in the generated level for its category.
423
426
  * @param {DocsCatalog} catalog
424
427
  * @param {boolean} fresh
425
428
  * @returns {Promise<DocsTree>}
@@ -509,23 +512,22 @@ function identitiesOf(tree) {
509
512
  }
510
513
 
511
514
  /**
512
- * The CLI's authoring docs, by kind and name. `astryx docs authoring` reads
513
- * each as one section keyed by its name, so a link to one opens that section.
514
- * Loaded once per process, like the CLI's tree files.
515
+ * The CLI's authoring docs, by kind and name. The field reference under
516
+ * `astryx docs authoring` reads each as one section keyed by its name, so a
517
+ * link to one opens that section. Loaded once per process, like the CLI's
518
+ * tree files.
515
519
  * @type {Promise<Map<string, any>> | undefined}
516
520
  */
517
521
  let authoringDocs;
518
522
 
519
523
  /**
520
- * The CLI authoring doc a link names, while `astryx docs authoring` is the
521
- * CLI's own topic.
522
- * @param {DocsCatalog} catalog
524
+ * The CLI authoring doc a link names. The `authoring` namespace is the CLI's
525
+ * own, so no integration can take its route.
523
526
  * @param {string} kind
524
527
  * @param {string} name
525
528
  * @returns {Promise<any | null>}
526
529
  */
527
- async function authoringDoc(catalog, kind, name) {
528
- if (catalog.resolve('authoring')?.package !== CLI_PROVIDER_ID) return null;
530
+ async function authoringDoc(kind, name) {
529
531
  authoringDocs ??= loadAuthoringSelfDocs().then(
530
532
  ({loaded}) =>
531
533
  new Map(loaded.map(({doc}) => [`${doc.type}\u0000${doc.name}`, doc])),
@@ -611,14 +613,14 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
611
613
  }
612
614
  const authored =
613
615
  provider === CLI_PROVIDER_ID
614
- ? await authoringDoc(catalog, parsed.kind, parsed.name)
616
+ ? await authoringDoc(parsed.kind, parsed.name)
615
617
  : null;
616
618
  if (authored) {
617
619
  return {
618
620
  link: {
619
621
  target,
620
622
  id: createDocId(provider, authored.type, authored.name),
621
- route: 'authoring',
623
+ route: AUTHORING_REFERENCE_ROUTE,
622
624
  title: authored.displayName ?? authored.name,
623
625
  summary: authored.description ?? '',
624
626
  command: `astryx docs authoring ${authored.name}`,
@@ -1428,7 +1430,7 @@ export function placeLinks(tree, node) {
1428
1430
 
1429
1431
  /**
1430
1432
  * The moves a topic read offers: from its place in the tree, where a guide
1431
- * sits in its namespace and a flat topic in the Unorganized level.
1433
+ * sits in its namespace and a flat topic in its topic level.
1432
1434
  * @param {DocsCatalog} catalog
1433
1435
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
1434
1436
  * @returns {Promise<import('./docs.type.mjs').DocsLinks>}
@@ -1526,7 +1528,7 @@ function treeArgument(catalog, tree, node) {
1526
1528
  /**
1527
1529
  * The doc that took a flat topic's route in the docs tree, when it is not
1528
1530
  * that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
1529
- * and `unorganized`, and a namespace keeps its route over a topic of the same
1531
+ * and `guides`, and a namespace keeps its route over a topic of the same
1530
1532
  * name. Null when the topic owns its route, or the tree has no node there.
1531
1533
  * @param {DocsTree} tree
1532
1534
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
@@ -1540,6 +1542,35 @@ export function routeOwner(tree, entry) {
1540
1542
  : node;
1541
1543
  }
1542
1544
 
1545
+ /**
1546
+ * Routes that moved, old prefix first: the integration guides moved from
1547
+ * `cli/integrations` (and, before that, the `cli-integrations` topic) into
1548
+ * `authoring`, the one home for integration authors.
1549
+ * Only the not-found error reads this, to name where a doc went; an old route
1550
+ * opens nothing.
1551
+ */
1552
+ const MOVED_ROUTES = [
1553
+ ['cli/integrations', 'authoring'],
1554
+ ['cli-integrations', 'authoring'],
1555
+ ];
1556
+
1557
+ /**
1558
+ * The node an old route moved to, or null.
1559
+ * @param {unknown} topic
1560
+ * @param {DocsTree} tree
1561
+ * @returns {TreeNode | null}
1562
+ */
1563
+ function movedRoute(topic, tree) {
1564
+ if (typeof topic !== 'string') return null;
1565
+ const wanted = topic.toLowerCase();
1566
+ for (const [from, to] of MOVED_ROUTES) {
1567
+ if (wanted !== from && !wanted.startsWith(`${from}/`)) continue;
1568
+ const node = tree.getFolded(`${to}${wanted.slice(from.length)}`);
1569
+ if (node) return node;
1570
+ }
1571
+ return null;
1572
+ }
1573
+
1543
1574
  /**
1544
1575
  * The error for a docs argument that names nothing. For a route, it suggests
1545
1576
  * the children of the deepest namespace the route reaches; otherwise, every
@@ -1572,8 +1603,7 @@ export async function unknownTopicError(topic, catalog) {
1572
1603
  }
1573
1604
  if (suggestions.length === 0 && typeof topic === 'string') {
1574
1605
  // The docs whose own name it is (`doctor` is cli/commands/doctor), or whose
1575
- // route it spells with hyphens (`cli-integrations`, the guide's name before
1576
- // it moved to cli/integrations).
1606
+ // route it spells with hyphens (`cli-host-entry` is cli/host-entry).
1577
1607
  const wanted = topic.toLowerCase();
1578
1608
  suggestions = [...tree.nodes.values()]
1579
1609
  .filter(
@@ -1592,6 +1622,19 @@ export async function unknownTopicError(topic, catalog) {
1592
1622
  ...catalog.names().map(name => ({name, reason: 'available topic'})),
1593
1623
  ];
1594
1624
  }
1625
+ // A route that moved names where it went, ahead of the usual suggestions
1626
+ // (spec:AST-046 FR9, FR6).
1627
+ const moved = movedRoute(topic, tree);
1628
+ if (moved) {
1629
+ return new AstryxError(
1630
+ `Unknown topic "${String(topic)}". It moved to "${moved.route}"${notLoaded(catalog)}`,
1631
+ [
1632
+ {name: moved.route, reason: moved.summary},
1633
+ ...suggestions.filter(entry => entry.name !== moved.route),
1634
+ ],
1635
+ ERROR_CODES.ERR_UNKNOWN_TOPIC,
1636
+ );
1637
+ }
1595
1638
  return new AstryxError(
1596
1639
  `Unknown topic "${String(topic)}"${notLoaded(catalog)}`,
1597
1640
  suggestions,
@@ -0,0 +1,127 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Every Core doc has a named home in the docs tree (spec:AST-046 FR12).
5
+ *
6
+ * A reader sees a doc's home in its path (`Guides › Getting started`) and in
7
+ * its Up move. A flat Core topic sits in Guides or Foundations by the
8
+ * category it declares, so a new topic with no category, or one the levels
9
+ * do not know, fails here instead of landing in a catch-all. The integration
10
+ * guides and their field reference live under `authoring`, and the routes
11
+ * they left name where they went.
12
+ */
13
+
14
+ import {describe, expect, it} from 'vitest';
15
+ import {docs} from './docs.mjs';
16
+ import {TOPIC_LEVELS} from '../../foundation/doc-compiler/tree.mjs';
17
+
18
+ const CLI = '@astryxdesign/cli';
19
+ const SLOW = 60_000;
20
+
21
+ describe('every Core doc has a named home', () => {
22
+ it(
23
+ 'puts each flat Core topic in Guides or Foundations by its category',
24
+ async () => {
25
+ const list = await docs();
26
+ const core = list.data.filter(topic => topic.package === CLI);
27
+ expect(core.length).toBeGreaterThan(10);
28
+ /** @type {string[]} */
29
+ const unfiled = [];
30
+ for (const topic of core) {
31
+ const read = await docs(topic.topic);
32
+ const {category} = read.data;
33
+ if (category !== 'guide' && category !== 'foundations') {
34
+ unfiled.push(`${topic.topic} (category ${String(category)})`);
35
+ continue;
36
+ }
37
+ const level =
38
+ category === 'foundations'
39
+ ? TOPIC_LEVELS.foundations
40
+ : TOPIC_LEVELS.guides;
41
+ expect(read.data.links.up, topic.topic).toBe(
42
+ `astryx docs ${level.route}`,
43
+ );
44
+ }
45
+ expect(unfiled, 'Core topics with no home: give each a category').toEqual(
46
+ [],
47
+ );
48
+ },
49
+ SLOW,
50
+ );
51
+
52
+ it(
53
+ 'lists each level under a plain name, and no catch-all',
54
+ async () => {
55
+ const list = await docs();
56
+ const roots = (list.meta.namespaces ?? []).map(entry => entry.topic);
57
+ expect(roots).toEqual(expect.arrayContaining(['guides', 'foundations']));
58
+ expect(roots).not.toContain('unorganized');
59
+ const guides = await docs('guides');
60
+ expect(guides.data).toMatchObject({route: 'guides', title: 'Guides'});
61
+ expect(guides.data.slots[0].children.map(child => child.route)).toEqual(
62
+ expect.arrayContaining(['getting-started', 'principles', 'theme']),
63
+ );
64
+ const foundations = await docs('foundations');
65
+ expect(foundations.data.title).toBe('Foundations');
66
+ expect(
67
+ foundations.data.slots[0].children.map(child => child.route),
68
+ ).toEqual(expect.arrayContaining(['color', 'icons', 'spacing']));
69
+ await expect(docs('unorganized')).rejects.toMatchObject({
70
+ code: 'ERR_UNKNOWN_TOPIC',
71
+ });
72
+ },
73
+ SLOW,
74
+ );
75
+
76
+ it(
77
+ 'keeps everything for integration authors under authoring, and names where an old route went',
78
+ async () => {
79
+ const authoring = await docs('authoring');
80
+ expect(authoring.data).toMatchObject({
81
+ route: 'authoring',
82
+ kind: 'namespace',
83
+ breadcrumb: [],
84
+ links: {up: 'astryx docs'},
85
+ });
86
+ const children = authoring.data.slots.flatMap(slot =>
87
+ slot.children.map(child => child.route),
88
+ );
89
+ expect(children).toEqual(
90
+ expect.arrayContaining([
91
+ 'authoring/quick-start',
92
+ 'authoring/building-blocks',
93
+ 'authoring/ship',
94
+ 'authoring/help',
95
+ 'authoring/field-reference',
96
+ ]),
97
+ );
98
+ // Every field reference section still opens from the namespace by its
99
+ // key, as `astryx docs authoring <name>` did on the topic (FR13).
100
+ const reference = await docs('authoring/field-reference', undefined, {
101
+ index: true,
102
+ });
103
+ const keys = reference.data.sections.map(section => section.id);
104
+ expect(keys.length).toBeGreaterThan(15);
105
+ for (const key of keys) {
106
+ const section = await docs('authoring', key);
107
+ expect(section.type, key).toBe('docs.detail.section');
108
+ expect(section.data.id, key).toBe(key);
109
+ }
110
+ for (const [old, now] of [
111
+ ['cli/integrations', 'authoring'],
112
+ ['cli/integrations/quick-start', 'authoring/quick-start'],
113
+ ['cli/integrations/ship/publishing', 'authoring/ship/publishing'],
114
+ ]) {
115
+ const error = await docs(old).catch(e => e);
116
+ expect(error).toMatchObject({
117
+ code: 'ERR_UNKNOWN_TOPIC',
118
+ message: expect.stringContaining(`It moved to "${now}"`),
119
+ });
120
+ // The new route comes first, ahead of the suggestions any unknown
121
+ // route gets (FR6).
122
+ expect(error.suggestions[0]).toMatchObject({name: now});
123
+ }
124
+ },
125
+ SLOW,
126
+ );
127
+ });
@@ -28,7 +28,7 @@ export const doc = {
28
28
  '`cli/api` returns its children one level down (`depth` reads as many ' +
29
29
  'levels as asked, and `detail` how much of each doc below), a typed doc such as ' +
30
30
  "`cli/api/functions/search` returns its content, and a guide the tree " +
31
- 'places (`cli/integrations/quick-start`) reads like any topic. ' +
31
+ 'places (`authoring/quick-start`) reads like any topic. ' +
32
32
  'Every read but the list carries `links`, the commands that move from it: ' +
33
33
  '`up` to the level it sits in, `previous` and `next` to its neighbors, and, ' +
34
34
  'for a typed doc, `related` to the docs it names (its command or function, ' +
@@ -162,12 +162,12 @@ export const doc = {
162
162
  },
163
163
  {
164
164
  label: 'A namespace and everything below it, in full',
165
- code: "await docs('cli/integrations', undefined, {depth: 'all', detail: 'full'});",
165
+ code: "await docs('authoring', undefined, {depth: 'all', detail: 'full'});",
166
166
  },
167
167
  {label: 'One API function', code: "await docs('cli/api/functions/search');"},
168
168
  {
169
169
  label: 'A whole guide from the docs tree',
170
- code: "await docs('cli/integrations/quick-start');",
170
+ code: "await docs('authoring/quick-start');",
171
171
  },
172
172
  {label: 'One section by key', code: "await docs('spacing', 'scale');"},
173
173
  ],
@@ -93,7 +93,7 @@ describe('docs() dispatcher routing', () => {
93
93
 
94
94
  it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
95
95
  const res = await docs();
96
- expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'global', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
96
+ expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['authoring', 'cli', 'foundations', 'global', 'guides', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography']);
97
97
  for (const entry of res.data) {
98
98
  expect((await docs(entry.topic)).type).toBe('docs.detail');
99
99
  }
@@ -158,8 +158,8 @@ describe('docs() dispatcher routing', () => {
158
158
  }, SLOW);
159
159
 
160
160
  it('a guide the tree places reads like a topic: the whole doc, its index, a section', async () => {
161
- // cli/integrations is a namespace of short guides; each guide reads like a topic.
162
- const integrations = await docs('cli/integrations');
161
+ // authoring is a namespace of short guides; each guide reads like a topic.
162
+ const integrations = await docs('authoring');
163
163
  expect(integrations.type).toBe('docs.node');
164
164
  const guide = placedGuide(integrations.data);
165
165
  expect((await docs(guide)).type).toBe('docs.detail');
@@ -178,7 +178,7 @@ describe('docs() dispatcher routing', () => {
178
178
  expect(leaf.links.up).toBe('astryx docs cli/api/functions');
179
179
  expect(leaf.links.previous).toMatch(/^astryx docs cli\/api\/functions\/[a-z-]+$/);
180
180
  expect(leaf.links.next).toMatch(/^astryx docs cli\/api\/functions\/[a-z-]+$/);
181
- const integrations = (await docs('cli/integrations')).data;
181
+ const integrations = (await docs('authoring')).data;
182
182
  const guide = placedGuide(integrations);
183
183
  const siblings = integrations.slots
184
184
  .find(slot => slot.children.some(child => child.route === guide))
@@ -187,7 +187,7 @@ describe('docs() dispatcher routing', () => {
187
187
  const index = await docs(guide, undefined, {index: true});
188
188
  // A guide moves across its namespace's slot, as any tree node does.
189
189
  expect(index.data.links).toEqual({
190
- up: 'astryx docs cli/integrations',
190
+ up: 'astryx docs authoring',
191
191
  ...(at > 0 ? {previous: `astryx docs ${siblings[at - 1]}`} : {}),
192
192
  ...(at < siblings.length - 1
193
193
  ? {next: `astryx docs ${siblings[at + 1]}`}
@@ -204,16 +204,22 @@ describe('docs() dispatcher routing', () => {
204
204
  expect(end.links.previous).toBe(
205
205
  `astryx docs ${guide} ${index.data.sections.at(-2).id}`,
206
206
  );
207
- // A flat topic's home is the Unorganized level, and it moves across it.
207
+ // A flat topic's home is the level for its category, and it moves across it.
208
208
  const flat = (await docs('principles')).data.links;
209
- expect(flat.up).toBe('astryx docs unorganized');
209
+ expect(flat.up).toBe('astryx docs guides');
210
210
  expect(flat.previous).toMatch(/^astryx docs [a-z-]+$/);
211
211
  expect(flat.next).toMatch(/^astryx docs [a-z-]+$/);
212
- const home = (await docs('unorganized')).data;
213
- expect(home).toMatchObject({id: null, kind: 'namespace', links: {up: 'astryx docs'}});
214
- expect(home.slots[0].children.map(child => child.route)).toEqual(
215
- (await docs()).data.map(entry => entry.topic),
216
- );
212
+ const guides = (await docs('guides')).data;
213
+ expect(guides).toMatchObject({id: null, kind: 'namespace', links: {up: 'astryx docs'}});
214
+ const foundations = (await docs('foundations')).data;
215
+ expect(foundations).toMatchObject({id: null, kind: 'namespace', links: {up: 'astryx docs'}});
216
+ // Between them the two levels hold every flat topic, each in list order.
217
+ const topics = (await docs()).data.map(entry => entry.topic);
218
+ const held = [guides, foundations].map(level => level.slots[0].children.map(child => child.route));
219
+ for (const routes of held) {
220
+ expect(routes).toEqual(topics.filter(topic => routes.includes(topic)));
221
+ }
222
+ expect(held.flat().sort()).toEqual([...topics].sort());
217
223
  }, SLOW);
218
224
 
219
225
  it('names a node by its doc identity; a generated level has id null', async () => {
@@ -240,10 +246,9 @@ describe('docs() dispatcher routing', () => {
240
246
  }, SLOW);
241
247
 
242
248
  it("the guide's old flat name is gone, and its error names the new route", async () => {
243
- await expect(docs('cli-integrations')).rejects.toMatchObject({
244
- code: 'ERR_UNKNOWN_TOPIC',
245
- suggestions: [expect.objectContaining({name: 'cli/integrations'})],
246
- });
249
+ const error = await docs('cli-integrations').catch(e => e);
250
+ expect(error.code).toBe('ERR_UNKNOWN_TOPIC');
251
+ expect(error.suggestions[0]).toMatchObject({name: 'authoring'});
247
252
  expect((await docs()).data.map(entry => entry.topic)).not.toContain(
248
253
  'cli-integrations',
249
254
  );
@@ -253,11 +258,16 @@ describe('docs() dispatcher routing', () => {
253
258
  const err = await docs('cli', 'zzzz-nope').catch(e => e);
254
259
  expect(err).toBeInstanceOf(AstryxError);
255
260
  expect(err.code).toBe('ERR_UNKNOWN_SECTION');
256
- // It names every guide below the namespace, at any depth.
257
261
  const names = err.suggestions.map(s => s.name);
258
262
  expect(names).toContain('cli/component-lookups');
259
- expect(names).toContain('cli/integrations/quick-start');
260
263
  expect(names.every(name => name.startsWith('cli/'))).toBe(true);
264
+ // It names every guide below the namespace, at any depth.
265
+ const deep = await docs('authoring', 'zzzz-nope').catch(e => e);
266
+ expect(deep.code).toBe('ERR_UNKNOWN_SECTION');
267
+ const below = deep.suggestions.map(s => s.name);
268
+ expect(below).toContain('authoring/quick-start');
269
+ expect(below).toContain('authoring/building-blocks/components/add-a-component');
270
+ expect(below.every(name => name.startsWith('authoring/'))).toBe(true);
261
271
  }, SLOW);
262
272
 
263
273
  it('an unknown route suggests the children of the deepest namespace it reaches', async () => {
@@ -246,7 +246,7 @@ describe('integration docs in the docs tree', () => {
246
246
  });
247
247
  scaffold({
248
248
  ...kit(),
249
- 'unorganized.doc.mjs': {...NAMESPACE, name: 'unorganized', title: 'Mine', summary: 'Mine.'},
249
+ 'guides.doc.mjs': {...NAMESPACE, name: 'guides', title: 'Mine', summary: 'Mine.'},
250
250
  'use-a-theme.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Acme use-a-theme', summary: 'Acme use-a-theme.'},
251
251
  'cli.doc.mjs': flat('cli'),
252
252
  });
@@ -254,26 +254,26 @@ describe('integration docs in the docs tree', () => {
254
254
  expect(listed.meta.namespaces).toEqual(
255
255
  expect.arrayContaining([
256
256
  expect.objectContaining({topic: 'cli', package: '@astryxdesign/cli'}),
257
- expect.objectContaining({topic: 'unorganized', package: '@astryxdesign/cli'}),
257
+ expect.objectContaining({topic: 'guides', package: '@astryxdesign/cli'}),
258
258
  ]),
259
259
  );
260
- expect(listed.meta.namespaces.filter(n => ['use-a-theme', 'unorganized'].includes(n.topic) && n.package === '@acme/kit')).toEqual([]);
260
+ expect(listed.meta.namespaces.filter(n => ['use-a-theme', 'guides'].includes(n.topic) && n.package === '@acme/kit')).toEqual([]);
261
261
  expect(listed.data.map(entry => entry.topic)).not.toContain('cli');
262
262
  // Each name opens the CLI's doc, and a CLI topic keeps its home.
263
263
  expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
264
- expect((await docs('unorganized', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
264
+ expect((await docs('guides', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'guides', package: '@astryxdesign/cli'});
265
265
  const tokens = await docs('use-a-theme', undefined, {cwd: tmpDir});
266
266
  expect(tokens.type).toBe('docs.detail');
267
- expect(tokens.data.links.up).toBe('astryx docs unorganized');
267
+ expect(tokens.data.links.up).toBe('astryx docs guides');
268
268
  // The project doctor and the package doctor both name the claims.
269
269
  const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
270
270
  expect(check.status).toBe('warn');
271
- expect(check.message).toContain('takes the route "unorganized", which the CLI\'s own docs keep');
271
+ expect(check.message).toContain('takes the route "guides", which the CLI\'s own docs keep');
272
272
  expect(check.message).toContain('takes the route "use-a-theme"');
273
273
  expect(check.message).toContain('both have the route "cli"');
274
274
  const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
275
275
  const graph = result.data.issues.filter(issue => issue.code === 'invalid_doc_graph').map(issue => issue.message).join('\n');
276
- expect(graph).toContain('takes the route "unorganized"');
276
+ expect(graph).toContain('takes the route "guides"');
277
277
  expect(graph).toContain('takes the route "use-a-theme"');
278
278
  expect(graph).toContain('route "cli"');
279
279
  }, SLOW);
@@ -294,16 +294,16 @@ describe('integration docs in the docs tree', () => {
294
294
  const nested = path.join(tmpDir, 'node_modules', '@acme', 'kit', 'docs', 'nested');
295
295
  fs.mkdirSync(nested, {recursive: true});
296
296
  fs.writeFileSync(
297
- path.join(nested, 'caps-unorganized.doc.mjs'),
298
- `export const docs = ${JSON.stringify(flat('Unorganized'), null, 2)};\n`,
297
+ path.join(nested, 'caps-guides.doc.mjs'),
298
+ `export const docs = ${JSON.stringify(flat('Guides'), null, 2)};\n`,
299
299
  );
300
300
  fs.writeFileSync(
301
301
  path.join(nested, 'caps-use-a-theme.doc.mjs'),
302
302
  `export const docs = ${JSON.stringify(flat('USE-A-THEME'), null, 2)};\n`,
303
303
  );
304
304
  expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
305
- expect((await docs('unorganized', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
306
- expect((await docs('theme', undefined, {cwd: tmpDir, index: true})).data.links.up).toBe('astryx docs unorganized');
305
+ expect((await docs('guides', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'guides', package: '@astryxdesign/cli'});
306
+ expect((await docs('theme', undefined, {cwd: tmpDir, index: true})).data.links.up).toBe('astryx docs guides');
307
307
  const listed = await docs(undefined, undefined, {cwd: tmpDir});
308
308
  expect(listed.data.map(entry => entry.topic.toLowerCase())).not.toContain('cli');
309
309
  // Search does not offer a topic whose route another doc owns.
@@ -314,10 +314,10 @@ describe('integration docs in the docs tree', () => {
314
314
  const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
315
315
  expect(check.status).toBe('warn');
316
316
  expect(check.message).toContain('route "CLI"');
317
- expect(check.message).toContain('takes the route "Unorganized"');
317
+ expect(check.message).toContain('takes the route "Guides"');
318
318
  // `USE-A-THEME` is the CLI's topic `use-a-theme` in another spelling: the CLI's wins.
319
319
  const tokens = await docs('USE-A-THEME', undefined, {cwd: tmpDir, index: true});
320
- expect(tokens.data).toMatchObject({name: 'use-a-theme', links: {up: 'astryx docs unorganized'}});
320
+ expect(tokens.data).toMatchObject({name: 'use-a-theme', links: {up: 'astryx docs guides'}});
321
321
  expect(tokens.data.title).not.toBe('Acme USE-A-THEME');
322
322
  const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
323
323
  const graph = result.data.issues
@@ -325,7 +325,7 @@ describe('integration docs in the docs tree', () => {
325
325
  .map(issue => issue.message)
326
326
  .join('\n');
327
327
  expect(graph).toContain('route "CLI"');
328
- expect(graph).toContain('takes the route "Unorganized"');
328
+ expect(graph).toContain('takes the route "Guides"');
329
329
  }, SLOW);
330
330
 
331
331
  it("keeps a replaced name for the topic that replaces it, over another integration's namespace", async () => {
@@ -420,9 +420,9 @@ describe('integration docs in the docs tree', () => {
420
420
  scaffold({
421
421
  ...kit(),
422
422
  'a-cli.doc.mjs': flat('cli'),
423
- 'a-unorganized.doc.mjs': flat('Unorganized'),
423
+ 'a-guides.doc.mjs': flat('Guides'),
424
424
  'z-b2.doc.mjs': flat('b2', {replaces: 'cli'}),
425
- 'z-u2.doc.mjs': flat('u2', {replaces: 'Unorganized'}),
425
+ 'z-u2.doc.mjs': flat('u2', {replaces: 'Guides'}),
426
426
  });
427
427
  // Another package carries the chain on: c3 replaces b2, which replaced cli.
428
428
  const three = path.join(tmpDir, 'node_modules', '@acme', 'three');
@@ -440,8 +440,8 @@ describe('integration docs in the docs tree', () => {
440
440
  for (const name of ['cli', 'CLI']) {
441
441
  expect((await docs(name, undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
442
442
  }
443
- for (const name of ['unorganized', 'UNORGANIZED']) {
444
- expect((await docs(name, undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
443
+ for (const name of ['guides', 'GUIDES']) {
444
+ expect((await docs(name, undefined, {cwd: tmpDir})).data).toMatchObject({route: 'guides', package: '@astryxdesign/cli'});
445
445
  }
446
446
  // The replacement still answers to its own names.
447
447
  for (const name of ['b2', 'c3']) {
@@ -456,7 +456,7 @@ describe('integration docs in the docs tree', () => {
456
456
  const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
457
457
  expect(check.status).toBe('warn');
458
458
  expect(check.message).toContain('The topic "c3" answers to "cli" through replaces');
459
- expect(check.message).toContain('The topic "u2" answers to "unorganized" through replaces');
459
+ expect(check.message).toContain('The topic "u2" answers to "guides" through replaces');
460
460
  const inPackage = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
461
461
  const graph = inPackage.data.issues
462
462
  .filter(issue => issue.code === 'invalid_doc_graph')
@@ -519,7 +519,7 @@ describe('integration docs in the docs tree', () => {
519
519
  });
520
520
  const {data} = await docs('theme', 'acme-theming-notes', {cwd: tmpDir});
521
521
  // `generic:integrations` is the extension's own guide, never the CLI's
522
- // `cli/integrations`; a provider-qualified link reaches the CLI's topic.
522
+ // `authoring`; a provider-qualified link reaches the CLI's topic.
523
523
  expect(data.content[0].text).toBe(
524
524
  'See `astryx docs acme/integrations`, and `astryx docs tokens` for the tokens.',
525
525
  );
@@ -447,7 +447,7 @@ describe('integration-contributed topics', () => {
447
447
  // places it.
448
448
  expect(top).toContain('troubleshooting');
449
449
  expect(
450
- top.some(name => /^cli\/integrations\/(?:.+\/)?troubleshooting$/.test(name)),
450
+ top.some(name => /^authoring\/(?:.+\/)?troubleshooting$/.test(name)),
451
451
  top.join(', '),
452
452
  ).toBe(true);
453
453
  }, SLOW);
@@ -157,13 +157,13 @@ describe('a section read on a namespace', () => {
157
157
  expect(names).toContain('layout/side-panels');
158
158
  expect(names.every(name => name.startsWith('layout/'))).toBe(true);
159
159
  // At any depth: guides under nested namespaces are named, namespaces are not.
160
- const cli = await docs('cli', 'zzzz-nope').catch(e => e);
161
- expect(cli.code).toBe('ERR_UNKNOWN_SECTION');
162
- expect(cli.suggestions.map(s => s.name)).toContain(
163
- 'cli/integrations/quick-start',
160
+ const authoring = await docs('authoring', 'zzzz-nope').catch(e => e);
161
+ expect(authoring.code).toBe('ERR_UNKNOWN_SECTION');
162
+ expect(authoring.suggestions.map(s => s.name)).toContain(
163
+ 'authoring/building-blocks/components/add-a-component',
164
164
  );
165
- expect(cli.suggestions.map(s => s.name)).not.toContain(
166
- 'cli/integrations',
165
+ expect(authoring.suggestions.map(s => s.name)).not.toContain(
166
+ 'authoring/building-blocks',
167
167
  );
168
168
  },
169
169
  SLOW,
@@ -300,11 +300,11 @@ describe('a reference block that includes what it names', () => {
300
300
  });
301
301
 
302
302
  describe('what a reference block names', () => {
303
- it('resolves a CLI authoring schema by identity, to its section of `astryx docs authoring`', async () => {
303
+ it('resolves a CLI authoring schema by identity, to its section of the field reference', async () => {
304
304
  const resolve = await linkResolver(builtinCatalog(), CLI_PROVIDER_ID);
305
305
  expect(await resolve('schema:integration')).toMatchObject({
306
306
  id: createDocId(CLI_PROVIDER_ID, 'schema', 'integration'),
307
- route: 'authoring',
307
+ route: 'authoring/field-reference',
308
308
  title: 'Astryx Integration',
309
309
  command: 'astryx docs authoring integration',
310
310
  });