@astryxdesign/cli 0.6.5-canary.c3016f8 → 0.6.5-canary.c8d8a1d

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 (167) hide show
  1. package/README.md +14 -13
  2. package/api/build/_adapter.d.mts +36 -2
  3. package/api/build/_adapter.mjs +41 -10
  4. package/api/build/build.doc.mjs +2 -2
  5. package/api/build/build.test.mjs +38 -2
  6. package/api/build/kit/kit.mjs +65 -21
  7. package/api/build/kit/rank.d.mts +24 -8
  8. package/api/build/kit/rank.mjs +277 -97
  9. package/api/build/kit/rank.test.mjs +231 -48
  10. package/api/docs/docs.test.mjs +279 -0
  11. package/api/docs/integration-tree.test.mjs +572 -0
  12. package/api/docs/integrationDocs.test.mjs +336 -0
  13. package/api/error.d.mts +22 -0
  14. package/api/error.mjs +42 -0
  15. package/api/integration/add-contribution.d.mts +2 -1
  16. package/api/integration/add-contribution.mjs +7 -3
  17. package/api/integration/add-contribution.test.mjs +3 -3
  18. package/api/integration/add-theme.mjs +246 -24
  19. package/api/integration/add-theme.test.mjs +214 -1
  20. package/api/integration/authoring-checks.mjs +10 -7
  21. package/api/integration/authoring-checks.type.d.mts +8 -0
  22. package/api/integration/authoring-checks.type.mjs +7 -3
  23. package/api/integration/integration-authoring.type.d.mts +4 -1
  24. package/api/integration/integration-authoring.type.mjs +6 -1
  25. package/api/integration/integrationAdd.doc.mjs +6 -0
  26. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  27. package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
  28. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  29. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  30. package/api/integration/pack-check.mjs +12 -3
  31. package/api/integration/pack-check.test.mjs +52 -3
  32. package/api/integration/validate-integration.d.mts +4 -2
  33. package/api/integration/validate-integration.mjs +7 -2
  34. package/api/integration/validate-integration.test.mjs +55 -0
  35. package/api/integration/validate-integration.type.d.mts +5 -0
  36. package/api/integration/validate-integration.type.mjs +5 -1
  37. package/api/integration/validateIntegration.doc.mjs +1 -1
  38. package/api/layout/expand/expand.mjs +12 -7
  39. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  40. package/api/layout/layout.type.d.mts +1 -0
  41. package/api/layout/layout.type.mjs +1 -0
  42. package/api/layout/layoutExpand.doc.mjs +1 -1
  43. package/api/search/search.d.mts +24 -0
  44. package/api/search/search.mjs +71 -1
  45. package/api/search/search.test.mjs +710 -0
  46. package/api/swizzle/copy/copy.mjs +66 -3
  47. package/api/swizzle/swizzle.doc.mjs +4 -0
  48. package/api/template/copy/copy.mjs +14 -8
  49. package/api/template/copy/copy.receipt.test.mjs +77 -0
  50. package/api/template/show/show.mjs +15 -4
  51. package/api/template/show/show.test.mjs +76 -0
  52. package/api/template/template-integration.test.mjs +14 -0
  53. package/api/template/template.d.mts +1 -1
  54. package/api/template/template.doc.mjs +6 -2
  55. package/api/template/template.mjs +1 -0
  56. package/api/template/template.type.d.mts +2 -0
  57. package/api/template/template.type.mjs +2 -0
  58. package/api/theme/build/build.d.mts +24 -0
  59. package/api/theme/build/build.mjs +235 -8
  60. package/api/theme/build/build.project-core.test.mjs +165 -0
  61. package/api/upgrade/run/run.mjs +20 -3
  62. package/api/upgrade/run/run.test.mjs +45 -1
  63. package/api/upgrade/upgrade.doc.mjs +1 -1
  64. package/api/upgrade/upgrade.type.d.mts +1 -0
  65. package/api/upgrade/upgrade.type.mjs +1 -0
  66. package/assets/docs/icons.doc.mjs +1 -0
  67. package/assets/docs/theme.doc.mjs +1 -1
  68. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  69. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  70. package/assets/docs/tree/checks.doc.mjs +1 -1
  71. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  72. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  73. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  74. package/assets/docs/tree/troubleshooting.doc.mjs +9 -5
  75. package/assets/docs/tree/versioning.doc.mjs +7 -6
  76. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  77. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  78. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  79. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  80. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  81. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  82. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  83. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  84. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  85. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  86. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  87. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  88. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  89. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  90. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  91. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  92. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  93. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  94. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  95. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  96. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  97. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  98. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  99. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  100. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  101. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  102. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  103. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  104. package/assets/templates/pages/library/template.doc.mjs +15 -1
  105. package/assets/templates/pages/login/template.doc.mjs +10 -1
  106. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  107. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  108. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  109. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  110. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  111. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  112. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  113. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  114. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  115. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  116. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  117. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  118. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  119. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  120. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  121. package/assets/templates/pages/table/template.doc.mjs +11 -1
  122. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  123. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  124. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  125. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  126. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  127. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  128. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  129. package/assets/templates/themes/butter/icons.tsx +2 -0
  130. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  131. package/assets/templates/themes/gothic/icons.tsx +2 -0
  132. package/assets/templates/themes/matcha/icons.tsx +2 -0
  133. package/assets/templates/themes/neutral/icons.tsx +2 -0
  134. package/assets/templates/themes/stone/icons.tsx +2 -0
  135. package/assets/templates/themes/y2k/icons.tsx +2 -0
  136. package/authoring/doctypes/template/parse.d.mts +2 -0
  137. package/authoring/doctypes/template/parse.mjs +1 -0
  138. package/authoring/doctypes/template/parse.test.mjs +21 -0
  139. package/authoring/doctypes/template/template.doc.mjs +6 -0
  140. package/authoring/doctypes/template/type.ts +10 -0
  141. package/clients/cli/commands/docs.test.mjs +383 -0
  142. package/clients/cli/commands/doctor.mjs +4 -4
  143. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  144. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  145. package/clients/cli/commands/integration.mjs +3 -1
  146. package/clients/cli/commands/layout-expand.doc.mjs +3 -1
  147. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  148. package/clients/cli/commands/layout.mjs +16 -0
  149. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  150. package/clients/cli/commands/template.mjs +19 -5
  151. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  152. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  153. package/clients/cli/commands/write-failure.test.mjs +175 -0
  154. package/clients/cli/lib/manifest.mjs +44 -165
  155. package/clients/cli/lib/manifest.test.mjs +98 -7
  156. package/foundation/agent-docs/agent-docs.test.mjs +1160 -0
  157. package/foundation/discovery/template-adapter.d.mts +14 -0
  158. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  159. package/foundation/discovery/template-adapter.mjs +21 -1
  160. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  161. package/foundation/doc-compiler/tree.test.mjs +649 -0
  162. package/foundation/integrations/cli-requirement.d.mts +57 -13
  163. package/foundation/integrations/cli-requirement.mjs +84 -22
  164. package/foundation/integrations/cli-requirement.test.mjs +135 -8
  165. package/foundation/response/response-types.doc.d.mts +5 -5
  166. package/foundation/response/response-types.doc.mjs +13 -13
  167. package/package.json +9 -9
