@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The MCP tools of `astryx mcp`: the CLI's manifest, in MCP's shape.
|
|
5
|
+
*
|
|
6
|
+
* Each command the manifest lists as answering with --json, with an
|
|
7
|
+
* `outsideProject`, is one tool; a group that only holds subcommands has no
|
|
8
|
+
* `outsideProject`, so it is no tool. A tool's inputs are the command's
|
|
9
|
+
* arguments and options, and the root options, under their CLI names, and a
|
|
10
|
+
* call becomes the command line that runs it. The manifest is the only input,
|
|
11
|
+
* so the tools are the commands of this CLI, and nothing else. A docs-only
|
|
12
|
+
* server (`--docs-only`) serves the named commands that only read the docs.
|
|
13
|
+
*
|
|
14
|
+
* @input the CLI's manifest (`astryx manifest --json`'s data); the folder served
|
|
15
|
+
* @output tool descriptors for tools/list; the command line a tools/call runs;
|
|
16
|
+
* the server instructions
|
|
17
|
+
* @position clients/cli/lib — read by commands/mcp.mjs and lib/mcp-server.mjs
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import {Option} from 'commander';
|
|
21
|
+
import {isAstryxPromptInReach} from '../../../foundation/agent-docs/agent-doc-state.mjs';
|
|
22
|
+
import {
|
|
23
|
+
REMOVE_LINE,
|
|
24
|
+
renderAgentDocsBlock,
|
|
25
|
+
} from '../../../foundation/agent-docs/agent-docs.mjs';
|
|
26
|
+
import {assertWithin, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Root options that are not tool inputs. `--json` is how every tool runs its
|
|
30
|
+
* command. `--version` prints the version in place of the command; the server
|
|
31
|
+
* reports the version in its `initialize` answer.
|
|
32
|
+
*/
|
|
33
|
+
export const RUN_OPTIONS = Object.freeze(['--json', '--version']);
|
|
34
|
+
|
|
35
|
+
/** The input that names the folder a command runs in. */
|
|
36
|
+
export const CWD_INPUT = 'cwd';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The commands a docs-only server offers (`astryx mcp --docs-only`), by
|
|
40
|
+
* command path. Each one answers from Astryx's docs and the Core the folder
|
|
41
|
+
* has: it writes nothing, reads no path a caller names, and reaches no other
|
|
42
|
+
* service. They are named, not inferred from the manifest, because offering a
|
|
43
|
+
* command on a server many people share is a decision about that command.
|
|
44
|
+
*/
|
|
45
|
+
export const DOCS_ONLY_COMMANDS = Object.freeze([
|
|
46
|
+
'search',
|
|
47
|
+
'build',
|
|
48
|
+
'component',
|
|
49
|
+
'hook',
|
|
50
|
+
'docs',
|
|
51
|
+
'template',
|
|
52
|
+
'discover',
|
|
53
|
+
'theme list',
|
|
54
|
+
'theme targets',
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The inputs a docs-only tool leaves out: a package to read (`package`, and
|
|
59
|
+
* the root option `base`), and the template inputs that write a file. The
|
|
60
|
+
* server answers for the one Core its folder has.
|
|
61
|
+
*/
|
|
62
|
+
export const DOCS_ONLY_OMITTED_INPUTS = Object.freeze(['package', 'base', 'path', 'cdn', 'overwrite']);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {object} McpArgument
|
|
66
|
+
* @property {string} key the input property
|
|
67
|
+
* @property {boolean} required
|
|
68
|
+
* @property {boolean} variadic
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {object} McpOption
|
|
73
|
+
* @property {string} key the input property: the long flag without `--`
|
|
74
|
+
* @property {string} long the long flag
|
|
75
|
+
* @property {'flag' | 'value' | 'optional-value'} takes
|
|
76
|
+
* @property {boolean} variadic it takes a list: the flag is given once per item
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @typedef {object} McpTool
|
|
81
|
+
* @property {string} name the command's words joined by `_`
|
|
82
|
+
* @property {string[]} words the command's words, e.g. ['theme', 'build']
|
|
83
|
+
* @property {string} title
|
|
84
|
+
* @property {string} description
|
|
85
|
+
* @property {Record<string, unknown>} inputSchema
|
|
86
|
+
* @property {McpArgument[]} args in command-line order
|
|
87
|
+
* @property {McpOption[]} options the command's options, then the root options
|
|
88
|
+
* @property {boolean} docsOnly a docs-only tool: it takes no folder
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Every command in a manifest's tree, depth first.
|
|
93
|
+
* @param {import('./manifest').ManifestCommand[]} commands
|
|
94
|
+
* @returns {import('./manifest').ManifestCommand[]}
|
|
95
|
+
*/
|
|
96
|
+
function flatten(commands) {
|
|
97
|
+
return commands.flatMap(c => [c, ...flatten(c.subcommands ?? [])]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* How a manifest option is given on the command line, read by Commander from
|
|
102
|
+
* its flag. An option whose default is a list collects one value each time it
|
|
103
|
+
* is given, as `upgrade --integration` does.
|
|
104
|
+
* @param {import('./manifest').ManifestOption} manifestOption
|
|
105
|
+
* @returns {McpOption}
|
|
106
|
+
*/
|
|
107
|
+
function optionEntry(manifestOption) {
|
|
108
|
+
const option = new Option(manifestOption.flag);
|
|
109
|
+
if (!option.long) {
|
|
110
|
+
throw new Error(`${manifestOption.flag} has no long flag, so it has no tool input name`);
|
|
111
|
+
}
|
|
112
|
+
const takes = option.required ? 'value' : option.optional ? 'optional-value' : 'flag';
|
|
113
|
+
return {
|
|
114
|
+
key: option.long.slice(2),
|
|
115
|
+
long: option.long,
|
|
116
|
+
takes,
|
|
117
|
+
variadic: takes !== 'flag' && (option.variadic || Array.isArray(manifestOption.default)),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The input property for one option.
|
|
123
|
+
* @param {import('./manifest').ManifestOption} manifestOption
|
|
124
|
+
* @param {McpOption} entry
|
|
125
|
+
* @param {boolean} describe whether the property carries the option's text;
|
|
126
|
+
* the server instructions give the root options' text once
|
|
127
|
+
* @returns {Record<string, unknown>}
|
|
128
|
+
*/
|
|
129
|
+
function optionSchema(manifestOption, entry, describe) {
|
|
130
|
+
/** @type {Record<string, unknown>} */
|
|
131
|
+
let value = {type: 'boolean'};
|
|
132
|
+
if (entry.takes !== 'flag') {
|
|
133
|
+
value = manifestOption.choices?.length
|
|
134
|
+
? {type: 'string', enum: [...manifestOption.choices]}
|
|
135
|
+
: {type: 'string'};
|
|
136
|
+
if (entry.variadic) value = {type: 'array', items: value};
|
|
137
|
+
else if (entry.takes === 'optional-value') value = {anyOf: [{type: 'boolean'}, value]};
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
...value,
|
|
141
|
+
...(describe && manifestOption.description ? {description: manifestOption.description} : {}),
|
|
142
|
+
...(manifestOption.default !== undefined ? {default: manifestOption.default} : {}),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The root options a tool takes as inputs; a docs-only tool leaves out the
|
|
148
|
+
* DOCS_ONLY_OMITTED_INPUTS among them. The tools and the instructions both
|
|
149
|
+
* read this list, so the instructions name exactly the root options a tool
|
|
150
|
+
* takes.
|
|
151
|
+
* @param {import('./manifest').CLIManifest} manifest
|
|
152
|
+
* @param {boolean} docsOnly
|
|
153
|
+
* @returns {import('./manifest').ManifestOption[]}
|
|
154
|
+
*/
|
|
155
|
+
function toolRootOptions(manifest, docsOnly) {
|
|
156
|
+
return manifest.globalOptions.filter(o => {
|
|
157
|
+
const long = new Option(o.flag).long ?? '';
|
|
158
|
+
return !RUN_OPTIONS.includes(long) && !(docsOnly && DOCS_ONLY_OMITTED_INPUTS.includes(long.slice(2)));
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The MCP tool for one manifest command.
|
|
164
|
+
* @param {import('./manifest').ManifestCommand} command
|
|
165
|
+
* @param {import('./manifest').ManifestOption[]} rootOptions
|
|
166
|
+
* @param {boolean} docsOnly
|
|
167
|
+
* @returns {McpTool}
|
|
168
|
+
*/
|
|
169
|
+
function toolOf(command, rootOptions, docsOnly) {
|
|
170
|
+
const words = command.name.split(' ');
|
|
171
|
+
/** @param {string} key */
|
|
172
|
+
const offered = key => !docsOnly || !DOCS_ONLY_OMITTED_INPUTS.includes(key);
|
|
173
|
+
/** @type {Record<string, Record<string, unknown>>} */
|
|
174
|
+
const properties = {};
|
|
175
|
+
/** @type {string[]} */
|
|
176
|
+
const required = [];
|
|
177
|
+
const args = command.arguments.filter(arg => offered(arg.name)).map(arg => {
|
|
178
|
+
const item = {type: 'string'};
|
|
179
|
+
properties[arg.name] = {
|
|
180
|
+
...(arg.variadic ? {type: 'array', items: item} : item),
|
|
181
|
+
...(arg.description ? {description: arg.description} : {}),
|
|
182
|
+
};
|
|
183
|
+
if (arg.required) required.push(arg.name);
|
|
184
|
+
return {key: arg.name, required: arg.required, variadic: arg.variadic};
|
|
185
|
+
});
|
|
186
|
+
/** @type {McpOption[]} */
|
|
187
|
+
const options = [];
|
|
188
|
+
for (const [manifestOption, describe] of [
|
|
189
|
+
...command.options
|
|
190
|
+
.filter(o => o.available !== false)
|
|
191
|
+
.map(o => /** @type {const} */ ([o, true])),
|
|
192
|
+
...rootOptions.map(o => /** @type {const} */ ([o, false])),
|
|
193
|
+
]) {
|
|
194
|
+
const entry = optionEntry(manifestOption);
|
|
195
|
+
if (!offered(entry.key)) continue;
|
|
196
|
+
properties[entry.key] = optionSchema(manifestOption, entry, describe);
|
|
197
|
+
options.push(entry);
|
|
198
|
+
}
|
|
199
|
+
// The server instructions describe it once.
|
|
200
|
+
if (!docsOnly) properties[CWD_INPUT] = {type: 'string'};
|
|
201
|
+
return {
|
|
202
|
+
name: words.join('_'),
|
|
203
|
+
words,
|
|
204
|
+
title: `astryx ${command.name}`,
|
|
205
|
+
description: command.description,
|
|
206
|
+
inputSchema: {
|
|
207
|
+
type: 'object',
|
|
208
|
+
properties,
|
|
209
|
+
...(required.length > 0 ? {required} : {}),
|
|
210
|
+
additionalProperties: false,
|
|
211
|
+
},
|
|
212
|
+
args,
|
|
213
|
+
options,
|
|
214
|
+
docsOnly,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The MCP tools of the CLI: one per command the manifest lists as answering
|
|
220
|
+
* with --json, with an `outsideProject`, in the manifest's order. A command or
|
|
221
|
+
* an option the manifest marks unavailable on the run's base is left out. A docs-only
|
|
222
|
+
* server serves the DOCS_ONLY_COMMANDS among them, without the
|
|
223
|
+
* DOCS_ONLY_OMITTED_INPUTS and without a folder input.
|
|
224
|
+
*
|
|
225
|
+
* @param {import('./manifest').CLIManifest} manifest
|
|
226
|
+
* @param {{docsOnly?: boolean}} [mode]
|
|
227
|
+
* @returns {McpTool[]}
|
|
228
|
+
*/
|
|
229
|
+
export function mcpTools(manifest, {docsOnly = false} = {}) {
|
|
230
|
+
const rootOptions = toolRootOptions(manifest, docsOnly);
|
|
231
|
+
return flatten(manifest.commands)
|
|
232
|
+
.filter(command => command.json && command.outsideProject && command.available !== false)
|
|
233
|
+
.filter(command => !docsOnly || DOCS_ONLY_COMMANDS.includes(command.name))
|
|
234
|
+
.map(command => toolOf(command, rootOptions, docsOnly));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The agent text `astryx init` writes for the project `root` serves, without
|
|
239
|
+
* its markers, so an agent that reaches the CLI only through this server reads
|
|
240
|
+
* the same guidance. Null when the project already has that text in an agent
|
|
241
|
+
* file within reach, or when it cannot be rendered.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} root
|
|
244
|
+
* @returns {Promise<string | null>}
|
|
245
|
+
*/
|
|
246
|
+
export async function projectAgentText(root) {
|
|
247
|
+
if (isAstryxPromptInReach(root)) return null;
|
|
248
|
+
try {
|
|
249
|
+
const block = await renderAgentDocsBlock(root);
|
|
250
|
+
// The remove line is about a block in an agent file; these instructions
|
|
251
|
+
// are no file, so it goes with the markers.
|
|
252
|
+
return block
|
|
253
|
+
.split('\n')
|
|
254
|
+
.filter(line => !/^<!-- ASTRYX:(START|END) -->$/.test(line.trim()))
|
|
255
|
+
.filter(line => line !== REMOVE_LINE)
|
|
256
|
+
.join('\n')
|
|
257
|
+
.trim();
|
|
258
|
+
} catch {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* What a client shows the model once: the project's agent text, the CLI's
|
|
265
|
+
* description, the rule from a tool to its command, and the root options, as
|
|
266
|
+
* the root help gives them.
|
|
267
|
+
*
|
|
268
|
+
* @param {import('./manifest').CLIManifest} manifest
|
|
269
|
+
* @param {{agentText?: string | null, docsOnly?: boolean}} [context]
|
|
270
|
+
* agentText from projectAgentText(); docsOnly for a docs-only server
|
|
271
|
+
* @returns {string}
|
|
272
|
+
*/
|
|
273
|
+
export function mcpInstructions(manifest, {agentText = null, docsOnly = false} = {}) {
|
|
274
|
+
const rootLines = toolRootOptions(manifest, docsOnly).map(o => ` ${o.flag} ${o.description}`);
|
|
275
|
+
const toolRule =
|
|
276
|
+
"A tool name is the command's words joined by _ (theme build is theme_build), and its inputs are the command's arguments and options under their CLI names: a value option takes a string, and a list takes an array of strings.";
|
|
277
|
+
return [
|
|
278
|
+
...(agentText ? [agentText] : []),
|
|
279
|
+
manifest.description,
|
|
280
|
+
docsOnly
|
|
281
|
+
? 'This server offers only the astryx commands that read the docs, and it answers for the Astryx release it has, which can differ from the one your project uses. ' +
|
|
282
|
+
`Each tool runs one of those commands with --json and answers with its JSON output unchanged. ${toolRule}`
|
|
283
|
+
: `Each tool runs one astryx command in this folder with --json and answers with its JSON output unchanged. ${toolRule}`,
|
|
284
|
+
['Every tool also takes the root options, which change only the reads their text names:', ...rootLines].join('\n'),
|
|
285
|
+
...(docsOnly
|
|
286
|
+
? []
|
|
287
|
+
: [`and ${CWD_INPUT}, the folder to run the command in, inside this one (default: this one).`]),
|
|
288
|
+
"A command's full docs are the docs tool with topic cli/commands/<the command's words joined by ->.",
|
|
289
|
+
].join('\n\n');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Thrown for a tools/call input that cannot become a command line.
|
|
294
|
+
*/
|
|
295
|
+
export class McpInputError extends Error {}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* The text an input value becomes on the command line.
|
|
299
|
+
* @param {unknown} value
|
|
300
|
+
* @returns {string}
|
|
301
|
+
*/
|
|
302
|
+
function argText(value) {
|
|
303
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The values of a list input; a single value is a list of one.
|
|
308
|
+
* @param {unknown} value
|
|
309
|
+
* @returns {string[]}
|
|
310
|
+
*/
|
|
311
|
+
function listOf(value) {
|
|
312
|
+
return (Array.isArray(value) ? value : [value]).map(argText);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The command-line arguments that run `tool` with `input`, and the folder to
|
|
317
|
+
* run them in. An input the tool does not declare is refused, as its schema
|
|
318
|
+
* says; a docs-only tool always runs in the folder served.
|
|
319
|
+
*
|
|
320
|
+
* @param {McpTool} tool
|
|
321
|
+
* @param {Record<string, unknown>} input
|
|
322
|
+
* @param {{root: string}} context the folder the server serves
|
|
323
|
+
* @returns {{argv: string[], cwd: string}}
|
|
324
|
+
*/
|
|
325
|
+
export function commandLine(tool, input, {root}) {
|
|
326
|
+
const given = input ?? {};
|
|
327
|
+
/** @type {string[]} */
|
|
328
|
+
const flags = [];
|
|
329
|
+
/** @type {Set<string>} */
|
|
330
|
+
const used = new Set(tool.docsOnly ? [] : [CWD_INPUT]);
|
|
331
|
+
|
|
332
|
+
for (const option of tool.options) {
|
|
333
|
+
used.add(option.key);
|
|
334
|
+
const value = given[option.key];
|
|
335
|
+
if (value === undefined || value === null || value === false) continue;
|
|
336
|
+
if (option.takes === 'flag') {
|
|
337
|
+
if (value === 'false') continue;
|
|
338
|
+
if (value === true || value === 'true') flags.push(option.long);
|
|
339
|
+
else flags.push(`${option.long}=${argText(value)}`);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (option.takes === 'optional-value' && value === true) {
|
|
343
|
+
flags.push(option.long);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
for (const item of option.variadic ? listOf(value) : [argText(value)]) {
|
|
347
|
+
flags.push(`${option.long}=${item}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** @type {string[]} */
|
|
352
|
+
const positionals = [];
|
|
353
|
+
let missing = /** @type {string | null} */ (null);
|
|
354
|
+
for (const arg of tool.args) {
|
|
355
|
+
used.add(arg.key);
|
|
356
|
+
const value = given[arg.key];
|
|
357
|
+
if (value === undefined || value === null) {
|
|
358
|
+
missing ??= arg.key;
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (missing != null) {
|
|
362
|
+
throw new McpInputError(
|
|
363
|
+
`${tool.name}: give ${missing} before ${arg.key}; the command reads its arguments in order`,
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
positionals.push(...(arg.variadic ? listOf(value) : [argText(value)]));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
for (const key of Object.keys(given)) {
|
|
370
|
+
if (used.has(key)) continue;
|
|
371
|
+
throw new McpInputError(
|
|
372
|
+
`${tool.name} takes no ${JSON.stringify(key)}${tool.docsOnly ? ' on this server' : ''}`,
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return {
|
|
377
|
+
argv: [
|
|
378
|
+
...tool.words,
|
|
379
|
+
...flags,
|
|
380
|
+
'--json',
|
|
381
|
+
...(positionals.length > 0 ? ['--', ...positionals] : []),
|
|
382
|
+
],
|
|
383
|
+
cwd: tool.docsOnly ? root : commandFolder(given[CWD_INPUT], root),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* The folder a call runs in: `root`, or a folder inside it, also through
|
|
389
|
+
* symbolic links.
|
|
390
|
+
* @param {unknown} value
|
|
391
|
+
* @param {string} root
|
|
392
|
+
* @returns {string}
|
|
393
|
+
*/
|
|
394
|
+
function commandFolder(value, root) {
|
|
395
|
+
if (value === undefined || value === null || value === '') return root;
|
|
396
|
+
if (typeof value !== 'string') {
|
|
397
|
+
throw new McpInputError(`${CWD_INPUT} must be a string`);
|
|
398
|
+
}
|
|
399
|
+
try {
|
|
400
|
+
return assertWithin(value, root, {allowAbsolute: true, label: CWD_INPUT});
|
|
401
|
+
} catch (error) {
|
|
402
|
+
if (error instanceof PathSafetyError) throw new McpInputError(error.message);
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The words from other command lines that the unknown-command answer
|
|
5
|
+
* reads. Each entry names the word and the common tool that uses it.
|
|
6
|
+
*
|
|
7
|
+
* An entry is added only with evidence that coding agents or people type
|
|
8
|
+
* the word at astryx. A word is never the name of an astryx command, or the
|
|
9
|
+
* plural of one: that command answers the word itself. The unknown-command
|
|
10
|
+
* tests check both rules against the real program.
|
|
11
|
+
*
|
|
12
|
+
* @input none
|
|
13
|
+
* @output the word tables `unknown-command.mjs` reads
|
|
14
|
+
* @position packages/cli/clients/cli/lib — data for unknown-command.mjs
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A word and the tool that uses it.
|
|
19
|
+
* @typedef {{word: string, usedBy: string}} ToolWord
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A word for a job one astryx command does. `run` is the run that does the
|
|
24
|
+
* job. A word in angle brackets (`<old-version>`) names an input the run
|
|
25
|
+
* needs, which the words typed fill when they hold it. `notNeededWith` names
|
|
26
|
+
* the options that make those inputs unneeded: the run leaves them out when
|
|
27
|
+
* the words typed hold one of these options.
|
|
28
|
+
* @typedef {ToolWord & {run: readonly string[], reason: string, notNeededWith?: readonly string[]}} JobWord
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Words that ask a command for its whole list (`templates list`).
|
|
33
|
+
* @type {readonly ToolWord[]}
|
|
34
|
+
*/
|
|
35
|
+
export const LIST_WORDS = [{word: 'list', usedBy: 'npm (`npm list`)'}];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Words that only ask to read what the next word names (`show component
|
|
39
|
+
* Button`, `templates view settings`).
|
|
40
|
+
* @type {readonly ToolWord[]}
|
|
41
|
+
*/
|
|
42
|
+
export const READ_WORDS = [
|
|
43
|
+
{word: 'info', usedBy: 'npm (`npm info`)'},
|
|
44
|
+
{word: 'view', usedBy: 'npm (`npm view`)'},
|
|
45
|
+
{word: 'show', usedBy: 'npm (`npm show`)'},
|
|
46
|
+
{word: 'describe', usedBy: 'kubectl (`kubectl describe`)'},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Verbs that put a component or a page into a project (`add button`).
|
|
51
|
+
* @type {readonly ToolWord[]}
|
|
52
|
+
*/
|
|
53
|
+
export const ADD_WORDS = [{word: 'add', usedBy: 'shadcn (`shadcn add`)'}];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Verbs that copy a component's source into a project (`eject button`).
|
|
57
|
+
* @type {readonly ToolWord[]}
|
|
58
|
+
*/
|
|
59
|
+
export const SOURCE_WORDS = [
|
|
60
|
+
{word: 'eject', usedBy: 'Create React App (`npm run eject`)'},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Words that ask for a component's props (`props Card`).
|
|
65
|
+
* @type {readonly ToolWord[]}
|
|
66
|
+
*/
|
|
67
|
+
export const PROPS_WORDS = [
|
|
68
|
+
{word: 'props', usedBy: 'React, which names the inputs of a component props'},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Options for where a file goes. A command with a `path` argument takes
|
|
73
|
+
* their value as that argument.
|
|
74
|
+
* @type {readonly ToolWord[]}
|
|
75
|
+
*/
|
|
76
|
+
export const PATH_OPTIONS = [
|
|
77
|
+
{word: '--path', usedBy: 'shadcn (`shadcn add --path`)'},
|
|
78
|
+
{word: '--out', usedBy: 'TypeScript (`tsc --out`)'},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Words for a job one astryx command does, with the run that does it.
|
|
83
|
+
* @type {readonly JobWord[]}
|
|
84
|
+
*/
|
|
85
|
+
export const JOB_WORDS = [
|
|
86
|
+
{
|
|
87
|
+
word: 'migrate',
|
|
88
|
+
usedBy: 'Prisma, Django and Rails (`migrate`)',
|
|
89
|
+
run: ['upgrade', '--from', '<old-version>'],
|
|
90
|
+
notNeededWith: ['--list', '--registry'],
|
|
91
|
+
reason: 'upgrade runs the codemods for a new version',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
word: 'browse',
|
|
95
|
+
usedBy: 'GitHub CLI (`gh extension browse`)',
|
|
96
|
+
run: ['discover'],
|
|
97
|
+
reason: 'discover lists the integrations you can add',
|
|
98
|
+
},
|
|
99
|
+
];
|
|
@@ -54,7 +54,7 @@ function pathOf(cmd) {
|
|
|
54
54
|
* @param {(option: OptionLike) => boolean} keep
|
|
55
55
|
* @returns {OptionLike[]}
|
|
56
56
|
*/
|
|
57
|
-
function optionsInReach(cmd, keep) {
|
|
57
|
+
export function optionsInReach(cmd, keep) {
|
|
58
58
|
/** @type {OptionLike[]} */
|
|
59
59
|
const options = [];
|
|
60
60
|
for (
|
|
@@ -278,6 +278,19 @@ function runAsMeant(cmd, path, stray, message, words, offered) {
|
|
|
278
278
|
return firstStray(words2, optionsInReach(cmd, any)) == null ? words2 : null;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Options a command no longer takes, which older docs and agents still pass:
|
|
283
|
+
* each answers what to do instead, not only that it is unknown.
|
|
284
|
+
* @type {Record<string, Record<string, string>>}
|
|
285
|
+
*/
|
|
286
|
+
const REMOVED_OPTIONS = {
|
|
287
|
+
'experimental render': {
|
|
288
|
+
'--static': "--static is no longer an option: every render carries the page's script now. Drop the flag and run the command again.",
|
|
289
|
+
'--interactive':
|
|
290
|
+
"--interactive is no longer an option: every render carries the page's script now. Drop the flag and run the command again.",
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
|
|
281
294
|
/**
|
|
282
295
|
* The answer to an option a command does not take.
|
|
283
296
|
*
|
|
@@ -303,6 +316,19 @@ export function strayOptionAnswer(
|
|
|
303
316
|
const stray = /unknown option '([^']+)'/.exec(message)?.[1];
|
|
304
317
|
if (!stray) return undefined;
|
|
305
318
|
const path = pathOf(cmd);
|
|
319
|
+
const removed = REMOVED_OPTIONS[path.join(' ')]?.[stray.split('=')[0]];
|
|
320
|
+
if (removed) {
|
|
321
|
+
const run = words.filter(word => word.split('=')[0] !== stray.split('=')[0]);
|
|
322
|
+
return {
|
|
323
|
+
message: removed,
|
|
324
|
+
suggestions: [
|
|
325
|
+
{
|
|
326
|
+
name: formatCliCommand(run.map(w => quoteCommandArgument(w)).join(' ')),
|
|
327
|
+
reason: 'the same command without the flag',
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
};
|
|
331
|
+
}
|
|
306
332
|
const json = path.length === 0 || jsonSupported(path.join(' '));
|
|
307
333
|
const offered = optionsInReach(
|
|
308
334
|
cmd,
|