@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.626f01e

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 (200) hide show
  1. package/README.md +63 -63
  2. package/api/component/_adapter.mjs +4 -3
  3. package/api/component/component.mjs +13 -6
  4. package/api/component/doc-links.test.mjs +33 -0
  5. package/api/docs/_adapter.d.mts +80 -0
  6. package/api/docs/_adapter.mjs +261 -11
  7. package/api/docs/detail/detail.mjs +8 -0
  8. package/api/docs/docOverlays.test.mjs +2 -1
  9. package/api/docs/docs.d.mts +16 -6
  10. package/api/docs/docs.doc.mjs +1 -1
  11. package/api/docs/docs.mjs +55 -6
  12. package/api/docs/docs.type.d.mts +28 -2
  13. package/api/docs/docs.type.mjs +13 -3
  14. package/api/docs/guide-route-targets.test.mjs +1002 -0
  15. package/api/docs/index/index.mjs +9 -0
  16. package/api/docs/integration-tree.test.mjs +22 -0
  17. package/api/docs/integrationDocs.test.mjs +85 -0
  18. package/api/docs/list/list.mjs +7 -1
  19. package/api/docs/node/node.mjs +9 -1
  20. package/api/docs/reference-blocks.test.mjs +1 -1
  21. package/api/doctor/built-checks.mjs +43 -13
  22. package/api/doctor/built-checks.test.mjs +29 -0
  23. package/api/doctor/doctor.doc.mjs +2 -2
  24. package/api/hook/list/list.d.mts +1 -1
  25. package/api/integration/_adapter.d.mts +11 -2
  26. package/api/integration/_adapter.mjs +30 -4
  27. package/api/integration/authoring-checks.mjs +29 -2
  28. package/api/integration/authoring-checks.test.mjs +131 -1
  29. package/api/integration/check/check.d.mts +4 -1
  30. package/api/integration/check/check.mjs +34 -4
  31. package/api/integration/check/check.test.mjs +49 -0
  32. package/api/integration/integration-check.type.d.mts +8 -0
  33. package/api/integration/integration-check.type.mjs +4 -1
  34. package/api/integration/integrationCheck.doc.mjs +8 -1
  35. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  36. package/api/integration/pack-check.mjs +65 -1
  37. package/api/integration/pack-check.test.mjs +63 -0
  38. package/api/integration/validate-integration-case-disk.test.mjs +2 -0
  39. package/api/integration/validate-integration-gaps.test.mjs +7 -4
  40. package/api/integration/validate-integration.mjs +96 -14
  41. package/api/integration/validate-integration.type.d.mts +10 -4
  42. package/api/integration/validate-integration.type.mjs +10 -5
  43. package/api/integration/validateIntegration.doc.mjs +1 -1
  44. package/api/search/_candidate-score.d.mts +9 -3
  45. package/api/search/_candidate-score.mjs +90 -3
  46. package/api/search/_gather-components.mjs +48 -1
  47. package/api/search/_gather-docs.mjs +12 -2
  48. package/api/search/_lexical.d.mts +12 -0
  49. package/api/search/_lexical.mjs +3 -0
  50. package/api/search/_priority.mjs +5 -2
  51. package/api/search/_score.d.mts +2 -1
  52. package/api/search/_score.mjs +4 -3
  53. package/api/search/search.doc.mjs +1 -1
  54. package/api/search/search.family-members.test.mjs +124 -0
  55. package/api/search/search.family-word.test.mjs +146 -0
  56. package/api/search/search.mjs +28 -0
  57. package/api/theme/themeBuild.doc.mjs +1 -1
  58. package/api/theme/themeList.doc.mjs +1 -1
  59. package/api/theme/themeTargets.doc.mjs +1 -1
  60. package/assets/discover/official-packages.json +16 -0
  61. package/assets/docs/author-a-theme.doc.mjs +15 -15
  62. package/assets/docs/browser-support.doc.mjs +1 -1
  63. package/assets/docs/getting-started.doc.mjs +16 -16
  64. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  65. package/assets/docs/styling-overview.doc.mjs +5 -5
  66. package/assets/docs/theme.doc.mjs +5 -5
  67. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  68. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  69. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  70. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  71. package/assets/docs/tree/authoring.doc.mjs +2 -2
  72. package/assets/docs/tree/block-template.doc.mjs +1 -1
  73. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  74. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  75. package/assets/docs/tree/checks.doc.mjs +11 -11
  76. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  77. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  78. package/assets/docs/tree/codemods.doc.mjs +7 -7
  79. package/assets/docs/tree/component-family.doc.mjs +1 -1
  80. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  81. package/assets/docs/tree/component-lookups.doc.mjs +6 -5
  82. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  83. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  84. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  85. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  86. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  87. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  88. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  89. package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
  90. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  91. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  92. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  93. package/assets/docs/tree/global.doc.mjs +2 -2
  94. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  95. package/assets/docs/tree/install-once.doc.mjs +4 -4
  96. package/assets/docs/tree/layout.doc.mjs +1 -1
  97. package/assets/docs/tree/links.doc.mjs +2 -2
  98. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  99. package/assets/docs/tree/migration.doc.mjs +2 -1
  100. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  101. package/assets/docs/tree/page-template.doc.mjs +2 -2
  102. package/assets/docs/tree/problems.doc.mjs +8 -8
  103. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  104. package/assets/docs/tree/publishing.doc.mjs +7 -7
  105. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  106. package/assets/docs/tree/reference.doc.mjs +2 -2
  107. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  108. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  109. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  110. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  111. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  112. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  113. package/assets/docs/tree/single-component.doc.mjs +4 -4
  114. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  115. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  116. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  117. package/assets/docs/tree/styling.doc.mjs +1 -1
  118. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  119. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  120. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  121. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  122. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  123. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  124. package/assets/docs/tree/updates.doc.mjs +1 -1
  125. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  126. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  127. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  128. package/assets/docs/tree/versioning.doc.mjs +4 -4
  129. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  130. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  131. package/assets/docs/use-a-theme.doc.mjs +10 -10
  132. package/assets/docs/use-integrations.doc.mjs +1 -1
  133. package/assets/docs/working-with-ai.doc.mjs +15 -15
  134. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  135. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  136. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  137. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  138. package/assets/templates/themes/butter/palette.config.json +484 -0
  139. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  140. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  141. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  142. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  143. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  144. package/assets/templates/themes/matcha/palette.config.json +448 -0
  145. package/assets/templates/themes/y2k/palette.config.json +166 -0
  146. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  147. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  148. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  149. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  150. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  151. package/authoring/codemod/codemod.doc.mjs +1 -1
  152. package/authoring/config/config.doc.mjs +4 -4
  153. package/authoring/debug/parse.d.mts +1 -1
  154. package/authoring/discover/discover.doc.mjs +1 -1
  155. package/authoring/doctypes/_schema.d.mts +4 -0
  156. package/authoring/doctypes/_schema.mjs +4 -0
  157. package/authoring/doctypes/reference/type.ts +14 -2
  158. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  159. package/authoring/integration/integration.doc.mjs +6 -6
  160. package/clients/cli/commands/docs.doc.mjs +1 -1
  161. package/clients/cli/commands/docs.mjs +27 -2
  162. package/clients/cli/commands/docs.test.mjs +1 -1
  163. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  164. package/clients/cli/commands/doctor.doc.mjs +1 -1
  165. package/clients/cli/commands/doctor.mjs +2 -1
  166. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  167. package/clients/cli/commands/integration-check.test.mjs +36 -3
  168. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  169. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  170. package/clients/cli/commands/integration.mjs +15 -3
  171. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  172. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  173. package/clients/cli/lib/define-command.mjs +5 -3
  174. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  175. package/foundation/agent-docs/agent-docs.mjs +65 -4
  176. package/foundation/agent-docs/agent-docs.test.mjs +107 -0
  177. package/foundation/discovery/docs-discovery.d.mts +93 -2
  178. package/foundation/discovery/docs-discovery.mjs +237 -8
  179. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  180. package/foundation/discovery/runner-allowlist.mjs +4 -0
  181. package/foundation/discovery/runner-commands.d.mts +29 -13
  182. package/foundation/discovery/runner-commands.mjs +253 -17
  183. package/foundation/discovery/stray-pointers.mjs +11 -5
  184. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  185. package/foundation/doc-compiler/compile.mjs +8 -1
  186. package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
  187. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  188. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  189. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  190. package/foundation/doc-compiler/links.d.mts +13 -16
  191. package/foundation/doc-compiler/links.mjs +40 -7
  192. package/foundation/doc-compiler/tree.d.mts +5 -0
  193. package/foundation/doc-compiler/tree.mjs +9 -0
  194. package/foundation/env/package-manager.d.mts +18 -0
  195. package/foundation/env/package-manager.mjs +40 -0
  196. package/foundation/integrations/cli-requirement.d.mts +29 -0
  197. package/foundation/integrations/cli-requirement.mjs +47 -0
  198. package/foundation/integrations/cli-requirement.test.mjs +23 -2
  199. package/foundation/response/response-types.doc.mjs +6 -6
  200. package/package.json +9 -9
