@angular/cli 21.0.0 → 21.1.0-next.0
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/code-examples.db +0 -0
- package/lib/config/schema.json +9 -0
- package/lib/config/workspace-schema.d.ts +4 -0
- package/lib/config/workspace-schema.js.map +1 -1
- package/package.json +20 -20
- package/src/command-builder/architect-base-command-module.js +5 -8
- package/src/command-builder/architect-base-command-module.js.map +1 -1
- package/src/command-builder/command-module.d.ts +1 -1
- package/src/command-builder/command-module.js.map +1 -1
- package/src/command-builder/utilities/json-schema.js +1 -1
- package/src/command-builder/utilities/json-schema.js.map +1 -1
- package/src/commands/add/cli.js +3 -1
- package/src/commands/add/cli.js.map +1 -1
- package/src/commands/mcp/cli.d.ts +2 -2
- package/src/commands/mcp/cli.js.map +1 -1
- package/src/commands/mcp/dev-server.d.ts +71 -0
- package/src/commands/mcp/dev-server.js +96 -0
- package/src/commands/mcp/dev-server.js.map +1 -0
- package/src/commands/mcp/host.d.ts +20 -5
- package/src/commands/mcp/host.js +44 -13
- package/src/commands/mcp/host.js.map +1 -1
- package/src/commands/mcp/mcp-server.d.ts +26 -4
- package/src/commands/mcp/mcp-server.js +12 -6
- package/src/commands/mcp/mcp-server.js.map +1 -1
- package/src/commands/mcp/resources/best-practices.md +12 -4
- package/src/commands/mcp/resources/instructions.d.ts +1 -1
- package/src/commands/mcp/resources/instructions.js +2 -5
- package/src/commands/mcp/resources/instructions.js.map +1 -1
- package/src/commands/mcp/tools/ai-tutor.js +2 -5
- package/src/commands/mcp/tools/ai-tutor.js.map +1 -1
- package/src/commands/mcp/tools/best-practices.js +6 -9
- package/src/commands/mcp/tools/best-practices.js.map +1 -1
- package/src/commands/mcp/tools/build.d.ts +48 -0
- package/src/commands/mcp/tools/build.js +97 -0
- package/src/commands/mcp/tools/build.js.map +1 -0
- package/src/commands/mcp/tools/devserver/start-devserver.d.ts +41 -0
- package/src/commands/mcp/tools/devserver/start-devserver.js +82 -0
- package/src/commands/mcp/tools/devserver/start-devserver.js.map +1 -0
- package/src/commands/mcp/tools/devserver/stop-devserver.d.ts +49 -0
- package/src/commands/mcp/tools/devserver/stop-devserver.js +66 -0
- package/src/commands/mcp/tools/devserver/stop-devserver.js.map +1 -0
- package/src/commands/mcp/tools/devserver/wait-for-devserver-build.d.ts +47 -0
- package/src/commands/mcp/tools/devserver/wait-for-devserver-build.js +100 -0
- package/src/commands/mcp/tools/devserver/wait-for-devserver-build.js.map +1 -0
- package/src/commands/mcp/tools/doc-search.js.map +1 -1
- package/src/commands/mcp/tools/examples.js +6 -9
- package/src/commands/mcp/tools/examples.js.map +1 -1
- package/src/commands/mcp/tools/modernize.d.ts +15 -11
- package/src/commands/mcp/tools/modernize.js +13 -45
- package/src/commands/mcp/tools/modernize.js.map +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/{analyze_for_unsupported_zone_uses.d.ts → analyze-for-unsupported-zone-uses.d.ts} +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/{analyze_for_unsupported_zone_uses.js → analyze-for-unsupported-zone-uses.js} +2 -2
- package/src/commands/mcp/tools/onpush-zoneless-migration/{analyze_for_unsupported_zone_uses.js.map → analyze-for-unsupported-zone-uses.js.map} +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/{migrate_single_file.d.ts → migrate-single-file.d.ts} +3 -3
- package/src/commands/mcp/tools/onpush-zoneless-migration/{migrate_single_file.js → migrate-single-file.js} +5 -5
- package/src/commands/mcp/tools/onpush-zoneless-migration/{migrate_single_file.js.map → migrate-single-file.js.map} +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/{migrate_test_file.js → migrate-test-file.js} +6 -52
- 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 +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +2 -2
- package/src/commands/mcp/tools/onpush-zoneless-migration/{send_debug_message.d.ts → send-debug-message.d.ts} +2 -2
- package/src/commands/mcp/tools/onpush-zoneless-migration/{send_debug_message.js → send-debug-message.js} +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/{send_debug_message.js.map → send-debug-message.js.map} +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/{ts_utils.d.ts → ts-utils.d.ts} +3 -4
- package/src/commands/mcp/tools/onpush-zoneless-migration/{ts_utils.js → ts-utils.js} +3 -3
- package/src/commands/mcp/tools/onpush-zoneless-migration/{ts_utils.js.map → ts-utils.js.map} +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +2 -2
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +68 -72
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -1
- package/src/commands/mcp/tools/projects.d.ts +1 -1
- package/src/commands/mcp/tools/projects.js +33 -33
- package/src/commands/mcp/tools/projects.js.map +1 -1
- package/src/commands/mcp/tools/tool-registry.d.ts +3 -1
- package/src/commands/mcp/tools/tool-registry.js.map +1 -1
- package/src/commands/mcp/utils.d.ts +33 -0
- package/src/commands/mcp/utils.js +55 -0
- package/src/commands/mcp/utils.js.map +1 -0
- package/src/utilities/package-manager.d.ts +1 -1
- package/src/utilities/package-manager.js +5 -2
- package/src/utilities/package-manager.js.map +1 -1
- package/src/utilities/version.js +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.js.map +0 -1
- package/src/package-managers/testing/mock-host.d.ts +0 -26
- package/src/package-managers/testing/mock-host.js +0 -53
- package/src/package-managers/testing/mock-host.js.map +0 -1
- /package/src/commands/mcp/tools/onpush-zoneless-migration/{migrate_test_file.d.ts → migrate-test-file.d.ts} +0 -0
package/src/commands/mcp/host.js
CHANGED
|
@@ -17,17 +17,16 @@ exports.LocalWorkspaceHost = exports.CommandError = void 0;
|
|
|
17
17
|
const fs_1 = require("fs");
|
|
18
18
|
const node_child_process_1 = require("node:child_process");
|
|
19
19
|
const promises_1 = require("node:fs/promises");
|
|
20
|
+
const node_net_1 = require("node:net");
|
|
20
21
|
/**
|
|
21
22
|
* An error thrown when a command fails to execute.
|
|
22
23
|
*/
|
|
23
24
|
class CommandError extends Error {
|
|
24
|
-
|
|
25
|
-
stderr;
|
|
25
|
+
logs;
|
|
26
26
|
code;
|
|
27
|
-
constructor(message,
|
|
27
|
+
constructor(message, logs, code) {
|
|
28
28
|
super(message);
|
|
29
|
-
this.
|
|
30
|
-
this.stderr = stderr;
|
|
29
|
+
this.logs = logs;
|
|
31
30
|
this.code = code;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -51,27 +50,59 @@ exports.LocalWorkspaceHost = {
|
|
|
51
50
|
...options.env,
|
|
52
51
|
},
|
|
53
52
|
});
|
|
54
|
-
|
|
55
|
-
childProcess.stdout?.on('data', (data) => (
|
|
56
|
-
|
|
57
|
-
childProcess.stderr?.on('data', (data) => (stderr += data.toString()));
|
|
53
|
+
const logs = [];
|
|
54
|
+
childProcess.stdout?.on('data', (data) => logs.push(data.toString()));
|
|
55
|
+
childProcess.stderr?.on('data', (data) => logs.push(data.toString()));
|
|
58
56
|
childProcess.on('close', (code) => {
|
|
59
57
|
if (code === 0) {
|
|
60
|
-
resolve({
|
|
58
|
+
resolve({ logs });
|
|
61
59
|
}
|
|
62
60
|
else {
|
|
63
61
|
const message = `Process exited with code ${code}.`;
|
|
64
|
-
reject(new CommandError(message,
|
|
62
|
+
reject(new CommandError(message, logs, code));
|
|
65
63
|
}
|
|
66
64
|
});
|
|
67
65
|
childProcess.on('error', (err) => {
|
|
68
66
|
if (err.name === 'AbortError') {
|
|
69
67
|
const message = `Process timed out.`;
|
|
70
|
-
reject(new CommandError(message,
|
|
68
|
+
reject(new CommandError(message, logs, null));
|
|
71
69
|
return;
|
|
72
70
|
}
|
|
73
71
|
const message = `Process failed with error: ${err.message}`;
|
|
74
|
-
reject(new CommandError(message,
|
|
72
|
+
reject(new CommandError(message, logs, null));
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
spawn(command, args, options = {}) {
|
|
77
|
+
return (0, node_child_process_1.spawn)(command, args, {
|
|
78
|
+
shell: false,
|
|
79
|
+
stdio: options.stdio ?? 'pipe',
|
|
80
|
+
cwd: options.cwd,
|
|
81
|
+
env: {
|
|
82
|
+
...process.env,
|
|
83
|
+
...options.env,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
getAvailablePort() {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
// Create a new temporary server from Node's net library.
|
|
90
|
+
const server = (0, node_net_1.createServer)();
|
|
91
|
+
server.once('error', (err) => {
|
|
92
|
+
reject(err);
|
|
93
|
+
});
|
|
94
|
+
// Listen on port 0 to let the OS assign an available port.
|
|
95
|
+
server.listen(0, () => {
|
|
96
|
+
const address = server.address();
|
|
97
|
+
// Ensure address is an object with a port property.
|
|
98
|
+
if (address && typeof address === 'object') {
|
|
99
|
+
const port = address.port;
|
|
100
|
+
server.close();
|
|
101
|
+
resolve(port);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
reject(new Error('Unable to retrieve address information from server.'));
|
|
105
|
+
}
|
|
75
106
|
});
|
|
76
107
|
});
|
|
77
108
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;GAKG;AAEH,2BAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;GAKG;AAEH,2BAAkD;AAClD,2DAAyD;AAEzD,+CAAwC;AACxC,uCAAwC;AAExC;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;IAGnB;IACA;IAHlB,YACE,OAAe,EACC,IAAc,EACd,IAAmB;QAEnC,K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CAAC,OAAO,EAAE,CAAC,GAAY,EAAE,EAAE;gBACpC,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,2DAA2D;YAC3D,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE;gBACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;gBAEjC,oDAAoD;gBACpD,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;oBAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;oBAE1B,MAAM,CAAC,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC,CAAC;gBAC3E,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -7,19 +7,41 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
9
|
import type { AngularWorkspace } from '../../utilities/config';
|
|
10
|
-
import { AnyMcpToolDeclaration } from './tools/tool-registry';
|
|
10
|
+
import { type AnyMcpToolDeclaration } from './tools/tool-registry';
|
|
11
11
|
/**
|
|
12
12
|
* The set of tools that are available but not enabled by default.
|
|
13
13
|
* These tools are considered experimental and may have limitations.
|
|
14
14
|
*/
|
|
15
15
|
export declare const EXPERIMENTAL_TOOLS: readonly [import("./tools/tool-registry").McpToolDeclaration<{
|
|
16
|
+
project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
configuration: import("zod").ZodOptional<import("zod").ZodString>;
|
|
18
|
+
}, {
|
|
19
|
+
status: import("zod").ZodEnum<["success", "failure"]>;
|
|
20
|
+
logs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
21
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
22
|
+
}>, import("./tools/tool-registry").McpToolDeclaration<{
|
|
16
23
|
directories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
17
24
|
transformations: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<[string, ...string[]]>, "many">>;
|
|
18
25
|
}, {
|
|
19
26
|
instructions: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
logs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
28
|
+
}>, ...(import("./tools/tool-registry").McpToolDeclaration<{
|
|
29
|
+
project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
30
|
+
}, {
|
|
31
|
+
message: import("zod").ZodString;
|
|
32
|
+
address: import("zod").ZodOptional<import("zod").ZodString>;
|
|
33
|
+
}> | import("./tools/tool-registry").McpToolDeclaration<{
|
|
34
|
+
project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
|
+
}, {
|
|
36
|
+
message: import("zod").ZodString;
|
|
37
|
+
logs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
38
|
+
}> | import("./tools/tool-registry").McpToolDeclaration<{
|
|
39
|
+
project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
40
|
+
timeout: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
41
|
+
}, {
|
|
42
|
+
status: import("zod").ZodEnum<["success", "failure", "unknown", "timeout", "no_devserver_found"]>;
|
|
43
|
+
logs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
44
|
+
}>)[]];
|
|
23
45
|
export declare function createMcpServer(options: {
|
|
24
46
|
workspace?: AngularWorkspace;
|
|
25
47
|
readOnly?: boolean;
|
|
@@ -6,25 +6,30 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.EXPERIMENTAL_TOOLS = void 0;
|
|
14
11
|
exports.createMcpServer = createMcpServer;
|
|
15
12
|
exports.assembleToolDeclarations = assembleToolDeclarations;
|
|
16
13
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
17
|
-
const node_path_1 =
|
|
14
|
+
const node_path_1 = require("node:path");
|
|
18
15
|
const version_1 = require("../../utilities/version");
|
|
19
16
|
const instructions_1 = require("./resources/instructions");
|
|
20
17
|
const ai_tutor_1 = require("./tools/ai-tutor");
|
|
21
18
|
const best_practices_1 = require("./tools/best-practices");
|
|
19
|
+
const build_1 = require("./tools/build");
|
|
20
|
+
const start_devserver_1 = require("./tools/devserver/start-devserver");
|
|
21
|
+
const stop_devserver_1 = require("./tools/devserver/stop-devserver");
|
|
22
|
+
const wait_for_devserver_build_1 = require("./tools/devserver/wait-for-devserver-build");
|
|
22
23
|
const doc_search_1 = require("./tools/doc-search");
|
|
23
24
|
const examples_1 = require("./tools/examples");
|
|
24
25
|
const modernize_1 = require("./tools/modernize");
|
|
25
26
|
const zoneless_migration_1 = require("./tools/onpush-zoneless-migration/zoneless-migration");
|
|
26
27
|
const projects_1 = require("./tools/projects");
|
|
27
28
|
const tool_registry_1 = require("./tools/tool-registry");
|
|
29
|
+
/**
|
|
30
|
+
* Tools to manage devservers. Should be bundled together, then added to experimental or stable as a group.
|
|
31
|
+
*/
|
|
32
|
+
const SERVE_TOOLS = [start_devserver_1.START_DEVSERVER_TOOL, stop_devserver_1.STOP_DEVSERVER_TOOL, wait_for_devserver_build_1.WAIT_FOR_DEVSERVER_BUILD_TOOL];
|
|
28
33
|
/**
|
|
29
34
|
* The set of tools that are enabled by default for the MCP server.
|
|
30
35
|
* These tools are considered stable and suitable for general use.
|
|
@@ -41,7 +46,7 @@ const STABLE_TOOLS = [
|
|
|
41
46
|
* The set of tools that are available but not enabled by default.
|
|
42
47
|
* These tools are considered experimental and may have limitations.
|
|
43
48
|
*/
|
|
44
|
-
exports.EXPERIMENTAL_TOOLS = [modernize_1.MODERNIZE_TOOL];
|
|
49
|
+
exports.EXPERIMENTAL_TOOLS = [build_1.BUILD_TOOL, modernize_1.MODERNIZE_TOOL, ...SERVE_TOOLS];
|
|
45
50
|
async function createMcpServer(options, logger) {
|
|
46
51
|
const server = new mcp_js_1.McpServer({
|
|
47
52
|
name: 'angular-cli-server',
|
|
@@ -90,7 +95,8 @@ equivalent actions.
|
|
|
90
95
|
await (0, tool_registry_1.registerTools)(server, {
|
|
91
96
|
workspace: options.workspace,
|
|
92
97
|
logger,
|
|
93
|
-
exampleDatabasePath: node_path_1.
|
|
98
|
+
exampleDatabasePath: (0, node_path_1.join)(__dirname, '../../../lib/code-examples.db'),
|
|
99
|
+
devServers: new Map(),
|
|
94
100
|
}, toolDeclarations);
|
|
95
101
|
return server;
|
|
96
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["mcp-server.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["mcp-server.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA6CH,0CAuEC;AAED,4DAuCC;AA3JD,oEAAoE;AACpE,yCAAiC;AAEjC,qDAAkD;AAElD,2DAAwE;AACxE,+CAAiD;AACjD,2DAA6D;AAC7D,yCAA2C;AAC3C,uEAAyE;AACzE,qEAAuE;AACvE,yFAA2F;AAC3F,mDAAqD;AACrD,+CAAqD;AACrD,iDAAmD;AACnD,6FAA+F;AAC/F,+CAAsD;AACtD,yDAAkF;AAElF;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,sCAAoB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C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpE,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,GAAG,EAAE,CAAC;QAChD,wBAAwB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,wBAAwB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAEhG,KAAK,MAAM,QAAQ,IAAI,wBAAwB,EAAE,CAAC;YAChD,MAAM,IAAI,GAAG,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChD,IAAI,IAAI,EAAE,CAAC;gBACT,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
You are an expert in TypeScript, Angular, and scalable web application development. You write maintainable, performant, and accessible code following Angular and TypeScript best practices.
|
|
1
|
+
You are an expert in TypeScript, Angular, and scalable web application development. You write functional, maintainable, performant, and accessible code following Angular and TypeScript best practices.
|
|
2
2
|
|
|
3
3
|
## TypeScript Best Practices
|
|
4
4
|
|
|
@@ -9,14 +9,19 @@ You are an expert in TypeScript, Angular, and scalable web application developme
|
|
|
9
9
|
## Angular Best Practices
|
|
10
10
|
|
|
11
11
|
- Always use standalone components over NgModules
|
|
12
|
-
- Must NOT set `standalone: true` inside Angular decorators. It's the default
|
|
12
|
+
- Must NOT set `standalone: true` inside Angular decorators. It's the default in Angular v20+.
|
|
13
13
|
- Use signals for state management
|
|
14
14
|
- Implement lazy loading for feature routes
|
|
15
15
|
- Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
|
|
16
16
|
- Use `NgOptimizedImage` for all static images.
|
|
17
17
|
- `NgOptimizedImage` does not work for inline base64 images.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Accessibility Requirements
|
|
20
|
+
|
|
21
|
+
- It MUST pass all AXE checks.
|
|
22
|
+
- It MUST follow all WCAG AA minimums, including focus management, color contrast, and ARIA attributes.
|
|
23
|
+
|
|
24
|
+
### Components
|
|
20
25
|
|
|
21
26
|
- Keep components small and focused on a single responsibility
|
|
22
27
|
- Use `input()` and `output()` functions instead of decorators
|
|
@@ -25,7 +30,8 @@ You are an expert in TypeScript, Angular, and scalable web application developme
|
|
|
25
30
|
- Prefer inline templates for small components
|
|
26
31
|
- Prefer Reactive forms instead of Template-driven ones
|
|
27
32
|
- Do NOT use `ngClass`, use `class` bindings instead
|
|
28
|
-
-
|
|
33
|
+
- Do NOT use `ngStyle`, use `style` bindings instead
|
|
34
|
+
- When using external templates/styles, use paths relative to the component TS file.
|
|
29
35
|
|
|
30
36
|
## State Management
|
|
31
37
|
|
|
@@ -39,6 +45,8 @@ You are an expert in TypeScript, Angular, and scalable web application developme
|
|
|
39
45
|
- Keep templates simple and avoid complex logic
|
|
40
46
|
- Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
|
|
41
47
|
- Use the async pipe to handle observables
|
|
48
|
+
- Do not assume globals like (`new Date()`) are available.
|
|
49
|
+
- Do not write arrow functions in templates (they are not supported).
|
|
42
50
|
|
|
43
51
|
## Services
|
|
44
52
|
|
|
@@ -5,5 +5,5 @@
|
|
|
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
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
9
|
export declare function registerInstructionsResource(server: McpServer): void;
|
|
@@ -6,13 +6,10 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.registerInstructionsResource = registerInstructionsResource;
|
|
14
11
|
const promises_1 = require("node:fs/promises");
|
|
15
|
-
const node_path_1 =
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
16
13
|
function registerInstructionsResource(server) {
|
|
17
14
|
server.registerResource('instructions', 'instructions://best-practices', {
|
|
18
15
|
title: 'Angular Best Practices and Code Generation Guide',
|
|
@@ -22,7 +19,7 @@ function registerInstructionsResource(server) {
|
|
|
22
19
|
' typed forms, modern control flow syntax, and other current conventions.',
|
|
23
20
|
mimeType: 'text/markdown',
|
|
24
21
|
}, async () => {
|
|
25
|
-
const text = await (0, promises_1.readFile)(node_path_1.
|
|
22
|
+
const text = await (0, promises_1.readFile)((0, node_path_1.join)(__dirname, 'best-practices.md'), 'utf-8');
|
|
26
23
|
return { contents: [{ uri: 'instructions://best-practices', text }] };
|
|
27
24
|
});
|
|
28
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["instructions.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["instructions.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAMH,oEAmBC;AAtBD,+CAA4C;AAC5C,yCAAiC;AAEjC,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,IAAA,gBAAI,EAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,OAAO,CAAC,CAAC;QAE3E,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,+BAA+B,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACxE,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -6,13 +6,10 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.AI_TUTOR_TOOL = void 0;
|
|
14
11
|
const promises_1 = require("node:fs/promises");
|
|
15
|
-
const node_path_1 =
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
16
13
|
const tool_registry_1 = require("./tool-registry");
|
|
17
14
|
exports.AI_TUTOR_TOOL = (0, tool_registry_1.declareTool)({
|
|
18
15
|
name: 'ai_tutor',
|
|
@@ -43,7 +40,7 @@ with a new core identity and knowledge base.
|
|
|
43
40
|
factory: () => {
|
|
44
41
|
let aiTutorText;
|
|
45
42
|
return async () => {
|
|
46
|
-
aiTutorText ??= await (0, promises_1.readFile)(node_path_1.
|
|
43
|
+
aiTutorText ??= await (0, promises_1.readFile)((0, node_path_1.join)(__dirname, '../resources/ai-tutor.md'), 'utf-8');
|
|
47
44
|
return {
|
|
48
45
|
content: [
|
|
49
46
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-tutor.js","sourceRoot":"","sources":["ai-tutor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"ai-tutor.js","sourceRoot":"","sources":["ai-tutor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAA4C;AAC5C,yCAAiC;AACjC,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,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,0BAA0B,CAAC,EAAE,OAAO,CAAC,CAAC;YAErF,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"}
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.BEST_PRACTICES_TOOL = void 0;
|
|
14
11
|
/**
|
|
@@ -21,7 +18,7 @@ exports.BEST_PRACTICES_TOOL = void 0;
|
|
|
21
18
|
*/
|
|
22
19
|
const promises_1 = require("node:fs/promises");
|
|
23
20
|
const node_module_1 = require("node:module");
|
|
24
|
-
const node_path_1 =
|
|
21
|
+
const node_path_1 = require("node:path");
|
|
25
22
|
const zod_1 = require("zod");
|
|
26
23
|
const version_1 = require("../../../utilities/version");
|
|
27
24
|
const tool_registry_1 = require("./tool-registry");
|
|
@@ -69,7 +66,7 @@ that **MUST** be followed for any task involving the creation, analysis, or modi
|
|
|
69
66
|
* @returns A promise that resolves to the string content of the bundled markdown file.
|
|
70
67
|
*/
|
|
71
68
|
async function getBundledBestPractices() {
|
|
72
|
-
return (0, promises_1.readFile)(node_path_1.
|
|
69
|
+
return (0, promises_1.readFile)((0, node_path_1.join)(__dirname, '../resources/best-practices.md'), 'utf-8');
|
|
73
70
|
}
|
|
74
71
|
/**
|
|
75
72
|
* Attempts to find and read a version-specific best practices guide from the user's installed
|
|
@@ -113,13 +110,13 @@ async function getVersionSpecificBestPractices(workspacePath, logger) {
|
|
|
113
110
|
if (bestPracticesInfo &&
|
|
114
111
|
bestPracticesInfo.format === 'markdown' &&
|
|
115
112
|
typeof bestPracticesInfo.path === 'string') {
|
|
116
|
-
const packageDirectory = node_path_1.
|
|
117
|
-
const guidePath = node_path_1.
|
|
113
|
+
const packageDirectory = (0, node_path_1.dirname)(pkgJsonPath);
|
|
114
|
+
const guidePath = (0, node_path_1.resolve)(packageDirectory, bestPracticesInfo.path);
|
|
118
115
|
// Ensure the resolved guide path is within the package boundary.
|
|
119
116
|
// Uses path.relative to create a cross-platform, case-insensitive check.
|
|
120
117
|
// If the relative path starts with '..' or is absolute, it is a traversal attempt.
|
|
121
|
-
const relativePath = node_path_1.
|
|
122
|
-
if (relativePath.startsWith('..') || node_path_1.
|
|
118
|
+
const relativePath = (0, node_path_1.relative)(packageDirectory, guidePath);
|
|
119
|
+
if (relativePath.startsWith('..') || (0, node_path_1.isAbsolute)(relativePath)) {
|
|
123
120
|
logger.warn(`Detected a potential path traversal attempt in '${pkgJsonPath}'. ` +
|
|
124
121
|
`The path '${bestPracticesInfo.path}' escapes the package boundary. ` +
|
|
125
122
|
'Falling back to the bundled guide.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"best-practices.js","sourceRoot":"","sources":["best-practices.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"best-practices.js","sourceRoot":"","sources":["best-practices.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;;;GAOG;AAEH,+CAAkD;AAClD,6CAA4C;AAC5C,yCAAyE;AACzE,6BAAwB;AACxB,wDAAqD;AACrD,mDAAmE;AAEnE,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,aAAa,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,2FAA2F;QACzF,yFAAyF;QACzF,2FAA2F;QAC3F,6EAA6E,CAChF;CACJ,CAAC,CAAC;AAIU,QAAA,mBAAmB,GAAG,IAAA,2BAAW,EAAC;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,yCAAyC;IAChD,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;qBAoBM;IACnB,WAAW,EAAE,wBAAwB,CAAC,KAAK;IAC3C,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,0BAA0B;CACpC,CAAC,CAAC;AAEH;;;;GA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B,CAAC;QAChC,IAAI,MAA0B,CAAC;QAE/B,gDAAgD;QAChD,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,eAAe,GAAG,MAAM,+BAA+B,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAC3F,IAAI,eAAe,EAAE,CAAC;gBACpB,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;gBAClC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;YAClC,CAAC;QACH,CAAC;QAED,gGAAgG;QAChG,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,MAAM,CAAC,oBAAoB,KAAK,uBAAuB,EAAE,CAAC,CAAC;YACrE,MAAM,GAAG,iBAAiB,iBAAO,CAAC,IAAI,GAAG,CAAC;QAC5C,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE;wBACX,QAAQ,EAAE,CAAC,WAAW,CAAC;wBACvB,QAAQ,EAAE,GAAG;wBACb,MAAM;qBACP;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 McpToolDeclaration } from './tool-registry';
|
|
11
|
+
declare const buildToolInputSchema: z.ZodObject<{
|
|
12
|
+
project: z.ZodOptional<z.ZodString>;
|
|
13
|
+
configuration: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
project?: string | undefined;
|
|
16
|
+
configuration?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
project?: string | undefined;
|
|
19
|
+
configuration?: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type BuildToolInput = z.infer<typeof buildToolInputSchema>;
|
|
22
|
+
declare const buildToolOutputSchema: z.ZodObject<{
|
|
23
|
+
status: z.ZodEnum<["success", "failure"]>;
|
|
24
|
+
logs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
|
+
path: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
status: "success" | "failure";
|
|
28
|
+
path?: string | undefined;
|
|
29
|
+
logs?: string[] | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
status: "success" | "failure";
|
|
32
|
+
path?: string | undefined;
|
|
33
|
+
logs?: string[] | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export type BuildToolOutput = z.infer<typeof buildToolOutputSchema>;
|
|
36
|
+
export declare function runBuild(input: BuildToolInput, host: Host): Promise<{
|
|
37
|
+
content: {
|
|
38
|
+
type: "text";
|
|
39
|
+
text: string;
|
|
40
|
+
}[];
|
|
41
|
+
structuredContent: {
|
|
42
|
+
status: "success" | "failure";
|
|
43
|
+
path?: string | undefined;
|
|
44
|
+
logs?: string[] | undefined;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
export declare const BUILD_TOOL: McpToolDeclaration<typeof buildToolInputSchema.shape, typeof buildToolOutputSchema.shape>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
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.BUILD_TOOL = void 0;
|
|
11
|
+
exports.runBuild = runBuild;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const host_1 = require("../host");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const tool_registry_1 = require("./tool-registry");
|
|
16
|
+
const DEFAULT_CONFIGURATION = 'development';
|
|
17
|
+
const buildStatusSchema = zod_1.z.enum(['success', 'failure']);
|
|
18
|
+
const buildToolInputSchema = zod_1.z.object({
|
|
19
|
+
project: zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Which project to build in a monorepo context. If not provided, builds the default project.'),
|
|
23
|
+
configuration: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Which build configuration to use. Defaults to "development".'),
|
|
27
|
+
});
|
|
28
|
+
const buildToolOutputSchema = zod_1.z.object({
|
|
29
|
+
status: buildStatusSchema.describe('Build status.'),
|
|
30
|
+
logs: zod_1.z.array(zod_1.z.string()).optional().describe('Output logs from `ng build`.'),
|
|
31
|
+
path: zod_1.z.string().optional().describe('The output location for the build, if successful.'),
|
|
32
|
+
});
|
|
33
|
+
async function runBuild(input, host) {
|
|
34
|
+
// Build "ng"'s command line.
|
|
35
|
+
const args = ['build'];
|
|
36
|
+
if (input.project) {
|
|
37
|
+
args.push(input.project);
|
|
38
|
+
}
|
|
39
|
+
args.push('-c', input.configuration ?? DEFAULT_CONFIGURATION);
|
|
40
|
+
let status = 'success';
|
|
41
|
+
let logs = [];
|
|
42
|
+
let outputPath;
|
|
43
|
+
try {
|
|
44
|
+
logs = (await host.runCommand('ng', args)).logs;
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
status = 'failure';
|
|
48
|
+
if (e instanceof host_1.CommandError) {
|
|
49
|
+
logs = e.logs;
|
|
50
|
+
}
|
|
51
|
+
else if (e instanceof Error) {
|
|
52
|
+
logs = [e.message];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
logs = [String(e)];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const line of logs) {
|
|
59
|
+
const match = line.match(/Output location: (.*)/);
|
|
60
|
+
if (match) {
|
|
61
|
+
outputPath = match[1].trim();
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const structuredContent = {
|
|
66
|
+
status,
|
|
67
|
+
logs,
|
|
68
|
+
path: outputPath,
|
|
69
|
+
};
|
|
70
|
+
return (0, utils_1.createStructuredContentOutput)(structuredContent);
|
|
71
|
+
}
|
|
72
|
+
exports.BUILD_TOOL = (0, tool_registry_1.declareTool)({
|
|
73
|
+
name: 'build',
|
|
74
|
+
title: 'Build Tool',
|
|
75
|
+
description: `
|
|
76
|
+
<Purpose>
|
|
77
|
+
Perform a one-off, non-watched build using "ng build". Use this tool whenever the user wants to build an Angular project; this is similar to
|
|
78
|
+
"ng build", but the tool is smarter about using the right configuration and collecting the output logs.
|
|
79
|
+
</Purpose>
|
|
80
|
+
<Use Cases>
|
|
81
|
+
* Building an Angular project and getting build logs back.
|
|
82
|
+
</Use Cases>
|
|
83
|
+
<Operational Notes>
|
|
84
|
+
* This tool runs "ng build" so it expects to run within an Angular workspace.
|
|
85
|
+
* If you want a watched build which updates as files are changed, use "start_devserver" instead, which also serves the app.
|
|
86
|
+
* You can provide a project instead of building the root one. The "list_projects" MCP tool could be used to obtain the list of projects.
|
|
87
|
+
* This tool defaults to a development environment while a regular "ng build" defaults to a production environment. An unexpected build
|
|
88
|
+
failure might suggest the project is not configured for the requested environment.
|
|
89
|
+
</Operational Notes>
|
|
90
|
+
`,
|
|
91
|
+
isReadOnly: false,
|
|
92
|
+
isLocalOnly: true,
|
|
93
|
+
inputSchema: buildToolInputSchema.shape,
|
|
94
|
+
outputSchema: buildToolOutputSchema.shape,
|
|
95
|
+
factory: () => (input) => runBuild(input, host_1.LocalWorkspaceHost),
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|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O,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,yBAAkB,CAAC;CAC9D,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 startDevServerToolInputSchema: z.ZodObject<{
|
|
12
|
+
project: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
project?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
project?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type StartDevserverToolInput = z.infer<typeof startDevServerToolInputSchema>;
|
|
19
|
+
declare const startDevServerToolOutputSchema: z.ZodObject<{
|
|
20
|
+
message: z.ZodString;
|
|
21
|
+
address: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
message: string;
|
|
24
|
+
address?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
message: string;
|
|
27
|
+
address?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type StartDevserverToolOutput = z.infer<typeof startDevServerToolOutputSchema>;
|
|
30
|
+
export declare function startDevServer(input: StartDevserverToolInput, context: McpToolContext, host: Host): Promise<{
|
|
31
|
+
content: {
|
|
32
|
+
type: "text";
|
|
33
|
+
text: string;
|
|
34
|
+
}[];
|
|
35
|
+
structuredContent: {
|
|
36
|
+
message: string;
|
|
37
|
+
address: string;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
export declare const START_DEVSERVER_TOOL: McpToolDeclaration<typeof startDevServerToolInputSchema.shape, typeof startDevServerToolOutputSchema.shape>;
|
|
41
|
+
export {};
|