@@ -49,21 +49,25 @@
49
49
  */
50
50
 
51
51
  /**
52
+ * Each of the three authoring checks reports `validated`: false means no
53
+ * integration manifest was found, so nothing was inspected and the empty
54
+ * conflicts/findings list carries no information about the package.
55
+ *
52
56
  * @typedef {object} IntegrationTemplateConflictResponse
53
57
  * @property {'integration.template-conflicts'} type
54
- * @property {{name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
58
+ * @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
55
59
  */
56
60
 
57
61
  /**
58
62
  * @typedef {object} IntegrationComponentConflictResponse
59
63
  * @property {'integration.component-conflicts'} type
60
- * @property {{name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
64
+ * @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
61
65
  */
62
66
 
63
67
  /**
64
68
  * @typedef {object} IntegrationDocConflictResponse
65
69
  * @property {'integration.doc-conflicts'} type
66
- * @property {{name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
70
+ * @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
67
71
  */
68
72
 
69
73
  export {};
@@ -19,7 +19,9 @@ export type IntegrationAddCodemodOptions = IntegrationAddBaseOptions & {
19
19
  to: string;
20
20
  };
21
21
  export type IntegrationAddAgentDocOptions = IntegrationAddBaseOptions;
22
- export type IntegrationAddThemeOptions = IntegrationAddBaseOptions;
22
+ export type IntegrationAddThemeOptions = IntegrationAddBaseOptions & {
23
+ from?: string;
24
+ };
23
25
  /**
24
26
  * Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
25
27
  * when the contribution kind is known so the accepted options stay narrow.
@@ -54,4 +56,5 @@ export type IntegrationAddData = {
54
56
  files: string[];
55
57
  written: boolean;
56
58
  dryRun: boolean;
59
+ from?: string | undefined;
57
60
  };
@@ -37,7 +37,11 @@
37
37
  */