@@ -1401,7 +1401,7 @@ describe('validateIntegration runner-command notes', () => {
1401
1401
  line: 1,
1402
1402
  command: 'pnpm exec astryx doctor',
1403
1403
  });
1404
- expect(hit.message).toContain('Write `astryx doctor`');
1404
+ expect(hit.message).toContain('Write the token `{@command doctor}`');
1405
1405
  // A note only: no issue, so no exit changes on it.
1406
1406
  expect(
1407
1407
  data.issues.map((/** @type {any} */ issue) => issue.code),
@@ -1544,6 +1544,136 @@ describe('validateIntegration runner-command notes', () => {
1544
1544
  );
1545
1545
  });
1546
1546
 
1547
+ it('lists package-manager commands, bare commands and broken tokens with the token to write, all for the next minor', async () => {
1548
+ writeTopic(
1549
+ 'Add it with `npm install -D @acme/widgets`, run `astryx search acme`, then {@pm add x} and {@cmd docs}. Only npm: `npm pkg set name=x`.',
1550
+ );
1551
+
1552
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1553
+ const notes = (data.notes ?? []).filter(
1554
+ (/** @type {any} */ note) => note.code !== 'runner_command',
1555
+ );
1556
+
1557
+ expect(
1558
+ notes.map((/** @type {any} */ note) => [note.code, note.next]),
1559
+ ).toEqual([
1560
+ ['package_manager_command', true],
1561
+ ['plain_command', true],
1562
+ ['doc_token', true],
1563
+ ['doc_token', true],
1564
+ ['package_manager_command', true],
1565
+ // The fixture's install step, in its bash block.
1566
+ ['package_manager_command', true],
1567
+ ]);
1568
+ const messages = notes.map((/** @type {any} */ note) => note.message);
1569
+ expect(messages[0]).toContain('{@pm install @acme/widgets --dev}');
1570
+ expect(messages[1]).toContain('{@command search acme}');
1571
+ expect(messages[2]).toContain('{@pm}` starts with a verb');
1572
+ expect(messages[3]).toContain('Doc tokens are');
1573
+ expect(messages[4]).toContain(
1574
+ '{@pm-only npm "<why only npm>" pkg set name=x}',
1575
+ );
1576
+ expect(messages[5]).toContain('{@pm dlx @astryxdesign/cli init}');
1577
+ expect(data.issues.map((/** @type {any} */ issue) => issue.code)).toEqual(
1578
+ [],
1579
+ );
1580
+ });
1581
+
1582
+ it('reads a verb named alone as a mention, and TSDoc tags in a TypeScript sample as code', async () => {
1583
+ writeTopic(
1584
+ 'Scripts run with `npm run`, `pnpm dlx` fetches a package, and `npm i -g`, `yarn global add` and `npm pkg set` each take one.',
1585
+ );
1586
+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1587
+ fs.writeFileSync(
1588
+ file,
1589
+ fs.readFileSync(file, 'utf8').replace(
1590
+ /\{"type":"code"[^}]*\}/,
1591
+ JSON.stringify({
1592
+ type: 'code',
1593
+ lang: 'ts',
1594
+ code: '/** {@inheritDoc Base.render} */\nexport const x = 1;',
1595
+ }),
1596
+ ),
1597
+ );
1598
+
1599
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1600
+ expect(
1601
+ (data.notes ?? []).filter((/** @type {any} */ note) =>
1602
+ ['package_manager_command', 'doc_token'].includes(note.code),
1603
+ ),
1604
+ ).toEqual([]);
1605
+ });
1606
+
1607
+ it('lists a token that never closes, in prose and in any code block', async () => {
1608
+ writeTopic(
1609
+ 'Install with {@pm install @acme/widgets --dev before you start.',
1610
+ );
1611
+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1612
+ fs.writeFileSync(
1613
+ file,
1614
+ fs.readFileSync(file, 'utf8').replace(
1615
+ /\{"type":"code"[^}]*\}/,
1616
+ JSON.stringify({
1617
+ type: 'code',
1618
+ lang: 'tsx',
1619
+ code: '// {@pm install @acme/widgets --dev\nexport const x = 1;',
1620
+ }),
1621
+ ),
1622
+ );
1623
+
1624
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1625
+ const tokens = (data.notes ?? []).filter(
1626
+ (/** @type {any} */ note) => note.code === 'doc_token',
1627
+ );
1628
+ expect(tokens).toHaveLength(2);
1629
+ expect(tokens[0].message).toContain('never closes');
1630
+ });
1631
+
1632
+ it('lists a {@command} token that names no Astryx command', async () => {
1633
+ writeTopic('Run {@command dcotor} before you ship.');
1634
+
1635
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1636
+ const tokens = (data.notes ?? []).filter(
1637
+ (/** @type {any} */ note) => note.code === 'doc_token',
1638
+ );
1639
+ expect(tokens).toHaveLength(1);
1640
+ expect(tokens[0].message).toContain('`dcotor` is not an Astryx command');
1641
+ });
1642
+
1643
+ it('reads the command after leading global flags in a {@command} token', async () => {
1644
+ writeTopic(
1645
+ 'Read it as data with {@command --json component Button} or {@command --detail full docs acme}, not {@command --json dcotor}, {@command --json nosuch docs} or {@command --detail full nosuch}. Check the version with {@command --version}; {@command --json} alone names nothing.',
1646
+ );
1647
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1648
+ const tokens = (data.notes ?? []).filter(
1649
+ (/** @type {any} */ note) => note.code === 'doc_token',
1650
+ );
1651
+ expect(
1652
+ tokens.map(note => note.message.match(/`(\w+)` is not/)?.[1]),
1653
+ ).toEqual(['dcotor', 'nosuch', 'nosuch', undefined]);
1654
+ expect(tokens[3].message).toContain('names no Astryx command');
1655
+ });
1656
+
1657
+ it('lists nothing for a topic written in the doc syntax', async () => {
1658
+ writeTopic(
1659
+ 'Add it with {@pm install @acme/widgets --dev}, run {@command docs acme}, and {@pm-only npm "only npm has pkg" pkg set name=x}. Show the syntax: {@@pm install x}.',
1660
+ );
1661
+ // The fixture's bash block holds a scoped install step; write it as a token.
1662
+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1663
+ fs.writeFileSync(
1664
+ file,
1665
+ fs
1666
+ .readFileSync(file, 'utf8')
1667
+ .replace(
1668
+ 'npx @astryxdesign/cli init',
1669
+ '{@pm dlx @astryxdesign/cli init}',
1670
+ ),
1671
+ );
1672
+
1673
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1674
+ expect(data.notes ?? []).toEqual([]);
1675
+ });
1676
+
1547
1677
  it('lists nothing for bare commands and the scoped install step', async () => {
1548
1678
  writeTopic('Check it with `astryx doctor` first.');
1549
1679
 
@@ -60,13 +60,16 @@ export function integrationCheck(options?: IntegrationCheckOptions): Promise<Int
60
60
  * on its own, so two findings with one message stay two.
61
61
  * @param {IntegrationCheckResponse[]} responses validate first
62
62
  * @param {boolean} strict
63
+ * @param {boolean} [next] count validate's notes marked `next`, the findings
64
+ * the next minor release turns into warnings, as warnings now
63
65
  */
64
- export function combineChecks(responses: IntegrationCheckResponse[], strict: boolean): {
66
+ export function combineChecks(responses: IntegrationCheckResponse[], strict: boolean, next?: boolean): {
65
67
  checks: import("../integration-check.type.mjs").IntegrationCheckResult[];
66
68
  errors: number;
67
69
  warnings: number;
68
70
  skipped: string[];
69
71
  unchecked: number;
72
+ upcoming: number;
70
73
  failures: import("../integration-check.type.mjs").IntegrationCheckFailure[];
71
74
  failed: boolean;
72
75
  };
@@ -11,7 +11,10 @@
11
11
  * any warning and on any check, or comparison a check carries, that did not
12
12
  * run, so a package can gate its build on its docs staying in sync. `--strict`
13
13
  * adds no check: it reports the same warnings and skipped work again, as
14
- * errors in the checks' own issue format, and fails on them.
14
+ * errors in the checks' own issue format, and fails on them. `--next` counts
15
+ * the findings the next minor release turns into warnings (validate's notes
16
+ * marked `next`) as warnings now, so a package can fix them ahead of the
17
+ * release; every run reports how many there are.
15
18
  *
16
19
  * What fails it is a contract for the builds that run it: a new check, or a
17
20
  * new failure code, joins only in a minor release that names it.
@@ -236,7 +239,7 @@ export function summarizeCheck(response, context = {}) {
236
239
  * @returns {Promise<IntegrationCheckCommandResponse>}
237
240
  */
238
241
  export async function integrationCheck(options = {}) {
239
- const {cwd = process.cwd(), strict = false} = options;
242
+ const {cwd = process.cwd(), strict = false, next = false} = options;
240
243
  // One after another: each loads the package through the same discovery.
241
244
  /** @type {IntegrationCheckResponse[]} */
242
245
  const responses = [];
@@ -253,7 +256,8 @@ export async function integrationCheck(options = {}) {
253
256
  name: validation.data.name,
254
257
  version: validation.data.version,
255
258
  strict,
256
- ...combineChecks(responses, strict),
259
+ next,
260
+ ...combineChecks(responses, strict, next),
257
261
  },
258
262
  };
259
263
  }
@@ -265,8 +269,10 @@ export async function integrationCheck(options = {}) {
265
269
  * on its own, so two findings with one message stay two.
266
270
  * @param {IntegrationCheckResponse[]} responses validate first
267
271
  * @param {boolean} strict
272
+ * @param {boolean} [next] count validate's notes marked `next`, the findings
273
+ * the next minor release turns into warnings, as warnings now
268
274
  */
269
- export function combineChecks(responses, strict) {
275
+ export function combineChecks(responses, strict, next = false) {
270
276
  const [validation] = responses;
271
277
  // Only validate reports a missing package.json; the other checks read it
272
278
  // from there instead of each naming a missing manifest.
@@ -345,12 +351,36 @@ export function combineChecks(responses, strict) {
345
351
  if (strict) failures.push({check, severity: 'error', ...issue});
346
352
  }
347
353
  });
354
+ // The findings the next minor release turns into warnings: always counted,
355
+ // so the default run can say how many there are, and with `next` counted
356
+ // as warnings now.
357
+ const notes =
358
+ /** @type {{notes?: Array<{code: string, message: string, next?: boolean}>}} */ (
359
+ validation.data
360
+ ).notes ?? [];
361
+ const upcoming = notes.filter(note => note.next === true);
362
+ if (next) {
363
+ warnings += upcoming.length;
364
+ // validate's own row counts them too, so the summary shows what fails.
365
+ checks[0].warnings += upcoming.length;
366
+ if (strict) {
367
+ for (const note of upcoming) {
368
+ failures.push({
369
+ check: 'validate',
370
+ severity: 'error',
371
+ code: note.code,
372
+ message: note.message,
373
+ });
374
+ }
375
+ }
376
+ }
348
377
  return {
349
378
  checks,
350
379
  errors,
351
380
  warnings,
352
381
  skipped,
353
382
  unchecked,
383
+ upcoming: upcoming.length,
354
384
  failures,
355
385
  failed: checks.some(check => check.failed) || failures.length > 0,
356
386
  };
@@ -276,6 +276,55 @@ describe('combineChecks', () => {
276
276
  respond('integration.doc-conflicts', {}),
277
277
  ];
278
278
 
279
+ it('counts the findings the next minor release fails as upcoming, and fails on them only with strict and next', () => {
280
+ const withNotes = [
281
+ respond('integration.validate', {
282
+ notes: [
283
+ {
284
+ code: 'duplicate_component_doc',
285
+ message: 'Two docs. Fix: one.',
286
+ next: true,
287
+ },
288
+ {code: 'invalid_cli_command', message: 'Not a command.'},
289
+ ],
290
+ }),
291
+ respond('integration.component-conflicts', {}),
292
+ respond('integration.template-conflicts', {}),
293
+ respond('integration.doc-conflicts', {}),
294
+ ];
295
+ // The default run, strict included, fails on none: the next minor does.
296
+ for (const strict of [false, true]) {
297
+ expect(combineChecks(withNotes, strict)).toMatchObject({
298
+ upcoming: 1,
299
+ warnings: 0,
300
+ failures: [],
301
+ failed: false,
302
+ });
303
+ }
304
+ expect(combineChecks(withNotes, false, true)).toMatchObject({
305
+ upcoming: 1,
306
+ warnings: 1,
307
+ failures: [],
308
+ failed: false,
309
+ });
310
+ // validate's own summary row shows the note it now counts.
311
+ expect(combineChecks(withNotes, false, true).checks[0].warnings).toBe(1);
312
+ expect(combineChecks(withNotes, false).checks[0].warnings).toBe(0);
313
+ expect(combineChecks(withNotes, true, true)).toMatchObject({
314
+ upcoming: 1,
315
+ warnings: 1,
316
+ failures: [
317
+ {
318
+ check: 'validate',
319
+ severity: 'error',
320
+ code: 'duplicate_component_doc',
321
+ message: 'Two docs. Fix: one.',
322
+ },
323
+ ],
324
+ failed: true,
325
+ });
326
+ });
327
+
279
328
  it('counts a package-level issue once, and two findings with one message twice, naming each component', () => {
280
329
  const loose = combineChecks(responses, false);
281
330
  const strict = combineChecks(responses, true);
@@ -15,6 +15,12 @@ export type IntegrationCheckOptions = {
15
15
  * did not run, not only on errors.
16
16
  */
17
17
  strict?: boolean | undefined;
18
+ /**
19
+ * Also count each finding the next minor release
20
+ * turns into a warning (a note marked `next`) as a warning now, so `strict`
21
+ * fails on it.
22
+ */
23
+ next?: boolean | undefined;
18
24
  };
19
25
  /**
20
26
  * The checks `integrationCheck()` runs, in the order it runs them.
@@ -107,11 +113,13 @@ export type IntegrationCheckCommandResponse = {
107
113
  name: string | null;
108
114
  version: string | null;
109
115
  strict: boolean;
116
+ next: boolean;
110
117
  checks: IntegrationCheckResult[];
111
118
  errors: number;
112
119
  warnings: number;
113
120
  skipped: string[];
114
121
  unchecked: number;
122
+ upcoming: number;
115
123
  failures: IntegrationCheckFailure[];
116
124
  failed: boolean;
117
125
  };
@@ -11,6 +11,9 @@
11
11
  * current directory by default.
12
12
  * @property {boolean} [strict] Also fail on any warning and on any check that
13
13
  * did not run, not only on errors.
14
+ * @property {boolean} [next] Also count each finding the next minor release
15
+ * turns into a warning (a note marked `next`) as a warning now, so `strict`
16
+ * fails on it.
14
17
  */
15
18
 
16
19
  /**
@@ -78,7 +81,7 @@
78
81
  * @property {'integration.check'} type
79
82
  * `unchecked` counts the items the checks list as not compared, which never
80
83
  * fail it.
81
- * @property {{validated: boolean, name: string | null, version: string | null, strict: boolean, checks: IntegrationCheckResult[], errors: number, warnings: number, skipped: string[], unchecked: number, failures: IntegrationCheckFailure[], failed: boolean}} data
84
+ * @property {{validated: boolean, name: string | null, version: string | null, strict: boolean, next: boolean, checks: IntegrationCheckResult[], errors: number, warnings: number, skipped: string[], unchecked: number, upcoming: number, failures: IntegrationCheckFailure[], failed: boolean}} data
82
85
  */
83
86
 
84
87
  export {};
@@ -44,12 +44,19 @@ export const doc = {
44
44
  description:
45
45
  'Also fail on any warning and on any check that did not run, not only on errors. A malformed `cliCommand` is reported as a note (`invalid_cli_command`) in `data.notes` of the validate check, which fails nothing until a minor release names it.',
46
46
  },
47
+ {
48
+ name: 'options.next',
49
+ type: 'boolean',
50
+ default: 'false',
51
+ description:
52
+ "Also count the findings the next minor release turns into warnings, validate's notes marked `next`, as warnings now, so `strict` fails on them.",
53
+ },
47
54
  ],
48
55
  returns: [
49
56
  {
50
57
  type: 'integration.check',
51
58
  description:
52
- "`data.validated` (false when no integration manifest was found, so nothing was checked), `data.name` and `data.version` of the package, `data.strict`, and `data.checks`, one entry per check in the order they run (`validate`, `components`, `templates`, `docs`), each with `check`, `errors` (what makes that check's own subcommand exit 1), `warnings`, `skipped` (why work did not run), `failed` (whether that subcommand exits 1), and `response`, the envelope the check returns on its own. The totals are `data.errors`, `data.warnings`, and `data.skipped` (each reason prefixed with its check); an issue every check starts from, such as one about the manifest, counts once, and every other finding counts on its own. `data.unchecked` counts the items the checks list as not compared, which never fail it. With `strict`, `data.failures` lists each warning and each piece of skipped work once again as an error in the checks' own issue format ({check, severity: `error`, code, message, component, prop, fix, file, line}, each where it applies); it is empty without `strict`. `data.failed` decides the exit code.",
59
+ "`data.validated` (false when no integration manifest was found, so nothing was checked), `data.name` and `data.version` of the package, `data.strict`, `data.next`, and `data.checks`, one entry per check in the order they run (`validate`, `components`, `templates`, `docs`), each with `check`, `errors` (what makes that check's own subcommand exit 1), `warnings`, `skipped` (why work did not run), `failed` (whether that subcommand exits 1), and `response`, the envelope the check returns on its own. The totals are `data.errors`, `data.warnings`, and `data.skipped` (each reason prefixed with its check); an issue every check starts from, such as one about the manifest, counts once, and every other finding counts on its own. `data.unchecked` counts the items the checks list as not compared, which never fail it. `data.upcoming` counts the findings the next minor release turns into warnings (validate's notes marked `next`), and `data.next` says whether this run counted them as warnings now. With `strict`, `data.failures` lists each warning and each piece of skipped work once again as an error in the checks' own issue format ({check, severity: `error`, code, message, component, prop, fix, file, line}, each where it applies); it is empty without `strict`. `data.failed` decides the exit code.",
53
60
  },
54
61
  ],
55
62
  examples: [
@@ -19,7 +19,7 @@ export const doc = {
19
19
  "package's topics, or one of them and a Core topic other than the one it replaces. " +
20
20
  'Code and examples are not compared. `fluff` lists each padding phrase, with its file ' +
21
21
  'line, and each topic of 80 or more prose words in which fewer than half carry content. ' +
22
- '`strayPointers` lists each code span that is exactly `astryx docs <name>` for a doc that ' +
22
+ '`strayPointers` lists each code span that is exactly `{@command docs <name>}` for a doc that ' +
23
23
  "exists, in a topic's prose, description or summary or a component doc's text fields, " +
24
24
  'with the `{@link}` that replaces it. ' +
25
25
  'Each entry of these lists is also a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`), so ' +
@@ -25,6 +25,7 @@ import * as os from 'node:os';
25
25
  import {fileURLToPath} from 'node:url';
26
26
  import {spawnSync} from 'node:child_process';
27
27
  import {assertWithin} from '../../foundation/fs/path-safety.mjs';
28
+ import {commandTokensIn} from '../../foundation/doc-compiler/doc-syntax.mjs';
28
29
  import {resolvePackageDir} from '../../foundation/integrations/integrations.mjs';
29
30
  import {
30
31
  literalThemeName,
@@ -37,6 +38,8 @@ import {
37
38
  keywordsCliProblem,
38
39
  replacesCliProblem,
39
40
  sectionIdsCliProblem,
41
+ docTokensCliProblem,
42
+ sectionPositionCliProblem,
40
43
  themesCliProblem,
41
44
  } from '../../foundation/integrations/cli-requirement.mjs';
42
45
  import {
@@ -322,19 +325,50 @@ function extractTarball(tgzPath, extractDir) {
322
325
  }
323
326
  }
324
327
 
328
+ /**
329
+ * Whether any of these doc files writes a doc token (`{@command …}`, `{@pm …}`
330
+ * or `{@pm-only …}`; an escaped `{@@…}` is not one).
331
+ * @param {unknown[]} files
332
+ * @returns {boolean}
333
+ */
334
+ function writesDocTokens(files) {
335
+ return files.some(file => {
336
+ if (typeof file !== 'string') return false;
337
+ try {
338
+ return commandTokensIn(fs.readFileSync(file, 'utf8')).length > 0;
339
+ } catch {
340
+ return false;
341
+ }
342
+ });
343
+ }
344
+
325
345
  /**
326
346
  * Whether any of these doc files has a section that sets `id`.
327
347
  * @param {string[]} files
328
348
  * @returns {Promise<boolean>}
329
349
  */
330
350
  async function setsSectionIds(files) {
351
+ return setsSectionField(files, ['id']);
352
+ }
353
+
354
+ /**
355
+ * Whether any of these doc files has a section that sets one of `fields`.
356
+ * @param {string[]} files
357
+ * @param {string[]} fields
358
+ * @returns {Promise<boolean>}
359
+ */
360
+ async function setsSectionField(files, fields) {
331
361
  for (const file of files) {
332
362
  if (typeof file !== 'string') continue;
333
363
  const doc = /** @type {any} */ (
334
364
  await loadTopicModule(file).catch(() => null)
335
365
  );
336
366
  const sections = Array.isArray(doc?.sections) ? doc.sections : [];
337
- if (sections.some((/** @type {any} */ section) => section?.id != null)) {
367
+ if (
368
+ sections.some((/** @type {any} */ section) =>
369
+ fields.some(field => section?.[field] != null),
370
+ )
371
+ ) {
338
372
  return true;
339
373
  }
340
374
  }
@@ -1383,6 +1417,36 @@ export async function integrationPackCheck(options = {}) {
1383
1417
  issues.push(error('section_ids_need_cli', idProblem));
1384
1418
  }
1385
1419
  }
1420
+ // `before` and `after` need a newer CLI than any field above. Added in a
1421
+ // patch release, it warns and never fails the check (INV35).
1422
+ if (
1423
+ await setsSectionField(
1424
+ [
1425
+ ...records.map(record => record.path),
1426
+ ...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),
1427
+ ],
1428
+ ['before', 'after'],
1429
+ )
1430
+ ) {
1431
+ const positionProblem = sectionPositionCliProblem(pkg);
1432
+ if (positionProblem != null) {
1433
+ issues.push(warning('section_position_needs_cli', positionProblem));
1434
+ }
1435
+ }
1436
+ // A doc token shows as written on a CLI before the one that renders
1437
+ // them. Added in a patch release, it warns and never fails (INV35).
1438
+ if (
1439
+ problem == null &&
1440
+ writesDocTokens([
1441
+ ...records.map(record => record.path),
1442
+ ...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),
1443
+ ])
1444
+ ) {
1445
+ const tokenProblem = docTokensCliProblem(pkg);
1446
+ if (tokenProblem != null) {
1447
+ issues.push(warning('doc_tokens_need_cli', tokenProblem));
1448
+ }
1449
+ }
1386
1450
  }
1387
1451
  // A template that sets `replaces` (spec:AST-035) or `keywords` needs a CLI
1388
1452
  // that reads the field: an older CLI drops that template and can hide the
@@ -1724,6 +1724,69 @@ describe('integrationPackCheck', () => {
1724
1724
  expect(await codes()).not.toContain('section_ids_need_cli');
1725
1725
  }, 120_000);
1726
1726
 
1727
+ it('warns, without failing, when a doc section sets before or after on a CLI range that rejects them', async () => {
1728
+ writePackage({
1729
+ manifest: "export default {docs: './docs'};\n",
1730
+ themes: false,
1731
+ });
1732
+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1733
+ const pkgFile = path.join(tmpDir, 'package.json');
1734
+ const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1735
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
1736
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1737
+ const issues = async () =>
1738
+ (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
1739
+ (/** @type {{code: string}} */ issue) =>
1740
+ issue.code === 'section_position_needs_cli',
1741
+ );
1742
+ // A placed guide's section counts too: an older CLI rejects the field in
1743
+ // any doc and hides the package's topics.
1744
+ fs.writeFileSync(
1745
+ path.join(tmpDir, 'docs', 'acme.doc.mjs'),
1746
+ "export default {type: 'namespace', name: 'acme', title: 'Acme', summary: 'Acme.', slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}}};\n",
1747
+ );
1748
+ fs.writeFileSync(
1749
+ path.join(tmpDir, 'docs', 'setup.doc.mjs'),
1750
+ "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",
1751
+ );
1752
+ expect(await issues()).toEqual([
1753
+ expect.objectContaining({severity: 'warning'}),
1754
+ ]);
1755
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
1756
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1757
+ expect(await issues()).toEqual([]);
1758
+ }, 120_000);
1759
+
1760
+ it('warns when a package whose docs write doc tokens has a CLI range that prints them raw', async () => {
1761
+ writePackage({
1762
+ manifest: "export default {docs: './docs'};\n",
1763
+ themes: false,
1764
+ });
1765
+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1766
+ const write = (/** @type {string} */ name, /** @type {string} */ text) =>
1767
+ fs.writeFileSync(
1768
+ path.join(tmpDir, 'docs', `${name}.doc.mjs`),
1769
+ `export default {type: 'generic', name: '${name}', title: 'Notes', description: 'Notes.', sections: [{title: 'Run', content: [{type: 'prose', text: ${JSON.stringify(text)}}]}]};\n`,
1770
+ );
1771
+ const found = async () =>
1772
+ (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
1773
+ (/** @type {{code: string}} */ issue) => issue.code === 'doc_tokens_need_cli',
1774
+ );
1775
+ // An escaped token is shown as written by every release.
1776
+ write('escaped', 'Write {@@pm install x} for an install.');
1777
+ expect(await found()).toEqual([]);
1778
+ write('tokens', 'Run {@command doctor} first.');
1779
+ expect((await found()).map((/** @type {any} */ issue) => issue.severity)).toEqual(['warning']);
1780
+ const pkgFile = path.join(tmpDir, 'package.json');
1781
+ const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1782
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.3'};
1783
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1784
+ expect(await found()).toHaveLength(1);
1785
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
1786
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1787
+ expect(await found()).toEqual([]);
1788
+ }, 120_000);
1789
+
1727
1790
  it('fails a package with a template that sets replaces on a CLI range that rejects the field', async () => {
1728
1791
  writePackage({
1729
1792
  manifest: "export default {templates: './templates'};\n",
@@ -73,6 +73,7 @@ describe('a doc whose name differs from its source only in case, on a case-insen
73
73
  expect(data.notes).toEqual([
74
74
  {
75
75
  code: 'source_without_component_doc',
76
+ next: true,
76
77
  message:
77
78
  'Component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run, so there the component is missing. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',
78
79
  },
@@ -103,6 +104,7 @@ describe('a doc whose name differs from its source only in case, on a case-insen
103
104
  expect(data.notes).toEqual([
104
105
  {
105
106
  code: 'source_without_component_doc',
107
+ next: true,
106
108
  message:
107
109
  'Hidden component doc "Acmewidget.doc.mjs" and its source "AcmeWidget.tsx" differ only in letter case. They pair on a case-insensitive disk (macOS, Windows) but not on Linux, where CI and most installs run. Fix: rename Acmewidget.doc.mjs to AcmeWidget.doc.mjs.',
108
110
  },
@@ -185,7 +185,7 @@ describe('a name that differs from its file name', () => {
185
185
  expect(await issuesOf(dir)).toEqual([]);
186
186
  const issues = await allOf(dir);
187
187
  expect(issues.map(issue => issue.code)).toEqual(['doc_name_mismatch']);
188
- expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message']);
188
+ expect(Object.keys(issues[0]).sort()).toEqual(['code', 'message', 'next']);
189
189
  expect(issues[0].message).toBe(
190
190
  'Component doc "AcmeWidget.doc.mjs" sets name: \'AcmeWidgets\', but components/AcmeWidget.tsx, the module its import names, does not export AcmeWidgets, so Astryx lists the component as "AcmeWidget" (its file name), and `astryx component AcmeWidget` prints `import {AcmeWidgets}`. Fix: set name: \'AcmeWidget\' in AcmeWidget.doc.mjs.',
191
191
  );
@@ -1369,6 +1369,7 @@ describe('package.json', () => {
1369
1369
  expect('notes' in validate ? validate.notes : undefined).toEqual([
1370
1370
  {
1371
1371
  code: 'invalid_package_json',
1372
+ next: true,
1372
1373
  message:
1373
1374
  'package.json has no "name", so npm cannot pack or publish the package, and a project that installs it has no name to select it by. Fix: add "name": "@your-scope/your-package" to package.json.',
1374
1375
  },
@@ -1892,7 +1893,9 @@ describe('layout findings 0.7.2 did not fail on', () => {
1892
1893
  );
1893
1894
  expect(validate.notes.length).toBeGreaterThan(0);
1894
1895
  for (const note of validate.notes) {
1895
- expect(Object.keys(note).sort()).toEqual(['code', 'message']);
1896
+ // Listed now, a warning from the next minor release: `next`.
1897
+ expect(Object.keys(note).sort()).toEqual(['code', 'message', 'next']);
1898
+ expect(note.next).toBe(true);
1896
1899
  expect(note.message).toContain('Fix: ');
1897
1900
  }
1898
1901
  } finally {
@@ -1917,7 +1920,7 @@ describe('layout findings 0.7.2 did not fail on', () => {
1917
1920
  );
1918
1921
  expect(run.status, run.stderr).toBe(0);
1919
1922
  expect(run.stdout).toContain(
1920
- 'note (duplicate_component_doc): Component "AcmeWidget" has 2 docs:',
1923
+ 'note (duplicate_component_doc): [next minor] Component "AcmeWidget" has 2 docs:',
1921
1924
  );
1922
1925
  expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');
1923
1926
  });
@@ -1968,7 +1971,7 @@ describe('name findings listed until the next minor release', () => {
1968
1971
  );
1969
1972
  expect(run.status, run.stderr).toBe(0);
1970
1973
  expect(run.stdout).toContain(
1971
- 'note (unknown_block_component): Template "account-card" names "AcmeGizmo" in componentsUsed',
1974
+ 'note (unknown_block_component): [next minor] Template "account-card" names "AcmeGizmo" in componentsUsed',
1972
1975
  );
1973
1976
  expect(run.stdout).toContain('Summary: 0 errors, 0 warnings');
1974
1977
  });