@astryxdesign/cli 0.6.3-canary.ea2f048 → 0.6.3-canary.f04b501
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.
- package/README.md +106 -72
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +13 -3
- package/api/component/component.mjs +31 -2
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +22 -11
- package/api/component/component.type.mjs +32 -24
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +4 -3
- package/api/component/list/list.d.mts +0 -5
- package/api/component/list/list.mjs +37 -9
- package/api/discover/discover.doc.mjs +2 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +32 -24
- package/api/docs/_adapter.mjs +81 -87
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +14 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +44 -20
- package/api/docs/detail/section/section.test.mjs +41 -0
- package/api/docs/docs.d.mts +7 -2
- package/api/docs/docs.doc.mjs +28 -10
- package/api/docs/docs.mjs +16 -9
- package/api/docs/docs.test.mjs +6 -0
- package/api/docs/docs.type.d.mts +40 -3
- package/api/docs/docs.type.mjs +36 -8
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +32 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/integrationDocs.test.mjs +106 -0
- package/api/docs/list/list.mjs +3 -7
- package/api/doctor/doctor.d.mts +70 -0
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +404 -0
- package/api/doctor/doctor.test.mjs +522 -1
- package/api/gap-report/gap-report.doc.mjs +8 -4
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +1 -0
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/hook/list/list.d.mts +2 -2
- package/api/hook/list/list.mjs +69 -17
- package/api/init/init.doc.mjs +5 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +23 -10
- package/api/integration/add-contribution.test.mjs +121 -7
- package/api/integration/add-theme.mjs +34 -64
- package/api/integration/add-theme.test.mjs +105 -21
- package/api/integration/authoring-checks.test.mjs +8 -4
- package/api/integration/integration-authoring.type.d.mts +1 -1
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +8 -4
- package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
- package/api/integration/integrationAddCodemod.doc.mjs +1 -0
- package/api/integration/integrationAddComponent.doc.mjs +2 -1
- package/api/integration/integrationAddDoc.doc.mjs +1 -0
- package/api/integration/integrationAddTemplate.doc.mjs +1 -0
- package/api/integration/integrationAddTheme.doc.mjs +6 -5
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
- package/api/integration/integrationDocConflicts.doc.mjs +1 -0
- package/api/integration/integrationPackCheck.doc.mjs +1 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +266 -47
- package/api/integration/summarizeIssues.doc.mjs +1 -0
- package/api/integration/validate-integration-fixes.test.mjs +1389 -0
- package/api/integration/validate-integration.mjs +52 -102
- package/api/integration/validate-integration.test.mjs +176 -23
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +2 -1
- package/api/json/assertResponse.doc.mjs +1 -0
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/isError.doc.mjs +1 -0
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutCheck.doc.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +2 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -0
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +3 -10
- package/api/search/search.doc.mjs +6 -1
- package/api/search/search.mjs +31 -14
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +2 -2
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +3 -1
- package/api/template/template.type.d.mts +6 -6
- package/api/template/template.type.mjs +12 -12
- package/api/theme/_adapter.d.mts +2 -3
- package/api/theme/_adapter.mjs +4 -5
- package/api/theme/add/add.binary.test.mjs +84 -0
- package/api/theme/add/add.mjs +20 -3
- package/api/theme/add/add.staging.test.mjs +66 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/generateTonalPalette.doc.mjs +1 -0
- package/api/theme/integration-themes.test.mjs +39 -28
- package/api/theme/list/list.test.mjs +19 -20
- package/api/theme/listThemes.doc.mjs +6 -5
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeAdd.doc.mjs +4 -3
- package/api/theme/themeBuild.doc.mjs +8 -4
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +5 -3
- package/api/theme/themePaletteGenerate.doc.mjs +1 -0
- package/api/theme/themeTargets.doc.mjs +1 -0
- package/api/theme/themeTemplate.doc.mjs +5 -1
- package/api/upgrade/_adapter.d.mts +12 -3
- package/api/upgrade/_adapter.mjs +123 -19
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/project-context.test.mjs +272 -0
- package/api/upgrade/provider-agreement.test.mjs +152 -0
- package/api/upgrade/run/run.mjs +1 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +7 -4
- package/api/upgrade/upgrade.type.d.mts +9 -5
- package/api/upgrade/upgrade.type.mjs +12 -11
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -0
- package/assets/codemods/runner.mjs +115 -5
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transform-prop.mjs +109 -0
- package/assets/codemods/transform-prop.test.mjs +95 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/README.md +9 -0
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/cli-integrations.doc.mjs +78 -20
- package/assets/docs/cli.doc.mjs +15 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
- package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
- package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
- package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
- package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
- package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
- package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +7 -2
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +788 -23
- package/authoring/doctypes/_schema.mjs +492 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
- package/authoring/doctypes/base/type.ts +40 -0
- package/authoring/doctypes/command/command.doc.mjs +4 -3
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +4 -3
- package/authoring/doctypes/component/component.doc.mjs +6 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +6 -5
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +4 -2
- package/authoring/doctypes/function/function.doc.mjs +5 -1
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +7 -3
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +5 -4
- package/authoring/doctypes/legacy.d.mts +8 -6
- package/authoring/doctypes/legacy.mjs +5 -4
- package/authoring/doctypes/load-contract.test.mjs +208 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +132 -0
- package/authoring/doctypes/namespace/parse.d.mts +12 -0
- package/authoring/doctypes/namespace/parse.mjs +25 -0
- package/authoring/doctypes/namespace/parse.test.mjs +165 -0
- package/authoring/doctypes/namespace/type.ts +71 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -12
- package/authoring/doctypes/parse.test.mjs +77 -3
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +8 -5
- package/authoring/doctypes/reference/reference.doc.mjs +18 -5
- package/authoring/doctypes/reference/type.ts +53 -7
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +4 -4
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +36 -2
- package/authoring/doctypes/template/parse.test.mjs +8 -2
- package/authoring/doctypes/template/template.doc.mjs +7 -3
- package/authoring/doctypes/template/type.ts +5 -2
- package/authoring/doctypes/theme/parse.d.mts +35 -0
- package/authoring/doctypes/theme/parse.mjs +76 -0
- package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
- package/authoring/doctypes/theme/theme.doc.mjs +79 -0
- package/authoring/doctypes/theme/type.ts +42 -0
- package/authoring/doctypes/types.ts +12 -10
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/gap-report/parse.d.mts +10 -10
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.d.mts +9 -0
- package/authoring/identity/identity.doc.mjs +61 -0
- package/authoring/identity/type.ts +132 -0
- package/authoring/index.d.mts +2 -0
- package/authoring/index.d.ts +51 -17
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +15 -8
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/parse.test.mjs +10 -1
- package/authoring/integration/schema.d.mts +6 -4
- package/authoring/integration/schema.mjs +9 -3
- package/authoring/integration/type.ts +18 -7
- package/authoring/shadcn/receipt.d.mts +6 -6
- package/clients/cli/__tests__/cliManifest.test.ts +27 -29
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +5 -2
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +46 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +5 -3
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +14 -4
- package/clients/cli/commands/docs.mjs +121 -21
- package/clients/cli/commands/docs.test.mjs +88 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor-integration.test.mjs +15 -7
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +17 -6
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +20 -9
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +22 -6
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +3 -9
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +15 -4
- package/clients/cli/commands/layout-expand.doc.mjs +22 -5
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
- package/clients/cli/commands/layout.doc.mjs +3 -3
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +7 -4
- package/clients/cli/commands/search.mjs +17 -7
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/swizzle.doc.mjs +3 -2
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +29 -7
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +4 -3
- package/clients/cli/commands/theme-build.doc.mjs +8 -7
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +9 -5
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +1 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +20 -9
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/formatters/index.mjs +162 -1
- package/clients/cli/formatters/index.test.mjs +91 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +29 -2
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project-themes.test.mjs +11 -19
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +190 -32
- package/foundation/config/project.test.mjs +129 -16
- package/foundation/discovery/authoring-self-docs.d.mts +75 -0
- package/foundation/discovery/authoring-self-docs.mjs +224 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +154 -0
- package/foundation/discovery/authoring-surface.d.mts +74 -0
- package/foundation/discovery/authoring-surface.mjs +525 -0
- package/foundation/discovery/authoring-surface.test.mjs +392 -0
- package/foundation/discovery/cli-self-docs.d.mts +113 -0
- package/foundation/discovery/cli-self-docs.mjs +514 -0
- package/foundation/discovery/cli-self-docs.test.mjs +437 -0
- package/foundation/discovery/component-discovery.d.mts +1 -1
- package/foundation/discovery/component-discovery.mjs +2 -1
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +12 -4
- package/foundation/discovery/docs-discovery.mjs +214 -98
- package/foundation/discovery/docs-discovery.test.mjs +284 -15
- package/foundation/discovery/docs-output-budget.d.mts +28 -0
- package/foundation/discovery/docs-output-budget.mjs +50 -0
- package/foundation/discovery/docs-section-key.d.mts +98 -0
- package/foundation/discovery/docs-section-key.mjs +221 -0
- package/foundation/discovery/docs-section-key.test.mjs +224 -0
- package/foundation/discovery/template-adapter.d.mts +21 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +321 -66
- package/foundation/discovery/template-adapter.test.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +67 -7
- package/foundation/discovery/theme-discovery.mjs +916 -186
- package/foundation/discovery/theme-discovery.test.mjs +613 -219
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/bundle.d.mts +47 -0
- package/foundation/doc-compiler/bundle.mjs +218 -0
- package/foundation/doc-compiler/bundle.test.mjs +255 -0
- package/foundation/doc-compiler/compile.d.mts +362 -0
- package/foundation/doc-compiler/compile.mjs +511 -0
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +277 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
- package/foundation/doc-compiler/import.d.mts +24 -0
- package/foundation/doc-compiler/import.mjs +59 -0
- package/foundation/doc-compiler/inputs.d.mts +102 -0
- package/foundation/doc-compiler/inputs.mjs +286 -0
- package/foundation/doc-compiler/inputs.test.mjs +299 -0
- package/foundation/doc-compiler/ir.d.mts +22 -0
- package/foundation/doc-compiler/ir.mjs +464 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
- package/foundation/doc-compiler/overlays.d.mts +37 -0
- package/foundation/doc-compiler/overlays.mjs +206 -0
- package/foundation/doc-compiler/parse-readable.d.mts +9 -0
- package/foundation/doc-compiler/parse-readable.mjs +29 -0
- package/foundation/doc-compiler/read.d.mts +126 -0
- package/foundation/doc-compiler/read.mjs +320 -0
- package/foundation/doc-compiler/read.test.mjs +313 -0
- package/foundation/doc-compiler/source.d.mts +33 -0
- package/foundation/doc-compiler/source.mjs +128 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/identity/provider-identity.d.mts +90 -0
- package/foundation/identity/provider-identity.mjs +320 -0
- package/foundation/identity/provider-identity.test.mjs +254 -0
- package/foundation/identity/providers.d.mts +7 -0
- package/foundation/identity/providers.mjs +16 -0
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -45
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +1 -1
- package/foundation/integrations/contribution-inventory.mjs +17 -20
- package/foundation/integrations/contribution-inventory.test.mjs +67 -27
- package/foundation/integrations/integration-warnings.mjs +6 -0
- package/foundation/integrations/integrations.d.mts +49 -2
- package/foundation/integrations/integrations.mjs +81 -8
- package/foundation/integrations/integrations.test.mjs +384 -1
- package/foundation/integrations/provider-conflicts.test.mjs +125 -0
- package/foundation/integrations/provider-ledger.test.mjs +275 -0
- package/foundation/integrations/provider-resolution.d.mts +152 -0
- package/foundation/integrations/provider-resolution.mjs +576 -0
- package/foundation/integrations/provider-resolution.test.mjs +369 -0
- package/foundation/integrations/theme-descriptor.d.mts +8 -0
- package/foundation/integrations/theme-descriptor.mjs +44 -0
- package/foundation/integrations/validate-contributions.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +114 -10
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +3 -4
- package/foundation/response/error-codes.mjs +2 -2
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +57 -17
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +16 -11
- package/foundation/response/response-types.doc.test.mjs +158 -0
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/text/string-utils.mjs +22 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/assets/templates/themes/manifest.json +0 -95
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The published `@astryxdesign/cli/json` envelope types carry
|
|
5
|
+
* `apiVersion`, the field every `--json` envelope has. Type-checks a consumer
|
|
6
|
+
* fixture that reads it from each envelope shape.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, it, expect} from 'vitest';
|
|
10
|
+
import {spawnSync} from 'node:child_process';
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
import * as os from 'node:os';
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import {createRequire} from 'node:module';
|
|
15
|
+
import {fileURLToPath} from 'node:url';
|
|
16
|
+
|
|
17
|
+
const INDEX = fileURLToPath(new URL('./index.ts', import.meta.url));
|
|
18
|
+
const TSC = createRequire(import.meta.url).resolve('typescript/bin/tsc');
|
|
19
|
+
|
|
20
|
+
const FIXTURE = `
|
|
21
|
+
import type {
|
|
22
|
+
assertResponse,
|
|
23
|
+
CLIError,
|
|
24
|
+
CLIUnsupportedError,
|
|
25
|
+
parseResponse,
|
|
26
|
+
} from ${JSON.stringify(INDEX)};
|
|
27
|
+
|
|
28
|
+
declare const error: CLIError;
|
|
29
|
+
declare const unsupported: CLIUnsupportedError;
|
|
30
|
+
declare const parsed: Exclude<ReturnType<typeof parseResponse>, CLIError | CLIUnsupportedError>;
|
|
31
|
+
declare const asserted: ReturnType<typeof assertResponse<'manifest'>>;
|
|
32
|
+
|
|
33
|
+
export const versions: number[] = [
|
|
34
|
+
error.apiVersion,
|
|
35
|
+
unsupported.apiVersion,
|
|
36
|
+
parsed.apiVersion,
|
|
37
|
+
asserted.apiVersion,
|
|
38
|
+
];
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
describe('@astryxdesign/cli/json envelope types', () => {
|
|
42
|
+
it('declare apiVersion on the success and error envelopes', () => {
|
|
43
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-envelope-types-'));
|
|
44
|
+
try {
|
|
45
|
+
fs.writeFileSync(path.join(dir, 'fixture.ts'), FIXTURE);
|
|
46
|
+
fs.writeFileSync(
|
|
47
|
+
path.join(dir, 'tsconfig.json'),
|
|
48
|
+
JSON.stringify({
|
|
49
|
+
compilerOptions: {
|
|
50
|
+
target: 'ES2022',
|
|
51
|
+
module: 'ESNext',
|
|
52
|
+
moduleResolution: 'bundler',
|
|
53
|
+
strict: true,
|
|
54
|
+
noEmit: true,
|
|
55
|
+
skipLibCheck: true,
|
|
56
|
+
allowImportingTsExtensions: true,
|
|
57
|
+
// index.ts re-exports JSDoc types from .type.mjs files; read them
|
|
58
|
+
// from source, as tsconfig.json-api.json does, not from generated
|
|
59
|
+
// declarations that exist only after a build.
|
|
60
|
+
allowJs: true,
|
|
61
|
+
types: [],
|
|
62
|
+
},
|
|
63
|
+
files: ['fixture.ts'],
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
const res = spawnSync(process.execPath, [TSC, '-p', dir], {
|
|
67
|
+
encoding: 'utf-8',
|
|
68
|
+
timeout: 60_000,
|
|
69
|
+
});
|
|
70
|
+
expect(res.stdout + res.stderr).toBe('');
|
|
71
|
+
expect(res.status).toBe(0);
|
|
72
|
+
} finally {
|
|
73
|
+
fs.rmSync(dir, {recursive: true, force: true});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
package/api/json/isError.doc.mjs
CHANGED
|
@@ -11,12 +11,13 @@ export const doc = {
|
|
|
11
11
|
type: 'function',
|
|
12
12
|
kind: 'api',
|
|
13
13
|
name: 'parseResponse',
|
|
14
|
+
namespace: 'cli/api',
|
|
14
15
|
displayName: 'parseResponse()',
|
|
15
16
|
summary: 'Parse `astryx --json` stdout into the structural response envelope.',
|
|
16
17
|
description:
|
|
17
18
|
'The entry point for consuming the CLI as a subprocess. A JSON string is parsed; ' +
|
|
18
19
|
'an already-parsed object is passed through unchanged, so it is safe to call on ' +
|
|
19
|
-
'either. It returns the structural { type, data, meta? } envelope without narrowing: ' +
|
|
20
|
+
'either. It returns the structural { apiVersion, type, data, meta? } envelope without narrowing: ' +
|
|
20
21
|
'`data` stays unknown until you discriminate on `type` (or use assertResponse).',
|
|
21
22
|
importPath: '@astryxdesign/cli/json',
|
|
22
23
|
signature: 'parseResponse(raw: unknown): any',
|
|
@@ -34,7 +35,7 @@ export const doc = {
|
|
|
34
35
|
{
|
|
35
36
|
type: 'any',
|
|
36
37
|
description:
|
|
37
|
-
'The { type, data, meta? } envelope, or a CLIError envelope. The published signature is intentionally untyped; narrow it by casting to the matching *Response type exported from @astryxdesign/cli/json.',
|
|
38
|
+
'The { apiVersion, type, data, meta? } envelope, or a CLIError envelope ({ apiVersion, error, code, suggestions? }). The published signature is intentionally untyped; narrow it by casting to the matching *Response type exported from @astryxdesign/cli/json.',
|
|
38
39
|
},
|
|
39
40
|
],
|
|
40
41
|
throws: [
|
|
@@ -120,18 +120,20 @@ export async function layoutExpand(expression, options = {}) {
|
|
|
120
120
|
|
|
121
121
|
let written = null;
|
|
122
122
|
if (targetPath) {
|
|
123
|
-
|
|
123
|
+
// The guard sees the file that will be written, not only its directory:
|
|
124
|
+
// a symlink at that name would otherwise carry the write outside the root.
|
|
125
|
+
const fileTarget = isFilePathArg(targetPath)
|
|
126
|
+
? targetPath
|
|
127
|
+
: path.join(targetPath, `${componentName}.tsx`);
|
|
128
|
+
let filePath;
|
|
124
129
|
try {
|
|
125
|
-
|
|
130
|
+
filePath = assertWithin(fileTarget, cwd, {label: 'layout target path'});
|
|
126
131
|
} catch (err) {
|
|
127
132
|
if (err instanceof PathSafetyError) {
|
|
128
133
|
throw new AstryxError(err.message, undefined, ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
129
134
|
}
|
|
130
135
|
throw err;
|
|
131
136
|
}
|
|
132
|
-
const filePath = isFilePathArg(targetPath)
|
|
133
|
-
? resolved
|
|
134
|
-
: path.join(resolved, `${componentName}.tsx`);
|
|
135
137
|
fs.mkdirSync(path.dirname(filePath), {recursive: true});
|
|
136
138
|
fs.writeFileSync(filePath, result.code);
|
|
137
139
|
written = path.relative(cwd, filePath);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Path-safety tests for the `layout.expand` write. The file written, not
|
|
5
|
+
* only the directory it lands in, must stay inside the project root.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {describe, it, expect, beforeAll} from 'vitest';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import {layoutExpand} from '../layout.mjs';
|
|
13
|
+
import {buildRegistry} from '../../../foundation/xle/registry.mjs';
|
|
14
|
+
|
|
15
|
+
const SLOW = 30_000;
|
|
16
|
+
|
|
17
|
+
// The registry imports every component doc on first use; warm it once.
|
|
18
|
+
beforeAll(async () => {
|
|
19
|
+
await buildRegistry();
|
|
20
|
+
}, 120_000);
|
|
21
|
+
|
|
22
|
+
describe('layout.expand — write confinement', () => {
|
|
23
|
+
it('rejects a directory target whose generated file is a symlink leading outside cwd', async () => {
|
|
24
|
+
// Inside the workspace so @astryxdesign/core resolves.
|
|
25
|
+
const cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-confine-test-'));
|
|
26
|
+
const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'xle-confine-outside-'));
|
|
27
|
+
try {
|
|
28
|
+
const victim = path.join(outside, 'victim.tsx');
|
|
29
|
+
fs.writeFileSync(victim, 'OUTSIDE');
|
|
30
|
+
fs.mkdirSync(path.join(cwd, 'out'));
|
|
31
|
+
fs.symlinkSync(victim, path.join(cwd, 'out', 'GeneratedLayout.tsx'));
|
|
32
|
+
|
|
33
|
+
await expect(
|
|
34
|
+
layoutExpand('V > B', {targetPath: './out', cwd}),
|
|
35
|
+
).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
36
|
+
expect(fs.readFileSync(victim, 'utf-8')).toBe('OUTSIDE');
|
|
37
|
+
} finally {
|
|
38
|
+
fs.rmSync(cwd, {recursive: true, force: true});
|
|
39
|
+
fs.rmSync(outside, {recursive: true, force: true});
|
|
40
|
+
}
|
|
41
|
+
}, SLOW);
|
|
42
|
+
|
|
43
|
+
it('still writes <Name>.tsx into a plain directory target', async () => {
|
|
44
|
+
const cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-confine-test-'));
|
|
45
|
+
try {
|
|
46
|
+
const result = await layoutExpand('V > B', {targetPath: './out', name: 'Demo', cwd});
|
|
47
|
+
expect(result.data.written).toBe(path.join('out', 'Demo.tsx'));
|
|
48
|
+
expect(fs.existsSync(path.join(cwd, 'out', 'Demo.tsx'))).toBe(true);
|
|
49
|
+
} finally {
|
|
50
|
+
fs.rmSync(cwd, {recursive: true, force: true});
|
|
51
|
+
}
|
|
52
|
+
}, SLOW);
|
|
53
|
+
});
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import {buildRegistry} from '../../../foundation/xle/registry.mjs';
|
|
13
|
+
import {MAX_REPEAT} from '../../../foundation/xle/expand.mjs';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* `astryx layout grammar` — the agent cheatsheet, with the alias table
|
|
@@ -50,7 +51,7 @@ NODE ANATOMY Name#id.enum"payload"[attrs]{hint}*N > children
|
|
|
50
51
|
.enum unique enum value of any prop: Bd.success Tx.lg B.primary
|
|
51
52
|
"payload" primary text prop (label/title/heading) or text child: TI"Email" B"Save"
|
|
52
53
|
{hint} kebab-case template/component reference (see TEMPLATE REFERENCING) — NEVER text
|
|
53
|
-
*N / xN repeat (use $ for the counter: Tk"item-$"*3)
|
|
54
|
+
*N / xN repeat, at most ${MAX_REPEAT} copies (use $ for the counter: Tk"item-$"*3)
|
|
54
55
|
trailing ! initial selection for scaffolded state: Tab"Overview"!
|
|
55
56
|
|
|
56
57
|
ATTRS [...] (outline: bare tokens after the name, no brackets)
|
|
@@ -12,6 +12,7 @@ export const doc = {
|
|
|
12
12
|
type: 'function',
|
|
13
13
|
kind: 'api',
|
|
14
14
|
name: 'layoutExpand',
|
|
15
|
+
namespace: 'cli/api',
|
|
15
16
|
displayName: 'layoutExpand()',
|
|
16
17
|
summary: 'Expand a validated layout expression into XDS TSX.',
|
|
17
18
|
description:
|
|
@@ -36,7 +37,7 @@ export const doc = {
|
|
|
36
37
|
name: 'options.targetPath',
|
|
37
38
|
type: 'string',
|
|
38
39
|
description:
|
|
39
|
-
'Write the generated TSX here (validated to stay within cwd). A
|
|
40
|
+
'Write the generated TSX here (validated to stay within cwd). A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is used as-is; any other path is a directory that gets <name>.tsx. An existing file is replaced. Omit to return the code without writing.',
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
43
|
name: 'options.form',
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The declared return type of `search()` is the canonical SearchResponse.
|
|
5
|
+
* Consumers of `@astryxdesign/cli/api` type-check against it; an `object` entry
|
|
6
|
+
* type erases every result field from their view.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {createRequire} from 'node:module';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {describe, expect, it} from 'vitest';
|
|
13
|
+
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const ts = require('typescript');
|
|
16
|
+
|
|
17
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const SEARCH = path.join(HERE, 'search.mjs');
|
|
19
|
+
const TYPES = path.join(HERE, 'search.type.mjs');
|
|
20
|
+
|
|
21
|
+
describe('search() declared return type', () => {
|
|
22
|
+
it('types each result as the canonical SearchResultEntry', () => {
|
|
23
|
+
const program = ts.createProgram([SEARCH, TYPES], {
|
|
24
|
+
allowJs: true,
|
|
25
|
+
noEmit: true,
|
|
26
|
+
skipLibCheck: true,
|
|
27
|
+
types: [],
|
|
28
|
+
module: ts.ModuleKind.NodeNext,
|
|
29
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
30
|
+
target: ts.ScriptTarget.ES2022,
|
|
31
|
+
});
|
|
32
|
+
const checker = program.getTypeChecker();
|
|
33
|
+
const source = program.getSourceFile(SEARCH);
|
|
34
|
+
/** @param {string} file @param {string} name */
|
|
35
|
+
const exportOf = (file, name) =>
|
|
36
|
+
checker
|
|
37
|
+
.getExportsOfModule(checker.getSymbolAtLocation(program.getSourceFile(file)))
|
|
38
|
+
.find((/** @type {any} */ s) => s.name === name);
|
|
39
|
+
/** @param {any} type @param {string} name */
|
|
40
|
+
const prop = (type, name) =>
|
|
41
|
+
checker.getTypeOfSymbolAtLocation(type.getProperty(name), source);
|
|
42
|
+
/** @param {any} type */
|
|
43
|
+
const names = type => type.getProperties().map((/** @type {any} */ p) => p.name).sort();
|
|
44
|
+
|
|
45
|
+
const fn = checker.getTypeOfSymbolAtLocation(exportOf(SEARCH, 'search'), source);
|
|
46
|
+
const response = checker.getAwaitedType(fn.getCallSignatures()[0].getReturnType());
|
|
47
|
+
const data = prop(response, 'data');
|
|
48
|
+
expect(names(data)).toEqual(['matchCount', 'query', 'results']);
|
|
49
|
+
const entry = checker.getIndexTypeOfType(prop(data, 'results'), ts.IndexKind.Number);
|
|
50
|
+
const canonical = checker.getDeclaredTypeOfSymbol(exportOf(TYPES, 'SearchResultEntry'));
|
|
51
|
+
expect(names(canonical)).toContain('command');
|
|
52
|
+
expect(names(entry)).toEqual(names(canonical));
|
|
53
|
+
}, 30_000);
|
|
54
|
+
});
|
package/api/search/search.d.mts
CHANGED
|
@@ -68,20 +68,13 @@ export function scoreCandidate(term: string, { name, keywords, weakKeywords, des
|
|
|
68
68
|
* @param {string} [options.cwd]
|
|
69
69
|
* @param {'component'|'hook'|'doc'|'template'} [options.type] - Restrict to one domain.
|
|
70
70
|
* @param {number} [options.limit] - Max results (default 20).
|
|
71
|
-
* @returns {Promise<
|
|
71
|
+
* @returns {Promise<import('./search.type.mjs').SearchResponse>}
|
|
72
72
|
*/
|
|
73
73
|
export function search(query: string, options?: {
|
|
74
74
|
cwd?: string | undefined;
|
|
75
75
|
type?: "component" | "hook" | "doc" | "template" | undefined;
|
|
76
76
|
limit?: number | undefined;
|
|
77
|
-
}): Promise<
|
|
78
|
-
type: "search";
|
|
79
|
-
data: {
|
|
80
|
-
query: string;
|
|
81
|
-
matchCount: number;
|
|
82
|
-
results: Array<object>;
|
|
83
|
-
};
|
|
84
|
-
}>;
|
|
77
|
+
}): Promise<import("./search.type.mjs").SearchResponse>;
|
|
85
78
|
/** Valid domain filters for `--type`. */
|
|
86
79
|
export const SEARCH_DOMAINS: string[];
|
|
87
80
|
/**
|
|
@@ -99,5 +92,5 @@ export type Candidate = {
|
|
|
99
92
|
_import?: string | undefined;
|
|
100
93
|
_title?: string | undefined;
|
|
101
94
|
_displayName?: string | undefined;
|
|
102
|
-
_kind?: "
|
|
95
|
+
_kind?: "page" | "block" | undefined;
|
|
103
96
|
};
|
|
@@ -11,6 +11,7 @@ export const doc = {
|
|
|
11
11
|
type: 'function',
|
|
12
12
|
kind: 'api',
|
|
13
13
|
name: 'search',
|
|
14
|
+
namespace: 'cli/api',
|
|
14
15
|
displayName: 'search()',
|
|
15
16
|
summary:
|
|
16
17
|
'Unified ranked search across components, hooks, docs, and templates.',
|
|
@@ -53,7 +54,7 @@ export const doc = {
|
|
|
53
54
|
{
|
|
54
55
|
type: 'search',
|
|
55
56
|
description:
|
|
56
|
-
'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit
|
|
57
|
+
'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, and `displayName` and `kind` for templates.',
|
|
57
58
|
},
|
|
58
59
|
],
|
|
59
60
|
throws: [
|
|
@@ -61,6 +62,10 @@ export const doc = {
|
|
|
61
62
|
code: 'ERR_INVALID_ARGUMENT',
|
|
62
63
|
when: 'the query is empty, --type is unknown, or --limit is not a positive integer',
|
|
63
64
|
},
|
|
65
|
+
{
|
|
66
|
+
code: 'ERR_CORE_NOT_FOUND',
|
|
67
|
+
when: '@astryxdesign/core cannot be found from the cwd',
|
|
68
|
+
},
|
|
64
69
|
],
|
|
65
70
|
examples: [
|
|
66
71
|
{label: 'Find a component', code: "const r = await search('button');"},
|
package/api/search/search.mjs
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* queries they have nothing to do with.
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
|
-
import {
|
|
53
|
+
import {readDocView} from '../../foundation/doc-compiler/read.mjs';
|
|
54
54
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
55
55
|
import {
|
|
56
56
|
discoverComponents,
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
import {loadIntegrationsSafely} from '../component/_adapter.mjs';
|
|
67
67
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
68
68
|
import {discoverTemplates, extractComponents} from '../template/template.mjs';
|
|
69
|
-
import {loadDocsCatalog,
|
|
69
|
+
import {loadDocsCatalog, lowerTopic} from '../docs/_adapter.mjs';
|
|
70
70
|
import {AstryxError} from '../error.mjs';
|
|
71
71
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
72
72
|
import {setResultCoverage} from './coverage.mjs';
|
|
@@ -528,16 +528,26 @@ export function scoreCandidate(
|
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
/**
|
|
531
|
-
*
|
|
531
|
+
* A component or hook doc, compiled, or null when it cannot be read.
|
|
532
532
|
* @param {string} docPath
|
|
533
533
|
* @param {string} [exportName]
|
|
534
|
+
* @param {'components' | 'hooks'} [root]
|
|
534
535
|
* @returns {Promise<any>}
|
|
535
536
|
*/
|
|
536
|
-
async function loadModuleDoc(
|
|
537
|
+
async function loadModuleDoc(
|
|
538
|
+
docPath,
|
|
539
|
+
exportName = 'docs',
|
|
540
|
+
root = 'components',
|
|
541
|
+
) {
|
|
537
542
|
try {
|
|
538
|
-
const mod = await import(pathToFileURL(docPath).href);
|
|
539
543
|
// Support both the stamped default export and the legacy named export.
|
|
540
|
-
return
|
|
544
|
+
return (
|
|
545
|
+
(await readDocView(docPath, {
|
|
546
|
+
root,
|
|
547
|
+
loader: 'native',
|
|
548
|
+
exports: ['default', exportName],
|
|
549
|
+
})) ?? null
|
|
550
|
+
);
|
|
541
551
|
} catch {
|
|
542
552
|
return null;
|
|
543
553
|
}
|
|
@@ -701,7 +711,7 @@ async function gatherHooks(coreDir) {
|
|
|
701
711
|
let description = '';
|
|
702
712
|
let importPath = '@astryxdesign/core/hooks';
|
|
703
713
|
if (docPath) {
|
|
704
|
-
const doc = await loadModuleDoc(docPath);
|
|
714
|
+
const doc = await loadModuleDoc(docPath, 'docs', 'hooks');
|
|
705
715
|
if (doc) {
|
|
706
716
|
keywords = Array.isArray(doc.keywords) ? doc.keywords : [];
|
|
707
717
|
description = doc.usage?.description || doc.description || '';
|
|
@@ -732,16 +742,16 @@ async function gatherHooks(coreDir) {
|
|
|
732
742
|
async function gatherDocs(cwd) {
|
|
733
743
|
/** @type {Candidate[]} */
|
|
734
744
|
const candidates = [];
|
|
735
|
-
let
|
|
745
|
+
let catalog;
|
|
736
746
|
try {
|
|
737
|
-
|
|
747
|
+
catalog = await loadDocsCatalog(cwd);
|
|
738
748
|
} catch {
|
|
739
749
|
return candidates;
|
|
740
750
|
}
|
|
741
|
-
for (const entry of entries) {
|
|
751
|
+
for (const entry of catalog.entries()) {
|
|
742
752
|
let doc = null;
|
|
743
753
|
try {
|
|
744
|
-
doc = await
|
|
754
|
+
doc = (await lowerTopic(catalog, entry)).doc;
|
|
745
755
|
} catch {
|
|
746
756
|
// A topic that cannot be loaded is reported by the commands that own
|
|
747
757
|
// integration issues; search just cannot index it.
|
|
@@ -884,7 +894,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
884
894
|
* @param {string} [options.cwd]
|
|
885
895
|
* @param {'component'|'hook'|'doc'|'template'} [options.type] - Restrict to one domain.
|
|
886
896
|
* @param {number} [options.limit] - Max results (default 20).
|
|
887
|
-
* @returns {Promise<
|
|
897
|
+
* @returns {Promise<import('./search.type.mjs').SearchResponse>}
|
|
888
898
|
*/
|
|
889
899
|
export async function search(query, options = {}) {
|
|
890
900
|
const {cwd = process.cwd(), type, limit = 20} = options;
|
|
@@ -921,7 +931,11 @@ export async function search(query, options = {}) {
|
|
|
921
931
|
|
|
922
932
|
const coreDir = findCoreDir(cwd);
|
|
923
933
|
if (!coreDir) {
|
|
924
|
-
throw new AstryxError(
|
|
934
|
+
throw new AstryxError(
|
|
935
|
+
'Could not find @astryxdesign/core package',
|
|
936
|
+
undefined,
|
|
937
|
+
ERROR_CODES.ERR_CORE_NOT_FOUND,
|
|
938
|
+
);
|
|
925
939
|
}
|
|
926
940
|
|
|
927
941
|
// Gather candidates from each requested domain in parallel.
|
|
@@ -971,7 +985,10 @@ export async function search(query, options = {}) {
|
|
|
971
985
|
data: {
|
|
972
986
|
query: String(query).trim(),
|
|
973
987
|
matchCount: scored.length,
|
|
974
|
-
|
|
988
|
+
// toResult gives every domain its command and domain fields.
|
|
989
|
+
results: /** @type {import('./search.type.mjs').SearchResultEntry[]} */ (
|
|
990
|
+
limited
|
|
991
|
+
),
|
|
975
992
|
},
|
|
976
993
|
};
|
|
977
994
|
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import {describe, it, expect} from 'vitest';
|
|
23
23
|
import * as fs from 'node:fs';
|
|
24
|
+
import * as os from 'node:os';
|
|
24
25
|
import * as path from 'node:path';
|
|
25
26
|
import {fileURLToPath} from 'node:url';
|
|
26
27
|
import {
|
|
@@ -70,6 +71,28 @@ describe('search leaf — envelope + ranking', () => {
|
|
|
70
71
|
}, SLOW);
|
|
71
72
|
});
|
|
72
73
|
|
|
74
|
+
describe('search leaf — per-domain result fields', () => {
|
|
75
|
+
it('carries import for components and hooks, title for docs, displayName and kind for templates', async () => {
|
|
76
|
+
const r = await search('theme', {cwd, limit: 60});
|
|
77
|
+
expect(new Set(r.data.results.map(res => res.domain))).toEqual(
|
|
78
|
+
new Set(SEARCH_DOMAINS),
|
|
79
|
+
);
|
|
80
|
+
for (const res of r.data.results) {
|
|
81
|
+
expect(typeof res.command).toBe('string');
|
|
82
|
+
expect(typeof res.description).toBe('string');
|
|
83
|
+
if (res.domain === 'component' || res.domain === 'hook') {
|
|
84
|
+
expect(res.import).toMatch(/\S/);
|
|
85
|
+
} else if (res.domain === 'doc') {
|
|
86
|
+
expect(res.title).toMatch(/\S/);
|
|
87
|
+
expect(res.command).toBe(`astryx docs ${res.name}`);
|
|
88
|
+
} else {
|
|
89
|
+
expect(res.displayName).toMatch(/\S/);
|
|
90
|
+
expect(['page', 'block']).toContain(res.kind);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, SLOW);
|
|
94
|
+
});
|
|
95
|
+
|
|
73
96
|
describe('search leaf — matchCount is the total, not the cap', () => {
|
|
74
97
|
it('reports every match while `results` stays bounded by the limit', async () => {
|
|
75
98
|
// The regression: `matchCount` used to be `results.length`, so a query
|
|
@@ -160,6 +183,17 @@ describe('search leaf — error paths (pinned)', () => {
|
|
|
160
183
|
search('button', {cwd, type: /** @type {any} */ ('bogus')}),
|
|
161
184
|
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
162
185
|
}, SLOW);
|
|
186
|
+
|
|
187
|
+
it('throws ERR_CORE_NOT_FOUND when @astryxdesign/core cannot be found', async () => {
|
|
188
|
+
const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-search-no-core-'));
|
|
189
|
+
try {
|
|
190
|
+
await expect(search('button', {cwd: empty})).rejects.toMatchObject({
|
|
191
|
+
code: 'ERR_CORE_NOT_FOUND',
|
|
192
|
+
});
|
|
193
|
+
} finally {
|
|
194
|
+
fs.rmSync(empty, {recursive: true, force: true});
|
|
195
|
+
}
|
|
196
|
+
}, SLOW);
|
|
163
197
|
});
|
|
164
198
|
|
|
165
199
|
describe('search leaf — limit validation (API matches the CLI contract)', () => {
|
|
@@ -48,10 +48,10 @@ export type SearchResultEntry = {
|
|
|
48
48
|
/**
|
|
49
49
|
* - Template kind (`page` | `block`) — present for template results.
|
|
50
50
|
*/
|
|
51
|
-
kind?: "
|
|
51
|
+
kind?: "page" | "block" | undefined;
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* astryx --json search <query>
|
|
55
55
|
*/
|
|
56
56
|
export type SearchResponse = {
|
|
57
57
|
type: "search";
|
|
@@ -159,6 +159,24 @@ function resolveOwners(coreDir, loadedIntegrations, name, coreIssuesUrl) {
|
|
|
159
159
|
return owners;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/**
|
|
163
|
+
* `assertWithin`, with an escape reported as ERR_PATH_TRAVERSAL.
|
|
164
|
+
* @param {string} target
|
|
165
|
+
* @param {string} cwd
|
|
166
|
+
* @param {{allowAbsolute?: boolean, label: string}} options
|
|
167
|
+
* @returns {string}
|
|
168
|
+
*/
|
|
169
|
+
function confineWrite(target, cwd, options) {
|
|
170
|
+
try {
|
|
171
|
+
return assertWithin(target, cwd, options);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (err instanceof PathSafetyError) {
|
|
174
|
+
throw new AstryxError(err.message, [], ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
175
|
+
}
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
162
180
|
/** @param {string} file */
|
|
163
181
|
function isExcludedFromCopy(file) {
|
|
164
182
|
return (
|
|
@@ -243,23 +261,22 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
243
261
|
|
|
244
262
|
const componentDir = owner.sourceDir;
|
|
245
263
|
|
|
246
|
-
// Path-safety:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
outputBase = assertWithin(output, cwd, {label: 'output directory'});
|
|
250
|
-
} catch (err) {
|
|
251
|
-
if (err instanceof PathSafetyError) {
|
|
252
|
-
throw new AstryxError(err.message, [], ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
253
|
-
}
|
|
254
|
-
throw err;
|
|
255
|
-
}
|
|
264
|
+
// Path-safety: every write target resolves inside cwd, not just --output. An
|
|
265
|
+
// existing component directory or file may be a symlink out of cwd.
|
|
266
|
+
const outputBase = confineWrite(output, cwd, {label: 'output directory'});
|
|
256
267
|
const outputDir = path.join(outputBase, dirName);
|
|
257
268
|
|
|
258
|
-
// Pre-flight overwrite
|
|
269
|
+
// Pre-flight path and overwrite checks before any mkdir/writeFile.
|
|
259
270
|
const sourceFiles = fs.readdirSync(componentDir).filter(file => {
|
|
260
271
|
if (isExcludedFromCopy(file)) return false;
|
|
261
272
|
return fs.statSync(path.join(componentDir, file)).isFile();
|
|
262
273
|
});
|
|
274
|
+
for (const file of sourceFiles) {
|
|
275
|
+
confineWrite(path.join(outputDir, file), cwd, {
|
|
276
|
+
allowAbsolute: true,
|
|
277
|
+
label: 'output file',
|
|
278
|
+
});
|
|
279
|
+
}
|
|
263
280
|
const existingFiles = sourceFiles.filter(f =>
|
|
264
281
|
fs.existsSync(path.join(outputDir, f)),
|
|
265
282
|
);
|
|
@@ -11,6 +11,7 @@ export const doc = {
|
|
|
11
11
|
type: 'function',
|
|
12
12
|
kind: 'api',
|
|
13
13
|
name: 'swizzle',
|
|
14
|
+
namespace: 'cli/api',
|
|
14
15
|
displayName: 'swizzle()',
|
|
15
16
|
summary: "Eject a component's source into your project for customization.",
|
|
16
17
|
description:
|
|
@@ -80,7 +81,7 @@ export const doc = {
|
|
|
80
81
|
},
|
|
81
82
|
{
|
|
82
83
|
code: 'ERR_PATH_TRAVERSAL',
|
|
83
|
-
when: 'the component name contains a path separator or traversal, or output resolves outside cwd',
|
|
84
|
+
when: 'the component name contains a path separator or traversal, output resolves outside cwd, or an existing output file or directory is a symlink that resolves outside cwd',
|
|
84
85
|
},
|
|
85
86
|
{
|
|
86
87
|
code: 'ERR_UNKNOWN_COMPONENT',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json swizzle [--list]
|
|
6
6
|
*/
|
|
7
7
|
export type SwizzleListResponse = {
|
|
8
8
|
type: "swizzle.list";
|
|
@@ -22,7 +22,7 @@ export type SwizzleFeedback = {
|
|
|
22
22
|
ghCommand?: string | undefined;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* astryx --json swizzle <component>
|
|
26
26
|
*/
|
|
27
27
|
export type SwizzleCopyResponse = {
|
|
28
28
|
type: "swizzle.copy";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* astryx --json swizzle [--list]
|
|
11
11
|
*
|
|
12
12
|
* @typedef {object} SwizzleListResponse
|
|
13
13
|
* @property {'swizzle.list'} type
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* astryx --json swizzle <component>
|
|
27
27
|
*
|
|
28
28
|
* @typedef {object} SwizzleCopyResponse
|
|
29
29
|
* @property {'swizzle.copy'} type
|