38
38
 
39
39
  /** @typedef {IntegrationAddBaseOptions} IntegrationAddAgentDocOptions */
40
- /** @typedef {IntegrationAddBaseOptions} IntegrationAddThemeOptions */
40
+ /**
41
+ * @typedef {IntegrationAddBaseOptions & {
42
+ * from?: string,
43
+ * }} IntegrationAddThemeOptions
44
+ */
41
45
 
42
46
  /**
43
47
  * Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
@@ -73,6 +77,7 @@
73
77
  * @property {string[]} files
74
78
  * @property {boolean} written
75
79
  * @property {boolean} dryRun
80
+ * @property {string} [from]
76
81
  */
77
82
 
78
83
  export {};
@@ -78,6 +78,12 @@ export const doc = {
78
78
  type: 'string',
79
79
  description: 'Exact target semver (e.g. 1.2.0). Required for codemod and only valid there.',
80
80
  },
81
+ {
82
+ name: 'options.from',
83
+ type: 'string',
84
+ description:
85
+ 'Slug of an existing theme to fork as the starting point. Only valid for theme.',
86
+ },
81
87
  ],
82
88
  returns: [
83
89
  {
@@ -33,6 +33,12 @@ export const doc = {
33
33
  'Validate and return the same receipt without writing; data.written is false and data.dryRun is true.',
34
34
  default: 'false',
35
35
  },
36
+ {
37
+ name: 'options.from',
38
+ type: 'string',
39
+ description:
40
+ 'Slug of an existing theme to fork as the starting point. The new theme copies the base and has no link back.',
41
+ },
36
42
  ],
37
43
  returns: [
38
44
  {
@@ -76,6 +82,10 @@ export const doc = {
76
82
  label: 'Add a theme',
77
83
  code: "await integrationAddTheme('ocean');",
78
84
  },
85
+ {
86
+ label: 'Fork an existing theme',
87
+ code: "await integrationAddTheme('ocean', {from: 'neutral'});",
88
+ },
79
89
  {
80
90
  label: 'Preview writes',
81
91
  code: "await integrationAddTheme('ocean', {dryRun: true});",
@@ -26,7 +26,7 @@ export const doc = {
26
26
  {
27
27
  type: 'integration.component-conflicts',
28
28
  description:
29
- 'Integration identity, structural issues, and Core component-name conflicts with package-qualified commands.',
29
+ '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and Core component-name conflicts with package-qualified commands.',
30
30
  },
31
31
  ],
32
32
  examples: [
@@ -26,7 +26,7 @@ export const doc = {
26
26
  {
27
27
  type: 'integration.doc-conflicts',
28
28
  description:
29
- 'Integration identity, structural issues, and classified Core doc relationships.',
29
+ '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and classified Core doc relationships.',
30
30
  },
31
31
  ],
32
32
  examples: [
@@ -41,7 +41,7 @@ export const doc = {
41
41
  {
42
42
  type: 'integration.template-conflicts',
43
43
  description:
44
- 'The integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
44
+ '`validated` (false when no integration manifest was found, so nothing was inspected and the empty conflict list carries no information), the integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
45
45
  },
46
46
  ],
47
47
  examples: [
@@ -29,6 +29,7 @@ import {assertWithin} from '../../foundation/fs/path-safety.mjs';
29
29
  import {resolvePackageDir} from '../../foundation/integrations/integrations.mjs';
30
30
  import {
31
31
  docsTreeCliProblem,
32
+ keywordsCliProblem,
32
33
  replacesCliProblem,
33
34
  sectionIdsCliProblem,
34
35
  themesCliProblem,
@@ -663,15 +664,16 @@ export async function integrationPackCheck(options = {}) {
663
664
  ])
664
665
  ) {
665
666
  // A section `id` is also a field an older CLI rejects, hiding the
666
- // package's doc topics; the same peer range fixes both.
667
+ // package's doc topics. It needs an older CLI than the docs tree does.
667
668
  const idProblem = sectionIdsCliProblem(pkg);
668
669
  if (idProblem != null) {
669
670
  issues.push(error('section_ids_need_cli', idProblem));
670
671
  }
671
672
  }
672
673
  }
673
- // A template that sets `replaces` needs a CLI that reads the field
674
- // (spec:AST-035): an older CLI drops that template and hides the package's docs.
674
+ // A template that sets `replaces` (spec:AST-035) or `keywords` needs a CLI
675
+ // that reads the field: an older CLI drops that template and hides the
676
+ // package's docs.
675
677
  if (loaded.templates) {
676
678
  const found = await discoverIntegrationTemplatesForOne(loaded).catch(
677
679
  () => ({templates: [], errors: []}),
@@ -683,6 +685,13 @@ export async function integrationPackCheck(options = {}) {
683
685
  );
684
686
  const problem = setsReplaces ? replacesCliProblem(pkg) : null;
685
687
  if (problem != null) issues.push(error('replaces_needs_cli', problem));
688
+ const setsKeywords = found.templates.some(
689
+ template => template.keywords != null && template.keywords.length > 0,
690
+ );
691
+ const keywordsProblem = setsKeywords ? keywordsCliProblem(pkg) : null;
692
+ if (keywordsProblem != null) {
693
+ issues.push(error('keywords_needs_cli', keywordsProblem));
694
+ }
686
695
  }
687
696
  // A theme needs a CLI that reads typed theme descriptors: an older CLI
688
697
  // rejects the themes root and withholds the package's themes and docs.
@@ -37,7 +37,7 @@ function writePackage({
37
37
  } = {}) {
38
38
  const pkg = {name, version};
39
39
  // A theme needs a CLI that reads typed theme descriptors.
40
- if (themes) pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
40
+ if (themes) pkg.peerDependencies = {'@astryxdesign/cli': '>=0.6.4'};
41
41
  if (files !== undefined) pkg.files = files;
42
42
  if (scripts !== undefined) pkg.scripts = scripts;
43
43
  fs.writeFileSync(
@@ -118,6 +118,14 @@ describe('integrationPackCheck', () => {
118
118
  expect(old.data.issues).toContainEqual(
119
119
  expect.objectContaining({code: 'themes_need_cli'}),
120
120
  );
121
+
122
+ // Published 0.6.4 reads typed theme descriptors.
123
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.6.4'};
124
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
125
+ const current = await integrationPackCheck({cwd: tmpDir});
126
+ expect(current.data.issues).not.toContainEqual(
127
+ expect.objectContaining({code: 'themes_need_cli'}),
128
+ );
121
129
  });
122
130
 
123
131
  it('fails when a theme entry omits its inferred runtime export', async () => {
@@ -366,7 +374,10 @@ describe('integrationPackCheck', () => {
366
374
  expect(await codes()).toContain('docs_tree_needs_cli');
367
375
  peer('^0.6.0 || >=0.7.0');
368
376
  expect(await codes()).toContain('docs_tree_needs_cli');
369
- peer('>=0.7.0');
377
+ peer('>=0.6.3');
378
+ expect(await codes()).toContain('docs_tree_needs_cli');
379
+ // Published 0.6.4 reads the docs tree.
380
+ peer('>=0.6.4');
370
381
  expect(await codes()).not.toContain('docs_tree_needs_cli');
371
382
  }, 120_000);
372
383
 
@@ -421,7 +432,11 @@ describe('integrationPackCheck', () => {
421
432
  expect(await codes()).toContain('section_ids_need_cli');
422
433
  const pkgFile = path.join(tmpDir, 'package.json');
423
434
  const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
424
- pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
435
+ pkg.peerDependencies = {'@astryxdesign/cli': '^0.6.3'};
436
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
437
+ expect(await codes()).toContain('section_ids_need_cli');
438
+ // Published 0.6.4 reads a section id.
439
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.6.4'};
425
440
  fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
426
441
  expect(await codes()).not.toContain('section_ids_need_cli');
427
442
  }, 120_000);
@@ -453,10 +468,44 @@ describe('integrationPackCheck', () => {
453
468
  expect(await codes()).toContain('replaces_needs_cli');
454
469
  peer('^0.6.0');
455
470
  expect(await codes()).toContain('replaces_needs_cli');
471
+ // `replaces` still needs 0.7.0.
472
+ peer('>=0.6.4');
473
+ expect(await codes()).toContain('replaces_needs_cli');
456
474
  peer('>=0.7.0');
457
475
  expect(await codes()).not.toContain('replaces_needs_cli');
458
476
  }, 120_000);
459
477
 
478
+ it('fails a package with a template that sets keywords on a CLI range that rejects the field', async () => {
479
+ writePackage({manifest: "export default {templates: './templates'};\n", themes: false});
480
+ fs.mkdirSync(path.join(tmpDir, 'templates'), {recursive: true});
481
+ fs.writeFileSync(
482
+ path.join(tmpDir, 'templates', 'acme-health.doc.mjs'),
483
+ "export default {type: 'page', name: 'acme-health', description: 'Status tiles.', keywords: ['uptime']};\n",
484
+ );
485
+ fs.writeFileSync(
486
+ path.join(tmpDir, 'templates', 'acme-health.tsx'),
487
+ 'export default function AcmeHealth() { return null; }\n',
488
+ );
489
+ const file = path.join(tmpDir, 'package.json');
490
+ const peer = (/** @type {string | undefined} */ range) => {
491
+ const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
492
+ if (range == null) delete pkg.peerDependencies;
493
+ else pkg.peerDependencies = {'@astryxdesign/cli': range};
494
+ fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
495
+ };
496
+ const codes = async () =>
497
+ (await integrationPackCheck({cwd: tmpDir})).data.issues.map(
498
+ (/** @type {{code: string}} */ issue) => issue.code,
499
+ );
500
+
501
+ peer(undefined);
502
+ expect(await codes()).toContain('keywords_needs_cli');
503
+ peer('^0.6.0');
504
+ expect(await codes()).toContain('keywords_needs_cli');
505
+ peer('>=0.7.0');
506
+ expect(await codes()).not.toContain('keywords_needs_cli');
507
+ }, 120_000);
508
+
460
509
  it('passes when package.json has no files field', async () => {
461
510
  writePackage({files: undefined});
462
511
  const result = await integrationPackCheck({cwd: tmpDir});
@@ -19,8 +19,10 @@ export function validateInstalledIntegration(spec: string, cwd?: string): Promis
19
19
  /**
20
20
  * Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
21
21
  * (`pkg` given) and return the `integration.validate` envelope. The no-manifest
22
- * local case is guidance, not an error — it comes back with `name: null` and no
23
- * issues so the CLI can print a hint and stay exit-0.
22
+ * local case is guidance, not an error — it comes back with `validated: false`,
23
+ * `name: null` and no issues so the CLI can print a hint and stay exit-0.
24
+ * `validated` is what tells a machine consumer that empty `issues` means
25
+ * "nothing was checked" rather than "checked and healthy".
24
26
  *
25
27
  * This is the seam that keeps the CLI a thin wrapper: the command handler calls
26
28
  * this and only chooses how to render (human vs --json) + the exit code.
@@ -427,8 +427,10 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
427
427
  /**
428
428
  * Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
429
429
  * (`pkg` given) and return the `integration.validate` envelope. The no-manifest
430
- * local case is guidance, not an error — it comes back with `name: null` and no
431
- * issues so the CLI can print a hint and stay exit-0.
430
+ * local case is guidance, not an error — it comes back with `validated: false`,
431
+ * `name: null` and no issues so the CLI can print a hint and stay exit-0.
432
+ * `validated` is what tells a machine consumer that empty `issues` means
433
+ * "nothing was checked" rather than "checked and healthy".
432
434
  *
433
435
  * This is the seam that keeps the CLI a thin wrapper: the command handler calls
434
436
  * this and only chooses how to render (human vs --json) + the exit code.
@@ -445,6 +447,9 @@ export async function validateIntegration(pkg, options = {}) {
445
447
  return {
446
448
  type: 'integration.validate',
447
449
  data: {
450
+ // The one bit that separates "checked and clean" from "never checked":
451
+ // with no manifest there is nothing to validate, and issues stays [].
452
+ validated: result.found,
448
453
  name: result.found ? (result.name ?? null) : null,
449
454
  version: result.found ? (result.version ?? null) : null,
450
455
  issues: result.issues,
@@ -625,3 +625,58 @@ describe('integration diagnostics are read-only', () => {
625
625
  expect({pkg: snapshot(pkgDir), consumer: snapshot(consumer)}).toEqual(before);
626
626
  });
627
627
  });
628
+
629
+ describe('validated separates "checked and clean" from "never checked"', () => {
630
+ // `doctor integration validate --json` from a directory with no manifest
631
+ // returned {name: null, version: null, issues: []} and exit 0 — the same
632
+ // envelope a healthy, fully validated integration produces. Wire that into
633
+ // CI from the wrong directory and it is green forever.
634
+ it('is false for every check when no manifest is found', async () => {
635
+ const dir = path.join(tmpDir, 'plain');
636
+ fs.mkdirSync(dir, {recursive: true});
637
+ fs.writeFileSync(
638
+ path.join(dir, 'package.json'),
639
+ JSON.stringify({name: 'plain-app', version: '1.0.0'}),
640
+ );
641
+
642
+ const validate = await validateIntegration(undefined, {cwd: dir});
643
+ expect(validate.data.validated).toBe(false);
644
+ expect(validate.data.issues).toEqual([]);
645
+
646
+ const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
647
+ const components = await integrationComponentConflicts(undefined, {cwd: dir});
648
+ const docs = await integrationDocConflicts(undefined, {cwd: dir});
649
+ expect(templates.data.validated).toBe(false);
650
+ expect(components.data.validated).toBe(false);
651
+ expect(docs.data.validated).toBe(false);
652
+ });
653
+
654
+ it('is true for a real integration, whose empty issue list then means healthy', async () => {
655
+ const dir = path.join(tmpDir, 'integration');
656
+ writePackage(dir, {manifest: 'export default {};\n'});
657
+
658
+ const validate = await validateIntegration(undefined, {cwd: dir});
659
+ expect(validate.data.validated).toBe(true);
660
+ expect(validate.data.name).toBe('@acme/widgets');
661
+
662
+ const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
663
+ const components = await integrationComponentConflicts(undefined, {cwd: dir});
664
+ const docs = await integrationDocConflicts(undefined, {cwd: dir});
665
+ expect(templates.data.validated).toBe(true);
666
+ expect(components.data.validated).toBe(true);
667
+ expect(docs.data.validated).toBe(true);
668
+ });
669
+
670
+ it('is true for an installed package that could not be found — that is a real finding', async () => {
671
+ const consumer = path.join(tmpDir, 'consumer');
672
+ fs.mkdirSync(consumer, {recursive: true});
673
+ fs.writeFileSync(
674
+ path.join(consumer, 'package.json'),
675
+ JSON.stringify({name: 'consumer', version: '1.0.0'}),
676
+ );
677
+
678
+ const res = await validateIntegration('@acme/nope', {cwd: consumer});
679
+ expect(res.data.validated).toBe(true);
680
+ expect(summarizeIssues(res.data.issues).errors).toBeGreaterThan(0);
681
+ });
682
+ });
@@ -27,10 +27,15 @@ export type ValidateIntegrationOptions = {
27
27
  };
28
28
  /**
29
29
  * `astryx --json doctor integration validate [package]`.
30
+ *
31
+ * `validated` is false in exactly one case: no integration manifest was found,
32
+ * so nothing was checked. An empty `issues` then means "not looked at", not
33
+ * "healthy" — the two are otherwise byte-identical.
30
34
  */
31
35
  export type ValidateIntegrationResponse = {
32
36
  type: "integration.validate";
33
37
  data: {
38
+ validated: boolean;
34
39
  name: string | null;
35
40
  version: string | null;
36
41
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
@@ -32,9 +32,13 @@
32
32
 
33
33
  /**
34
34
  * `astryx --json doctor integration validate [package]`.
35
+ *
36
+ * `validated` is false in exactly one case: no integration manifest was found,
37
+ * so nothing was checked. An empty `issues` then means "not looked at", not
38
+ * "healthy" — the two are otherwise byte-identical.
35
39
  * @typedef {object} ValidateIntegrationResponse
36
40
  * @property {'integration.validate'} type
37
- * @property {{name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
41
+ * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
38
42
  */
39
43
 
40
44
  export {};
@@ -46,7 +46,7 @@ export const doc = {
46
46
  {
47
47
  type: 'integration.validate',
48
48
  description:
49
- 'The result envelope: `data.name` and `data.version` of the validated package (both null only when no local manifest is found; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
49
+ 'The result envelope: `data.validated`, false only when no integration manifest was found — nothing was checked, so the empty `data.issues` means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
50
50
  },
51
51
  ],
52
52
  examples: [
@@ -18,7 +18,7 @@ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
18
18
  import {assertWithin, isFilePathArg, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
19
19
  import {detectForm} from '../../../foundation/xle/parse.mjs';
20
20
  import {expand} from '../../../foundation/xle/expand.mjs';
21
- import {stripTemplateAssetRefs} from '../../template/template.mjs';
21
+ import {replaceDemoMedia} from '../../template/template.mjs';
22
22
  import {analyze, formatIssue} from '../_adapter.mjs';
23
23
 
24
24
  /** @param {string} name */
@@ -59,28 +59,32 @@ function collectHintNames(doc) {
59
59
  /**
60
60
  * Build the blockModules map expand() needs: import-mode for app components,
61
61
  * splice-mode (reading + asset-stripping the block source) for template blocks.
62
- * Only blocks actually referenced are read.
62
+ * Only blocks actually referenced are read. Also returns how many demo media
63
+ * references the splice-mode sources had replaced.
63
64
  *
64
65
  * @param {import('../../../foundation/xle/xle-ast').XLEDoc} doc
65
66
  * @param {import('../_adapter.mjs').LayoutBlock[]} blocks
66
- * @returns {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>}
67
+ * @returns {{modules: Map<string, import('../../../foundation/xle/xle-ast').BlockModule>, demoMediaReplaced: number}}
67
68
  */
68
69
  function buildBlockModules(doc, blocks) {
69
70
  const referenced = collectHintNames(doc);
70
- if (referenced.size === 0) return new Map();
71
+ if (referenced.size === 0) return {modules: new Map(), demoMediaReplaced: 0};
71
72
  const byKey = new Map(blocks.map(b => [normKey(b.dirName), b]));
72
73
  /** @type {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>} */
73
74
  const modules = new Map();
75
+ let demoMediaReplaced = 0;
74
76
  for (const name of referenced) {
75
77
  const block = byKey.get(normKey(name));
76
78
  if (!block) continue;
77
79
  if (block.kind === 'component') {
78
80
  modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ (/** @type {unknown} */ ({mode: 'import', componentName: block.name, importPath: block.importPath, isDefault: block.isDefault})));
79
81
  } else if (block.filePath && fs.existsSync(block.filePath)) {
80
- modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ ({mode: 'splice', componentName: block.dirName, source: stripTemplateAssetRefs(fs.readFileSync(block.filePath, 'utf-8'))}));
82
+ const spliced = replaceDemoMedia(fs.readFileSync(block.filePath, 'utf-8'));
83
+ demoMediaReplaced += spliced.demoMediaReplaced;
84
+ modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ ({mode: 'splice', componentName: block.dirName, source: spliced.source}));
81
85
  }
82
86
  }
83
- return modules;
87
+ return {modules, demoMediaReplaced};
84
88
  }
85
89
 
86
90
  /**
@@ -115,7 +119,7 @@ export async function layoutExpand(expression, options = {}) {
115
119
  ERROR_CODES.ERR_INVALID_ARGUMENT,
116
120
  );
117
121
  }
118
- const blockModules = buildBlockModules(doc, blocks);
122
+ const {modules: blockModules, demoMediaReplaced} = buildBlockModules(doc, blocks);
119
123
  const result = expand(doc, registry, {componentName, blockModules});
120
124
 
121
125
  let written = null;
@@ -150,6 +154,7 @@ export async function layoutExpand(expression, options = {}) {
150
154
  blocksReferenced: [...blockModules.entries()].map(([name, m]) => ({name, mode: m.mode})),
151
155
  warnings: warnings.map(formatIssue),
152
156
  written,
157
+ demoMediaReplaced,
153
158
  },
154
159
  };
155
160
  }
@@ -0,0 +1,74 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The layout.expand receipt discloses demo media replaced in the template
5
+ * blocks it splices. Blocks are picked by what their source contains, not by
6
+ * name, so catalog renames do not break the suite.
7
+ */
8
+
9
+ import {describe, it, expect, beforeAll} from 'vitest';
10
+ import * as fs from 'node:fs';
11
+ import {layoutExpand} from '../layout.mjs';
12
+ import {discoverTemplates} from '../../template/template.mjs';
13
+ import {buildRegistry} from '../../../foundation/xle/registry.mjs';
14
+
15
+ const SLOW = 60_000;
16
+ const FIXTURE_REF = /\/template-assets\/[\w.-]+\.\w+/g;
17
+
18
+ beforeAll(async () => {
19
+ await buildRegistry();
20
+ }, 120_000);
21
+
22
+ /** @param {string} name */
23
+ const hintKey = name => name.toLowerCase().replace(/[^a-z0-9]/g, '');
24
+
25
+ /** @type {Promise<Array<{hint: string, refs: number}>> | undefined} */
26
+ let catalog;
27
+
28
+ /**
29
+ * Template blocks a `{hint}` resolves to unambiguously, with the number of demo
30
+ * media references in each one's source.
31
+ * @returns {Promise<Array<{hint: string, refs: number}>>}
32
+ */
33
+ function catalogBlocks() {
34
+ catalog ??= discoverTemplates().then(found => {
35
+ const all = /** @type {Array<{dirName: string, type: string, filePath: string}>} */ (
36
+ found
37
+ ).filter(t => t.type === 'block' && t.filePath && fs.existsSync(t.filePath));
38
+ const seen = new Map();
39
+ for (const t of all) seen.set(hintKey(t.dirName), (seen.get(hintKey(t.dirName)) ?? 0) + 1);
40
+ return all
41
+ .filter(t => seen.get(hintKey(t.dirName)) === 1)
42
+ .map(t => ({
43
+ hint: hintKey(t.dirName),
44
+ refs: (fs.readFileSync(t.filePath, 'utf-8').match(FIXTURE_REF) ?? []).length,
45
+ }));
46
+ });
47
+ return catalog;
48
+ }
49
+
50
+ describe('layout.expand receipt - replaced demo media', () => {
51
+ it('counts the demo media of a spliced block once, however often it is referenced', async () => {
52
+ const block = (await catalogBlocks()).find(b => b.refs > 0);
53
+ if (!block) throw new Error('no template block carries demo media');
54
+ const res = await layoutExpand(`V > {${block.hint}}*3`);
55
+ expect(res.type).toBe('layout.expand');
56
+ expect(res.data.blocksReferenced).toHaveLength(1);
57
+ expect(res.data.demoMediaReplaced).toBe(block.refs);
58
+ expect(res.data.code).not.toContain('/template-assets/');
59
+ }, SLOW);
60
+
61
+ it('sums the demo media of every spliced block', async () => {
62
+ const [a, b] = (await catalogBlocks()).filter(x => x.refs > 0);
63
+ if (!b) throw new Error('fewer than two template blocks carry demo media');
64
+ const res = await layoutExpand(`V > {${a.hint}} + {${b.hint}}`);
65
+ expect(res.data.demoMediaReplaced).toBe(a.refs + b.refs);
66
+ }, SLOW);
67
+
68
+ it('reports 0 when nothing spliced carries demo media', async () => {
69
+ const plain = (await catalogBlocks()).find(b => b.refs === 0);
70
+ if (!plain) throw new Error('every template block carries demo media');
71
+ expect((await layoutExpand(`V > {${plain.hint}}`)).data.demoMediaReplaced).toBe(0);
72
+ expect((await layoutExpand('V > B"Save"')).data.demoMediaReplaced).toBe(0);
73
+ }, SLOW);
74
+ });
@@ -36,6 +36,7 @@ export type LayoutExpandResponse = {
36
36
  blocksReferenced: LayoutBlockReference[];
37
37
  warnings: string[];
38
38
  written: string | null;
39
+ demoMediaReplaced: number;
39
40
  };
40
41
  };
41
42
  /**
@@ -48,6 +48,7 @@
48
48
  * @property {LayoutBlockReference[]} data.blocksReferenced
49
49
  * @property {string[]} data.warnings
50
50
  * @property {string | null} data.written
51
+ * @property {number} data.demoMediaReplaced Astryx demo media references (images, posters, videos) replaced in the spliced template blocks: images with a neutral placeholder, videos with an empty source. Swap in your own media at those points in the code; no media is installed. 0 when no spliced block carried any.
51
52
  */
52
53
 
53
54
  /**
@@ -70,7 +70,7 @@ export const doc = {
70
70
  {
71
71
  type: 'layout.expand',
72
72
  description:
73
- 'The expansion: the parsed form, the generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, and written (the relative output path, or null when nothing was written).',
73
+ 'The expansion: the parsed form, the generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the relative output path, or null when nothing was written), and demoMediaReplaced (how many Astryx demo media references in the spliced template blocks, such as images, posters and videos, were replaced with placeholders for you to swap for your own media).',
74
74
  },
75
75
  ],
76
76
  throws: [
@@ -90,6 +90,30 @@ export function scoreCandidate(term: string, { name, domain, keywords, weakKeywo
90
90
  score: number;
91
91
  reason: string;
92
92
  } | null;
93
+ /**
94
+ * The components (name and keywords) a search response was scored against, or
95
+ * null when that search was narrowed away from components.
96
+ * @param {object} response
97
+ * @returns {{name: string, keywords: string[]}[] | null}
98
+ */
99
+ export function searchedComponents(response: object): {
100
+ name: string;
101
+ keywords: string[];
102
+ }[] | null;
103
+ /**
104
+ * Every component the project can use, Core's and its integrations', with the
105
+ * keywords its own doc declares: the discovery and doc reads search's own
106
+ * candidates use, without the import paths and prose a result carries. `build`
107
+ * reads it to tell a part of a page from a page when its search was narrowed
108
+ * away from components.
109
+ * @param {string} coreDir
110
+ * @param {string} cwd
111
+ * @returns {Promise<{name: string, keywords: string[]}[]>}
112
+ */
113
+ export function componentKeywords(coreDir: string, cwd: string): Promise<{
114
+ name: string;
115
+ keywords: string[];
116
+ }[]>;
93
117
  /**
94
118
  * Unified ranked search across components, hooks, docs, and templates.
95
119
  *