@astryxdesign/cli 0.7.4-canary.ccdb1b8 → 0.7.4-canary.d329515

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 (160) 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.mjs +13 -6
  6. package/api/docs/docOverlays.test.mjs +2 -1
  7. package/api/docs/docs.d.mts +16 -6
  8. package/api/docs/docs.mjs +55 -6
  9. package/api/docs/guide-route-targets.test.mjs +4 -0
  10. package/api/docs/integration-tree.test.mjs +22 -0
  11. package/api/docs/integrationDocs.test.mjs +85 -0
  12. package/api/doctor/doctor.doc.mjs +1 -1
  13. package/api/hook/list/list.d.mts +1 -1
  14. package/api/integration/_adapter.d.mts +3 -2
  15. package/api/integration/_adapter.mjs +5 -4
  16. package/api/integration/authoring-checks.test.mjs +131 -1
  17. package/api/integration/check/check.d.mts +4 -1
  18. package/api/integration/check/check.mjs +34 -4
  19. package/api/integration/check/check.test.mjs +49 -0
  20. package/api/integration/example-checks.no-npm.test.mjs +140 -0
  21. package/api/integration/example-checks.test.mjs +776 -0
  22. package/api/integration/integration-check.type.d.mts +8 -0
  23. package/api/integration/integration-check.type.mjs +4 -1
  24. package/api/integration/integrationCheck.doc.mjs +8 -1
  25. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  26. package/api/integration/pack-check.mjs +33 -0
  27. package/api/integration/pack-check.test.mjs +30 -0
  28. package/api/integration/validate-integration-case-disk.test.mjs +14 -2
  29. package/api/integration/validate-integration-gaps.test.mjs +43 -19
  30. package/api/integration/validate-integration.mjs +48 -15
  31. package/api/integration/validate-integration.type.d.mts +23 -4
  32. package/api/integration/validate-integration.type.mjs +14 -5
  33. package/api/integration/validateIntegration.doc.mjs +1 -1
  34. package/api/search/_candidate-score.d.mts +8 -3
  35. package/api/search/_candidate-score.mjs +26 -2
  36. package/api/search/_gather-components.mjs +48 -1
  37. package/api/search/_lexical.d.mts +12 -0
  38. package/api/search/_lexical.mjs +3 -0
  39. package/api/search/_priority.mjs +5 -3
  40. package/api/search/_score.mjs +2 -1
  41. package/api/search/search.doc.mjs +1 -1
  42. package/api/search/search.family-word.test.mjs +146 -0
  43. package/api/search/search.mjs +28 -0
  44. package/api/template/template-suffix.test.mjs +26 -0
  45. package/api/theme/themeBuild.doc.mjs +1 -1
  46. package/api/theme/themeList.doc.mjs +1 -1
  47. package/api/theme/themeTargets.doc.mjs +1 -1
  48. package/assets/docs/author-a-theme.doc.mjs +15 -15
  49. package/assets/docs/getting-started.doc.mjs +16 -16
  50. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  51. package/assets/docs/styling-overview.doc.mjs +5 -5
  52. package/assets/docs/theme.doc.mjs +3 -3
  53. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  54. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  55. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  56. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  57. package/assets/docs/tree/authoring.doc.mjs +2 -2
  58. package/assets/docs/tree/block-template.doc.mjs +1 -1
  59. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  60. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  61. package/assets/docs/tree/checks.doc.mjs +11 -11
  62. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  63. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  64. package/assets/docs/tree/codemods.doc.mjs +7 -7
  65. package/assets/docs/tree/component-family.doc.mjs +1 -1
  66. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  67. package/assets/docs/tree/component-lookups.doc.mjs +4 -4
  68. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  69. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  70. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  71. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  72. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  73. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  74. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  75. package/assets/docs/tree/extend-or-replace.doc.mjs +3 -3
  76. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  77. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  78. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  79. package/assets/docs/tree/global.doc.mjs +2 -2
  80. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  81. package/assets/docs/tree/install-once.doc.mjs +4 -4
  82. package/assets/docs/tree/layout.doc.mjs +1 -1
  83. package/assets/docs/tree/links.doc.mjs +2 -2
  84. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  85. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  86. package/assets/docs/tree/page-template.doc.mjs +2 -2
  87. package/assets/docs/tree/problems.doc.mjs +8 -8
  88. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  89. package/assets/docs/tree/publishing.doc.mjs +7 -7
  90. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  91. package/assets/docs/tree/reference.doc.mjs +2 -2
  92. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  93. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  94. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  95. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  96. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  97. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  98. package/assets/docs/tree/single-component.doc.mjs +4 -4
  99. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  100. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  101. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  102. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  103. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  104. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  105. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  106. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  107. package/assets/docs/tree/updates.doc.mjs +1 -1
  108. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  109. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  110. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  111. package/assets/docs/tree/versioning.doc.mjs +4 -4
  112. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  113. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  114. package/assets/docs/use-a-theme.doc.mjs +10 -10
  115. package/assets/docs/use-integrations.doc.mjs +1 -1
  116. package/assets/docs/working-with-ai.doc.mjs +15 -15
  117. package/authoring/codemod/codemod.doc.mjs +1 -1
  118. package/authoring/config/config.doc.mjs +4 -4
  119. package/authoring/debug/parse.d.mts +1 -1
  120. package/authoring/discover/discover.doc.mjs +1 -1
  121. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  122. package/authoring/integration/integration.doc.mjs +6 -6
  123. package/clients/cli/commands/docs.doc.mjs +1 -1
  124. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  125. package/clients/cli/commands/doctor.doc.mjs +1 -1
  126. package/clients/cli/commands/doctor.mjs +12 -1
  127. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  128. package/clients/cli/commands/integration-check.test.mjs +36 -3
  129. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  130. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  131. package/clients/cli/commands/integration.mjs +15 -3
  132. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  133. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  134. package/clients/cli/lib/define-command.mjs +5 -3
  135. package/foundation/agent-docs/agent-docs.mjs +11 -2
  136. package/foundation/agent-docs/agent-docs.test.mjs +46 -0
  137. package/foundation/discovery/docs-discovery.mjs +1 -0
  138. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  139. package/foundation/discovery/runner-allowlist.mjs +4 -0
  140. package/foundation/discovery/runner-commands.d.mts +29 -13
  141. package/foundation/discovery/runner-commands.mjs +253 -17
  142. package/foundation/discovery/stray-pointers.mjs +11 -5
  143. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  144. package/foundation/discovery/template-adapter.mjs +11 -0
  145. package/foundation/doc-compiler/doc-loads.test.mjs +4 -0
  146. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  147. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  148. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  149. package/foundation/doc-compiler/links.d.mts +13 -16
  150. package/foundation/doc-compiler/links.mjs +40 -7
  151. package/foundation/doc-compiler/tree.mjs +6 -0
  152. package/foundation/env/package-manager.d.mts +18 -0
  153. package/foundation/env/package-manager.mjs +40 -0
  154. package/foundation/integrations/cli-requirement.d.mts +15 -0
  155. package/foundation/integrations/cli-requirement.mjs +24 -0
  156. package/foundation/integrations/cli-requirement.test.mjs +22 -2
  157. package/foundation/integrations/validate-contributions.d.mts +53 -0
  158. package/foundation/integrations/validate-contributions.mjs +788 -0
  159. package/foundation/response/response-types.doc.mjs +2 -2
  160. package/package.json +9 -9
