@angular/cli 21.0.0-next.1 → 21.0.0-next.10
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/lib/cli/index.js +1 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/code-examples.db +0 -0
- package/lib/config/schema.json +272 -46
- package/lib/config/workspace-schema.d.ts +55 -0
- package/lib/config/workspace-schema.js +22 -1
- package/lib/config/workspace-schema.js.map +1 -0
- package/lib/init.js +1 -0
- package/lib/init.js.map +1 -0
- package/package.json +24 -23
- package/src/analytics/analytics-collector.js +1 -0
- package/src/analytics/analytics-collector.js.map +1 -0
- package/src/analytics/analytics-parameters.js +1 -0
- package/src/analytics/analytics-parameters.js.map +1 -0
- package/src/analytics/analytics.js +1 -0
- package/src/analytics/analytics.js.map +1 -0
- package/src/command-builder/architect-base-command-module.js +1 -0
- package/src/command-builder/architect-base-command-module.js.map +1 -0
- package/src/command-builder/architect-command-module.js +21 -7
- package/src/command-builder/architect-command-module.js.map +1 -0
- package/src/command-builder/command-module.js +1 -0
- package/src/command-builder/command-module.js.map +1 -0
- package/src/command-builder/command-runner.js +2 -2
- package/src/command-builder/command-runner.js.map +1 -0
- package/src/command-builder/schematics-command-module.js +1 -0
- package/src/command-builder/schematics-command-module.js.map +1 -0
- package/src/command-builder/utilities/command.js +1 -0
- package/src/command-builder/utilities/command.js.map +1 -0
- package/src/command-builder/utilities/json-help.js +1 -0
- package/src/command-builder/utilities/json-help.js.map +1 -0
- package/src/command-builder/utilities/json-schema.d.ts +13 -1
- package/src/command-builder/utilities/json-schema.js +180 -100
- package/src/command-builder/utilities/json-schema.js.map +1 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +1 -0
- package/src/command-builder/utilities/normalize-options-middleware.js.map +1 -0
- package/src/command-builder/utilities/schematic-engine-host.js +1 -0
- package/src/command-builder/utilities/schematic-engine-host.js.map +1 -0
- package/src/command-builder/utilities/schematic-workflow.js +1 -0
- package/src/command-builder/utilities/schematic-workflow.js.map +1 -0
- package/src/commands/add/cli.js +66 -26
- package/src/commands/add/cli.js.map +1 -0
- package/src/commands/analytics/cli.js +1 -0
- package/src/commands/analytics/cli.js.map +1 -0
- package/src/commands/analytics/info/cli.js +1 -0
- package/src/commands/analytics/info/cli.js.map +1 -0
- package/src/commands/analytics/settings/cli.js +1 -0
- package/src/commands/analytics/settings/cli.js.map +1 -0
- package/src/commands/build/cli.js +1 -0
- package/src/commands/build/cli.js.map +1 -0
- package/src/commands/cache/clean/cli.js +1 -0
- package/src/commands/cache/clean/cli.js.map +1 -0
- package/src/commands/cache/cli.js +1 -0
- package/src/commands/cache/cli.js.map +1 -0
- package/src/commands/cache/info/cli.js +36 -11
- package/src/commands/cache/info/cli.js.map +1 -0
- package/src/commands/cache/settings/cli.js +1 -0
- package/src/commands/cache/settings/cli.js.map +1 -0
- package/src/commands/cache/utilities.js +1 -0
- package/src/commands/cache/utilities.js.map +1 -0
- package/src/commands/command-config.js +1 -0
- package/src/commands/command-config.js.map +1 -0
- package/src/commands/completion/cli.js +1 -0
- package/src/commands/completion/cli.js.map +1 -0
- package/src/commands/config/cli.js +1 -0
- package/src/commands/config/cli.js.map +1 -0
- package/src/commands/deploy/cli.js +1 -0
- package/src/commands/deploy/cli.js.map +1 -0
- package/src/commands/e2e/cli.js +1 -0
- package/src/commands/e2e/cli.js.map +1 -0
- package/src/commands/extract-i18n/cli.js +1 -0
- package/src/commands/extract-i18n/cli.js.map +1 -0
- package/src/commands/generate/cli.js +1 -0
- package/src/commands/generate/cli.js.map +1 -0
- package/src/commands/lint/cli.js +1 -0
- package/src/commands/lint/cli.js.map +1 -0
- package/src/commands/make-this-awesome/cli.js +1 -0
- package/src/commands/make-this-awesome/cli.js.map +1 -0
- package/src/commands/mcp/cli.js +1 -0
- package/src/commands/mcp/cli.js.map +1 -0
- package/src/commands/mcp/constants.d.ts +1 -1
- package/src/commands/mcp/constants.js +2 -1
- package/src/commands/mcp/constants.js.map +1 -0
- package/src/commands/mcp/mcp-server.d.ts +3 -3
- package/src/commands/mcp/mcp-server.js +40 -4
- package/src/commands/mcp/mcp-server.js.map +1 -0
- package/src/commands/mcp/resources/ai-tutor.md +627 -0
- package/src/commands/mcp/resources/instructions.js +1 -0
- package/src/commands/mcp/resources/instructions.js.map +1 -0
- package/src/commands/mcp/tools/ai-tutor.d.ts +8 -0
- package/src/commands/mcp/tools/ai-tutor.js +62 -0
- package/src/commands/mcp/tools/ai-tutor.js.map +1 -0
- package/src/commands/mcp/tools/best-practices.d.ts +4 -1
- package/src/commands/mcp/tools/best-practices.js +167 -22
- package/src/commands/mcp/tools/best-practices.js.map +1 -0
- package/src/commands/mcp/tools/doc-search.d.ts +20 -1
- package/src/commands/mcp/tools/doc-search.js +186 -67
- package/src/commands/mcp/tools/doc-search.js.map +1 -0
- package/src/commands/mcp/tools/examples.d.ts +35 -1
- package/src/commands/mcp/tools/examples.js +414 -56
- package/src/commands/mcp/tools/examples.js.map +1 -0
- package/src/commands/mcp/tools/modernize.js +29 -17
- 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 +106 -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 +36 -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 +14 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +228 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -0
- package/src/commands/mcp/tools/projects.d.ts +75 -16
- package/src/commands/mcp/tools/projects.js +427 -30
- package/src/commands/mcp/tools/projects.js.map +1 -0
- package/src/commands/mcp/tools/tool-registry.d.ts +2 -1
- package/src/commands/mcp/tools/tool-registry.js +4 -2
- package/src/commands/mcp/tools/tool-registry.js.map +1 -0
- package/src/commands/new/cli.js +2 -0
- package/src/commands/new/cli.js.map +1 -0
- package/src/commands/run/cli.js +1 -0
- package/src/commands/run/cli.js.map +1 -0
- package/src/commands/serve/cli.js +1 -0
- package/src/commands/serve/cli.js.map +1 -0
- package/src/commands/test/cli.js +1 -0
- package/src/commands/test/cli.js.map +1 -0
- package/src/commands/update/cli.js +1 -0
- package/src/commands/update/cli.js.map +1 -0
- package/src/commands/update/schematic/index.js +1 -0
- package/src/commands/update/schematic/index.js.map +1 -0
- package/src/commands/update/schematic/schema.js +1 -0
- package/src/commands/update/schematic/schema.js.map +1 -0
- package/src/commands/version/cli.d.ts +3 -7
- package/src/commands/version/cli.js +50 -49
- package/src/commands/version/cli.js.map +1 -0
- package/src/commands/version/version-info.d.ts +28 -10
- package/src/commands/version/version-info.js +34 -50
- 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 +110 -0
- package/src/package-managers/discovery.js.map +1 -0
- package/src/package-managers/error.d.ts +31 -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 +25 -0
- package/src/package-managers/factory.js +123 -0
- package/src/package-managers/factory.js.map +1 -0
- package/src/package-managers/host.d.ts +64 -0
- package/src/package-managers/host.js +69 -0
- package/src/package-managers/host.js.map +1 -0
- package/src/package-managers/index.d.ts +12 -0
- package/src/package-managers/index.js +15 -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 +204 -0
- package/src/package-managers/package-manager-descriptor.js +147 -0
- package/src/package-managers/package-manager-descriptor.js.map +1 -0
- package/src/package-managers/package-manager.d.ts +144 -0
- package/src/package-managers/package-manager.js +304 -0
- package/src/package-managers/package-manager.js.map +1 -0
- package/src/package-managers/package-metadata.d.ts +87 -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 +92 -0
- package/src/package-managers/parsers.js +234 -0
- package/src/package-managers/parsers.js.map +1 -0
- package/src/package-managers/testing/mock-host.d.ts +26 -0
- package/src/package-managers/testing/mock-host.js +53 -0
- package/src/package-managers/testing/mock-host.js.map +1 -0
- package/src/utilities/color.js +1 -0
- package/src/utilities/color.js.map +1 -0
- package/src/utilities/completion.js +1 -0
- package/src/utilities/completion.js.map +1 -0
- package/src/utilities/config.js +1 -0
- package/src/utilities/config.js.map +1 -0
- package/src/utilities/environment-options.js +1 -0
- package/src/utilities/environment-options.js.map +1 -0
- package/src/utilities/eol.js +1 -0
- package/src/utilities/eol.js.map +1 -0
- package/src/utilities/error.js +1 -0
- package/src/utilities/error.js.map +1 -0
- package/src/utilities/find-up.js +1 -0
- package/src/utilities/find-up.js.map +1 -0
- package/src/utilities/json-file.js +1 -0
- package/src/utilities/json-file.js.map +1 -0
- package/src/utilities/log-file.js +1 -0
- package/src/utilities/log-file.js.map +1 -0
- package/src/utilities/memoize.js +1 -0
- package/src/utilities/memoize.js.map +1 -0
- package/src/utilities/package-manager.d.ts +12 -0
- package/src/utilities/package-manager.js +52 -35
- package/src/utilities/package-manager.js.map +1 -0
- package/src/utilities/package-metadata.js +1 -0
- package/src/utilities/package-metadata.js.map +1 -0
- package/src/utilities/package-tree.js +1 -0
- package/src/utilities/package-tree.js.map +1 -0
- package/src/utilities/project.js +1 -0
- package/src/utilities/project.js.map +1 -0
- package/src/utilities/prompt.js +1 -0
- package/src/utilities/prompt.js.map +1 -0
- package/src/utilities/tty.js +1 -0
- package/src/utilities/tty.js.map +1 -0
- package/src/utilities/version.js +2 -1
- package/src/utilities/version.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["instructions.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAMH,oEAmBC;AAtBD,+CAA4C;AAC5C,0DAA6B;AAE7B,SAAgB,4BAA4B,CAAC,MAAiB;IAC5D,MAAM,CAAC,gBAAgB,CACrB,cAAc,EACd,+BAA+B,EAC/B;QACE,KAAK,EAAE,kDAAkD;QACzD,WAAW,EACT,+FAA+F;YAC/F,kFAAkF;YAClF,mFAAmF;YACnF,0EAA0E;QAC5E,QAAQ,EAAE,eAAe;KAC1B,EACD,KAAK,IAAI,EAAE;QACT,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAQ,EAAC,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,OAAO,CAAC,CAAC;QAEhF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACxE,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export declare const AI_TUTOR_TOOL: import("./tool-registry").McpToolDeclaration<import("zod").ZodRawShape, import("zod").ZodRawShape>;
|
|
@@ -0,0 +1,62 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AI_TUTOR_TOOL = void 0;
|
|
14
|
+
const promises_1 = require("node:fs/promises");
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
const tool_registry_1 = require("./tool-registry");
|
|
17
|
+
exports.AI_TUTOR_TOOL = (0, tool_registry_1.declareTool)({
|
|
18
|
+
name: 'ai_tutor',
|
|
19
|
+
title: 'Start Angular AI Tutor',
|
|
20
|
+
description: `
|
|
21
|
+
<Purpose>
|
|
22
|
+
Loads the core instructions, curriculum, and persona for the Angular AI Tutor.
|
|
23
|
+
This tool acts as a RAG (Retrieval-Augmented Generation) source, effectively
|
|
24
|
+
reprogramming the assistant to become a specialized Angular tutor by providing it
|
|
25
|
+
with a new core identity and knowledge base.
|
|
26
|
+
</Purpose>
|
|
27
|
+
<Use Cases>
|
|
28
|
+
* The user asks to start a guided, step-by-step tutorial for learning Angular (e.g., "teach me Angular," "start the tutorial").
|
|
29
|
+
* The user asks to resume a previous tutoring session.
|
|
30
|
+
</Use Cases>
|
|
31
|
+
<Operational Notes>
|
|
32
|
+
* The text returned by this tool is a new set of instructions and rules for you, the LLM. It is NOT meant to be displayed to the user.
|
|
33
|
+
* After invoking this tool, you MUST adopt the persona of the Angular AI Tutor and follow the curriculum provided in the text.
|
|
34
|
+
* Be aware that the tutor persona supports special user commands, such as "skip this section," "show the table of contents,"
|
|
35
|
+
or "set my experience level to beginner." The curriculum text will provide the full details on how to handle these.
|
|
36
|
+
* Your subsequent responses should be governed by these new instructions, leading the user through the "Smart Recipe Box"
|
|
37
|
+
application tutorial.
|
|
38
|
+
* As the tutor, you will use your other tools to access the user's project files to verify their solutions as instructed by the curriculum.
|
|
39
|
+
</Operational Notes>
|
|
40
|
+
`,
|
|
41
|
+
isReadOnly: true,
|
|
42
|
+
isLocalOnly: true,
|
|
43
|
+
factory: () => {
|
|
44
|
+
let aiTutorText;
|
|
45
|
+
return async () => {
|
|
46
|
+
aiTutorText ??= await (0, promises_1.readFile)(node_path_1.default.join(__dirname, '..', 'resources', 'ai-tutor.md'), 'utf-8');
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text: aiTutorText,
|
|
52
|
+
annotations: {
|
|
53
|
+
audience: ['assistant'],
|
|
54
|
+
priority: 1.0,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=ai-tutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-tutor.js","sourceRoot":"","sources":["ai-tutor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH,+CAA4C;AAC5C,0DAA6B;AAC7B,mDAA8C;AAEjC,QAAA,aAAa,GAAG,IAAA,2BAAW,EAAC;IACvC,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;CAoBd;IACC,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,GAAG,EAAE;QACZ,IAAI,WAAmB,CAAC;QAExB,OAAO,KAAK,IAAI,EAAE;YAChB,WAAW,KAAK,MAAM,IAAA,mBAAQ,EAC5B,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,EACtD,OAAO,CACR,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,WAAW;wBACjB,WAAW,EAAE;4BACX,QAAQ,EAAE,CAAC,WAAW,CAAC;4BACvB,QAAQ,EAAE,GAAG;yBACd;qBACF;iBACF;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -5,4 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
export declare const BEST_PRACTICES_TOOL: import("./tool-registry").McpToolDeclaration<{
|
|
10
|
+
workspacePath: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.ZodRawShape>;
|
|
@@ -11,35 +11,180 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.BEST_PRACTICES_TOOL = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* @fileoverview
|
|
16
|
+
* This file defines the `get_best_practices` MCP tool. The tool is designed to be version-aware,
|
|
17
|
+
* dynamically resolving the best practices guide from the user's installed version of
|
|
18
|
+
* `@angular/core`. It achieves this by reading a custom `angular` metadata block in the
|
|
19
|
+
* framework's `package.json`. If this resolution fails, it gracefully falls back to a generic
|
|
20
|
+
* guide bundled with the Angular CLI.
|
|
21
|
+
*/
|
|
14
22
|
const promises_1 = require("node:fs/promises");
|
|
23
|
+
const node_module_1 = require("node:module");
|
|
15
24
|
const node_path_1 = __importDefault(require("node:path"));
|
|
25
|
+
const zod_1 = require("zod");
|
|
26
|
+
const version_1 = require("../../../utilities/version");
|
|
16
27
|
const tool_registry_1 = require("./tool-registry");
|
|
28
|
+
const bestPracticesInputSchema = zod_1.z.object({
|
|
29
|
+
workspacePath: zod_1.z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('The absolute path to the `angular.json` file for the workspace. This is used to find the ' +
|
|
33
|
+
'version-specific best practices guide that corresponds to the installed version of the ' +
|
|
34
|
+
'Angular framework. You **MUST** get this path from the `list_projects` tool. If omitted, ' +
|
|
35
|
+
'the tool will return the generic best practices guide bundled with the CLI.'),
|
|
36
|
+
});
|
|
17
37
|
exports.BEST_PRACTICES_TOOL = (0, tool_registry_1.declareTool)({
|
|
18
38
|
name: 'get_best_practices',
|
|
19
39
|
title: 'Get Angular Coding Best Practices Guide',
|
|
20
|
-
description:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
description: `
|
|
41
|
+
<Purpose>
|
|
42
|
+
Retrieves the official Angular Best Practices Guide. This guide contains the essential rules and conventions
|
|
43
|
+
that **MUST** be followed for any task involving the creation, analysis, or modification of Angular code.
|
|
44
|
+
</Purpose>
|
|
45
|
+
<Use Cases>
|
|
46
|
+
* As a mandatory first step before writing or modifying any Angular code to ensure adherence to modern standards.
|
|
47
|
+
* To learn about key concepts like standalone components, typed forms, and modern control flow syntax (@if, @for, @switch).
|
|
48
|
+
* To verify that existing code aligns with current Angular conventions before making changes.
|
|
49
|
+
</Use Cases>
|
|
50
|
+
<Operational Notes>
|
|
51
|
+
* **Project-Specific Use (Recommended):** For tasks inside a user's project, you **MUST** provide the
|
|
52
|
+
\`workspacePath\` argument to get the guide that matches the project's Angular version. Get this
|
|
53
|
+
path from \`list_projects\`.
|
|
54
|
+
* **General Use:** If no project context is available (e.g., for general questions or learning),
|
|
55
|
+
you can call the tool without the \`workspacePath\` argument. It will return the latest
|
|
56
|
+
generic best practices guide.
|
|
57
|
+
* The content of this guide is non-negotiable and reflects the official, up-to-date standards for Angular development.
|
|
58
|
+
* You **MUST** internalize and apply the principles from this guide in all subsequent Angular-related tasks.
|
|
59
|
+
* Failure to adhere to these best practices will result in suboptimal and outdated code.
|
|
60
|
+
</Operational Notes>`,
|
|
61
|
+
inputSchema: bestPracticesInputSchema.shape,
|
|
25
62
|
isReadOnly: true,
|
|
26
63
|
isLocalOnly: true,
|
|
27
|
-
factory:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
factory: createBestPracticesHandler,
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the content of the generic best practices guide that is bundled with the CLI.
|
|
68
|
+
* This serves as a fallback when a version-specific guide cannot be found.
|
|
69
|
+
* @returns A promise that resolves to the string content of the bundled markdown file.
|
|
70
|
+
*/
|
|
71
|
+
async function getBundledBestPractices() {
|
|
72
|
+
return (0, promises_1.readFile)(node_path_1.default.join(__dirname, '..', 'resources', 'best-practices.md'), 'utf-8');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Attempts to find and read a version-specific best practices guide from the user's installed
|
|
76
|
+
* version of `@angular/core`. It looks for a custom `angular` metadata property in the
|
|
77
|
+
* framework's `package.json` to locate the guide.
|
|
78
|
+
*
|
|
79
|
+
* @example A sample `package.json` `angular` field:
|
|
80
|
+
* ```json
|
|
81
|
+
* {
|
|
82
|
+
* "angular": {
|
|
83
|
+
* "bestPractices": {
|
|
84
|
+
* "format": "markdown",
|
|
85
|
+
* "path": "./resources/best-practices.md"
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param workspacePath The absolute path to the user's `angular.json` file.
|
|
92
|
+
* @param logger The MCP tool context logger for reporting warnings.
|
|
93
|
+
* @returns A promise that resolves to an object containing the guide's content and source,
|
|
94
|
+
* or `undefined` if the guide could not be resolved.
|
|
95
|
+
*/
|
|
96
|
+
async function getVersionSpecificBestPractices(workspacePath, logger) {
|
|
97
|
+
// 1. Resolve the path to package.json
|
|
98
|
+
let pkgJsonPath;
|
|
99
|
+
try {
|
|
100
|
+
const workspaceRequire = (0, node_module_1.createRequire)(workspacePath);
|
|
101
|
+
pkgJsonPath = workspaceRequire.resolve('@angular/core/package.json');
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
logger.warn(`Could not resolve '@angular/core/package.json' from '${workspacePath}'. ` +
|
|
105
|
+
'Is Angular installed in this project? Falling back to the bundled guide.');
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
// 2. Read and parse package.json, then find and read the guide.
|
|
109
|
+
try {
|
|
110
|
+
const pkgJsonContent = await (0, promises_1.readFile)(pkgJsonPath, 'utf-8');
|
|
111
|
+
const pkgJson = JSON.parse(pkgJsonContent);
|
|
112
|
+
const bestPracticesInfo = pkgJson['angular']?.bestPractices;
|
|
113
|
+
if (bestPracticesInfo &&
|
|
114
|
+
bestPracticesInfo.format === 'markdown' &&
|
|
115
|
+
typeof bestPracticesInfo.path === 'string') {
|
|
116
|
+
const packageDirectory = node_path_1.default.dirname(pkgJsonPath);
|
|
117
|
+
const guidePath = node_path_1.default.resolve(packageDirectory, bestPracticesInfo.path);
|
|
118
|
+
// Ensure the resolved guide path is within the package boundary.
|
|
119
|
+
// Uses path.relative to create a cross-platform, case-insensitive check.
|
|
120
|
+
// If the relative path starts with '..' or is absolute, it is a traversal attempt.
|
|
121
|
+
const relativePath = node_path_1.default.relative(packageDirectory, guidePath);
|
|
122
|
+
if (relativePath.startsWith('..') || node_path_1.default.isAbsolute(relativePath)) {
|
|
123
|
+
logger.warn(`Detected a potential path traversal attempt in '${pkgJsonPath}'. ` +
|
|
124
|
+
`The path '${bestPracticesInfo.path}' escapes the package boundary. ` +
|
|
125
|
+
'Falling back to the bundled guide.');
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// Check the file size to prevent reading a very large file.
|
|
129
|
+
const stats = await (0, promises_1.stat)(guidePath);
|
|
130
|
+
if (stats.size > 1024 * 1024) {
|
|
131
|
+
// 1MB
|
|
132
|
+
logger.warn(`The best practices guide at '${guidePath}' is larger than 1MB (${stats.size} bytes). ` +
|
|
133
|
+
'This is unexpected and the file will not be read. Falling back to the bundled guide.');
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const content = await (0, promises_1.readFile)(guidePath, 'utf-8');
|
|
137
|
+
const source = `framework version ${pkgJson.version}`;
|
|
138
|
+
return { content, source };
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
logger.warn(`Did not find valid 'angular.bestPractices' metadata in '${pkgJsonPath}'. ` +
|
|
142
|
+
'Falling back to the bundled guide.');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
logger.warn(`Failed to read or parse version-specific best practices referenced in '${pkgJsonPath}': ${e instanceof Error ? e.message : e}. Falling back to the bundled guide.`);
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Creates the handler function for the `get_best_practices` tool.
|
|
152
|
+
* The handler orchestrates the process of first attempting to get a version-specific guide
|
|
153
|
+
* and then falling back to the bundled guide if necessary.
|
|
154
|
+
* @param context The MCP tool context, containing the logger.
|
|
155
|
+
* @returns An async function that serves as the tool's executor.
|
|
156
|
+
*/
|
|
157
|
+
function createBestPracticesHandler({ logger }) {
|
|
158
|
+
let bundledBestPractices;
|
|
159
|
+
return async (input) => {
|
|
160
|
+
let content;
|
|
161
|
+
let source;
|
|
162
|
+
// First, try to get the version-specific guide.
|
|
163
|
+
if (input.workspacePath) {
|
|
164
|
+
const versionSpecific = await getVersionSpecificBestPractices(input.workspacePath, logger);
|
|
165
|
+
if (versionSpecific) {
|
|
166
|
+
content = versionSpecific.content;
|
|
167
|
+
source = versionSpecific.source;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// If the version-specific guide was not found for any reason, fall back to the bundled version.
|
|
171
|
+
if (content === undefined) {
|
|
172
|
+
content = await (bundledBestPractices ??= getBundledBestPractices());
|
|
173
|
+
source = `bundled (CLI v${version_1.VERSION.full})`;
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
content: [
|
|
177
|
+
{
|
|
178
|
+
type: 'text',
|
|
179
|
+
text: content,
|
|
180
|
+
annotations: {
|
|
181
|
+
audience: ['assistant'],
|
|
182
|
+
priority: 0.9,
|
|
183
|
+
source,
|
|
40
184
|
},
|
|
41
|
-
|
|
42
|
-
|
|
185
|
+
},
|
|
186
|
+
],
|
|
43
187
|
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=best-practices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"best-practices.js","sourceRoot":"","sources":["best-practices.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH;;;;;;;GAOG;AAEH,+CAAkD;AAClD,6CAA4C;AAC5C,0DAA6B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CAAC,WAAW,CAAC;wBACvB,QAAQ,EAAE,GAAG;wBACb,MAAM;qBACP;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -9,4 +9,23 @@ import { z } from 'zod';
|
|
|
9
9
|
export declare const DOC_SEARCH_TOOL: import("./tool-registry").McpToolDeclaration<{
|
|
10
10
|
query: z.ZodString;
|
|
11
11
|
includeTopContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
12
|
-
|
|
12
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, {
|
|
14
|
+
searchedVersion: z.ZodNumber;
|
|
15
|
+
results: z.ZodArray<z.ZodObject<{
|
|
16
|
+
title: z.ZodString;
|
|
17
|
+
breadcrumb: z.ZodString;
|
|
18
|
+
url: z.ZodString;
|
|
19
|
+
content: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
title: string;
|
|
22
|
+
breadcrumb: string;
|
|
23
|
+
url: string;
|
|
24
|
+
content?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
title: string;
|
|
27
|
+
breadcrumb: string;
|
|
28
|
+
url: string;
|
|
29
|
+
content?: string | undefined;
|
|
30
|
+
}>, "many">;
|
|
31
|
+
}>;
|