@astryxdesign/cli 0.6.5-canary.24fe2cd → 0.6.5-canary.2ad3b83

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 (156) hide show
  1. package/README.md +13 -14
  2. package/api/build/_adapter.d.mts +2 -36
  3. package/api/build/_adapter.mjs +10 -41
  4. package/api/build/build.doc.mjs +2 -2
  5. package/api/build/build.test.mjs +2 -38
  6. package/api/build/kit/kit.mjs +21 -65
  7. package/api/build/kit/rank.d.mts +8 -24
  8. package/api/build/kit/rank.mjs +97 -277
  9. package/api/build/kit/rank.test.mjs +48 -231
  10. package/api/error.d.mts +0 -22
  11. package/api/error.mjs +0 -42
  12. package/api/integration/add-contribution.d.mts +1 -2
  13. package/api/integration/add-contribution.mjs +3 -7
  14. package/api/integration/add-contribution.test.mjs +3 -3
  15. package/api/integration/add-theme.mjs +22 -243
  16. package/api/integration/add-theme.test.mjs +0 -213
  17. package/api/integration/authoring-checks.mjs +7 -10
  18. package/api/integration/authoring-checks.type.d.mts +0 -8
  19. package/api/integration/authoring-checks.type.mjs +3 -7
  20. package/api/integration/integration-authoring.type.d.mts +1 -4
  21. package/api/integration/integration-authoring.type.mjs +1 -6
  22. package/api/integration/integrationAdd.doc.mjs +0 -6
  23. package/api/integration/integrationAddTheme.doc.mjs +0 -10
  24. package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
  25. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  26. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  27. package/api/integration/pack-check.mjs +2 -11
  28. package/api/integration/pack-check.test.mjs +1 -38
  29. package/api/integration/validate-integration.d.mts +2 -4
  30. package/api/integration/validate-integration.mjs +2 -7
  31. package/api/integration/validate-integration.test.mjs +0 -55
  32. package/api/integration/validate-integration.type.d.mts +0 -5
  33. package/api/integration/validate-integration.type.mjs +1 -5
  34. package/api/integration/validateIntegration.doc.mjs +1 -1
  35. package/api/layout/expand/expand.mjs +7 -12
  36. package/api/layout/layout.type.d.mts +0 -1
  37. package/api/layout/layout.type.mjs +0 -1
  38. package/api/layout/layoutExpand.doc.mjs +1 -1
  39. package/api/search/search.d.mts +0 -24
  40. package/api/search/search.mjs +1 -71
  41. package/api/swizzle/copy/copy.mjs +3 -66
  42. package/api/swizzle/swizzle.doc.mjs +0 -4
  43. package/api/template/copy/copy.mjs +8 -14
  44. package/api/template/show/show.mjs +4 -15
  45. package/api/template/template-integration.test.mjs +0 -14
  46. package/api/template/template.d.mts +1 -1
  47. package/api/template/template.doc.mjs +2 -6
  48. package/api/template/template.mjs +0 -1
  49. package/api/template/template.type.d.mts +0 -2
  50. package/api/template/template.type.mjs +0 -2
  51. package/api/theme/build/build.d.mts +0 -24
  52. package/api/theme/build/build.mjs +8 -235
  53. package/api/upgrade/run/run.mjs +3 -20
  54. package/api/upgrade/run/run.test.mjs +1 -45
  55. package/api/upgrade/upgrade.doc.mjs +1 -1
  56. package/api/upgrade/upgrade.type.d.mts +0 -1
  57. package/api/upgrade/upgrade.type.mjs +0 -1
  58. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  59. package/assets/docs/tree/checks.doc.mjs +1 -1
  60. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  61. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -13
  62. package/assets/docs/tree/troubleshooting.doc.mjs +3 -7
  63. package/assets/docs/tree/versioning.doc.mjs +6 -6
  64. package/assets/templates/pages/ai-chat/template.doc.mjs +1 -16
  65. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +1 -9
  66. package/assets/templates/pages/blank/template.doc.mjs +1 -3
  67. package/assets/templates/pages/canvas-editor/template.doc.mjs +1 -9
  68. package/assets/templates/pages/centered-hero/template.doc.mjs +1 -3
  69. package/assets/templates/pages/checkout-wizard/template.doc.mjs +0 -1
  70. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -3
  71. package/assets/templates/pages/contact-form/template.doc.mjs +1 -16
  72. package/assets/templates/pages/dashboard/template.doc.mjs +1 -15
  73. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +1 -23
  74. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +1 -10
  75. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +1 -9
  76. package/assets/templates/pages/dashboard-composition/template.doc.mjs +1 -10
  77. package/assets/templates/pages/dashboard-progress/template.doc.mjs +1 -17
  78. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +1 -2
  79. package/assets/templates/pages/detail-page/template.doc.mjs +0 -8
  80. package/assets/templates/pages/documentation/template.doc.mjs +1 -10
  81. package/assets/templates/pages/documentation-design/template.doc.mjs +1 -10
  82. package/assets/templates/pages/documentation-technical/template.doc.mjs +1 -10
  83. package/assets/templates/pages/editor/template.doc.mjs +1 -9
  84. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -3
  85. package/assets/templates/pages/form-two-column/template.doc.mjs +1 -17
  86. package/assets/templates/pages/form-wizard/template.doc.mjs +1 -14
  87. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +0 -1
  88. package/assets/templates/pages/gallery-hero/template.doc.mjs +1 -10
  89. package/assets/templates/pages/ide/template.doc.mjs +1 -9
  90. package/assets/templates/pages/incident-console/template.doc.mjs +1 -10
  91. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -11
  92. package/assets/templates/pages/library/template.doc.mjs +1 -15
  93. package/assets/templates/pages/login/template.doc.mjs +1 -10
  94. package/assets/templates/pages/login-card/template.doc.mjs +1 -11
  95. package/assets/templates/pages/login-split/template.doc.mjs +1 -10
  96. package/assets/templates/pages/login-sso/template.doc.mjs +1 -10
  97. package/assets/templates/pages/messaging-shell/template.doc.mjs +1 -11
  98. package/assets/templates/pages/mixed-gallery/template.doc.mjs +1 -10
  99. package/assets/templates/pages/payment-form/template.doc.mjs +1 -3
  100. package/assets/templates/pages/product-detail/template.doc.mjs +1 -9
  101. package/assets/templates/pages/product-gallery/template.doc.mjs +1 -10
  102. package/assets/templates/pages/settings/template.doc.mjs +1 -3
  103. package/assets/templates/pages/settings-dialog/template.doc.mjs +1 -9
  104. package/assets/templates/pages/settings-sidebar/template.doc.mjs +1 -9
  105. package/assets/templates/pages/shell-nav/template.doc.mjs +1 -10
  106. package/assets/templates/pages/shell-side-nav/template.doc.mjs +1 -14
  107. package/assets/templates/pages/shell-top-nav/template.doc.mjs +1 -11
  108. package/assets/templates/pages/side-gallery/template.doc.mjs +1 -3
  109. package/assets/templates/pages/table/template.doc.mjs +1 -11
  110. package/assets/templates/pages/table-filter/template.doc.mjs +1 -21
  111. package/assets/templates/pages/table-grouped/template.doc.mjs +1 -15
  112. package/assets/templates/pages/table-inbox/template.doc.mjs +6 -18
  113. package/assets/templates/pages/table-page/template.doc.mjs +1 -20
  114. package/assets/templates/pages/table-tree/template.doc.mjs +1 -14
  115. package/assets/templates/pages/theme-showcase/template.doc.mjs +1 -10
  116. package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -10
  117. package/authoring/doctypes/template/parse.d.mts +0 -2
  118. package/authoring/doctypes/template/parse.mjs +0 -1
  119. package/authoring/doctypes/template/parse.test.mjs +0 -21
  120. package/authoring/doctypes/template/template.doc.mjs +0 -6
  121. package/authoring/doctypes/template/type.ts +0 -10
  122. package/clients/cli/commands/doctor.mjs +4 -4
  123. package/clients/cli/commands/integration-add.doc.mjs +0 -10
  124. package/clients/cli/commands/integration-authoring.test.mjs +2 -12
  125. package/clients/cli/commands/integration.mjs +1 -3
  126. package/clients/cli/commands/layout-expand.doc.mjs +1 -3
  127. package/clients/cli/commands/layout.mjs +0 -16
  128. package/clients/cli/commands/template.mjs +5 -19
  129. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -14
  130. package/clients/cli/lib/manifest.mjs +165 -44
  131. package/clients/cli/lib/manifest.test.mjs +7 -98
  132. package/foundation/discovery/template-adapter.d.mts +0 -14
  133. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +1 -37
  134. package/foundation/discovery/template-adapter.mjs +1 -21
  135. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  136. package/foundation/integrations/cli-requirement.d.mts +11 -23
  137. package/foundation/integrations/cli-requirement.mjs +18 -40
  138. package/foundation/integrations/cli-requirement.test.mjs +15 -66
  139. package/foundation/response/response-types.doc.d.mts +5 -5
  140. package/foundation/response/response-types.doc.mjs +13 -13
  141. package/package.json +9 -9
  142. package/api/docs/docs.test.mjs +0 -279
  143. package/api/docs/integration-tree.test.mjs +0 -572
  144. package/api/docs/integrationDocs.test.mjs +0 -336
  145. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  146. package/api/search/search.test.mjs +0 -710
  147. package/api/template/copy/copy.receipt.test.mjs +0 -77
  148. package/api/template/show/show.test.mjs +0 -76
  149. package/api/theme/build/build.project-core.test.mjs +0 -165
  150. package/clients/cli/commands/docs.test.mjs +0 -383
  151. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  152. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  153. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  154. package/clients/cli/commands/write-failure.test.mjs +0 -175
  155. package/foundation/agent-docs/agent-docs.test.mjs +0 -1160
  156. package/foundation/doc-compiler/tree.test.mjs +0 -649