@@ -718,7 +718,7 @@ export async function linkSearchResponse(response, cwd) {
718
718
  result =>
719
719
  result?.domain === 'component' &&
720
720
  typeof result.description === 'string' &&
721
- result.description.includes('{@link'),
721
+ result.description.includes('{@'),
722
722
  )
723
723
  ) {
724
724
  return response;
@@ -728,7 +728,7 @@ export async function linkSearchResponse(response, cwd) {
728
728
  if (
729
729
  result?.domain !== 'component' ||
730
730
  typeof result.description !== 'string' ||
731
- !result.description.includes('{@link')
731
+ !result.description.includes('{@')
732
732
  ) {
733
733
  linked.push(result);
734
734
  continue;
@@ -767,7 +767,8 @@ export async function linkComponentResponse(response, cwd) {
767
767
  ) {
768
768
  return response;
769
769
  }
770
- if (!JSON.stringify(response.data ?? null).includes('{@link')) {
770
+ // Doc tokens render in the same pass as links.
771
+ if (!JSON.stringify(response.data ?? null).includes('{@')) {
771
772
  return response;
772
773
  }
773
774
  const catalog = await loadDocsCatalog(cwd);
@@ -12,6 +12,10 @@
12
12
  * Every leaf is also re-exported for direct scripting use.
13
13
  */
14
14
 
15
+ import {
16
+ docPackageManager,
17
+ runWithDocPackageManager,
18
+ } from '../../foundation/env/package-manager.mjs';
15
19
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
16
20
  import {AstryxError} from '../error.mjs';
17
21
  import {
@@ -258,13 +262,16 @@ async function componentBatch(selectors, options, coreDir) {
258
262
  * )>}
259
263
  */
260
264
  export async function component(name, options = {}) {
265
+ const cwd = options.cwd ?? process.cwd();
261
266
  // Every read resolves the links in the doc text it returns (spec:AST-047
262
- // FR9); a batch's results are each a read of their own.
263
- return /** @type {any} */ (
264
- await linkComponentResponse(
265
- await componentRead(name, options),
266
- options.cwd ?? process.cwd(),
267
- )
267
+ // FR9); a batch's results are each a read of their own. Doc tokens render
268
+ // for the project in `cwd`.
269
+ return runWithDocPackageManager(
270
+ docPackageManager(cwd),
271
+ async () =>
272
+ /** @type {any} */ (
273
+ await linkComponentResponse(await componentRead(name, options), cwd)
274
+ ),
268
275
  );
269
276
  }
270
277
 
@@ -219,6 +219,39 @@ describe("a link in a component doc's text", () => {
219
219
  });
220
220
  });
221
221
 
222
+ describe("doc tokens in a component doc's text", () => {
223
+ it(
224
+ 'render with no link beside them, in the read and in search, for the project in cwd',
225
+ async () => {
226
+ scaffold();
227
+ fs.writeFileSync(path.join(tmpDir, 'bun.lock'), '{}\n');
228
+ const docFile = path.join(
229
+ tmpDir,
230
+ 'node_modules/@acme/widgets/components/AcmeButton.doc.mjs',
231
+ );
232
+ fs.writeFileSync(
233
+ docFile,
234
+ `export default ${JSON.stringify({
235
+ ...ACME_BUTTON,
236
+ usage: {
237
+ description:
238
+ 'A button. Install with {@pm install @acme/widgets}; check with {@command doctor}.',
239
+ },
240
+ props: [],
241
+ examples: [],
242
+ })};\n`,
243
+ );
244
+ const read = /** @type {any} */ (
245
+ await component('AcmeButton', {cwd: tmpDir})
246
+ );
247
+ expect(read.data.usage.description).toBe(
248
+ 'A button. Install with `bun add @acme/widgets`; check with `astryx doctor`.',
249
+ );
250
+ },
251
+ SLOW,
252
+ );
253
+ });
254
+
222
255
  describe("a link in a topic's description", () => {
223
256
  it(
224
257
  'reads as the command that opens its doc, in the detail and the list',
@@ -46,6 +46,7 @@ import {
46
46
  linkBlocks,
47
47
  linkFields,
48
48
  parseLinkTarget,
49
+ renderTokens,
49
50
  } from '../../foundation/doc-compiler/links.mjs';
50
51
  import {
51
52
  createDocId,
@@ -315,7 +316,8 @@ function topicTextFields(doc) {
315
316
  * @returns {Promise<string>}
316
317
  */
317
318
  export async function linkDocText(catalog, providerId, text) {
318
- if (typeof text !== 'string' || !text.includes('{@link')) return text;
319
+ if (typeof text !== 'string') return text;
320
+ if (!text.includes('{@link')) return renderTokens(text);
319
321
  let provider;
320
322
  try {
321
323
  provider = normalizeProviderId(providerId);
@@ -343,7 +345,8 @@ export async function linkDocText(catalog, providerId, text) {
343
345
  * @returns {Promise<{doc: T, problems: LinkProblem[]}>}
344
346
  */
345
347
  export async function linkComponentDoc(catalog, providerId, doc) {
346
- if (!JSON.stringify(doc ?? null).includes('{@link')) {
348
+ // Doc tokens render in the same pass as links (resolveInline).
349
+ if (!JSON.stringify(doc ?? null).includes('{@')) {
347
350
  return {doc, problems: []};
348
351
  }
349
352
  return linkFields(
@@ -416,6 +419,7 @@ async function flatTopicInputs(catalog) {
416
419
  providerId: entry.providerId ?? entry.package,
417
420
  name: entry.name,
418
421
  title: title ?? entry.name,
422
+ // Rendered once, with the tree's other summaries (buildProjectTree).
419
423
  summary: description ?? '',
420
424
  category: category ?? null,
421
425
  source: `${entry.package}:${entry.name}`,
@@ -488,7 +492,7 @@ async function buildProjectTree(catalog, fresh) {
488
492
  // A summary is a doc's text too: each link in it reads as the command that
489
493
  // opens its doc, wherever the tree's summaries print (spec:AST-047 FR9).
490
494
  for (const node of result.nodes.values()) {
491
- if (typeof node.summary === 'string' && node.summary.includes('{@link')) {
495
+ if (typeof node.summary === 'string' && node.summary.includes('{@')) {
492
496
  const replacement = node.guideOverlay?.replacement;
493
497
  node.summary = await linkSummary(
494
498
  catalog,
@@ -517,7 +521,7 @@ async function buildProjectTree(catalog, fresh) {
517
521
  * @returns {Promise<string>}
518
522
  */
519
523
  async function linkSummary(catalog, tree, providerId, summary) {
520
- if (!summary.includes('{@link')) return summary;
524
+ if (!summary.includes('{@link')) return renderTokens(summary);
521
525
  let provider;
522
526
  try {
523
527
  provider = normalizeProviderId(providerId);
@@ -674,7 +678,7 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
674
678
  id: createDocId(provider, authored.type, authored.name),
675
679
  route: AUTHORING_REFERENCE_ROUTE,
676
680
  title: authored.displayName ?? authored.name,
677
- summary: authored.description ?? '',
681
+ summary: renderTokens(authored.description ?? ''),
678
682
  command: `astryx docs authoring ${authored.name}`,
679
683
  },
680
684
  kind: parsed.kind,
@@ -732,13 +736,16 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
732
736
  // The summary is the target doc's own text, so its links resolve
733
737
  // against the target's provider, never the linking doc's: a Core
734
738
  // component's against the CLI's docs, like its other fields.
735
- if (summaries && link.summary.includes('{@link')) {
739
+ // contributedDocLink returns the authored text; it renders once here.
740
+ if (summaries && link.summary.includes('{@')) {
736
741
  link.summary = await linkSummary(
737
742
  catalog,
738
743
  tree,
739
744
  provider === CORE_COMPONENT_PROVIDER ? CLI_PROVIDER_ID : provider,
740
745
  link.summary,
741
746
  );
747
+ } else {
748
+ link.summary = renderTokens(link.summary);
742
749
  }
743
750
  return {link: {target, ...link}, kind: parsed.kind, typed: null};
744
751
  }
@@ -176,8 +176,9 @@ describe('the reported defect: docs tokens --dense (#2182)', () => {
176
176
  for (const options of [{}, {dense: true}, {zh: true}]) {
177
177
  const result = await docs('theme', null, options);
178
178
  const rendered = JSON.stringify(result.data.sections);
179
+ // The command, as `{@command …}` or bare `astryx …`: both print it.
179
180
  expect(rendered).toContain(
180
- 'astryx theme palette generate palette.config.json --out palette.generated.ts',
181
+ 'theme palette generate palette.config.json --out palette.generated.ts',
181
182
  );
182
183
  expect(rendered).toContain(
183
184
  "import {palette} from './palette.generated';",
@@ -32,9 +32,19 @@ export function docs(topic?: string, section?: string, options?: {
32
32
  detail?: "compact" | "full" | "brief" | undefined;
33
33
  cwd?: string | undefined;
34
34
  }): Promise<import("./docs.type.mjs").DocsListResponse | import("./docs.type.mjs").DocsIndexResponse | import("./docs.type.mjs").DocsDetailResponse | import("./docs.type.mjs").DocsDetailSectionResponse | import("./docs.type.mjs").DocsNodeResponse>;
35
- import { list } from './list/list.mjs';
36
- import { index } from './index/index.mjs';
37
- import { detail } from './detail/detail.mjs';
38
- import { section as sectionLeaf } from './detail/section/section.mjs';
39
- import { node as nodeLeaf } from './node/node.mjs';
40
- export { list, index, detail, sectionLeaf as section, nodeLeaf as node };
35
+ /** @type {typeof listRead} */
36
+ export const list: typeof listRead;
37
+ /** @type {typeof indexRead} */
38
+ export const index: typeof indexRead;
39
+ /** @type {typeof detailRead} */
40
+ export const detail: typeof detailRead;
41
+ /** @type {typeof sectionRead} */
42
+ declare const sectionLeaf: typeof sectionRead;
43
+ /** @type {typeof nodeRead} */
44
+ declare const nodeLeaf: typeof nodeRead;
45
+ import { list as listRead } from './list/list.mjs';
46
+ import { index as indexRead } from './index/index.mjs';
47
+ import { detail as detailRead } from './detail/detail.mjs';
48
+ import { section as sectionRead } from './detail/section/section.mjs';
49
+ import { node as nodeRead } from './node/node.mjs';
50
+ export { sectionLeaf as section, nodeLeaf as node };
package/api/docs/docs.mjs CHANGED
@@ -23,18 +23,50 @@
23
23
  * overlay loading, and resolution they share sit in _adapter.mjs.
24
24
  */
25
25
 
26
- import {list} from './list/list.mjs';
27
- import {index} from './index/index.mjs';
28
- import {detail} from './detail/detail.mjs';
26
+ import {list as listRead} from './list/list.mjs';
27
+ import {index as indexRead} from './index/index.mjs';
28
+ import {detail as detailRead} from './detail/detail.mjs';
29
29
  import {
30
30
  namespaceSection,
31
- section as sectionLeaf,
31
+ section as sectionRead,
32
32
  } from './detail/section/section.mjs';
33
- import {node as nodeLeaf, nodeView} from './node/node.mjs';
33
+ import {node as nodeRead, nodeView} from './node/node.mjs';
34
34
  import {resolveDocsArgument} from './_adapter.mjs';
35
35
  import {AstryxError} from '../error.mjs';
36
36
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
37
- import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
37
+ import {
38
+ docPackageManager,
39
+ formatCliCommand,
40
+ runWithDocPackageManager,
41
+ } from '../../foundation/env/package-manager.mjs';
42
+
43
+ /**
44
+ * Run a docs read with `{@pm}` steps rendered for the project in `cwd`, the
45
+ * folder the read is about, not the process's working directory. A host that
46
+ * already chose a package manager keeps its choice.
47
+ * @template T
48
+ * @param {string | undefined} cwd
49
+ * @param {() => T} fn
50
+ * @returns {T}
51
+ */
52
+ function inProject(cwd, fn) {
53
+ return runWithDocPackageManager(docPackageManager(cwd ?? process.cwd()), fn);
54
+ }
55
+
56
+ /** @type {typeof listRead} */
57
+ const list = (options = {}) => inProject(options?.cwd, () => listRead(options));
58
+ /** @type {typeof indexRead} */
59
+ const index = (topic, options = {}) =>
60
+ inProject(options?.cwd, () => indexRead(topic, options));
61
+ /** @type {typeof detailRead} */
62
+ const detail = (topic, options = {}) =>
63
+ inProject(options?.cwd, () => detailRead(topic, options));
64
+ /** @type {typeof sectionRead} */
65
+ const sectionLeaf = (topic, sectionName, options = {}) =>
66
+ inProject(options?.cwd, () => sectionRead(topic, sectionName, options));
67
+ /** @type {typeof nodeRead} */
68
+ const nodeLeaf = (route, options = {}) =>
69
+ inProject(options?.cwd, () => nodeRead(route, options));
38
70
 
39
71
  export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
40
72
 
@@ -98,6 +130,23 @@ function depthRead(options) {
98
130
  * >}
99
131
  */
100
132
  export async function docs(topic, section, options = {}) {
133
+ return inProject(options.cwd, () => docsRead(topic, section, options));
134
+ }
135
+
136
+ /**
137
+ * The docs read itself, inside its project's package-manager scope.
138
+ * @param {string} [topic]
139
+ * @param {string} [section]
140
+ * @param {any} [options]
141
+ * @returns {Promise<
142
+ * import('./docs.type.mjs').DocsListResponse |
143
+ * import('./docs.type.mjs').DocsIndexResponse |
144
+ * import('./docs.type.mjs').DocsDetailResponse |
145
+ * import('./docs.type.mjs').DocsDetailSectionResponse |
146
+ * import('./docs.type.mjs').DocsNodeResponse
147
+ * >}
148
+ */
149
+ async function docsRead(topic, section, options = {}) {
101
150
  const read = depthRead(options);
102
151
  if (!topic) return list(options);
103
152
  const found = await resolveDocsArgument(topic, options);
@@ -296,6 +296,7 @@ describe('a flat topic that extends a placed guide by its route', () => {
296
296
  expect(validated.data.notes).toContainEqual({
297
297
  code: 'doc_section_unplaced',
298
298
  message: expect.stringContaining('"no-such-section"'),
299
+ next: true,
299
300
  });
300
301
  const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});
301
302
  expect(docsCheck.data.issues).toEqual([]);
@@ -361,6 +362,7 @@ describe('a route that holds no guide', () => {
361
362
  expect(validated.data.notes).toContainEqual({
362
363
  code: 'doc_target_not_found',
363
364
  message: expect.stringContaining('"authoring/no-such-guide"'),
365
+ next: true,
364
366
  });
365
367
  const docsCheck = await integrationDocConflicts(KIT, {cwd: tmpDir});
366
368
  expect(docsCheck.data.issues).toEqual([]);
@@ -604,6 +606,7 @@ describe('review follow-ups', () => {
604
606
  expect(validated.data.notes).toContainEqual({
605
607
  code: 'duplicate_guide_replacement',
606
608
  message: expect.stringContaining('"acme-b", is read'),
609
+ next: true,
607
610
  });
608
611
  const check = await integrationCheck({cwd: kitDir(), strict: true});
609
612
  expect(check.data.failed).toBe(false);
@@ -756,6 +759,7 @@ describe('third review follow-ups', () => {
756
759
  expect(validated.data.notes).toContainEqual({
757
760
  code: 'duplicate_guide_replacement',
758
761
  message: expect.stringContaining('"acme-b", is read'),
762
+ next: true,
759
763
  });
760
764
  },
761
765
  SLOW,
@@ -189,6 +189,28 @@ describe('integration docs in the docs tree', () => {
189
189
  ).toEqual(['acme/setup', 'acme/deploy']);
190
190
  }, SLOW);
191
191
 
192
+ it('renders a placed guide summary once, so an escaped token stays written', async () => {
193
+ scaffold({
194
+ ...kit(),
195
+ 'deploy.doc.mjs': guide('deploy', {
196
+ description: 'Show the syntax {@@pm run build} beside {@pm run build}.',
197
+ placement: {parent: 'namespace:acme', slot: 'guides', order: 2},
198
+ }),
199
+ });
200
+ const top = await docs('acme', undefined, {cwd: tmpDir});
201
+ const deploy = top.data.slots[0].children.find((/** @type {any} */ c) => c.route === 'acme/deploy');
202
+ expect(deploy.summary).toMatch(/^Show the syntax \{@pm run build\} beside `\S+ run build`\.$/);
203
+ }, SLOW);
204
+
205
+ it('renders a flat topic summary once, so an escaped token stays written', async () => {
206
+ scaffold({
207
+ ...kit(),
208
+ 'notes.doc.mjs': {...kit()['notes.doc.mjs'], description: 'Show the syntax {@@pm run build} beside {@pm run build}.'},
209
+ });
210
+ const listed = await docs('guides', undefined, {cwd: tmpDir});
211
+ expect(JSON.stringify(listed.data)).toContain('Show the syntax {@pm run build} beside `');
212
+ }, SLOW);
213
+
192
214
  it('reads a placed guide one level at a time, with its links resolved', async () => {
193
215
  scaffold(kit());
194
216
  const index = await docs('acme/setup', undefined, {cwd: tmpDir, index: true});
@@ -164,6 +164,46 @@ describe('integration-contributed topics', () => {
164
164
  expect(prose).not.toContain('{@link');
165
165
  }, SLOW);
166
166
 
167
+ it('renders a linked component or template summary once, so an escaped token stays written', async () => {
168
+ scaffold({
169
+ 'using-widgets.doc.mjs': topic({
170
+ name: 'using-widgets',
171
+ title: 'Using widgets',
172
+ sections: [
173
+ {
174
+ title: 'Overview',
175
+ content: [
176
+ {type: 'reference', target: 'component:AcmeButton'},
177
+ {type: 'reference', target: 'block:acme-card'},
178
+ ],
179
+ },
180
+ ],
181
+ }),
182
+ });
183
+ const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
184
+ fs.writeFileSync(
185
+ path.join(pkgDir, 'astryx.integration.mjs'),
186
+ "export default {components: './components', templates: './templates', docs: './docs'};\n",
187
+ );
188
+ fs.mkdirSync(path.join(pkgDir, 'components'));
189
+ fs.writeFileSync(
190
+ path.join(pkgDir, 'components', 'AcmeButton.doc.mjs'),
191
+ "export default {type: 'component', name: 'AcmeButton', displayName: 'Acme Button', description: 'Shows {@@pm run build}.', props: []};\n",
192
+ );
193
+ fs.writeFileSync(path.join(pkgDir, 'components', 'AcmeButton.tsx'), 'export function AcmeButton() { return null; }\n');
194
+ fs.mkdirSync(path.join(pkgDir, 'templates'));
195
+ fs.writeFileSync(
196
+ path.join(pkgDir, 'templates', 'acme-card.doc.mjs'),
197
+ "export default {type: 'block', name: 'Acme card', description: 'Card for {@@pm run build}.'};\n",
198
+ );
199
+ fs.writeFileSync(path.join(pkgDir, 'templates', 'acme-card.tsx'), 'export default function Fixture() { return null; }\n');
200
+
201
+ const detail = await docs('using-widgets', undefined, {cwd: tmpDir, full: true});
202
+ const text = JSON.stringify(detail.data);
203
+ expect(text).toContain('Shows {@pm run build}.');
204
+ expect(text).toContain('Card for {@pm run build}.');
205
+ }, SLOW);
206
+
167
207
  it('selects Core in a link only where the bare name would open something else', async () => {
168
208
  const core = await discoverCoreTemplates();
169
209
  const page = core.find(template => template.type === 'page')?.dirName;
@@ -459,3 +499,48 @@ describe('integration-contributed topics', () => {
459
499
  expect(catalog.resolve('deploying')).toBeUndefined();
460
500
  }, SLOW);
461
501
  });
502
+
503
+ describe('doc tokens in a contributed topic', () => {
504
+ it(
505
+ 'render in the list, the read and search, for the project the read is about',
506
+ async () => {
507
+ scaffold({
508
+ 'deploying.doc.mjs': topic({
509
+ description:
510
+ 'Install with {@pm install @acme/widgets}, then run {@command doctor}.',
511
+ sections: [
512
+ {
513
+ title: 'Overview',
514
+ content: [{type: 'prose', text: 'Run {@command doctor} first.'}],
515
+ },
516
+ ],
517
+ }),
518
+ });
519
+ // The project in tmpDir uses Bun; the process's own folder uses pnpm.
520
+ fs.writeFileSync(path.join(tmpDir, 'bun.lock'), '{}\n');
521
+
522
+ const listed = await docs(undefined, undefined, {cwd: tmpDir});
523
+ const entry = listed.data.find(t => t.topic === 'deploying');
524
+ expect(entry.description).toBe(
525
+ 'Install with `bun add @acme/widgets`, then run `astryx doctor`.',
526
+ );
527
+ const detail = await docs('deploying', undefined, {
528
+ cwd: tmpDir,
529
+ full: true,
530
+ });
531
+ expect(JSON.stringify(detail)).not.toContain('{@');
532
+ expect(detail.data.sections[0].content[0].text).toBe(
533
+ 'Run `astryx doctor` first.',
534
+ );
535
+ // Core's own docs show tokens as written on purpose; this topic's render.
536
+ const found = await search('deploying', {cwd: tmpDir, type: 'doc'});
537
+ const hit = found.data.results.find(
538
+ (/** @type {any} */ result) => result.name === 'deploying',
539
+ );
540
+ expect(hit.description).toBe(
541
+ 'Install with `bun add @acme/widgets`, then run `astryx doctor`.',
542
+ );
543
+ },
544
+ SLOW,
545
+ );
546
+ });
@@ -24,7 +24,7 @@ export const doc = {
24
24
  'integration provider identity and contribution issues, agent docs, the ' +
25
25
  'detected package manager, and the health of the docs the CLI reads (authoring ' +
26
26
  'and CLI docs, the docs tree, doc size), and returns a structured ' +
27
- 'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `astryx init --user` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `npm i -g @astryxdesign/cli@latest`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +
27
+ 'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `{@command init --user}` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `{@pm install @astryxdesign/cli@latest --global}`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +
28
28
  ' In global mode: with `cwd` outside a project, it checks the computer instead (the Node version, the version that answered, the newest version it knows of, the astryx commands on the search path, the integrations installed globally, and the agent guide for the computer) and never fails a check because the folder has no project. See {@link namespace:global} and {@link generic:who-answers}.',
29
29
  importPath: '@astryxdesign/cli/api',
30
30
  signature: 'doctor(options?: DoctorOptions): Promise<DoctorResponse>',
@@ -13,7 +13,7 @@
13
13
  export function list({ cwd, category, detail, zh, lang, }?: {
14
14
  cwd?: string | undefined;
15
15
  category?: string | undefined;
16
- detail?: "names" | "compact" | "full" | "brief" | undefined;
16
+ detail?: "compact" | "full" | "names" | "brief" | undefined;
17
17
  zh?: boolean | undefined;
18
18
  lang?: string | null | undefined;
19
19
  }): Promise<import("../hook.type.mjs").HookListResponse>;
@@ -49,13 +49,14 @@ export function integrationStrayPointers(discovered: Parameters<typeof findStray
49
49
  */
50
50
  export function integrationDocTargets(integration: any): Promise<import("../docs/_adapter.mjs").DocTarget[]>;
51
51
  /**
52
- * Each Astryx command a package's topics write with a package runner. A
52
+ * The doc-syntax findings in a package's topics: commands written with a
53
+ * runner, for one package manager, or bare, and tokens that do not parse. A
53
54
  * package whose topics cannot be discovered has none here: the other checks
54
55
  * report topics that do not load.
55
56
  * @param {any} integration a loaded integration
56
57
  * @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
57
58
  */
58
- export function integrationRunnerCommands(integration: any): Promise<import("../../foundation/discovery/runner-commands.mjs").RunnerCommand[]>;
59
+ export function integrationDocCommands(integration: any): Promise<import("../../foundation/discovery/runner-commands.mjs").RunnerCommand[]>;
59
60
  import { findCopiedPassages } from '../../foundation/discovery/copied-passages.mjs';
60
61
  import { findFluff } from '../../foundation/discovery/doc-fluff.mjs';
61
62
  import { findStrayPointers } from '../../foundation/discovery/stray-pointers.mjs';
@@ -20,7 +20,7 @@ import {packageDocTargets} from '../docs/_adapter.mjs';
20
20
  import {comparePropDocs} from '../../foundation/discovery/prop-drift.mjs';
21
21
  import {findCopiedPassages} from '../../foundation/discovery/copied-passages.mjs';
22
22
  import {findFluff} from '../../foundation/discovery/doc-fluff.mjs';
23
- import {findRunnerCommands} from '../../foundation/discovery/runner-commands.mjs';
23
+ import {findDocCommands} from '../../foundation/discovery/runner-commands.mjs';
24
24
  import {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';
25
25
 
26
26
  /**
@@ -140,18 +140,19 @@ export async function integrationDocTargets(integration) {
140
140
  }
141
141
 
142
142
  /**
143
- * Each Astryx command a package's topics write with a package runner. A
143
+ * The doc-syntax findings in a package's topics: commands written with a
144
+ * runner, for one package manager, or bare, and tokens that do not parse. A
144
145
  * package whose topics cannot be discovered has none here: the other checks
145
146
  * report topics that do not load.
146
147
  * @param {any} integration a loaded integration
147
148
  * @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
148
149
  */
149
- export async function integrationRunnerCommands(integration) {
150
+ export async function integrationDocCommands(integration) {
150
151
  let discovered;
151
152
  try {
152
153
  discovered = await discoverIntegrationDocs(integration);
153
154
  } catch {
154
155
  return [];
155
156
  }
156
- return findRunnerCommands(discovered);
157
+ return findDocCommands(discovered);
157
158
  }