@astryxdesign/cli 0.6.3 → 0.6.4-canary.078fd25
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/CHANGELOG.md +194 -0
- package/README.md +152 -107
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/_adapter.d.mts +50 -0
- package/api/build/_adapter.mjs +60 -0
- package/api/build/build.doc.mjs +22 -10
- package/api/build/build.test.mjs +219 -8
- package/api/build/build.type.d.mts +91 -2
- package/api/build/build.type.mjs +52 -8
- package/api/build/help/help.d.mts +12 -5
- package/api/build/help/help.mjs +69 -6
- package/api/build/kit/kit.d.mts +4 -1
- package/api/build/kit/kit.mjs +208 -53
- package/api/build/kit/rank.d.mts +44 -0
- package/api/build/kit/rank.mjs +432 -0
- package/api/build/kit/rank.test.mjs +196 -0
- package/api/component/_adapter.d.mts +31 -12
- package/api/component/_adapter.mjs +79 -15
- package/api/component/component.d.mts +6 -3
- package/api/component/component.doc.mjs +49 -19
- package/api/component/component.mjs +339 -22
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +47 -11
- package/api/component/component.type.mjs +76 -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 +40 -11
- package/api/discover/_adapter.d.mts +114 -6
- package/api/discover/_adapter.mjs +372 -17
- package/api/discover/_adapter.test.mjs +215 -0
- package/api/discover/_catalog-view.d.mts +115 -0
- package/api/discover/_catalog-view.mjs +203 -0
- package/api/discover/_catalog-view.test.mjs +128 -0
- package/api/discover/detail/detail.d.mts +18 -6
- package/api/discover/detail/detail.mjs +67 -13
- package/api/discover/detail/detail.test.mjs +85 -0
- package/api/discover/detail/item/item.d.mts +26 -0
- package/api/discover/detail/item/item.mjs +78 -0
- package/api/discover/detail/item/item.test.mjs +73 -0
- package/api/discover/discover.d.mts +3 -9
- package/api/discover/discover.doc.mjs +62 -18
- package/api/discover/discover.mjs +220 -36
- package/api/discover/discover.test.mjs +11 -2
- package/api/discover/discover.type.d.mts +150 -11
- package/api/discover/discover.type.mjs +107 -17
- package/api/discover/list/list.d.mts +20 -6
- package/api/discover/list/list.mjs +45 -12
- package/api/discover/list/list.test.mjs +46 -0
- package/api/discover/search/search.d.mts +18 -16
- package/api/discover/search/search.mjs +102 -56
- package/api/discover/search/search.test.mjs +144 -10
- package/api/docs/_adapter.d.mts +277 -41
- package/api/docs/_adapter.mjs +993 -108
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +22 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +54 -19
- package/api/docs/detail/section/section.test.mjs +50 -0
- package/api/docs/docOverlays.test.mjs +27 -1
- package/api/docs/docs.d.mts +10 -3
- package/api/docs/docs.doc.mjs +55 -16
- package/api/docs/docs.mjs +53 -10
- package/api/docs/docs.type.d.mts +221 -5
- package/api/docs/docs.type.mjs +153 -11
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +40 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/list/list.mjs +28 -12
- package/api/docs/node/node.d.mts +43 -0
- package/api/docs/node/node.mjs +192 -0
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.d.mts +104 -1
- package/api/doctor/doctor.doc.mjs +18 -8
- package/api/doctor/doctor.mjs +635 -7
- package/api/doctor/doctor.test.mjs +732 -11
- package/api/doctor/doctor.type.d.mts +1 -1
- package/api/doctor/doctor.type.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +27 -14
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +7 -3
- 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/index.d.mts +2 -1
- package/api/index.mjs +6 -3
- package/api/init/init.doc.mjs +22 -12
- 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.d.mts +2 -1
- package/api/integration/add-contribution.mjs +130 -15
- package/api/integration/add-contribution.test.mjs +258 -7
- package/api/integration/add-helpers.d.mts +5 -2
- package/api/integration/add-helpers.mjs +36 -9
- package/api/integration/add-theme.mjs +56 -65
- package/api/integration/add-theme.test.mjs +139 -21
- package/api/integration/authoring-checks.mjs +138 -28
- package/api/integration/authoring-checks.test.mjs +179 -7
- package/api/integration/authoring-checks.type.mjs +6 -1
- package/api/integration/integration-authoring.type.d.mts +3 -1
- package/api/integration/integration-authoring.type.mjs +2 -0
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +14 -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 +8 -1
- 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 +2 -1
- package/api/integration/integrationPackCheck.doc.mjs +5 -4
- package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +4 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +107 -0
- package/api/integration/pack-check.mjs +160 -11
- package/api/integration/pack-check.test.mjs +477 -47
- package/api/integration/pack-check.type.d.mts +26 -2
- package/api/integration/pack-check.type.mjs +15 -2
- package/api/integration/summarizeIssues.doc.mjs +1 -0
- package/api/integration/template-conflict-compatibility.test.mjs +73 -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 +179 -26
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +3 -2
- package/api/json/assertResponse.doc.mjs +2 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/index.ts +2 -0
- package/api/json/isError.doc.mjs +2 -1
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/_adapter.mjs +20 -5
- 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 +89 -12
- package/api/search/search.doc.mjs +8 -2
- package/api/search/search.mjs +697 -97
- package/api/search/search.type.d.mts +15 -3
- package/api/search/search.type.mjs +5 -2
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +8 -5
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +18 -24
- package/api/template/copy/copy.test.mjs +26 -0
- package/api/template/list/list.mjs +1 -0
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/api/template/template-integration.test.mjs +1072 -3
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +32 -9
- package/api/template/template.mjs +45 -8
- package/api/template/template.type.d.mts +12 -14
- package/api/template/template.type.mjs +15 -14
- 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 +31 -22
- package/api/theme/add/add.rollback.test.mjs +158 -0
- package/api/theme/add/add.staging.test.mjs +83 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.family.test.mjs +7 -12
- package/api/theme/build/build.mjs +140 -59
- 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.rollback.test.mjs +148 -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 +2 -2
- 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 +20 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeAdd.doc.mjs +12 -12
- package/api/theme/themeBuild.doc.mjs +21 -17
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +6 -3
- package/api/theme/themePaletteGenerate.doc.mjs +16 -8
- package/api/theme/themeTargets.doc.mjs +4 -2
- package/api/theme/themeTemplate.doc.mjs +8 -3
- package/api/upgrade/_adapter.d.mts +32 -5
- package/api/upgrade/_adapter.mjs +139 -22
- 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/files-changed.test.mjs +111 -0
- package/api/upgrade/run/run.mjs +358 -59
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +32 -23
- package/api/upgrade/upgrade.type.d.mts +43 -5
- package/api/upgrade/upgrade.type.mjs +29 -13
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/__tests__/runner.test.mjs +332 -8
- package/assets/codemods/file-count.test.mjs +163 -0
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -0
- package/assets/codemods/integration-runner.mjs +59 -7
- package/assets/codemods/integration-runner.protection.test.mjs +153 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/run-codemod.mjs +177 -34
- package/assets/codemods/runner.mjs +353 -104
- 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/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/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
- package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +220 -0
- package/assets/codemods/transforms/v0.6.4/index.mjs +31 -0
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +148 -0
- package/assets/codemods/transforms/v0.6.4/migrate-theme-catalog-to-descriptors.mjs +141 -0
- package/assets/docs/README.md +12 -1
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/browser-support.doc.mjs +11 -11
- package/assets/docs/color.doc.mjs +8 -2
- package/assets/docs/elevation.doc.mjs +6 -4
- package/assets/docs/getting-started.doc.mjs +6 -17
- package/assets/docs/icons.doc.mjs +2 -21
- package/assets/docs/illustrations.doc.mjs +7 -15
- package/assets/docs/internationalization.doc.mjs +7 -5
- package/assets/docs/layout.doc.dense.mjs +132 -84
- package/assets/docs/layout.doc.mjs +134 -78
- package/assets/docs/migration.doc.mjs +19 -21
- package/assets/docs/motion.doc.mjs +16 -3
- package/assets/docs/principles.doc.dense.mjs +5 -5
- package/assets/docs/principles.doc.mjs +14 -6
- package/assets/docs/principles.doc.zh.mjs +6 -6
- package/assets/docs/shape.doc.mjs +8 -3
- package/assets/docs/spacing.doc.mjs +7 -2
- package/assets/docs/styling-libraries.doc.mjs +10 -6
- package/assets/docs/styling.doc.mjs +22 -26
- package/assets/docs/theme.doc.dense.mjs +58 -18
- package/assets/docs/theme.doc.mjs +60 -50
- package/assets/docs/theme.doc.zh.mjs +9 -8
- package/assets/docs/tokens.doc.dense.mjs +2 -2
- package/assets/docs/tokens.doc.mjs +390 -9
- package/assets/docs/tokens.doc.zh.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +75 -0
- package/assets/docs/tree/add-a-theme.doc.mjs +85 -0
- package/assets/docs/tree/add-a-topic.doc.mjs +144 -0
- package/assets/docs/tree/agent-guidance.doc.mjs +138 -0
- package/assets/docs/tree/api.doc.mjs +30 -0
- package/assets/docs/tree/block-template.doc.mjs +130 -0
- package/assets/docs/tree/build-the-template.doc.mjs +28 -0
- package/assets/docs/tree/building-blocks.doc.mjs +46 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +137 -0
- package/assets/docs/tree/checks.doc.mjs +119 -0
- package/assets/docs/tree/cli.doc.mjs +23 -0
- package/assets/docs/tree/codemods.doc.mjs +147 -0
- package/assets/docs/tree/commands.doc.mjs +25 -0
- package/assets/docs/tree/component-family.doc.mjs +113 -0
- package/assets/docs/tree/component-imports.doc.mjs +69 -0
- package/assets/docs/tree/component-lookups.doc.mjs +149 -0
- package/assets/docs/tree/components.doc.mjs +23 -0
- package/assets/docs/tree/configuration.doc.mjs +23 -0
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +182 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +118 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +57 -0
- package/assets/docs/tree/docs.doc.mjs +21 -0
- package/assets/docs/tree/document-the-template.doc.mjs +28 -0
- package/assets/docs/tree/document-the-theme.doc.mjs +68 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +147 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +103 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +106 -0
- package/assets/docs/tree/generate-a-palette.doc.mjs +66 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +105 -0
- package/assets/docs/tree/help.doc.mjs +16 -0
- package/assets/docs/tree/integrations.doc.mjs +40 -0
- package/assets/docs/tree/links.doc.mjs +98 -0
- package/assets/docs/tree/package-and-test.doc.mjs +32 -0
- package/assets/docs/tree/page-template.doc.mjs +71 -0
- package/assets/docs/tree/publishing.doc.mjs +111 -0
- package/assets/docs/tree/quick-start.doc.mjs +272 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +104 -0
- package/assets/docs/tree/replace-a-core-template.doc.mjs +172 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +108 -0
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +59 -0
- package/assets/docs/tree/ship.doc.mjs +16 -0
- package/assets/docs/tree/short-and-findable.doc.mjs +108 -0
- package/assets/docs/tree/single-component.doc.mjs +165 -0
- package/assets/docs/tree/start-a-template.doc.mjs +143 -0
- package/assets/docs/tree/subcomponent.doc.mjs +115 -0
- package/assets/docs/tree/template-assets.doc.mjs +64 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +109 -0
- package/assets/docs/tree/template-fonts.doc.mjs +102 -0
- package/assets/docs/tree/template-grading-rubric.doc.mjs +452 -0
- package/assets/docs/tree/template-icons.doc.mjs +97 -0
- package/assets/docs/tree/template-images-media.doc.mjs +127 -0
- package/assets/docs/tree/template-styles.doc.mjs +93 -0
- package/assets/docs/tree/templates.doc.mjs +34 -0
- package/assets/docs/tree/test-in-an-app.doc.mjs +115 -0
- package/assets/docs/tree/test-template-in-app.doc.mjs +128 -0
- package/assets/docs/tree/themes.doc.mjs +39 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +149 -0
- package/assets/docs/tree/upgrading.doc.mjs +103 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +51 -0
- package/assets/docs/tree/verify-packed-template.doc.mjs +77 -0
- package/assets/docs/tree/versioning.doc.mjs +161 -0
- package/assets/docs/tree/write-good-templates.doc.mjs +64 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +154 -0
- package/assets/docs/typography.doc.mjs +24 -4
- package/assets/docs/working-with-ai.doc.mjs +34 -26
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
- 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/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
- package/assets/templates/blocks/components/Timer/TimerFormats.doc.mjs +14 -0
- package/assets/templates/blocks/components/Timer/TimerFormats.tsx +34 -0
- package/assets/templates/blocks/components/Timer/TimerInline.doc.mjs +14 -0
- package/assets/templates/blocks/components/Timer/TimerInline.tsx +14 -0
- package/assets/templates/blocks/components/Timer/TimerShowcase.doc.mjs +13 -0
- package/assets/templates/blocks/components/Timer/TimerShowcase.tsx +47 -0
- package/assets/templates/blocks/components/Timer/TimerTypography.doc.mjs +14 -0
- package/assets/templates/blocks/components/Timer/TimerTypography.tsx +31 -0
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.doc.mjs +19 -3
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +383 -65
- 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/codemod/type.ts +12 -0
- package/authoring/config/config.doc.mjs +11 -3
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +15 -13
- package/authoring/config/parse.mjs +27 -8
- package/authoring/config/parse.test.mjs +8 -0
- package/authoring/config/type.ts +29 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +8 -8
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/discover/discover.doc.d.mts +13 -0
- package/authoring/discover/discover.doc.mjs +138 -0
- package/authoring/discover/parse.d.mts +24 -0
- package/authoring/discover/parse.mjs +128 -0
- package/authoring/discover/parse.test.mjs +124 -0
- package/authoring/discover/type.ts +87 -0
- package/authoring/doctypes/_schema.d.mts +792 -24
- package/authoring/doctypes/_schema.mjs +549 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +64 -0
- package/authoring/doctypes/base/type.ts +43 -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 +5 -4
- package/authoring/doctypes/component/component.doc.mjs +12 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +14 -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 +7 -2
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +9 -4
- 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 +233 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +128 -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 +163 -0
- package/authoring/doctypes/namespace/type.ts +74 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -11
- 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 +55 -6
- package/authoring/doctypes/reference/type.ts +75 -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 +2 -2
- package/authoring/doctypes/schema/type.ts +4 -4
- package/authoring/doctypes/template/parse.d.mts +94 -1
- package/authoring/doctypes/template/parse.mjs +40 -2
- package/authoring/doctypes/template/parse.test.mjs +26 -2
- package/authoring/doctypes/template/template.doc.mjs +13 -3
- package/authoring/doctypes/template/type.ts +13 -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 +3 -0
- package/authoring/index.d.ts +62 -17
- package/authoring/index.mjs +4 -1
- package/authoring/integration/integration.doc.mjs +22 -13
- 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 +19 -8
- 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.adaptations.test.mjs +100 -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 +16 -50
- 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 +16 -8
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +137 -114
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +81 -0
- package/clients/cli/commands/component/index.mjs +153 -61
- package/clients/cli/commands/component-batch.test.mjs +341 -0
- package/clients/cli/commands/component-ownership.test.mjs +92 -3
- 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 +28 -10
- 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 +52 -5
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +55 -9
- package/clients/cli/commands/discover.mjs +393 -118
- package/clients/cli/commands/discover.sources.test.mjs +267 -0
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +28 -6
- package/clients/cli/commands/docs.mjs +295 -38
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +6 -5
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +15 -8
- 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 +143 -8
- package/clients/cli/commands/doctor.doc.mjs +4 -2
- package/clients/cli/commands/doctor.mjs +108 -37
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +27 -15
- 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 +24 -10
- 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 +39 -13
- package/clients/cli/commands/integration-authoring.test.mjs +74 -19
- package/clients/cli/commands/integration-pack.doc.mjs +6 -10
- package/clients/cli/commands/integration-real-world.test.mjs +4 -10
- package/clients/cli/commands/integration-verify.doc.mjs +22 -0
- package/clients/cli/commands/integration.doc.mjs +5 -5
- package/clients/cli/commands/integration.mjs +75 -43
- 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 +2 -2
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +16 -6
- package/clients/cli/commands/search.mjs +49 -11
- package/clients/cli/commands/search.test.mjs +92 -0
- package/clients/cli/commands/setup-nudge.test.mjs +6 -0
- package/clients/cli/commands/swizzle.doc.mjs +4 -3
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +53 -14
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.mjs +4 -91
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/text-json-parity.test.mjs +725 -0
- package/clients/cli/commands/theme-add.doc.mjs +5 -4
- 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 +12 -7
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +2 -3
- package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
- package/clients/cli/commands/theme-targets.doc.mjs +3 -3
- 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 +3 -2
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +83 -12
- package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
- 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/commands/upgrade.mjs +29 -7
- package/clients/cli/formatters/index.mjs +164 -1
- package/clients/cli/formatters/index.test.mjs +97 -0
- package/clients/cli/index.mjs +47 -34
- 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 +56 -6
- package/clients/cli/lib/define-command.test.mjs +54 -0
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +113 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +62 -16
- 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 +53 -6
- package/clients/cli/lib/manifest.test.mjs +22 -2
- package/clients/cli/lib/parse-error-format.test.mjs +81 -0
- package/foundation/agent-docs/agent-docs.d.mts +7 -2
- package/foundation/agent-docs/agent-docs.mjs +83 -13
- 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 +20 -11
- package/foundation/config/project.mjs +263 -91
- package/foundation/config/project.test.mjs +270 -21
- package/foundation/discovery/authoring-self-docs.d.mts +87 -0
- package/foundation/discovery/authoring-self-docs.mjs +237 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +174 -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 +119 -0
- package/foundation/discovery/cli-self-docs.mjs +504 -0
- package/foundation/discovery/cli-self-docs.test.mjs +395 -0
- package/foundation/discovery/component-discovery.d.mts +39 -1
- package/foundation/discovery/component-discovery.mjs +50 -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 +119 -11
- package/foundation/discovery/docs-discovery.mjs +427 -108
- package/foundation/discovery/docs-discovery.test.mjs +386 -20
- 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 +116 -0
- package/foundation/discovery/docs-section-key.mjs +322 -0
- package/foundation/discovery/docs-section-key.test.mjs +246 -0
- package/foundation/discovery/template-adapter.d.mts +113 -11
- 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 +774 -83
- package/foundation/discovery/template-adapter.test.mjs +57 -0
- package/foundation/discovery/template-conflict-release.d.mts +13 -0
- package/foundation/discovery/template-conflict-release.mjs +40 -0
- package/foundation/discovery/template-conflict-release.test.mjs +40 -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 +278 -0
- package/foundation/doc-compiler/bundle.test.mjs +266 -0
- package/foundation/doc-compiler/compile.d.mts +343 -0
- package/foundation/doc-compiler/compile.mjs +558 -0
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +305 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1643 -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 +291 -0
- package/foundation/doc-compiler/inputs.test.mjs +298 -0
- package/foundation/doc-compiler/ir.d.mts +22 -0
- package/foundation/doc-compiler/ir.mjs +471 -0
- package/foundation/doc-compiler/lenses.d.mts +36 -0
- package/foundation/doc-compiler/lenses.mjs +173 -0
- package/foundation/doc-compiler/links.d.mts +162 -0
- package/foundation/doc-compiler/links.mjs +294 -0
- package/foundation/doc-compiler/links.test.mjs +192 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +495 -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 +127 -0
- package/foundation/doc-compiler/read.mjs +325 -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/doc-compiler/tree.d.mts +292 -0
- package/foundation/doc-compiler/tree.mjs +881 -0
- package/foundation/fs/file-protection.d.mts +33 -0
- package/foundation/fs/file-protection.mjs +825 -0
- package/foundation/fs/file-protection.test.mjs +250 -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/autolink.test.mjs +1 -1
- package/foundation/integrations/cli-requirement.d.mts +65 -0
- package/foundation/integrations/cli-requirement.mjs +189 -0
- package/foundation/integrations/cli-requirement.test.mjs +89 -0
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +3 -2
- package/foundation/integrations/contribution-inventory.mjs +28 -25
- package/foundation/integrations/contribution-inventory.test.mjs +86 -27
- package/foundation/integrations/integration-warnings.d.mts +9 -2
- package/foundation/integrations/integration-warnings.mjs +52 -21
- package/foundation/integrations/integration-warnings.test.mjs +74 -1
- package/foundation/integrations/integrations.d.mts +63 -3
- package/foundation/integrations/integrations.mjs +122 -9
- package/foundation/integrations/integrations.test.mjs +415 -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 +131 -29
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/batch.type.d.mts +33 -0
- package/foundation/response/batch.type.mjs +34 -0
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +2 -0
- package/foundation/response/error-codes.doc.mjs +19 -12
- package/foundation/response/error-codes.mjs +8 -2
- package/foundation/response/error-codes.test.mjs +166 -14
- 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.d.mts +7 -2
- package/foundation/response/response-types.doc.mjs +69 -25
- package/foundation/response/response-types.doc.test.mjs +181 -0
- package/foundation/response/response.doc.mjs +12 -11
- package/foundation/text/string-utils.d.mts +8 -0
- package/foundation/text/string-utils.mjs +40 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +4 -3
- package/foundation/xle/expand.test.mjs +54 -0
- package/foundation/xle/xle.test.mjs +13 -0
- package/package.json +10 -11
- package/api/docs/docs.test.mjs +0 -83
- package/api/docs/integrationDocs.test.mjs +0 -208
- package/api/search/search.test.mjs +0 -389
- package/assets/docs/cli-integrations.doc.mjs +0 -367
- package/assets/templates/themes/manifest.json +0 -95
- package/clients/cli/commands/docs.test.mjs +0 -102
- 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
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1141
|
@@ -1,1141 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
4
|
-
import * as fs from 'node:fs';
|
|
5
|
-
import * as path from 'node:path';
|
|
6
|
-
import * as os from 'node:os';
|
|
7
|
-
import {
|
|
8
|
-
generateCompressedIndex,
|
|
9
|
-
detectStylingSystem,
|
|
10
|
-
getXdsVersion,
|
|
11
|
-
installAgentDocs,
|
|
12
|
-
injectAgentsMd,
|
|
13
|
-
injectClaudeMd,
|
|
14
|
-
injectXdsBlock,
|
|
15
|
-
removeAgentDocs,
|
|
16
|
-
removeXdsBlock,
|
|
17
|
-
discoverAgentDocs,
|
|
18
|
-
resolveAgentPaths,
|
|
19
|
-
parseBlockVersion,
|
|
20
|
-
renderAgentDocsBlock,
|
|
21
|
-
inspectAgentDocs,
|
|
22
|
-
isAstryxInitialized,
|
|
23
|
-
} from './agent-docs.mjs';
|
|
24
|
-
|
|
25
|
-
let tmpDir;
|
|
26
|
-
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-agent-docs-test-'));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterEach(() => {
|
|
32
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
33
|
-
vi.restoreAllMocks();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('generateCompressedIndex', () => {
|
|
37
|
-
it('includes the version number', () => {
|
|
38
|
-
const result = generateCompressedIndex('1.2.3');
|
|
39
|
-
expect(result).toContain('Astryx v1.2.3');
|
|
40
|
-
expect(result).toContain('<!-- ASTRYX:START -->');
|
|
41
|
-
expect(result).toContain('<!-- ASTRYX:END -->');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('includes theme nudge rule', () => {
|
|
45
|
-
const result = generateCompressedIndex('1.0.0');
|
|
46
|
-
expect(result).toMatch(/astryx theme/);
|
|
47
|
-
expect(result).toMatch(/never override --color-/);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('sends frame choice to the layout doc rather than naming a shell', () => {
|
|
51
|
-
const result = generateCompressedIndex('1.0.0');
|
|
52
|
-
const frameRule = result.split('\n').find(l => l.includes('Frame first'));
|
|
53
|
-
expect(frameRule).toContain('astryx docs layout');
|
|
54
|
-
expect(result).not.toMatch(/AppShell/);
|
|
55
|
-
expect(frameRule).not.toMatch(/https?:/);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('includes the post-generation self-check rule', () => {
|
|
59
|
-
const result = generateCompressedIndex('1.0.0');
|
|
60
|
-
expect(result).toContain('SELF-CHECK before you finish');
|
|
61
|
-
expect(result).toMatch(/re-read the file/);
|
|
62
|
-
expect(result).toMatch(/don't hand-roll CSS/);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('tailors the self-check to the styling system (xstyle for StyleX, not className for Tailwind)', () => {
|
|
66
|
-
// StyleX path: className/inline style are veers; the fix is the xstyle prop + a token
|
|
67
|
-
const stylex = generateCompressedIndex('1.0.0', {stylingSystem: 'stylex'});
|
|
68
|
-
const stylexSelfCheck = stylex.split('\n').find(l => l.includes('SELF-CHECK'));
|
|
69
|
-
expect(stylexSelfCheck).toMatch(/xstyle/);
|
|
70
|
-
expect(stylexSelfCheck).toMatch(/className=/);
|
|
71
|
-
// className IS the system in Tailwind — it must NOT be flagged
|
|
72
|
-
const tailwind = generateCompressedIndex('1.0.0', {stylingSystem: 'tailwind'});
|
|
73
|
-
const tailwindSelfCheck = tailwind.split('\n').find(l => l.includes('SELF-CHECK'));
|
|
74
|
-
expect(tailwindSelfCheck).toBeDefined();
|
|
75
|
-
expect(tailwindSelfCheck).not.toMatch(/className=/);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('defaults to the CSS-variable styling path (no compiler)', () => {
|
|
79
|
-
const result = generateCompressedIndex('1.0.0');
|
|
80
|
-
expect(result).toMatch(/style\/className with tokens/);
|
|
81
|
-
expect(result).toMatch(/var\(--color-\*/);
|
|
82
|
-
// Must NOT push xstyle when no StyleX compiler is present.
|
|
83
|
-
expect(result).not.toMatch(/xstyle prop/);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('recommends xstyle when StyleX is configured', () => {
|
|
87
|
-
const result = generateCompressedIndex('1.0.0', {stylingSystem: 'stylex'});
|
|
88
|
-
expect(result).toMatch(/xstyle prop \/ StyleX tokens/);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('recommends Tailwind utilities when Tailwind is configured', () => {
|
|
92
|
-
const result = generateCompressedIndex('1.0.0', {stylingSystem: 'tailwind'});
|
|
93
|
-
expect(result).toMatch(/Tailwind utilities backed by tokens/);
|
|
94
|
-
expect(result).toMatch(/tailwind-theme\.css/);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('includes upgrade command and migration rule', () => {
|
|
98
|
-
const result = generateCompressedIndex('1.0.0');
|
|
99
|
-
expect(result).toContain('upgrade --apply');
|
|
100
|
-
expect(result).toMatch(/after any Astryx or integration dependency bump/);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('states the invocation once in the CLI header (yarn)', () => {
|
|
104
|
-
const result = generateCompressedIndex('1.0.0', {invocation: 'yarn astryx'});
|
|
105
|
-
expect(result).toContain('yarn astryx <cmd>');
|
|
106
|
-
expect(result).not.toContain('npx astryx');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('uses the pnpm exec invocation', () => {
|
|
110
|
-
const result = generateCompressedIndex('1.0.0', {invocation: 'pnpm exec astryx'});
|
|
111
|
-
expect(result).toContain('pnpm exec astryx <cmd>');
|
|
112
|
-
expect(result).not.toContain('npx astryx');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('uses the scoped package for one-off (uninstalled) runs so agents never hit the bare name', () => {
|
|
116
|
-
const result = generateCompressedIndex('1.0.0', {invocation: 'npx @astryxdesign/cli'});
|
|
117
|
-
expect(result).toContain('npx @astryxdesign/cli <cmd>');
|
|
118
|
-
// The header defines the mapping; the bare "run every command as `npx astryx`" footgun must be absent.
|
|
119
|
-
expect(result).not.toContain('npx astryx <cmd>');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
/** The `docs <topic> a, b, c` line of the block. */
|
|
123
|
-
function topicLine(block) {
|
|
124
|
-
return (
|
|
125
|
-
block.split('\n').find(line => line.trimStart().startsWith('docs <topic>')) ?? ''
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
it('names the hyphenated topics, which the scan used to drop', () => {
|
|
130
|
-
// The fallback scan matched `\w+`, which does not match `-`, so five real
|
|
131
|
-
// topics were missing from every block ever written. An agent cannot ask
|
|
132
|
-
// for a topic it was never told about, and `getting-started` — the one it
|
|
133
|
-
// should reach for first — was one of them.
|
|
134
|
-
const line = topicLine(generateCompressedIndex('1.0.0'));
|
|
135
|
-
for (const topic of [
|
|
136
|
-
'getting-started',
|
|
137
|
-
'cli-integrations',
|
|
138
|
-
'browser-support',
|
|
139
|
-
'styling-libraries',
|
|
140
|
-
'working-with-ai',
|
|
141
|
-
]) {
|
|
142
|
-
expect(line).toContain(topic);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('lists the topics it is given, so an integration’s reach the agent', () => {
|
|
147
|
-
const line = topicLine(
|
|
148
|
-
generateCompressedIndex('1.0.0', {topics: ['tokens', 'deploying']}),
|
|
149
|
-
);
|
|
150
|
-
expect(line).toContain('tokens, deploying');
|
|
151
|
-
// The project's catalog replaces the built-in scan rather than adding to it:
|
|
152
|
-
// a topic an integration replaced must not also be listed under its old name.
|
|
153
|
-
expect(line).not.toContain('typography');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('omits the line entirely when the project has no topics', () => {
|
|
157
|
-
expect(topicLine(generateCompressedIndex('1.0.0', {topics: []}))).toBe('');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('is byte-identical when integrations contribute no lines', () => {
|
|
161
|
-
const options = {
|
|
162
|
-
invocation: 'npx @astryxdesign/cli',
|
|
163
|
-
stylingSystem: 'css',
|
|
164
|
-
topics: ['tokens', 'working-with-ai'],
|
|
165
|
-
};
|
|
166
|
-
expect(generateCompressedIndex('1.0.0', {...options, agentDocs: []})).toBe(
|
|
167
|
-
generateCompressedIndex('1.0.0', options),
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('appends package-labeled lines after core guidance in config order', () => {
|
|
172
|
-
const result = generateCompressedIndex('1.0.0', {
|
|
173
|
-
topics: [],
|
|
174
|
-
agentDocs: [
|
|
175
|
-
{
|
|
176
|
-
package: '@acme/second',
|
|
177
|
-
append: ['second one', 'second two'],
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
package: '@acme/first',
|
|
181
|
-
append: ['first one'],
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
expect(result.indexOf('upgrade --apply')).toBeLessThan(
|
|
187
|
-
result.indexOf('INTEGRATIONS:'),
|
|
188
|
-
);
|
|
189
|
-
expect(result.indexOf('INTEGRATIONS:')).toBeLessThan(
|
|
190
|
-
result.indexOf('<!-- ASTRYX:END -->'),
|
|
191
|
-
);
|
|
192
|
-
expect(result).toContain(
|
|
193
|
-
'INTEGRATIONS:\n' +
|
|
194
|
-
'- `@acme/second`: second one\n' +
|
|
195
|
-
'- `@acme/second`: second two\n' +
|
|
196
|
-
'- `@acme/first`: first one',
|
|
197
|
-
);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('caps the configured project at 32 integration lines', () => {
|
|
201
|
-
const agentDocs = Array.from({length: 5}, (_, packageIndex) => ({
|
|
202
|
-
package: `@acme/package-${packageIndex}`,
|
|
203
|
-
append: Array.from(
|
|
204
|
-
{length: packageIndex === 4 ? 1 : 8},
|
|
205
|
-
(_, lineIndex) => `line ${lineIndex}`,
|
|
206
|
-
),
|
|
207
|
-
}));
|
|
208
|
-
expect(() => generateCompressedIndex('1.0.0', {agentDocs})).toThrow(
|
|
209
|
-
/32-line project limit/,
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('renderAgentDocsBlock', () => {
|
|
215
|
-
it('produces repeatable target bytes from configured manifests', async () => {
|
|
216
|
-
const projectDir = fs.mkdtempSync(
|
|
217
|
-
path.join(process.cwd(), '.astryx-agent-doc-render-'),
|
|
218
|
-
);
|
|
219
|
-
try {
|
|
220
|
-
fs.writeFileSync(
|
|
221
|
-
path.join(projectDir, 'package.json'),
|
|
222
|
-
JSON.stringify({name: 'consumer'}),
|
|
223
|
-
);
|
|
224
|
-
fs.writeFileSync(
|
|
225
|
-
path.join(projectDir, 'astryx.config.mjs'),
|
|
226
|
-
`export default {integrations: ['@acme/second', '@acme/first']};\n`,
|
|
227
|
-
);
|
|
228
|
-
const coreDir = path.join(
|
|
229
|
-
projectDir,
|
|
230
|
-
'node_modules',
|
|
231
|
-
'@astryxdesign',
|
|
232
|
-
'core',
|
|
233
|
-
);
|
|
234
|
-
fs.mkdirSync(coreDir, {recursive: true});
|
|
235
|
-
fs.writeFileSync(
|
|
236
|
-
path.join(coreDir, 'package.json'),
|
|
237
|
-
JSON.stringify({name: '@astryxdesign/core', version: '1.0.0'}),
|
|
238
|
-
);
|
|
239
|
-
for (const [name, agentDocs] of [
|
|
240
|
-
['@acme/second', {append: ['second one', 'second two']}],
|
|
241
|
-
['@acme/first', {append: ['first one']}],
|
|
242
|
-
]) {
|
|
243
|
-
const packageDir = path.join(
|
|
244
|
-
projectDir,
|
|
245
|
-
'node_modules',
|
|
246
|
-
...name.split('/'),
|
|
247
|
-
);
|
|
248
|
-
fs.mkdirSync(packageDir, {recursive: true});
|
|
249
|
-
fs.writeFileSync(
|
|
250
|
-
path.join(packageDir, 'package.json'),
|
|
251
|
-
JSON.stringify({name}),
|
|
252
|
-
);
|
|
253
|
-
fs.writeFileSync(
|
|
254
|
-
path.join(packageDir, 'astryx.integration.mjs'),
|
|
255
|
-
`export default {agentDocs: ${JSON.stringify(agentDocs)}};\n`,
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
fs.writeFileSync(path.join(projectDir, 'AGENTS.md'), '# Agents\n');
|
|
259
|
-
fs.writeFileSync(path.join(projectDir, 'CLAUDE.md'), '# Claude\n');
|
|
260
|
-
|
|
261
|
-
const renderedBlock = await renderAgentDocsBlock(projectDir);
|
|
262
|
-
expect(renderedBlock.indexOf('second one')).toBeLessThan(
|
|
263
|
-
renderedBlock.indexOf('second two'),
|
|
264
|
-
);
|
|
265
|
-
expect(renderedBlock.indexOf('second two')).toBeLessThan(
|
|
266
|
-
renderedBlock.indexOf('first one'),
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
installAgentDocs(projectDir, {renderedBlock});
|
|
270
|
-
const firstAgents = fs.readFileSync(
|
|
271
|
-
path.join(projectDir, 'AGENTS.md'),
|
|
272
|
-
'utf-8',
|
|
273
|
-
);
|
|
274
|
-
const firstClaude = fs.readFileSync(
|
|
275
|
-
path.join(projectDir, 'CLAUDE.md'),
|
|
276
|
-
'utf-8',
|
|
277
|
-
);
|
|
278
|
-
expect(firstAgents).toContain(renderedBlock);
|
|
279
|
-
expect(firstClaude).toContain(renderedBlock);
|
|
280
|
-
|
|
281
|
-
installAgentDocs(projectDir, {renderedBlock});
|
|
282
|
-
expect(fs.readFileSync(path.join(projectDir, 'AGENTS.md'), 'utf-8')).toBe(
|
|
283
|
-
firstAgents,
|
|
284
|
-
);
|
|
285
|
-
expect(fs.readFileSync(path.join(projectDir, 'CLAUDE.md'), 'utf-8')).toBe(
|
|
286
|
-
firstClaude,
|
|
287
|
-
);
|
|
288
|
-
} finally {
|
|
289
|
-
fs.rmSync(projectDir, {recursive: true, force: true});
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
it('rejects a package label that could alter managed block structure', async () => {
|
|
293
|
-
const projectDir = fs.mkdtempSync(
|
|
294
|
-
path.join(process.cwd(), '.astryx-agent-doc-label-'),
|
|
295
|
-
);
|
|
296
|
-
try {
|
|
297
|
-
fs.writeFileSync(
|
|
298
|
-
path.join(projectDir, 'package.json'),
|
|
299
|
-
JSON.stringify({name: 'consumer'}),
|
|
300
|
-
);
|
|
301
|
-
fs.writeFileSync(
|
|
302
|
-
path.join(projectDir, 'astryx.config.mjs'),
|
|
303
|
-
`export default {integrations: ['@acme/widgets']};\n`,
|
|
304
|
-
);
|
|
305
|
-
const packageDir = path.join(
|
|
306
|
-
projectDir,
|
|
307
|
-
'node_modules',
|
|
308
|
-
'@acme',
|
|
309
|
-
'widgets',
|
|
310
|
-
);
|
|
311
|
-
fs.mkdirSync(packageDir, {recursive: true});
|
|
312
|
-
fs.writeFileSync(
|
|
313
|
-
path.join(packageDir, 'package.json'),
|
|
314
|
-
JSON.stringify({name: '@acme/widgets\nASTRYX:END'}),
|
|
315
|
-
);
|
|
316
|
-
fs.writeFileSync(
|
|
317
|
-
path.join(packageDir, 'astryx.integration.mjs'),
|
|
318
|
-
`export default {agentDocs: {append: ['safe line']}};\n`,
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
await expect(renderAgentDocsBlock(projectDir)).rejects.toThrow(
|
|
322
|
-
/not safe to render/,
|
|
323
|
-
);
|
|
324
|
-
} finally {
|
|
325
|
-
fs.rmSync(projectDir, {recursive: true, force: true});
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
describe('detectStylingSystem', () => {
|
|
331
|
-
function writePkg(deps) {
|
|
332
|
-
fs.writeFileSync(
|
|
333
|
-
path.join(tmpDir, 'package.json'),
|
|
334
|
-
JSON.stringify({name: 'x', devDependencies: deps}),
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
it('defaults to css when no package.json', () => {
|
|
339
|
-
expect(detectStylingSystem(tmpDir)).toBe('css');
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('returns css for a plain project', () => {
|
|
343
|
-
writePkg({react: '19.0.0', vite: '6.0.0'});
|
|
344
|
-
expect(detectStylingSystem(tmpDir)).toBe('css');
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it('detects stylex when the compiler plugin is present', () => {
|
|
348
|
-
writePkg({'@stylexjs/babel-plugin': '0.0.1'});
|
|
349
|
-
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it('detects tailwind when tailwindcss is present', () => {
|
|
353
|
-
writePkg({tailwindcss: '4.0.0'});
|
|
354
|
-
expect(detectStylingSystem(tmpDir)).toBe('tailwind');
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('does NOT treat the StyleX runtime alone as a compiler', () => {
|
|
358
|
-
// Only the runtime, no compiler plugin → must stay on the safe css path.
|
|
359
|
-
writePkg({'@stylexjs/stylex': '0.0.1'});
|
|
360
|
-
expect(detectStylingSystem(tmpDir)).toBe('css');
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it('prefers stylex over tailwind when both are configured', () => {
|
|
364
|
-
writePkg({'@stylexjs/babel-plugin': '0.0.1', tailwindcss: '4.0.0'});
|
|
365
|
-
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
describe('getXdsVersion', () => {
|
|
370
|
-
it('reads version from core package.json', () => {
|
|
371
|
-
const coreDir = path.join(tmpDir, 'core');
|
|
372
|
-
fs.mkdirSync(coreDir, {recursive: true});
|
|
373
|
-
fs.writeFileSync(
|
|
374
|
-
path.join(coreDir, 'package.json'),
|
|
375
|
-
JSON.stringify({version: '3.4.5'}),
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
expect(getXdsVersion(coreDir)).toBe('3.4.5');
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
describe('injectXdsBlock', () => {
|
|
383
|
-
it('injects into an existing file without markers', () => {
|
|
384
|
-
const filePath = path.join(tmpDir, 'test.md');
|
|
385
|
-
fs.writeFileSync(filePath, '# Existing content\n');
|
|
386
|
-
|
|
387
|
-
const result = injectXdsBlock(filePath, '<!-- ASTRYX:START -->\nnew\n<!-- ASTRYX:END -->');
|
|
388
|
-
|
|
389
|
-
expect(result).toBe(true);
|
|
390
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
391
|
-
expect(content).toContain('# Existing content');
|
|
392
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
it('replaces existing markers', () => {
|
|
396
|
-
const filePath = path.join(tmpDir, 'test.md');
|
|
397
|
-
fs.writeFileSync(filePath, 'before\n<!-- XDS:START -->\nold\n<!-- XDS:END -->\nafter\n');
|
|
398
|
-
|
|
399
|
-
injectXdsBlock(filePath, '<!-- ASTRYX:START -->\nnew\n<!-- ASTRYX:END -->');
|
|
400
|
-
|
|
401
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
402
|
-
expect(content).toContain('new');
|
|
403
|
-
expect(content).not.toContain('old');
|
|
404
|
-
expect(content).toContain('before');
|
|
405
|
-
expect(content).toContain('after');
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
it('returns false and does not create file when createIfMissing is false', () => {
|
|
409
|
-
const filePath = path.join(tmpDir, 'nonexistent.md');
|
|
410
|
-
|
|
411
|
-
const result = injectXdsBlock(filePath, '<!-- ASTRYX:START -->\ncontent\n<!-- ASTRYX:END -->');
|
|
412
|
-
|
|
413
|
-
expect(result).toBe(false);
|
|
414
|
-
expect(fs.existsSync(filePath)).toBe(false);
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
it('skips files without markers when onlyReplace is true', () => {
|
|
418
|
-
const filePath = path.join(tmpDir, 'test.md');
|
|
419
|
-
fs.writeFileSync(filePath, '# Existing content\n\nNo XDS markers here.\n');
|
|
420
|
-
|
|
421
|
-
const result = injectXdsBlock(filePath, '<!-- ASTRYX:START -->\nnew\n<!-- ASTRYX:END -->', {onlyReplace: true});
|
|
422
|
-
|
|
423
|
-
expect(result).toBe(false);
|
|
424
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
425
|
-
expect(content).not.toContain('<!-- ASTRYX:START -->');
|
|
426
|
-
expect(content).toBe('# Existing content\n\nNo XDS markers here.\n');
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
it('replaces existing markers even when onlyReplace is true', () => {
|
|
430
|
-
const filePath = path.join(tmpDir, 'test.md');
|
|
431
|
-
fs.writeFileSync(filePath, 'before\n<!-- XDS:START -->\nold\n<!-- XDS:END -->\nafter\n');
|
|
432
|
-
|
|
433
|
-
const result = injectXdsBlock(filePath, '<!-- ASTRYX:START -->\nnew\n<!-- ASTRYX:END -->', {onlyReplace: true});
|
|
434
|
-
|
|
435
|
-
expect(result).toBe(true);
|
|
436
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
437
|
-
expect(content).toContain('new');
|
|
438
|
-
expect(content).not.toContain('old');
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
it('creates file when createIfMissing is true', () => {
|
|
442
|
-
const filePath = path.join(tmpDir, 'new.md');
|
|
443
|
-
|
|
444
|
-
const result = injectXdsBlock(filePath, '<!-- ASTRYX:START -->\ncontent\n<!-- ASTRYX:END -->', {
|
|
445
|
-
createIfMissing: true,
|
|
446
|
-
header: '# Header',
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
expect(result).toBe(true);
|
|
450
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
451
|
-
expect(content).toContain('# Header');
|
|
452
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
describe('injectAgentsMd', () => {
|
|
457
|
-
it('creates new AGENTS.md when none exists', () => {
|
|
458
|
-
injectAgentsMd(tmpDir, '1.0.0');
|
|
459
|
-
|
|
460
|
-
const content = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
461
|
-
expect(content).toContain('# AGENTS.md');
|
|
462
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
463
|
-
expect(content).toContain('Astryx v1.0.0');
|
|
464
|
-
expect(content).toContain('<!-- ASTRYX:END -->');
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
it('updates existing AGENTS.md by replacing XDS markers', () => {
|
|
468
|
-
const existing = `# My Project
|
|
469
|
-
|
|
470
|
-
Some content.
|
|
471
|
-
|
|
472
|
-
<!-- XDS:START -->
|
|
473
|
-
old content
|
|
474
|
-
<!-- XDS:END -->
|
|
475
|
-
|
|
476
|
-
More stuff.
|
|
477
|
-
`;
|
|
478
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), existing);
|
|
479
|
-
|
|
480
|
-
injectAgentsMd(tmpDir, '2.0.0');
|
|
481
|
-
|
|
482
|
-
const content = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
483
|
-
expect(content).toContain('Astryx v2.0.0');
|
|
484
|
-
expect(content).not.toContain('old content');
|
|
485
|
-
expect(content).toContain('Some content.');
|
|
486
|
-
expect(content).toContain('More stuff.');
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
it('appends to existing AGENTS.md without markers', () => {
|
|
490
|
-
const existing = `# My Project
|
|
491
|
-
|
|
492
|
-
Existing agent docs.
|
|
493
|
-
`;
|
|
494
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), existing);
|
|
495
|
-
|
|
496
|
-
injectAgentsMd(tmpDir, '1.0.0');
|
|
497
|
-
|
|
498
|
-
const content = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
499
|
-
expect(content).toContain('Existing agent docs.');
|
|
500
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
501
|
-
expect(content).toContain('Astryx v1.0.0');
|
|
502
|
-
});
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
describe('injectClaudeMd', () => {
|
|
506
|
-
it('injects into existing CLAUDE.md', () => {
|
|
507
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '# Claude Config\n\nExisting rules.\n');
|
|
508
|
-
|
|
509
|
-
const result = injectClaudeMd(tmpDir, '1.0.0');
|
|
510
|
-
|
|
511
|
-
expect(result).toBe(true);
|
|
512
|
-
const content = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
513
|
-
expect(content).toContain('# Claude Config');
|
|
514
|
-
expect(content).toContain('Existing rules.');
|
|
515
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
516
|
-
expect(content).toContain('Astryx v1.0.0');
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it('does not create CLAUDE.md when it does not exist', () => {
|
|
520
|
-
const result = injectClaudeMd(tmpDir, '1.0.0');
|
|
521
|
-
|
|
522
|
-
expect(result).toBe(false);
|
|
523
|
-
expect(fs.existsSync(path.join(tmpDir, 'CLAUDE.md'))).toBe(false);
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
it('updates existing markers in CLAUDE.md', () => {
|
|
527
|
-
const existing = `# Claude Config
|
|
528
|
-
|
|
529
|
-
<!-- XDS:START -->
|
|
530
|
-
old content
|
|
531
|
-
<!-- XDS:END -->
|
|
532
|
-
|
|
533
|
-
Other rules.
|
|
534
|
-
`;
|
|
535
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), existing);
|
|
536
|
-
|
|
537
|
-
injectClaudeMd(tmpDir, '2.0.0');
|
|
538
|
-
|
|
539
|
-
const content = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
540
|
-
expect(content).toContain('Astryx v2.0.0');
|
|
541
|
-
expect(content).not.toContain('old content');
|
|
542
|
-
expect(content).toContain('Other rules.');
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
describe('removeAgentDocs', () => {
|
|
547
|
-
it('removes XDS section from AGENTS.md', () => {
|
|
548
|
-
const content = `# My Project
|
|
549
|
-
|
|
550
|
-
Custom content here.
|
|
551
|
-
|
|
552
|
-
<!-- XDS:START -->
|
|
553
|
-
XDS index stuff
|
|
554
|
-
<!-- XDS:END -->
|
|
555
|
-
|
|
556
|
-
More custom content.
|
|
557
|
-
`;
|
|
558
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), content);
|
|
559
|
-
vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
560
|
-
|
|
561
|
-
removeAgentDocs(tmpDir);
|
|
562
|
-
|
|
563
|
-
const result = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
564
|
-
expect(result).toContain('Custom content here.');
|
|
565
|
-
expect(result).toContain('More custom content.');
|
|
566
|
-
expect(result).not.toContain('<!-- XDS:START -->');
|
|
567
|
-
expect(result).not.toContain('XDS index stuff');
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
it('removes the file entirely when only XDS content remains', () => {
|
|
571
|
-
const content = `# AGENTS.md
|
|
572
|
-
|
|
573
|
-
Project-specific guidance for AI coding agents.
|
|
574
|
-
|
|
575
|
-
<!-- XDS:START -->
|
|
576
|
-
XDS index stuff
|
|
577
|
-
<!-- XDS:END -->
|
|
578
|
-
`;
|
|
579
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), content);
|
|
580
|
-
vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
581
|
-
|
|
582
|
-
removeAgentDocs(tmpDir);
|
|
583
|
-
|
|
584
|
-
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(false);
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
it('removes XDS section from CLAUDE.md when present', () => {
|
|
588
|
-
fs.writeFileSync(
|
|
589
|
-
path.join(tmpDir, 'AGENTS.md'),
|
|
590
|
-
'# AGENTS.md\n\n<!-- XDS:START -->\nstuff\n<!-- XDS:END -->\n',
|
|
591
|
-
);
|
|
592
|
-
fs.writeFileSync(
|
|
593
|
-
path.join(tmpDir, 'CLAUDE.md'),
|
|
594
|
-
'# Claude\n\nRules.\n\n<!-- XDS:START -->\nstuff\n<!-- XDS:END -->\n\nMore rules.\n',
|
|
595
|
-
);
|
|
596
|
-
vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
597
|
-
|
|
598
|
-
removeAgentDocs(tmpDir);
|
|
599
|
-
|
|
600
|
-
const claudeContent = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
601
|
-
expect(claudeContent).toContain('Rules.');
|
|
602
|
-
expect(claudeContent).toContain('More rules.');
|
|
603
|
-
expect(claudeContent).not.toContain('<!-- XDS:START -->');
|
|
604
|
-
});
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
describe('installAgentDocs', () => {
|
|
608
|
-
function setupCorePackage(dir, version = '1.0.0') {
|
|
609
|
-
// Create a minimal @astryxdesign/core so getXdsVersion works
|
|
610
|
-
const coreDir = path.join(dir, 'node_modules', '@astryxdesign', 'core');
|
|
611
|
-
fs.mkdirSync(coreDir, {recursive: true});
|
|
612
|
-
fs.writeFileSync(
|
|
613
|
-
path.join(coreDir, 'package.json'),
|
|
614
|
-
JSON.stringify({version}),
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
it('creates AGENTS.md when no agent docs exist (tool-agnostic default)', () => {
|
|
619
|
-
setupCorePackage(tmpDir);
|
|
620
|
-
|
|
621
|
-
const written = installAgentDocs(tmpDir);
|
|
622
|
-
|
|
623
|
-
expect(written).toEqual(['AGENTS.md']);
|
|
624
|
-
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(true);
|
|
625
|
-
// Must NOT create the Claude-specific file by default.
|
|
626
|
-
expect(fs.existsSync(path.join(tmpDir, '.claude', 'CLAUDE.md'))).toBe(false);
|
|
627
|
-
const content = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
628
|
-
expect(content).toContain('# AGENTS.md');
|
|
629
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
it('defaults to AGENTS.md but writes .claude/CLAUDE.md only when --agent claude is explicit', () => {
|
|
633
|
-
// Default (no agent): tool-agnostic AGENTS.md, never the Claude file.
|
|
634
|
-
setupCorePackage(tmpDir);
|
|
635
|
-
expect(installAgentDocs(tmpDir)).toEqual(['AGENTS.md']);
|
|
636
|
-
expect(fs.existsSync(path.join(tmpDir, '.claude', 'CLAUDE.md'))).toBe(false);
|
|
637
|
-
|
|
638
|
-
// Explicit Claude: the Claude-specific file, in a fresh project.
|
|
639
|
-
const claudeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-agent-docs-claude-'));
|
|
640
|
-
setupCorePackage(claudeDir);
|
|
641
|
-
try {
|
|
642
|
-
expect(installAgentDocs(claudeDir, {agent: 'claude'})).toEqual(['.claude/CLAUDE.md']);
|
|
643
|
-
expect(fs.existsSync(path.join(claudeDir, 'AGENTS.md'))).toBe(false);
|
|
644
|
-
} finally {
|
|
645
|
-
fs.rmSync(claudeDir, {recursive: true, force: true});
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
it('injects into CLAUDE.md at root when it exists', () => {
|
|
650
|
-
setupCorePackage(tmpDir);
|
|
651
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '# Claude\n\nProject rules.\n');
|
|
652
|
-
|
|
653
|
-
const written = installAgentDocs(tmpDir);
|
|
654
|
-
|
|
655
|
-
expect(written).toEqual(['CLAUDE.md']);
|
|
656
|
-
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(false);
|
|
657
|
-
const claudeContent = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
658
|
-
expect(claudeContent).toContain('<!-- ASTRYX:START -->');
|
|
659
|
-
expect(claudeContent).toContain('Project rules.');
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
it('injects into all existing agent doc files', () => {
|
|
663
|
-
setupCorePackage(tmpDir);
|
|
664
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), '# Agents\n\nAgent rules.\n');
|
|
665
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '# Claude\n\nClaude rules.\n');
|
|
666
|
-
|
|
667
|
-
const written = installAgentDocs(tmpDir);
|
|
668
|
-
|
|
669
|
-
expect(written).toContain('AGENTS.md');
|
|
670
|
-
expect(written).toContain('CLAUDE.md');
|
|
671
|
-
const agentsContent = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
672
|
-
const claudeContent = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
673
|
-
expect(agentsContent).toContain('<!-- ASTRYX:START -->');
|
|
674
|
-
expect(claudeContent).toContain('<!-- ASTRYX:START -->');
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
it('preserves import wrappers while initializing standalone files', () => {
|
|
678
|
-
setupCorePackage(tmpDir);
|
|
679
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), '# Agents\n');
|
|
680
|
-
fs.mkdirSync(path.join(tmpDir, '.claude'), {recursive: true});
|
|
681
|
-
const wrapperPath = path.join(tmpDir, '.claude', 'CLAUDE.md');
|
|
682
|
-
const wrapper = '@../AGENTS.md\n';
|
|
683
|
-
fs.writeFileSync(wrapperPath, wrapper);
|
|
684
|
-
fs.writeFileSync(path.join(tmpDir, '.cursorrules'), 'Cursor rules.\n');
|
|
685
|
-
|
|
686
|
-
const written = installAgentDocs(tmpDir);
|
|
687
|
-
|
|
688
|
-
expect(written).toEqual(['AGENTS.md', '.cursorrules']);
|
|
689
|
-
expect(fs.readFileSync(wrapperPath, 'utf-8')).toBe(wrapper);
|
|
690
|
-
expect(fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8')).toContain(
|
|
691
|
-
'<!-- ASTRYX:START -->',
|
|
692
|
-
);
|
|
693
|
-
expect(fs.readFileSync(path.join(tmpDir, '.cursorrules'), 'utf-8')).toContain(
|
|
694
|
-
'<!-- ASTRYX:START -->',
|
|
695
|
-
);
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
it('keeps cyclic imports standalone when another file exists', () => {
|
|
699
|
-
setupCorePackage(tmpDir);
|
|
700
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), '@CLAUDE.md\n');
|
|
701
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '@AGENTS.md\n');
|
|
702
|
-
fs.writeFileSync(path.join(tmpDir, '.cursorrules'), 'Cursor rules.\n');
|
|
703
|
-
|
|
704
|
-
const written = installAgentDocs(tmpDir);
|
|
705
|
-
|
|
706
|
-
expect(written).toEqual(['AGENTS.md', 'CLAUDE.md', '.cursorrules']);
|
|
707
|
-
for (const rel of written) {
|
|
708
|
-
expect(fs.readFileSync(path.join(tmpDir, rel), 'utf-8')).toContain(
|
|
709
|
-
'<!-- ASTRYX:START -->',
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
it('removes a managed block previously expanded into an import wrapper', () => {
|
|
715
|
-
setupCorePackage(tmpDir);
|
|
716
|
-
installAgentDocs(tmpDir, {agent: 'codex'});
|
|
717
|
-
fs.mkdirSync(path.join(tmpDir, '.claude'), {recursive: true});
|
|
718
|
-
const wrapperPath = path.join(tmpDir, '.claude', 'CLAUDE.md');
|
|
719
|
-
const wrapper = '@../AGENTS.md\n';
|
|
720
|
-
fs.writeFileSync(wrapperPath, wrapper);
|
|
721
|
-
installAgentDocs(tmpDir, {agent: 'claude'});
|
|
722
|
-
expect(fs.readFileSync(wrapperPath, 'utf-8')).toContain(
|
|
723
|
-
'<!-- ASTRYX:START -->',
|
|
724
|
-
);
|
|
725
|
-
|
|
726
|
-
const written = installAgentDocs(tmpDir, {onlyReplace: true});
|
|
727
|
-
|
|
728
|
-
expect(written).toContain('AGENTS.md');
|
|
729
|
-
expect(written).toContain('.claude/CLAUDE.md');
|
|
730
|
-
expect(fs.readFileSync(wrapperPath, 'utf-8')).toBe(wrapper);
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
it('refuses a malformed managed block inside an import wrapper', () => {
|
|
734
|
-
setupCorePackage(tmpDir);
|
|
735
|
-
installAgentDocs(tmpDir, {agent: 'codex'});
|
|
736
|
-
fs.mkdirSync(path.join(tmpDir, '.claude'), {recursive: true});
|
|
737
|
-
fs.writeFileSync(
|
|
738
|
-
path.join(tmpDir, '.claude', 'CLAUDE.md'),
|
|
739
|
-
'@../AGENTS.md\n<!-- ASTRYX:START -->\nincomplete\n',
|
|
740
|
-
);
|
|
741
|
-
|
|
742
|
-
expect(() => installAgentDocs(tmpDir)).toThrow(/malformed|no matching/i);
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
it('updates existing .claude/CLAUDE.md', () => {
|
|
746
|
-
setupCorePackage(tmpDir);
|
|
747
|
-
fs.mkdirSync(path.join(tmpDir, '.claude'), {recursive: true});
|
|
748
|
-
fs.writeFileSync(path.join(tmpDir, '.claude', 'CLAUDE.md'), '# Project\n\nExisting content.\n');
|
|
749
|
-
|
|
750
|
-
const written = installAgentDocs(tmpDir);
|
|
751
|
-
|
|
752
|
-
expect(written).toEqual(['.claude/CLAUDE.md']);
|
|
753
|
-
const content = fs.readFileSync(path.join(tmpDir, '.claude', 'CLAUDE.md'), 'utf-8');
|
|
754
|
-
expect(content).toContain('Existing content.');
|
|
755
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
it('respects --agent claude preset: finds existing CLAUDE.md', () => {
|
|
759
|
-
setupCorePackage(tmpDir);
|
|
760
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '# Claude\n\nRules.\n');
|
|
761
|
-
|
|
762
|
-
const written = installAgentDocs(tmpDir, {agent: 'claude'});
|
|
763
|
-
|
|
764
|
-
expect(written).toEqual(['CLAUDE.md']);
|
|
765
|
-
});
|
|
766
|
-
|
|
767
|
-
it('respects --agent claude preset: creates .claude/CLAUDE.md when nothing exists', () => {
|
|
768
|
-
setupCorePackage(tmpDir);
|
|
769
|
-
|
|
770
|
-
const written = installAgentDocs(tmpDir, {agent: 'claude'});
|
|
771
|
-
|
|
772
|
-
expect(written).toEqual(['.claude/CLAUDE.md']);
|
|
773
|
-
expect(fs.existsSync(path.join(tmpDir, '.claude', 'CLAUDE.md'))).toBe(true);
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
it('respects --agent codex preset: creates AGENTS.md', () => {
|
|
777
|
-
setupCorePackage(tmpDir);
|
|
778
|
-
|
|
779
|
-
const written = installAgentDocs(tmpDir, {agent: 'codex'});
|
|
780
|
-
|
|
781
|
-
expect(written).toEqual(['AGENTS.md']);
|
|
782
|
-
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(true);
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
it('respects --agent hermes preset: creates AGENTS.md', () => {
|
|
786
|
-
setupCorePackage(tmpDir);
|
|
787
|
-
|
|
788
|
-
const written = installAgentDocs(tmpDir, {agent: 'hermes'});
|
|
789
|
-
|
|
790
|
-
expect(written).toEqual(['AGENTS.md']);
|
|
791
|
-
const content = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
792
|
-
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
793
|
-
expect(fs.existsSync(path.join(tmpDir, '.claude'))).toBe(false);
|
|
794
|
-
});
|
|
795
|
-
|
|
796
|
-
it('respects --agent muse preset: creates AGENTS.md', () => {
|
|
797
|
-
setupCorePackage(tmpDir);
|
|
798
|
-
|
|
799
|
-
const written = installAgentDocs(tmpDir, {agent: 'muse'});
|
|
800
|
-
|
|
801
|
-
expect(written).toEqual(['AGENTS.md']);
|
|
802
|
-
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(true);
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
it('respects explicit --paths', () => {
|
|
806
|
-
setupCorePackage(tmpDir);
|
|
807
|
-
|
|
808
|
-
const written = installAgentDocs(tmpDir, {paths: ['custom/AGENT.md']});
|
|
809
|
-
|
|
810
|
-
expect(written).toEqual(['custom/AGENT.md']);
|
|
811
|
-
expect(fs.existsSync(path.join(tmpDir, 'custom', 'AGENT.md'))).toBe(true);
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
it('onlyReplace: skips files without XDS markers', () => {
|
|
815
|
-
setupCorePackage(tmpDir);
|
|
816
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '# Claude\n\nProject rules only.\n');
|
|
817
|
-
|
|
818
|
-
const written = installAgentDocs(tmpDir, {onlyReplace: true});
|
|
819
|
-
|
|
820
|
-
expect(written).toEqual([]);
|
|
821
|
-
const content = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
822
|
-
expect(content).not.toContain('<!-- ASTRYX:START -->');
|
|
823
|
-
expect(content).toBe('# Claude\n\nProject rules only.\n');
|
|
824
|
-
});
|
|
825
|
-
|
|
826
|
-
it('onlyReplace: updates files that have XDS markers', () => {
|
|
827
|
-
setupCorePackage(tmpDir, '2.0.0');
|
|
828
|
-
fs.writeFileSync(
|
|
829
|
-
path.join(tmpDir, 'CLAUDE.md'),
|
|
830
|
-
'# Claude\n\n<!-- XDS:START -->\nPLACEHOLDER_STALE_CONTENT\n<!-- XDS:END -->\n\nOther rules.\n',
|
|
831
|
-
);
|
|
832
|
-
|
|
833
|
-
const written = installAgentDocs(tmpDir, {onlyReplace: true});
|
|
834
|
-
|
|
835
|
-
expect(written).toEqual(['CLAUDE.md']);
|
|
836
|
-
const content = fs.readFileSync(path.join(tmpDir, 'CLAUDE.md'), 'utf-8');
|
|
837
|
-
expect(content).toContain('Astryx v2.0.0');
|
|
838
|
-
expect(content).not.toContain('PLACEHOLDER_STALE_CONTENT');
|
|
839
|
-
expect(content).toContain('Other rules.');
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
it('onlyReplace: does not create the default AGENTS.md when nothing exists', () => {
|
|
843
|
-
setupCorePackage(tmpDir);
|
|
844
|
-
|
|
845
|
-
const written = installAgentDocs(tmpDir, {onlyReplace: true});
|
|
846
|
-
|
|
847
|
-
expect(written).toEqual([]);
|
|
848
|
-
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(false);
|
|
849
|
-
expect(fs.existsSync(path.join(tmpDir, '.claude', 'CLAUDE.md'))).toBe(false);
|
|
850
|
-
});
|
|
851
|
-
});
|
|
852
|
-
|
|
853
|
-
describe('discoverAgentDocs', () => {
|
|
854
|
-
it('finds AGENTS.md and CLAUDE.md at root', () => {
|
|
855
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), '');
|
|
856
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '');
|
|
857
|
-
|
|
858
|
-
const found = discoverAgentDocs(tmpDir);
|
|
859
|
-
|
|
860
|
-
expect(found).toContain('AGENTS.md');
|
|
861
|
-
expect(found).toContain('CLAUDE.md');
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
it('finds .claude/CLAUDE.md', () => {
|
|
865
|
-
fs.mkdirSync(path.join(tmpDir, '.claude'), {recursive: true});
|
|
866
|
-
fs.writeFileSync(path.join(tmpDir, '.claude', 'CLAUDE.md'), '');
|
|
867
|
-
|
|
868
|
-
const found = discoverAgentDocs(tmpDir);
|
|
869
|
-
|
|
870
|
-
expect(found).toContain('.claude/CLAUDE.md');
|
|
871
|
-
});
|
|
872
|
-
|
|
873
|
-
it('returns empty when nothing exists', () => {
|
|
874
|
-
expect(discoverAgentDocs(tmpDir)).toEqual([]);
|
|
875
|
-
});
|
|
876
|
-
});
|
|
877
|
-
|
|
878
|
-
describe('resolveAgentPaths', () => {
|
|
879
|
-
it('claude preset finds existing CLAUDE.md at root', () => {
|
|
880
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '');
|
|
881
|
-
const result = resolveAgentPaths(tmpDir, 'claude');
|
|
882
|
-
expect(result).toEqual({inject: ['CLAUDE.md'], create: []});
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
it('claude preset falls back to .claude/CLAUDE.md', () => {
|
|
886
|
-
const result = resolveAgentPaths(tmpDir, 'claude');
|
|
887
|
-
expect(result).toEqual({inject: [], create: ['.claude/CLAUDE.md']});
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
it('all preset discovers existing files', () => {
|
|
891
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), '');
|
|
892
|
-
fs.writeFileSync(path.join(tmpDir, 'CLAUDE.md'), '');
|
|
893
|
-
const result = resolveAgentPaths(tmpDir, 'all');
|
|
894
|
-
expect(result.inject).toContain('AGENTS.md');
|
|
895
|
-
expect(result.inject).toContain('CLAUDE.md');
|
|
896
|
-
expect(result.create).toEqual([]);
|
|
897
|
-
});
|
|
898
|
-
|
|
899
|
-
it('all preset creates defaults when nothing exists', () => {
|
|
900
|
-
const result = resolveAgentPaths(tmpDir, 'all');
|
|
901
|
-
expect(result.inject).toEqual([]);
|
|
902
|
-
expect(result.create).toContain('AGENTS.md');
|
|
903
|
-
expect(result.create).toContain('.claude/CLAUDE.md');
|
|
904
|
-
});
|
|
905
|
-
|
|
906
|
-
it('hermes preset creates AGENTS.md when nothing exists', () => {
|
|
907
|
-
const result = resolveAgentPaths(tmpDir, 'hermes');
|
|
908
|
-
expect(result).toEqual({inject: [], create: ['AGENTS.md']});
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
it('hermes preset finds existing .hermes.md', () => {
|
|
912
|
-
fs.writeFileSync(path.join(tmpDir, '.hermes.md'), '');
|
|
913
|
-
const result = resolveAgentPaths(tmpDir, 'hermes');
|
|
914
|
-
expect(result).toEqual({inject: ['.hermes.md'], create: []});
|
|
915
|
-
});
|
|
916
|
-
|
|
917
|
-
it('hermes preset finds existing HERMES.md when no .hermes.md', () => {
|
|
918
|
-
fs.writeFileSync(path.join(tmpDir, 'HERMES.md'), '');
|
|
919
|
-
const result = resolveAgentPaths(tmpDir, 'hermes');
|
|
920
|
-
expect(result).toEqual({inject: ['HERMES.md'], create: []});
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
it('muse preset creates AGENTS.md when nothing exists', () => {
|
|
924
|
-
const result = resolveAgentPaths(tmpDir, 'muse');
|
|
925
|
-
expect(result).toEqual({inject: [], create: ['AGENTS.md']});
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
it('claude preset still creates .claude/CLAUDE.md when nothing exists (hermes is additive)', () => {
|
|
929
|
-
const result = resolveAgentPaths(tmpDir, 'claude');
|
|
930
|
-
expect(result).toEqual({inject: [], create: ['.claude/CLAUDE.md']});
|
|
931
|
-
});
|
|
932
|
-
});
|
|
933
|
-
|
|
934
|
-
describe('parseBlockVersion', () => {
|
|
935
|
-
it('reads the version from the header of a generated block', () => {
|
|
936
|
-
expect(parseBlockVersion(generateCompressedIndex('1.2.3'))).toBe('1.2.3');
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
it('reads prerelease versions', () => {
|
|
940
|
-
expect(parseBlockVersion('Astryx v1.2.3-beta.4 · 10 components')).toBe(
|
|
941
|
-
'1.2.3-beta.4',
|
|
942
|
-
);
|
|
943
|
-
});
|
|
944
|
-
|
|
945
|
-
it('returns null when no versioned header is present', () => {
|
|
946
|
-
expect(parseBlockVersion('<!-- XDS:START -->\nold\n<!-- XDS:END -->')).toBeNull();
|
|
947
|
-
expect(parseBlockVersion('')).toBeNull();
|
|
948
|
-
expect(parseBlockVersion(undefined)).toBeNull();
|
|
949
|
-
});
|
|
950
|
-
});
|
|
951
|
-
|
|
952
|
-
describe('inspectAgentDocs', () => {
|
|
953
|
-
function writeBlock(rel, version) {
|
|
954
|
-
const filePath = path.join(tmpDir, rel);
|
|
955
|
-
fs.mkdirSync(path.dirname(filePath), {recursive: true});
|
|
956
|
-
fs.writeFileSync(filePath, `# Doc\n\n${generateCompressedIndex(version)}\n`);
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
it('reports missing when no agent docs exist at all', () => {
|
|
960
|
-
const res = inspectAgentDocs(tmpDir, '1.0.0');
|
|
961
|
-
expect(res.status).toBe('missing');
|
|
962
|
-
expect(res.files).toEqual([]);
|
|
963
|
-
expect(res.staleFiles).toEqual([]);
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
it('reports missing when agent files exist but carry no Astryx marker', () => {
|
|
967
|
-
fs.writeFileSync(path.join(tmpDir, 'AGENTS.md'), '# Agents\n\nHand-written notes.\n');
|
|
968
|
-
expect(inspectAgentDocs(tmpDir, '1.0.0').status).toBe('missing');
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
it('reports current when the only block matches the installed version', () => {
|
|
972
|
-
writeBlock('AGENTS.md', '1.0.0');
|
|
973
|
-
const res = inspectAgentDocs(tmpDir, '1.0.0');
|
|
974
|
-
expect(res.status).toBe('current');
|
|
975
|
-
expect(res.staleFiles).toEqual([]);
|
|
976
|
-
expect(res.blockVersions).toEqual([]);
|
|
977
|
-
});
|
|
978
|
-
|
|
979
|
-
it.each([
|
|
980
|
-
['append addition', [], [{package: '@acme/a', append: ['added']}]],
|
|
981
|
-
['append removal', [{package: '@acme/a', append: ['removed']}], []],
|
|
982
|
-
[
|
|
983
|
-
'integration reorder',
|
|
984
|
-
[
|
|
985
|
-
{package: '@acme/a', append: ['a']},
|
|
986
|
-
{package: '@acme/b', append: ['b']},
|
|
987
|
-
],
|
|
988
|
-
[
|
|
989
|
-
{package: '@acme/b', append: ['b']},
|
|
990
|
-
{package: '@acme/a', append: ['a']},
|
|
991
|
-
],
|
|
992
|
-
],
|
|
993
|
-
[
|
|
994
|
-
'line content change',
|
|
995
|
-
[{package: '@acme/a', append: ['old']}],
|
|
996
|
-
[{package: '@acme/a', append: ['new']}],
|
|
997
|
-
],
|
|
998
|
-
])(
|
|
999
|
-
'reports stale at the same Core version after %s',
|
|
1000
|
-
(_label, current, expected) => {
|
|
1001
|
-
const actualBlock = generateCompressedIndex('1.0.0', {
|
|
1002
|
-
agentDocs: current,
|
|
1003
|
-
});
|
|
1004
|
-
fs.writeFileSync(
|
|
1005
|
-
path.join(tmpDir, 'AGENTS.md'),
|
|
1006
|
-
`# Doc\n\n${actualBlock}\n`,
|
|
1007
|
-
);
|
|
1008
|
-
const expectedBlock = generateCompressedIndex('1.0.0', {
|
|
1009
|
-
agentDocs: expected,
|
|
1010
|
-
});
|
|
1011
|
-
|
|
1012
|
-
expect(inspectAgentDocs(tmpDir, '1.0.0', expectedBlock)).toMatchObject({
|
|
1013
|
-
status: 'stale',
|
|
1014
|
-
staleFiles: ['AGENTS.md'],
|
|
1015
|
-
});
|
|
1016
|
-
},
|
|
1017
|
-
);
|
|
1018
|
-
|
|
1019
|
-
it('reports stale (with the old version) when the block is behind', () => {
|
|
1020
|
-
writeBlock('AGENTS.md', '1.0.0');
|
|
1021
|
-
const res = inspectAgentDocs(tmpDir, '2.0.0');
|
|
1022
|
-
expect(res.status).toBe('stale');
|
|
1023
|
-
expect(res.staleFiles).toEqual(['AGENTS.md']);
|
|
1024
|
-
expect(res.blockVersions).toEqual(['1.0.0']);
|
|
1025
|
-
expect(res.installedVersion).toBe('2.0.0');
|
|
1026
|
-
});
|
|
1027
|
-
|
|
1028
|
-
it('treats a legacy XDS block as stale even with no parseable version', () => {
|
|
1029
|
-
fs.writeFileSync(
|
|
1030
|
-
path.join(tmpDir, 'CLAUDE.md'),
|
|
1031
|
-
'# Claude\n\n<!-- XDS:START -->\nlegacy index\n<!-- XDS:END -->\n',
|
|
1032
|
-
);
|
|
1033
|
-
const res = inspectAgentDocs(tmpDir, '1.0.0');
|
|
1034
|
-
expect(res.status).toBe('stale');
|
|
1035
|
-
expect(res.files[0].legacy).toBe(true);
|
|
1036
|
-
expect(res.blockVersions).toEqual([]);
|
|
1037
|
-
});
|
|
1038
|
-
|
|
1039
|
-
it('is stale if ANY marked file is behind (mixed current + stale)', () => {
|
|
1040
|
-
writeBlock('AGENTS.md', '2.0.0');
|
|
1041
|
-
writeBlock('CLAUDE.md', '1.0.0');
|
|
1042
|
-
const res = inspectAgentDocs(tmpDir, '2.0.0');
|
|
1043
|
-
expect(res.status).toBe('stale');
|
|
1044
|
-
expect(res.staleFiles).toEqual(['CLAUDE.md']);
|
|
1045
|
-
});
|
|
1046
|
-
|
|
1047
|
-
it('defaults the installed version to the core package when omitted', () => {
|
|
1048
|
-
const coreDir = path.join(tmpDir, 'node_modules', '@astryxdesign', 'core');
|
|
1049
|
-
fs.mkdirSync(coreDir, {recursive: true});
|
|
1050
|
-
fs.writeFileSync(path.join(coreDir, 'package.json'), JSON.stringify({version: '3.0.0'}));
|
|
1051
|
-
writeBlock('AGENTS.md', '3.0.0');
|
|
1052
|
-
const res = inspectAgentDocs(tmpDir);
|
|
1053
|
-
expect(res.installedVersion).toBe('3.0.0');
|
|
1054
|
-
expect(res.status).toBe('current');
|
|
1055
|
-
});
|
|
1056
|
-
});
|
|
1057
|
-
|
|
1058
|
-
describe('injectXdsBlock / removeXdsBlock — malformed managed blocks (no user-content loss)', () => {
|
|
1059
|
-
const S = '<!-- ASTRYX:START -->';
|
|
1060
|
-
const E = '<!-- ASTRYX:END -->';
|
|
1061
|
-
const BLOCK = `${S}\nNEW\n${E}`;
|
|
1062
|
-
|
|
1063
|
-
it('does not duplicate user content when END precedes START', () => {
|
|
1064
|
-
const f = path.join(tmpDir, 'a.md');
|
|
1065
|
-
fs.writeFileSync(f, `# Doc\nUSER-A\n${E}\nUSER-B\n${S}\nUSER-C\n`);
|
|
1066
|
-
removeXdsBlock(f);
|
|
1067
|
-
const c = fs.readFileSync(f, 'utf-8');
|
|
1068
|
-
expect((c.match(/USER-B/g) || []).length).toBeLessThanOrEqual(1);
|
|
1069
|
-
});
|
|
1070
|
-
|
|
1071
|
-
it('refuses (throws) instead of orphaning a second block when duplicates exist', () => {
|
|
1072
|
-
const f = path.join(tmpDir, 'b.md');
|
|
1073
|
-
fs.writeFileSync(f, `# Doc\n${S}\nB1\n${E}\nMID\n${S}\nB2\n${E}\nTAIL\n`);
|
|
1074
|
-
expect(() => injectXdsBlock(f, BLOCK)).toThrow(/multiple|malformed/i);
|
|
1075
|
-
// file left untouched for the user to fix
|
|
1076
|
-
expect(fs.readFileSync(f, 'utf-8')).toContain('MID');
|
|
1077
|
-
expect(fs.readFileSync(f, 'utf-8')).toContain('TAIL');
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
it('refuses to append a second block when a START has no matching END', () => {
|
|
1081
|
-
const f = path.join(tmpDir, 'c.md');
|
|
1082
|
-
fs.writeFileSync(f, `# Doc\nUSER1\n${S}\nOLD (no end)\nUSER2\n`);
|
|
1083
|
-
expect(() => injectXdsBlock(f, BLOCK)).toThrow(/end marker|malformed|no matching/i);
|
|
1084
|
-
expect((fs.readFileSync(f, 'utf-8').match(/ASTRYX:START/g) || []).length).toBe(1);
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
it('replaces a single well-formed block idempotently, preserving surrounding content', () => {
|
|
1088
|
-
const f = path.join(tmpDir, 'ok.md');
|
|
1089
|
-
fs.writeFileSync(f, `# Doc\nUSER\n${S}\nOLD\n${E}\nTAIL\n`);
|
|
1090
|
-
injectXdsBlock(f, BLOCK);
|
|
1091
|
-
const c = fs.readFileSync(f, 'utf-8');
|
|
1092
|
-
expect((c.match(/ASTRYX:START/g) || []).length).toBe(1);
|
|
1093
|
-
expect(c).toContain('NEW');
|
|
1094
|
-
expect(c).toContain('USER');
|
|
1095
|
-
expect(c).toContain('TAIL');
|
|
1096
|
-
expect(c).not.toContain('OLD');
|
|
1097
|
-
});
|
|
1098
|
-
});
|
|
1099
|
-
|
|
1100
|
-
describe('isAstryxInitialized — resilient to malformed markers (postinstall hot path)', () => {
|
|
1101
|
-
// isAstryxInitialized runs on every consumer `npm install` (via postinstall).
|
|
1102
|
-
// It must never throw — even on a half-written or garbage-marker file — so it
|
|
1103
|
-
// uses a plain `.includes(MARKER_START)`, never the strict findManagedBlock.
|
|
1104
|
-
const START = '<!-- ASTRYX:START -->';
|
|
1105
|
-
const END = '<!-- ASTRYX:END -->';
|
|
1106
|
-
|
|
1107
|
-
it('returns true (never throws) on duplicate START markers', () => {
|
|
1108
|
-
fs.writeFileSync(
|
|
1109
|
-
path.join(tmpDir, 'AGENTS.md'),
|
|
1110
|
-
`${START}\na\n${START}\nb\n${END}\n`,
|
|
1111
|
-
);
|
|
1112
|
-
expect(() => isAstryxInitialized(tmpDir)).not.toThrow();
|
|
1113
|
-
expect(isAstryxInitialized(tmpDir)).toBe(true);
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
it('returns true on an END-before-START file without throwing', () => {
|
|
1117
|
-
fs.writeFileSync(
|
|
1118
|
-
path.join(tmpDir, 'AGENTS.md'),
|
|
1119
|
-
`${END}\nuser\n${START}\nblock\n`,
|
|
1120
|
-
);
|
|
1121
|
-
expect(() => isAstryxInitialized(tmpDir)).not.toThrow();
|
|
1122
|
-
expect(isAstryxInitialized(tmpDir)).toBe(true);
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
|
-
it('returns true on a START with no END (half-written block)', () => {
|
|
1126
|
-
fs.writeFileSync(
|
|
1127
|
-
path.join(tmpDir, 'AGENTS.md'),
|
|
1128
|
-
`# Doc\nuser\n${START}\ntruncated block, no end\n`,
|
|
1129
|
-
);
|
|
1130
|
-
expect(() => isAstryxInitialized(tmpDir)).not.toThrow();
|
|
1131
|
-
expect(isAstryxInitialized(tmpDir)).toBe(true);
|
|
1132
|
-
});
|
|
1133
|
-
|
|
1134
|
-
it('returns false for a directory with no agent docs', () => {
|
|
1135
|
-
expect(isAstryxInitialized(tmpDir)).toBe(false);
|
|
1136
|
-
});
|
|
1137
|
-
|
|
1138
|
-
it('returns false for a nonexistent directory', () => {
|
|
1139
|
-
expect(isAstryxInitialized(path.join(tmpDir, 'does-not-exist'))).toBe(false);
|
|
1140
|
-
});
|
|
1141
|
-
});
|