@@ -19,9 +19,7 @@ export type IntegrationAddCodemodOptions = IntegrationAddBaseOptions & {
19
19
  to: string;
20
20
  };
21
21
  export type IntegrationAddAgentDocOptions = IntegrationAddBaseOptions;
22
- export type IntegrationAddThemeOptions = IntegrationAddBaseOptions & {
23
- from?: string;
24
- };
22
+ export type IntegrationAddThemeOptions = IntegrationAddBaseOptions;
25
23
  /**
26
24
  * Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
27
25
  * when the contribution kind is known so the accepted options stay narrow.
@@ -56,5 +54,4 @@ export type IntegrationAddData = {
56
54
  files: string[];
57
55
  written: boolean;
58
56
  dryRun: boolean;
59
- from?: string | undefined;
60
57
  };
@@ -37,11 +37,7 @@
37
37
  */
38
38
 
39
39
  /** @typedef {IntegrationAddBaseOptions} IntegrationAddAgentDocOptions */
40
- /**
41
- * @typedef {IntegrationAddBaseOptions & {
42
- * from?: string,
43
- * }} IntegrationAddThemeOptions
44
- */
40
+ /** @typedef {IntegrationAddBaseOptions} IntegrationAddThemeOptions */
45
41
 
46
42
  /**
47
43
  * Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
@@ -77,7 +73,6 @@
77
73
  * @property {string[]} files
78
74
  * @property {boolean} written
79
75
  * @property {boolean} dryRun
80
- * @property {string} [from]
81
76
  */
