@aws/nx-plugin 1.0.0-rc.79 → 1.0.0-rc.80
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/generators.json +10 -0
- package/migrations.json +1 -1
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/agent-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/agent-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/agent-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/attach-upstream.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/generator.d.ts +3 -3
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/react-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/react-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/react-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/react-connection/schema.d.ts +1 -1
- package/src/agentcore-gateway/schema.d.js.map +1 -1
- package/src/agentcore-gateway/schema.d.ts +1 -1
- package/src/agentcore-harness/generator.d.ts +4 -4
- package/src/agentcore-harness/generator.js.map +1 -1
- package/src/agentcore-harness/schema.d.js.map +1 -1
- package/src/agentcore-harness/schema.d.ts +1 -1
- package/src/connection/agent-local-dev.d.ts +1 -1
- package/src/connection/agent-local-dev.js.map +1 -1
- package/src/connection/agent-runtime-config.js.map +1 -1
- package/src/connection/gateway-runtime-config.js.map +1 -1
- package/src/connection/generator.d.ts +2 -2
- package/src/connection/generator.js.map +1 -1
- package/src/connection/local-dev.js.map +1 -1
- package/src/connection/scaffold-catalog.d.ts +1 -1
- package/src/connection/scaffold-catalog.js +6 -6
- package/src/connection/scaffold-catalog.js.map +1 -1
- package/src/connection/schema-resolver.d.ts +1 -1
- package/src/connection/schema-resolver.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js.map +1 -1
- package/src/infra/app/generator.d.ts +7 -7
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +3 -3
- package/src/init/generator.js.map +1 -1
- package/src/init/schema.d.js.map +1 -1
- package/src/init/schema.d.ts +2 -2
- package/src/internal/test-matrix/generator.js.map +1 -1
- package/src/license/config-types.d.ts +2 -2
- package/src/license/config-types.js.map +1 -1
- package/src/license/config.d.ts +2 -2
- package/src/license/config.js.map +1 -1
- package/src/license/dependency-check/check.d.ts +2 -2
- package/src/license/dependency-check/check.js.map +1 -1
- package/src/license/dependency-check/collectors/collector.js.map +1 -1
- package/src/license/dependency-check/collectors/python-collector.js.map +1 -1
- package/src/license/dependency-check/evaluator.d.ts +1 -1
- package/src/license/dependency-check/evaluator.js.map +1 -1
- package/src/license/dependency-check/executor.js.map +1 -1
- package/src/license/dependency-check/pre-approved.d.ts +1 -1
- package/src/license/dependency-check/pre-approved.js.map +1 -1
- package/src/license/dependency-check/types.d.ts +1 -1
- package/src/license/dependency-check/types.js.map +1 -1
- package/src/license/generator.d.ts +1 -1
- package/src/license/generator.js.map +1 -1
- package/src/license/index.d.ts +4 -4
- package/src/license/index.js.map +1 -1
- package/src/license/known-exceptions.d.ts +1 -1
- package/src/license/known-exceptions.js.map +1 -1
- package/src/license/sync/generator.js.map +1 -1
- package/src/license/sync/project-file-sync.d.ts +1 -1
- package/src/license/sync/project-file-sync.js.map +1 -1
- package/src/mcp-server/dev-server.js.map +1 -1
- package/src/mcp-server/generator-info.d.ts +3 -3
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/mcp-server/guide-pipeline.d.ts +1 -1
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/guide-render.js.map +1 -1
- package/src/mcp-server/index.js.map +1 -1
- package/src/mcp-server/mdx-ast.js.map +1 -1
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/add-to-existing-project.d.ts +1 -1
- package/src/mcp-server/tools/add-to-existing-project.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.d.ts +1 -1
- package/src/mcp-server/tools/general-guidance.js +1 -1
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.d.ts +1 -1
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/mcp-server/tools/list-generators.d.ts +1 -1
- package/src/mcp-server/tools/list-generators.js.map +1 -1
- package/src/mcp-server/tools/upgrade-workspace.d.ts +1 -1
- package/src/mcp-server/tools/upgrade-workspace.js.map +1 -1
- package/src/migrations/latest/apt-security-updates-in-container-images/migration.js.map +1 -1
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.js.map +1 -1
- package/src/migrations/latest/py-agent-ag-ui-hooks/migration.js.map +1 -1
- package/src/migrations/latest/py-agent-session-id-middleware-extraction/migration.js.map +1 -1
- package/src/migrations/latest/remove-mcp-inspector-license-exceptions/migration.js.map +1 -1
- package/src/migrations/latest/static-website-configurable-waf-encryption/migration.js.map +1 -1
- package/src/migrations/latest/ts-agent-session-id-middleware-extraction/migration.js.map +1 -1
- package/src/migrations/latest/user-identity-configurable-mfa/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.50/0001-modernize-function-props-cast/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.50/0002-restrict-cors-to-custom-domains/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.50/0003-terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.52/0001-user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.54/0001-order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.d.ts +1 -1
- package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.56/0001-dynamodb-local-remove-optimize-flag/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.57/0001-ts-agent-session-management-support/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.63/0001-add-deploy-sandbox-target/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.64/0001-smithy-build-without-docker/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.65/0001-vite-config-import-meta-dirname/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.65/0002-rolldown-code-splitting/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.67/0001-smithy-server-package-rename/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.68/0001-translate-script-whole-file-writes/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.70/0001-py-agent-a2a-lifespan-construction/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.71/0001-py-agent-a2a-httpx-client-per-call/migration.js.map +1 -1
- package/src/migrations/v1.0.0-rc.72/0001-py-agent-session-management-support/migration.js.map +1 -1
- package/src/open-api/ts-client/generator.d.ts +1 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.d.ts +1 -1
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.spec.tsx +6 -6
- package/src/open-api/ts-metadata/generator.d.ts +1 -1
- package/src/open-api/ts-metadata/generator.js.map +1 -1
- package/src/open-api/utils/codegen-data/languages.d.ts +1 -1
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +2 -2
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.d.ts +1 -1
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parse.d.ts +1 -1
- package/src/open-api/utils/parse.js.map +1 -1
- package/src/open-api/utils/parser.d.ts +2 -2
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/open-api/utils/refs.d.ts +1 -1
- package/src/open-api/utils/refs.js.map +1 -1
- package/src/preset/generator.d.ts +3 -3
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.js.map +1 -1
- package/src/preset/schema.d.ts +3 -3
- package/src/py/agent/a2a-connection/generator.d.ts +3 -3
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +3 -3
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.ts +1 -1
- package/src/py/agent/generator.d.ts +3 -3
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +3 -3
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.ts +1 -1
- package/src/py/agent/react-connection/generator.d.ts +12 -12
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/local-dev.d.ts +1 -1
- package/src/py/agent/react-connection/local-dev.js.map +1 -1
- package/src/py/agent/react-connection/schema.d.js.map +1 -1
- package/src/py/agent/react-connection/schema.d.ts +1 -1
- package/src/py/agent/schema.d.js.map +1 -1
- package/src/py/agent/schema.d.ts +1 -1
- package/src/py/api/generator.d.ts +1 -1
- package/src/py/api/generator.js.map +1 -1
- package/src/py/api/schema.d.js.map +1 -1
- package/src/py/api/schema.d.ts +1 -1
- package/src/py/dynamodb/agent-connection/generator.d.ts +1 -1
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.ts +1 -1
- package/src/py/dynamodb/fast-api-connection/generator.d.ts +1 -1
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/generator.d.ts +4 -4
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/generator.d.ts +1 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.ts +1 -1
- package/src/py/dynamodb/schema.d.js.map +1 -1
- package/src/py/dynamodb/schema.d.ts +1 -1
- package/src/py/fast-api/generator.d.ts +3 -3
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +3 -3
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/open-api.js.map +1 -1
- package/src/py/fast-api/schema.d.js.map +1 -1
- package/src/py/fast-api/schema.d.ts +1 -1
- package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +1 -1
- package/src/py/lambda-function/generator.d.ts +10 -4
- package/src/py/lambda-function/generator.js +8 -1
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.js.map +1 -1
- package/src/py/lambda-function/schema.d.ts +2 -2
- package/src/py/lambda-function/schema.json +1 -1
- package/src/py/mcp-server/generator.d.ts +3 -3
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.js.map +1 -1
- package/src/py/mcp-server/schema.d.ts +1 -1
- package/src/py/project/generator.d.ts +2 -2
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.json +1 -0
- package/src/py/rdb/agent-connection/generator.d.ts +1 -1
- package/src/py/rdb/agent-connection/generator.js.map +1 -1
- package/src/py/rdb/agent-connection/schema.d.js.map +1 -1
- package/src/py/rdb/agent-connection/schema.d.ts +1 -1
- package/src/py/rdb/fast-api-connection/generator.d.ts +1 -1
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +3 -3
- package/src/py/rdb/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/generator.d.ts +1 -1
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/schema.d.ts +1 -1
- package/src/sdk/agentcore-gateway.d.ts +1 -1
- package/src/sdk/agentcore-gateway.js.map +1 -1
- package/src/sdk/agentcore-harness.d.ts +1 -1
- package/src/sdk/agentcore-harness.js.map +1 -1
- package/src/sdk/connection.d.ts +1 -1
- package/src/sdk/connection.js.map +1 -1
- package/src/sdk/license.d.ts +3 -3
- package/src/sdk/license.js.map +1 -1
- package/src/sdk/open-api.d.ts +3 -3
- package/src/sdk/open-api.js.map +1 -1
- package/src/sdk/py.d.ts +7 -7
- package/src/sdk/py.js.map +1 -1
- package/src/sdk/smithy.d.ts +1 -1
- package/src/sdk/smithy.js.map +1 -1
- package/src/sdk/terraform.d.ts +1 -1
- package/src/sdk/terraform.js.map +1 -1
- package/src/sdk/ts.d.ts +18 -18
- package/src/sdk/ts.js.map +1 -1
- package/src/sdk/utils/ast.d.ts +1 -1
- package/src/sdk/utils/ast.js.map +1 -1
- package/src/sdk/utils/format.d.ts +1 -1
- package/src/sdk/utils/format.js.map +1 -1
- package/src/sdk/utils/test.d.ts +1 -1
- package/src/sdk/utils/test.js.map +1 -1
- package/src/smithy/project/generator.d.ts +4 -4
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +3 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/generator.d.ts +3 -3
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.js.map +1 -1
- package/src/smithy/ts/api/schema.d.ts +1 -1
- package/src/terraform/project/generator.d.ts +5 -5
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/generator.d.ts +3 -3
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +1 -1
- package/src/trpc/react/generator.d.ts +3 -3
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +3 -3
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +3 -3
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.ts +1 -1
- package/src/ts/agent/generator.d.ts +3 -3
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +3 -3
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +11 -11
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/local-dev.d.ts +1 -1
- package/src/ts/agent/react-connection/local-dev.js.map +1 -1
- package/src/ts/agent/react-connection/schema.d.js.map +1 -1
- package/src/ts/agent/react-connection/schema.d.ts +1 -1
- package/src/ts/agent/schema.d.js.map +1 -1
- package/src/ts/agent/schema.d.ts +1 -1
- package/src/ts/api/generator.d.ts +1 -1
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.js.map +1 -1
- package/src/ts/api/schema.d.ts +1 -1
- package/src/ts/astro-docs/generator.d.ts +3 -3
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +5 -5
- package/src/ts/dcr-proxy/generator.js.map +1 -1
- package/src/ts/dcr-proxy/schema.d.js.map +1 -1
- package/src/ts/dcr-proxy/schema.d.ts +1 -1
- package/src/ts/docs/generator.d.ts +1 -1
- package/src/ts/docs/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.ts +1 -1
- package/src/ts/dynamodb/generator.d.ts +5 -5
- package/src/ts/dynamodb/generator.js +1 -0
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.ts +1 -1
- package/src/ts/dynamodb/schema.d.js.map +1 -1
- package/src/ts/dynamodb/schema.d.ts +1 -1
- package/src/ts/dynamodb/smithy-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/generator.d.ts +1 -1
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/lambda-function/generator.d.ts +5 -5
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/schema.d.js.map +1 -1
- package/src/ts/lambda-function/schema.d.ts +1 -1
- package/src/ts/lib/biome.d.ts +1 -1
- package/src/ts/lib/biome.js.map +1 -1
- package/src/ts/lib/generator.d.ts +3 -3
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +3 -3
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +2 -2
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.d.ts +3 -3
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +1 -1
- package/src/ts/nx-generator/generator.d.ts +2 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-migration/generator.d.ts +3 -3
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -3
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +1 -1
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/agent-connection/generator.d.ts +1 -1
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.ts +1 -1
- package/src/ts/rdb/generator.d.ts +4 -4
- package/src/ts/rdb/generator.js +1 -0
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/generator.d.ts +1 -1
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.ts +1 -1
- package/src/ts/rdb/schema.d.js.map +1 -1
- package/src/ts/rdb/schema.d.ts +1 -1
- package/src/ts/rdb/smithy-connection/generator.d.ts +1 -1
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/generator.d.ts +1 -1
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +2 -2
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/generator.d.ts +3 -3
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.js.map +1 -1
- package/src/ts/react-website/app/schema.d.ts +2 -2
- package/src/ts/react-website/cognito-auth/generator.d.ts +5 -5
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.ts +1 -1
- package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
- package/src/ts/react-website/runtime-config/generator.d.ts +1 -1
- package/src/ts/react-website/runtime-config/generator.js.map +1 -1
- package/src/ts/sync/generator.d.ts +1 -1
- package/src/ts/sync/generator.js.map +1 -1
- package/src/ts/website/app/generator.d.ts +1 -1
- package/src/ts/website/app/generator.js.map +1 -1
- package/src/ts/website/app/schema.d.js.map +1 -1
- package/src/ts/website/app/schema.d.ts +2 -2
- package/src/ts/website/auth/generator.d.ts +1 -1
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/ts/website/auth/schema.d.js.map +1 -1
- package/src/ts/website/auth/schema.d.ts +1 -1
- package/src/utils/add-dependencies.d.ts +1 -1
- package/src/utils/add-dependencies.js.map +1 -1
- package/src/utils/agent-chat/agent-chat.js.map +1 -1
- package/src/utils/agent-connection/agent-connection.d.ts +2 -2
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +4 -4
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +3 -3
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/open-api-metadata.d.ts +1 -1
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/ast/website.js.map +1 -1
- package/src/utils/ast.js +6 -0
- package/src/utils/ast.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +1 -1
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.d.ts +1 -1
- package/src/utils/commands.js.map +1 -1
- package/src/utils/config/index.d.ts +6 -6
- package/src/utils/config/index.js.map +1 -1
- package/src/utils/config/utils.d.ts +1 -1
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +1 -1
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/containers.js.map +1 -1
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.d.ts +1 -1
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js.map +1 -1
- package/src/utils/declared-dependencies.d.ts +1 -1
- package/src/utils/declared-dependencies.js.map +1 -1
- package/src/utils/dependencies.js.map +1 -1
- package/src/utils/docker.d.ts +1 -1
- package/src/utils/docker.js.map +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.d.ts +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.d.ts +1 -1
- package/src/utils/fs.js.map +1 -1
- package/src/utils/function-constructs/function-constructs.d.ts +1 -1
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/iac.d.ts +2 -2
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/init.d.ts +3 -3
- package/src/utils/init.js.map +1 -1
- package/src/utils/install.d.ts +1 -1
- package/src/utils/install.js.map +1 -1
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/metrics.d.ts +1 -1
- package/src/utils/metrics.js.map +1 -1
- package/src/utils/migration-manifest.d.ts +1 -1
- package/src/utils/migration-manifest.js.map +1 -1
- package/src/utils/nx.d.ts +3 -3
- package/src/utils/nx.js.map +1 -1
- package/src/utils/paths.js.map +1 -1
- package/src/utils/pkg-manager.d.ts +1 -1
- package/src/utils/pkg-manager.js.map +1 -1
- package/src/utils/pnpm-workspace.js.map +1 -1
- package/src/utils/project-package-json.js.map +1 -1
- package/src/utils/py.d.ts +2 -2
- package/src/utils/py.js.map +1 -1
- package/src/utils/rdb-constructs/rdb-constructs.d.ts +2 -2
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +3 -3
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +1 -1
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-config.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +2 -2
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +1 -1
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +1 -1
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/smithy.js.map +1 -1
- package/src/utils/test.js.map +1 -1
- package/src/utils/version-upgrade-migration/migration.js.map +1 -1
- package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -1
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +1 -1
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -1
- package/src/utils/version-upgrade-migration/register.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-embedded-versions.d.ts +1 -1
- package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/website-constructs.d.ts +2 -2
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/license/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { getProjects, readNxJson, type Tree, updateNxJson } from '@nx/devkit';\nimport { PY_AGENT_GENERATOR_INFO } from '../py/agent/generator';\nimport { ensureAwsNxPluginConfig } from '../utils/config/utils';\nimport { formatFilesInSubtree } from '../utils/format';\nimport { addGeneratorMetricsIfApplicable } from '../utils/metrics';\nimport {\n getGeneratorInfo,\n mergeTargetDefault,\n type NxGeneratorInfo,\n} from '../utils/nx';\nimport {\n addLicenseCheckToAllLintTargets,\n defaultLicenseConfig,\n ensureDependencyCheckBlock,\n ensureLicenseExceptions,\n ensurePythonLicenseCollector,\n updateLicenseCheckTargetInputs,\n writeLicenseConfig,\n} from './config';\nimport { AG_UI_LANGGRAPH_EXCEPTIONS } from './known-exceptions';\nimport type { LicenseGeneratorSchema } from './schema';\nimport { SYNC_GENERATOR_NAME } from './sync/generator';\n\nexport const LICENSE_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport async function licenseGenerator(\n tree: Tree,\n options: LicenseGeneratorSchema,\n) {\n const { license, copyrightHolder } = options;\n const dependencyCheckEnabled = options.dependencyCheck !== false;\n\n await ensureAwsNxPluginConfig(tree);\n await writeLicenseConfig(\n tree,\n defaultLicenseConfig(license, copyrightHolder),\n );\n\n if (dependencyCheckEnabled) {\n const hasPython = hasPythonProjects(tree);\n await ensureDependencyCheckBlock(tree, {\n includeCollectors: hasPython ? 'npm+python' : 'npm',\n });\n // When the dependencyCheck block already existed (e.g. on a re-run after\n // python projects were added), the block above is a no-op — so explicitly\n // ensure the python collector is present. This is idempotent.\n if (hasPython) {\n await ensurePythonLicenseCollector(tree);\n }\n await addExceptionsForExistingProjects(tree);\n await writeLicenseCheckTarget(tree);\n // Make every existing project's lint target depend on the root\n // license-check target, so the check runs as part of lint/build regardless\n // of whether projects were created before or after the license generator.\n addLicenseCheckToAllLintTargets(tree);\n }\n\n const nxJson = readNxJson(tree);\n const updatedNxJson = {\n ...nxJson,\n targetDefaults: {\n ...nxJson.targetDefaults,\n lint: mergeTargetDefault(nxJson.targetDefaults?.lint, (base) => ({\n ...base,\n syncGenerators: [\n ...(base.syncGenerators ?? []).filter(\n (g) => g !== SYNC_GENERATOR_NAME,\n ),\n SYNC_GENERATOR_NAME,\n ],\n })),\n },\n };\n\n updateNxJson(tree, updatedNxJson);\n\n await addGeneratorMetricsIfApplicable(tree, [LICENSE_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n}\n\n/**\n * Write/update root project.json with the license-check target.\n */\nconst writeLicenseCheckTarget = async (tree: Tree): Promise<void> => {\n const rootProjectJsonPath = 'project.json';\n let rootProject: any = {};\n if (tree.exists(rootProjectJsonPath)) {\n rootProject = JSON.parse(tree.read(rootProjectJsonPath, 'utf-8')!);\n }\n rootProject.targets = rootProject.targets ?? {};\n rootProject.targets['license-check'] = {\n executor: '@aws/nx-plugin:license-check',\n cache: true,\n inputs: [],\n options: {},\n };\n tree.write(rootProjectJsonPath, JSON.stringify(rootProject, null, 2));\n\n // Populate `inputs` from the lockfiles actually present (+ uv.lock if a\n // Python collector is configured) and the config file.\n await updateLicenseCheckTargetInputs(tree);\n\n // Adding a root project.json registers the workspace root as an Nx project.\n // Suppress target inference from the root package.json scripts (build, lint,\n // test, etc. are `nx run-many` wrappers) so they don't become targets — an\n // inferred `build` target would recurse when running `nx run-many --target build`.\n if (tree.exists('package.json')) {\n const packageJson = JSON.parse(tree.read('package.json', 'utf-8')!);\n if (\n !packageJson.nx?.includedScripts ||\n packageJson.nx.includedScripts.length !== 0\n ) {\n packageJson.nx = { ...packageJson.nx, includedScripts: [] };\n tree.write('package.json', JSON.stringify(packageJson, null, 2));\n }\n }\n};\n\nconst addExceptionsForExistingProjects = async (tree: Tree): Promise<void> => {\n const projects = getProjects(tree);\n // A LangChain AG-UI agent pulls jsonpatch/jsonpointer (BSD-3-Clause but with\n // only free-text metadata) via langchain-core. The py#agent generator adds\n // these exceptions itself, but if the license generator runs afterwards (or\n // the agent predates the dependency-check block) they may be missing, so\n // re-assert them here when such an agent exists.\n let needsLangchain = false;\n\n for (const [, config] of projects) {\n const components =\n (config as any).metadata?.components ??\n (config as any).metadata?.generators ??\n [];\n for (const comp of components) {\n const gen = comp.generator ?? comp;\n if (\n gen === PY_AGENT_GENERATOR_INFO.id &&\n comp.framework === 'langchain'\n ) {\n needsLangchain = true;\n }\n }\n }\n\n if (needsLangchain) {\n await ensureLicenseExceptions(tree, AG_UI_LANGGRAPH_EXCEPTIONS);\n }\n};\n\nconst hasPythonProjects = (tree: Tree): boolean => {\n const projects = getProjects(tree);\n for (const [, config] of projects) {\n if (tree.exists(`${config.root}/pyproject.toml`)) return true;\n }\n return tree.exists('pyproject.toml');\n};\n\nexport default licenseGenerator;\n"],"names":["getProjects","readNxJson","updateNxJson","PY_AGENT_GENERATOR_INFO","ensureAwsNxPluginConfig","formatFilesInSubtree","addGeneratorMetricsIfApplicable","getGeneratorInfo","mergeTargetDefault","addLicenseCheckToAllLintTargets","defaultLicenseConfig","ensureDependencyCheckBlock","ensureLicenseExceptions","ensurePythonLicenseCollector","updateLicenseCheckTargetInputs","writeLicenseConfig","AG_UI_LANGGRAPH_EXCEPTIONS","SYNC_GENERATOR_NAME","LICENSE_GENERATOR_INFO","filename","licenseGenerator","tree","options","license","copyrightHolder","dependencyCheckEnabled","dependencyCheck","hasPython","hasPythonProjects","includeCollectors","addExceptionsForExistingProjects","writeLicenseCheckTarget","nxJson","updatedNxJson","targetDefaults","lint","base","syncGenerators","filter","g","rootProjectJsonPath","rootProject","exists","JSON","parse","read","targets","executor","cache","inputs","write","stringify","packageJson","nx","includedScripts","length","projects","needsLangchain","config","components","metadata","generators","comp","gen","generator","id","framework","root"],"mappings":"AAAA;;;CAGC,GACD,SAASA,WAAW,EAAEC,UAAU,EAAaC,YAAY,QAAQ,aAAa;AAC9E,SAASC,uBAAuB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/license/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { getProjects, readNxJson, type Tree, updateNxJson } from '@nx/devkit';\nimport { PY_AGENT_GENERATOR_INFO } from '../py/agent/generator.js';\nimport { ensureAwsNxPluginConfig } from '../utils/config/utils.js';\nimport { formatFilesInSubtree } from '../utils/format.js';\nimport { addGeneratorMetricsIfApplicable } from '../utils/metrics.js';\nimport {\n getGeneratorInfo,\n mergeTargetDefault,\n type NxGeneratorInfo,\n} from '../utils/nx.js';\nimport {\n addLicenseCheckToAllLintTargets,\n defaultLicenseConfig,\n ensureDependencyCheckBlock,\n ensureLicenseExceptions,\n ensurePythonLicenseCollector,\n updateLicenseCheckTargetInputs,\n writeLicenseConfig,\n} from './config.js';\nimport { AG_UI_LANGGRAPH_EXCEPTIONS } from './known-exceptions.js';\nimport type { LicenseGeneratorSchema } from './schema';\nimport { SYNC_GENERATOR_NAME } from './sync/generator.js';\n\nexport const LICENSE_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport async function licenseGenerator(\n tree: Tree,\n options: LicenseGeneratorSchema,\n) {\n const { license, copyrightHolder } = options;\n const dependencyCheckEnabled = options.dependencyCheck !== false;\n\n await ensureAwsNxPluginConfig(tree);\n await writeLicenseConfig(\n tree,\n defaultLicenseConfig(license, copyrightHolder),\n );\n\n if (dependencyCheckEnabled) {\n const hasPython = hasPythonProjects(tree);\n await ensureDependencyCheckBlock(tree, {\n includeCollectors: hasPython ? 'npm+python' : 'npm',\n });\n // When the dependencyCheck block already existed (e.g. on a re-run after\n // python projects were added), the block above is a no-op — so explicitly\n // ensure the python collector is present. This is idempotent.\n if (hasPython) {\n await ensurePythonLicenseCollector(tree);\n }\n await addExceptionsForExistingProjects(tree);\n await writeLicenseCheckTarget(tree);\n // Make every existing project's lint target depend on the root\n // license-check target, so the check runs as part of lint/build regardless\n // of whether projects were created before or after the license generator.\n addLicenseCheckToAllLintTargets(tree);\n }\n\n const nxJson = readNxJson(tree);\n const updatedNxJson = {\n ...nxJson,\n targetDefaults: {\n ...nxJson.targetDefaults,\n lint: mergeTargetDefault(nxJson.targetDefaults?.lint, (base) => ({\n ...base,\n syncGenerators: [\n ...(base.syncGenerators ?? []).filter(\n (g) => g !== SYNC_GENERATOR_NAME,\n ),\n SYNC_GENERATOR_NAME,\n ],\n })),\n },\n };\n\n updateNxJson(tree, updatedNxJson);\n\n await addGeneratorMetricsIfApplicable(tree, [LICENSE_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n}\n\n/**\n * Write/update root project.json with the license-check target.\n */\nconst writeLicenseCheckTarget = async (tree: Tree): Promise<void> => {\n const rootProjectJsonPath = 'project.json';\n let rootProject: any = {};\n if (tree.exists(rootProjectJsonPath)) {\n rootProject = JSON.parse(tree.read(rootProjectJsonPath, 'utf-8')!);\n }\n rootProject.targets = rootProject.targets ?? {};\n rootProject.targets['license-check'] = {\n executor: '@aws/nx-plugin:license-check',\n cache: true,\n inputs: [],\n options: {},\n };\n tree.write(rootProjectJsonPath, JSON.stringify(rootProject, null, 2));\n\n // Populate `inputs` from the lockfiles actually present (+ uv.lock if a\n // Python collector is configured) and the config file.\n await updateLicenseCheckTargetInputs(tree);\n\n // Adding a root project.json registers the workspace root as an Nx project.\n // Suppress target inference from the root package.json scripts (build, lint,\n // test, etc. are `nx run-many` wrappers) so they don't become targets — an\n // inferred `build` target would recurse when running `nx run-many --target build`.\n if (tree.exists('package.json')) {\n const packageJson = JSON.parse(tree.read('package.json', 'utf-8')!);\n if (\n !packageJson.nx?.includedScripts ||\n packageJson.nx.includedScripts.length !== 0\n ) {\n packageJson.nx = { ...packageJson.nx, includedScripts: [] };\n tree.write('package.json', JSON.stringify(packageJson, null, 2));\n }\n }\n};\n\nconst addExceptionsForExistingProjects = async (tree: Tree): Promise<void> => {\n const projects = getProjects(tree);\n // A LangChain AG-UI agent pulls jsonpatch/jsonpointer (BSD-3-Clause but with\n // only free-text metadata) via langchain-core. The py#agent generator adds\n // these exceptions itself, but if the license generator runs afterwards (or\n // the agent predates the dependency-check block) they may be missing, so\n // re-assert them here when such an agent exists.\n let needsLangchain = false;\n\n for (const [, config] of projects) {\n const components =\n (config as any).metadata?.components ??\n (config as any).metadata?.generators ??\n [];\n for (const comp of components) {\n const gen = comp.generator ?? comp;\n if (\n gen === PY_AGENT_GENERATOR_INFO.id &&\n comp.framework === 'langchain'\n ) {\n needsLangchain = true;\n }\n }\n }\n\n if (needsLangchain) {\n await ensureLicenseExceptions(tree, AG_UI_LANGGRAPH_EXCEPTIONS);\n }\n};\n\nconst hasPythonProjects = (tree: Tree): boolean => {\n const projects = getProjects(tree);\n for (const [, config] of projects) {\n if (tree.exists(`${config.root}/pyproject.toml`)) return true;\n }\n return tree.exists('pyproject.toml');\n};\n\nexport default licenseGenerator;\n"],"names":["getProjects","readNxJson","updateNxJson","PY_AGENT_GENERATOR_INFO","ensureAwsNxPluginConfig","formatFilesInSubtree","addGeneratorMetricsIfApplicable","getGeneratorInfo","mergeTargetDefault","addLicenseCheckToAllLintTargets","defaultLicenseConfig","ensureDependencyCheckBlock","ensureLicenseExceptions","ensurePythonLicenseCollector","updateLicenseCheckTargetInputs","writeLicenseConfig","AG_UI_LANGGRAPH_EXCEPTIONS","SYNC_GENERATOR_NAME","LICENSE_GENERATOR_INFO","filename","licenseGenerator","tree","options","license","copyrightHolder","dependencyCheckEnabled","dependencyCheck","hasPython","hasPythonProjects","includeCollectors","addExceptionsForExistingProjects","writeLicenseCheckTarget","nxJson","updatedNxJson","targetDefaults","lint","base","syncGenerators","filter","g","rootProjectJsonPath","rootProject","exists","JSON","parse","read","targets","executor","cache","inputs","write","stringify","packageJson","nx","includedScripts","length","projects","needsLangchain","config","components","metadata","generators","comp","gen","generator","id","framework","root"],"mappings":"AAAA;;;CAGC,GACD,SAASA,WAAW,EAAEC,UAAU,EAAaC,YAAY,QAAQ,aAAa;AAC9E,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,+BAA+B,QAAQ,sBAAsB;AACtE,SACEC,gBAAgB,EAChBC,kBAAkB,QAEb,iBAAiB;AACxB,SACEC,+BAA+B,EAC/BC,oBAAoB,EACpBC,0BAA0B,EAC1BC,uBAAuB,EACvBC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,kBAAkB,QACb,cAAc;AACrB,SAASC,0BAA0B,QAAQ,wBAAwB;AAEnE,SAASC,mBAAmB,QAAQ,sBAAsB;AAE1D,OAAO,MAAMC,yBAA0CX,iBACrD,YAAYY,QAAQ,EACpB;AAEF,OAAO,eAAeC,iBACpBC,IAAU,EACVC,OAA+B;IAE/B,MAAM,EAAEC,OAAO,EAAEC,eAAe,EAAE,GAAGF;IACrC,MAAMG,yBAAyBH,QAAQI,eAAe,KAAK;IAE3D,MAAMtB,wBAAwBiB;IAC9B,MAAMN,mBACJM,MACAX,qBAAqBa,SAASC;IAGhC,IAAIC,wBAAwB;QAC1B,MAAME,YAAYC,kBAAkBP;QACpC,MAAMV,2BAA2BU,MAAM;YACrCQ,mBAAmBF,YAAY,eAAe;QAChD;QACA,yEAAyE;QACzE,0EAA0E;QAC1E,8DAA8D;QAC9D,IAAIA,WAAW;YACb,MAAMd,6BAA6BQ;QACrC;QACA,MAAMS,iCAAiCT;QACvC,MAAMU,wBAAwBV;QAC9B,+DAA+D;QAC/D,2EAA2E;QAC3E,0EAA0E;QAC1EZ,gCAAgCY;IAClC;IAEA,MAAMW,SAAS/B,WAAWoB;IAC1B,MAAMY,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,EAAE;YAAC;YAC1DjC,KAAK6B,KAAK,CAAC,gBAAgBP,KAAKQ,SAAS,CAACC,aAAa,MAAM;QAC/D;IACF;AACF;AAEA,MAAMtB,mCAAmC,OAAOT;IAC9C,MAAMmC,WAAWxD,YAAYqB;IAC7B,6EAA6E;IAC7E,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,iDAAiD;IACjD,IAAIoC,iBAAiB;IAErB,KAAK,MAAM,GAAGC,OAAO,IAAIF,SAAU;QACjC,MAAMG,aACJ,AAACD,OAAeE,QAAQ,EAAED,cAC1B,AAACD,OAAeE,QAAQ,EAAEC,cAC1B,EAAE;QACJ,KAAK,MAAMC,QAAQH,WAAY;YAC7B,MAAMI,MAAMD,KAAKE,SAAS,IAAIF;YAC9B,IACEC,QAAQ5D,wBAAwB8D,EAAE,IAClCH,KAAKI,SAAS,KAAK,aACnB;gBACAT,iBAAiB;YACnB;QACF;IACF;IAEA,IAAIA,gBAAgB;QAClB,MAAM7C,wBAAwBS,MAAML;IACtC;AACF;AAEA,MAAMY,oBAAoB,CAACP;IACzB,MAAMmC,WAAWxD,YAAYqB;IAC7B,KAAK,MAAM,GAAGqC,OAAO,IAAIF,SAAU;QACjC,IAAInC,KAAKqB,MAAM,CAAC,GAAGgB,OAAOS,IAAI,CAAC,eAAe,CAAC,GAAG,OAAO;IAC3D;IACA,OAAO9C,KAAKqB,MAAM,CAAC;AACrB;AAEA,eAAetB,iBAAiB"}
|
package/src/license/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
export type { CollectedDependency, LicenseCollector, } from './dependency-check/collectors/collector';
|
|
6
|
-
export { npmCollector, pythonCollector, } from './dependency-check/collectors/collector';
|
|
7
|
-
export { PRE_APPROVED_LICENSES as DEFAULT_LICENSE_ALLOWLIST } from './dependency-check/pre-approved';
|
|
8
|
-
export type { AllowlistEntry, DependencyCheckConfig, DependencyCheckException, } from './dependency-check/types';
|
|
5
|
+
export type { CollectedDependency, LicenseCollector, } from './dependency-check/collectors/collector.js';
|
|
6
|
+
export { npmCollector, pythonCollector, } from './dependency-check/collectors/collector.js';
|
|
7
|
+
export { PRE_APPROVED_LICENSES as DEFAULT_LICENSE_ALLOWLIST } from './dependency-check/pre-approved.js';
|
|
8
|
+
export type { AllowlistEntry, DependencyCheckConfig, DependencyCheckException, } from './dependency-check/types.js';
|
package/src/license/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/license/index.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport type {\n CollectedDependency,\n LicenseCollector,\n} from './dependency-check/collectors/collector';\nexport {\n npmCollector,\n pythonCollector,\n} from './dependency-check/collectors/collector';\nexport { PRE_APPROVED_LICENSES as DEFAULT_LICENSE_ALLOWLIST } from './dependency-check/pre-approved';\nexport type {\n AllowlistEntry,\n DependencyCheckConfig,\n DependencyCheckException,\n} from './dependency-check/types';\n"],"names":["npmCollector","pythonCollector","PRE_APPROVED_LICENSES","DEFAULT_LICENSE_ALLOWLIST"],"mappings":"AAAA;;;CAGC,GAMD,SACEA,YAAY,EACZC,eAAe,QACV,
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/license/index.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport type {\n CollectedDependency,\n LicenseCollector,\n} from './dependency-check/collectors/collector.js';\nexport {\n npmCollector,\n pythonCollector,\n} from './dependency-check/collectors/collector.js';\nexport { PRE_APPROVED_LICENSES as DEFAULT_LICENSE_ALLOWLIST } from './dependency-check/pre-approved.js';\nexport type {\n AllowlistEntry,\n DependencyCheckConfig,\n DependencyCheckException,\n} from './dependency-check/types.js';\n"],"names":["npmCollector","pythonCollector","PRE_APPROVED_LICENSES","DEFAULT_LICENSE_ALLOWLIST"],"mappings":"AAAA;;;CAGC,GAMD,SACEA,YAAY,EACZC,eAAe,QACV,6CAA6C;AACpD,SAASC,yBAAyBC,yBAAyB,QAAQ,qCAAqC"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import type { DependencyCheckException } from './dependency-check/types';
|
|
5
|
+
import type { DependencyCheckException } from './dependency-check/types.js';
|
|
6
6
|
export declare const AG_UI_LANGGRAPH_EXCEPTIONS: DependencyCheckException[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/license/known-exceptions.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { DependencyCheckException } from './dependency-check/types';\n\nexport const AG_UI_LANGGRAPH_EXCEPTIONS: DependencyCheckException[] = [\n {\n package: 'jsonpatch',\n reason:\n 'Unconditional dependency of langchain-core. Genuinely BSD-3-Clause (LICENSE matches the SPDX BSD-3-Clause template), but the wheel only carries the free-text \"Modified BSD License\" metadata, not an SPDX expression.',\n spdx: 'BSD-3-Clause',\n },\n {\n package: 'jsonpointer',\n reason:\n 'Transitive dependency of jsonpatch (via langchain-core). Genuinely BSD-3-Clause (LICENSE matches the SPDX BSD-3-Clause template), but the wheel only carries the free-text \"Modified BSD License\" metadata, not an SPDX expression.',\n spdx: 'BSD-3-Clause',\n },\n];\n"],"names":["AG_UI_LANGGRAPH_EXCEPTIONS","package","reason","spdx"],"mappings":"AAAA;;;CAGC,GAGD,OAAO,MAAMA,6BAAyD;IACpE;QACEC,SAAS;QACTC,QACE;QACFC,MAAM;IACR;IACA;QACEF,SAAS;QACTC,QACE;QACFC,MAAM;IACR;CACD,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/license/known-exceptions.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { DependencyCheckException } from './dependency-check/types.js';\n\nexport const AG_UI_LANGGRAPH_EXCEPTIONS: DependencyCheckException[] = [\n {\n package: 'jsonpatch',\n reason:\n 'Unconditional dependency of langchain-core. Genuinely BSD-3-Clause (LICENSE matches the SPDX BSD-3-Clause template), but the wheel only carries the free-text \"Modified BSD License\" metadata, not an SPDX expression.',\n spdx: 'BSD-3-Clause',\n },\n {\n package: 'jsonpointer',\n reason:\n 'Transitive dependency of jsonpatch (via langchain-core). Genuinely BSD-3-Clause (LICENSE matches the SPDX BSD-3-Clause template), but the wheel only carries the free-text \"Modified BSD License\" metadata, not an SPDX expression.',\n spdx: 'BSD-3-Clause',\n },\n];\n"],"names":["AG_UI_LANGGRAPH_EXCEPTIONS","package","reason","spdx"],"mappings":"AAAA;;;CAGC,GAGD,OAAO,MAAMA,6BAAyD;IACpE;QACEC,SAAS;QACTC,QACE;QACFC,MAAM;IACR;IACA;QACEF,SAAS;QACTC,QACE;QACFC,MAAM;IACR;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/license/sync/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n globAsync,\n joinPathFragments,\n type Tree,\n} from '@nx/devkit';\nimport fastGlob from 'fast-glob';\nimport { minimatch } from 'minimatch';\nimport type { SyncGeneratorResult } from 'nx/src/utils/sync-generators';\nimport { basename } from 'path';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../../utils/config/utils';\nimport { getGitIncludedFiles, isWithinGitRepo } from '../../utils/git';\nimport { getGeneratorInfo } from '../../utils/nx';\nimport { LANGUAGE_COMMENT_SYNTAX, readLicenseConfig } from '../config';\nimport type {\n CommentSyntax,\n LicenseHeaderConfig,\n LicenseHeaderFormat,\n} from '../config-types';\nimport {\n PROJECT_FILES_TO_SYNC,\n type ProjectFileToSync,\n syncProjectFile,\n} from './project-file-sync';\n\nexport const SYNC_GENERATOR_NAME = `${PackageJson.name}:${getGeneratorInfo(import.meta.filename).id}`;\n\ninterface ProjectFile {\n name: ProjectFileToSync;\n path: string;\n}\n\nexport async function licenseSyncGenerator(\n tree: Tree,\n): Promise<SyncGeneratorResult> {\n const source = (await readLicenseConfig(tree))?.source;\n\n if (!source) {\n // Nothing to do when source licensing (headers + LICENSE files) isn't configured\n return {};\n }\n\n const licenseHeadersUpdated: string[] = [];\n\n if (source.header) {\n // Get all candidate project files for header\n const candidateProjectFiles = await getCandidateProjectFilesForHeader(\n tree,\n source.header,\n );\n\n const headerContentLines = loadHeaderContentLines(tree, source.header);\n\n // Add headers to project files which match the include pattern\n for (const [includePattern, format] of Object.entries(\n source.header.format,\n )) {\n const files = minimatch.match(candidateProjectFiles, includePattern);\n\n files.forEach((file) => {\n const didAdd = addHeader(\n tree,\n file,\n headerContentLines,\n source.header,\n format,\n );\n if (didAdd) {\n licenseHeadersUpdated.push(file);\n }\n });\n }\n }\n\n const projectFilesUpdated: ProjectFile[] = [];\n\n // Helper to check whether a file should be included in the sync based on file exclude configuration\n const isFileIncludedInSync = (path: string): boolean =>\n !(source.files?.exclude ?? []).some((excludePattern) =>\n minimatch(path, excludePattern),\n );\n\n // Sync files in the root, and all projects\n const projectRoots = [\n '.',\n ...[...getProjects(tree).values()].map((p) => p.root),\n ];\n\n // Sync subproject license files and project files\n for (const projectRoot of projectRoots) {\n // Check that this project should have files synced - allows users to specify a project path\n // to exclude from all file syncs\n if (isFileIncludedInSync(projectRoot)) {\n PROJECT_FILES_TO_SYNC.forEach((projectFile) => {\n const projectFilePath = joinPathFragments(projectRoot, projectFile);\n // Check that the specific project file should be synced - allows users to be more granular to\n // decide to eg omit LICENSE file sync but keep package.json sync\n if (isFileIncludedInSync(projectFilePath)) {\n const prevContent = tree.read(projectFilePath, 'utf-8');\n\n syncProjectFile(tree, projectRoot, projectFile, source);\n\n const newContent = tree.read(projectFilePath, 'utf-8');\n\n if (prevContent !== newContent) {\n projectFilesUpdated.push({\n path: projectFilePath,\n name: projectFile,\n });\n }\n }\n });\n }\n }\n\n return {\n outOfSyncMessage: buildOutOfSyncMessage({\n licenseHeadersUpdated,\n projectFilesUpdated,\n }),\n };\n}\n\n/**\n * Build the message to display when the sync generator would make changes to the tree\n */\nconst buildOutOfSyncMessage = (updates: {\n projectFilesUpdated: ProjectFile[];\n licenseHeadersUpdated: string[];\n}): string => {\n let outOfSyncMessage = '';\n\n const pathsByName: { [key: string]: string[] } =\n updates.projectFilesUpdated.reduce(\n (prev, { name, path }) => ({\n ...prev,\n [name]: [...(prev[name] ?? []), path],\n }),\n {},\n );\n Object.entries(pathsByName).forEach(([name, files]) => {\n outOfSyncMessage += `Project ${name} files are out of sync:\\n${files.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n });\n\n if (updates.licenseHeadersUpdated.length > 0) {\n outOfSyncMessage += `License headers are out of sync in the following source files:\\n${updates.licenseHeadersUpdated.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n }\n\n return outOfSyncMessage.trim();\n};\n\n/**\n * Load the license header content lines\n */\nconst loadHeaderContentLines = (\n tree: Tree,\n config: LicenseHeaderConfig,\n): string[] => {\n // Load the license header content\n let headerContentLines = [];\n if ('lines' in config.content) {\n headerContentLines = config.content.lines;\n } else {\n if (!tree.exists(config.content.filePath)) {\n throw new Error(\n `Could not find license header content file ${config.content.filePath}`,\n );\n }\n headerContentLines = tree\n .read(config.content.filePath, 'utf-8')\n .split('\\n');\n }\n return headerContentLines;\n};\n\n/**\n * Returns all files in the given tree - both in-memory only and in the filesystem under the tree root\n */\nconst getAllFilesInTree = async (tree: Tree): Promise<string[]> => {\n return [\n ...new Set([\n // Get all files in memory in the tree\n ...(await globAsync(tree, ['*', '**/*'])),\n // Find all files on the filesystem that may not be in memory in the tree\n ...(await fastGlob(['*', '**/*'], { cwd: tree.root, dot: true })),\n ]),\n ].filter((f) => tree.exists(f));\n};\n\n/**\n * Returns the list of project files\n */\nconst getCandidateProjectFilesForHeader = async (\n tree: Tree,\n config: LicenseHeaderConfig,\n): Promise<string[]> => {\n // Prefer, if possible, to treat all non gitignored files as our candidate set such that we honour users .gitignore files\n // If we're not in a git repo, fall back to everything and rely on the user configuring exclusions below\n const projectFiles = isWithinGitRepo(tree)\n ? getGitIncludedFiles(tree)\n : await getAllFilesInTree(tree);\n\n // Remove any files that were excluded in the config\n const ignoredProjectFiles = new Set(\n (config.exclude ?? []).flatMap((pattern) =>\n minimatch.match(projectFiles, pattern),\n ),\n );\n return projectFiles.filter((file) => !ignoredProjectFiles.has(file));\n};\n\n/**\n * Renders a header with the given format\n */\nconst renderHeader = (\n contentLines: string[],\n format: LicenseHeaderFormat,\n): string => {\n return `${format.blockStart ? `${format.blockStart}\\n` : ''}${contentLines.map((line) => `${format.lineStart ?? ''}${line}${format.lineEnd ?? ''}`).join('\\n')}${format.blockEnd ? `\\n${format.blockEnd}` : ''}`;\n};\n\n/**\n * Validates header format to ensure it produces a valid comment\n */\nconst validateFormat = (\n fileExtension: string,\n syntax: CommentSyntax,\n format: LicenseHeaderFormat,\n contentLines: string[],\n): void => {\n const blockStartOpensBlockComment =\n format.blockStart &&\n syntax.block &&\n format.blockStart.startsWith(syntax.block.start);\n const blockEndClosesBlockComment =\n format.blockEnd &&\n syntax.block &&\n format.blockEnd.endsWith(syntax.block.end);\n\n // Block start must start with the block start or line comment\n const validBlockStart =\n !format.blockStart ||\n blockStartOpensBlockComment ||\n (syntax.line && format.blockStart.startsWith(syntax.line));\n // Block end must end with the block end, or begin with the line comment\n const validBlockEnd =\n !format.blockEnd ||\n blockEndClosesBlockComment ||\n (syntax.line && format.blockEnd.startsWith(syntax.line));\n\n // Lines must start with the line comment syntax, unless within a block comment\n const validLineStart =\n !format.lineStart ||\n (syntax.line && format.lineStart.startsWith(syntax.line)) ||\n (blockStartOpensBlockComment && blockEndClosesBlockComment);\n\n if (!validLineStart || !validBlockStart || !validBlockEnd) {\n throw new Error(\n `Provided format for ${fileExtension} file would generate invalid comment syntax. Configured syntax for ${fileExtension} is ${JSON.stringify(syntax, null, 2)}.`,\n );\n }\n\n if (blockStartOpensBlockComment && !blockEndClosesBlockComment) {\n throw new Error(\n `Provided format for ${fileExtension} file opens a block comment with \"${syntax.block.start}\" in blockStart but does not close it with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n\n if (\n blockStartOpensBlockComment &&\n contentLines.some((line) => line.includes(syntax.block.end))\n ) {\n throw new Error(\n `Provided license content would close a block comment early and cause a syntax error! Please remove \"${syntax.block.end}\" from your license text.`,\n );\n }\n\n if (blockStartOpensBlockComment && blockEndClosesBlockComment) {\n if (\n format.blockEnd.lastIndexOf(syntax.block.end) !==\n format.blockEnd.indexOf(syntax.block.end)\n ) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors due to closing a block comment multiple times with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n if (format.blockStart.includes(syntax.block.end)) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors since it closes the block comment with \"${syntax.block.end}\" in blockStart`,\n );\n }\n }\n};\n\n/**\n * Parse the hashbang, header and body from a file.\n * The header is the first block comment, or consecutive series of line comments found in the file, after the hashbang\n */\nconst parseFile = (\n content: string,\n syntax: CommentSyntax,\n): { hashbang: string; header: string; body: string } => {\n const lines = content.split('\\n');\n let i = 0;\n\n // Hashbangs must always go first, so extract this if it exists\n const hashbangLines = [];\n for (; i < lines.length; i++) {\n if (hashbangLines.length === 0) {\n if (lines[i].startsWith('#!')) {\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n } else {\n if (lines[i].trim().length === 0) {\n // Preserve any empty lines following the hashbang\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n }\n }\n\n // After the hashbang, consume the next comment which follows.\n // This could either be all lines of a block comment, or all consecutive line comments until a non line-comment is seen\n const headerLines = [];\n let withinBlockComment = false;\n let withinLineCommentSeries = false;\n for (; i < lines.length; i++) {\n const trimmedLine = lines[i].trim();\n if (\n syntax.block &&\n trimmedLine.endsWith(syntax.block.end) &&\n !withinLineCommentSeries &&\n (withinBlockComment || trimmedLine.startsWith(syntax.block.start))\n ) {\n // Comment ends with the block end, so we've completed the header and therefore break out of the loop\n headerLines.push(lines[i]);\n i++; // Increment here to ensure we point to the next line for the body\n break;\n } else if (\n syntax.block &&\n trimmedLine.startsWith(syntax.block.start) &&\n !withinLineCommentSeries\n ) {\n // Line begins a comment block (without also ending it on the same line), so start consuming the block\n withinBlockComment = true;\n headerLines.push(lines[i]);\n } else if (withinBlockComment) {\n // We haven't yet closed the block comment, so consume this line\n headerLines.push(lines[i]);\n } else if (syntax.line && trimmedLine.startsWith(syntax.line)) {\n // Line starts with the line comment syntax, so consume it\n withinLineCommentSeries = true;\n headerLines.push(lines[i]);\n } else {\n break;\n }\n }\n\n // Body of the file is the rest\n const bodyLines = lines.slice(i);\n\n return {\n hashbang: hashbangLines.join('\\n'),\n header: headerLines.join('\\n'),\n body: bodyLines.join('\\n'),\n };\n};\n\n/**\n * Add a header to the given file according to the header content and license config\n * Returns true if the header was added/updated, and false otherwise.\n */\nconst addHeader = (\n tree: Tree,\n file: string,\n contentLines: string[],\n config: LicenseHeaderConfig,\n format: LicenseHeaderFormat,\n): boolean => {\n const fileName = basename(file);\n const fileNameParts = fileName.split('.');\n const fileExtension = fileNameParts[fileNameParts.length - 1];\n\n const syntax =\n (config.commentSyntax ?? {})[fileExtension] ??\n LANGUAGE_COMMENT_SYNTAX[fileExtension];\n if (!syntax) {\n throw new Error(`Unknown file extension ${fileExtension}. Please configure commentSyntax in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}, eg:\n\nexport default {\n license: {\n header: {\n ...\n commentSyntax: {\n ${fileExtension}: {\n line: \"//\",\n block: { start: \"/*\", end: \"*/\" }\n }\n }\n }\n }\n} satisfies AwsNxPluginConfig;\n`);\n }\n\n // Check that we would render a valid comment\n validateFormat(fileExtension, syntax, format, contentLines);\n\n const existingContent = tree.read(file, 'utf-8');\n\n const { hashbang, body } = parseFile(existingContent, syntax);\n\n const newContent = [\n ...(hashbang ? [hashbang] : []),\n renderHeader(contentLines, format),\n body,\n ].join('\\n');\n\n // Sanity check that we wouldn't edit the hashbang or body, only the header\n const { hashbang: newHashbang, body: newBody } = parseFile(\n newContent,\n syntax,\n );\n if (hashbang !== newHashbang || body !== newBody) {\n throw new Error(\n `The license header content, or format for ${fileExtension} files would produce a header that cannot be safely replaced in ${file}. Please revise license content and format in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}`,\n );\n }\n\n if (newContent !== existingContent) {\n tree.write(file, newContent);\n return true;\n }\n\n return false;\n};\n\nexport default licenseSyncGenerator;\n"],"names":["getProjects","globAsync","joinPathFragments","fastGlob","minimatch","basename","PackageJson","type","AWS_NX_PLUGIN_CONFIG_FILE_NAME","getGitIncludedFiles","isWithinGitRepo","getGeneratorInfo","LANGUAGE_COMMENT_SYNTAX","readLicenseConfig","PROJECT_FILES_TO_SYNC","syncProjectFile","SYNC_GENERATOR_NAME","name","filename","id","licenseSyncGenerator","tree","source","licenseHeadersUpdated","header","candidateProjectFiles","getCandidateProjectFilesForHeader","headerContentLines","loadHeaderContentLines","includePattern","format","Object","entries","files","match","forEach","file","didAdd","addHeader","push","projectFilesUpdated","isFileIncludedInSync","path","exclude","some","excludePattern","projectRoots","values","map","p","root","projectRoot","projectFile","projectFilePath","prevContent","read","newContent","outOfSyncMessage","buildOutOfSyncMessage","updates","pathsByName","reduce","prev","join","length","trim","config","content","lines","exists","filePath","Error","split","getAllFilesInTree","Set","cwd","dot","filter","f","projectFiles","ignoredProjectFiles","flatMap","pattern","has","renderHeader","contentLines","blockStart","line","lineStart","lineEnd","blockEnd","validateFormat","fileExtension","syntax","blockStartOpensBlockComment","block","startsWith","start","blockEndClosesBlockComment","endsWith","end","validBlockStart","validBlockEnd","validLineStart","JSON","stringify","includes","lastIndexOf","indexOf","parseFile","i","hashbangLines","headerLines","withinBlockComment","withinLineCommentSeries","trimmedLine","bodyLines","slice","hashbang","body","fileName","fileNameParts","commentSyntax","existingContent","newHashbang","newBody","write"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,SAAS,EACTC,iBAAiB,QAEZ,aAAa;AACpB,OAAOC,cAAc,YAAY;AACjC,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,QAAQ,QAAQ,OAAO;AAChC,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,8BAA8B,QAAQ,8BAA2B;AAC1E,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,qBAAkB;AACvE,SAASC,gBAAgB,QAAQ,oBAAiB;AAClD,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,eAAY;AAMvE,SACEC,qBAAqB,EAErBC,eAAe,QACV,yBAAsB;AAE7B,OAAO,MAAMC,sBAAsB,GAAGV,YAAYW,IAAI,CAAC,CAAC,EAAEN,iBAAiB,YAAYO,QAAQ,EAAEC,EAAE,EAAE,CAAC;AAOtG,OAAO,eAAeC,qBACpBC,IAAU;IAEV,MAAMC,SAAU,CAAA,MAAMT,kBAAkBQ,KAAI,GAAIC;IAEhD,IAAI,CAACA,QAAQ;QACX,iFAAiF;QACjF,OAAO,CAAC;IACV;IAEA,MAAMC,wBAAkC,EAAE;IAE1C,IAAID,OAAOE,MAAM,EAAE;QACjB,6CAA6C;QAC7C,MAAMC,wBAAwB,MAAMC,kCAClCL,MACAC,OAAOE,MAAM;QAGf,MAAMG,qBAAqBC,uBAAuBP,MAAMC,OAAOE,MAAM;QAErE,+DAA+D;QAC/D,KAA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,CAAC,CAAA,CAAE,CAAC9B,cAAc,IAC3ChF,uBAAuB,CAACgF,cAAc;IACxC,IAAI,CAACC,QAAQ;QACX,MAAM,IAAItB,MAAM,CAAC,uBAAuB,EAAEqB,cAAc,oCAAoC,EAAEpF,+BAA+B;;;;;;;QAOzH,EAAEoF,cAAc;;;;;;;;AAQxB,CAAC;IACC;IAEA,6CAA6C;IAC7CD,eAAeC,eAAeC,QAAQ/D,QAAQuD;IAE9C,MAAMsC,kBAAkBtG,KAAKkC,IAAI,CAACnB,MAAM;IAExC,MAAM,EAAEkF,QAAQ,EAAEC,IAAI,EAAE,GAAGV,UAAUc,iBAAiB9B;IAEtD,MAAMrC,aAAa;WACb8D,WAAW;YAACA;SAAS,GAAG,EAAE;QAC9BlC,aAAaC,cAAcvD;QAC3ByF;KACD,CAACxD,IAAI,CAAC;IAEP,2EAA2E;IAC3E,MAAM,EAAEuD,UAAUM,WAAW,EAAEL,MAAMM,OAAO,EAAE,GAAGhB,UAC/CrD,YACAqC;IAEF,IAAIyB,aAAaM,eAAeL,SAASM,SAAS;QAChD,MAAM,IAAItD,MACR,CAAC,0CAA0C,EAAEqB,cAAc,gEAAgE,EAAExD,KAAK,8CAA8C,EAAE5B,gCAAgC;IAEtN;IAEA,IAAIgD,eAAemE,iBAAiB;QAClCtG,KAAKyG,KAAK,CAAC1F,MAAMoB;QACjB,OAAO;IACT;IAEA,OAAO;AACT;AAEA,eAAepC,qBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/license/sync/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n globAsync,\n joinPathFragments,\n type Tree,\n} from '@nx/devkit';\nimport fastGlob from 'fast-glob';\nimport { minimatch } from 'minimatch';\nimport type { SyncGeneratorResult } from 'nx/src/utils/sync-generators';\nimport { basename } from 'path';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../../utils/config/utils.js';\nimport { getGitIncludedFiles, isWithinGitRepo } from '../../utils/git.js';\nimport { getGeneratorInfo } from '../../utils/nx.js';\nimport { LANGUAGE_COMMENT_SYNTAX, readLicenseConfig } from '../config.js';\nimport type {\n CommentSyntax,\n LicenseHeaderConfig,\n LicenseHeaderFormat,\n} from '../config-types.js';\nimport {\n PROJECT_FILES_TO_SYNC,\n type ProjectFileToSync,\n syncProjectFile,\n} from './project-file-sync.js';\n\nexport const SYNC_GENERATOR_NAME = `${PackageJson.name}:${getGeneratorInfo(import.meta.filename).id}`;\n\ninterface ProjectFile {\n name: ProjectFileToSync;\n path: string;\n}\n\nexport async function licenseSyncGenerator(\n tree: Tree,\n): Promise<SyncGeneratorResult> {\n const source = (await readLicenseConfig(tree))?.source;\n\n if (!source) {\n // Nothing to do when source licensing (headers + LICENSE files) isn't configured\n return {};\n }\n\n const licenseHeadersUpdated: string[] = [];\n\n if (source.header) {\n // Get all candidate project files for header\n const candidateProjectFiles = await getCandidateProjectFilesForHeader(\n tree,\n source.header,\n );\n\n const headerContentLines = loadHeaderContentLines(tree, source.header);\n\n // Add headers to project files which match the include pattern\n for (const [includePattern, format] of Object.entries(\n source.header.format,\n )) {\n const files = minimatch.match(candidateProjectFiles, includePattern);\n\n files.forEach((file) => {\n const didAdd = addHeader(\n tree,\n file,\n headerContentLines,\n source.header,\n format,\n );\n if (didAdd) {\n licenseHeadersUpdated.push(file);\n }\n });\n }\n }\n\n const projectFilesUpdated: ProjectFile[] = [];\n\n // Helper to check whether a file should be included in the sync based on file exclude configuration\n const isFileIncludedInSync = (path: string): boolean =>\n !(source.files?.exclude ?? []).some((excludePattern) =>\n minimatch(path, excludePattern),\n );\n\n // Sync files in the root, and all projects\n const projectRoots = [\n '.',\n ...[...getProjects(tree).values()].map((p) => p.root),\n ];\n\n // Sync subproject license files and project files\n for (const projectRoot of projectRoots) {\n // Check that this project should have files synced - allows users to specify a project path\n // to exclude from all file syncs\n if (isFileIncludedInSync(projectRoot)) {\n PROJECT_FILES_TO_SYNC.forEach((projectFile) => {\n const projectFilePath = joinPathFragments(projectRoot, projectFile);\n // Check that the specific project file should be synced - allows users to be more granular to\n // decide to eg omit LICENSE file sync but keep package.json sync\n if (isFileIncludedInSync(projectFilePath)) {\n const prevContent = tree.read(projectFilePath, 'utf-8');\n\n syncProjectFile(tree, projectRoot, projectFile, source);\n\n const newContent = tree.read(projectFilePath, 'utf-8');\n\n if (prevContent !== newContent) {\n projectFilesUpdated.push({\n path: projectFilePath,\n name: projectFile,\n });\n }\n }\n });\n }\n }\n\n return {\n outOfSyncMessage: buildOutOfSyncMessage({\n licenseHeadersUpdated,\n projectFilesUpdated,\n }),\n };\n}\n\n/**\n * Build the message to display when the sync generator would make changes to the tree\n */\nconst buildOutOfSyncMessage = (updates: {\n projectFilesUpdated: ProjectFile[];\n licenseHeadersUpdated: string[];\n}): string => {\n let outOfSyncMessage = '';\n\n const pathsByName: { [key: string]: string[] } =\n updates.projectFilesUpdated.reduce(\n (prev, { name, path }) => ({\n ...prev,\n [name]: [...(prev[name] ?? []), path],\n }),\n {},\n );\n Object.entries(pathsByName).forEach(([name, files]) => {\n outOfSyncMessage += `Project ${name} files are out of sync:\\n${files.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n });\n\n if (updates.licenseHeadersUpdated.length > 0) {\n outOfSyncMessage += `License headers are out of sync in the following source files:\\n${updates.licenseHeadersUpdated.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n }\n\n return outOfSyncMessage.trim();\n};\n\n/**\n * Load the license header content lines\n */\nconst loadHeaderContentLines = (\n tree: Tree,\n config: LicenseHeaderConfig,\n): string[] => {\n // Load the license header content\n let headerContentLines = [];\n if ('lines' in config.content) {\n headerContentLines = config.content.lines;\n } else {\n if (!tree.exists(config.content.filePath)) {\n throw new Error(\n `Could not find license header content file ${config.content.filePath}`,\n );\n }\n headerContentLines = tree\n .read(config.content.filePath, 'utf-8')\n .split('\\n');\n }\n return headerContentLines;\n};\n\n/**\n * Returns all files in the given tree - both in-memory only and in the filesystem under the tree root\n */\nconst getAllFilesInTree = async (tree: Tree): Promise<string[]> => {\n return [\n ...new Set([\n // Get all files in memory in the tree\n ...(await globAsync(tree, ['*', '**/*'])),\n // Find all files on the filesystem that may not be in memory in the tree\n ...(await fastGlob(['*', '**/*'], { cwd: tree.root, dot: true })),\n ]),\n ].filter((f) => tree.exists(f));\n};\n\n/**\n * Returns the list of project files\n */\nconst getCandidateProjectFilesForHeader = async (\n tree: Tree,\n config: LicenseHeaderConfig,\n): Promise<string[]> => {\n // Prefer, if possible, to treat all non gitignored files as our candidate set such that we honour users .gitignore files\n // If we're not in a git repo, fall back to everything and rely on the user configuring exclusions below\n const projectFiles = isWithinGitRepo(tree)\n ? getGitIncludedFiles(tree)\n : await getAllFilesInTree(tree);\n\n // Remove any files that were excluded in the config\n const ignoredProjectFiles = new Set(\n (config.exclude ?? []).flatMap((pattern) =>\n minimatch.match(projectFiles, pattern),\n ),\n );\n return projectFiles.filter((file) => !ignoredProjectFiles.has(file));\n};\n\n/**\n * Renders a header with the given format\n */\nconst renderHeader = (\n contentLines: string[],\n format: LicenseHeaderFormat,\n): string => {\n return `${format.blockStart ? `${format.blockStart}\\n` : ''}${contentLines.map((line) => `${format.lineStart ?? ''}${line}${format.lineEnd ?? ''}`).join('\\n')}${format.blockEnd ? `\\n${format.blockEnd}` : ''}`;\n};\n\n/**\n * Validates header format to ensure it produces a valid comment\n */\nconst validateFormat = (\n fileExtension: string,\n syntax: CommentSyntax,\n format: LicenseHeaderFormat,\n contentLines: string[],\n): void => {\n const blockStartOpensBlockComment =\n format.blockStart &&\n syntax.block &&\n format.blockStart.startsWith(syntax.block.start);\n const blockEndClosesBlockComment =\n format.blockEnd &&\n syntax.block &&\n format.blockEnd.endsWith(syntax.block.end);\n\n // Block start must start with the block start or line comment\n const validBlockStart =\n !format.blockStart ||\n blockStartOpensBlockComment ||\n (syntax.line && format.blockStart.startsWith(syntax.line));\n // Block end must end with the block end, or begin with the line comment\n const validBlockEnd =\n !format.blockEnd ||\n blockEndClosesBlockComment ||\n (syntax.line && format.blockEnd.startsWith(syntax.line));\n\n // Lines must start with the line comment syntax, unless within a block comment\n const validLineStart =\n !format.lineStart ||\n (syntax.line && format.lineStart.startsWith(syntax.line)) ||\n (blockStartOpensBlockComment && blockEndClosesBlockComment);\n\n if (!validLineStart || !validBlockStart || !validBlockEnd) {\n throw new Error(\n `Provided format for ${fileExtension} file would generate invalid comment syntax. Configured syntax for ${fileExtension} is ${JSON.stringify(syntax, null, 2)}.`,\n );\n }\n\n if (blockStartOpensBlockComment && !blockEndClosesBlockComment) {\n throw new Error(\n `Provided format for ${fileExtension} file opens a block comment with \"${syntax.block.start}\" in blockStart but does not close it with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n\n if (\n blockStartOpensBlockComment &&\n contentLines.some((line) => line.includes(syntax.block.end))\n ) {\n throw new Error(\n `Provided license content would close a block comment early and cause a syntax error! Please remove \"${syntax.block.end}\" from your license text.`,\n );\n }\n\n if (blockStartOpensBlockComment && blockEndClosesBlockComment) {\n if (\n format.blockEnd.lastIndexOf(syntax.block.end) !==\n format.blockEnd.indexOf(syntax.block.end)\n ) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors due to closing a block comment multiple times with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n if (format.blockStart.includes(syntax.block.end)) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors since it closes the block comment with \"${syntax.block.end}\" in blockStart`,\n );\n }\n }\n};\n\n/**\n * Parse the hashbang, header and body from a file.\n * The header is the first block comment, or consecutive series of line comments found in the file, after the hashbang\n */\nconst parseFile = (\n content: string,\n syntax: CommentSyntax,\n): { hashbang: string; header: string; body: string } => {\n const lines = content.split('\\n');\n let i = 0;\n\n // Hashbangs must always go first, so extract this if it exists\n const hashbangLines = [];\n for (; i < lines.length; i++) {\n if (hashbangLines.length === 0) {\n if (lines[i].startsWith('#!')) {\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n } else {\n if (lines[i].trim().length === 0) {\n // Preserve any empty lines following the hashbang\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n }\n }\n\n // After the hashbang, consume the next comment which follows.\n // This could either be all lines of a block comment, or all consecutive line comments until a non line-comment is seen\n const headerLines = [];\n let withinBlockComment = false;\n let withinLineCommentSeries = false;\n for (; i < lines.length; i++) {\n const trimmedLine = lines[i].trim();\n if (\n syntax.block &&\n trimmedLine.endsWith(syntax.block.end) &&\n !withinLineCommentSeries &&\n (withinBlockComment || trimmedLine.startsWith(syntax.block.start))\n ) {\n // Comment ends with the block end, so we've completed the header and therefore break out of the loop\n headerLines.push(lines[i]);\n i++; // Increment here to ensure we point to the next line for the body\n break;\n } else if (\n syntax.block &&\n trimmedLine.startsWith(syntax.block.start) &&\n !withinLineCommentSeries\n ) {\n // Line begins a comment block (without also ending it on the same line), so start consuming the block\n withinBlockComment = true;\n headerLines.push(lines[i]);\n } else if (withinBlockComment) {\n // We haven't yet closed the block comment, so consume this line\n headerLines.push(lines[i]);\n } else if (syntax.line && trimmedLine.startsWith(syntax.line)) {\n // Line starts with the line comment syntax, so consume it\n withinLineCommentSeries = true;\n headerLines.push(lines[i]);\n } else {\n break;\n }\n }\n\n // Body of the file is the rest\n const bodyLines = lines.slice(i);\n\n return {\n hashbang: hashbangLines.join('\\n'),\n header: headerLines.join('\\n'),\n body: bodyLines.join('\\n'),\n };\n};\n\n/**\n * Add a header to the given file according to the header content and license config\n * Returns true if the header was added/updated, and false otherwise.\n */\nconst addHeader = (\n tree: Tree,\n file: string,\n contentLines: string[],\n config: LicenseHeaderConfig,\n format: LicenseHeaderFormat,\n): boolean => {\n const fileName = basename(file);\n const fileNameParts = fileName.split('.');\n const fileExtension = fileNameParts[fileNameParts.length - 1];\n\n const syntax =\n (config.commentSyntax ?? {})[fileExtension] ??\n LANGUAGE_COMMENT_SYNTAX[fileExtension];\n if (!syntax) {\n throw new Error(`Unknown file extension ${fileExtension}. Please configure commentSyntax in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}, eg:\n\nexport default {\n license: {\n header: {\n ...\n commentSyntax: {\n ${fileExtension}: {\n line: \"//\",\n block: { start: \"/*\", end: \"*/\" }\n }\n }\n }\n }\n} satisfies AwsNxPluginConfig;\n`);\n }\n\n // Check that we would render a valid comment\n validateFormat(fileExtension, syntax, format, contentLines);\n\n const existingContent = tree.read(file, 'utf-8');\n\n const { hashbang, body } = parseFile(existingContent, syntax);\n\n const newContent = [\n ...(hashbang ? [hashbang] : []),\n renderHeader(contentLines, format),\n body,\n ].join('\\n');\n\n // Sanity check that we wouldn't edit the hashbang or body, only the header\n const { hashbang: newHashbang, body: newBody } = parseFile(\n newContent,\n syntax,\n );\n if (hashbang !== newHashbang || body !== newBody) {\n throw new Error(\n `The license header content, or format for ${fileExtension} files would produce a header that cannot be safely replaced in ${file}. Please revise license content and format in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}`,\n );\n }\n\n if (newContent !== existingContent) {\n tree.write(file, newContent);\n return true;\n }\n\n return false;\n};\n\nexport default licenseSyncGenerator;\n"],"names":["getProjects","globAsync","joinPathFragments","fastGlob","minimatch","basename","PackageJson","type","AWS_NX_PLUGIN_CONFIG_FILE_NAME","getGitIncludedFiles","isWithinGitRepo","getGeneratorInfo","LANGUAGE_COMMENT_SYNTAX","readLicenseConfig","PROJECT_FILES_TO_SYNC","syncProjectFile","SYNC_GENERATOR_NAME","name","filename","id","licenseSyncGenerator","tree","source","licenseHeadersUpdated","header","candidateProjectFiles","getCandidateProjectFilesForHeader","headerContentLines","loadHeaderContentLines","includePattern","format","Object","entries","files","match","forEach","file","didAdd","addHeader","push","projectFilesUpdated","isFileIncludedInSync","path","exclude","some","excludePattern","projectRoots","values","map","p","root","projectRoot","projectFile","projectFilePath","prevContent","read","newContent","outOfSyncMessage","buildOutOfSyncMessage","updates","pathsByName","reduce","prev","join","length","trim","config","content","lines","exists","filePath","Error","split","getAllFilesInTree","Set","cwd","dot","filter","f","projectFiles","ignoredProjectFiles","flatMap","pattern","has","renderHeader","contentLines","blockStart","line","lineStart","lineEnd","blockEnd","validateFormat","fileExtension","syntax","blockStartOpensBlockComment","block","startsWith","start","blockEndClosesBlockComment","endsWith","end","validBlockStart","validBlockEnd","validLineStart","JSON","stringify","includes","lastIndexOf","indexOf","parseFile","i","hashbangLines","headerLines","withinBlockComment","withinLineCommentSeries","trimmedLine","bodyLines","slice","hashbang","body","fileName","fileNameParts","commentSyntax","existingContent","newHashbang","newBody","write"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,SAAS,EACTC,iBAAiB,QAEZ,aAAa;AACpB,OAAOC,cAAc,YAAY;AACjC,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,QAAQ,QAAQ,OAAO;AAChC,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,8BAA8B,QAAQ,8BAA8B;AAC7E,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,qBAAqB;AAC1E,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,eAAe;AAM1E,SACEC,qBAAqB,EAErBC,eAAe,QACV,yBAAyB;AAEhC,OAAO,MAAMC,sBAAsB,GAAGV,YAAYW,IAAI,CAAC,CAAC,EAAEN,iBAAiB,YAAYO,QAAQ,EAAEC,EAAE,EAAE,CAAC;AAOtG,OAAO,eAAeC,qBACpBC,IAAU;IAEV,MAAMC,SAAU,CAAA,MAAMT,kBAAkBQ,KAAI,GAAIC;IAEhD,IAAI,CAACA,QAAQ;QACX,iFAAiF;QACjF,OAAO,CAAC;IACV;IAEA,MAAMC,wBAAkC,EAAE;IAE1C,IAAID,OAAOE,MAAM,EAAE;QACjB,6CAA6C;QAC7C,MAAMC,wBAAwB,MAAMC,kCAClCL,MACAC,OAAOE,MAAM;QAGf,MAAMG,qBAAq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E;IAE7D,MAAM6B,SACJ,AAAC3B,CAAAA,OAAOwD,aAAa,IAAI,CAAC,CAAA,CAAE,CAAC9B,cAAc,IAC3ChF,uBAAuB,CAACgF,cAAc;IACxC,IAAI,CAACC,QAAQ;QACX,MAAM,IAAItB,MAAM,CAAC,uBAAuB,EAAEqB,cAAc,oCAAoC,EAAEpF,+BAA+B;;;;;;;QAOzH,EAAEoF,cAAc;;;;;;;;AAQxB,CAAC;IACC;IAEA,6CAA6C;IAC7CD,eAAeC,eAAeC,QAAQ/D,QAAQuD;IAE9C,MAAMsC,kBAAkBtG,KAAKkC,IAAI,CAACnB,MAAM;IAExC,MAAM,EAAEkF,QAAQ,EAAEC,IAAI,EAAE,GAAGV,UAAUc,iBAAiB9B;IAEtD,MAAMrC,aAAa;WACb8D,WAAW;YAACA;SAAS,GAAG,EAAE;QAC9BlC,aAAaC,cAAcvD;QAC3ByF;KACD,CAACxD,IAAI,CAAC;IAEP,2EAA2E;IAC3E,MAAM,EAAEuD,UAAUM,WAAW,EAAEL,MAAMM,OAAO,EAAE,GAAGhB,UAC/CrD,YACAqC;IAEF,IAAIyB,aAAaM,eAAeL,SAASM,SAAS;QAChD,MAAM,IAAItD,MACR,CAAC,0CAA0C,EAAEqB,cAAc,gEAAgE,EAAExD,KAAK,8CAA8C,EAAE5B,gCAAgC;IAEtN;IAEA,IAAIgD,eAAemE,iBAAiB;QAClCtG,KAAKyG,KAAK,CAAC1F,MAAMoB;QACjB,OAAO;IACT;IAEA,OAAO;AACT;AAEA,eAAepC,qBAAqB"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type Tree } from '@nx/devkit';
|
|
6
|
-
import type { LicenseSourceConfig } from '../config-types';
|
|
6
|
+
import type { LicenseSourceConfig } from '../config-types.js';
|
|
7
7
|
/**
|
|
8
8
|
* Different project files with licensing information to be synchronised
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/license/sync/project-file-sync.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { updateToml } from '../../utils/toml';\nimport type { LicenseSourceConfig } from '../config-types';\n\n/**\n * Different project files with licensing information to be synchronised\n */\nexport const PROJECT_FILES_TO_SYNC = [\n 'LICENSE',\n 'package.json',\n 'pyproject.toml',\n] as const;\n\nexport type ProjectFileToSync = (typeof PROJECT_FILES_TO_SYNC)[number];\n\n/**\n * Methods to sync each type of project file\n */\nconst SYNC_STRATEGIES: Record<\n ProjectFileToSync,\n (tree: Tree, projectRoot: string, config: LicenseSourceConfig) => void\n> = {\n LICENSE: (tree, projectRoot, config) => {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'licenses', config.spdx),\n projectRoot,\n {\n copyrightHolder: config.copyrightHolder,\n year: config.copyrightYear,\n },\n {},\n );\n },\n 'package.json': (tree, projectRoot, config) => {\n const packageJsonPath = joinPathFragments(projectRoot, 'package.json');\n if (tree.exists(packageJsonPath)) {\n updateJson(tree, packageJsonPath, (prev) => ({\n ...prev,\n license: config.spdx,\n }));\n }\n },\n 'pyproject.toml': (tree, projectRoot, config) => {\n const pyProjectPath = joinPathFragments(projectRoot, 'pyproject.toml');\n if (tree.exists(pyProjectPath)) {\n updateToml(tree, pyProjectPath, (prev) => ({\n ...prev,\n license: config.spdx,\n ...(tree.exists(joinPathFragments(projectRoot, 'LICENSE'))\n ? {\n 'license-files': ['LICENSE'],\n }\n : {}),\n }));\n }\n },\n};\n\n/**\n * Synchronise a particular project file\n */\nexport const syncProjectFile = (\n tree: Tree,\n projectRoot: string,\n projectFile: (typeof PROJECT_FILES_TO_SYNC)[number],\n config: LicenseSourceConfig,\n) => {\n return SYNC_STRATEGIES[projectFile](tree, projectRoot, config);\n};\n"],"names":["generateFiles","joinPathFragments","updateJson","updateToml","PROJECT_FILES_TO_SYNC","SYNC_STRATEGIES","LICENSE","tree","projectRoot","config","dirname","spdx","copyrightHolder","year","copyrightYear","packageJsonPath","exists","prev","license","pyProjectPath","syncProjectFile","projectFile"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EAEjBC,UAAU,QACL,aAAa;AACpB,SAASC,UAAU,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/license/sync/project-file-sync.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { updateToml } from '../../utils/toml.js';\nimport type { LicenseSourceConfig } from '../config-types.js';\n\n/**\n * Different project files with licensing information to be synchronised\n */\nexport const PROJECT_FILES_TO_SYNC = [\n 'LICENSE',\n 'package.json',\n 'pyproject.toml',\n] as const;\n\nexport type ProjectFileToSync = (typeof PROJECT_FILES_TO_SYNC)[number];\n\n/**\n * Methods to sync each type of project file\n */\nconst SYNC_STRATEGIES: Record<\n ProjectFileToSync,\n (tree: Tree, projectRoot: string, config: LicenseSourceConfig) => void\n> = {\n LICENSE: (tree, projectRoot, config) => {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'licenses', config.spdx),\n projectRoot,\n {\n copyrightHolder: config.copyrightHolder,\n year: config.copyrightYear,\n },\n {},\n );\n },\n 'package.json': (tree, projectRoot, config) => {\n const packageJsonPath = joinPathFragments(projectRoot, 'package.json');\n if (tree.exists(packageJsonPath)) {\n updateJson(tree, packageJsonPath, (prev) => ({\n ...prev,\n license: config.spdx,\n }));\n }\n },\n 'pyproject.toml': (tree, projectRoot, config) => {\n const pyProjectPath = joinPathFragments(projectRoot, 'pyproject.toml');\n if (tree.exists(pyProjectPath)) {\n updateToml(tree, pyProjectPath, (prev) => ({\n ...prev,\n license: config.spdx,\n ...(tree.exists(joinPathFragments(projectRoot, 'LICENSE'))\n ? {\n 'license-files': ['LICENSE'],\n }\n : {}),\n }));\n }\n },\n};\n\n/**\n * Synchronise a particular project file\n */\nexport const syncProjectFile = (\n tree: Tree,\n projectRoot: string,\n projectFile: (typeof PROJECT_FILES_TO_SYNC)[number],\n config: LicenseSourceConfig,\n) => {\n return SYNC_STRATEGIES[projectFile](tree, projectRoot, config);\n};\n"],"names":["generateFiles","joinPathFragments","updateJson","updateToml","PROJECT_FILES_TO_SYNC","SYNC_STRATEGIES","LICENSE","tree","projectRoot","config","dirname","spdx","copyrightHolder","year","copyrightYear","packageJsonPath","exists","prev","license","pyProjectPath","syncProjectFile","projectFile"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EAEjBC,UAAU,QACL,aAAa;AACpB,SAASC,UAAU,QAAQ,sBAAsB;AAGjD;;CAEC,GACD,OAAO,MAAMC,wBAAwB;IACnC;IACA;IACA;CACD,CAAU;AAIX;;CAEC,GACD,MAAMC,kBAGF;IACFC,SAAS,CAACC,MAAMC,aAAaC;QAC3BT,cACEO,MACAN,kBAAkB,YAAYS,OAAO,EAAE,SAAS,YAAYD,OAAOE,IAAI,GACvEH,aACA;YACEI,iBAAiBH,OAAOG,eAAe;YACvCC,MAAMJ,OAAOK,aAAa;QAC5B,GACA,CAAC;IAEL;IACA,gBAAgB,CAACP,MAAMC,aAAaC;QAClC,MAAMM,kBAAkBd,kBAAkBO,aAAa;QACvD,IAAID,KAAKS,MAAM,CAACD,kBAAkB;YAChCb,WAAWK,MAAMQ,iBAAiB,CAACE,OAAU,CAAA;oBAC3C,GAAGA,IAAI;oBACPC,SAAST,OAAOE,IAAI;gBACtB,CAAA;QACF;IACF;IACA,kBAAkB,CAACJ,MAAMC,aAAaC;QACpC,MAAMU,gBAAgBlB,kBAAkBO,aAAa;QACrD,IAAID,KAAKS,MAAM,CAACG,gBAAgB;YAC9BhB,WAAWI,MAAMY,eAAe,CAACF,OAAU,CAAA;oBACzC,GAAGA,IAAI;oBACPC,SAAST,OAAOE,IAAI;oBACpB,GAAIJ,KAAKS,MAAM,CAACf,kBAAkBO,aAAa,cAC3C;wBACE,iBAAiB;4BAAC;yBAAU;oBAC9B,IACA,CAAC,CAAC;gBACR,CAAA;QACF;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMY,kBAAkB,CAC7Bb,MACAC,aACAa,aACAZ;IAEA,OAAOJ,eAAe,CAACgB,YAAY,CAACd,MAAMC,aAAaC;AACzD,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/dev-server.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { startMcpServer } from '.';\n\n/**\n * Entry point for the `mcp-inspect` target, which runs the server from source\n * with live reload. The published server is `@aws/nx-plugin-mcp`, whose bundled\n * entry point resolves `generators.json` relative to itself and so only works\n * once built.\n */\nvoid (async () => {\n try {\n await startMcpServer();\n } catch (e) {\n console.error(e);\n }\n})();\n"],"names":["startMcpServer","e","console","error"],"mappings":"AAAA;;;CAGC,GACD,SAASA,cAAc,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/dev-server.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { startMcpServer } from './index.js';\n\n/**\n * Entry point for the `mcp-inspect` target, which runs the server from source\n * with live reload. The published server is `@aws/nx-plugin-mcp`, whose bundled\n * entry point resolves `generators.json` relative to itself and so only works\n * once built.\n */\nvoid (async () => {\n try {\n await startMcpServer();\n } catch (e) {\n console.error(e);\n }\n})();\n"],"names":["startMcpServer","e","console","error"],"mappings":"AAAA;;;CAGC,GACD,SAASA,cAAc,QAAQ,aAAa;AAE5C;;;;;CAKC,GACD,KAAK,AAAC,CAAA;IACJ,IAAI;QACF,MAAMA;IACR,EAAE,OAAOC,GAAG;QACVC,QAAQC,KAAK,CAACF;IAChB;AACF,CAAA"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
import type { NxGeneratorInfo } from '../utils/generators';
|
|
6
|
-
export { buildNxCommand } from './guide-render';
|
|
5
|
+
import type { NxGeneratorInfo } from '../utils/generators.js';
|
|
6
|
+
export { buildNxCommand } from './guide-render.js';
|
|
7
7
|
/**
|
|
8
8
|
* Render summary information about a generator
|
|
9
9
|
*/
|
|
10
10
|
export declare const renderGeneratorInfo: (packageManager: string, info: NxGeneratorInfo) => string;
|
|
11
|
-
export type FilterableOption = import('./schema-registry').FilterableOption;
|
|
11
|
+
export type FilterableOption = import('./schema-registry.js').FilterableOption;
|
|
12
12
|
/**
|
|
13
13
|
* Enum properties from the generator's JSON schema — the options a user
|
|
14
14
|
* could pass on the CLI. Agents use this list to pick `options` values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/generator-info.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport type { NxGeneratorInfo } from '../utils/generators';\nimport { kebabCase } from '../utils/names';\nimport { parseMdx, postProcessGuideWithRemark } from './guide-pipeline';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render';\nimport { collectFilterableKeysFromJsx, extractFrontmatter } from './mdx-ast';\nimport { evaluatePredicate } from './option-filter';\nimport {\n filterableOptionsFromSchema,\n type GeneratorSchema,\n} from './schema-registry';\n\n// Re-export so existing callers of `generator-info` continue working.\nexport { buildNxCommand } from './guide-render';\n\n/**\n * Render summary information about a generator\n */\nexport const renderGeneratorInfo = (\n packageManager: string,\n info: NxGeneratorInfo,\n): string => {\n const schema = JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n\n return `${info.id}\n\nDescription: ${info.description}\n\nAvailable Parameters:\n${renderSchema(schema)}\n\nCommand:\n${renderGeneratorCommand(info.id, schema, packageManager)}\n`;\n};\n\nexport type FilterableOption = import('./schema-registry').FilterableOption;\n\n/**\n * Enum properties from the generator's JSON schema — the options a user\n * could pass on the CLI. Agents use this list to pick `options` values\n * when calling `generator-guide`.\n *\n * Multi-variant generators (e.g. `connection`) layer additional keys on\n * top via each guide page's `when:` frontmatter — merged in by\n * `collectFrontmatterFilterableOptions` / `renderFilterableOptionsAsync`.\n */\nexport const loadFilterableOptionsFromSchema = (\n info: NxGeneratorInfo,\n): FilterableOption[] => {\n try {\n const schema = JSON.parse(\n fs.readFileSync(info.resolvedSchemaPath, 'utf-8'),\n ) as GeneratorSchema;\n return filterableOptionsFromSchema(schema);\n } catch {\n return [];\n }\n};\n\n/**\n * Look at the `when:` frontmatter of every guide page belonging to a\n * generator and add any keys not already surfaced via the JSON schema.\n * This lets the `connection` generator advertise `sourceType` /\n * `targetType` / `protocol` without touching `generators.json`.\n */\nconst collectFrontmatterFilterableOptions = (\n fetched: FetchedGuide[],\n fromSchema: FilterableOption[],\n): FilterableOption[] => {\n const extras = new Map<string, Set<string>>();\n for (const guide of fetched) {\n const when = guide.frontmatter.when;\n if (!when) continue;\n for (const [key, rawValues] of Object.entries(when)) {\n const bucket = extras.get(key) ?? new Set<string>();\n for (const v of rawValues) bucket.add(v);\n extras.set(key, bucket);\n }\n }\n const out: FilterableOption[] = [];\n const seen = new Set(fromSchema.map((o) => o.key));\n for (const [key, values] of extras) {\n if (seen.has(key)) continue;\n out.push({ key, enum: [...values] });\n }\n return out;\n};\n\n/**\n * Decide whether the agent-supplied `options` describe a combination the\n * generator actually supports. Returns undefined when the combination is\n * fine (including when the agent hasn't narrowed enough to decide) and a\n * human-readable explanation otherwise.\n *\n * Supported combinations are inferred from the union of `when:` predicates\n * across a generator's guide pages. A generator with no `when:` predicates\n * on any of its pages (the common case — `ts#trpc-api`, `py#fast-api` …)\n * opts out of the check automatically.\n */\nconst describeUnsupportedCombinationFromFetched = (\n info: NxGeneratorInfo,\n fetched: FetchedGuide[],\n options: Record<string, string> | undefined,\n): string | undefined => {\n if (!options) return undefined;\n\n const predicates = fetched\n .map((g) => g.frontmatter.when)\n .filter((w): w is Record<string, string[]> => w !== undefined);\n if (predicates.length === 0) return undefined;\n\n // Consider only the option keys that actually participate in at least\n // one predicate — other options (e.g. schema enums) are orthogonal.\n const predicateKeys = new Set<string>();\n for (const p of predicates)\n for (const k of Object.keys(p)) predicateKeys.add(k);\n const suppliedPredicateKeys = [...predicateKeys].filter(\n (k) => options[k] !== undefined,\n );\n if (suppliedPredicateKeys.length === 0) return undefined;\n\n // If any predicate is still reachable given the keys the agent has\n // committed to so far, treat this as a partial (valid) selection and\n // skip the warning — the agent can keep narrowing.\n const stillReachable = predicates.some((pred) =>\n suppliedPredicateKeys.every((k) => {\n const values = pred[k];\n if (values === undefined) return true; // predicate doesn't care about this key\n return values.includes(options[k]);\n }),\n );\n if (stillReachable) return undefined;\n\n return renderUnsupportedMessage(info, options, predicates);\n};\n\nconst renderUnsupportedMessage = (\n info: NxGeneratorInfo,\n requested: Record<string, string>,\n predicates: Record<string, string[]>[],\n): string => {\n const requestedDesc = Object.entries(requested)\n .map(([k, v]) => `${k} = ${v}`)\n .join(', ');\n const supportedList = predicates\n .map((pred) => {\n const parts = Object.entries(pred).map(\n ([k, vs]) => `${k} = ${vs.join(' | ')}`,\n );\n return `- ${parts.join(', ')}`;\n })\n .join('\\n');\n return `## ${info.id}\n\n> [!WARNING] Unsupported combination: ${requestedDesc}. The \\`${info.id}\\` generator has no guide variant matching this combination — running it will likely fail.\n\nSupported combinations:\n${supportedList}\n\nPick a combination from the list above, or choose a different generator.`;\n};\n\n/**\n * Render the \"Filterable options\" block that list-generators emits for each\n * generator. Only keys the guide pages actually branch on are included —\n * enum properties the schema exposes but no guide filters on are omitted\n * so agents don't waste tokens setting options that won't affect the\n * returned content.\n *\n * Keys come from two sources:\n * - Schema enums, intersected with keys referenced by\n * `<OptionFilter when>` / `<TabItem _filter>` across the generator's\n * guide pages.\n * - Per-page `when:` frontmatter blocks (multi-variant generators like\n * `connection`).\n */\nexport const renderFilterableOptionsAsync = async (\n info: NxGeneratorInfo,\n): Promise<string> => {\n const fetched = await fetchGuideFrontmatters(info);\n\n const referenced = new Set<string>();\n for (const g of fetched) {\n for (const k of g.referencedKeys) referenced.add(k);\n }\n\n const schemaOptions = loadFilterableOptionsFromSchema(info).filter((o) =>\n referenced.has(o.key),\n );\n const frontmatterOptions = collectFrontmatterFilterableOptions(\n fetched,\n schemaOptions,\n );\n return formatFilterableOptions(info, [\n ...schemaOptions,\n ...frontmatterOptions,\n ]);\n};\n\nconst formatFilterableOptions = (\n _info: NxGeneratorInfo,\n filterable: FilterableOption[],\n): string => {\n if (filterable.length === 0) return '';\n const entries = filterable\n .map((opt) => {\n const def = opt.default ? ` (default: ${opt.default})` : '';\n return `- ${opt.key}: ${opt.enum.join(' | ')}${def}`;\n })\n .join('\\n');\n return `\\`generator-guide\\` options:\\n${entries}`;\n};\n\n/**\n * A guide page after its raw MDX has been fetched and the YAML frontmatter\n * parsed. The body excludes the frontmatter delimiter; the parsed\n * `frontmatter.when` predicate drives guide-level filtering.\n */\ninterface FetchedGuide {\n page: string;\n raw: string;\n body: string;\n frontmatter: {\n when?: Record<string, string[]>;\n title?: string;\n };\n /** Option keys referenced by `<OptionFilter when>` / `<TabItem _filter>` in the body. */\n referencedKeys: Set<string>;\n}\n\n/**\n * Result of `fetchGuidePagesForGenerator`. When the agent's options pick\n * a combination no variant page matches, `kind` is `'unsupported'` and\n * `content` holds an explanatory warning the tool should surface on its\n * own (without wrapping it in the usual `## <id>` summary). Otherwise\n * `content` is the rendered guide text.\n */\nexport type GuideFetchResult =\n | { kind: 'ok'; content: string }\n | { kind: 'unsupported'; content: string };\n\n/**\n * Retrieve the markdown guide pages for a generator.\n *\n * Every page listed in `guidePages` (or the kebab-cased generator id when\n * that field is absent) is fetched in parallel — local files first, GitHub\n * fallback — and its YAML frontmatter is parsed to pick up any `when:`\n * predicate. Pages without a `when:` are always included; pages with a\n * `when:` are included when either:\n * - `options` is absent (agent hasn't narrowed yet — keep every variant),\n * or\n * - the predicate matches `options` using the same semantics as\n * `<OptionFilter when={{…}}>` (AND across keys, OR within a key).\n *\n * If the agent has supplied enough options to identify a combination and\n * no variant page matches, the result is `{ kind: 'unsupported' }` and the\n * caller surfaces the warning directly.\n */\nexport const fetchGuidePagesForGenerator = async (\n info: NxGeneratorInfo,\n generators: NxGeneratorInfo[],\n packageManager?: string,\n snippetContentProvider?: SnippetContentProvider,\n options?: Record<string, string>,\n): Promise<GuideFetchResult> => {\n const fetched = await fetchGuideFrontmatters(info);\n\n const unsupported = describeUnsupportedCombinationFromFetched(\n info,\n fetched,\n options,\n );\n if (unsupported !== undefined) {\n return { kind: 'unsupported', content: unsupported };\n }\n\n const kept = fetched.filter((g) => {\n if (!g.frontmatter.when) return true;\n if (!options) return true;\n return evaluatePredicate(g.frontmatter.when, false, options);\n });\n\n const processed = await Promise.all(\n kept.map((g) =>\n postProcessGuide(\n g.body,\n generators,\n packageManager,\n snippetContentProvider,\n options,\n ),\n ),\n );\n return { kind: 'ok', content: processed.join('\\n\\n') };\n};\n\n/**\n * Fetch every guide page referenced by a generator, in parallel, and\n * return { page, raw, body, frontmatter } for each one. Used by both\n * `fetchGuidePagesForGenerator` (to filter + render) and\n * `renderFilterableOptionsAsync` (to build the filterable-options list\n * from the union of frontmatter `when:` keys).\n */\nexport const fetchGuideFrontmatters = async (\n info: NxGeneratorInfo,\n): Promise<FetchedGuide[]> => {\n const pages: string[] = [...(info.guidePages ?? [kebabCase(info.id)])];\n const results = await Promise.allSettled(\n pages.map(async (page) => ({ page, raw: await fetchGuideRaw(page) })),\n );\n const fulfilled: { page: string; raw: string }[] = [];\n for (const r of results) {\n if (r.status === 'fulfilled' && r.value.raw) fulfilled.push(r.value);\n }\n return Promise.all(\n fulfilled.map(async ({ page, raw }) => {\n const parsed = await parseGuide(raw);\n return { page, raw, ...parsed };\n }),\n );\n};\n\n/**\n * Read a guide's raw MDX from the local filesystem (bundled or monorepo).\n */\nconst fetchGuideRaw = async (page: string): Promise<string> => {\n const local = fetchLocalGuide(page);\n if (local !== undefined) return local;\n return '';\n};\n\n/**\n * Parse a guide's MDX once and return the body, the frontmatter, and the\n * set of option keys its `<OptionFilter>` / `<TabItem _filter>` blocks\n * actually reference. The yaml node's `position.end.offset` gives us the\n * body slice without re-stringifying the tree.\n */\nconst parseGuide = async (\n raw: string,\n): Promise<Omit<FetchedGuide, 'page' | 'raw'>> => {\n const tree = await parseMdx(raw);\n const { data, bodyOffset } = extractFrontmatter(tree);\n const body = raw.slice(bodyOffset).replace(/^\\r?\\n/, '');\n const frontmatter: { when?: Record<string, string[]>; title?: string } = {};\n if (typeof data.title === 'string') frontmatter.title = data.title;\n if (data.when && typeof data.when === 'object' && !Array.isArray(data.when)) {\n const when: Record<string, string[]> = {};\n for (const [key, value] of Object.entries(\n data.when as Record<string, unknown>,\n )) {\n when[key] = Array.isArray(value) ? value.map(String) : [String(value)];\n }\n frontmatter.when = when;\n }\n return {\n body,\n frontmatter,\n referencedKeys: collectFilterableKeysFromJsx(tree),\n };\n};\n\n/**\n * Base directories to probe for guide MDX files, relative to this module.\n * Each is checked in order:\n * 1. Bundled docs in the published @aws/nx-plugin-mcp package\n * 2. Source checkout when running from the monorepo (dev/test)\n * 3. Rolldown-bundled binary in dist/ (monorepo layout)\n */\nconst GUIDE_BASE_PROBES = [\n // Bundled docs inside published @aws/nx-plugin-mcp package (bin/ → ../docs)\n '../docs',\n // nx-plugin package compiled from source (src/mcp-server/…)\n '../../../docs/src/content/docs/en',\n // rolldown-bundled `@aws/nx-plugin-mcp` binary in dist (monorepo layout)\n '../../../../docs/src/content/docs/en',\n];\n\n/**\n * Content sub-directories that hold pages a generator may reference via\n * `guidePages`. Both the per-generator reference guides (`guides/`) and the\n * getting-started pages (`get_started/`) are fetchable, so a page can live in\n * whichever section reads best for humans while still being served by the MCP\n * tools. Bare `guidePages` names may also include a sub-path (e.g.\n * `connection/react-trpc`).\n */\nconst GUIDE_SECTIONS = ['guides', 'get_started'];\n\nconst fetchLocalGuide = (guide: string): string | undefined => {\n for (const base of GUIDE_BASE_PROBES) {\n for (const section of GUIDE_SECTIONS) {\n const candidate = path.resolve(\n import.meta.dirname,\n base,\n section,\n `${guide}.mdx`,\n );\n try {\n if (fs.existsSync(candidate)) {\n return fs.readFileSync(candidate, 'utf-8');\n }\n } catch {\n // Probe failure → keep looking.\n }\n }\n }\n return undefined;\n};\n\n/**\n * Fetch markdown guide pages from the local filesystem (bundled or monorepo).\n */\nexport const fetchGuidePages = async (\n guidePages: string[],\n generators: NxGeneratorInfo[],\n packageManager?: string,\n snippetContentProvider?: SnippetContentProvider,\n options?: Record<string, string>,\n): Promise<string> => {\n const guides = guidePages\n .map((guide) => fetchLocalGuide(guide))\n .filter((content): content is string => content !== undefined);\n const processed = await Promise.all(\n guides.map((content) =>\n postProcessGuide(\n content,\n generators,\n packageManager,\n snippetContentProvider,\n options,\n ),\n ),\n );\n return processed.join('\\n\\n');\n};\n\n/**\n * A function which retrieves snippet content given a snippet name.\n */\nexport type SnippetContentProvider = (\n snippetName: string,\n) => Promise<string> | string;\n\nconst SNIPPETS_RELATIVE_PROBES = [\n // Bundled docs inside published @aws/nx-plugin-mcp package (bin/ → ../docs/snippets)\n '../docs/snippets',\n '../../../docs/src/content/docs/en/snippets',\n '../../../../docs/src/content/docs/en/snippets',\n];\n\n/**\n * Fetch a snippet's content from the local filesystem (bundled or monorepo).\n */\nexport const fetchSnippet: SnippetContentProvider = async (\n snippetName: string,\n): Promise<string> => {\n for (const rel of SNIPPETS_RELATIVE_PROBES) {\n const candidate = path.resolve(\n import.meta.dirname,\n rel,\n `${snippetName}.mdx`,\n );\n try {\n if (fs.existsSync(candidate)) {\n return fs.readFileSync(candidate, 'utf-8');\n }\n } catch {\n // Probe failure — try next path.\n }\n }\n return '';\n};\n\n/**\n * Post-process a guide page. Thin wrapper around the unified/remark-mdx\n * pipeline in `guide-pipeline.ts` — the real work (snippet inlining,\n * OptionFilter/Infrastructure/TabItem filtering, command/schema rendering)\n * happens there. Kept under the same name so other packages\n * (e.g. the docs site's `markdown-content.astro`) can continue importing\n * `postProcessGuide` with the same signature.\n */\nexport const postProcessGuide = async (\n guide: string,\n generators: NxGeneratorInfo[],\n packageManager?: string,\n snippetContentProvider?: SnippetContentProvider,\n options?: Record<string, string>,\n): Promise<string> => {\n return postProcessGuideWithRemark(guide, {\n generators,\n packageManager,\n snippetContentProvider: snippetContentProvider ?? fetchSnippet,\n options,\n });\n};\n"],"names":["fs","path","kebabCase","parseMdx","postProcessGuideWithRemark","renderGeneratorCommand","renderSchema","collectFilterableKeysFromJsx","extractFrontmatter","evaluatePredicate","filterableOptionsFromSchema","buildNxCommand","renderGeneratorInfo","packageManager","info","schema","JSON","parse","readFileSync","resolvedSchemaPath","id","description","loadFilterableOptionsFromSchema","collectFrontmatterFilterableOptions","fetched","fromSchema","extras","Map","guide","when","frontmatter","key","rawValues","Object","entries","bucket","get","Set","v","add","set","out","seen","map","o","values","has","push","enum","describeUnsupportedCombinationFromFetched","options","undefined","predicates","g","filter","w","length","predicateKeys","p","k","keys","suppliedPredicateKeys","stillReachable","some","pred","every","includes","renderUnsupportedMessage","requested","requestedDesc","join","supportedList","parts","vs","renderFilterableOptionsAsync","fetchGuideFrontmatters","referenced","referencedKeys","schemaOptions","frontmatterOptions","formatFilterableOptions","_info","filterable","opt","def","default","fetchGuidePagesForGenerator","generators","snippetContentProvider","unsupported","kind","content","kept","processed","Promise","all","postProcessGuide","body","pages","guidePages","results","allSettled","page","raw","fetchGuideRaw","fulfilled","r","status","value","parsed","parseGuide","local","fetchLocalGuide","tree","data","bodyOffset","slice","replace","title","Array","isArray","String","GUIDE_BASE_PROBES","GUIDE_SECTIONS","base","section","candidate","resolve","dirname","existsSync","fetchGuidePages","guides","SNIPPETS_RELATIVE_PROBES","fetchSnippet","snippetName","rel"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AAExB,SAASC,SAAS,QAAQ,oBAAiB;AAC3C,SAASC,QAAQ,EAAEC,0BAA0B,QAAQ,sBAAmB;AACxE,SAEEC,sBAAsB,EACtBC,YAAY,QACP,oBAAiB;AACxB,SAASC,4BAA4B,EAAEC,kBAAkB,QAAQ,eAAY;AAC7E,SAASC,iBAAiB,QAAQ,qBAAkB;AACpD,SACEC,2BAA2B,QAEtB,uBAAoB;AAE3B,sEAAsE;AACtE,SAASC,cAAc,QAAQ,oBAAiB;AAEhD;;CAEC,GACD,OAAO,MAAMC,sBAAsB,CACjCC,gBACAC;IAEA,MAAMC,SAASC,KAAKC,KAAK,CAACjB,GAAGkB,YAAY,CAACJ,KAAKK,kBAAkB,EAAE;IAEnE,OAAO,GAAGL,KAAKM,EAAE,CAAC;;aAEP,EAAEN,KAAKO,WAAW,CAAC;;;AAGhC,EAAEf,aAAaS,QAAQ;;;AAGvB,EAAEV,uBAAuBS,KAAKM,EAAE,EAAEL,QAAQF,gBAAgB;AAC1D,CAAC;AACD,EAAE;AAIF;;;;;;;;CAQC,GACD,OAAO,MAAMS,kCAAkC,CAC7CR;IAEA,IAAI;QACF,MAAMC,SAASC,KAAKC,KAAK,CACvBjB,GAAGkB,YAAY,CAACJ,KAAKK,kBAAkB,EAAE;QAE3C,OAAOT,4BAA4BK;IACrC,EAAE,OAAM;QACN,OAAO,EAAE;IACX;AACF,EAAE;AAEF;;;;;CAKC,GACD,MAAMQ,sCAAsC,CAC1CC,SACAC;IAEA,MAAMC,SAAS,IAAIC;IACnB,KAAK,MAA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BAA2B;IAC/B,qFAAqF;IACrF;IACA;IACA;CACD;AAED;;CAEC,GACD,OAAO,MAAMC,eAAuC,OAClDC;IAEA,KAAK,MAAMC,OAAOH,yBAA0B;QAC1C,MAAMN,YAAY7H,KAAK8H,OAAO,CAC5B,YAAYC,OAAO,EACnBO,KACA,GAAGD,YAAY,IAAI,CAAC;QAEtB,IAAI;YACF,IAAItI,GAAGiI,UAAU,CAACH,YAAY;gBAC5B,OAAO9H,GAAGkB,YAAY,CAAC4G,WAAW;YACpC;QACF,EAAE,OAAM;QACN,iCAAiC;QACnC;IACF;IACA,OAAO;AACT,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAM9B,mBAAmB,OAC9BpE,OACA2D,YACA1E,gBACA2E,wBACAtC;IAEA,OAAO9C,2BAA2BwB,OAAO;QACvC2D;QACA1E;QACA2E,wBAAwBA,0BAA0B6C;QAClDnF;IACF;AACF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/generator-info.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport type { NxGeneratorInfo } from '../utils/generators.js';\nimport { kebabCase } from '../utils/names.js';\nimport { parseMdx, postProcessGuideWithRemark } from './guide-pipeline.js';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render.js';\nimport { collectFilterableKeysFromJsx, extractFrontmatter } from './mdx-ast.js';\nimport { evaluatePredicate } from './option-filter.js';\nimport {\n filterableOptionsFromSchema,\n type GeneratorSchema,\n} from './schema-registry.js';\n\n// Re-export so existing callers of `generator-info` continue working.\nexport { buildNxCommand } from './guide-render.js';\n\n/**\n * Render summary information about a generator\n */\nexport const renderGeneratorInfo = (\n packageManager: string,\n info: NxGeneratorInfo,\n): string => {\n const schema = JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n\n return `${info.id}\n\nDescription: ${info.description}\n\nAvailable Parameters:\n${renderSchema(schema)}\n\nCommand:\n${renderGeneratorCommand(info.id, schema, packageManager)}\n`;\n};\n\nexport type FilterableOption = import('./schema-registry.js').FilterableOption;\n\n/**\n * Enum properties from the generator's JSON schema — the options a user\n * could pass on the CLI. Agents use this list to pick `options` values\n * when calling `generator-guide`.\n *\n * Multi-variant generators (e.g. `connection`) layer additional keys on\n * top via each guide page's `when:` frontmatter — merged in by\n * `collectFrontmatterFilterableOptions` / `renderFilterableOptionsAsync`.\n */\nexport const loadFilterableOptionsFromSchema = (\n info: NxGeneratorInfo,\n): FilterableOption[] => {\n try {\n const schema = JSON.parse(\n fs.readFileSync(info.resolvedSchemaPath, 'utf-8'),\n ) as GeneratorSchema;\n return filterableOptionsFromSchema(schema);\n } catch {\n return [];\n }\n};\n\n/**\n * Look at the `when:` frontmatter of every guide page belonging to a\n * generator and add any keys not already surfaced via the JSON schema.\n * This lets the `connection` generator advertise `sourceType` /\n * `targetType` / `protocol` without touching `generators.json`.\n */\nconst collectFrontmatterFilterableOptions = (\n fetched: FetchedGuide[],\n fromSchema: FilterableOption[],\n): FilterableOption[] => {\n const extras = new Map<string, Set<string>>();\n for (const guide of fetched) {\n const when = guide.frontmatter.when;\n if (!when) continue;\n for (const [key, rawValues] of Object.entries(when)) {\n const bucket = extras.get(key) ?? new Set<string>();\n for (const v of rawValues) bucket.add(v);\n extras.set(key, bucket);\n }\n }\n const out: FilterableOption[] = [];\n const seen = new Set(fromSchema.map((o) => o.key));\n for (const [key, values] of extras) {\n if (seen.has(key)) continue;\n out.push({ key, enum: [...values] });\n }\n return out;\n};\n\n/**\n * Decide whether the agent-supplied `options` describe a combination the\n * generator actually supports. Returns undefined when the combination is\n * fine (including when the agent hasn't narrowed enough to decide) and a\n * human-readable explanation otherwise.\n *\n * Supported combinations are inferred from the union of `when:` predicates\n * across a generator's guide pages. A generator with no `when:` predicates\n * on any of its pages (the common case — `ts#trpc-api`, `py#fast-api` …)\n * opts out of the check automatically.\n */\nconst describeUnsupportedCombinationFromFetched = (\n info: NxGeneratorInfo,\n fetched: FetchedGuide[],\n options: Record<string, string> | undefined,\n): string | undefined => {\n if (!options) return undefined;\n\n const predicates = fetched\n .map((g) => g.frontmatter.when)\n .filter((w): w is Record<string, string[]> => w !== undefined);\n if (predicates.length === 0) return undefined;\n\n // Consider only the option keys that actually participate in at least\n // one predicate — other options (e.g. schema enums) are orthogonal.\n const predicateKeys = new Set<string>();\n for (const p of predicates)\n for (const k of Object.keys(p)) predicateKeys.add(k);\n const suppliedPredicateKeys = [...predicateKeys].filter(\n (k) => options[k] !== undefined,\n );\n if (suppliedPredicateKeys.length === 0) return undefined;\n\n // If any predicate is still reachable given the keys the agent has\n // committed to so far, treat this as a partial (valid) selection and\n // skip the warning — the agent can keep narrowing.\n const stillReachable = predicates.some((pred) =>\n suppliedPredicateKeys.every((k) => {\n const values = pred[k];\n if (values === undefined) return true; // predicate doesn't care about this key\n return values.includes(options[k]);\n }),\n );\n if (stillReachable) return undefined;\n\n return renderUnsupportedMessage(info, options, predicates);\n};\n\nconst renderUnsupportedMessage = (\n info: NxGeneratorInfo,\n requested: Record<string, string>,\n predicates: Record<string, string[]>[],\n): string => {\n const requestedDesc = Object.entries(requested)\n .map(([k, v]) => `${k} = ${v}`)\n .join(', ');\n const supportedList = predicates\n .map((pred) => {\n const parts = Object.entries(pred).map(\n ([k, vs]) => `${k} = ${vs.join(' | ')}`,\n );\n return `- ${parts.join(', ')}`;\n })\n .join('\\n');\n return `## ${info.id}\n\n> [!WARNING] Unsupported combination: ${requestedDesc}. The \\`${info.id}\\` generator has no guide variant matching this combination — running it will likely fail.\n\nSupported combinations:\n${supportedList}\n\nPick a combination from the list above, or choose a different generator.`;\n};\n\n/**\n * Render the \"Filterable options\" block that list-generators emits for each\n * generator. Only keys the guide pages actually branch on are included —\n * enum properties the schema exposes but no guide filters on are omitted\n * so agents don't waste tokens setting options that won't affect the\n * returned content.\n *\n * Keys come from two sources:\n * - Schema enums, intersected with keys referenced by\n * `<OptionFilter when>` / `<TabItem _filter>` across the generator's\n * guide pages.\n * - Per-page `when:` frontmatter blocks (multi-variant generators like\n * `connection`).\n */\nexport const renderFilterableOptionsAsync = async (\n info: NxGeneratorInfo,\n): Promise<string> => {\n const fetched = await fetchGuideFrontmatters(info);\n\n const referenced = new Set<string>();\n for (const g of fetched) {\n for (const k of g.referencedKeys) referenced.add(k);\n }\n\n const schemaOptions = loadFilterableOptionsFromSchema(info).filter((o) =>\n referenced.has(o.key),\n );\n const frontmatterOptions = collectFrontmatterFilterableOptions(\n fetched,\n schemaOptions,\n );\n return formatFilterableOptions(info, [\n ...schemaOptions,\n ...frontmatterOptions,\n ]);\n};\n\nconst formatFilterableOptions = (\n _info: NxGeneratorInfo,\n filterable: FilterableOption[],\n): string => {\n if (filterable.length === 0) return '';\n const entries = filterable\n .map((opt) => {\n const def = opt.default ? ` (default: ${opt.default})` : '';\n return `- ${opt.key}: ${opt.enum.join(' | ')}${def}`;\n })\n .join('\\n');\n return `\\`generator-guide\\` options:\\n${entries}`;\n};\n\n/**\n * A guide page after its raw MDX has been fetched and the YAML frontmatter\n * parsed. The body excludes the frontmatter delimiter; the parsed\n * `frontmatter.when` predicate drives guide-level filtering.\n */\ninterface FetchedGuide {\n page: string;\n raw: string;\n body: string;\n frontmatter: {\n when?: Record<string, string[]>;\n title?: string;\n };\n /** Option keys referenced by `<OptionFilter when>` / `<TabItem _filter>` in the body. */\n referencedKeys: Set<string>;\n}\n\n/**\n * Result of `fetchGuidePagesForGenerator`. When the agent's options pick\n * a combination no variant page matches, `kind` is `'unsupported'` and\n * `content` holds an explanatory warning the tool should surface on its\n * own (without wrapping it in the usual `## <id>` summary). Otherwise\n * `content` is the rendered guide text.\n */\nexport type GuideFetchResult =\n | { kind: 'ok'; content: string }\n | { kind: 'unsupported'; content: string };\n\n/**\n * Retrieve the markdown guide pages for a generator.\n *\n * Every page listed in `guidePages` (or the kebab-cased generator id when\n * that field is absent) is fetched in parallel — local files first, GitHub\n * fallback — and its YAML frontmatter is parsed to pick up any `when:`\n * predicate. Pages without a `when:` are always included; pages with a\n * `when:` are included when either:\n * - `options` is absent (agent hasn't narrowed yet — keep every variant),\n * or\n * - the predicate matches `options` using the same semantics as\n * `<OptionFilter when={{…}}>` (AND across keys, OR within a key).\n *\n * If the agent has supplied enough options to identify a combination and\n * no variant page matches, the result is `{ kind: 'unsupported' }` and the\n * caller surfaces the warning directly.\n */\nexport const fetchGuidePagesForGenerator = async (\n info: NxGeneratorInfo,\n generators: NxGeneratorInfo[],\n packageManager?: string,\n snippetContentProvider?: SnippetContentProvider,\n options?: Record<string, string>,\n): Promise<GuideFetchResult> => {\n const fetched = await fetchGuideFrontmatters(info);\n\n const unsupported = describeUnsupportedCombinationFromFetched(\n info,\n fetched,\n options,\n );\n if (unsupported !== undefined) {\n return { kind: 'unsupported', content: unsupported };\n }\n\n const kept = fetched.filter((g) => {\n if (!g.frontmatter.when) return true;\n if (!options) return true;\n return evaluatePredicate(g.frontmatter.when, false, options);\n });\n\n const processed = await Promise.all(\n kept.map((g) =>\n postProcessGuide(\n g.body,\n generators,\n packageManager,\n snippetContentProvider,\n options,\n ),\n ),\n );\n return { kind: 'ok', content: processed.join('\\n\\n') };\n};\n\n/**\n * Fetch every guide page referenced by a generator, in parallel, and\n * return { page, raw, body, frontmatter } for each one. Used by both\n * `fetchGuidePagesForGenerator` (to filter + render) and\n * `renderFilterableOptionsAsync` (to build the filterable-options list\n * from the union of frontmatter `when:` keys).\n */\nexport const fetchGuideFrontmatters = async (\n info: NxGeneratorInfo,\n): Promise<FetchedGuide[]> => {\n const pages: string[] = [...(info.guidePages ?? [kebabCase(info.id)])];\n const results = await Promise.allSettled(\n pages.map(async (page) => ({ page, raw: await fetchGuideRaw(page) })),\n );\n const fulfilled: { page: string; raw: string }[] = [];\n for (const r of results) {\n if (r.status === 'fulfilled' && r.value.raw) fulfilled.push(r.value);\n }\n return Promise.all(\n fulfilled.map(async ({ page, raw }) => {\n const parsed = await parseGuide(raw);\n return { page, raw, ...parsed };\n }),\n );\n};\n\n/**\n * Read a guide's raw MDX from the local filesystem (bundled or monorepo).\n */\nconst fetchGuideRaw = async (page: string): Promise<string> => {\n const local = fetchLocalGuide(page);\n if (local !== undefined) return local;\n return '';\n};\n\n/**\n * Parse a guide's MDX once and return the body, the frontmatter, and the\n * set of option keys its `<OptionFilter>` / `<TabItem _filter>` blocks\n * actually reference. The yaml node's `position.end.offset` gives us the\n * body slice without re-stringifying the tree.\n */\nconst parseGuide = async (\n raw: string,\n): Promise<Omit<FetchedGuide, 'page' | 'raw'>> => {\n const tree = await parseMdx(raw);\n const { data, bodyOffset } = extractFrontmatter(tree);\n const body = raw.slice(bodyOffset).replace(/^\\r?\\n/, '');\n const frontmatter: { when?: Record<string, string[]>; title?: string } = {};\n if (typeof data.title === 'string') frontmatter.title = data.title;\n if (data.when && typeof data.when === 'object' && !Array.isArray(data.when)) {\n const when: Record<string, string[]> = {};\n for (const [key, value] of Object.entries(\n data.when as Record<string, unknown>,\n )) {\n when[key] = Array.isArray(value) ? value.map(String) : [String(value)];\n }\n frontmatter.when = when;\n }\n return {\n body,\n frontmatter,\n referencedKeys: collectFilterableKeysFromJsx(tree),\n };\n};\n\n/**\n * Base directories to probe for guide MDX files, relative to this module.\n * Each is checked in order:\n * 1. Bundled docs in the published @aws/nx-plugin-mcp package\n * 2. Source checkout when running from the monorepo (dev/test)\n * 3. Rolldown-bundled binary in dist/ (monorepo layout)\n */\nconst GUIDE_BASE_PROBES = [\n // Bundled docs inside published @aws/nx-plugin-mcp package (bin/ → ../docs)\n '../docs',\n // nx-plugin package compiled from source (src/mcp-server/…)\n '../../../docs/src/content/docs/en',\n // rolldown-bundled `@aws/nx-plugin-mcp` binary in dist (monorepo layout)\n '../../../../docs/src/content/docs/en',\n];\n\n/**\n * Content sub-directories that hold pages a generator may reference via\n * `guidePages`. Both the per-generator reference guides (`guides/`) and the\n * getting-started pages (`get_started/`) are fetchable, so a page can live in\n * whichever section reads best for humans while still being served by the MCP\n * tools. Bare `guidePages` names may also include a sub-path (e.g.\n * `connection/react-trpc`).\n */\nconst GUIDE_SECTIONS = ['guides', 'get_started'];\n\nconst fetchLocalGuide = (guide: string): string | undefined => {\n for (const base of GUIDE_BASE_PROBES) {\n for (const section of GUIDE_SECTIONS) {\n const candidate = path.resolve(\n import.meta.dirname,\n base,\n section,\n `${guide}.mdx`,\n );\n try {\n if (fs.existsSync(candidate)) {\n return fs.readFileSync(candidate, 'utf-8');\n }\n } catch {\n // Probe failure → keep looking.\n }\n }\n }\n return undefined;\n};\n\n/**\n * Fetch markdown guide pages from the local filesystem (bundled or monorepo).\n */\nexport const fetchGuidePages = async (\n guidePages: string[],\n generators: NxGeneratorInfo[],\n packageManager?: string,\n snippetContentProvider?: SnippetContentProvider,\n options?: Record<string, string>,\n): Promise<string> => {\n const guides = guidePages\n .map((guide) => fetchLocalGuide(guide))\n .filter((content): content is string => content !== undefined);\n const processed = await Promise.all(\n guides.map((content) =>\n postProcessGuide(\n content,\n generators,\n packageManager,\n snippetContentProvider,\n options,\n ),\n ),\n );\n return processed.join('\\n\\n');\n};\n\n/**\n * A function which retrieves snippet content given a snippet name.\n */\nexport type SnippetContentProvider = (\n snippetName: string,\n) => Promise<string> | string;\n\nconst SNIPPETS_RELATIVE_PROBES = [\n // Bundled docs inside published @aws/nx-plugin-mcp package (bin/ → ../docs/snippets)\n '../docs/snippets',\n '../../../docs/src/content/docs/en/snippets',\n '../../../../docs/src/content/docs/en/snippets',\n];\n\n/**\n * Fetch a snippet's content from the local filesystem (bundled or monorepo).\n */\nexport const fetchSnippet: SnippetContentProvider = async (\n snippetName: string,\n): Promise<string> => {\n for (const rel of SNIPPETS_RELATIVE_PROBES) {\n const candidate = path.resolve(\n import.meta.dirname,\n rel,\n `${snippetName}.mdx`,\n );\n try {\n if (fs.existsSync(candidate)) {\n return fs.readFileSync(candidate, 'utf-8');\n }\n } catch {\n // Probe failure — try next path.\n }\n }\n return '';\n};\n\n/**\n * Post-process a guide page. Thin wrapper around the unified/remark-mdx\n * pipeline in `guide-pipeline.ts` — the real work (snippet inlining,\n * OptionFilter/Infrastructure/TabItem filtering, command/schema rendering)\n * happens there. Kept under the same name so other packages\n * (e.g. the docs site's `markdown-content.astro`) can continue importing\n * `postProcessGuide` with the same signature.\n */\nexport const postProcessGuide = async (\n guide: string,\n generators: NxGeneratorInfo[],\n packageManager?: string,\n snippetContentProvider?: SnippetContentProvider,\n options?: Record<string, string>,\n): Promise<string> => {\n return postProcessGuideWithRemark(guide, {\n generators,\n packageManager,\n snippetContentProvider: snippetContentProvider ?? fetchSnippet,\n options,\n });\n};\n"],"names":["fs","path","kebabCase","parseMdx","postProcessGuideWithRemark","renderGeneratorCommand","renderSchema","collectFilterableKeysFromJsx","extractFrontmatter","evaluatePredicate","filterableOptionsFromSchema","buildNxCommand","renderGeneratorInfo","packageManager","info","schema","JSON","parse","readFileSync","resolvedSchemaPath","id","description","loadFilterableOptionsFromSchema","collectFrontmatterFilterableOptions","fetched","fromSchema","extras","Map","guide","when","frontmatter","key","rawValues","Object","entries","bucket","get","Set","v","add","set","out","seen","map","o","values","has","push","enum","describeUnsupportedCombinationFromFetched","options","undefined","predicates","g","filter","w","length","predicateKeys","p","k","keys","suppliedPredicateKeys","stillReachable","some","pred","every","includes","renderUnsupportedMessage","requested","requestedDesc","join","supportedList","parts","vs","renderFilterableOptionsAsync","fetchGuideFrontmatters","referenced","referencedKeys","schemaOptions","frontmatterOptions","formatFilterableOptions","_info","filterable","opt","def","default","fetchGuidePagesForGenerator","generators","snippetContentProvider","unsupported","kind","content","kept","processed","Promise","all","postProcessGuide","body","pages","guidePages","results","allSettled","page","raw","fetchGuideRaw","fulfilled","r","status","value","parsed","parseGuide","local","fetchLocalGuide","tree","data","bodyOffset","slice","replace","title","Array","isArray","String","GUIDE_BASE_PROBES","GUIDE_SECTIONS","base","section","candidate","resolve","dirname","existsSync","fetchGuidePages","guides","SNIPP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B,YAAYC,OAAO,EACnBO,KACA,GAAGD,YAAY,IAAI,CAAC;QAEtB,IAAI;YACF,IAAItI,GAAGiI,UAAU,CAACH,YAAY;gBAC5B,OAAO9H,GAAGkB,YAAY,CAAC4G,WAAW;YACpC;QACF,EAAE,OAAM;QACN,iCAAiC;QACnC;IACF;IACA,OAAO;AACT,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAM9B,mBAAmB,OAC9BpE,OACA2D,YACA1E,gBACA2E,wBACAtC;IAEA,OAAO9C,2BAA2BwB,OAAO;QACvC2D;QACA1E;QACA2E,wBAAwBA,0BAA0B6C;QAClDnF;IACF;AACF,EAAE"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* `<PackageManagerExecCommand>` render down to markdown.
|
|
16
16
|
*/
|
|
17
17
|
import type { Root } from 'mdast';
|
|
18
|
-
import type { NxGeneratorInfo } from '../utils/generators';
|
|
18
|
+
import type { NxGeneratorInfo } from '../utils/generators.js';
|
|
19
19
|
export interface PipelineOptions {
|
|
20
20
|
generators: NxGeneratorInfo[];
|
|
21
21
|
packageManager?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\n/**\n * Unified + remark-mdx pipeline for the MCP `generator-guide` tool.\n *\n * Passes (in order, each over the already-transformed tree):\n * 1. Snippet inlining — `<Snippet name>` → recursive post-process.\n * 2. Filter transforms — `<OptionFilter>`, `<Infrastructure>` slot\n * selection, `<Tabs><TabItem _filter>` pruning.\n * 3. Component transforms — `<NxCommands>` / `<RunGenerator>` /\n * `<GeneratorParameters>` / `<CreateNxWorkspaceCommand>` /\n * `<InstallCommand>` / `<PackageManagerShortCommand>` /\n * `<PackageManagerExecCommand>` render down to markdown.\n */\nimport type { Root, RootContent } from 'mdast';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\nimport {\n buildCreateNxWorkspaceCommand,\n buildInstallCommand,\n buildNxInitCommand,\n buildPackageManagerExecCommand,\n buildPackageManagerShortCommand,\n} from '../utils/commands';\nimport type { NxGeneratorInfo } from '../utils/generators';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render';\nimport {\n hasBareAttr,\n isJsxElement,\n type JsxElement,\n type JsxParent,\n readEstreeAttr,\n readExpressionAttr,\n readStringAttr,\n} from './mdx-ast';\nimport {\n describePredicate,\n evaluatePredicate,\n extractStringArrayExpression,\n type Predicate,\n parseWhenExpression,\n} from './option-filter';\n\nexport interface PipelineOptions {\n generators: NxGeneratorInfo[];\n packageManager?: string;\n snippetContentProvider?: (name: string) => Promise<string> | string;\n options?: Record<string, string>;\n}\n\n// unified v11 is ESM-only and this package is CJS; dynamic import + rolldown's\n// `codeSplitting: false` bundles everything into the published MCP binary.\ninterface RemarkDeps {\n unified: typeof import('unified').unified;\n remarkParse: typeof import('remark-parse').default;\n remarkMdx: typeof import('remark-mdx').default;\n remarkStringify: typeof import('remark-stringify').default;\n remarkFrontmatter: typeof import('remark-frontmatter').default;\n}\n\nlet depsPromise: Promise<RemarkDeps> | undefined;\nconst loadRemarkDeps = (): Promise<RemarkDeps> => {\n if (!depsPromise) {\n depsPromise = (async () => ({\n unified: (await import('unified')).unified,\n remarkParse: (await import('remark-parse')).default,\n remarkMdx: (await import('remark-mdx')).default,\n remarkStringify: (await import('remark-stringify')).default,\n remarkFrontmatter: (await import('remark-frontmatter')).default,\n }))();\n }\n return depsPromise;\n};\n\nconst parseMdxWithDeps = (source: string, deps: RemarkDeps): Root =>\n deps\n .unified()\n .use(deps.remarkParse)\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .parse(source) as Root;\n\n/** Parse MDX (with frontmatter) into mdast. Exposed so callers like\n * `fetchGuideFrontmatters` don't need to re-load remark themselves. */\nexport const parseMdx = async (source: string): Promise<Root> => {\n const deps = await loadRemarkDeps();\n return parseMdxWithDeps(source, deps);\n};\n\nconst stringifyMdx = (tree: Root, deps: RemarkDeps): string =>\n String(\n deps\n .unified()\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .use(deps.remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n })\n .stringify(tree),\n );\n\n/**\n * Remove nodes that are meaningless once the MDX is rendered to plain markdown\n * for an agent: the YAML frontmatter block and the `import`/`export` (ESM)\n * statements at the top of every docs page. They add noise and tokens without\n * conveying guidance.\n */\nconst stripFrontmatterAndEsm = (tree: Root): void => {\n tree.children = tree.children.filter(\n (node) => node.type !== 'yaml' && node.type !== 'mdxjsEsm',\n );\n};\n\nexport const postProcessGuideWithRemark = async (\n guide: string,\n opts: PipelineOptions,\n): Promise<string> => {\n const deps = await loadRemarkDeps();\n const tree = parseMdxWithDeps(guide, deps);\n\n await inlineSnippets(tree, opts, deps);\n applyFilterTransforms(tree, opts.options);\n applyComponentTransforms(tree, opts, deps);\n stripFrontmatterAndEsm(tree);\n\n return stringifyMdx(tree, deps);\n};\n\nconst inlineSnippets = async (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): Promise<void> => {\n const provider = opts.snippetContentProvider;\n if (!provider) return;\n\n interface PendingSnippet {\n parent: JsxParent;\n index: number;\n name: string;\n node: JsxElement;\n }\n\n const pending: PendingSnippet[] = [];\n const walk = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n if (child.name === 'Snippet') {\n const name = readStringAttr(child, 'name');\n if (name) pending.push({ parent, index: i, name, node: child });\n continue;\n }\n walk(child);\n }\n };\n walk(tree);\n if (pending.length === 0) return;\n\n const fetched = await Promise.all(\n pending.map(async (p) => {\n let raw = '';\n try {\n raw = await provider(p.name);\n } catch {\n raw = '';\n }\n if (!raw) return { ...p, replacement: undefined };\n const processed = await postProcessGuideWithRemark(raw.trim(), opts);\n return { ...p, replacement: processed };\n }),\n );\n\n // Splice in descending index order per parent so earlier indices stay valid.\n const byParent = new Map<JsxParent, (typeof fetched)[number][]>();\n for (const f of fetched) {\n const bucket = byParent.get(f.parent) ?? [];\n bucket.push(f);\n byParent.set(f.parent, bucket);\n }\n for (const [parent, items] of byParent) {\n items.sort((a, b) => b.index - a.index);\n for (const { index, name, replacement, node } of items) {\n if (replacement === undefined) continue;\n const snippetTree = parseMdxWithDeps(replacement, deps);\n const wrapper: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'Snippet',\n attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],\n children: snippetTree.children as MdxJsxFlowElement['children'],\n };\n if ('position' in node && node.position) {\n (wrapper as { position?: unknown }).position = node.position;\n }\n (parent.children as RootContent[]).splice(\n index,\n 1,\n wrapper as RootContent,\n );\n }\n }\n};\n\nconst applyFilterTransforms = (\n tree: Root,\n options: Record<string, string> | undefined,\n): void => {\n const iac = options?.iac;\n\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n\n if (child.name === 'OptionFilter') {\n const when = parseWhenAttr(child);\n if (!when) continue; // malformed — leave alone\n // Recurse first so nested filters collapse before we replace this wrapper.\n transform(child);\n const not = hasBareAttr(child, 'not');\n if (options) {\n const replacement = evaluatePredicate(when, not, options)\n ? (child.children as RootContent[])\n : [];\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n } else {\n children.splice(i, 1, buildNoteQuote(child, when, not));\n }\n continue;\n }\n\n if (child.name === 'Infrastructure') {\n if (iac === 'cdk' || iac === 'terraform') {\n const body = selectInfrastructureSlot(child, iac);\n const pseudo: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'tmp',\n attributes: [],\n children: body as MdxJsxFlowElement['children'],\n };\n transform(pseudo);\n children.splice(i, 1, ...(pseudo.children as RootContent[]));\n i--;\n continue;\n }\n // No iac → keep both slots so readers / agents see both variants.\n transform(child);\n continue;\n }\n\n if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {\n transform(child);\n const dropped = applyTabsFilter(child, options);\n if (dropped === 'empty') {\n children.splice(i, 1);\n i--;\n continue;\n }\n if (dropped === 'inline') {\n const survivor = (child.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) && c.name === 'TabItem',\n )!;\n const body = survivor.children as RootContent[];\n children.splice(i, 1, ...body);\n i += body.length - 1;\n continue;\n }\n continue;\n }\n\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst selectInfrastructureSlot = (\n node: JsxElement,\n iac: 'cdk' | 'terraform',\n): RootContent[] => {\n const slotName = iac.toLowerCase();\n const frag = (node.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) &&\n c.name === 'Fragment' &&\n readStringAttr(c, 'slot') === slotName,\n );\n return (frag?.children as RootContent[]) ?? [];\n};\n\n/**\n * Prune TabItems whose `_filter` doesn't match `options`. Returns:\n * - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.\n * - `'inline'` if exactly one filtered <TabItem> survived — caller\n * inlines the body so agents see just the picked variant.\n * - `'keep'` otherwise.\n */\nconst applyTabsFilter = (\n tabs: MdxJsxFlowElement,\n options: Record<string, string> | undefined,\n): 'empty' | 'inline' | 'keep' => {\n const children = tabs.children as RootContent[];\n const surviving: RootContent[] = [];\n let anyFiltered = false;\n for (const child of children) {\n if (!isJsxElement(child) || child.name !== 'TabItem') {\n surviving.push(child);\n continue;\n }\n const filterEstree = readEstreeAttr(child, '_filter');\n if (!filterEstree) {\n surviving.push(child);\n continue;\n }\n anyFiltered = true;\n let predicate: Predicate;\n try {\n predicate = parseWhenExpression(filterEstree as never);\n } catch {\n stripFilterAttr(child);\n surviving.push(child);\n continue;\n }\n if (!options || evaluatePredicate(predicate, false, options)) {\n stripFilterAttr(child);\n surviving.push(child);\n }\n }\n if (anyFiltered) {\n tabs.children = surviving as MdxJsxFlowElement['children'];\n }\n const tabItems = surviving.filter(\n (c) => isJsxElement(c) && c.name === 'TabItem',\n );\n if (tabItems.length === 0 && surviving.length === 0) return 'empty';\n if (anyFiltered && tabItems.length === 1) return 'inline';\n return 'keep';\n};\n\nconst stripFilterAttr = (el: JsxElement): void => {\n el.attributes = el.attributes.filter(\n (a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'),\n );\n};\n\n/**\n * `> [!NOTE] Only when …` blockquote. The alert header goes through as an\n * `html` node so remark-stringify doesn't escape the `[`/`]` brackets —\n * downstream agents match on the literal GitHub alert syntax.\n */\nconst buildNoteQuote = (\n source: JsxElement,\n predicate: Predicate,\n not: boolean,\n): RootContent => {\n const marker = describePredicate(predicate, not);\n const description = readStringAttr(source, 'description');\n const headerLines = description\n ? [`[!NOTE] ${marker}`, description]\n : [`[!NOTE] ${marker}`];\n const headerNodes: RootContent[] = headerLines.map(\n (line) => ({ type: 'html', value: line }) as RootContent,\n );\n return {\n type: 'blockquote',\n children: [...headerNodes, ...(source.children as RootContent[])] as never,\n } as RootContent;\n};\n\nconst parseWhenAttr = (node: JsxElement): Predicate | undefined => {\n const estree = readEstreeAttr(node, 'when');\n if (!estree) return undefined;\n try {\n return parseWhenExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n\nconst applyComponentTransforms = (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): void => {\n const pm = opts.packageManager ?? 'pnpm';\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n const replacement = renderComponent(child, opts, pm, deps);\n if (replacement !== undefined) {\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n continue;\n }\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst renderComponent = (\n node: JsxElement,\n opts: PipelineOptions,\n pm: string,\n deps: RemarkDeps,\n): RootContent[] | undefined => {\n switch (node.name) {\n case 'NxCommands': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildNxCommand(c, opts.packageManager))\n .join('\\n'),\n ),\n ];\n }\n case 'RunGenerator': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(\n renderGeneratorCommand(generatorId, schema, opts.packageManager),\n deps,\n );\n }\n case 'GeneratorParameters': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(renderSchema(schema), deps);\n }\n case 'CreateNxWorkspaceCommand': {\n const workspace = readStringAttr(node, 'workspace');\n if (!workspace) return undefined;\n const iac = readStringAttr(node, 'iac') as\n | 'cdk'\n | 'terraform'\n | undefined;\n return [codeBlock(buildCreateNxWorkspaceCommand(pm, workspace, iac))];\n }\n case 'NxInitCommand': {\n return [codeBlock(buildNxInitCommand(pm))];\n }\n case 'InstallCommand': {\n // Without `pkg`, installs the workspace's existing dependencies\n const pkg =\n readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');\n return [\n codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev'))),\n ];\n }\n case 'PackageManagerShortCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildPackageManagerShortCommand(pm, c))\n .join('\\n'),\n ),\n ];\n }\n case 'PackageManagerExecCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands.map((c) => buildPackageManagerExecCommand(pm, c)).join('\\n'),\n ),\n ];\n }\n default:\n return undefined;\n }\n};\n\nconst codeBlock = (body: string): RootContent => ({\n type: 'code',\n lang: 'bash',\n value: body,\n});\n\nconst parseMarkdownFragment = (\n markdown: string,\n deps: RemarkDeps,\n): RootContent[] => {\n const fragTree = deps.unified().use(deps.remarkParse).parse(markdown) as Root;\n return fragTree.children as RootContent[];\n};\n\nconst findSchema = (\n generators: NxGeneratorInfo[],\n generatorId: string,\n):\n | { properties?: Record<string, unknown>; required?: string[] }\n | undefined => {\n const info = generators.find((g) => g.id === generatorId);\n if (!info) return undefined;\n try {\n return JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n } catch {\n return undefined;\n }\n};\n\n/** Parse the `commands={[…]}` attribute from the estree that remark-mdx\n * attaches to the JSX attribute value. */\nconst readCommandsAttr = (node: JsxElement): string[] | undefined => {\n const estree = readEstreeAttr(node, 'commands');\n if (!estree) return undefined;\n try {\n return extractStringArrayExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n"],"names":["fs","buildCreateNxWorkspaceCommand","buildInstallCommand","buildNxInitCommand","buildPackageManagerExecCommand","buildPackageManagerShortCommand","buildNxCommand","renderGeneratorCommand","renderSchema","hasBareAttr","isJsxElement","readEstreeAttr","readExpressionAttr","readStringAttr","describePredicate","evaluatePredicate","extractStringArrayExpression","parseWhenExpression","depsPromise","loadRemarkDeps","unified","remarkParse","default","remarkMdx","remarkStringify","remarkFrontmatter","parseMdxWithDeps","source","deps","use","parse","parseMdx","stringifyMdx","tree","String","bullet","fences","listItemIndent","stringify","stripFrontmatterAndEsm","children","filter","node","type","postProcessGuideWithRemark","guide","opts","inlineSnippets","applyFilterTransforms","options","applyComponentTransforms","provider","snippetContentProvider","pending","walk","parent","i","length","child","name","push","index","fetched","Promise","all","map","p","raw","replacement","undefined","processed","trim","byParent","Map","f","bucket","get","set","items","sort","a","b","snippetTree","wrapper","attributes","value","position","splice","iac","transform","when","parseWhenAttr","not","buildNoteQuote","body","selectInfrastructureSlot","pseudo","dropped","applyTabsFilter","survivor","find","c","slotName","toLowerCase","frag","tabs","surviving","anyFiltered","filterEstree","predicate","stripFilterAttr","tabItems","el","marker","description","headerLines","headerNodes","line","estree","pm","packageManager","renderComponent","commands","readCommandsAttr","codeBlock","join","generatorId","schema","findSchema","generators","parseMarkdownFragment","workspace","pkg","lang","markdown","fragTree","info","g","id","JSON","readFileSync","resolvedSchemaPath"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AAepB,SACEC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,+BAA+B,QAC1B,uBAAoB;AAE3B,SACEC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,QACP,oBAAiB;AACxB,SACEC,WAAW,EACXC,YAAY,EAGZC,cAAc,EACdC,kBAAkB,EAClBC,cAAc,QACT,eAAY;AACnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,4BAA4B,EAE5BC,mBAAmB,QACd,qBAAkB;AAmBzB,IAAIC;AACJ,MAAMC,iBAAiB;IACrB,IAAI,CAACD,aAAa;QAChBA,cAAc,AAAC,CAAA,UAAa,CAAA;gBAC1BE,SAAS,AAAC,CAAA,MAAM,MAAM,CAAC,UAAS,EAAGA,OAAO;gBAC1CC,aAAa,AAAC,CAAA,MAAM,MAAM,CAAC,eAAc,EAAGC,OAAO;gBACnDC,WAAW,AAAC,CAAA,MAAM,MAAM,CAAC,aAAY,EAAGD,OAAO;gBAC/CE,iBAAiB,AAAC,CAAA,MAAM,MAAM,CAAC,mBAAkB,EAAGF,OAAO;gBAC3DG,mBAAmB,AAAC,CAAA,MAAM,MAAM,CAAC,qBAAoB,EAAGH,OAAO;YACjE,CAAA,CAAC;IACH;IACA,OAAOJ;AACT;AAEA,MAAMQ,mBAAmB,CAACC,QAAgBC,OACxCA,KACGR,OAAO,GACPS,GAAG,CAACD,KAAKP,WAAW,EACpBQ,GAAG,CAACD,KAAKH,iBAAiB,EAC1BI,GAAG,CAACD,KAAKL,SAAS,EAClBO,KAAK,CAACH;AAEX;sEACsE,GACtE,OAAO,MAAMI,WAAW,OAAOJ;IAC7B,MAAMC,OAAO,MAAMT;IACnB,OAAOO,iBAAiBC,QAAQC;A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AS/F,QAAQ;AAC1B;AAEA,MAAMwF,aAAa,CACjBC,YACAH;IAIA,MAAMU,OAAOP,WAAW7B,IAAI,CAAC,CAACqC,IAAMA,EAAEC,EAAE,KAAKZ;IAC7C,IAAI,CAACU,MAAM,OAAOnE;IAClB,IAAI;QACF,OAAOsE,KAAK7G,KAAK,CAAC9B,GAAG4I,YAAY,CAACJ,KAAKK,kBAAkB,EAAE;IAC7D,EAAE,OAAM;QACN,OAAOxE;IACT;AACF;AAEA;yCACyC,GACzC,MAAMsD,mBAAmB,CAACjF;IACxB,MAAM4E,SAAS3G,eAAe+B,MAAM;IACpC,IAAI,CAAC4E,QAAQ,OAAOjD;IACpB,IAAI;QACF,OAAOrD,6BAA6BsG;IACtC,EAAE,OAAM;QACN,OAAOjD;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\n/**\n * Unified + remark-mdx pipeline for the MCP `generator-guide` tool.\n *\n * Passes (in order, each over the already-transformed tree):\n * 1. Snippet inlining — `<Snippet name>` → recursive post-process.\n * 2. Filter transforms — `<OptionFilter>`, `<Infrastructure>` slot\n * selection, `<Tabs><TabItem _filter>` pruning.\n * 3. Component transforms — `<NxCommands>` / `<RunGenerator>` /\n * `<GeneratorParameters>` / `<CreateNxWorkspaceCommand>` /\n * `<InstallCommand>` / `<PackageManagerShortCommand>` /\n * `<PackageManagerExecCommand>` render down to markdown.\n */\nimport type { Root, RootContent } from 'mdast';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\nimport {\n buildCreateNxWorkspaceCommand,\n buildInstallCommand,\n buildNxInitCommand,\n buildPackageManagerExecCommand,\n buildPackageManagerShortCommand,\n} from '../utils/commands.js';\nimport type { NxGeneratorInfo } from '../utils/generators.js';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render.js';\nimport {\n hasBareAttr,\n isJsxElement,\n type JsxElement,\n type JsxParent,\n readEstreeAttr,\n readExpressionAttr,\n readStringAttr,\n} from './mdx-ast.js';\nimport {\n describePredicate,\n evaluatePredicate,\n extractStringArrayExpression,\n type Predicate,\n parseWhenExpression,\n} from './option-filter.js';\n\nexport interface PipelineOptions {\n generators: NxGeneratorInfo[];\n packageManager?: string;\n snippetContentProvider?: (name: string) => Promise<string> | string;\n options?: Record<string, string>;\n}\n\n// unified v11 is ESM-only and this package is CJS; dynamic import + rolldown's\n// `codeSplitting: false` bundles everything into the published MCP binary.\ninterface RemarkDeps {\n unified: typeof import('unified').unified;\n remarkParse: typeof import('remark-parse').default;\n remarkMdx: typeof import('remark-mdx').default;\n remarkStringify: typeof import('remark-stringify').default;\n remarkFrontmatter: typeof import('remark-frontmatter').default;\n}\n\nlet depsPromise: Promise<RemarkDeps> | undefined;\nconst loadRemarkDeps = (): Promise<RemarkDeps> => {\n if (!depsPromise) {\n depsPromise = (async () => ({\n unified: (await import('unified')).unified,\n remarkParse: (await import('remark-parse')).default,\n remarkMdx: (await import('remark-mdx')).default,\n remarkStringify: (await import('remark-stringify')).default,\n remarkFrontmatter: (await import('remark-frontmatter')).default,\n }))();\n }\n return depsPromise;\n};\n\nconst parseMdxWithDeps = (source: string, deps: RemarkDeps): Root =>\n deps\n .unified()\n .use(deps.remarkParse)\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .parse(source) as Root;\n\n/** Parse MDX (with frontmatter) into mdast. Exposed so callers like\n * `fetchGuideFrontmatters` don't need to re-load remark themselves. */\nexport const parseMdx = async (source: string): Promise<Root> => {\n const deps = await loadRemarkDeps();\n return parseMdxWithDeps(source, deps);\n};\n\nconst stringifyMdx = (tree: Root, deps: RemarkDeps): string =>\n String(\n deps\n .unified()\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .use(deps.remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n })\n .stringify(tree),\n );\n\n/**\n * Remove nodes that are meaningless once the MDX is rendered to plain markdown\n * for an agent: the YAML frontmatter block and the `import`/`export` (ESM)\n * statements at the top of every docs page. They add noise and tokens without\n * conveying guidance.\n */\nconst stripFrontmatterAndEsm = (tree: Root): void => {\n tree.children = tree.children.filter(\n (node) => node.type !== 'yaml' && node.type !== 'mdxjsEsm',\n );\n};\n\nexport const postProcessGuideWithRemark = async (\n guide: string,\n opts: PipelineOptions,\n): Promise<string> => {\n const deps = await loadRemarkDeps();\n const tree = parseMdxWithDeps(guide, deps);\n\n await inlineSnippets(tree, opts, deps);\n applyFilterTransforms(tree, opts.options);\n applyComponentTransforms(tree, opts, deps);\n stripFrontmatterAndEsm(tree);\n\n return stringifyMdx(tree, deps);\n};\n\nconst inlineSnippets = async (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): Promise<void> => {\n const provider = opts.snippetContentProvider;\n if (!provider) return;\n\n interface PendingSnippet {\n parent: JsxParent;\n index: number;\n name: string;\n node: JsxElement;\n }\n\n const pending: PendingSnippet[] = [];\n const walk = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n if (child.name === 'Snippet') {\n const name = readStringAttr(child, 'name');\n if (name) pending.push({ parent, index: i, name, node: child });\n continue;\n }\n walk(child);\n }\n };\n walk(tree);\n if (pending.length === 0) return;\n\n const fetched = await Promise.all(\n pending.map(async (p) => {\n let raw = '';\n try {\n raw = await provider(p.name);\n } catch {\n raw = '';\n }\n if (!raw) return { ...p, replacement: undefined };\n const processed = await postProcessGuideWithRemark(raw.trim(), opts);\n return { ...p, replacement: processed };\n }),\n );\n\n // Splice in descending index order per parent so earlier indices stay valid.\n const byParent = new Map<JsxParent, (typeof fetched)[number][]>();\n for (const f of fetched) {\n const bucket = byParent.get(f.parent) ?? [];\n bucket.push(f);\n byParent.set(f.parent, bucket);\n }\n for (const [parent, items] of byParent) {\n items.sort((a, b) => b.index - a.index);\n for (const { index, name, replacement, node } of items) {\n if (replacement === undefined) continue;\n const snippetTree = parseMdxWithDeps(replacement, deps);\n const wrapper: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'Snippet',\n attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],\n children: snippetTree.children as MdxJsxFlowElement['children'],\n };\n if ('position' in node && node.position) {\n (wrapper as { position?: unknown }).position = node.position;\n }\n (parent.children as RootContent[]).splice(\n index,\n 1,\n wrapper as RootContent,\n );\n }\n }\n};\n\nconst applyFilterTransforms = (\n tree: Root,\n options: Record<string, string> | undefined,\n): void => {\n const iac = options?.iac;\n\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n\n if (child.name === 'OptionFilter') {\n const when = parseWhenAttr(child);\n if (!when) continue; // malformed — leave alone\n // Recurse first so nested filters collapse before we replace this wrapper.\n transform(child);\n const not = hasBareAttr(child, 'not');\n if (options) {\n const replacement = evaluatePredicate(when, not, options)\n ? (child.children as RootContent[])\n : [];\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n } else {\n children.splice(i, 1, buildNoteQuote(child, when, not));\n }\n continue;\n }\n\n if (child.name === 'Infrastructure') {\n if (iac === 'cdk' || iac === 'terraform') {\n const body = selectInfrastructureSlot(child, iac);\n const pseudo: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'tmp',\n attributes: [],\n children: body as MdxJsxFlowElement['children'],\n };\n transform(pseudo);\n children.splice(i, 1, ...(pseudo.children as RootContent[]));\n i--;\n continue;\n }\n // No iac → keep both slots so readers / agents see both variants.\n transform(child);\n continue;\n }\n\n if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {\n transform(child);\n const dropped = applyTabsFilter(child, options);\n if (dropped === 'empty') {\n children.splice(i, 1);\n i--;\n continue;\n }\n if (dropped === 'inline') {\n const survivor = (child.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) && c.name === 'TabItem',\n )!;\n const body = survivor.children as RootContent[];\n children.splice(i, 1, ...body);\n i += body.length - 1;\n continue;\n }\n continue;\n }\n\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst selectInfrastructureSlot = (\n node: JsxElement,\n iac: 'cdk' | 'terraform',\n): RootContent[] => {\n const slotName = iac.toLowerCase();\n const frag = (node.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) &&\n c.name === 'Fragment' &&\n readStringAttr(c, 'slot') === slotName,\n );\n return (frag?.children as RootContent[]) ?? [];\n};\n\n/**\n * Prune TabItems whose `_filter` doesn't match `options`. Returns:\n * - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.\n * - `'inline'` if exactly one filtered <TabItem> survived — caller\n * inlines the body so agents see just the picked variant.\n * - `'keep'` otherwise.\n */\nconst applyTabsFilter = (\n tabs: MdxJsxFlowElement,\n options: Record<string, string> | undefined,\n): 'empty' | 'inline' | 'keep' => {\n const children = tabs.children as RootContent[];\n const surviving: RootContent[] = [];\n let anyFiltered = false;\n for (const child of children) {\n if (!isJsxElement(child) || child.name !== 'TabItem') {\n surviving.push(child);\n continue;\n }\n const filterEstree = readEstreeAttr(child, '_filter');\n if (!filterEstree) {\n surviving.push(child);\n continue;\n }\n anyFiltered = true;\n let predicate: Predicate;\n try {\n predicate = parseWhenExpression(filterEstree as never);\n } catch {\n stripFilterAttr(child);\n surviving.push(child);\n continue;\n }\n if (!options || evaluatePredicate(predicate, false, options)) {\n stripFilterAttr(child);\n surviving.push(child);\n }\n }\n if (anyFiltered) {\n tabs.children = surviving as MdxJsxFlowElement['children'];\n }\n const tabItems = surviving.filter(\n (c) => isJsxElement(c) && c.name === 'TabItem',\n );\n if (tabItems.length === 0 && surviving.length === 0) return 'empty';\n if (anyFiltered && tabItems.length === 1) return 'inline';\n return 'keep';\n};\n\nconst stripFilterAttr = (el: JsxElement): void => {\n el.attributes = el.attributes.filter(\n (a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'),\n );\n};\n\n/**\n * `> [!NOTE] Only when …` blockquote. The alert header goes through as an\n * `html` node so remark-stringify doesn't escape the `[`/`]` brackets —\n * downstream agents match on the literal GitHub alert syntax.\n */\nconst buildNoteQuote = (\n source: JsxElement,\n predicate: Predicate,\n not: boolean,\n): RootContent => {\n const marker = describePredicate(predicate, not);\n const description = readStringAttr(source, 'description');\n const headerLines = description\n ? [`[!NOTE] ${marker}`, description]\n : [`[!NOTE] ${marker}`];\n const headerNodes: RootContent[] = headerLines.map(\n (line) => ({ type: 'html', value: line }) as RootContent,\n );\n return {\n type: 'blockquote',\n children: [...headerNodes, ...(source.children as RootContent[])] as never,\n } as RootContent;\n};\n\nconst parseWhenAttr = (node: JsxElement): Predicate | undefined => {\n const estree = readEstreeAttr(node, 'when');\n if (!estree) return undefined;\n try {\n return parseWhenExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n\nconst applyComponentTransforms = (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): void => {\n const pm = opts.packageManager ?? 'pnpm';\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n const replacement = renderComponent(child, opts, pm, deps);\n if (replacement !== undefined) {\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n continue;\n }\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst renderComponent = (\n node: JsxElement,\n opts: PipelineOptions,\n pm: string,\n deps: RemarkDeps,\n): RootContent[] | undefined => {\n switch (node.name) {\n case 'NxCommands': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildNxCommand(c, opts.packageManager))\n .join('\\n'),\n ),\n ];\n }\n case 'RunGenerator': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(\n renderGeneratorCommand(generatorId, schema, opts.packageManager),\n deps,\n );\n }\n case 'GeneratorParameters': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(renderSchema(schema), deps);\n }\n case 'CreateNxWorkspaceCommand': {\n const workspace = readStringAttr(node, 'workspace');\n if (!workspace) return undefined;\n const iac = readStringAttr(node, 'iac') as\n | 'cdk'\n | 'terraform'\n | undefined;\n return [codeBlock(buildCreateNxWorkspaceCommand(pm, workspace, iac))];\n }\n case 'NxInitCommand': {\n return [codeBlock(buildNxInitCommand(pm))];\n }\n case 'InstallCommand': {\n // Without `pkg`, installs the workspace's existing dependencies\n const pkg =\n readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');\n return [\n codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev'))),\n ];\n }\n case 'PackageManagerShortCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildPackageManagerShortCommand(pm, c))\n .join('\\n'),\n ),\n ];\n }\n case 'PackageManagerExecCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands.map((c) => buildPackageManagerExecCommand(pm, c)).join('\\n'),\n ),\n ];\n }\n default:\n return undefined;\n }\n};\n\nconst codeBlock = (body: string): RootContent => ({\n type: 'code',\n lang: 'bash',\n value: body,\n});\n\nconst parseMarkdownFragment = (\n markdown: string,\n deps: RemarkDeps,\n): RootContent[] => {\n const fragTree = deps.unified().use(deps.remarkParse).parse(markdown) as Root;\n return fragTree.children as RootContent[];\n};\n\nconst findSchema = (\n generators: NxGeneratorInfo[],\n generatorId: string,\n):\n | { properties?: Record<string, unknown>; required?: string[] }\n | undefined => {\n const info = generators.find((g) => g.id === generatorId);\n if (!info) return undefined;\n try {\n return JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n } catch {\n return undefined;\n }\n};\n\n/** Parse the `commands={[…]}` attribute from the estree that remark-mdx\n * attaches to the JSX attribute value. */\nconst readCommandsAttr = (node: JsxElement): string[] | undefined => {\n const estree = readEstreeAttr(node, 'commands');\n if (!estree) return undefined;\n try {\n return extractStringArrayExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n"],"names":["fs","buildCreateNxWorkspaceCommand","buildInstallCommand","buildNxInitCommand","buildPackageManagerExecCommand","buildPackageManagerShortCommand","buildNxCommand","renderGeneratorCommand","renderSchema","hasBareAttr","isJsxElement","readEstreeAttr","readExpressionAttr","readStringAttr","describePredicate","evaluatePredicate","extractStringArrayExpression","parseWhenExpression","depsPromise","loadRemarkDeps","unified","remarkParse","default","remarkMdx","remarkStringify","remarkFrontmatter","parseMdxWithDeps","source","deps","use","parse","parseMdx","stringifyMdx","tree","String","bullet","fences","listItemIndent","stringify","stripFrontmatterAndEsm","children","filter","node","type","postProcessGuideWithRemark","guide","opts","inlineSnippets","applyFilterTransforms","options","applyComponentTransforms","provider","snippetContentProvider","pending","walk","parent","i","length","child","name","push","index","fetched","Promise","all","map","p","raw","replacement","undefined","processed","trim","byParent","Map","f","bucket","get","set","items","sort","a","b","snippetTree","wrapper","attributes","value","position","splice","iac","transform","when","parseWhenAttr","not","buildNoteQuote","body","selectInfrastructureSlot","pseudo","dropped","applyTabsFilter","survivor","find","c","slotName","toLowerCase","frag","tabs","surviving","anyFiltered","filterEstree","predicate","stripFilterAttr","tabItems","el","marker","description","headerLines","headerNodes","line","estree","pm","packageManager","renderComponent","commands","readCommandsAttr","codeBlock","join","generatorId","schema","findSchema","generators","parseMarkdownFragment","workspace","pkg","lang","markdown","fragTree","info","g","id","JSON","readFileSync","resolvedSchemaPath"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AAepB,SACEC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBA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