@astryxdesign/cli 0.7.2-canary.6d4f178 → 0.7.2-canary.72db6f9

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 (276) hide show
  1. package/README.md +74 -73
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +31 -0
  4. package/api/component/_adapter.mjs +116 -0
  5. package/api/component/component.mjs +60 -10
  6. package/api/component/doc-links.test.mjs +386 -0
  7. package/api/discover/_adapter.d.mts +119 -12
  8. package/api/discover/_adapter.mjs +449 -10
  9. package/api/discover/_adapter.test.mjs +599 -17
  10. package/api/discover/_catalog-view.d.mts +16 -5
  11. package/api/discover/_catalog-view.mjs +32 -8
  12. package/api/discover/detail/doc/doc.mjs +9 -1
  13. package/api/discover/discover.d.mts +11 -0
  14. package/api/discover/discover.doc.mjs +7 -6
  15. package/api/discover/discover.mjs +107 -19
  16. package/api/discover/discover.type.d.mts +18 -7
  17. package/api/discover/discover.type.mjs +15 -7
  18. package/api/discover/list/list.d.mts +4 -3
  19. package/api/discover/list/list.mjs +17 -10
  20. package/api/docs/_adapter.d.mts +74 -0
  21. package/api/docs/_adapter.mjs +550 -14
  22. package/api/docs/integration-tree.test.mjs +22 -0
  23. package/api/docs/integrationDocs.test.mjs +124 -0
  24. package/api/docs/list/list.mjs +12 -2
  25. package/api/doctor/doctor.mjs +27 -3
  26. package/api/doctor/doctor.test.mjs +43 -0
  27. package/api/doctor/theme-checks.mjs +1 -1
  28. package/api/doctor/theme-checks.test.mjs +136 -0
  29. package/api/gap-report/gap-report.d.mts +3 -0
  30. package/api/gap-report/gap-report.doc.mjs +11 -3
  31. package/api/gap-report/gap-report.mjs +152 -48
  32. package/api/gap-report/gap-report.test.mjs +233 -0
  33. package/api/gap-report/gap-report.type.d.mts +41 -0
  34. package/api/gap-report/gap-report.type.mjs +18 -0
  35. package/api/index.d.mts +2 -0
  36. package/api/index.mjs +2 -0
  37. package/api/init/run/run.mjs +2 -2
  38. package/api/integration/_adapter.d.mts +45 -0
  39. package/api/integration/_adapter.mjs +112 -0
  40. package/api/integration/add-contribution.mjs +1 -1
  41. package/api/integration/add-contribution.test.mjs +4 -2
  42. package/api/integration/authoring-checks.mjs +108 -4
  43. package/api/integration/authoring-checks.test.mjs +808 -0
  44. package/api/integration/authoring-checks.type.d.mts +143 -0
  45. package/api/integration/authoring-checks.type.mjs +74 -2
  46. package/api/integration/check/check.d.mts +96 -0
  47. package/api/integration/check/check.mjs +357 -0
  48. package/api/integration/check/check.test.mjs +489 -0
  49. package/api/integration/integration-check.type.d.mts +118 -0
  50. package/api/integration/integration-check.type.mjs +84 -0
  51. package/api/integration/integrationCheck.doc.d.mts +10 -0
  52. package/api/integration/integrationCheck.doc.mjs +73 -0
  53. package/api/integration/integrationComponentConflicts.doc.mjs +45 -6
  54. package/api/integration/integrationDocConflicts.doc.mjs +22 -5
  55. package/api/integration/pack-check.mjs +296 -7
  56. package/api/integration/pack-check.test.mjs +367 -0
  57. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  58. package/api/integration/validate-integration.mjs +36 -3
  59. package/api/integration/validate-integration.test.mjs +88 -8
  60. package/api/integration/validate-integration.type.d.mts +8 -0
  61. package/api/integration/validate-integration.type.mjs +12 -1
  62. package/api/integration/validateIntegration.doc.mjs +19 -3
  63. package/api/search/search.d.mts +72 -12
  64. package/api/search/search.domain-priority.test.mjs +108 -18
  65. package/api/search/search.integration-check.test.mjs +24 -0
  66. package/api/search/search.mjs +503 -38
  67. package/api/search/search.test.mjs +139 -0
  68. package/api/theme/build/build.family.test.mjs +54 -6
  69. package/api/theme/build/build.mjs +114 -17
  70. package/api/theme/themeBuild.doc.mjs +4 -4
  71. package/api/upgrade/_adapter.d.mts +40 -2
  72. package/api/upgrade/_adapter.mjs +117 -4
  73. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  74. package/api/upgrade/run/run.mjs +30 -1
  75. package/api/upgrade/status/status.d.mts +21 -5
  76. package/api/upgrade/status/status.mjs +45 -8
  77. package/api/upgrade/upgrade.doc.mjs +5 -3
  78. package/api/upgrade/upgrade.type.d.mts +23 -0
  79. package/api/upgrade/upgrade.type.mjs +16 -1
  80. package/assets/codemods/runner.mjs +7 -1
  81. package/assets/discover/official-packages.json +367 -0
  82. package/assets/docs/README.md +10 -0
  83. package/assets/docs/author-a-theme.doc.mjs +3 -3
  84. package/assets/docs/browser-support.doc.mjs +1 -1
  85. package/assets/docs/getting-started.doc.mjs +3 -3
  86. package/assets/docs/styling-overview.doc.mjs +1 -1
  87. package/assets/docs/theme.doc.dense.mjs +1 -1
  88. package/assets/docs/theme.doc.mjs +2 -2
  89. package/assets/docs/theme.doc.zh.mjs +1 -1
  90. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  91. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  92. package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
  93. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  94. package/assets/docs/tree/block-template.doc.mjs +8 -20
  95. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  96. package/assets/docs/tree/check-the-props.doc.mjs +201 -0
  97. package/assets/docs/tree/check-your-docs.doc.mjs +65 -7
  98. package/assets/docs/tree/checks.doc.mjs +25 -17
  99. package/assets/docs/tree/codemods.doc.mjs +4 -4
  100. package/assets/docs/tree/component-family.doc.mjs +3 -5
  101. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  102. package/assets/docs/tree/components.doc.mjs +1 -1
  103. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
  104. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  105. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  106. package/assets/docs/tree/docs.doc.mjs +3 -3
  107. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  108. package/assets/docs/tree/document-the-theme.doc.mjs +3 -3
  109. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  110. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  111. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  112. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  113. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  114. package/assets/docs/tree/integrations.doc.mjs +8 -0
  115. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  116. package/assets/docs/tree/layout.doc.mjs +6 -6
  117. package/assets/docs/tree/links.doc.mjs +6 -5
  118. package/assets/docs/tree/migration-setup.doc.mjs +3 -2
  119. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  120. package/assets/docs/tree/migration.doc.mjs +0 -1
  121. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  122. package/assets/docs/tree/page-template.doc.mjs +4 -8
  123. package/assets/docs/tree/publishing.doc.mjs +4 -4
  124. package/assets/docs/tree/quick-start.doc.mjs +38 -22
  125. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  126. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  127. package/assets/docs/tree/sections-and-placement.doc.mjs +6 -8
  128. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  129. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  130. package/assets/docs/tree/single-component.doc.mjs +14 -5
  131. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  132. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  133. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  134. package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
  135. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  136. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  137. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  138. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  139. package/assets/docs/tree/templates.doc.mjs +1 -1
  140. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  141. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  142. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  143. package/assets/docs/tree/troubleshooting.doc.mjs +8 -8
  144. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  145. package/assets/docs/tree/upgrading.doc.mjs +4 -4
  146. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  147. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  148. package/assets/docs/tree/versioning.doc.mjs +6 -6
  149. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  150. package/assets/docs/use-a-theme.doc.mjs +2 -2
  151. package/assets/theme.template.ts +1 -1
  152. package/authoring/codemod/codemod.doc.mjs +7 -3
  153. package/authoring/config/config.doc.mjs +9 -6
  154. package/authoring/config/type.ts +4 -2
  155. package/authoring/discover/discover.doc.mjs +1 -1
  156. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  157. package/authoring/doctypes/command/command.doc.mjs +14 -12
  158. package/authoring/doctypes/component/component.doc.mjs +29 -26
  159. package/authoring/doctypes/component/type.ts +15 -5
  160. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  161. package/authoring/doctypes/function/function.doc.mjs +9 -8
  162. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  163. package/authoring/doctypes/hook/type.ts +4 -0
  164. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  165. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  166. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  167. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  168. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  169. package/authoring/doctypes/template/parse.d.mts +6 -2
  170. package/authoring/doctypes/template/parse.mjs +3 -1
  171. package/authoring/doctypes/template/template.doc.mjs +3 -3
  172. package/authoring/doctypes/template/type.ts +22 -0
  173. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  174. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  175. package/authoring/identity/identity.doc.mjs +3 -3
  176. package/authoring/index.d.ts +1 -0
  177. package/authoring/integration/integration.doc.mjs +12 -4
  178. package/authoring/integration/parse.test.mjs +10 -0
  179. package/authoring/integration/schema.d.mts +2 -0
  180. package/authoring/integration/schema.mjs +1 -0
  181. package/authoring/integration/type.ts +4 -0
  182. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  183. package/clients/cli/commands/build-theme.mjs +1 -1
  184. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  185. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  186. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  187. package/clients/cli/commands/discover.doc.mjs +1 -1
  188. package/clients/cli/commands/discover.mjs +144 -93
  189. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  190. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  191. package/clients/cli/commands/doctor-integration-components.doc.mjs +18 -4
  192. package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
  193. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  194. package/clients/cli/commands/doctor-integration.test.mjs +884 -0
  195. package/clients/cli/commands/doctor.mjs +281 -5
  196. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  197. package/clients/cli/commands/gap-report.mjs +24 -2
  198. package/clients/cli/commands/gap-report.test.mjs +79 -0
  199. package/clients/cli/commands/integration-authoring.test.mjs +46 -0
  200. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  201. package/clients/cli/commands/integration-check.test.mjs +411 -0
  202. package/clients/cli/commands/integration.doc.mjs +6 -2
  203. package/clients/cli/commands/integration.mjs +116 -5
  204. package/clients/cli/commands/json-contract.test.mjs +5 -1
  205. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  206. package/clients/cli/commands/swizzle.mjs +5 -3
  207. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  208. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  209. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  210. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  211. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  212. package/clients/cli/index.mjs +30 -5
  213. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  214. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  215. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  216. package/foundation/agent-docs/agent-docs.mjs +8 -6
  217. package/foundation/config/project.mjs +82 -0
  218. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  219. package/foundation/discovery/component-discovery.d.mts +18 -0
  220. package/foundation/discovery/component-discovery.mjs +2 -2
  221. package/foundation/discovery/copied-passages.d.mts +216 -0
  222. package/foundation/discovery/copied-passages.mjs +720 -0
  223. package/foundation/discovery/copied-passages.test.mjs +124 -0
  224. package/foundation/discovery/doc-consistency.d.mts +34 -0
  225. package/foundation/discovery/doc-consistency.mjs +513 -0
  226. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  227. package/foundation/discovery/doc-fluff.d.mts +112 -0
  228. package/foundation/discovery/doc-fluff.mjs +328 -0
  229. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  230. package/foundation/discovery/doc-types.d.mts +157 -0
  231. package/foundation/discovery/doc-types.mjs +1231 -0
  232. package/foundation/discovery/doc-types.test.mjs +744 -0
  233. package/foundation/discovery/docs-discovery.d.mts +88 -0
  234. package/foundation/discovery/docs-discovery.mjs +83 -2
  235. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  236. package/foundation/discovery/integration-doc-files.mjs +231 -0
  237. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  238. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  239. package/foundation/discovery/package-tsconfig.mjs +228 -0
  240. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  241. package/foundation/discovery/project-typescript.d.mts +32 -0
  242. package/foundation/discovery/project-typescript.mjs +89 -0
  243. package/foundation/discovery/prop-drift.d.mts +297 -0
  244. package/foundation/discovery/prop-drift.mjs +2428 -0
  245. package/foundation/discovery/prop-drift.test.mjs +2337 -0
  246. package/foundation/discovery/stray-pointers.d.mts +52 -0
  247. package/foundation/discovery/stray-pointers.mjs +293 -0
  248. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  249. package/foundation/discovery/type-match.d.mts +53 -0
  250. package/foundation/discovery/type-match.mjs +660 -0
  251. package/foundation/discovery/type-match.test.mjs +169 -0
  252. package/foundation/discovery/type-text.d.mts +68 -0
  253. package/foundation/discovery/type-text.mjs +658 -0
  254. package/foundation/discovery/type-text.test.mjs +196 -0
  255. package/foundation/discovery/unresolved-references.d.mts +62 -0
  256. package/foundation/discovery/unresolved-references.mjs +790 -0
  257. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  258. package/foundation/doc-compiler/doc-loads.test.mjs +26 -0
  259. package/foundation/doc-compiler/links.d.mts +41 -5
  260. package/foundation/doc-compiler/links.mjs +167 -28
  261. package/foundation/doc-compiler/links.test.mjs +97 -4
  262. package/foundation/doc-compiler/tree.mjs +30 -1
  263. package/foundation/doc-compiler/tree.test.mjs +7 -0
  264. package/foundation/env/package-manager.d.mts +32 -0
  265. package/foundation/env/package-manager.mjs +47 -0
  266. package/foundation/env/package-manager.test.mjs +194 -7
  267. package/foundation/fs/module-loader.d.mts +2 -1
  268. package/foundation/fs/module-loader.mjs +60 -4
  269. package/foundation/fs/module-loader.test.mjs +194 -0
  270. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  271. package/foundation/integrations/contribution-inventory.mjs +50 -2
  272. package/foundation/integrations/issue.ts +6 -0
  273. package/foundation/integrations/validate-contributions.mjs +30 -1
  274. package/foundation/response/response-types.doc.mjs +15 -9
  275. package/package.json +11 -11
  276. package/scripts/postinstall.mjs +3 -3