82
77
 
83
78
  export {};
@@ -78,12 +78,6 @@ 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
- },
87
81
  ],
88
82
  returns: [
89
83
  {
@@ -33,12 +33,6 @@ 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
- },
42
36
  ],
43
37
  returns: [
44
38
  {
@@ -82,10 +76,6 @@ export const doc = {
82
76
  label: 'Add a theme',
83
77
  code: "await integrationAddTheme('ocean');",
84
78
  },
85
- {
86
- label: 'Fork an existing theme',
87
- code: "await integrationAddTheme('ocean', {from: 'neutral'});",
88
- },
89
79
  {
90
80
  label: 'Preview writes',
91
81
  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
- '`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.',
29
+ '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
- '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and classified Core doc relationships.',
29
+ '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
- '`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.',
44
+ 'The integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
45
45
  },
46
46
  ],
47
47
  examples: [
@@ -29,7 +29,6 @@ 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,
33
32
  replacesCliProblem,
34
33
  sectionIdsCliProblem,
35
34
  themesCliProblem,
@@ -671,9 +670,8 @@ export async function integrationPackCheck(options = {}) {
671
670
  }
672
671
  }
673
672
  }
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.
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.
677
675
  if (loaded.templates) {
678
676
  const found = await discoverIntegrationTemplatesForOne(loaded).catch(
679
677
  () => ({templates: [], errors: []}),
@@ -685,13 +683,6 @@ export async function integrationPackCheck(options = {}) {
685
683
  );
686
684
  const problem = setsReplaces ? replacesCliProblem(pkg) : null;
687
685
  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
- }
695
686
  }
