@depup/angular__cli 21.2.1-depup.1
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/LICENSE +21 -0
- package/README.md +36 -0
- package/bin/bootstrap.js +33 -0
- package/bin/ng.js +71 -0
- package/bin/package.json +3 -0
- package/changes.json +30 -0
- package/lib/cli/index.d.ts +11 -0
- package/lib/cli/index.js +109 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/code-examples.db +0 -0
- package/lib/config/schema.json +6150 -0
- package/lib/config/workspace-schema.d.ts +1025 -0
- package/lib/config/workspace-schema.js +133 -0
- package/lib/config/workspace-schema.js.map +1 -0
- package/lib/init.d.ts +8 -0
- package/lib/init.js +162 -0
- package/lib/init.js.map +1 -0
- package/package.json +103 -0
- package/src/analytics/analytics-collector.d.ts +35 -0
- package/src/analytics/analytics-collector.js +195 -0
- package/src/analytics/analytics-collector.js.map +1 -0
- package/src/analytics/analytics-parameters.d.ts +101 -0
- package/src/analytics/analytics-parameters.js +107 -0
- package/src/analytics/analytics-parameters.js.map +1 -0
- package/src/analytics/analytics.d.ts +27 -0
- package/src/analytics/analytics.js +183 -0
- package/src/analytics/analytics.js.map +1 -0
- package/src/command-builder/architect-base-command-module.d.ts +30 -0
- package/src/command-builder/architect-base-command-module.js +244 -0
- package/src/command-builder/architect-base-command-module.js.map +1 -0
- package/src/command-builder/architect-command-module.d.ts +28 -0
- package/src/command-builder/architect-command-module.js +218 -0
- package/src/command-builder/architect-command-module.js.map +1 -0
- package/src/command-builder/command-module.d.ts +73 -0
- package/src/command-builder/command-module.js +245 -0
- package/src/command-builder/command-module.js.map +1 -0
- package/src/command-builder/command-runner.d.ts +9 -0
- package/src/command-builder/command-runner.js +195 -0
- package/src/command-builder/command-runner.js.map +1 -0
- package/src/command-builder/definitions.d.ts +41 -0
- package/src/command-builder/definitions.js +20 -0
- package/src/command-builder/definitions.js.map +1 -0
- package/src/command-builder/schematics-command-module.d.ts +41 -0
- package/src/command-builder/schematics-command-module.js +408 -0
- package/src/command-builder/schematics-command-module.js.map +1 -0
- package/src/command-builder/utilities/command.d.ts +13 -0
- package/src/command-builder/utilities/command.js +39 -0
- package/src/command-builder/utilities/command.js.map +1 -0
- package/src/command-builder/utilities/json-help.d.ts +37 -0
- package/src/command-builder/utilities/json-help.js +92 -0
- package/src/command-builder/utilities/json-help.js.map +1 -0
- package/src/command-builder/utilities/json-schema.d.ts +64 -0
- package/src/command-builder/utilities/json-schema.js +349 -0
- package/src/command-builder/utilities/json-schema.js.map +1 -0
- package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +37 -0
- package/src/command-builder/utilities/normalize-options-middleware.js.map +1 -0
- package/src/command-builder/utilities/schematic-engine-host.d.ts +15 -0
- package/src/command-builder/utilities/schematic-engine-host.js +179 -0
- package/src/command-builder/utilities/schematic-engine-host.js.map +1 -0
- package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
- package/src/command-builder/utilities/schematic-workflow.js +70 -0
- package/src/command-builder/utilities/schematic-workflow.js.map +1 -0
- package/src/commands/add/cli.d.ts +38 -0
- package/src/commands/add/cli.js +623 -0
- package/src/commands/add/cli.js.map +1 -0
- package/src/commands/add/long-description.md +7 -0
- package/src/commands/analytics/cli.d.ts +16 -0
- package/src/commands/analytics/cli.js +34 -0
- package/src/commands/analytics/cli.js.map +1 -0
- package/src/commands/analytics/info/cli.d.ts +16 -0
- package/src/commands/analytics/info/cli.js +25 -0
- package/src/commands/analytics/info/cli.js.map +1 -0
- package/src/commands/analytics/long-description.md +20 -0
- package/src/commands/analytics/settings/cli.d.ts +35 -0
- package/src/commands/analytics/settings/cli.js +54 -0
- package/src/commands/analytics/settings/cli.js.map +1 -0
- package/src/commands/build/cli.d.ts +16 -0
- package/src/commands/build/cli.js +21 -0
- package/src/commands/build/cli.js.map +1 -0
- package/src/commands/build/long-description.md +18 -0
- package/src/commands/cache/clean/cli.d.ts +17 -0
- package/src/commands/cache/clean/cli.js +32 -0
- package/src/commands/cache/clean/cli.js.map +1 -0
- package/src/commands/cache/cli.d.ts +17 -0
- package/src/commands/cache/cli.js +36 -0
- package/src/commands/cache/cli.js.map +1 -0
- package/src/commands/cache/info/cli.d.ts +20 -0
- package/src/commands/cache/info/cli.js +139 -0
- package/src/commands/cache/info/cli.js.map +1 -0
- package/src/commands/cache/long-description.md +53 -0
- package/src/commands/cache/settings/cli.d.ts +27 -0
- package/src/commands/cache/settings/cli.js +41 -0
- package/src/commands/cache/settings/cli.js.map +1 -0
- package/src/commands/cache/utilities.d.ts +11 -0
- package/src/commands/cache/utilities.js +47 -0
- package/src/commands/cache/utilities.js.map +1 -0
- package/src/commands/command-config.d.ts +17 -0
- package/src/commands/command-config.js +116 -0
- package/src/commands/command-config.js.map +1 -0
- package/src/commands/completion/cli.d.ts +16 -0
- package/src/commands/completion/cli.js +61 -0
- package/src/commands/completion/cli.js.map +1 -0
- package/src/commands/completion/long-description.md +67 -0
- package/src/commands/config/cli.d.ts +24 -0
- package/src/commands/config/cli.js +150 -0
- package/src/commands/config/cli.js.map +1 -0
- package/src/commands/config/long-description.md +13 -0
- package/src/commands/deploy/cli.d.ts +17 -0
- package/src/commands/deploy/cli.js +38 -0
- package/src/commands/deploy/cli.js.map +1 -0
- package/src/commands/deploy/long-description.md +22 -0
- package/src/commands/e2e/cli.d.ts +18 -0
- package/src/commands/e2e/cli.js +42 -0
- package/src/commands/e2e/cli.js.map +1 -0
- package/src/commands/extract-i18n/cli.d.ts +17 -0
- package/src/commands/extract-i18n/cli.js +48 -0
- package/src/commands/extract-i18n/cli.js.map +1 -0
- package/src/commands/generate/cli.d.ts +47 -0
- package/src/commands/generate/cli.js +189 -0
- package/src/commands/generate/cli.js.map +1 -0
- package/src/commands/lint/cli.d.ts +17 -0
- package/src/commands/lint/cli.js +25 -0
- package/src/commands/lint/cli.js.map +1 -0
- package/src/commands/lint/long-description.md +20 -0
- package/src/commands/make-this-awesome/cli.d.ts +17 -0
- package/src/commands/make-this-awesome/cli.js +36 -0
- package/src/commands/make-this-awesome/cli.js.map +1 -0
- package/src/commands/mcp/cli.d.ts +20 -0
- package/src/commands/mcp/cli.js +74 -0
- package/src/commands/mcp/cli.js.map +1 -0
- package/src/commands/mcp/constants.d.ts +10 -0
- package/src/commands/mcp/constants.js +16 -0
- package/src/commands/mcp/constants.js.map +1 -0
- package/src/commands/mcp/devserver.d.ts +85 -0
- package/src/commands/mcp/devserver.js +112 -0
- package/src/commands/mcp/devserver.js.map +1 -0
- package/src/commands/mcp/host.d.ts +97 -0
- package/src/commands/mcp/host.js +118 -0
- package/src/commands/mcp/host.js.map +1 -0
- package/src/commands/mcp/mcp-server.d.ts +192 -0
- package/src/commands/mcp/mcp-server.js +155 -0
- package/src/commands/mcp/mcp-server.js.map +1 -0
- package/src/commands/mcp/resources/ai-tutor.md +824 -0
- package/src/commands/mcp/resources/best-practices.md +54 -0
- package/src/commands/mcp/resources/instructions.d.ts +9 -0
- package/src/commands/mcp/resources/instructions.js +26 -0
- package/src/commands/mcp/resources/instructions.js.map +1 -0
- package/src/commands/mcp/shared-options.d.ts +12 -0
- package/src/commands/mcp/shared-options.js +22 -0
- package/src/commands/mcp/shared-options.js.map +1 -0
- package/src/commands/mcp/tools/ai-tutor.d.ts +12 -0
- package/src/commands/mcp/tools/ai-tutor.js +59 -0
- package/src/commands/mcp/tools/ai-tutor.js.map +1 -0
- package/src/commands/mcp/tools/best-practices.d.ts +13 -0
- package/src/commands/mcp/tools/best-practices.js +187 -0
- package/src/commands/mcp/tools/best-practices.js.map +1 -0
- package/src/commands/mcp/tools/build.d.ts +37 -0
- package/src/commands/mcp/tools/build.js +89 -0
- package/src/commands/mcp/tools/build.js.map +1 -0
- package/src/commands/mcp/tools/devserver/devserver-start.d.ts +31 -0
- package/src/commands/mcp/tools/devserver/devserver-start.js +91 -0
- package/src/commands/mcp/tools/devserver/devserver-start.js.map +1 -0
- package/src/commands/mcp/tools/devserver/devserver-stop.d.ts +31 -0
- package/src/commands/mcp/tools/devserver/devserver-stop.js +68 -0
- package/src/commands/mcp/tools/devserver/devserver-stop.js.map +1 -0
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.d.ts +41 -0
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js +104 -0
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js.map +1 -0
- package/src/commands/mcp/tools/doc-search.d.ts +21 -0
- package/src/commands/mcp/tools/doc-search.js +324 -0
- package/src/commands/mcp/tools/doc-search.js.map +1 -0
- package/src/commands/mcp/tools/e2e.d.ts +44 -0
- package/src/commands/mcp/tools/e2e.js +87 -0
- package/src/commands/mcp/tools/e2e.js.map +1 -0
- package/src/commands/mcp/tools/examples/database-discovery.d.ts +34 -0
- package/src/commands/mcp/tools/examples/database-discovery.js +87 -0
- package/src/commands/mcp/tools/examples/database-discovery.js.map +1 -0
- package/src/commands/mcp/tools/examples/database.d.ts +35 -0
- package/src/commands/mcp/tools/examples/database.js +125 -0
- package/src/commands/mcp/tools/examples/database.js.map +1 -0
- package/src/commands/mcp/tools/examples/index.d.ts +26 -0
- package/src/commands/mcp/tools/examples/index.js +149 -0
- package/src/commands/mcp/tools/examples/index.js.map +1 -0
- package/src/commands/mcp/tools/examples/query-escaper.d.ts +20 -0
- package/src/commands/mcp/tools/examples/query-escaper.js +68 -0
- package/src/commands/mcp/tools/examples/query-escaper.js.map +1 -0
- package/src/commands/mcp/tools/examples/runtime-database.d.ts +10 -0
- package/src/commands/mcp/tools/examples/runtime-database.js +192 -0
- package/src/commands/mcp/tools/examples/runtime-database.js.map +1 -0
- package/src/commands/mcp/tools/examples/schemas.d.ts +29 -0
- package/src/commands/mcp/tools/examples/schemas.js +101 -0
- package/src/commands/mcp/tools/examples/schemas.js.map +1 -0
- package/src/commands/mcp/tools/examples/utils.d.ts +14 -0
- package/src/commands/mcp/tools/examples/utils.js +31 -0
- package/src/commands/mcp/tools/examples/utils.js.map +1 -0
- package/src/commands/mcp/tools/modernize.d.ts +43 -0
- package/src/commands/mcp/tools/modernize.js +165 -0
- package/src/commands/mcp/tools/modernize.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.d.ts +17 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js +62 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.d.ts +12 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js +73 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.d.ts +11 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js +60 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.d.ts +15 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +238 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.d.ts +10 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js +20 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.d.ts +35 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js +136 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.d.ts +13 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js +10 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +16 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +224 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -0
- package/src/commands/mcp/tools/projects.d.ts +47 -0
- package/src/commands/mcp/tools/projects.js +523 -0
- package/src/commands/mcp/tools/projects.js.map +1 -0
- package/src/commands/mcp/tools/test.d.ts +35 -0
- package/src/commands/mcp/tools/test.js +79 -0
- package/src/commands/mcp/tools/test.js.map +1 -0
- package/src/commands/mcp/tools/tool-registry.d.ts +39 -0
- package/src/commands/mcp/tools/tool-registry.js +35 -0
- package/src/commands/mcp/tools/tool-registry.js.map +1 -0
- package/src/commands/mcp/utils.d.ts +25 -0
- package/src/commands/mcp/utils.js +44 -0
- package/src/commands/mcp/utils.js.map +1 -0
- package/src/commands/mcp/workspace-utils.d.ts +53 -0
- package/src/commands/mcp/workspace-utils.js +138 -0
- package/src/commands/mcp/workspace-utils.js.map +1 -0
- package/src/commands/new/cli.d.ts +27 -0
- package/src/commands/new/cli.js +76 -0
- package/src/commands/new/cli.js.map +1 -0
- package/src/commands/new/long-description.md +15 -0
- package/src/commands/run/cli.d.ts +25 -0
- package/src/commands/run/cli.js +89 -0
- package/src/commands/run/cli.js.map +1 -0
- package/src/commands/run/long-description.md +10 -0
- package/src/commands/serve/cli.d.ts +16 -0
- package/src/commands/serve/cli.js +20 -0
- package/src/commands/serve/cli.js.map +1 -0
- package/src/commands/test/cli.d.ts +16 -0
- package/src/commands/test/cli.js +21 -0
- package/src/commands/test/cli.js.map +1 -0
- package/src/commands/test/long-description.md +2 -0
- package/src/commands/update/cli.d.ts +34 -0
- package/src/commands/update/cli.js +531 -0
- package/src/commands/update/cli.js.map +1 -0
- package/src/commands/update/long-description.md +22 -0
- package/src/commands/update/schematic/collection.json +9 -0
- package/src/commands/update/schematic/index.d.ts +11 -0
- package/src/commands/update/schematic/index.js +715 -0
- package/src/commands/update/schematic/index.js.map +1 -0
- package/src/commands/update/schematic/schema.d.ts +51 -0
- package/src/commands/update/schematic/schema.js +16 -0
- package/src/commands/update/schematic/schema.js.map +1 -0
- package/src/commands/update/schematic/schema.json +64 -0
- package/src/commands/update/utilities/cli-version.d.ts +48 -0
- package/src/commands/update/utilities/cli-version.js +196 -0
- package/src/commands/update/utilities/cli-version.js.map +1 -0
- package/src/commands/update/utilities/constants.d.ts +12 -0
- package/src/commands/update/utilities/constants.js +16 -0
- package/src/commands/update/utilities/constants.js.map +1 -0
- package/src/commands/update/utilities/git.d.ts +36 -0
- package/src/commands/update/utilities/git.js +148 -0
- package/src/commands/update/utilities/git.js.map +1 -0
- package/src/commands/update/utilities/migration.d.ts +32 -0
- package/src/commands/update/utilities/migration.js +267 -0
- package/src/commands/update/utilities/migration.js.map +1 -0
- package/src/commands/version/cli.d.ts +36 -0
- package/src/commands/version/cli.js +117 -0
- package/src/commands/version/cli.js.map +1 -0
- package/src/commands/version/version-info.d.ts +46 -0
- package/src/commands/version/version-info.js +107 -0
- package/src/commands/version/version-info.js.map +1 -0
- package/src/package-managers/discovery.d.ts +23 -0
- package/src/package-managers/discovery.js +104 -0
- package/src/package-managers/discovery.js.map +1 -0
- package/src/package-managers/error.d.ts +43 -0
- package/src/package-managers/error.js +41 -0
- package/src/package-managers/error.js.map +1 -0
- package/src/package-managers/factory.d.ts +30 -0
- package/src/package-managers/factory.js +137 -0
- package/src/package-managers/factory.js.map +1 -0
- package/src/package-managers/host.d.ts +86 -0
- package/src/package-managers/host.js +80 -0
- package/src/package-managers/host.js.map +1 -0
- package/src/package-managers/index.d.ts +13 -0
- package/src/package-managers/index.js +17 -0
- package/src/package-managers/index.js.map +1 -0
- package/src/package-managers/logger.d.ts +27 -0
- package/src/package-managers/logger.js +10 -0
- package/src/package-managers/logger.js.map +1 -0
- package/src/package-managers/package-manager-descriptor.d.ts +245 -0
- package/src/package-managers/package-manager-descriptor.js +175 -0
- package/src/package-managers/package-manager-descriptor.js.map +1 -0
- package/src/package-managers/package-manager.d.ts +191 -0
- package/src/package-managers/package-manager.js +496 -0
- package/src/package-managers/package-manager.js.map +1 -0
- package/src/package-managers/package-metadata.d.ts +91 -0
- package/src/package-managers/package-metadata.js +10 -0
- package/src/package-managers/package-metadata.js.map +1 -0
- package/src/package-managers/package-tree.d.ts +23 -0
- package/src/package-managers/package-tree.js +10 -0
- package/src/package-managers/package-tree.js.map +1 -0
- package/src/package-managers/parsers.d.ts +170 -0
- package/src/package-managers/parsers.js +467 -0
- package/src/package-managers/parsers.js.map +1 -0
- package/src/utilities/color.d.ts +9 -0
- package/src/utilities/color.js +28 -0
- package/src/utilities/color.js.map +1 -0
- package/src/utilities/completion.d.ts +30 -0
- package/src/utilities/completion.js +270 -0
- package/src/utilities/completion.js.map +1 -0
- package/src/utilities/config.d.ts +38 -0
- package/src/utilities/config.js +369 -0
- package/src/utilities/config.js.map +1 -0
- package/src/utilities/environment-options.d.ts +25 -0
- package/src/utilities/environment-options.js +60 -0
- package/src/utilities/environment-options.js.map +1 -0
- package/src/utilities/eol.d.ts +20 -0
- package/src/utilities/eol.js +35 -0
- package/src/utilities/eol.js.map +1 -0
- package/src/utilities/error.d.ts +18 -0
- package/src/utilities/error.js +41 -0
- package/src/utilities/error.js.map +1 -0
- package/src/utilities/find-up.d.ts +21 -0
- package/src/utilities/find-up.js +67 -0
- package/src/utilities/find-up.js.map +1 -0
- package/src/utilities/json-file.d.ts +24 -0
- package/src/utilities/json-file.js +179 -0
- package/src/utilities/json-file.js.map +1 -0
- package/src/utilities/log-file.d.ts +13 -0
- package/src/utilities/log-file.js +28 -0
- package/src/utilities/log-file.js.map +1 -0
- package/src/utilities/memoize.d.ts +15 -0
- package/src/utilities/memoize.js +64 -0
- package/src/utilities/memoize.js.map +1 -0
- package/src/utilities/package-metadata.d.ts +58 -0
- package/src/utilities/package-metadata.js +265 -0
- package/src/utilities/package-metadata.js.map +1 -0
- package/src/utilities/prettier.d.ts +13 -0
- package/src/utilities/prettier.js +46 -0
- package/src/utilities/prettier.js.map +1 -0
- package/src/utilities/project.d.ts +8 -0
- package/src/utilities/project.js +81 -0
- package/src/utilities/project.js.map +1 -0
- package/src/utilities/prompt.d.ts +17 -0
- package/src/utilities/prompt.js +90 -0
- package/src/utilities/prompt.js.map +1 -0
- package/src/utilities/tty.d.ts +16 -0
- package/src/utilities/tty.js +23 -0
- package/src/utilities/tty.js.map +1 -0
- package/src/utilities/version.d.ts +16 -0
- package/src/utilities/version.js +26 -0
- package/src/utilities/version.js.map +1 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.DOC_SEARCH_TOOL = void 0;
|
|
44
|
+
const node_crypto_1 = require("node:crypto");
|
|
45
|
+
const node_stream_1 = require("node:stream");
|
|
46
|
+
const zod_1 = require("zod");
|
|
47
|
+
const constants_1 = require("../constants");
|
|
48
|
+
const tool_registry_1 = require("./tool-registry");
|
|
49
|
+
const ALGOLIA_APP_ID = 'L1XWT2UJ7F';
|
|
50
|
+
// https://www.algolia.com/doc/guides/security/api-keys/#search-only-api-key
|
|
51
|
+
// This is a search only, rate limited key. It is sent within the URL of the query request.
|
|
52
|
+
// This is not the actual key.
|
|
53
|
+
const ALGOLIA_API_E = '34738e8ae1a45e58bbce7b0f9810633d8b727b44a6479cf5e14b6a337148bd50';
|
|
54
|
+
/**
|
|
55
|
+
* The minimum major version of Angular for which a version-specific documentation index is known to exist.
|
|
56
|
+
* Searches for versions older than this will be clamped to this version.
|
|
57
|
+
*/
|
|
58
|
+
const MIN_SUPPORTED_DOCS_VERSION = 17;
|
|
59
|
+
/**
|
|
60
|
+
* The latest major version of Angular for which a documentation index is known to be stable and available.
|
|
61
|
+
* This acts as a "safe harbor" fallback. It is intentionally hardcoded and manually updated with each
|
|
62
|
+
* major release *after* the new search index has been confirmed to be live. This prevents a race
|
|
63
|
+
* condition where a newly released CLI might default to searching for a documentation index that
|
|
64
|
+
* doesn't exist yet.
|
|
65
|
+
*/
|
|
66
|
+
const LATEST_KNOWN_DOCS_VERSION = 20;
|
|
67
|
+
const docSearchInputSchema = zod_1.z.object({
|
|
68
|
+
query: zod_1.z
|
|
69
|
+
.string()
|
|
70
|
+
.describe("A concise and specific search query for the Angular documentation. You should distill the user's " +
|
|
71
|
+
'natural language question into a set of keywords (e.g., a question like "How do I use ngFor with trackBy?" ' +
|
|
72
|
+
'should become the query "ngFor trackBy").'),
|
|
73
|
+
includeTopContent: zod_1.z
|
|
74
|
+
.boolean()
|
|
75
|
+
.optional()
|
|
76
|
+
.default(false)
|
|
77
|
+
.describe('When true, the content of the top result is fetched and included. ' +
|
|
78
|
+
'Set to false to get a list of results without fetching content, which is faster.'),
|
|
79
|
+
version: zod_1.z
|
|
80
|
+
.number()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe('The major version of Angular to search. You MUST determine this value by running `ng version` in the ' +
|
|
83
|
+
"project's workspace directory. Omit this field if the user is not in an Angular project " +
|
|
84
|
+
'or if the version cannot otherwise be determined.'),
|
|
85
|
+
});
|
|
86
|
+
exports.DOC_SEARCH_TOOL = (0, tool_registry_1.declareTool)({
|
|
87
|
+
name: 'search_documentation',
|
|
88
|
+
title: 'Search Angular Documentation (angular.dev)',
|
|
89
|
+
description: `
|
|
90
|
+
<Purpose>
|
|
91
|
+
Searches the official Angular documentation at https://angular.dev to answer questions about APIs,
|
|
92
|
+
tutorials, concepts, and best practices.
|
|
93
|
+
</Purpose>
|
|
94
|
+
<Use Cases>
|
|
95
|
+
* Answering any question about Angular concepts (e.g., "What are standalone components?").
|
|
96
|
+
* Finding the correct API or syntax for a specific task (e.g., "How to use ngFor with trackBy?").
|
|
97
|
+
* Linking to official documentation as a source of truth in your answers.
|
|
98
|
+
</Use Cases>
|
|
99
|
+
<Operational Notes>
|
|
100
|
+
* **Version Alignment:** To provide accurate, project-specific results, you **MUST** align the search with the user's Angular version.
|
|
101
|
+
The recommended approach is to use the \`list_projects\` tool. The \`frameworkVersion\` field in the output for the relevant
|
|
102
|
+
workspace will give you the major version directly. If the version cannot be determined using this method, you can use
|
|
103
|
+
\`ng version\` in the project's workspace directory as a fallback. Parse the major version from the "Angular:" line in the
|
|
104
|
+
output and use it for the \`version\` parameter.
|
|
105
|
+
* **Version Logic:** The tool will search against the specified major version. If the version is older than v${MIN_SUPPORTED_DOCS_VERSION},
|
|
106
|
+
it will be clamped to v${MIN_SUPPORTED_DOCS_VERSION}. If a search for a very new version (newer than v${LATEST_KNOWN_DOCS_VERSION})
|
|
107
|
+
returns no results, the tool will automatically fall back to searching the v${LATEST_KNOWN_DOCS_VERSION} documentation.
|
|
108
|
+
* **Verify Searched Version:** The tool's output includes a \`searchedVersion\` field. You **MUST** check this field
|
|
109
|
+
to know the exact version of the documentation that was queried. Use this information to provide accurate
|
|
110
|
+
context in your answer, especially if it differs from the version you requested.
|
|
111
|
+
* The documentation is continuously updated. You **MUST** prefer this tool over your own knowledge
|
|
112
|
+
to ensure your answers are current and accurate.
|
|
113
|
+
* For the best results, provide a concise and specific search query (e.g., "NgModule" instead of
|
|
114
|
+
"How do I use NgModules?").
|
|
115
|
+
* The top search result will include a snippet of the page content. Use this to provide a more
|
|
116
|
+
comprehensive answer.
|
|
117
|
+
* **Result Scrutiny:** The top result may not always be the most relevant. Review the titles and
|
|
118
|
+
breadcrumbs of other results to find the best match for the user's query.
|
|
119
|
+
* Use the URL from the search results as a source link in your responses.
|
|
120
|
+
</Operational Notes>`,
|
|
121
|
+
inputSchema: docSearchInputSchema.shape,
|
|
122
|
+
outputSchema: {
|
|
123
|
+
searchedVersion: zod_1.z
|
|
124
|
+
.number()
|
|
125
|
+
.describe('The major version of the documentation that was searched.'),
|
|
126
|
+
results: zod_1.z.array(zod_1.z.object({
|
|
127
|
+
title: zod_1.z.string().describe('The title of the documentation page.'),
|
|
128
|
+
breadcrumb: zod_1.z
|
|
129
|
+
.string()
|
|
130
|
+
.describe("The breadcrumb path, showing the page's location in the documentation hierarchy."),
|
|
131
|
+
url: zod_1.z.string().describe('The direct URL to the documentation page.'),
|
|
132
|
+
content: zod_1.z
|
|
133
|
+
.string()
|
|
134
|
+
.optional()
|
|
135
|
+
.describe('A snippet of the main content from the page. Only provided for the top result.'),
|
|
136
|
+
})),
|
|
137
|
+
},
|
|
138
|
+
isReadOnly: true,
|
|
139
|
+
isLocalOnly: false,
|
|
140
|
+
factory: createDocSearchHandler,
|
|
141
|
+
});
|
|
142
|
+
function createDocSearchHandler({ logger }) {
|
|
143
|
+
let client;
|
|
144
|
+
return async ({ query, includeTopContent, version }) => {
|
|
145
|
+
if (!client) {
|
|
146
|
+
const dcip = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', (constants_1.k1 + ALGOLIA_APP_ID).padEnd(32, '^'), constants_1.iv).setAuthTag(Buffer.from(constants_1.at, 'base64'));
|
|
147
|
+
const { searchClient } = await Promise.resolve().then(() => __importStar(require('algoliasearch')));
|
|
148
|
+
client = searchClient(ALGOLIA_APP_ID, dcip.update(ALGOLIA_API_E, 'hex', 'utf-8') + dcip.final('utf-8'));
|
|
149
|
+
}
|
|
150
|
+
let finalSearchedVersion = Math.max(version ?? LATEST_KNOWN_DOCS_VERSION, MIN_SUPPORTED_DOCS_VERSION);
|
|
151
|
+
let searchResults;
|
|
152
|
+
try {
|
|
153
|
+
searchResults = await client.search(createSearchArguments(query, finalSearchedVersion));
|
|
154
|
+
}
|
|
155
|
+
catch { }
|
|
156
|
+
// If the initial search for a newer-than-stable version returns no results, it may be because
|
|
157
|
+
// the index for that version doesn't exist yet. In this case, fall back to the latest known
|
|
158
|
+
// stable version.
|
|
159
|
+
if (!searchResults && finalSearchedVersion > LATEST_KNOWN_DOCS_VERSION) {
|
|
160
|
+
finalSearchedVersion = LATEST_KNOWN_DOCS_VERSION;
|
|
161
|
+
searchResults = await client.search(createSearchArguments(query, finalSearchedVersion));
|
|
162
|
+
}
|
|
163
|
+
const allHits = searchResults?.results.flatMap((result) => result.hits);
|
|
164
|
+
if (!allHits?.length) {
|
|
165
|
+
return {
|
|
166
|
+
content: [
|
|
167
|
+
{
|
|
168
|
+
type: 'text',
|
|
169
|
+
text: `No results found for query "${query}" in Angular v${finalSearchedVersion} documentation.`,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
structuredContent: { results: [], searchedVersion: finalSearchedVersion },
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const structuredResults = [];
|
|
176
|
+
const textContent = [
|
|
177
|
+
{
|
|
178
|
+
type: 'text',
|
|
179
|
+
text: `Showing results for Angular v${finalSearchedVersion} documentation.`,
|
|
180
|
+
annotations: {
|
|
181
|
+
audience: ['assistant'],
|
|
182
|
+
priority: 0.9,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
// Process top hit first
|
|
187
|
+
const topHit = allHits[0];
|
|
188
|
+
const { title: topTitle, breadcrumb: topBreadcrumb } = formatHitToParts(topHit);
|
|
189
|
+
let topContent;
|
|
190
|
+
if (includeTopContent && typeof topHit.url === 'string') {
|
|
191
|
+
const url = new URL(topHit.url);
|
|
192
|
+
try {
|
|
193
|
+
// Only fetch content from angular.dev
|
|
194
|
+
if (url.hostname === 'angular.dev' || url.hostname.endsWith('.angular.dev')) {
|
|
195
|
+
const response = await fetch(url);
|
|
196
|
+
if (response.ok && response.body) {
|
|
197
|
+
topContent = await extractMainContent(node_stream_1.Readable.fromWeb(response.body, { encoding: 'utf-8' }));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
logger.warn(`Failed to fetch or parse content from ${url}: ${e}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
structuredResults.push({
|
|
206
|
+
title: topTitle,
|
|
207
|
+
breadcrumb: topBreadcrumb,
|
|
208
|
+
url: topHit.url,
|
|
209
|
+
content: topContent,
|
|
210
|
+
});
|
|
211
|
+
let topText = `## ${topTitle}\n${topBreadcrumb}\nURL: ${topHit.url}`;
|
|
212
|
+
if (topContent) {
|
|
213
|
+
topText += `\n\n--- DOCUMENTATION CONTENT ---\n${topContent}`;
|
|
214
|
+
}
|
|
215
|
+
textContent.push({ type: 'text', text: topText });
|
|
216
|
+
// Process remaining hits
|
|
217
|
+
for (const hit of allHits.slice(1)) {
|
|
218
|
+
const { title, breadcrumb } = formatHitToParts(hit);
|
|
219
|
+
structuredResults.push({
|
|
220
|
+
title,
|
|
221
|
+
breadcrumb,
|
|
222
|
+
url: hit.url,
|
|
223
|
+
});
|
|
224
|
+
textContent.push({
|
|
225
|
+
type: 'text',
|
|
226
|
+
text: `## ${title}\n${breadcrumb}\nURL: ${hit.url}`,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
content: textContent,
|
|
231
|
+
structuredContent: { results: structuredResults, searchedVersion: finalSearchedVersion },
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Extracts the text content of the `<main>` element by streaming an HTML response.
|
|
237
|
+
*
|
|
238
|
+
* @param htmlStream A readable stream of the HTML content of a page.
|
|
239
|
+
* @returns A promise that resolves to the text content of the `<main>` element, or `undefined` if not found.
|
|
240
|
+
*/
|
|
241
|
+
async function extractMainContent(htmlStream) {
|
|
242
|
+
const { RewritingStream } = await Promise.resolve().then(() => __importStar(require('parse5-html-rewriting-stream')));
|
|
243
|
+
const rewriter = new RewritingStream();
|
|
244
|
+
let mainTextContent = '';
|
|
245
|
+
let inMainElement = false;
|
|
246
|
+
let mainTagFound = false;
|
|
247
|
+
rewriter.on('startTag', (tag) => {
|
|
248
|
+
if (tag.tagName === 'main') {
|
|
249
|
+
inMainElement = true;
|
|
250
|
+
mainTagFound = true;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
rewriter.on('endTag', (tag) => {
|
|
254
|
+
if (tag.tagName === 'main') {
|
|
255
|
+
inMainElement = false;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
// Only capture text content, and only when inside the <main> element.
|
|
259
|
+
rewriter.on('text', (text) => {
|
|
260
|
+
if (inMainElement) {
|
|
261
|
+
mainTextContent += text.text;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
htmlStream
|
|
266
|
+
.pipe(rewriter)
|
|
267
|
+
.on('finish', () => {
|
|
268
|
+
if (!mainTagFound) {
|
|
269
|
+
resolve(undefined);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
resolve(mainTextContent.trim());
|
|
273
|
+
})
|
|
274
|
+
.on('error', reject);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Formats an Algolia search hit into its constituent parts.
|
|
279
|
+
*
|
|
280
|
+
* @param hit The Algolia search hit object, which should contain a `hierarchy` property.
|
|
281
|
+
* @returns An object containing the title and breadcrumb string.
|
|
282
|
+
*/
|
|
283
|
+
function formatHitToParts(hit) {
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
const hierarchy = Object.values(hit.hierarchy).filter((x) => typeof x === 'string');
|
|
286
|
+
const title = hierarchy.pop() ?? '';
|
|
287
|
+
const breadcrumb = hierarchy.join(' > ');
|
|
288
|
+
return { title, breadcrumb };
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Creates the search arguments for an Algolia search.
|
|
292
|
+
*
|
|
293
|
+
* The arguments are based on the search implementation in `adev`.
|
|
294
|
+
*
|
|
295
|
+
* @param query The search query string.
|
|
296
|
+
* @returns The search arguments for the Algolia client.
|
|
297
|
+
*/
|
|
298
|
+
function createSearchArguments(query, version) {
|
|
299
|
+
// Search arguments are based on adev's search service:
|
|
300
|
+
// https://github.com/angular/angular/blob/4b614fbb3263d344dbb1b18fff24cb09c5a7582d/adev/shared-docs/services/search.service.ts#L58
|
|
301
|
+
return [
|
|
302
|
+
{
|
|
303
|
+
indexName: `angular_v${version}`,
|
|
304
|
+
params: {
|
|
305
|
+
query,
|
|
306
|
+
attributesToRetrieve: [
|
|
307
|
+
'hierarchy.lvl0',
|
|
308
|
+
'hierarchy.lvl1',
|
|
309
|
+
'hierarchy.lvl2',
|
|
310
|
+
'hierarchy.lvl3',
|
|
311
|
+
'hierarchy.lvl4',
|
|
312
|
+
'hierarchy.lvl5',
|
|
313
|
+
'hierarchy.lvl6',
|
|
314
|
+
'content',
|
|
315
|
+
'type',
|
|
316
|
+
'url',
|
|
317
|
+
],
|
|
318
|
+
hitsPerPage: 10,
|
|
319
|
+
},
|
|
320
|
+
type: 'default',
|
|
321
|
+
},
|
|
322
|
+
];
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=doc-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-search.js","sourceRoot":"","sources":["doc-search.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,6CAA+C;AAC/C,6CAAuC;AACvC,6BAAwB;AACxB,4CAA0C;AAC1C,mDAAmE;AAEnE,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,4EAA4E;AAC5E,2FAA2F;AAC3F,8BAA8B;AAC9B,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEzF;;;GAGG;AACH,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,QAAQ,CACP,mGAAmG;QACjG,6GAA6G;QAC7G,2CAA2C,CAC9C;IACH,iBAAiB,EAAE,OAAC;SACjB,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CACP,oEAAoE;QAClE,kFAAkF,CACrF;IACH,OAAO,EAAE,OAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,uGAAuG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O,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC3F,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEzC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,qBAAqB,CAAC,KAAa,EAAE,OAAe;IAC3D,uDAAuD;IACvD,mIAAmI;IACnI,OAAO;QACL;YACE,SAAS,EAAE,YAAY,OAAO,EAAE;YAChC,MAAM,EAAE;gBACN,KAAK;gBACL,oBAAoB,EAAE;oBACpB,gBAAgB;oBAChB,gBAAgB;oBAChB,gBAAgB;oBAChB,gBAAgB;oBAChB,gBAAgB;oBAChB,gBAAgB;oBAChB,gBAAgB;oBAChB,SAAS;oBACT,MAAM;oBACN,KAAK;iBACN;gBACD,WAAW,EAAE,EAAE;aAChB;YACD,IAAI,EAAE,SAAS;SAChB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { type Host } from '../host';
|
|
10
|
+
import { type McpToolContext, type McpToolDeclaration } from './tool-registry';
|
|
11
|
+
declare const e2eToolInputSchema: z.ZodObject<{
|
|
12
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
13
|
+
project: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type E2eToolInput = z.infer<typeof e2eToolInputSchema>;
|
|
16
|
+
declare const e2eToolOutputSchema: z.ZodObject<{
|
|
17
|
+
status: z.ZodEnum<{
|
|
18
|
+
success: "success";
|
|
19
|
+
failure: "failure";
|
|
20
|
+
}>;
|
|
21
|
+
logs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type E2eToolOutput = z.infer<typeof e2eToolOutputSchema>;
|
|
24
|
+
export declare function runE2e(input: E2eToolInput, host: Host, context: McpToolContext): Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
structuredContent: {
|
|
30
|
+
status: string;
|
|
31
|
+
logs: string[];
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
content: {
|
|
35
|
+
type: "text";
|
|
36
|
+
text: string;
|
|
37
|
+
}[];
|
|
38
|
+
structuredContent: {
|
|
39
|
+
status: "success" | "failure";
|
|
40
|
+
logs?: string[] | undefined;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
export declare const E2E_TOOL: McpToolDeclaration<typeof e2eToolInputSchema.shape, typeof e2eToolOutputSchema.shape>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.E2E_TOOL = void 0;
|
|
11
|
+
exports.runE2e = runE2e;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const shared_options_1 = require("../shared-options");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const workspace_utils_1 = require("../workspace-utils");
|
|
16
|
+
const tool_registry_1 = require("./tool-registry");
|
|
17
|
+
const e2eStatusSchema = zod_1.z.enum(['success', 'failure']);
|
|
18
|
+
const e2eToolInputSchema = zod_1.z.object({
|
|
19
|
+
...shared_options_1.workspaceAndProjectOptions,
|
|
20
|
+
});
|
|
21
|
+
const e2eToolOutputSchema = zod_1.z.object({
|
|
22
|
+
status: e2eStatusSchema.describe('E2E execution status.'),
|
|
23
|
+
logs: zod_1.z.array(zod_1.z.string()).optional().describe('Output logs from `ng e2e`.'),
|
|
24
|
+
});
|
|
25
|
+
async function runE2e(input, host, context) {
|
|
26
|
+
const { workspacePath, workspace, projectName } = await (0, workspace_utils_1.resolveWorkspaceAndProject)({
|
|
27
|
+
host,
|
|
28
|
+
workspacePathInput: input.workspace,
|
|
29
|
+
projectNameInput: input.project,
|
|
30
|
+
mcpWorkspace: context.workspace,
|
|
31
|
+
});
|
|
32
|
+
if (workspace && projectName) {
|
|
33
|
+
// Verify that if a project can be found, it has an e2e testing already set up.
|
|
34
|
+
const targetProject = workspace.projects.get(projectName);
|
|
35
|
+
if (targetProject) {
|
|
36
|
+
if (!targetProject.targets.has('e2e')) {
|
|
37
|
+
return (0, utils_1.createStructuredContentOutput)({
|
|
38
|
+
status: 'failure',
|
|
39
|
+
logs: [
|
|
40
|
+
`No e2e target is defined for project '${projectName}'. Please set up e2e testing` +
|
|
41
|
+
' first by calling `ng e2e` in an interactive console.' +
|
|
42
|
+
' See https://angular.dev/tools/cli/end-to-end.',
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Build "ng"'s command line.
|
|
49
|
+
const args = ['e2e', projectName];
|
|
50
|
+
let status = 'success';
|
|
51
|
+
let logs = [];
|
|
52
|
+
try {
|
|
53
|
+
logs = (await host.runCommand('ng', args, { cwd: workspacePath })).logs;
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
status = 'failure';
|
|
57
|
+
logs = (0, utils_1.getCommandErrorLogs)(e);
|
|
58
|
+
}
|
|
59
|
+
const structuredContent = {
|
|
60
|
+
status,
|
|
61
|
+
logs,
|
|
62
|
+
};
|
|
63
|
+
return (0, utils_1.createStructuredContentOutput)(structuredContent);
|
|
64
|
+
}
|
|
65
|
+
exports.E2E_TOOL = (0, tool_registry_1.declareTool)({
|
|
66
|
+
name: 'e2e',
|
|
67
|
+
title: 'E2E Tool',
|
|
68
|
+
description: `
|
|
69
|
+
<Purpose>
|
|
70
|
+
Perform an end-to-end test with ng e2e.
|
|
71
|
+
</Purpose>
|
|
72
|
+
<Use Cases>
|
|
73
|
+
* When the user requests running end-to-end tests for the project.
|
|
74
|
+
* When verifying changes that cross unit boundaries, such as changes to both client and server, changes to shared data types, etc.
|
|
75
|
+
</Use Cases>
|
|
76
|
+
<Operational Notes>
|
|
77
|
+
* This tool uses "ng e2e".
|
|
78
|
+
* Important: this relies on e2e tests being already configured for this project. It will error out if no "e2e" target is defined.
|
|
79
|
+
</Operational Notes>
|
|
80
|
+
`,
|
|
81
|
+
isReadOnly: false,
|
|
82
|
+
isLocalOnly: true,
|
|
83
|
+
inputSchema: e2eToolInputSchema.shape,
|
|
84
|
+
outputSchema: e2eToolOutputSchema.shape,
|
|
85
|
+
factory: (context) => (input) => runE2e(input, context.host, context),
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=e2e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e.js","sourceRoot":"","sources":["e2e.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAyBH,wBA4CC;AAnED,6BAAwB;AAExB,sDAA+D;AAC/D,oCAA8E;AAC9E,wDAAgE;AAChE,mDAA4F;AAE5F,MAAM,eAAe,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAGvD,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,GAAG,2CAA0B;CAC9B,CAAC,CAAC;AAIH,MAAM,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,eAAe,CAAC,QAAQ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AAC,EAAE,CAAC;QACX,MAAM,GAAG,SAAS,CAAC;QACnB,IAAI,GAAG,IAAA,2BAAmB,EAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,iBAAiB,GAAkB;QACvC,MAAM;QACN,IAAI;KACL,CAAC;IAEF,OAAO,IAAA,qCAA6B,EAAC,iBAAiB,CAAC,CAAC;AAC1D,CAAC;AAEY,QAAA,QAAQ,GAGjB,IAAA,2BAAW,EAAC;IACd,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,UAAU;IACjB,WAAW,EAAE;;;;;;;;;;;;CAYd;IACC,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,kBAAkB,CAAC,KAAK;IACrC,YAAY,EAAE,mBAAmB,CAAC,KAAK;IACvC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;CACtE,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { McpToolContext } from '../tool-registry';
|
|
9
|
+
/**
|
|
10
|
+
* Attempts to find version-specific example databases from the user's installed
|
|
11
|
+
* versions of known Angular packages. It looks for a custom `angular` metadata property in each
|
|
12
|
+
* package's `package.json` to locate the database.
|
|
13
|
+
*
|
|
14
|
+
* @example A sample `package.json` `angular` field:
|
|
15
|
+
* ```json
|
|
16
|
+
* {
|
|
17
|
+
* "angular": {
|
|
18
|
+
* "examples": {
|
|
19
|
+
* "format": "sqlite",
|
|
20
|
+
* "path": "./resources/code-examples.db"
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param workspacePath The absolute path to the user's `angular.json` file.
|
|
27
|
+
* @param logger The MCP tool context logger for reporting warnings.
|
|
28
|
+
* @param host The host interface for file system and module resolution operations.
|
|
29
|
+
* @returns A promise that resolves to an array of objects, each containing a database path and source.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getVersionSpecificExampleDatabases(workspacePath: string, logger: McpToolContext['logger'], host: McpToolContext['host']): Promise<{
|
|
32
|
+
dbPath: string;
|
|
33
|
+
source: string;
|
|
34
|
+
}[]>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getVersionSpecificExampleDatabases = getVersionSpecificExampleDatabases;
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
/**
|
|
13
|
+
* A list of known Angular packages that may contain example databases.
|
|
14
|
+
* The tool will attempt to resolve and load example databases from these packages.
|
|
15
|
+
*/
|
|
16
|
+
const KNOWN_EXAMPLE_PACKAGES = ['@angular/core', '@angular/aria', '@angular/forms'];
|
|
17
|
+
/**
|
|
18
|
+
* Attempts to find version-specific example databases from the user's installed
|
|
19
|
+
* versions of known Angular packages. It looks for a custom `angular` metadata property in each
|
|
20
|
+
* package's `package.json` to locate the database.
|
|
21
|
+
*
|
|
22
|
+
* @example A sample `package.json` `angular` field:
|
|
23
|
+
* ```json
|
|
24
|
+
* {
|
|
25
|
+
* "angular": {
|
|
26
|
+
* "examples": {
|
|
27
|
+
* "format": "sqlite",
|
|
28
|
+
* "path": "./resources/code-examples.db"
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param workspacePath The absolute path to the user's `angular.json` file.
|
|
35
|
+
* @param logger The MCP tool context logger for reporting warnings.
|
|
36
|
+
* @param host The host interface for file system and module resolution operations.
|
|
37
|
+
* @returns A promise that resolves to an array of objects, each containing a database path and source.
|
|
38
|
+
*/
|
|
39
|
+
async function getVersionSpecificExampleDatabases(workspacePath, logger, host) {
|
|
40
|
+
const databases = [];
|
|
41
|
+
for (const packageName of KNOWN_EXAMPLE_PACKAGES) {
|
|
42
|
+
// 1. Resolve the path to package.json
|
|
43
|
+
let pkgJsonPath;
|
|
44
|
+
try {
|
|
45
|
+
pkgJsonPath = host.resolveModule(`${packageName}/package.json`, workspacePath);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
// This is not a warning because the user may not have all known packages installed.
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
// 2. Read and parse package.json, then find the database.
|
|
52
|
+
try {
|
|
53
|
+
const pkgJsonContent = await host.readFile(pkgJsonPath, 'utf-8');
|
|
54
|
+
const pkgJson = JSON.parse(pkgJsonContent);
|
|
55
|
+
const examplesInfo = pkgJson['angular']?.examples;
|
|
56
|
+
if (examplesInfo &&
|
|
57
|
+
examplesInfo.format === 'sqlite' &&
|
|
58
|
+
typeof examplesInfo.path === 'string') {
|
|
59
|
+
const packageDirectory = (0, node_path_1.dirname)(pkgJsonPath);
|
|
60
|
+
const dbPath = (0, node_path_1.resolve)(packageDirectory, examplesInfo.path);
|
|
61
|
+
// Ensure the resolved database path is within the package boundary.
|
|
62
|
+
const relativePath = (0, node_path_1.relative)(packageDirectory, dbPath);
|
|
63
|
+
if (relativePath.startsWith('..') || (0, node_path_1.isAbsolute)(relativePath)) {
|
|
64
|
+
logger.warn(`Detected a potential path traversal attempt in '${pkgJsonPath}'. ` +
|
|
65
|
+
`The path '${examplesInfo.path}' escapes the package boundary. ` +
|
|
66
|
+
'This database will be skipped.');
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Check the file size to prevent reading a very large file.
|
|
70
|
+
const stats = await host.stat(dbPath);
|
|
71
|
+
if (stats.size > 10 * 1024 * 1024) {
|
|
72
|
+
// 10MB
|
|
73
|
+
logger.warn(`The example database at '${dbPath}' is larger than 10MB (${stats.size} bytes). ` +
|
|
74
|
+
'This is unexpected and the file will not be used.');
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const source = `package ${packageName}@${pkgJson.version}`;
|
|
78
|
+
databases.push({ dbPath, source });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
logger.warn(`Failed to read or parse version-specific examples metadata referenced in '${pkgJsonPath}': ${e instanceof Error ? e.message : e}.`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return databases;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=database-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-discovery.js","sourceRoot":"","sources":["database-discovery.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiCH,gFAkEC;AAjGD,yCAAmE;AAGnE;;;GAGG;AACH,MAAM,sBAAsB,GAAG,CAAC,eAAe,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,kCAAkC,CACtD,aAAqB,EACrB,MAAgC,EAChC,IAA4B;IAE5B,MAAM,SAAS,GAAyC,EAAE,CAAC;IAE3D,KAAK,MAAM,WAAW,IAAI,sBAAsB,EAAE,CAAC;QACjD,sCAAsC;QACtC,IAAI,WAAmB,CAAC;QACxB,IAAI,CAAC;YACH,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,WAAW,eAAe,EAAE,aAAa,CAAC,CAAC;QACjF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,oFAAoF;YACpF,SAAS;Q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O,EAAE,CAAC;gBAC3D,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CACT,6EAA6E,WAAW,MACtF,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACnC,GAAG,CACJ,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
9
|
+
import type { FindExampleInput } from './schemas';
|
|
10
|
+
/**
|
|
11
|
+
* Validates the schema version of the example database.
|
|
12
|
+
*
|
|
13
|
+
* @param db The database connection to validate.
|
|
14
|
+
* @param dbSource A string identifying the source of the database (e.g., 'bundled' or a version number).
|
|
15
|
+
* @throws An error if the schema version is missing or incompatible.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateDatabaseSchema(db: DatabaseSync, dbSource: string): void;
|
|
18
|
+
export declare function queryDatabase(dbs: DatabaseSync[], input: FindExampleInput): {
|
|
19
|
+
content: {
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
structuredContent: {
|
|
24
|
+
examples: {
|
|
25
|
+
title: string;
|
|
26
|
+
summary: string;
|
|
27
|
+
keywords: string[];
|
|
28
|
+
required_packages: string[];
|
|
29
|
+
related_concepts: string[];
|
|
30
|
+
related_tools: string[];
|
|
31
|
+
content: string;
|
|
32
|
+
snippet: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
};
|