@@ -55,6 +55,14 @@ export const GAP_REPORT_CATEGORIES = Object.freeze([
55
55
  export const PUBLIC_CONFIRMATION_MESSAGE =
56
56
  'Rerun with --confirm-public to file this report.';
57
57
 
58
+ /** What an agent does when more than one destination exists. */
59
+ export const ASK_DESTINATION_MESSAGE =
60
+ 'Ask the person where to file this report, then pass their choice with --to <package>. Never pick a package destination yourself; leave --to out to use the default.';
61
+
62
+ /**
63
+ * @typedef {import('./gap-report.type.mjs').GapReportDestination} GapReportDestination
64
+ */
65
+
58
66
  /**
59
67
  * @typedef {object} ReportTarget
60
68
  * @property {string} package
@@ -537,15 +545,14 @@ function githubRoute(issuesUrl) {
537
545
  }
538
546
 
539
547
  /**
540
- * Built-in GitHub fallback — runs only when the effective handler set is empty.
541
- * Requires confirmPublic.
548
+ * File a report on GitHub with `gh` — for the zero-handler fallback and for a
549
+ * destination the caller names. Requires confirmPublic.
542
550
  *
543
- * @param {ReportTarget} target
544
551
  * @param {{component: string, categoryLabel: string, intention: string, detail?: string, source: string, timestamp: string}} report
545
552
  * @param {{repo: string}} github
546
553
  * @returns {Promise<Pick<import('./gap-report.type.mjs').GapReportDelivery, 'status'|'url'|'message'>>}
547
554
  */
548
- async function runGithubFallback(target, report, github) {
555
+ async function runGithubFallback(report, github) {
549
556
  const {execFile} = await import('node:child_process');
550
557
  const title = `[gap] ${report.component}: ${report.intention.slice(0, 70)}`;
551
558
  const body = [
@@ -607,6 +614,87 @@ async function runGithubFallback(target, report, github) {
607
614
  }
608
615
  }
609
616
 
617
+ /**
618
+ * Send a report to an issues URL: a GitHub issues URL is filed with `gh` only
619
+ * with consent; any other URL comes back as routed_only. Serves the
620
+ * zero-handler fallback (spec:AST-031/FR8) and a destination named with `to`
621
+ * (architecture:cli-surface INV36).
622
+ *
623
+ * @param {string} issuesUrl
624
+ * @param {{component: string, categoryLabel: string, intention: string, detail?: string, source: string, timestamp: string}} report
625
+ * @param {boolean} confirmPublic
626
+ * @returns {Promise<import('./gap-report.type.mjs').GapReportDelivery>}
627
+ */
628
+ async function deliverToIssuesUrl(issuesUrl, report, confirmPublic) {
629
+ const github = githubRoute(issuesUrl);
630
+ if (github != null && !confirmPublic) {
631
+ return {
632
+ handlerType: 'fallback',
633
+ handler: 'github',
634
+ audience: 'public',
635
+ status: 'consent_required',
636
+ url: null,
637
+ message: PUBLIC_CONFIRMATION_MESSAGE,
638
+ };
639
+ }
640
+ if (github) {
641
+ return {
642
+ handlerType: 'fallback',
643
+ handler: 'github',
644
+ audience: 'public',
645
+ ...(await runGithubFallback(report, github)),
646
+ };
647
+ }
648
+ return {
649
+ handlerType: 'fallback',
650
+ handler: 'issuesUrl',
651
+ audience: null,
652
+ status: 'routed_only',
653
+ url: issuesUrl,
654
+ message:
655
+ 'No automatic handler is available; open the routed URL to file this report.',
656
+ };
657
+ }
658
+
659
+ /**
660
+ * Where a report can go: the default (the handlers, or with none the owning
661
+ * package's issues URL), then each loaded integration that names its own
662
+ * issues URL (architecture:cli-surface INV36).
663
+ *
664
+ * @param {Project} project
665
+ * @returns {GapReportDestination[]}
666
+ */
667
+ function listDestinations(project) {
668
+ /** @type {GapReportDestination[]} */
669
+ const destinations = [{to: null, default: true, issuesUrl: null}];
670
+ for (const integration of project.loadedIntegrations) {
671
+ if (integration.__loadError || !integration.issuesUrl) continue;
672
+ if (destinations.some(destination => destination.to === integration.name))
673
+ continue;
674
+ destinations.push({
675
+ to: integration.name,
676
+ default: false,
677
+ issuesUrl: integration.issuesUrl,
678
+ });
679
+ }
680
+ return destinations;
681
+ }
682
+
683
+ /**
684
+ * The destinations of the project at `cwd`, or only the default when no
685
+ * project loads there.
686
+ * @param {string|undefined} cwd
687
+ * @returns {Promise<GapReportDestination[]>}
688
+ */
689
+ async function destinationsAt(cwd) {
690
+ try {
691
+ const {resolve} = await import('node:path');
692
+ return listDestinations(await Project.load(resolve(cwd ?? process.cwd())));
693
+ } catch {
694
+ return [{to: null, default: true, issuesUrl: null}];
695
+ }
696
+ }
697
+
610
698
  /**
611
699
  * Compute the aggregate status from the deliveries.
612
700
  * @param {import('./gap-report.type.mjs').GapReportDelivery[]} deliveries
@@ -665,6 +753,7 @@ export async function gapReport(component, options = {}) {
665
753
  options.detail ? '--additional-context' : null,
666
754
  options.package ? '--package' : null,
667
755
  options.confirmPublic ? '--confirm-public' : null,
756
+ options.to != null ? '--to' : null,
668
757
  ].filter(Boolean);
669
758
  if (ignored.length > 0) {
670
759
  throw new AstryxError(
@@ -673,9 +762,13 @@ export async function gapReport(component, options = {}) {
673
762
  ERROR_CODES.ERR_INVALID_ARGUMENT,
674
763
  );
675
764
  }
765
+ const destinations = await destinationsAt(options.cwd);
676
766
  return {
677
767
  type: 'gap-report.categories',
678
768
  data: GAP_REPORT_CATEGORIES.map(category => ({...category})),
769
+ ...(destinations.length > 1
770
+ ? {meta: {destinations, ask: ASK_DESTINATION_MESSAGE}}
771
+ : {}),
679
772
  };
680
773
  }
681
774
 
@@ -704,7 +797,33 @@ export async function gapReport(component, options = {}) {
704
797
  options.package,
705
798
  );
706
799
 
707
- const entries = collectGapReportHandlers(project);
800
+ const destinations = listDestinations(project);
801
+ /** @type {GapReportDestination | undefined} */
802
+ let chosen;
803
+ // `to: null` is absent, like `package: null`; any other value is matched
804
+ // against the destinations as given, so an empty or unknown one lists them.
805
+ if (options.to != null) {
806
+ const to = options.to;
807
+ chosen = destinations.find(
808
+ destination => !destination.default && destination.to === to,
809
+ );
810
+ if (!chosen) {
811
+ const choices = destinations.filter(destination => !destination.default);
812
+ const named = JSON.stringify(String(to).slice(0, 214));
813
+ throw new AstryxError(
814
+ choices.length > 0
815
+ ? `No gap-report destination ${named}. Choose one of: ${choices.map(destination => destination.to).join(', ')}; or leave out --to for the default.`
816
+ : `No gap-report destination ${named}: no loaded integration names an issues URL. Leave out --to for the default.`,
817
+ choices.map(destination => ({
818
+ name: /** @type {string} */ (destination.to),
819
+ reason: /** @type {string} */ (destination.issuesUrl),
820
+ })),
821
+ ERROR_CODES.ERR_UNKNOWN_PACKAGE,
822
+ );
823
+ }
824
+ }
825
+
826
+ const entries = chosen ? [] : collectGapReportHandlers(project);
708
827
 
709
828
  const timestamp = new Date().toISOString();
710
829
  const source = captureEnv().invocationSource;
@@ -731,8 +850,24 @@ export async function gapReport(component, options = {}) {
731
850
 
732
851
  /** @type {import('./gap-report.type.mjs').GapReportDelivery[]} */
733
852
  const deliveries = [];
853
+ const routeReport = {
854
+ component: resolvedComponent,
855
+ categoryLabel: categoryEntry.label,
856
+ intention,
857
+ detail,
858
+ source,
859
+ timestamp,
860
+ };
734
861
 
735
- if (entries.length > 0) {
862
+ if (chosen) {
863
+ deliveries.push(
864
+ await deliverToIssuesUrl(
865
+ /** @type {string} */ (chosen.issuesUrl),
866
+ routeReport,
867
+ options.confirmPublic === true,
868
+ ),
869
+ );
870
+ } else if (entries.length > 0) {
736
871
  deliveries.push(
737
872
  ...(await deliverGapReportHandlers(entries, report, {
738
873
  confirmPublic: options.confirmPublic === true,
@@ -746,47 +881,13 @@ export async function gapReport(component, options = {}) {
746
881
  ERROR_CODES.ERR_NOT_FOUND,
747
882
  );
748
883
  }
749
-
750
- const github = githubRoute(target.issuesUrl);
751
- if (github != null && options.confirmPublic !== true) {
752
- deliveries.push({
753
- handlerType: 'fallback',
754
- handler: 'github',
755
- audience: 'public',
756
- status: 'consent_required',
757
- url: null,
758
- message: PUBLIC_CONFIRMATION_MESSAGE,
759
- });
760
- } else if (github) {
761
- const outcome = await runGithubFallback(
762
- target,
763
- {
764
- component: resolvedComponent,
765
- categoryLabel: categoryEntry.label,
766
- intention,
767
- detail,
768
- source,
769
- timestamp,
770
- },
771
- github,
772
- );
773
- deliveries.push({
774
- handlerType: 'fallback',
775
- handler: 'github',
776
- audience: 'public',
777
- ...outcome,
778
- });
779
- } else {
780
- deliveries.push({
781
- handlerType: 'fallback',
782
- handler: 'issuesUrl',
783
- audience: null,
784
- status: 'routed_only',
785
- url: target.issuesUrl,
786
- message:
787
- 'No automatic handler is available; open the routed URL to file this report.',
788
- });
789
- }
884
+ deliveries.push(
885
+ await deliverToIssuesUrl(
886
+ target.issuesUrl,
887
+ routeReport,
888
+ options.confirmPublic === true,
889
+ ),
890
+ );
790
891
  }
791
892
 
792
893
  const filedCount = deliveries.filter(d => d.status === 'filed').length;
@@ -800,10 +901,13 @@ export async function gapReport(component, options = {}) {
800
901
  data: {
801
902
  status,
802
903
  package: target.package,
803
- issuesUrl: target.issuesUrl,
904
+ issuesUrl: chosen ? chosen.issuesUrl : target.issuesUrl,
804
905
  deliveries,
805
906
  filedCount,
806
907
  routedOnlyCount,
908
+ ...(!chosen && destinations.length > 1
909
+ ? {destinations, ask: ASK_DESTINATION_MESSAGE}
910
+ : {}),
807
911
  },
808
912
  };
809
913
  }
@@ -7,6 +7,7 @@ import * as path from 'node:path';
7
7
  import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
8
8
  import {Project} from '../../foundation/config/project.mjs';
9
9
  import {
10
+ ASK_DESTINATION_MESSAGE,
10
11
  GAP_REPORT_CATEGORIES,
11
12
  PUBLIC_CONFIRMATION_MESSAGE,
12
13
  collectGapReportHandlers,
@@ -1022,6 +1023,238 @@ console.log('https://github.com/acme/widgets/issues/42');
1022
1023
  });
1023
1024
  });
1024
1025
 
1026
+ describe('gapReport destinations and --to', () => {
1027
+ /** A shared internal handler that records each call in a marker file. */
1028
+ function addSharedHandler() {
1029
+ const marker = path.join(projectDir, 'shared-called');
1030
+ addIntegration({
1031
+ name: '@test/shared',
1032
+ audience: 'internal',
1033
+ handleBody: `(await import('node:fs')).writeFileSync(${JSON.stringify(marker)}, 'x'); return {status: 'filed', message: 'shared'};`,
1034
+ });
1035
+ return marker;
1036
+ }
1037
+
1038
+ function addWidgets(issuesUrl = 'https://github.com/acme/widgets/issues') {
1039
+ addIntegration({name: '@test/widgets', handler: false, issuesUrl});
1040
+ }
1041
+
1042
+ it('keeps the default route and lists the destinations with the ask line', async () => {
1043
+ const marker = addSharedHandler();
1044
+ addWidgets();
1045
+ configure(['@test/shared', '@test/widgets']);
1046
+ const argsFile = stubGh();
1047
+
1048
+ const result = await gapReport('General', {
1049
+ ...reportOptions,
1050
+ confirmPublic: true,
1051
+ cwd: projectDir,
1052
+ });
1053
+
1054
+ expect(result.data.deliveries).toEqual([
1055
+ expect.objectContaining({handler: '@test/shared', status: 'filed'}),
1056
+ ]);
1057
+ expect(fs.existsSync(marker)).toBe(true);
1058
+ expect(fs.existsSync(argsFile)).toBe(false);
1059
+ expect(result.data.destinations).toEqual([
1060
+ {to: null, default: true, issuesUrl: null},
1061
+ {
1062
+ to: '@test/widgets',
1063
+ default: false,
1064
+ issuesUrl: 'https://github.com/acme/widgets/issues',
1065
+ },
1066
+ ]);
1067
+ expect(result.data.ask).toBe(ASK_DESTINATION_MESSAGE);
1068
+ expect(ASK_DESTINATION_MESSAGE).toMatch(/ask the person/i);
1069
+ });
1070
+
1071
+ it('lists no destinations when no integration names an issuesUrl', async () => {
1072
+ addSharedHandler();
1073
+ configure(['@test/shared']);
1074
+
1075
+ const result = await gapReport('General', {
1076
+ ...reportOptions,
1077
+ cwd: projectDir,
1078
+ });
1079
+
1080
+ expect(result.data).not.toHaveProperty('destinations');
1081
+ expect(result.data).not.toHaveProperty('ask');
1082
+ });
1083
+
1084
+ it('files with the chosen integration GitHub issuesUrl only with consent, and runs no handler', async () => {
1085
+ const marker = addSharedHandler();
1086
+ addWidgets();
1087
+ configure(['@test/shared', '@test/widgets']);
1088
+ const argsFile = stubGh();
1089
+
1090
+ const pending = await gapReport('General', {
1091
+ ...reportOptions,
1092
+ to: '@test/widgets',
1093
+ cwd: projectDir,
1094
+ });
1095
+ expect(pending.data.deliveries).toEqual([
1096
+ {
1097
+ handlerType: 'fallback',
1098
+ handler: 'github',
1099
+ audience: 'public',
1100
+ status: 'consent_required',
1101
+ url: null,
1102
+ message: PUBLIC_CONFIRMATION_MESSAGE,
1103
+ },
1104
+ ]);
1105
+ expect(pending.data.issuesUrl).toBe(
1106
+ 'https://github.com/acme/widgets/issues',
1107
+ );
1108
+ expect(pending.data).not.toHaveProperty('destinations');
1109
+ expect(fs.existsSync(argsFile)).toBe(false);
1110
+
1111
+ const filed = await gapReport('General', {
1112
+ ...reportOptions,
1113
+ to: '@test/widgets',
1114
+ confirmPublic: true,
1115
+ cwd: projectDir,
1116
+ });
1117
+ expect(filed.data.deliveries).toHaveLength(1);
1118
+ expect(filed.data.deliveries[0]).toMatchObject({
1119
+ handlerType: 'fallback',
1120
+ handler: 'github',
1121
+ status: 'filed',
1122
+ });
1123
+ const args = JSON.parse(fs.readFileSync(argsFile, 'utf8'));
1124
+ expect(args.slice(0, 4)).toEqual([
1125
+ 'issue',
1126
+ 'create',
1127
+ '--repo',
1128
+ 'acme/widgets',
1129
+ ]);
1130
+ expect(fs.existsSync(marker)).toBe(false);
1131
+ });
1132
+
1133
+ it('routes a chosen non-GitHub issuesUrl as routed_only', async () => {
1134
+ addSharedHandler();
1135
+ addWidgets('https://tracker.example/widgets');
1136
+ configure(['@test/shared', '@test/widgets']);
1137
+
1138
+ const result = await gapReport('General', {
1139
+ ...reportOptions,
1140
+ to: '@test/widgets',
1141
+ cwd: projectDir,
1142
+ });
1143
+
1144
+ expect(result.data.deliveries).toEqual([
1145
+ expect.objectContaining({
1146
+ handlerType: 'fallback',
1147
+ handler: 'issuesUrl',
1148
+ status: 'routed_only',
1149
+ url: 'https://tracker.example/widgets',
1150
+ }),
1151
+ ]);
1152
+ expect(result.data.status).toBe('routed_only');
1153
+ });
1154
+
1155
+ it.each([
1156
+ ['a package that is not loaded', '@test/nope'],
1157
+ ['a loaded integration without an issuesUrl', '@test/shared'],
1158
+ ])(
1159
+ 'refuses --to naming %s, lists the choices, and sends nothing',
1160
+ async (_label, to) => {
1161
+ const marker = addSharedHandler();
1162
+ addWidgets();
1163
+ configure(['@test/shared', '@test/widgets']);
1164
+
1165
+ await expect(
1166
+ gapReport('General', {...reportOptions, to, cwd: projectDir}),
1167
+ ).rejects.toMatchObject({
1168
+ code: 'ERR_UNKNOWN_PACKAGE',
1169
+ suggestions: [
1170
+ {
1171
+ name: '@test/widgets',
1172
+ reason: 'https://github.com/acme/widgets/issues',
1173
+ },
1174
+ ],
1175
+ });
1176
+ expect(fs.existsSync(marker)).toBe(false);
1177
+ },
1178
+ );
1179
+
1180
+ it.each([
1181
+ ['an empty value', ''],
1182
+ ['a blank value', ' '],
1183
+ ['an over-long value', `@test/${'a'.repeat(300)}`],
1184
+ ])('refuses %s for --to with the destination list', async (_label, to) => {
1185
+ const marker = addSharedHandler();
1186
+ addWidgets();
1187
+ configure(['@test/shared', '@test/widgets']);
1188
+
1189
+ await expect(
1190
+ gapReport('General', {...reportOptions, to, cwd: projectDir}),
1191
+ ).rejects.toMatchObject({
1192
+ code: 'ERR_UNKNOWN_PACKAGE',
1193
+ suggestions: [{name: '@test/widgets'}],
1194
+ });
1195
+ expect(fs.existsSync(marker)).toBe(false);
1196
+ });
1197
+
1198
+ it('treats to: null as absent', async () => {
1199
+ const marker = addSharedHandler();
1200
+ addWidgets();
1201
+ configure(['@test/shared', '@test/widgets']);
1202
+
1203
+ const result = await gapReport('General', {
1204
+ ...reportOptions,
1205
+ to: /** @type {any} */ (null),
1206
+ cwd: projectDir,
1207
+ });
1208
+
1209
+ expect(result.data.deliveries).toHaveLength(1);
1210
+ expect(fs.existsSync(marker)).toBe(true);
1211
+ expect(result.data.destinations).toHaveLength(2);
1212
+ });
1213
+
1214
+ it('lists the destinations with the categories', async () => {
1215
+ addSharedHandler();
1216
+ addWidgets();
1217
+ configure(['@test/shared', '@test/widgets']);
1218
+
1219
+ const listed = await gapReport(undefined, {
1220
+ listCategories: true,
1221
+ cwd: projectDir,
1222
+ });
1223
+
1224
+ expect(listed.data).toEqual(GAP_REPORT_CATEGORIES);
1225
+ expect(listed.meta).toEqual({
1226
+ destinations: [
1227
+ {to: null, default: true, issuesUrl: null},
1228
+ {
1229
+ to: '@test/widgets',
1230
+ default: false,
1231
+ issuesUrl: 'https://github.com/acme/widgets/issues',
1232
+ },
1233
+ ],
1234
+ ask: ASK_DESTINATION_MESSAGE,
1235
+ });
1236
+ });
1237
+
1238
+ it('adds no meta to the categories when there is only the default', async () => {
1239
+ configure([]);
1240
+ const listed = await gapReport(undefined, {
1241
+ listCategories: true,
1242
+ cwd: projectDir,
1243
+ });
1244
+ expect(listed).not.toHaveProperty('meta');
1245
+ });
1246
+
1247
+ it('refuses --to with --list-categories', async () => {
1248
+ await expect(
1249
+ gapReport(undefined, {
1250
+ listCategories: true,
1251
+ to: '@test/widgets',
1252
+ cwd: projectDir,
1253
+ }),
1254
+ ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
1255
+ });
1256
+ });
1257
+
1025
1258
  describe('gapReport target selection', () => {
1026
1259
  it('routes to the unique component owner', async () => {
1027
1260
  addIntegration({
@@ -35,10 +35,42 @@ export type GapReportOptions = {
35
35
  * Return the category vocabulary without routing or writing.
36
36
  */
37
37
  listCategories?: boolean | undefined;
38
+ /**
39
+ * A destination the person chose: a loaded integration
40
+ * whose manifest names an issues URL. The report goes only there.
41
+ */
42
+ to?: string | undefined;
43
+ };
44
+ /**
45
+ * Where a report can go. The default entry (`to: null`) is the configured
46
+ * handlers, or with none the owning package's issues URL.
47
+ */
48
+ export type GapReportDestination = {
49
+ /**
50
+ * The value to pass as `to`; null for the default.
51
+ */
52
+ to: string | null;
53
+ /**
54
+ * Whether this is the default destination.
55
+ */
56
+ default: boolean;
57
+ /**
58
+ * The integration's issues URL; null for the
59
+ * default.
60
+ */
61
+ issuesUrl: string | null;
38
62
  };
39
63
  export type GapReportCategoriesResponse = {
40
64
  type: "gap-report.categories";
41
65
  data: GapReportCategoryEntry[];
66
+ /**
67
+ * Present when a destination besides the default exists: every destination,
68
+ * and the line telling an agent to ask the person.
69
+ */
70
+ meta?: {
71
+ destinations: GapReportDestination[];
72
+ ask: string;
73
+ } | undefined;
42
74
  };
43
75
  export type GapReportAggregateStatus = "filed" | "partial" | "failed" | "routed_only" | "consent_required" | "skipped";
44
76
  export type GapReportDeliveryStatus = "filed" | "routed_only" | "skipped" | "failed" | "consent_required";
@@ -81,6 +113,15 @@ export type GapReportReceipt = {
81
113
  * Count of handlers that routed only.
82
114
  */
83
115
  routedOnlyCount: number;
116
+ /**
117
+ * For a run without `to`,
118
+ * when a destination besides the default exists: every destination.
119
+ */
120
+ destinations?: GapReportDestination[] | undefined;
121
+ /**
122
+ * With `destinations`: ask the person where to file.
123
+ */
124
+ ask?: string | undefined;
84
125
  };
85
126
  export type GapReportReceiptResponse = {
86
127
  type: "gap-report.file";
@@ -23,12 +23,27 @@
23
23
  * @property {string} [package] Explicit owner package for ambiguous routes.
24
24
  * @property {boolean} [confirmPublic] Explicit consent for public handlers or GitHub issue creation.
25
25
  * @property {boolean} [listCategories] Return the category vocabulary without routing or writing.
26
+ * @property {string} [to] A destination the person chose: a loaded integration
27
+ * whose manifest names an issues URL. The report goes only there.
28
+ */
29
+
30
+ /**
31
+ * Where a report can go. The default entry (`to: null`) is the configured
32
+ * handlers, or with none the owning package's issues URL.
33
+ * @typedef {object} GapReportDestination
34
+ * @property {string|null} to The value to pass as `to`; null for the default.
35
+ * @property {boolean} default Whether this is the default destination.
36
+ * @property {string|null} issuesUrl The integration's issues URL; null for the
37
+ * default.
26
38
  */
27
39
 
28
40
  /**
29
41
  * @typedef {object} GapReportCategoriesResponse
30
42
  * @property {'gap-report.categories'} type
31
43
  * @property {GapReportCategoryEntry[]} data
44
+ * @property {{destinations: GapReportDestination[], ask: string}} [meta]
45
+ * Present when a destination besides the default exists: every destination,
46
+ * and the line telling an agent to ask the person.
32
47
  */
33
48
 
34
49
  /**
@@ -58,6 +73,9 @@
58
73
  * @property {GapReportDelivery[]} deliveries Ordered handler outcomes.
59
74
  * @property {number} filedCount Count of handlers that filed the report.
60
75
  * @property {number} routedOnlyCount Count of handlers that routed only.
76
+ * @property {GapReportDestination[]} [destinations] For a run without `to`,
77
+ * when a destination besides the default exists: every destination.
78
+ * @property {string} [ask] With `destinations`: ask the person where to file.
61
79
  */
62
80
 
63
81
  /**
package/api/index.d.mts CHANGED
@@ -16,6 +16,7 @@ export { init } from "./init/init.mjs";
16
16
  export { doctor } from "./doctor/doctor.mjs";
17
17
  export { integrationAddTheme } from "./integration/add-theme.mjs";
18
18
  export { integrationPackCheck } from "./integration/pack-check.mjs";
19
+ export { integrationCheck } from "./integration/check/check.mjs";
19
20
  export { AstryxError } from "./error.mjs";
20
21
  export { logger } from "./logger.mjs";
21
22
  export * from "../foundation/response/batch.type.mjs";
@@ -37,6 +38,7 @@ export * from "./integration/integration-authoring.type.mjs";
37
38
  export * from "./integration/pack-check.type.mjs";
38
39
  export * from "./integration/validate-integration.type.mjs";
39
40
  export * from "./integration/authoring-checks.type.mjs";
41
+ export * from "./integration/integration-check.type.mjs";
40
42
  export type Logger = import("./logger.mjs").Logger;
41
43
  export { themeBuild, themeAdd, themeRemove, themeUse, themeEject, themeTemplate, themeList, themeListAvailable, themeListCopySources, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
42
44
  export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
package/api/index.mjs CHANGED
@@ -67,6 +67,7 @@ export {
67
67
  integrationComponentConflicts,
68
68
  integrationDocConflicts,
69
69
  } from './integration/authoring-checks.mjs';
70
+ export {integrationCheck} from './integration/check/check.mjs';
70
71
  export {AstryxError} from './error.mjs';
71
72
  // The one shared logger: the `logger` instance side-effecting commands write
72
73
  // through, plus its generated `Logger` type. Part of the public surface so an
@@ -100,3 +101,4 @@ export * from './integration/integration-authoring.type.mjs';
100
101
  export * from './integration/pack-check.type.mjs';
101
102
  export * from './integration/validate-integration.type.mjs';
102
103
  export * from './integration/authoring-checks.type.mjs';
104
+ export * from './integration/integration-check.type.mjs';
@@ -50,11 +50,11 @@ export function getNextSteps(invocation) {
50
50
  ` (run \`${invocation} doctor\` to verify)`,
51
51
  " 2. Import base styles: import '@astryxdesign/core/reset.css'",
52
52
  " and import '@astryxdesign/core/astryx.css'",
53
- " 3. Import components: import { Button } from '@astryxdesign/core'",
53
+ " 3. Import components: import { Button } from '@astryxdesign/core/Button'",
54
54
  ' 4. Add and wire a theme:',
55
55
  ' npm install @astryxdesign/theme-neutral',
56
56
  ` ${invocation} theme add neutral`,
57
- " import { Theme } from '@astryxdesign/core'",
57
+ " import { Theme } from '@astryxdesign/core/theme'",
58
58
  " import { themes, defaultThemeSlug } from './astryx-themes'",
59
59
  ' <Theme theme={themes[defaultThemeSlug]}>...</Theme>',
60
60
  ` Extend an imported theme to customize it. Run \`${invocation} theme eject <slug>\` only to fork source.`,