@astryxdesign/cli 0.7.6-canary.962dffe → 0.7.6-canary.9728cd7

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 (504) hide show
  1. package/api/search/_adapter.d.mts +3 -1
  2. package/api/search/_adapter.mjs +19 -19
  3. package/assets/docs/motion.doc.mjs +1 -1
  4. package/foundation/discovery/package-tsconfig.mjs +34 -0
  5. package/foundation/fs/read-record.d.mts +4 -1
  6. package/foundation/fs/read-record.mjs +9 -5
  7. package/package.json +24 -10
  8. package/api/api-docs-parse.test.mjs +0 -47
  9. package/api/blog/_adapter.test.mjs +0 -183
  10. package/api/blog/blog.test.mjs +0 -144
  11. package/api/blog/detail/detail.test.mjs +0 -118
  12. package/api/blog/list/list.test.mjs +0 -81
  13. package/api/build/blocks/blocks.test.mjs +0 -238
  14. package/api/build/build.test.mjs +0 -569
  15. package/api/build/kit/answer.test.mjs +0 -108
  16. package/api/build/kit/rank.test.mjs +0 -380
  17. package/api/build/kit/weights.test.mjs +0 -286
  18. package/api/build/tree.test.mjs +0 -185
  19. package/api/component/component-replacement.test.mjs +0 -616
  20. package/api/component/component.test.mjs +0 -532
  21. package/api/component/doc-links.test.mjs +0 -419
  22. package/api/component/integration-export-name.test.mjs +0 -644
  23. package/api/component/integration-import-agreement.test.mjs +0 -474
  24. package/api/discover/_adapter.test.mjs +0 -839
  25. package/api/discover/_catalog-view.test.mjs +0 -129
  26. package/api/discover/_package-scanner.test.mjs +0 -117
  27. package/api/discover/detail/detail.test.mjs +0 -145
  28. package/api/discover/detail/doc/doc.test.mjs +0 -93
  29. package/api/discover/detail/item/item.test.mjs +0 -75
  30. package/api/discover/discover.test.mjs +0 -100
  31. package/api/discover/list/list.test.mjs +0 -107
  32. package/api/discover/search/search.test.mjs +0 -319
  33. package/api/docs/compiled-topics.test.mjs +0 -94
  34. package/api/docs/detail/section/section.test.mjs +0 -92
  35. package/api/docs/docOverlays.test.mjs +0 -189
  36. package/api/docs/docs-homes.test.mjs +0 -127
  37. package/api/docs/docs.depth.test.mjs +0 -134
  38. package/api/docs/docs.test.mjs +0 -315
  39. package/api/docs/guide-route-targets.test.mjs +0 -1002
  40. package/api/docs/index/index.test.mjs +0 -67
  41. package/api/docs/integration-tree.test.mjs +0 -616
  42. package/api/docs/integrationDocs.test.mjs +0 -546
  43. package/api/docs/namespace-section.test.mjs +0 -260
  44. package/api/docs/react-version-sync.test.mjs +0 -79
  45. package/api/docs/reference-blocks.test.mjs +0 -404
  46. package/api/docs/token-tables.test.mjs +0 -93
  47. package/api/doctor/built-checks.test.mjs +0 -531
  48. package/api/doctor/doctor.test.mjs +0 -1651
  49. package/api/doctor/icon-sets.test.mjs +0 -111
  50. package/api/doctor/release-checks.test.mjs +0 -156
  51. package/api/doctor/theme-checks.test.mjs +0 -884
  52. package/api/gap-report/gap-report.test.mjs +0 -1549
  53. package/api/hook/detail/detail.test.mjs +0 -53
  54. package/api/hook/detail/params/params.test.mjs +0 -39
  55. package/api/hook/hook.test.mjs +0 -75
  56. package/api/icon/all-or-nothing.test.mjs +0 -283
  57. package/api/icon/error-codes.test.mjs +0 -341
  58. package/api/icon/experimental-markers.test.mjs +0 -93
  59. package/api/icon/icon.test.mjs +0 -506
  60. package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
  61. package/api/icon/new-set/new-set.test.mjs +0 -398
  62. package/api/icon/option-pairs.test.mjs +0 -368
  63. package/api/init/init.test.mjs +0 -319
  64. package/api/init/remove/remove.test.mjs +0 -124
  65. package/api/init/user/user.test.mjs +0 -232
  66. package/api/integration/add-contribution.component-names.test.mjs +0 -186
  67. package/api/integration/add-contribution.test.mjs +0 -990
  68. package/api/integration/add-helpers.test.mjs +0 -161
  69. package/api/integration/add-theme.test.mjs +0 -676
  70. package/api/integration/authoring-checks.test.mjs +0 -1683
  71. package/api/integration/check/check.test.mjs +0 -538
  72. package/api/integration/doc-stability.test.mjs +0 -216
  73. package/api/integration/example-checks.no-npm.test.mjs +0 -140
  74. package/api/integration/example-checks.test.mjs +0 -776
  75. package/api/integration/integration-block-exports.test.mjs +0 -248
  76. package/api/integration/pack-check.component-replaces.test.mjs +0 -126
  77. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
  78. package/api/integration/pack-check.test.mjs +0 -2512
  79. package/api/integration/public-api.test.mjs +0 -21
  80. package/api/integration/template-conflict-compatibility.test.mjs +0 -73
  81. package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
  82. package/api/integration/validate-integration-case-disk.test.mjs +0 -123
  83. package/api/integration/validate-integration-fixes.test.mjs +0 -1457
  84. package/api/integration/validate-integration-gaps.test.mjs +0 -1999
  85. package/api/integration/validate-integration.test.mjs +0 -835
  86. package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
  87. package/api/json/envelope-types.test.mjs +0 -76
  88. package/api/json/parse.test.mjs +0 -76
  89. package/api/render/render.test.mjs +0 -1155
  90. package/api/search/_adapter.test.mjs +0 -192
  91. package/api/search/_doc-searcher.test.mjs +0 -36
  92. package/api/search/_entries.test.mjs +0 -48
  93. package/api/search/_main-searcher.test.mjs +0 -106
  94. package/api/search/_order.test.mjs +0 -72
  95. package/api/search/_template-searcher.test.mjs +0 -40
  96. package/api/search/search-return-type.test.mjs +0 -54
  97. package/api/search/search.domain-priority.test.mjs +0 -351
  98. package/api/search/search.family-members.test.mjs +0 -124
  99. package/api/search/search.family-word.test.mjs +0 -146
  100. package/api/search/search.integration-block.test.mjs +0 -100
  101. package/api/search/search.integration-check.test.mjs +0 -24
  102. package/api/search/search.test.mjs +0 -1007
  103. package/api/search/search.tie-order.test.mjs +0 -39
  104. package/api/search/tree.test.mjs +0 -66
  105. package/api/swizzle/_github.test.mjs +0 -53
  106. package/api/swizzle/copy/copy.test.mjs +0 -60
  107. package/api/swizzle/swizzle.test.mjs +0 -157
  108. package/api/template/cdn/cdn.test.mjs +0 -108
  109. package/api/template/checkout-wizard.test.mjs +0 -87
  110. package/api/template/copy/copy.receipt.test.mjs +0 -77
  111. package/api/template/copy/copy.test.mjs +0 -77
  112. package/api/template/data-token-fallbacks.test.mjs +0 -85
  113. package/api/template/discover-integration-templates.test.mjs +0 -56
  114. package/api/template/form-wizard-dialog.test.mjs +0 -47
  115. package/api/template/inline-wizard-template.test.mjs +0 -24
  116. package/api/template/list/list.test.mjs +0 -52
  117. package/api/template/show/show.test.mjs +0 -76
  118. package/api/template/table-filter-view-tabs.test.mjs +0 -45
  119. package/api/template/table-floating-bulk-actions.test.mjs +0 -66
  120. package/api/template/template-integration.test.mjs +0 -1274
  121. package/api/template/template-suffix.test.mjs +0 -286
  122. package/api/template/template.test.mjs +0 -222
  123. package/api/template/tokenizer-showcase.test.mjs +0 -47
  124. package/api/template/unknown-name.test.mjs +0 -63
  125. package/api/theme/add/add.test.mjs +0 -363
  126. package/api/theme/add/add.types.test.mjs +0 -150
  127. package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
  128. package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
  129. package/api/theme/build/build.core-on-demand.test.mjs +0 -113
  130. package/api/theme/build/build.family.test.mjs +0 -503
  131. package/api/theme/build/build.font-warning.test.mjs +0 -170
  132. package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
  133. package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
  134. package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
  135. package/api/theme/build/build.icon-lineage.test.mjs +0 -117
  136. package/api/theme/build/build.icon-preservation.test.mjs +0 -639
  137. package/api/theme/build/build.icon-variants.test.mjs +0 -105
  138. package/api/theme/build/build.icons-specifier.test.mjs +0 -149
  139. package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
  140. package/api/theme/build/build.project-core.test.mjs +0 -220
  141. package/api/theme/build/build.public-component-vars.test.mjs +0 -151
  142. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  143. package/api/theme/build/build.rollback.test.mjs +0 -148
  144. package/api/theme/build/build.test.mjs +0 -1258
  145. package/api/theme/build/font-warning.test.mjs +0 -268
  146. package/api/theme/eject/eject.binary.test.mjs +0 -90
  147. package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
  148. package/api/theme/eject/eject.rollback.test.mjs +0 -158
  149. package/api/theme/eject/eject.staging.test.mjs +0 -83
  150. package/api/theme/eject/eject.test.mjs +0 -160
  151. package/api/theme/integration-themes.test.mjs +0 -218
  152. package/api/theme/list/list.test.mjs +0 -271
  153. package/api/theme/palette/generate/generate.test.mjs +0 -445
  154. package/api/theme/palette/generate/generator.test.mjs +0 -385
  155. package/api/theme/palette/generate/preview.test.mjs +0 -55
  156. package/api/theme/remove/remove.test.mjs +0 -94
  157. package/api/theme/targets/targets.test.mjs +0 -91
  158. package/api/theme/template/template.test.mjs +0 -102
  159. package/api/theme/use/use.test.mjs +0 -98
  160. package/api/upgrade/list/list.test.mjs +0 -73
  161. package/api/upgrade/project-context.test.mjs +0 -272
  162. package/api/upgrade/provider-agreement.test.mjs +0 -152
  163. package/api/upgrade/registry/registry.test.mjs +0 -911
  164. package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
  165. package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
  166. package/api/upgrade/run/failure-receipt.test.mjs +0 -212
  167. package/api/upgrade/run/files-changed.test.mjs +0 -111
  168. package/api/upgrade/run/outcomes.test.mjs +0 -646
  169. package/api/upgrade/run/run.test.mjs +0 -511
  170. package/api/upgrade/upgrade.test.mjs +0 -594
  171. package/assets/codemods/__tests__/registry.test.mjs +0 -77
  172. package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
  173. package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
  174. package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
  175. package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
  176. package/assets/codemods/__tests__/runner.test.mjs +0 -559
  177. package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
  178. package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
  179. package/assets/codemods/__tests__/validation.test.mjs +0 -108
  180. package/assets/codemods/file-count.test.mjs +0 -163
  181. package/assets/codemods/integration-discovery.test.mjs +0 -360
  182. package/assets/codemods/integration-runner.protection.test.mjs +0 -206
  183. package/assets/codemods/outcome.test.mjs +0 -40
  184. package/assets/codemods/term-log.test.mjs +0 -80
  185. package/assets/codemods/transform-prop.test.mjs +0 -130
  186. package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
  187. package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
  188. package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
  189. package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
  190. package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
  191. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
  192. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
  193. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
  194. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
  195. package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
  196. package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
  197. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
  198. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
  199. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
  200. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
  201. package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
  202. package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
  203. package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
  204. package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
  205. package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
  206. package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
  207. package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
  208. package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
  209. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
  210. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
  211. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
  212. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
  213. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
  214. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
  215. package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
  216. package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
  217. package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
  218. package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
  219. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
  220. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
  221. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
  222. package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
  223. package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
  224. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
  225. package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  226. package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  227. package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
  228. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
  229. package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
  230. package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
  231. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
  232. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
  233. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
  234. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
  235. package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
  236. package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
  237. package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
  238. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
  239. package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
  240. package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
  241. package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
  242. package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
  243. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
  244. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
  245. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
  246. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
  247. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
  248. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
  249. package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
  250. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
  251. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
  252. package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
  253. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
  254. package/authoring/_shared/errors.test.mjs +0 -49
  255. package/authoring/codemod/parse.test.mjs +0 -99
  256. package/authoring/config/debug-composition.test.mjs +0 -92
  257. package/authoring/config/parse.test.mjs +0 -121
  258. package/authoring/debug/parse.test.mjs +0 -187
  259. package/authoring/discover/parse.test.mjs +0 -158
  260. package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
  261. package/authoring/doctypes/doctypes-new.test.mjs +0 -162
  262. package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
  263. package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
  264. package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
  265. package/authoring/doctypes/load-contract.test.mjs +0 -246
  266. package/authoring/doctypes/namespace/parse.test.mjs +0 -163
  267. package/authoring/doctypes/parse.test.mjs +0 -422
  268. package/authoring/doctypes/template/parse.test.mjs +0 -198
  269. package/authoring/gap-report/parse.test.mjs +0 -172
  270. package/authoring/integration/parse.test.mjs +0 -184
  271. package/authoring/shadcn/receipt.test.mjs +0 -187
  272. package/authoring/shadcn/source-variants.test.mjs +0 -120
  273. package/clients/cli/__tests__/cliManifest.test.ts +0 -37
  274. package/clients/cli/cli-command.test.mjs +0 -166
  275. package/clients/cli/cli-exit-codes.test.mjs +0 -163
  276. package/clients/cli/command-load-failure.test.mjs +0 -83
  277. package/clients/cli/command-result-coverage.test.mjs +0 -136
  278. package/clients/cli/commands/blog.test.mjs +0 -138
  279. package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
  280. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
  281. package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
  282. package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
  283. package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
  284. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  285. package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
  286. package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
  287. package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
  288. package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
  289. package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
  290. package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
  291. package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
  292. package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
  293. package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
  294. package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
  295. package/clients/cli/commands/build.error-codes.test.mjs +0 -50
  296. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
  297. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  298. package/clients/cli/commands/build.text-fields.test.mjs +0 -81
  299. package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
  300. package/clients/cli/commands/component-batch.test.mjs +0 -341
  301. package/clients/cli/commands/component-ownership.test.mjs +0 -384
  302. package/clients/cli/commands/component-package.test.mjs +0 -169
  303. package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
  304. package/clients/cli/commands/component-resolution.test.mjs +0 -204
  305. package/clients/cli/commands/component.test.mjs +0 -612
  306. package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
  307. package/clients/cli/commands/detail-levels.test.mjs +0 -145
  308. package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
  309. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
  310. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  311. package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
  312. package/clients/cli/commands/discover.no-source.test.mjs +0 -490
  313. package/clients/cli/commands/discover.sources.test.mjs +0 -292
  314. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  315. package/clients/cli/commands/docs.depth.test.mjs +0 -219
  316. package/clients/cli/commands/docs.test.mjs +0 -385
  317. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  318. package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
  319. package/clients/cli/commands/doctor.test.mjs +0 -509
  320. package/clients/cli/commands/empty-argument.test.mjs +0 -16
  321. package/clients/cli/commands/external-showcase.test.mjs +0 -121
  322. package/clients/cli/commands/gap-report.test.mjs +0 -412
  323. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  324. package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
  325. package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
  326. package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
  327. package/clients/cli/commands/icon.test.mjs +0 -96
  328. package/clients/cli/commands/import-hint-correctness.test.mjs +0 -293
  329. package/clients/cli/commands/init.behavior.test.mjs +0 -434
  330. package/clients/cli/commands/init.flag-help.test.mjs +0 -151
  331. package/clients/cli/commands/init.next-steps.test.mjs +0 -41
  332. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  333. package/clients/cli/commands/integration-authoring.test.mjs +0 -288
  334. package/clients/cli/commands/integration-check.test.mjs +0 -522
  335. package/clients/cli/commands/integration-real-world.test.mjs +0 -661
  336. package/clients/cli/commands/interactive-guard.test.mjs +0 -143
  337. package/clients/cli/commands/json-contract.test.mjs +0 -216
  338. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  339. package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
  340. package/clients/cli/commands/outside-project.test.mjs +0 -874
  341. package/clients/cli/commands/search.test.mjs +0 -514
  342. package/clients/cli/commands/setup-nudge.test.mjs +0 -280
  343. package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
  344. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
  345. package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
  346. package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
  347. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  348. package/clients/cli/commands/template.flag-help.test.mjs +0 -124
  349. package/clients/cli/commands/template.icons.test.mjs +0 -132
  350. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  351. package/clients/cli/commands/template.path-safety.test.mjs +0 -82
  352. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  353. package/clients/cli/commands/template.test.mjs +0 -62
  354. package/clients/cli/commands/text-json-parity.test.mjs +0 -850
  355. package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
  356. package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
  357. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
  358. package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
  359. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
  360. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
  361. package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
  362. package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
  363. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
  364. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
  365. package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
  366. package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
  367. package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
  368. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
  369. package/clients/cli/commands/upgrade.test.mjs +0 -361
  370. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
  371. package/clients/cli/commands/write-failure.test.mjs +0 -175
  372. package/clients/cli/e2e-smoke.test.mjs +0 -162
  373. package/clients/cli/error-envelope-code.test.mjs +0 -38
  374. package/clients/cli/formatters/index.test.mjs +0 -262
  375. package/clients/cli/latest-version-env.test.mjs +0 -50
  376. package/clients/cli/lib/cli-error.test.mjs +0 -206
  377. package/clients/cli/lib/component-format.test.mjs +0 -246
  378. package/clients/cli/lib/define-command.test.mjs +0 -103
  379. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
  380. package/clients/cli/lib/exit-codes.test.mjs +0 -111
  381. package/clients/cli/lib/hook-format.test.mjs +0 -35
  382. package/clients/cli/lib/json-shim.test.mjs +0 -268
  383. package/clients/cli/lib/manifest.test.mjs +0 -346
  384. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  385. package/clients/cli/lib/resolve-theme.test.mjs +0 -543
  386. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
  387. package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
  388. package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
  389. package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
  390. package/foundation/config/config-cache.test.mjs +0 -83
  391. package/foundation/config/config-writer.test.mjs +0 -84
  392. package/foundation/config/integration-debug.test.mjs +0 -218
  393. package/foundation/config/project-themes.test.mjs +0 -119
  394. package/foundation/config/project.test.mjs +0 -931
  395. package/foundation/config/theme-private-vars.test.mjs +0 -76
  396. package/foundation/config/theme-state.test.mjs +0 -182
  397. package/foundation/debug/debug-fields.test.mjs +0 -327
  398. package/foundation/debug/integration-handlers.test.mjs +0 -267
  399. package/foundation/debug/on-event.test.mjs +0 -643
  400. package/foundation/debug/privacy-contract.test.mjs +0 -195
  401. package/foundation/debug/redact.test.mjs +0 -534
  402. package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
  403. package/foundation/discovery/authoring-surface.test.mjs +0 -392
  404. package/foundation/discovery/cli-self-docs.test.mjs +0 -396
  405. package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
  406. package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
  407. package/foundation/discovery/component-discovery.test.mjs +0 -336
  408. package/foundation/discovery/component-loader.test.mjs +0 -190
  409. package/foundation/discovery/component-replacement.test.mjs +0 -520
  410. package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
  411. package/foundation/discovery/copied-passages.test.mjs +0 -124
  412. package/foundation/discovery/doc-consistency.test.mjs +0 -347
  413. package/foundation/discovery/doc-fluff.test.mjs +0 -142
  414. package/foundation/discovery/doc-types.test.mjs +0 -774
  415. package/foundation/discovery/docs-discovery.test.mjs +0 -707
  416. package/foundation/discovery/docs-section-key.test.mjs +0 -246
  417. package/foundation/discovery/hook-discovery.test.mjs +0 -216
  418. package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
  419. package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
  420. package/foundation/discovery/icon-set-writer.test.mjs +0 -26
  421. package/foundation/discovery/integration-doc-files.test.mjs +0 -275
  422. package/foundation/discovery/module-exports.test.mjs +0 -209
  423. package/foundation/discovery/package-tsconfig.test.mjs +0 -210
  424. package/foundation/discovery/prop-drift.test.mjs +0 -2337
  425. package/foundation/discovery/runner-commands.test.mjs +0 -131
  426. package/foundation/discovery/stray-pointers.test.mjs +0 -92
  427. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
  428. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  429. package/foundation/discovery/template-adapter.test.mjs +0 -223
  430. package/foundation/discovery/template-conflict-release.test.mjs +0 -40
  431. package/foundation/discovery/template-icons.test.mjs +0 -560
  432. package/foundation/discovery/template-needs.test.mjs +0 -306
  433. package/foundation/discovery/theme-discovery.test.mjs +0 -775
  434. package/foundation/discovery/theme-imports.test.mjs +0 -173
  435. package/foundation/discovery/theming-targets.test.mjs +0 -328
  436. package/foundation/discovery/type-match.test.mjs +0 -169
  437. package/foundation/discovery/type-text.test.mjs +0 -196
  438. package/foundation/discovery/unresolved-references.test.mjs +0 -567
  439. package/foundation/doc-compiler/bundle.test.mjs +0 -266
  440. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
  441. package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
  442. package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
  443. package/foundation/doc-compiler/inputs.test.mjs +0 -298
  444. package/foundation/doc-compiler/links.test.mjs +0 -285
  445. package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
  446. package/foundation/doc-compiler/read.test.mjs +0 -380
  447. package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
  448. package/foundation/doc-compiler/tree.test.mjs +0 -691
  449. package/foundation/env/cli-command.test.mjs +0 -129
  450. package/foundation/env/node-version.test.mjs +0 -103
  451. package/foundation/env/package-manager.global.test.mjs +0 -66
  452. package/foundation/env/package-manager.test.mjs +0 -910
  453. package/foundation/env/search-path.test.mjs +0 -122
  454. package/foundation/env/semver.test.mjs +0 -111
  455. package/foundation/env/user-dirs.test.mjs +0 -72
  456. package/foundation/env/user-settings.test.mjs +0 -64
  457. package/foundation/fs/file-protection.test.mjs +0 -250
  458. package/foundation/fs/listing-cache.test.mjs +0 -88
  459. package/foundation/fs/module-loader.stdout.test.mjs +0 -333
  460. package/foundation/fs/module-loader.test.mjs +0 -410
  461. package/foundation/fs/path-safety.test.mjs +0 -222
  462. package/foundation/fs/paths.test.mjs +0 -725
  463. package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
  464. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
  465. package/foundation/fs/publish-file.test.mjs +0 -136
  466. package/foundation/fs/read-record.test.mjs +0 -164
  467. package/foundation/identity/provider-identity.test.mjs +0 -254
  468. package/foundation/integrations/autolink.test.mjs +0 -430
  469. package/foundation/integrations/cli-peer-version.test.mjs +0 -354
  470. package/foundation/integrations/cli-requirement.test.mjs +0 -383
  471. package/foundation/integrations/computer-integrations.test.mjs +0 -292
  472. package/foundation/integrations/contribution-inventory.test.mjs +0 -420
  473. package/foundation/integrations/integration-warnings.test.mjs +0 -191
  474. package/foundation/integrations/integrations.test.mjs +0 -818
  475. package/foundation/integrations/manifest-writer.test.mjs +0 -271
  476. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
  477. package/foundation/integrations/provider-ledger.test.mjs +0 -275
  478. package/foundation/integrations/provider-resolution.test.mjs +0 -369
  479. package/foundation/integrations/public-imports.test.mjs +0 -1818
  480. package/foundation/release/cache.test.mjs +0 -923
  481. package/foundation/release/choose.test.mjs +0 -427
  482. package/foundation/release/global-state.test.mjs +0 -381
  483. package/foundation/release/handoff.e2e.test.mjs +0 -278
  484. package/foundation/release/notices.test.mjs +0 -586
  485. package/foundation/release/project.test.mjs +0 -288
  486. package/foundation/render/render.test.mjs +0 -117
  487. package/foundation/response/error-codes.test.mjs +0 -297
  488. package/foundation/response/json-contract.test.mjs +0 -235
  489. package/foundation/response/json-serialize.test.mjs +0 -66
  490. package/foundation/response/response-types.doc.test.mjs +0 -278
  491. package/foundation/route/route.test.mjs +0 -153
  492. package/foundation/runtime/hosted-runtime.test.mjs +0 -403
  493. package/foundation/runtime/package-set.test.mjs +0 -432
  494. package/foundation/text/copyright-header.test.mjs +0 -58
  495. package/foundation/text/levenshtein.test.mjs +0 -53
  496. package/foundation/text/string-utils.test.mjs +0 -175
  497. package/foundation/text/suggest-order.test.mjs +0 -312
  498. package/foundation/xle/browser-imports.test.mjs +0 -74
  499. package/foundation/xle/expand.test.mjs +0 -54
  500. package/foundation/xle/print.test.mjs +0 -50
  501. package/foundation/xle/registry.test.mjs +0 -28
  502. package/foundation/xle/xle.test.mjs +0 -382
  503. package/host/door-conformance.test.mjs +0 -274
  504. package/host/index.test.mjs +0 -302