696
687
  // A theme needs a CLI that reads typed theme descriptors: an older CLI
697
688
  // rejects the themes root and withholds the package's themes and docs.
@@ -374,10 +374,7 @@ describe('integrationPackCheck', () => {
374
374
  expect(await codes()).toContain('docs_tree_needs_cli');
375
375
  peer('^0.6.0 || >=0.7.0');
376
376
  expect(await codes()).toContain('docs_tree_needs_cli');
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');
377
+ peer('>=0.7.0');
381
378
  expect(await codes()).not.toContain('docs_tree_needs_cli');
382
379
  }, 120_000);
383
380
 
@@ -468,44 +465,10 @@ describe('integrationPackCheck', () => {
468
465
  expect(await codes()).toContain('replaces_needs_cli');
469
466
  peer('^0.6.0');
470
467
  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');
474
468
  peer('>=0.7.0');
475
469
  expect(await codes()).not.toContain('replaces_needs_cli');
476
470
  }, 120_000);
477
471
 
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
-
509
472
  it('passes when package.json has no files field', async () => {
510
473
  writePackage({files: undefined});
511
474
  const result = await integrationPackCheck({cwd: tmpDir});
@@ -19,10 +19,8 @@ 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 `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".
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.
26
24
  *
27
25
  * This is the seam that keeps the CLI a thin wrapper: the command handler calls
28
26
  * this and only chooses how to render (human vs --json) + the exit code.
@@ -427,10 +427,8 @@ 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 `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".
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.
434
432
  *
435
433
  * This is the seam that keeps the CLI a thin wrapper: the command handler calls
436
434
  * this and only chooses how to render (human vs --json) + the exit code.
@@ -447,9 +445,6 @@ export async function validateIntegration(pkg, options = {}) {
447
445
  return {
448
446
  type: 'integration.validate',
449
447
  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,
453
448
  name: result.found ? (result.name ?? null) : null,
454
449
  version: result.found ? (result.version ?? null) : null,
455
450
  issues: result.issues,
@@ -625,58 +625,3 @@ 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,15 +27,10 @@ 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.
34
30
  */
35
31
  export type ValidateIntegrationResponse = {
36
32
  type: "integration.validate";
37
33
  data: {
38
- validated: boolean;
39
34
  name: string | null;
40
35
  version: string | null;
41
36
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
@@ -32,13 +32,9 @@
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.
39
35
  * @typedef {object} ValidateIntegrationResponse
40
36
  * @property {'integration.validate'} type
41
- * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
37
+ * @property {{name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
42
38
  */
43
39
 
44
40
  export {};
@@ -46,7 +46,7 @@ export const doc = {
46
46
  {
47
47
  type: 'integration.validate',
48
48
  description:
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}.',
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}.',
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 {replaceDemoMedia} from '../../template/template.mjs';
21
+ import {stripTemplateAssetRefs} from '../../template/template.mjs';
22
22
  import {analyze, formatIssue} from '../_adapter.mjs';
23
23
 
24
24
  /** @param {string} name */
@@ -59,32 +59,28 @@ 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. Also returns how many demo media
63
- * references the splice-mode sources had replaced.
62
+ * Only blocks actually referenced are read.
64
63
  *
65
64
  * @param {import('../../../foundation/xle/xle-ast').XLEDoc} doc
66
65
  * @param {import('../_adapter.mjs').LayoutBlock[]} blocks
67
- * @returns {{modules: Map<string, import('../../../foundation/xle/xle-ast').BlockModule>, demoMediaReplaced: number}}
66
+ * @returns {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>}
68
67
  */
69
68
  function buildBlockModules(doc, blocks) {
70
69
  const referenced = collectHintNames(doc);
71
- if (referenced.size === 0) return {modules: new Map(), demoMediaReplaced: 0};
70
+ if (referenced.size === 0) return new Map();
72
71
  const byKey = new Map(blocks.map(b => [normKey(b.dirName), b]));
73
72
  /** @type {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>} */
74
73
  const modules = new Map();
75
- let demoMediaReplaced = 0;
76
74
  for (const name of referenced) {
77
75
  const block = byKey.get(normKey(name));
78
76
  if (!block) continue;
79
77
  if (block.kind === 'component') {
80
78
  modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ (/** @type {unknown} */ ({mode: 'import', componentName: block.name, importPath: block.importPath, isDefault: block.isDefault})));
81
79
  } else if (block.filePath && fs.existsSync(block.filePath)) {
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}));
80
+ modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ ({mode: 'splice', componentName: block.dirName, source: stripTemplateAssetRefs(fs.readFileSync(block.filePath, 'utf-8'))}));
85
81
  }
86
82
  }
87
- return {modules, demoMediaReplaced};
83
+ return modules;
88
84
  }
89
85
 
90
86
  /**
@@ -119,7 +115,7 @@ export async function layoutExpand(expression, options = {}) {
119
115
  ERROR_CODES.ERR_INVALID_ARGUMENT,
120
116
  );
121
117
  }
122
- const {modules: blockModules, demoMediaReplaced} = buildBlockModules(doc, blocks);
118
+ const blockModules = buildBlockModules(doc, blocks);
123
119
  const result = expand(doc, registry, {componentName, blockModules});
124
120
 
125
121
  let written = null;
@@ -154,7 +150,6 @@ export async function layoutExpand(expression, options = {}) {
154
150
  blocksReferenced: [...blockModules.entries()].map(([name, m]) => ({name, mode: m.mode})),
155
151
  warnings: warnings.map(formatIssue),
156
152
  written,
157
- demoMediaReplaced,
158
153
  },
159
154
  };
160
155
  }
@@ -36,7 +36,6 @@ export type LayoutExpandResponse = {
36
36
  blocksReferenced: LayoutBlockReference[];
37
37
  warnings: string[];
38
38
  written: string | null;
39
- demoMediaReplaced: number;
40
39
  };
41
40
  };
42
41
  /**
@@ -48,7 +48,6 @@
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.
52
51
  */
53
52
 
54
53
  /**
@@ -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, 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).',
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).',
74
74
  },
75
75
  ],
76
76
  throws: [
@@ -90,30 +90,6 @@ 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
- }[]>;
117
93
  /**
118
94
  * Unified ranked search across components, hooks, docs, and templates.
119
95
  *
@@ -1007,64 +1007,6 @@ async function gatherComponents(coreDir, cwd) {
1007
1007
  return [...core, ...integrations];
1008
1008
  }
1009
1009
 
1010
- /**
1011
- * The components each search response was scored against, by response:
1012
- * `build` reads them to tell a part of a page from a page without gathering
1013
- * them again. Module-private, so they never enter search's JSON.
1014
- * @type {WeakMap<object, {name: string, keywords: string[]}[]>}
1015
- */
1016
- const searchedComponentsOf = new WeakMap();
1017
-
1018
- /**
1019
- * The components (name and keywords) a search response was scored against, or
1020
- * null when that search was narrowed away from components.
1021
- * @param {object} response
1022
- * @returns {{name: string, keywords: string[]}[] | null}
1023
- */
1024
- export function searchedComponents(response) {
1025
- return searchedComponentsOf.get(response) ?? null;
1026
- }
1027
-
1028
- /**
1029
- * Every component the project can use, Core's and its integrations', with the
1030
- * keywords its own doc declares: the discovery and doc reads search's own
1031
- * candidates use, without the import paths and prose a result carries. `build`
1032
- * reads it to tell a part of a page from a page when its search was narrowed
1033
- * away from components.
1034
- * @param {string} coreDir
1035
- * @param {string} cwd
1036
- * @returns {Promise<{name: string, keywords: string[]}[]>}
1037
- */
1038
- export async function componentKeywords(coreDir, cwd) {
1039
- /** @param {any} doc */
1040
- const keywordsOf = doc => (Array.isArray(doc?.keywords) ? doc.keywords : []);
1041
- const core = Object.values(discoverComponents(coreDir))
1042
- .flat()
1043
- .map(async name => {
1044
- const readme = findComponentReadme(coreDir, name);
1045
- const doc =
1046
- readme && readme.endsWith('.doc.mjs')
1047
- ? await loadModuleDoc(readme)
1048
- : null;
1049
- return {name, keywords: keywordsOf(doc)};
1050
- });
1051
- const integrations = (await loadIntegrationsSafely(cwd)).map(
1052
- async integration => {
1053
- const {components} = await discoverValidIntegrationComponents(integration);
1054
- return Promise.all(
1055
- components.map(async rec => ({
1056
- name: rec.name,
1057
- keywords: keywordsOf(await loadModuleDoc(rec.docPath)),
1058
- })),
1059
- );
1060
- },
1061
- );
1062
- return [
1063
- ...(await Promise.all(core)),
1064
- ...(await Promise.all(integrations)).flat(),
1065
- ];
1066
- }
1067
-
1068
1010
  /**
1069
1011
  * Build hook candidates: name + keywords + usage/description from the hook's
1070
1012
  * .doc.mjs.
@@ -1451,10 +1393,6 @@ async function gatherTemplates(cwd) {
1451
1393
  keywords,
1452
1394
  weakKeywords,
1453
1395
  description: t.description || '',
1454
- // A template's own keywords name the many ideas it serves, so they score
1455
- // as its prose does, not as a name: one of them matching one word of a
1456
- // short idea is not a direct match.
1457
- prose: t.keywords ?? [],
1458
1396
  _displayName: t.name,
1459
1397
  _kind: t.type, // 'page' | 'block'
1460
1398
  _resultName: t.dirName,
@@ -1625,8 +1563,7 @@ export async function search(query, options = {}) {
1625
1563
  // 57 things and one matching exactly 20 would be indistinguishable.
1626
1564
  const limited = scored.slice(0, limit);
1627
1565
 
1628
- /** @type {import('./search.type.mjs').SearchResponse} */
1629
- const response = {
1566
+ return {
1630
1567
  type: 'search',
1631
1568
  data: {
1632
1569
  query: String(query).trim(),
@@ -1637,11 +1574,4 @@ export async function search(query, options = {}) {
1637
1574
  ),
1638
1575
  },
1639
1576
  };
1640
- if (wants('component')) {
1641
- searchedComponentsOf.set(
1642
- response,
1643
- components.map(c => ({name: c.name, keywords: c.keywords ?? []})),
1644
- );
1645
- }
1646
- return response;
1647
1577
  }
@@ -25,7 +25,7 @@ import {
25
25
  findIntegrationComponentSource,
26
26
  } from '../../../foundation/discovery/component-discovery.mjs';
27
27
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
28
- import {AstryxError, writeFailed} from '../../error.mjs';
28
+ import {AstryxError} from '../../error.mjs';
29
29
 
30
30
  /** Default issue tracker for maintainer feedback after swizzling. */
31
31
  const DEFAULT_ISSUES_URL = 'https://github.com/facebook/astryx/issues/new';
@@ -290,21 +290,11 @@ export async function swizzleCopy(component, options = {}) {
290
290
  );
291
291
  }
292
292
 
293
- const outputDirExisted = fs.existsSync(outputDir);
294
- try {
295
- fs.mkdirSync(outputDir, {recursive: true});
296
- } catch (err) {
297
- throw writeFailed(outputDir, cwd, err);
298
- }
293
+ fs.mkdirSync(outputDir, {recursive: true});
299
294
 
300
295
  const files = fs.readdirSync(componentDir);
301
296
  let copied = 0;
302
297
  let usesStyleX = false;
303
- // A copy that fails part-way undoes what it already wrote, so the report is
304
- // true and a retry does not trip over half a component. Each entry keeps
305
- // the bytes the file had before this run (null when the copy created it).
306
- /** @type {Array<{dest: string, original: Buffer|null}>} */
307
- const written = [];
308
298
  for (const file of files) {
309
299
  if (isExcludedFromCopy(file)) continue;
310
300
  const srcPath = path.join(componentDir, file);
@@ -319,25 +309,7 @@ export async function swizzleCopy(component, options = {}) {
319
309
  ) {
320
310
  usesStyleX = true;
321
311
  }
322
- const dest = path.join(outputDir, file);
323
- try {
324
- // The snapshot read is guarded too: a destination that cannot be read
325
- // back (no permission, or a directory with this name) must still undo
326
- // the earlier writes and report ERR_WRITE_FAILED.
327
- const original = fs.existsSync(dest) ? fs.readFileSync(dest) : null;
328
- written.push({dest, original});
329
- fs.writeFileSync(dest, content);
330
- } catch (err) {
331
- const unrestored = undoCopy(written);
332
- if (!outputDirExisted) {
333
- try {
334
- fs.rmdirSync(outputDir);
335
- } catch {
336
- // Not empty (something could not be undone), or already gone.
337
- }
338
- }
339
- throw writeFailed(dest, cwd, err, unrestored);
340
- }
312
+ fs.writeFileSync(path.join(outputDir, file), content);
341
313
  copied++;
342
314
  }
343
315
 
@@ -361,38 +333,3 @@ export async function swizzleCopy(component, options = {}) {
361
333
  if (feedback) data.feedback = feedback;
362
334
  return {type: 'swizzle.copy', data};
363
335
  }
364
-
365
- /**
366
- * Undo the writes of a copy that failed part-way, newest first: delete the
367
- * files the copy created and put back the bytes of the files it replaced. A
368
- * file whose bytes are already the original ones is left alone, so a write
369
- * that failed before changing anything is not reported as unrestored.
370
- *
371
- * @param {Array<{dest: string, original: Buffer|null}>} written
372
- * @returns {string[]} the files it could not restore
373
- */
374
- function undoCopy(written) {
375
- /** @type {string[]} */
376
- const unrestored = [];
377
- for (const {dest, original} of [...written].reverse()) {
378
- try {
379
- if (original == null) {
380
- fs.rmSync(dest, {force: true});
381
- continue;
382
- }
383
- /** @type {Buffer|null} */
384
- let current = null;
385
- try {
386
- current = fs.readFileSync(dest);
387
- } catch {
388
- current = null;
389
- }
390
- if (current == null || !current.equals(original)) {
391
- fs.writeFileSync(dest, original);
392
- }
393
- } catch {
394
- unrestored.push(dest);
395
- }
396
- }
397
- return unrestored;
398
- }