@@ -1,1549 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- import {spawnSync} from 'node:child_process';
4
- import * as fs from 'node:fs';
5
- import * as os from 'node:os';
6
- import * as path from 'node:path';
7
- import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
8
- import {Project} from '../../foundation/config/project.mjs';
9
- import {
10
- ASK_DESTINATION_MESSAGE,
11
- GAP_REPORT_CATEGORIES,
12
- PUBLIC_CONFIRMATION_MESSAGE,
13
- collectGapReportHandlers,
14
- deliverGapReportHandlers,
15
- gapReport,
16
- } from './gap-report.mjs';
17
-
18
- let projectDir;
19
-
20
- function configure(integrations = [], opts = {}) {
21
- const config = {integrations, ...opts};
22
- fs.writeFileSync(
23
- path.join(projectDir, 'astryx.config.mjs'),
24
- `export default ${JSON.stringify(config)};\n`,
25
- );
26
- }
27
-
28
- function packageDir(packageName) {
29
- return path.join(projectDir, 'node_modules', ...packageName.split('/'));
30
- }
31
-
32
- function addCoreComponent(component = 'Button') {
33
- const coreDir = packageDir('@astryxdesign/core');
34
- const componentDir = path.join(coreDir, 'src', component);
35
- fs.mkdirSync(componentDir, {recursive: true});
36
- fs.writeFileSync(
37
- path.join(coreDir, 'package.json'),
38
- JSON.stringify({name: '@astryxdesign/core', version: '0.5.4'}),
39
- );
40
- fs.writeFileSync(
41
- path.join(componentDir, `${component}.doc.mjs`),
42
- `export default {name: ${JSON.stringify(component)}, usage: {description: 'Core fixture'}, props: []};\n`,
43
- );
44
- fs.writeFileSync(
45
- path.join(componentDir, `${component}.tsx`),
46
- `export const ${component} = null;\n`,
47
- );
48
- }
49
-
50
- /**
51
- * Add an integration with a handler (function-based, not executable).
52
- * @param {object} opts
53
- * @param {string} opts.name
54
- * @param {'internal'|'public'} [opts.audience]
55
- * @param {string} [opts.issuesUrl]
56
- * @param {string} [opts.component]
57
- * @param {boolean} [opts.handler] whether to export a gapReport handler
58
- * @param {string} [opts.handleBody] JS code for the handle function body
59
- * @param {string} [opts.malformedExport] raw JS to export instead of a proper handler
60
- */
61
- function addIntegration({
62
- name,
63
- audience = 'public',
64
- issuesUrl,
65
- component,
66
- handler = true,
67
- handleBody = "return {status: 'filed', message: 'Handled by ' + " +
68
- JSON.stringify(name) +
69
- '};',
70
- malformedExport,
71
- }) {
72
- const dir = packageDir(name);
73
- fs.mkdirSync(dir, {recursive: true});
74
- fs.writeFileSync(
75
- path.join(dir, 'package.json'),
76
- JSON.stringify({name, version: '1.2.3'}),
77
- );
78
-
79
- const manifest = {};
80
- if (issuesUrl) manifest.issuesUrl = issuesUrl;
81
- if (component) {
82
- manifest.components = './components';
83
- const components = path.join(dir, 'components');
84
- fs.mkdirSync(components, {recursive: true});
85
- fs.writeFileSync(
86
- path.join(components, `${component}.doc.mjs`),
87
- `export default {name: ${JSON.stringify(component)}, usage: {description: 'Fixture'}, props: []};\n`,
88
- );
89
- fs.writeFileSync(
90
- path.join(components, `${component}.tsx`),
91
- `export const ${component} = null;\n`,
92
- );
93
- }
94
-
95
- let namedExport = '';
96
- if (malformedExport != null) {
97
- namedExport = malformedExport;
98
- } else if (handler) {
99
- namedExport = `export const gapReport = {\n audience: ${JSON.stringify(audience)},\n handle: async (report, {signal}) => { ${handleBody} },\n};\n`;
100
- }
101
-
102
- fs.writeFileSync(
103
- path.join(dir, 'astryx.integration.mjs'),
104
- `${namedExport}export default ${JSON.stringify(manifest)};\n`,
105
- );
106
- return {dir};
107
- }
108
-
109
- /**
110
- * Add an integration whose module throws on import, so it never loads.
111
- * @param {string} name
112
- */
113
- function addBrokenIntegration(name) {
114
- const dir = packageDir(name);
115
- fs.mkdirSync(dir, {recursive: true});
116
- fs.writeFileSync(
117
- path.join(dir, 'package.json'),
118
- JSON.stringify({name, version: '1.0.0', type: 'module'}),
119
- );
120
- fs.writeFileSync(
121
- path.join(dir, 'astryx.integration.mjs'),
122
- "throw new Error('intentional integration load failure');\n",
123
- );
124
- }
125
-
126
- /**
127
- * Put a fake `gh` first on PATH that records its arguments if it is called.
128
- * @returns {string} the file the fake writes when invoked
129
- */
130
- function stubGh() {
131
- const binDir = path.join(projectDir, 'bin');
132
- const argsFile = path.join(projectDir, 'gh-args.json');
133
- fs.mkdirSync(binDir, {recursive: true});
134
- fs.writeFileSync(
135
- path.join(binDir, 'gh'),
136
- `#!/usr/bin/env node
137
- import fs from 'node:fs';
138
- fs.writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));
139
- console.log('https://github.com/acme/core/issues/42');
140
- `,
141
- {mode: 0o755},
142
- );
143
- fs.chmodSync(path.join(binDir, 'gh'), 0o755);
144
- vi.stubEnv('PATH', `${binDir}${path.delimiter}${process.env.PATH ?? ''}`);
145
- return argsFile;
146
- }
147
-
148
- const reportOptions = {
149
- category: 'missing_variant',
150
- reason: 'Need a compact size',
151
- detail: 'The current size does not fit the toolbar.',
152
- };
153
-
154
- beforeEach(() => {
155
- projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-report-'));
156
- fs.writeFileSync(
157
- path.join(projectDir, 'package.json'),
158
- JSON.stringify({name: 'fixture-app'}),
159
- );
160
- configure();
161
- });
162
-
163
- afterEach(() => {
164
- vi.unstubAllEnvs();
165
- fs.rmSync(projectDir, {recursive: true, force: true});
166
- });
167
-
168
- describe('gapReport categories and validation', () => {
169
- it('preserves the legacy category vocabulary', async () => {
170
- const result = await gapReport(undefined, {listCategories: true});
171
- expect(result).toEqual({
172
- type: 'gap-report.categories',
173
- data: GAP_REPORT_CATEGORIES,
174
- });
175
- expect(result.data.map(item => item.value)).toEqual([
176
- 'missing_component',
177
- 'missing_variant',
178
- 'layout_gap',
179
- 'styling_gap',
180
- 'a11y_gap',
181
- 'api_friction',
182
- 'docs_gap',
183
- 'other',
184
- ]);
185
- });
186
-
187
- it('rejects missing, unknown, and oversized report fields', async () => {
188
- await expect(
189
- gapReport(undefined, {...reportOptions, cwd: projectDir}),
190
- ).rejects.toMatchObject({code: 'ERR_MISSING_ARGUMENT'});
191
- await expect(
192
- gapReport('Button', {
193
- ...reportOptions,
194
- category: 'not_real',
195
- cwd: projectDir,
196
- }),
197
- ).rejects.toMatchObject({code: 'ERR_UNKNOWN_CATEGORY'});
198
- await expect(
199
- gapReport('Button', {
200
- ...reportOptions,
201
- detail: 'x'.repeat(8001),
202
- cwd: projectDir,
203
- }),
204
- ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
205
- });
206
- });
207
-
208
- describe('gapReport fan-out composition', () => {
209
- it('project handler and integration handler both run in order', async () => {
210
- const name = '@test/integration-one';
211
- addIntegration({
212
- name,
213
- audience: 'internal',
214
- handleBody: "return {status: 'filed', message: 'from integration'};",
215
- });
216
-
217
- // Write config with project handler + integration
218
- fs.writeFileSync(
219
- path.join(projectDir, 'astryx.config.mjs'),
220
- `
221
- export default {
222
- integrations: [${JSON.stringify(name)}],
223
- gapReport: {
224
- audience: 'internal',
225
- handle: (report) => ({status: 'filed', message: 'from project'}),
226
- },
227
- };
228
- `,
229
- );
230
-
231
- const result = await gapReport('General', {
232
- ...reportOptions,
233
- cwd: projectDir,
234
- });
235
-
236
- expect(result.data.status).toBe('filed');
237
- expect(result.data.deliveries).toHaveLength(2);
238
- expect(
239
- result.data.deliveries.map(({handlerType, handler, audience}) => ({
240
- handlerType,
241
- handler,
242
- audience,
243
- })),
244
- ).toEqual([
245
- {handlerType: 'project', handler: 'project', audience: 'internal'},
246
- {
247
- handlerType: 'integration',
248
- handler: name,
249
- audience: 'internal',
250
- },
251
- ]);
252
- expect(result.data.deliveries[0].message).toBe('from project');
253
- expect(result.data.deliveries[1].message).toBe('from integration');
254
- expect(result.data.filedCount).toBe(2);
255
- });
256
-
257
- it('runs the self-resolved local package handler', async () => {
258
- fs.writeFileSync(
259
- path.join(projectDir, 'package.json'),
260
- JSON.stringify({name: '@test/local', version: '1.0.0'}),
261
- );
262
- fs.writeFileSync(
263
- path.join(projectDir, 'astryx.integration.mjs'),
264
- `export const gapReport = {
265
- audience: 'internal',
266
- handle(report) { return {status: 'filed', message: report.component}; },
267
- };
268
- export default {};
269
- `,
270
- );
271
-
272
- const result = await gapReport('General', {
273
- ...reportOptions,
274
- cwd: projectDir,
275
- });
276
-
277
- expect(result.data.deliveries).toEqual([
278
- expect.objectContaining({
279
- handlerType: 'integration',
280
- handler: '@test/local',
281
- audience: 'internal',
282
- status: 'filed',
283
- message: 'General',
284
- }),
285
- ]);
286
- });
287
-
288
- it('all integration handlers run in config order', async () => {
289
- addIntegration({
290
- name: '@test/first',
291
- audience: 'internal',
292
- handleBody: "return {status: 'filed', message: 'first'};",
293
- });
294
- addIntegration({
295
- name: '@test/second',
296
- audience: 'internal',
297
- handleBody: "return {status: 'filed', message: 'second'};",
298
- });
299
- addIntegration({
300
- name: '@test/third',
301
- audience: 'internal',
302
- handleBody: "return {status: 'filed', message: 'third'};",
303
- });
304
- configure(['@test/first', '@test/second', '@test/third']);
305
-
306
- const result = await gapReport('General', {
307
- ...reportOptions,
308
- cwd: projectDir,
309
- });
310
-
311
- expect(result.data.deliveries).toHaveLength(3);
312
- expect(result.data.deliveries.map(d => d.handler)).toEqual([
313
- '@test/first',
314
- '@test/second',
315
- '@test/third',
316
- ]);
317
- expect(result.data.deliveries.map(d => d.message)).toEqual([
318
- 'first',
319
- 'second',
320
- 'third',
321
- ]);
322
- expect(result.data.filedCount).toBe(3);
323
- expect(result.data.status).toBe('filed');
324
- });
325
-
326
- it('deduplicates handlers by handle function identity', async () => {
327
- // Create two integrations that share the same handle function
328
- const sharedDir = path.join(projectDir, 'shared-handler');
329
- fs.mkdirSync(sharedDir, {recursive: true});
330
- fs.writeFileSync(
331
- path.join(sharedDir, 'handler.mjs'),
332
- "export const handle = async (report) => ({status: 'filed', message: 'shared'});\n",
333
- );
334
-
335
- const dir1 = packageDir('@test/first');
336
- fs.mkdirSync(dir1, {recursive: true});
337
- fs.writeFileSync(
338
- path.join(dir1, 'package.json'),
339
- JSON.stringify({name: '@test/first', version: '1.0.0'}),
340
- );
341
- fs.writeFileSync(
342
- path.join(dir1, 'astryx.integration.mjs'),
343
- `import {handle} from ${JSON.stringify(path.join(sharedDir, 'handler.mjs'))};\nexport const gapReport = {audience: 'internal', handle};\nexport default {};\n`,
344
- );
345
-
346
- const dir2 = packageDir('@test/second');
347
- fs.mkdirSync(dir2, {recursive: true});
348
- fs.writeFileSync(
349
- path.join(dir2, 'package.json'),
350
- JSON.stringify({name: '@test/second', version: '1.0.0'}),
351
- );
352
- fs.writeFileSync(
353
- path.join(dir2, 'astryx.integration.mjs'),
354
- `import {handle} from ${JSON.stringify(path.join(sharedDir, 'handler.mjs'))};\nexport const gapReport = {audience: 'internal', handle};\nexport default {};\n`,
355
- );
356
-
357
- configure(['@test/first', '@test/second']);
358
-
359
- const result = await gapReport('General', {
360
- ...reportOptions,
361
- cwd: projectDir,
362
- });
363
-
364
- expect(result.data.deliveries).toHaveLength(1);
365
- expect(result.data.deliveries[0].message).toBe('shared');
366
- });
367
-
368
- it('deduplicates the same handle across project and integration', () => {
369
- const handle = async () => ({status: 'filed', message: 'shared'});
370
- const entries = collectGapReportHandlers(
371
- /** @type {any} */ ({
372
- config: {gapReport: {audience: 'internal', handle}},
373
- configPath: '/tmp/astryx.config.mjs',
374
- loadedIntegrations: [
375
- {
376
- name: '@test/shared',
377
- __manifestFile: '/tmp/astryx.integration.mjs',
378
- __gapReport: {audience: 'internal', handle},
379
- },
380
- ],
381
- }),
382
- );
383
-
384
- expect(entries).toHaveLength(1);
385
- expect(entries[0]).toMatchObject({
386
- kind: 'handler',
387
- handlerType: 'project',
388
- handlerName: 'project',
389
- });
390
- });
391
-
392
- it('each handler receives a fresh structuredClone', async () => {
393
- addIntegration({
394
- name: '@test/mutator',
395
- audience: 'internal',
396
- handleBody:
397
- "report.component = 'MUTATED'; return {status: 'filed', message: report.component};",
398
- });
399
- addIntegration({
400
- name: '@test/reader',
401
- audience: 'internal',
402
- handleBody: "return {status: 'filed', message: report.component};",
403
- });
404
- configure(['@test/mutator', '@test/reader']);
405
-
406
- const result = await gapReport('General', {
407
- ...reportOptions,
408
- cwd: projectDir,
409
- });
410
-
411
- expect(result.data.deliveries).toHaveLength(2);
412
- expect(result.data.deliveries[0].message).toBe('MUTATED');
413
- expect(result.data.deliveries[1].message).toBe('General');
414
- });
415
-
416
- it('repeated Project.load does not duplicate handlers', async () => {
417
- addIntegration({
418
- name: '@test/only',
419
- audience: 'internal',
420
- handleBody: "return {status: 'filed', message: 'once'};",
421
- });
422
- configure(['@test/only']);
423
-
424
- // Call twice — second load should not add duplicates
425
- const result1 = await gapReport('General', {
426
- ...reportOptions,
427
- cwd: projectDir,
428
- });
429
- const result2 = await gapReport('General', {
430
- ...reportOptions,
431
- cwd: projectDir,
432
- });
433
-
434
- expect(result1.data.deliveries).toHaveLength(1);
435
- expect(result2.data.deliveries).toHaveLength(1);
436
- });
437
-
438
- it('does not treat inheritDebug as a gap-report opt-out', async () => {
439
- fs.writeFileSync(
440
- path.join(projectDir, 'package.json'),
441
- JSON.stringify({name: 'fixture-app', astryx: {inheritDebug: false}}),
442
- );
443
- addIntegration({
444
- name: '@test/always',
445
- audience: 'internal',
446
- handleBody: "return {status: 'filed', message: 'still ran'};",
447
- });
448
- configure(['@test/always']);
449
-
450
- const result = await gapReport('General', {
451
- ...reportOptions,
452
- cwd: projectDir,
453
- });
454
-
455
- expect(result.data.deliveries).toHaveLength(1);
456
- expect(result.data.deliveries[0]).toMatchObject({
457
- handler: '@test/always',
458
- status: 'filed',
459
- });
460
- });
461
- });
462
-
463
- describe('gapReport handler isolation', () => {
464
- it('terminates one timed-out handler and then runs the next handler', async () => {
465
- addIntegration({
466
- name: '@test/slow',
467
- audience: 'internal',
468
- handleBody: 'return new Promise(() => {});',
469
- });
470
- addIntegration({
471
- name: '@test/after',
472
- audience: 'internal',
473
- handleBody: "return {status: 'filed', message: 'after'};",
474
- });
475
- configure(['@test/slow', '@test/after']);
476
- const project = await Project.load(projectDir);
477
-
478
- const deliveries = await deliverGapReportHandlers(
479
- collectGapReportHandlers(project),
480
- /** @type {any} */ ({component: 'Button'}),
481
- {timeoutMs: 200},
482
- );
483
-
484
- expect(deliveries).toEqual([
485
- {
486
- handlerType: 'integration',
487
- handler: '@test/slow',
488
- audience: 'internal',
489
- status: 'failed',
490
- url: null,
491
- message: 'Gap report handler timed out.',
492
- },
493
- {
494
- handlerType: 'integration',
495
- handler: '@test/after',
496
- audience: 'internal',
497
- status: 'filed',
498
- url: null,
499
- message: 'after',
500
- },
501
- ]);
502
- });
503
-
504
- it('a timed-out late process.exit cannot terminate the caller', () => {
505
- addIntegration({
506
- name: '@test/late-exit',
507
- audience: 'internal',
508
- handleBody:
509
- 'await new Promise(resolve => setTimeout(resolve, 210)); process.exit(42);',
510
- });
511
- addIntegration({
512
- name: '@test/after-late-exit',
513
- audience: 'internal',
514
- handleBody: "return {status: 'filed', message: 'survived'};",
515
- });
516
- configure(['@test/late-exit', '@test/after-late-exit']);
517
-
518
- const projectModule = path.resolve(
519
- import.meta.dirname,
520
- '../../foundation/config/project.mjs',
521
- );
522
- const gapModule = path.resolve(import.meta.dirname, 'gap-report.mjs');
523
- const source = `
524
- const {Project} = await import(${JSON.stringify(projectModule)});
525
- const {collectGapReportHandlers, deliverGapReportHandlers} = await import(${JSON.stringify(gapModule)});
526
- const project = await Project.load(${JSON.stringify(projectDir)});
527
- const deliveries = await deliverGapReportHandlers(
528
- collectGapReportHandlers(project),
529
- {component: 'Button'},
530
- {timeoutMs: 200},
531
- );
532
- await new Promise(resolve => setTimeout(resolve, 300));
533
- process.stdout.write(JSON.stringify(deliveries));
534
- `;
535
- const child = spawnSync(
536
- process.execPath,
537
- ['--input-type=module', '-e', source],
538
- {encoding: 'utf8', timeout: 5000},
539
- );
540
-
541
- expect(child.status, child.stderr).toBe(0);
542
- expect(JSON.parse(child.stdout)).toMatchObject([
543
- {handler: '@test/late-exit', status: 'failed'},
544
- {handler: '@test/after-late-exit', status: 'filed'},
545
- ]);
546
- });
547
-
548
- it('redirects handler stdout and restores the parent stream method', async () => {
549
- fs.writeFileSync(
550
- path.join(projectDir, 'astryx.config.mjs'),
551
- `export default {
552
- gapReport: {
553
- audience: 'internal',
554
- handle() {
555
- process.stdout.write('handler-noise');
556
- return {status: 'skipped'};
557
- },
558
- },
559
- };\n`,
560
- );
561
- const project = await Project.load(projectDir);
562
- const stderrWrite = vi
563
- .spyOn(process.stderr, 'write')
564
- .mockImplementation(() => true);
565
- const stdoutBefore = process.stdout.write;
566
- try {
567
- const deliveries = await deliverGapReportHandlers(
568
- collectGapReportHandlers(project),
569
- /** @type {any} */ ({component: 'Button'}),
570
- );
571
-
572
- expect(deliveries[0].status).toBe('skipped');
573
- expect(
574
- stderrWrite.mock.calls.map(call => String(call[0])).join(''),
575
- ).toContain('handler-noise');
576
- expect(process.stdout.write).toBe(stdoutBefore);
577
- } finally {
578
- stderrWrite.mockRestore();
579
- }
580
- });
581
-
582
- it('later handlers run after one throws', async () => {
583
- addIntegration({
584
- name: '@test/thrower',
585
- audience: 'internal',
586
- handleBody: "throw new Error('handler exploded');",
587
- });
588
- addIntegration({
589
- name: '@test/survivor',
590
- audience: 'internal',
591
- handleBody: "return {status: 'filed', message: 'survived'};",
592
- });
593
- configure(['@test/thrower', '@test/survivor']);
594
-
595
- const result = await gapReport('General', {
596
- ...reportOptions,
597
- cwd: projectDir,
598
- });
599
-
600
- expect(result.data.deliveries).toHaveLength(2);
601
- expect(result.data.deliveries[0].status).toBe('failed');
602
- expect(result.data.deliveries[0].message).toContain('handler exploded');
603
- expect(result.data.deliveries[1].status).toBe('filed');
604
- expect(result.data.deliveries[1].message).toBe('survived');
605
- expect(result.data.status).toBe('partial');
606
- });
607
-
608
- it('later handlers run after one tries process.exit', async () => {
609
- addIntegration({
610
- name: '@test/exiter',
611
- audience: 'internal',
612
- handleBody: 'process.exit(42);',
613
- });
614
- addIntegration({
615
- name: '@test/survivor',
616
- audience: 'internal',
617
- handleBody: "return {status: 'filed', message: 'still here'};",
618
- });
619
- configure(['@test/exiter', '@test/survivor']);
620
-
621
- const result = await gapReport('General', {
622
- ...reportOptions,
623
- cwd: projectDir,
624
- });
625
-
626
- expect(result.data.deliveries).toHaveLength(2);
627
- expect(result.data.deliveries[0].status).toBe('failed');
628
- expect(result.data.deliveries[0].message).toContain('process.exit');
629
- expect(result.data.deliveries[1].status).toBe('filed');
630
- expect(result.data.filedCount).toBe(1);
631
- });
632
-
633
- it('later handlers run after one changes process.exitCode', async () => {
634
- addIntegration({
635
- name: '@test/exit-code',
636
- audience: 'internal',
637
- handleBody:
638
- "process.exitCode = 42; return {status: 'filed', message: 'wrong'};",
639
- });
640
- addIntegration({
641
- name: '@test/survivor',
642
- audience: 'internal',
643
- handleBody: "return {status: 'filed', message: 'still here'};",
644
- });
645
- configure(['@test/exit-code', '@test/survivor']);
646
- const before = process.exitCode;
647
-
648
- const result = await gapReport('General', {
649
- ...reportOptions,
650
- cwd: projectDir,
651
- });
652
-
653
- expect(process.exitCode).toBe(before);
654
- expect(result.data.deliveries[0]).toMatchObject({
655
- handler: '@test/exit-code',
656
- status: 'failed',
657
- message: 'Handler changed process.exitCode.',
658
- });
659
- expect(result.data.deliveries[1]).toMatchObject({
660
- handler: '@test/survivor',
661
- status: 'filed',
662
- });
663
- });
664
-
665
- it('handler that returns non-receipt is a failed delivery', async () => {
666
- addIntegration({
667
- name: '@test/non-receipt',
668
- audience: 'internal',
669
- handleBody: "return 'not an object';",
670
- });
671
- addIntegration({
672
- name: '@test/after',
673
- audience: 'internal',
674
- handleBody: "return {status: 'filed', message: 'still ok'};",
675
- });
676
- configure(['@test/non-receipt', '@test/after']);
677
-
678
- const result = await gapReport('General', {
679
- ...reportOptions,
680
- cwd: projectDir,
681
- });
682
-
683
- expect(result.data.deliveries).toHaveLength(2);
684
- expect(result.data.deliveries[0].status).toBe('failed');
685
- expect(result.data.deliveries[1].status).toBe('filed');
686
- });
687
-
688
- it('malformed integration handler is isolated as a failed delivery', async () => {
689
- const dir = packageDir('@test/malformed');
690
- fs.mkdirSync(dir, {recursive: true});
691
- fs.writeFileSync(
692
- path.join(dir, 'package.json'),
693
- JSON.stringify({name: '@test/malformed', version: '1.0.0'}),
694
- );
695
- fs.writeFileSync(
696
- path.join(dir, 'astryx.integration.mjs'),
697
- "export const gapReport = {audience: 'internal', command: './writer.mjs'};\nexport default {};\n",
698
- );
699
-
700
- addIntegration({
701
- name: '@test/valid',
702
- audience: 'internal',
703
- handleBody: "return {status: 'filed', message: 'ok'};",
704
- });
705
- configure(['@test/malformed', '@test/valid']);
706
-
707
- const result = await gapReport('General', {
708
- ...reportOptions,
709
- cwd: projectDir,
710
- });
711
-
712
- expect(result.data.deliveries).toHaveLength(2);
713
- expect(result.data.deliveries.map(d => d.handler)).toEqual([
714
- '@test/malformed',
715
- '@test/valid',
716
- ]);
717
- expect(result.data.deliveries[0].status).toBe('failed');
718
- expect(result.data.deliveries[1]).toMatchObject({
719
- status: 'filed',
720
- message: 'ok',
721
- });
722
- });
723
-
724
- it('an integration that fails to load is a failed delivery, not a missing handler', async () => {
725
- addBrokenIntegration('@test/broken');
726
- configure(['@test/broken'], {
727
- issuesUrl: 'https://github.com/acme/core/issues/new',
728
- });
729
-
730
- const result = await gapReport('General', {
731
- ...reportOptions,
732
- cwd: projectDir,
733
- });
734
-
735
- expect(result.data.status).toBe('failed');
736
- expect(result.data.deliveries).toEqual([
737
- {
738
- handlerType: 'integration',
739
- handler: '@test/broken',
740
- audience: null,
741
- status: 'failed',
742
- url: null,
743
- message: expect.stringContaining(
744
- 'intentional integration load failure',
745
- ),
746
- },
747
- ]);
748
- });
749
-
750
- it('an integration that fails to load keeps the public fallback off, even with consent', async () => {
751
- addBrokenIntegration('@test/broken');
752
- configure(['@test/broken'], {
753
- issuesUrl: 'https://github.com/acme/core/issues/new',
754
- });
755
- const argsFile = stubGh();
756
-
757
- const result = await gapReport('General', {
758
- ...reportOptions,
759
- confirmPublic: true,
760
- cwd: projectDir,
761
- });
762
-
763
- expect(result.data.status).toBe('failed');
764
- expect(result.data.deliveries.map(d => d.handlerType)).toEqual([
765
- 'integration',
766
- ]);
767
- expect(fs.existsSync(argsFile)).toBe(false);
768
- });
769
-
770
- it('an integration that fails to load keeps its place beside working handlers', async () => {
771
- addBrokenIntegration('@test/broken');
772
- addIntegration({
773
- name: '@test/valid',
774
- audience: 'internal',
775
- handleBody: "return {status: 'filed', message: 'ok'};",
776
- });
777
- configure(['@test/broken', '@test/valid']);
778
-
779
- const result = await gapReport('General', {
780
- ...reportOptions,
781
- cwd: projectDir,
782
- });
783
-
784
- expect(result.data.status).toBe('partial');
785
- expect(result.data.deliveries.map(d => [d.handler, d.status])).toEqual([
786
- ['@test/broken', 'failed'],
787
- ['@test/valid', 'filed'],
788
- ]);
789
- });
790
-
791
- it('invalid handler receipt is recorded as failed delivery', async () => {
792
- addIntegration({
793
- name: '@test/bad-receipt',
794
- audience: 'internal',
795
- handleBody: "return {status: 'invalid_status'};",
796
- });
797
- addIntegration({
798
- name: '@test/good',
799
- audience: 'internal',
800
- handleBody: "return {status: 'filed', message: 'good'};",
801
- });
802
- configure(['@test/bad-receipt', '@test/good']);
803
-
804
- const result = await gapReport('General', {
805
- ...reportOptions,
806
- cwd: projectDir,
807
- });
808
-
809
- expect(result.data.deliveries).toHaveLength(2);
810
- expect(result.data.deliveries[0].status).toBe('failed');
811
- expect(result.data.deliveries[0].message).toContain('invalid receipt');
812
- expect(result.data.deliveries[1].status).toBe('filed');
813
- });
814
- });
815
-
816
- describe('gapReport per-handler consent', () => {
817
- it('gates a public project handler until consent is explicit', async () => {
818
- const marker = path.join(projectDir, 'project-handler-ran');
819
- fs.writeFileSync(
820
- path.join(projectDir, 'astryx.config.mjs'),
821
- `import * as fs from 'node:fs';
822
- export default {
823
- gapReport: {
824
- audience: 'public',
825
- handle() {
826
- fs.writeFileSync(${JSON.stringify(marker)}, 'yes');
827
- return {status: 'filed', message: 'project filed'};
828
- },
829
- },
830
- };\n`,
831
- );
832
-
833
- const pending = await gapReport('General', {
834
- ...reportOptions,
835
- cwd: projectDir,
836
- });
837
- expect(pending.data.deliveries[0]).toMatchObject({
838
- handlerType: 'project',
839
- handler: 'project',
840
- audience: 'public',
841
- status: 'consent_required',
842
- });
843
- expect(fs.existsSync(marker)).toBe(false);
844
-
845
- const filed = await gapReport('General', {
846
- ...reportOptions,
847
- confirmPublic: true,
848
- cwd: projectDir,
849
- });
850
- expect(filed.data.deliveries[0]).toMatchObject({
851
- handlerType: 'project',
852
- handler: 'project',
853
- audience: 'public',
854
- status: 'filed',
855
- });
856
- expect(fs.readFileSync(marker, 'utf8')).toBe('yes');
857
- });
858
-
859
- it('public handler is skipped while internal handler runs', async () => {
860
- addIntegration({
861
- name: '@test/public-one',
862
- audience: 'public',
863
- handleBody: "return {status: 'filed', message: 'public filed'};",
864
- });
865
- addIntegration({
866
- name: '@test/internal-one',
867
- audience: 'internal',
868
- handleBody: "return {status: 'filed', message: 'internal filed'};",
869
- });
870
- configure(['@test/public-one', '@test/internal-one']);
871
-
872
- const result = await gapReport('General', {
873
- ...reportOptions,
874
- cwd: projectDir,
875
- });
876
-
877
- expect(result.data.deliveries).toHaveLength(2);
878
- expect(result.data.deliveries[0].status).toBe('consent_required');
879
- expect(result.data.deliveries[0].message).toBe(PUBLIC_CONFIRMATION_MESSAGE);
880
- expect(result.data.deliveries[1].status).toBe('filed');
881
- expect(result.data.deliveries[1].message).toBe('internal filed');
882
- expect(result.data.filedCount).toBe(1);
883
- });
884
-
885
- it('multiple internal handlers all run without consent', async () => {
886
- addIntegration({
887
- name: '@test/internal-a',
888
- audience: 'internal',
889
- handleBody: "return {status: 'filed', message: 'a'};",
890
- });
891
- addIntegration({
892
- name: '@test/internal-b',
893
- audience: 'internal',
894
- handleBody: "return {status: 'filed', message: 'b'};",
895
- });
896
- configure(['@test/internal-a', '@test/internal-b']);
897
-
898
- const result = await gapReport('General', {
899
- ...reportOptions,
900
- cwd: projectDir,
901
- });
902
-
903
- expect(result.data.deliveries).toHaveLength(2);
904
- expect(result.data.deliveries.every(d => d.status === 'filed')).toBe(true);
905
- expect(result.data.filedCount).toBe(2);
906
- expect(result.data.status).toBe('filed');
907
- });
908
-
909
- it('public handler runs when confirmPublic is true', async () => {
910
- addIntegration({
911
- name: '@test/public-ok',
912
- audience: 'public',
913
- handleBody: "return {status: 'filed', message: 'public worked'};",
914
- });
915
- configure(['@test/public-ok']);
916
-
917
- const result = await gapReport('General', {
918
- ...reportOptions,
919
- confirmPublic: true,
920
- cwd: projectDir,
921
- });
922
-
923
- expect(result.data.deliveries).toHaveLength(1);
924
- expect(result.data.deliveries[0].status).toBe('filed');
925
- expect(result.data.deliveries[0].message).toBe('public worked');
926
- });
927
- });
928
-
929
- describe('gapReport fallback behavior', () => {
930
- it('handlers suppress the built-in fallback', async () => {
931
- addIntegration({
932
- name: '@test/has-handler',
933
- audience: 'internal',
934
- issuesUrl: 'https://github.com/acme/widgets/issues',
935
- handleBody: "return {status: 'filed', message: 'handler took it'};",
936
- });
937
- configure(['@test/has-handler'], {
938
- issuesUrl: 'https://github.com/acme/core/issues',
939
- });
940
-
941
- const result = await gapReport('General', {
942
- ...reportOptions,
943
- cwd: projectDir,
944
- });
945
-
946
- // Should use handler, not GitHub fallback
947
- expect(result.data.deliveries).toHaveLength(1);
948
- expect(result.data.deliveries[0].message).toBe('handler took it');
949
- });
950
-
951
- it('no-handler GitHub consent-gated fallback works', async () => {
952
- configure([], {issuesUrl: 'https://github.com/acme/widgets/issues/new'});
953
- const binDir = path.join(projectDir, 'bin');
954
- const argsFile = path.join(projectDir, 'gh-args.json');
955
- fs.mkdirSync(binDir, {recursive: true});
956
- fs.writeFileSync(
957
- path.join(binDir, 'gh'),
958
- `#!/usr/bin/env node
959
- import fs from 'node:fs';
960
- fs.writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));
961
- console.log('https://github.com/acme/widgets/issues/42');
962
- `,
963
- {mode: 0o755},
964
- );
965
- fs.chmodSync(path.join(binDir, 'gh'), 0o755);
966
- vi.stubEnv('PATH', `${binDir}${path.delimiter}${process.env.PATH ?? ''}`);
967
-
968
- // Without consent
969
- const pending = await gapReport('Button', {
970
- ...reportOptions,
971
- cwd: projectDir,
972
- });
973
- expect(pending.data.deliveries[0].status).toBe('consent_required');
974
- expect(fs.existsSync(argsFile)).toBe(false);
975
-
976
- // With consent
977
- const filed = await gapReport('Button', {
978
- ...reportOptions,
979
- confirmPublic: true,
980
- cwd: projectDir,
981
- });
982
- expect(filed.data.deliveries[0].status).toBe('filed');
983
- expect(filed.data.status).toBe('filed');
984
- });
985
-
986
- it('no-handler non-GitHub route returns routed_only', async () => {
987
- configure([], {issuesUrl: 'https://tracker.example/new'});
988
-
989
- const result = await gapReport('Button', {
990
- ...reportOptions,
991
- confirmPublic: true,
992
- cwd: projectDir,
993
- });
994
-
995
- expect(result.data.deliveries[0].status).toBe('routed_only');
996
- expect(result.data.deliveries[0].url).toBe('https://tracker.example/new');
997
- expect(result.data.status).toBe('routed_only');
998
- });
999
-
1000
- it('no handler and no issues URL throws ERR_NOT_FOUND', async () => {
1001
- // Create a project with an integration that has no handler, no issuesUrl,
1002
- // and target an unknown package explicitly
1003
- const name = '@test/bare';
1004
- const dir = packageDir(name);
1005
- fs.mkdirSync(dir, {recursive: true});
1006
- fs.writeFileSync(
1007
- path.join(dir, 'package.json'),
1008
- JSON.stringify({name, version: '1.0.0'}),
1009
- );
1010
- fs.writeFileSync(
1011
- path.join(dir, 'astryx.integration.mjs'),
1012
- 'export default {};\n',
1013
- );
1014
- configure([name]);
1015
-
1016
- await expect(
1017
- gapReport('Button', {
1018
- ...reportOptions,
1019
- package: name,
1020
- cwd: projectDir,
1021
- }),
1022
- ).rejects.toMatchObject({code: 'ERR_NOT_FOUND'});
1023
- });
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
-
1258
- describe('gapReport target selection', () => {
1259
- it('routes to the unique component owner', async () => {
1260
- addIntegration({
1261
- name: '@test/owner',
1262
- audience: 'internal',
1263
- component: 'TargetWidget',
1264
- handleBody: "return {status: 'filed', message: report.target.package};",
1265
- });
1266
- configure(['@test/owner']);
1267
-
1268
- const result = await gapReport('XDSTargetWidget', {
1269
- ...reportOptions,
1270
- cwd: projectDir,
1271
- });
1272
-
1273
- expect(result.data.package).toBe('@test/owner');
1274
- expect(result.data.deliveries[0].message).toBe('@test/owner');
1275
- });
1276
-
1277
- it('uses explicit package', async () => {
1278
- addIntegration({
1279
- name: '@test/first',
1280
- audience: 'internal',
1281
- handleBody: "return {status: 'filed', message: 'first'};",
1282
- });
1283
- addIntegration({
1284
- name: '@test/second',
1285
- audience: 'internal',
1286
- handleBody: "return {status: 'filed', message: 'second'};",
1287
- });
1288
- configure(['@test/first', '@test/second']);
1289
-
1290
- const result = await gapReport('General', {
1291
- ...reportOptions,
1292
- package: '@test/second',
1293
- cwd: projectDir,
1294
- });
1295
-
1296
- expect(result.data.package).toBe('@test/second');
1297
- // Both handlers still run (fan-out)
1298
- expect(result.data.deliveries).toHaveLength(2);
1299
- });
1300
-
1301
- it('falls back to Core when no component owner found', async () => {
1302
- addIntegration({
1303
- name: '@test/no-match',
1304
- audience: 'internal',
1305
- handleBody: "return {status: 'filed', message: report.target.package};",
1306
- });
1307
- configure(['@test/no-match']);
1308
-
1309
- const result = await gapReport('General', {
1310
- ...reportOptions,
1311
- cwd: projectDir,
1312
- });
1313
-
1314
- expect(result.data.package).toBe('@astryxdesign/core');
1315
- });
1316
-
1317
- it('requires --package when multiple packages own the component', async () => {
1318
- addIntegration({
1319
- name: '@test/first',
1320
- component: 'SharedWidget',
1321
- audience: 'internal',
1322
- });
1323
- addIntegration({
1324
- name: '@test/second',
1325
- component: 'SharedWidget',
1326
- audience: 'internal',
1327
- });
1328
- configure(['@test/first', '@test/second']);
1329
-
1330
- await expect(
1331
- gapReport('SharedWidget', {...reportOptions, cwd: projectDir}),
1332
- ).rejects.toMatchObject({code: 'ERR_AMBIGUOUS_COMPONENT'});
1333
- });
1334
- });
1335
-
1336
- describe('gapReport aggregate status and CLI exit', () => {
1337
- it('all filed → status filed', async () => {
1338
- addIntegration({
1339
- name: '@test/a',
1340
- audience: 'internal',
1341
- handleBody: "return {status: 'filed', message: 'a'};",
1342
- });
1343
- configure(['@test/a']);
1344
-
1345
- const result = await gapReport('General', {
1346
- ...reportOptions,
1347
- cwd: projectDir,
1348
- });
1349
- expect(result.data.status).toBe('filed');
1350
- });
1351
-
1352
- it('mix of filed and failed → status partial', async () => {
1353
- addIntegration({
1354
- name: '@test/fail',
1355
- audience: 'internal',
1356
- handleBody: "throw new Error('boom');",
1357
- });
1358
- addIntegration({
1359
- name: '@test/ok',
1360
- audience: 'internal',
1361
- handleBody: "return {status: 'filed', message: 'ok'};",
1362
- });
1363
- configure(['@test/fail', '@test/ok']);
1364
-
1365
- const result = await gapReport('General', {
1366
- ...reportOptions,
1367
- cwd: projectDir,
1368
- });
1369
- expect(result.data.status).toBe('partial');
1370
- });
1371
-
1372
- it('mix of failed and consent-required → status partial', async () => {
1373
- addIntegration({
1374
- name: '@test/fail',
1375
- audience: 'internal',
1376
- handleBody: "throw new Error('boom');",
1377
- });
1378
- addIntegration({
1379
- name: '@test/public',
1380
- audience: 'public',
1381
- handleBody: "return {status: 'filed', message: 'public'};",
1382
- });
1383
- configure(['@test/fail', '@test/public']);
1384
-
1385
- const result = await gapReport('General', {
1386
- ...reportOptions,
1387
- cwd: projectDir,
1388
- });
1389
-
1390
- expect(result.data.status).toBe('partial');
1391
- expect(result.data.deliveries.map(d => d.status)).toEqual([
1392
- 'failed',
1393
- 'consent_required',
1394
- ]);
1395
- });
1396
-
1397
- it('all failed → status failed', async () => {
1398
- addIntegration({
1399
- name: '@test/fail1',
1400
- audience: 'internal',
1401
- handleBody: "throw new Error('boom');",
1402
- });
1403
- configure(['@test/fail1']);
1404
-
1405
- const result = await gapReport('General', {
1406
- ...reportOptions,
1407
- cwd: projectDir,
1408
- });
1409
- expect(result.data.status).toBe('failed');
1410
- });
1411
-
1412
- it('report event shape is plain camelCase with no internal context', async () => {
1413
- addIntegration({
1414
- name: '@test/inspector',
1415
- audience: 'internal',
1416
- handleBody: `
1417
- const keys = Object.keys(report).sort();
1418
- const targetKeys = Object.keys(report.target).sort();
1419
- return {
1420
- status: 'filed',
1421
- message: JSON.stringify({
1422
- keys,
1423
- targetKeys,
1424
- source: report.source,
1425
- sv: report.schemaVersion,
1426
- }),
1427
- };
1428
- `,
1429
- });
1430
- configure(['@test/inspector']);
1431
- vi.stubEnv('AGENT', 'secret-agent');
1432
-
1433
- const result = await gapReport('Button', {
1434
- ...reportOptions,
1435
- cwd: projectDir,
1436
- });
1437
-
1438
- const info = JSON.parse(result.data.deliveries[0].message);
1439
- expect(info.sv).toBe(1);
1440
- expect(info.source).toBe('ai');
1441
- expect(info.keys).toEqual([
1442
- 'category',
1443
- 'categoryLabel',
1444
- 'component',
1445
- 'detail',
1446
- 'intention',
1447
- 'schemaVersion',
1448
- 'source',
1449
- 'target',
1450
- 'timestamp',
1451
- ]);
1452
- expect(info.targetKeys).toEqual(['issuesUrl', 'package', 'version']);
1453
- // No handler-private context fields or raw agent identifiers
1454
- expect(result.data.deliveries[0].message).not.toContain('debug');
1455
- expect(result.data.deliveries[0].message).not.toContain('context');
1456
- expect(result.data.deliveries[0].message).not.toContain('secret-agent');
1457
- });
1458
-
1459
- it('receipt type is gap-report.file for the aggregate response', async () => {
1460
- addIntegration({
1461
- name: '@test/basic',
1462
- audience: 'internal',
1463
- handleBody: "return {status: 'filed', message: 'ok'};",
1464
- });
1465
- configure(['@test/basic']);
1466
-
1467
- const result = await gapReport('General', {
1468
- ...reportOptions,
1469
- cwd: projectDir,
1470
- });
1471
-
1472
- expect(result.type).toBe('gap-report.file');
1473
- expect(result.data).toHaveProperty('deliveries');
1474
- expect(result.data).toHaveProperty('filedCount');
1475
- expect(result.data).toHaveProperty('routedOnlyCount');
1476
- expect(result.data).toHaveProperty('status');
1477
- expect(result.data).toHaveProperty('package');
1478
- expect(result.data).toHaveProperty('issuesUrl');
1479
- });
1480
- });
1481
-
1482
- describe('gapReport strict receipt validation', () => {
1483
- it('rejects receipt with unknown fields', async () => {
1484
- addIntegration({
1485
- name: '@test/extra-fields',
1486
- audience: 'internal',
1487
- handleBody: "return {status: 'filed', message: 'ok', extra: true};",
1488
- });
1489
- configure(['@test/extra-fields']);
1490
-
1491
- const result = await gapReport('General', {
1492
- ...reportOptions,
1493
- cwd: projectDir,
1494
- });
1495
-
1496
- expect(result.data.deliveries[0].status).toBe('failed');
1497
- });
1498
-
1499
- it('rejects routed_only without url', async () => {
1500
- addIntegration({
1501
- name: '@test/no-url',
1502
- audience: 'internal',
1503
- handleBody: "return {status: 'routed_only', message: 'but no url'};",
1504
- });
1505
- configure(['@test/no-url']);
1506
-
1507
- const result = await gapReport('General', {
1508
- ...reportOptions,
1509
- cwd: projectDir,
1510
- });
1511
-
1512
- expect(result.data.deliveries[0].status).toBe('failed');
1513
- });
1514
-
1515
- it('accepts valid routed_only with url', async () => {
1516
- addIntegration({
1517
- name: '@test/routed',
1518
- audience: 'internal',
1519
- handleBody:
1520
- "return {status: 'routed_only', url: 'https://example.com/issue/1'};",
1521
- });
1522
- configure(['@test/routed']);
1523
-
1524
- const result = await gapReport('General', {
1525
- ...reportOptions,
1526
- cwd: projectDir,
1527
- });
1528
-
1529
- expect(result.data.deliveries[0].status).toBe('routed_only');
1530
- expect(result.data.routedOnlyCount).toBe(1);
1531
- });
1532
-
1533
- it('accepts skipped without url or message', async () => {
1534
- addIntegration({
1535
- name: '@test/skipper',
1536
- audience: 'internal',
1537
- handleBody: "return {status: 'skipped'};",
1538
- });
1539
- configure(['@test/skipper']);
1540
-
1541
- const result = await gapReport('General', {
1542
- ...reportOptions,
1543
- cwd: projectDir,
1544
- });
1545
-
1546
- expect(result.data.deliveries[0].status).toBe('skipped');
1547
- expect(result.data.status).toBe('skipped');
1548
- });
1549
- });