@rushstack/mcp-server 0.1.4 → 0.1.5
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/CHANGELOG.json +12 -0
- package/CHANGELOG.md +8 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +23 -0
- package/lib/index.js.map +1 -0
- package/lib/server.d.ts +9 -0
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +35 -0
- package/lib/server.js.map +1 -0
- package/lib/start.d.ts +1 -0
- package/lib/start.js +18 -0
- package/lib/start.js.map +1 -1
- package/lib/tools/base.tool.d.ts +19 -0
- package/lib/tools/base.tool.d.ts.map +1 -0
- package/lib/tools/base.tool.js +33 -0
- package/lib/tools/base.tool.js.map +1 -0
- package/lib/tools/conflict-resolver.tool.d.ts +9 -0
- package/lib/tools/conflict-resolver.tool.d.ts.map +1 -0
- package/lib/tools/conflict-resolver.tool.js +52 -0
- package/lib/tools/conflict-resolver.tool.js.map +1 -0
- package/lib/tools/docs.tool.d.ts +8 -0
- package/lib/tools/docs.tool.d.ts.map +1 -0
- package/lib/tools/docs.tool.js +39 -0
- package/lib/tools/docs.tool.js.map +1 -0
- package/lib/tools/index.d.ts +8 -0
- package/lib/tools/index.d.ts.map +1 -0
- package/lib/tools/index.js +26 -0
- package/lib/tools/index.js.map +1 -0
- package/lib/tools/migrate-project.tool.d.ts +13 -0
- package/lib/tools/migrate-project.tool.d.ts.map +1 -0
- package/lib/tools/migrate-project.tool.js +100 -0
- package/lib/tools/migrate-project.tool.js.map +1 -0
- package/lib/tools/project-details.tool.d.ts +8 -0
- package/lib/tools/project-details.tool.d.ts.map +1 -0
- package/lib/tools/project-details.tool.js +54 -0
- package/lib/tools/project-details.tool.js.map +1 -0
- package/lib/tools/rush-command-validator.tool.d.ts +11 -0
- package/lib/tools/rush-command-validator.tool.d.ts.map +1 -0
- package/lib/tools/rush-command-validator.tool.js +88 -0
- package/lib/tools/rush-command-validator.tool.js.map +1 -0
- package/lib/tools/workspace-details.d.ts +8 -0
- package/lib/tools/workspace-details.d.ts.map +1 -0
- package/lib/tools/workspace-details.js +107 -0
- package/lib/tools/workspace-details.js.map +1 -0
- package/lib/utilities/command-runner.d.ts +21 -0
- package/lib/utilities/command-runner.d.ts.map +1 -0
- package/lib/utilities/command-runner.js +59 -0
- package/lib/utilities/command-runner.js.map +1 -0
- package/lib/utilities/common.d.ts +3 -0
- package/lib/utilities/common.d.ts.map +1 -0
- package/lib/utilities/common.js +47 -0
- package/lib/utilities/common.js.map +1 -0
- package/lib/utilities/log.d.ts +4 -0
- package/lib/utilities/log.d.ts.map +1 -0
- package/lib/utilities/log.js +13 -0
- package/lib/utilities/log.js.map +1 -0
- package/package.json +9 -5
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/mcp-server",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.5",
|
|
6
|
+
"tag": "@rushstack/mcp-server_v0.1.5",
|
|
7
|
+
"date": "Fri, 02 May 2025 15:11:29 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add more tools to mcp server"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.4",
|
|
6
18
|
"tag": "@rushstack/mcp-server_v0.1.4",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @rushstack/mcp-server
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 02 May 2025 15:11:29 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.1.5
|
|
6
|
+
Fri, 02 May 2025 15:11:29 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Add more tools to mcp server
|
|
4
11
|
|
|
5
12
|
## 0.1.4
|
|
6
13
|
Thu, 01 May 2025 15:11:33 GMT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.log = void 0;
|
|
20
|
+
var log_1 = require("./utilities/log");
|
|
21
|
+
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_1.log; } });
|
|
22
|
+
__exportStar(require("./tools"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;AAE3D,uCAAsC;AAA7B,0FAAA,GAAG,OAAA;AACZ,0CAAwB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport { log } from './utilities/log';\nexport * from './tools';\n"]}
|
package/lib/server.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
export declare class RushMCPServer extends McpServer {
|
|
3
|
+
private _rushWorkspacePath;
|
|
4
|
+
private _tools;
|
|
5
|
+
constructor(rushWorkspacePath: string);
|
|
6
|
+
private _initializeTools;
|
|
7
|
+
private _registerTools;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWpE,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,MAAM,CAAkB;gBAEb,iBAAiB,EAAE,MAAM;IAY5C,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,cAAc;CAOvB"}
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.RushMCPServer = void 0;
|
|
6
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
7
|
+
const tools_1 = require("./tools");
|
|
8
|
+
class RushMCPServer extends mcp_js_1.McpServer {
|
|
9
|
+
constructor(rushWorkspacePath) {
|
|
10
|
+
super({
|
|
11
|
+
name: 'rush',
|
|
12
|
+
version: '1.0.0'
|
|
13
|
+
});
|
|
14
|
+
this._tools = [];
|
|
15
|
+
this._rushWorkspacePath = rushWorkspacePath;
|
|
16
|
+
this._initializeTools();
|
|
17
|
+
this._registerTools();
|
|
18
|
+
}
|
|
19
|
+
_initializeTools() {
|
|
20
|
+
this._tools.push(new tools_1.RushConflictResolverTool());
|
|
21
|
+
this._tools.push(new tools_1.RushMigrateProjectTool(this._rushWorkspacePath));
|
|
22
|
+
this._tools.push(new tools_1.RushCommandValidatorTool());
|
|
23
|
+
this._tools.push(new tools_1.RushWorkspaceDetailsTool());
|
|
24
|
+
this._tools.push(new tools_1.RushProjectDetailsTool());
|
|
25
|
+
this._tools.push(new tools_1.RushDocsTool());
|
|
26
|
+
}
|
|
27
|
+
_registerTools() {
|
|
28
|
+
process.chdir(this._rushWorkspacePath);
|
|
29
|
+
for (const tool of this._tools) {
|
|
30
|
+
tool.register(this);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.RushMCPServer = RushMCPServer;
|
|
35
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAoE;AACpE,mCAQiB;AAEjB,MAAa,aAAc,SAAQ,kBAAS;IAI1C,YAAmB,iBAAyB;QAC1C,KAAK,CAAC;YACJ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QANG,WAAM,GAAe,EAAE,CAAC;QAQ9B,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;QAE5C,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gCAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,8BAAsB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gCAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gCAAwB,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,oBAAY,EAAE,CAAC,CAAC;IACvC,CAAC;IAEO,cAAc;QACpB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEvC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF;AAhCD,sCAgCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n type BaseTool,\n RushConflictResolverTool,\n RushMigrateProjectTool,\n RushCommandValidatorTool,\n RushWorkspaceDetailsTool,\n RushProjectDetailsTool,\n RushDocsTool\n} from './tools';\n\nexport class RushMCPServer extends McpServer {\n private _rushWorkspacePath: string;\n private _tools: BaseTool[] = [];\n\n public constructor(rushWorkspacePath: string) {\n super({\n name: 'rush',\n version: '1.0.0'\n });\n\n this._rushWorkspacePath = rushWorkspacePath;\n\n this._initializeTools();\n this._registerTools();\n }\n\n private _initializeTools(): void {\n this._tools.push(new RushConflictResolverTool());\n this._tools.push(new RushMigrateProjectTool(this._rushWorkspacePath));\n this._tools.push(new RushCommandValidatorTool());\n this._tools.push(new RushWorkspaceDetailsTool());\n this._tools.push(new RushProjectDetailsTool());\n this._tools.push(new RushDocsTool());\n }\n\n private _registerTools(): void {\n process.chdir(this._rushWorkspacePath);\n\n for (const tool of this._tools) {\n tool.register(this);\n }\n }\n}\n"]}
|
package/lib/start.d.ts
CHANGED
package/lib/start.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const log_1 = require("./utilities/log");
|
|
7
|
+
const server_1 = require("./server");
|
|
8
|
+
const main = async () => {
|
|
9
|
+
const rushWorkspacePath = process.argv[2];
|
|
10
|
+
if (!rushWorkspacePath) {
|
|
11
|
+
throw new Error('Please provide workspace root path as the first argument');
|
|
12
|
+
}
|
|
13
|
+
const server = new server_1.RushMCPServer(rushWorkspacePath);
|
|
14
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
15
|
+
await server.connect(transport);
|
|
16
|
+
(0, log_1.log)('Rush MCP Server running on stdio');
|
|
17
|
+
};
|
|
18
|
+
main().catch((error) => {
|
|
19
|
+
(0, log_1.log)('Fatal error running server:', error);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
4
22
|
//# sourceMappingURL=start.js.map
|
package/lib/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n"]}
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,wEAAiF;AAEjF,yCAAsC;AACtC,qCAAyC;AAEzC,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IACrC,MAAM,iBAAiB,GAAuB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,MAAM,GAAkB,IAAI,sBAAa,CAAC,iBAAiB,CAAC,CAAC;IACnE,MAAM,SAAS,GAAyB,IAAI,+BAAoB,EAAE,CAAC;IACnE,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,IAAA,SAAG,EAAC,kCAAkC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,IAAA,SAAG,EAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n\nimport { log } from './utilities/log';\nimport { RushMCPServer } from './server';\n\nconst main = async (): Promise<void> => {\n const rushWorkspacePath: string | undefined = process.argv[2];\n if (!rushWorkspacePath) {\n throw new Error('Please provide workspace root path as the first argument');\n }\n\n const server: RushMCPServer = new RushMCPServer(rushWorkspacePath);\n const transport: StdioServerTransport = new StdioServerTransport();\n await server.connect(transport);\n\n log('Rush MCP Server running on stdio');\n};\n\nmain().catch((error) => {\n log('Fatal error running server:', error);\n process.exit(1);\n});\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
2
|
+
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol';
|
|
3
|
+
import type { CallToolResultSchema, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types';
|
|
4
|
+
import type { z, ZodRawShape, ZodTypeAny } from 'zod';
|
|
5
|
+
export type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
|
6
|
+
type ToolCallback<Args extends undefined | ZodRawShape = undefined> = Args extends ZodRawShape ? (args: z.objectOutputType<Args, ZodTypeAny>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult> : (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
|
|
7
|
+
export interface IBaseToolOptions<Args extends ZodRawShape = ZodRawShape> {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
schema: Args;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class BaseTool<Args extends ZodRawShape = ZodRawShape> {
|
|
13
|
+
private _options;
|
|
14
|
+
protected constructor(options: IBaseToolOptions<Args>);
|
|
15
|
+
protected abstract executeAsync(...args: Parameters<ToolCallback<Args>>): ReturnType<ToolCallback<Args>>;
|
|
16
|
+
register(server: McpServer): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=base.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.tool.d.ts","sourceRoot":"","sources":["../../src/tools/base.tool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,KAAK,YAAY,CAAC,IAAI,SAAS,SAAS,GAAG,WAAW,GAAG,SAAS,IAAI,IAAI,SAAS,WAAW,GAC1F,CACE,IAAI,EAAE,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,EAC1C,KAAK,EAAE,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,KAC1D,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,GAC7C,CACE,KAAK,EAAE,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,KAC1D,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAElD,MAAM,WAAW,gBAAgB,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC;CACd;AAED,8BAAsB,QAAQ,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW;IACnE,OAAO,CAAC,QAAQ,CAAyB;IAEzC,SAAS,aAAa,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAIrD,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjG,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;CAoBzC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.BaseTool = void 0;
|
|
6
|
+
class BaseTool {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this._options = options;
|
|
9
|
+
}
|
|
10
|
+
register(server) {
|
|
11
|
+
// TODO: remove ts-ignore
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
server.tool(this._options.name, this._options.description, this._options.schema, async (...args) => {
|
|
14
|
+
try {
|
|
15
|
+
const result = await this.executeAsync(...args);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return {
|
|
20
|
+
isError: true,
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: error instanceof Error ? error.message : error
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BaseTool = BaseTool;
|
|
33
|
+
//# sourceMappingURL=base.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.tool.js","sourceRoot":"","sources":["../../src/tools/base.tool.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AA4B3D,MAAsB,QAAQ;IAG5B,YAAsB,OAA+B;QACnD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAIM,QAAQ,CAAC,MAAiB;QAC/B,yBAAyB;QACzB,aAAa;QACb,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;YACjG,IAAI,CAAC;gBACH,MAAM,MAAM,GAAmB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAI,IAAuC,CAAC,CAAC;gBACpG,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;yBACrD;qBACF;iBACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7BD,4BA6BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol';\nimport type {\n CallToolResultSchema,\n ServerNotification,\n ServerRequest\n} from '@modelcontextprotocol/sdk/types';\nimport type { z, ZodRawShape, ZodTypeAny } from 'zod';\n\nexport type CallToolResult = z.infer<typeof CallToolResultSchema>;\n\ntype ToolCallback<Args extends undefined | ZodRawShape = undefined> = Args extends ZodRawShape\n ? (\n args: z.objectOutputType<Args, ZodTypeAny>,\n extra: RequestHandlerExtra<ServerRequest, ServerNotification>\n ) => CallToolResult | Promise<CallToolResult>\n : (\n extra: RequestHandlerExtra<ServerRequest, ServerNotification>\n ) => CallToolResult | Promise<CallToolResult>;\n\nexport interface IBaseToolOptions<Args extends ZodRawShape = ZodRawShape> {\n name: string;\n description: string;\n schema: Args;\n}\n\nexport abstract class BaseTool<Args extends ZodRawShape = ZodRawShape> {\n private _options: IBaseToolOptions<Args>;\n\n protected constructor(options: IBaseToolOptions<Args>) {\n this._options = options;\n }\n\n protected abstract executeAsync(...args: Parameters<ToolCallback<Args>>): ReturnType<ToolCallback<Args>>;\n\n public register(server: McpServer): void {\n // TODO: remove ts-ignore\n // @ts-ignore\n server.tool(this._options.name, this._options.description, this._options.schema, async (...args) => {\n try {\n const result: CallToolResult = await this.executeAsync(...(args as Parameters<ToolCallback<Args>>));\n return result;\n } catch (error: unknown) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: error instanceof Error ? error.message : error\n }\n ]\n };\n }\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseTool, type CallToolResult } from './base.tool';
|
|
2
|
+
export declare class RushConflictResolverTool extends BaseTool {
|
|
3
|
+
constructor();
|
|
4
|
+
private _tryGetSubspaceNameFromLockfilePath;
|
|
5
|
+
executeAsync({ lockfilePath }: {
|
|
6
|
+
lockfilePath: string;
|
|
7
|
+
}): Promise<CallToolResult>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=conflict-resolver.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-resolver.tool.d.ts","sourceRoot":"","sources":["../../src/tools/conflict-resolver.tool.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,wBAAyB,SAAQ,QAAQ;;IAYpD,OAAO,CAAC,mCAAmC;IAa9B,YAAY,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CA0B/F"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.RushConflictResolverTool = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const command_runner_1 = require("../utilities/command-runner");
|
|
8
|
+
const common_1 = require("../utilities/common");
|
|
9
|
+
const base_tool_1 = require("./base.tool");
|
|
10
|
+
class RushConflictResolverTool extends base_tool_1.BaseTool {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
name: 'rush_pnpm_lock_file_conflict_resolver',
|
|
14
|
+
description: 'If a user requests to resolve a pnpm-lock.yaml file conflict, use this tool to automatically fix the conflict directly.',
|
|
15
|
+
schema: {
|
|
16
|
+
lockfilePath: zod_1.z.string().describe('The path to the pnpm-lock.yaml file, should pass absolute path')
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_tryGetSubspaceNameFromLockfilePath(lockfilePath, rushConfiguration) {
|
|
21
|
+
for (const subspace of rushConfiguration.subspaces) {
|
|
22
|
+
const folderPath = subspace.getSubspaceConfigFolderPath();
|
|
23
|
+
if (lockfilePath.startsWith(folderPath)) {
|
|
24
|
+
return subspace.subspaceName;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
async executeAsync({ lockfilePath }) {
|
|
30
|
+
const rushConfiguration = await (0, common_1.getRushConfiguration)();
|
|
31
|
+
const subspaceName = this._tryGetSubspaceNameFromLockfilePath(lockfilePath, rushConfiguration);
|
|
32
|
+
if (!subspaceName) {
|
|
33
|
+
throw new Error('subspace name not found');
|
|
34
|
+
}
|
|
35
|
+
const options = {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
currentWorkingDirectory: rushConfiguration.rushJsonFolder
|
|
38
|
+
};
|
|
39
|
+
await command_runner_1.CommandRunner.runGitCommandAsync(['checkout', '--theirs', lockfilePath], options);
|
|
40
|
+
await command_runner_1.CommandRunner.runRushCommandAsync(['update', '--subspace', subspaceName], options);
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: 'Conflict resolved successfully'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.RushConflictResolverTool = RushConflictResolverTool;
|
|
52
|
+
//# sourceMappingURL=conflict-resolver.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-resolver.tool.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BAAa,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QAEzF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,gCAAgC;iBACvC;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAnDD,4DAmDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { z } from 'zod';\nimport type { RushConfiguration } from '@rushstack/rush-sdk';\nimport type { IExecutableSpawnSyncOptions } from '@rushstack/node-core-library';\n\nimport { CommandRunner } from '../utilities/command-runner';\nimport { getRushConfiguration } from '../utilities/common';\nimport { BaseTool, type CallToolResult } from './base.tool';\n\nexport class RushConflictResolverTool extends BaseTool {\n public constructor() {\n super({\n name: 'rush_pnpm_lock_file_conflict_resolver',\n description:\n 'If a user requests to resolve a pnpm-lock.yaml file conflict, use this tool to automatically fix the conflict directly.',\n schema: {\n lockfilePath: z.string().describe('The path to the pnpm-lock.yaml file, should pass absolute path')\n }\n });\n }\n\n private _tryGetSubspaceNameFromLockfilePath(\n lockfilePath: string,\n rushConfiguration: RushConfiguration\n ): string | null {\n for (const subspace of rushConfiguration.subspaces) {\n const folderPath: string = subspace.getSubspaceConfigFolderPath();\n if (lockfilePath.startsWith(folderPath)) {\n return subspace.subspaceName;\n }\n }\n return null;\n }\n\n public async executeAsync({ lockfilePath }: { lockfilePath: string }): Promise<CallToolResult> {\n const rushConfiguration: RushConfiguration = await getRushConfiguration();\n const subspaceName: string | null = this._tryGetSubspaceNameFromLockfilePath(\n lockfilePath,\n rushConfiguration\n );\n if (!subspaceName) {\n throw new Error('subspace name not found');\n }\n\n const options: IExecutableSpawnSyncOptions = {\n stdio: 'inherit',\n currentWorkingDirectory: rushConfiguration.rushJsonFolder\n };\n await CommandRunner.runGitCommandAsync(['checkout', '--theirs', lockfilePath], options);\n await CommandRunner.runRushCommandAsync(['update', '--subspace', subspaceName], options);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Conflict resolved successfully'\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.tool.d.ts","sourceRoot":"","sources":["../../src/tools/docs.tool.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAY5D,qBAAa,YAAa,SAAQ,QAAQ;;IAY3B,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CAqBzF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.RushDocsTool = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const base_tool_1 = require("./base.tool");
|
|
8
|
+
class RushDocsTool extends base_tool_1.BaseTool {
|
|
9
|
+
constructor() {
|
|
10
|
+
super({
|
|
11
|
+
name: 'rush_docs',
|
|
12
|
+
description: 'Search and retrieve relevant sections from Rush official documentation based on user queries.',
|
|
13
|
+
schema: {
|
|
14
|
+
userQuery: zod_1.z.string().describe('The user query to search for relevant documentation sections.')
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async executeAsync({ userQuery }) {
|
|
19
|
+
// An example of a knowledge base that can run, but needs to be replaced with Microsoft’s service.
|
|
20
|
+
const response = await fetch('http://47.120.46.115/search', {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json'
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify({ query: userQuery, topK: 10 })
|
|
26
|
+
});
|
|
27
|
+
const result = (await response.json());
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: result.results.map((item) => item.text).join('\n')
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.RushDocsTool = RushDocsTool;
|
|
39
|
+
//# sourceMappingURL=docs.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.tool.js","sourceRoot":"","sources":["../../src/tools/docs.tool.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,6BAAwB;AAExB,2CAA4D;AAY5D,MAAa,YAAa,SAAQ,oBAAQ;IACxC;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,WAAW;YACjB,WAAW,EACT,+FAA+F;YACjG,MAAM,EAAE;gBACN,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;aAChG;SACF,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,EAAE,SAAS,EAAyB;QAC5D,kGAAkG;QAClG,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,6BAA6B,EAAE;YACpE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;SACrD,CAAC,CAAC;QAEH,MAAM,MAAM,GAAgB,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAgB,CAAC;QAEnE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBACzD;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,oCAiCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { z } from 'zod';\n\nimport { BaseTool, type CallToolResult } from './base.tool';\n\ninterface IDocsResult {\n query: string;\n results: {\n score: number;\n text: string;\n }[];\n count: number;\n searchTimeMs: number;\n}\n\nexport class RushDocsTool extends BaseTool {\n public constructor() {\n super({\n name: 'rush_docs',\n description:\n 'Search and retrieve relevant sections from Rush official documentation based on user queries.',\n schema: {\n userQuery: z.string().describe('The user query to search for relevant documentation sections.')\n }\n });\n }\n\n public async executeAsync({ userQuery }: { userQuery: string }): Promise<CallToolResult> {\n // An example of a knowledge base that can run, but needs to be replaced with Microsoft’s service.\n const response: Response = await fetch('http://47.120.46.115/search', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({ query: userQuery, topK: 10 })\n });\n\n const result: IDocsResult = (await response.json()) as IDocsResult;\n\n return {\n content: [\n {\n type: 'text',\n text: result.results.map((item) => item.text).join('\\n')\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './base.tool';
|
|
2
|
+
export * from './migrate-project.tool';
|
|
3
|
+
export * from './project-details.tool';
|
|
4
|
+
export * from './rush-command-validator.tool';
|
|
5
|
+
export * from './workspace-details';
|
|
6
|
+
export * from './conflict-resolver.tool';
|
|
7
|
+
export * from './docs.tool';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./base.tool"), exports);
|
|
20
|
+
__exportStar(require("./migrate-project.tool"), exports);
|
|
21
|
+
__exportStar(require("./project-details.tool"), exports);
|
|
22
|
+
__exportStar(require("./rush-command-validator.tool"), exports);
|
|
23
|
+
__exportStar(require("./workspace-details"), exports);
|
|
24
|
+
__exportStar(require("./conflict-resolver.tool"), exports);
|
|
25
|
+
__exportStar(require("./docs.tool"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;AAE3D,8CAA4B;AAC5B,yDAAuC;AACvC,yDAAuC;AACvC,gEAA8C;AAC9C,sDAAoC;AACpC,2DAAyC;AACzC,8CAA4B","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport * from './base.tool';\nexport * from './migrate-project.tool';\nexport * from './project-details.tool';\nexport * from './rush-command-validator.tool';\nexport * from './workspace-details';\nexport * from './conflict-resolver.tool';\nexport * from './docs.tool';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseTool, type CallToolResult } from './base.tool';
|
|
2
|
+
export declare class RushMigrateProjectTool extends BaseTool {
|
|
3
|
+
private _rushWorkspacePath;
|
|
4
|
+
constructor(rushWorkspacePath: string);
|
|
5
|
+
private _modifyAndSaveSubspaceJsonFileAsync;
|
|
6
|
+
private _modifyAndSaveRushConfigurationAsync;
|
|
7
|
+
executeAsync({ projectName, targetSubspaceName, targetProjectPath }: {
|
|
8
|
+
projectName: string;
|
|
9
|
+
targetProjectPath: string;
|
|
10
|
+
targetSubspaceName: string;
|
|
11
|
+
}): Promise<CallToolResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=migrate-project.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-project.tool.d.ts","sourceRoot":"","sources":["../../src/tools/migrate-project.tool.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAQ5D,qBAAa,sBAAuB,SAAQ,QAAQ;IAClD,OAAO,CAAC,kBAAkB,CAAS;gBAEhB,iBAAiB,EAAE,MAAM;YAc9B,mCAAmC;YAgBnC,oCAAoC;IAerC,YAAY,CAAC,EACxB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EAClB,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;KAC5B,GAAG,OAAO,CAAC,cAAc,CAAC;CA+D5B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.RushMigrateProjectTool = void 0;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
11
|
+
const base_tool_1 = require("./base.tool");
|
|
12
|
+
const common_1 = require("../utilities/common");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
class RushMigrateProjectTool extends base_tool_1.BaseTool {
|
|
15
|
+
constructor(rushWorkspacePath) {
|
|
16
|
+
super({
|
|
17
|
+
name: 'rush_migrate_project',
|
|
18
|
+
description: 'Migrate a project to a different location or subspace within the Rush monorepo.',
|
|
19
|
+
schema: {
|
|
20
|
+
projectName: zod_1.z.string().describe('The name of the project to be migrated'),
|
|
21
|
+
targetProjectPath: zod_1.z.string().optional().describe('The target path to migrate the project to'),
|
|
22
|
+
targetSubspaceName: zod_1.z.string().optional().describe('The target subspace to migrate the project to')
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
this._rushWorkspacePath = rushWorkspacePath;
|
|
26
|
+
}
|
|
27
|
+
async _modifyAndSaveSubspaceJsonFileAsync(rushConfiguration, cb) {
|
|
28
|
+
const subspacesFolderPath = path_1.default.resolve(rushConfiguration.commonRushConfigFolder, 'subspaces.json');
|
|
29
|
+
const subspacesConfiguration = await node_core_library_1.JsonFile.loadAsync(subspacesFolderPath);
|
|
30
|
+
const newSubspaceNames = await cb(subspacesConfiguration.subspaceNames);
|
|
31
|
+
subspacesConfiguration.subspaceNames = newSubspaceNames;
|
|
32
|
+
await node_core_library_1.JsonFile.saveAsync(subspacesConfiguration, subspacesFolderPath, {
|
|
33
|
+
updateExistingFile: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async _modifyAndSaveRushConfigurationAsync(rushConfiguration, cb) {
|
|
37
|
+
const rushConfigurationJson = rushConfiguration.rushConfigurationJson;
|
|
38
|
+
const rushConfigurationFile = rushConfiguration.rushJsonFile;
|
|
39
|
+
const newRushConfigurationProjectJson = await cb(rushConfigurationJson.projects);
|
|
40
|
+
rushConfigurationJson.projects = newRushConfigurationProjectJson;
|
|
41
|
+
await node_core_library_1.JsonFile.saveAsync(rushConfigurationJson, rushConfigurationFile, { updateExistingFile: true });
|
|
42
|
+
}
|
|
43
|
+
async executeAsync({ projectName, targetSubspaceName, targetProjectPath }) {
|
|
44
|
+
const rushConfiguration = await (0, common_1.getRushConfiguration)();
|
|
45
|
+
const project = rushConfiguration.getProjectByName(projectName);
|
|
46
|
+
if (!project) {
|
|
47
|
+
return {
|
|
48
|
+
isError: true,
|
|
49
|
+
content: [{ type: 'text', text: `Project "${projectName}" not found` }]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const rootPath = this._rushWorkspacePath;
|
|
53
|
+
const sourceProjectSubspaceName = project.subspace.subspaceName;
|
|
54
|
+
const sourceProjectPath = project.projectFolder;
|
|
55
|
+
const destinationPath = path_1.default.resolve(rootPath, targetProjectPath);
|
|
56
|
+
const subspacehasOnlyOneProject = project.subspace.getProjects().length === 1;
|
|
57
|
+
// 1. Remove source subspace folder
|
|
58
|
+
if (subspacehasOnlyOneProject) {
|
|
59
|
+
const subspaceConfigFolderPath = project.subspace.getSubspaceConfigFolderPath();
|
|
60
|
+
await node_core_library_1.FileSystem.deleteFolderAsync(subspaceConfigFolderPath);
|
|
61
|
+
}
|
|
62
|
+
// 2. Move project to target subspace
|
|
63
|
+
await node_core_library_1.FileSystem.moveAsync({
|
|
64
|
+
sourcePath: sourceProjectPath,
|
|
65
|
+
destinationPath
|
|
66
|
+
});
|
|
67
|
+
// 3. Update rush configuration
|
|
68
|
+
await this._modifyAndSaveRushConfigurationAsync(rushConfiguration, (projects) => {
|
|
69
|
+
const projectIndex = projects.findIndex(({ packageName }) => packageName === projectName);
|
|
70
|
+
projects[projectIndex] = {
|
|
71
|
+
...projects[projectIndex],
|
|
72
|
+
subspaceName: targetSubspaceName,
|
|
73
|
+
projectFolder: path_1.default.relative(rootPath, destinationPath)
|
|
74
|
+
};
|
|
75
|
+
return projects;
|
|
76
|
+
});
|
|
77
|
+
// 4. Update `subspaces.json`
|
|
78
|
+
await this._modifyAndSaveSubspaceJsonFileAsync(rushConfiguration, (subspaceNames) => {
|
|
79
|
+
if (subspacehasOnlyOneProject) {
|
|
80
|
+
subspaceNames.splice(subspaceNames.indexOf(sourceProjectSubspaceName), 1);
|
|
81
|
+
}
|
|
82
|
+
if (!subspaceNames.includes(targetSubspaceName)) {
|
|
83
|
+
subspaceNames.push(targetSubspaceName);
|
|
84
|
+
}
|
|
85
|
+
return subspaceNames;
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: `Project "${projectName}" migrated to subspace "${targetSubspaceName}" successfully. ` +
|
|
92
|
+
`You can ask whether user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +
|
|
93
|
+
`If user says "yes" you can run "rush update --subspace ${targetSubspaceName}" directly for them.`
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.RushMigrateProjectTool = RushMigrateProjectTool;
|
|
100
|
+
//# sourceMappingURL=migrate-project.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-project.tool.js","sourceRoot":"","sources":["../../src/tools/migrate-project.tool.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2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the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { z } from 'zod';\nimport { FileSystem, JsonFile } from '@rushstack/node-core-library';\n\nimport { BaseTool, type CallToolResult } from './base.tool';\nimport { getRushConfiguration } from '../utilities/common';\nimport path from 'path';\nimport type { ISubspacesConfigurationJson } from '@rushstack/rush-sdk/lib/api/SubspacesConfiguration';\nimport type { RushConfiguration, RushConfigurationProject } from '@rushstack/rush-sdk';\nimport type { IRushConfigurationProjectJson } from '@rushstack/rush-sdk/lib/api/RushConfigurationProject';\nimport type { IRushConfigurationJson } from '@rushstack/rush-sdk/lib/api/RushConfiguration';\n\nexport class RushMigrateProjectTool extends BaseTool {\n private _rushWorkspacePath: string;\n\n public constructor(rushWorkspacePath: string) {\n super({\n name: 'rush_migrate_project',\n description: 'Migrate a project to a different location or subspace within the Rush monorepo.',\n schema: {\n projectName: z.string().describe('The name of the project to be migrated'),\n targetProjectPath: z.string().optional().describe('The target path to migrate the project to'),\n targetSubspaceName: z.string().optional().describe('The target subspace to migrate the project to')\n }\n });\n\n this._rushWorkspacePath = rushWorkspacePath;\n }\n\n private async _modifyAndSaveSubspaceJsonFileAsync(\n rushConfiguration: RushConfiguration,\n cb: (subspaceNames: string[]) => Promise<string[]> | string[]\n ): Promise<void> {\n const subspacesFolderPath: string = path.resolve(\n rushConfiguration.commonRushConfigFolder,\n 'subspaces.json'\n );\n const subspacesConfiguration: ISubspacesConfigurationJson = await JsonFile.loadAsync(subspacesFolderPath);\n const newSubspaceNames: string[] = await cb(subspacesConfiguration.subspaceNames);\n subspacesConfiguration.subspaceNames = newSubspaceNames;\n await JsonFile.saveAsync(subspacesConfiguration, subspacesFolderPath, {\n updateExistingFile: true\n });\n }\n\n private async _modifyAndSaveRushConfigurationAsync(\n rushConfiguration: RushConfiguration,\n cb: (\n projects: IRushConfigurationProjectJson[]\n ) => Promise<IRushConfigurationProjectJson[]> | IRushConfigurationProjectJson[]\n ): Promise<void> {\n const rushConfigurationJson: IRushConfigurationJson = rushConfiguration.rushConfigurationJson;\n const rushConfigurationFile: string = rushConfiguration.rushJsonFile;\n const newRushConfigurationProjectJson: IRushConfigurationProjectJson[] = await cb(\n rushConfigurationJson.projects\n );\n rushConfigurationJson.projects = newRushConfigurationProjectJson;\n await JsonFile.saveAsync(rushConfigurationJson, rushConfigurationFile, { updateExistingFile: true });\n }\n\n public async executeAsync({\n projectName,\n targetSubspaceName,\n targetProjectPath\n }: {\n projectName: string;\n targetProjectPath: string;\n targetSubspaceName: string;\n }): Promise<CallToolResult> {\n const rushConfiguration: RushConfiguration = await getRushConfiguration();\n const project: RushConfigurationProject | undefined = rushConfiguration.getProjectByName(projectName);\n\n if (!project) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Project \"${projectName}\" not found` }]\n };\n }\n\n const rootPath: string = this._rushWorkspacePath;\n const sourceProjectSubspaceName: string = project.subspace.subspaceName;\n const sourceProjectPath: string = project.projectFolder;\n const destinationPath: string = path.resolve(rootPath, targetProjectPath);\n const subspacehasOnlyOneProject: boolean = project.subspace.getProjects().length === 1;\n\n // 1. Remove source subspace folder\n if (subspacehasOnlyOneProject) {\n const subspaceConfigFolderPath: string = project.subspace.getSubspaceConfigFolderPath();\n await FileSystem.deleteFolderAsync(subspaceConfigFolderPath);\n }\n\n // 2. Move project to target subspace\n await FileSystem.moveAsync({\n sourcePath: sourceProjectPath,\n destinationPath\n });\n\n // 3. Update rush configuration\n await this._modifyAndSaveRushConfigurationAsync(rushConfiguration, (projects) => {\n const projectIndex: number = projects.findIndex(({ packageName }) => packageName === projectName);\n projects[projectIndex] = {\n ...projects[projectIndex],\n subspaceName: targetSubspaceName,\n projectFolder: path.relative(rootPath, destinationPath)\n };\n return projects;\n });\n\n // 4. Update `subspaces.json`\n await this._modifyAndSaveSubspaceJsonFileAsync(rushConfiguration, (subspaceNames) => {\n if (subspacehasOnlyOneProject) {\n subspaceNames.splice(subspaceNames.indexOf(sourceProjectSubspaceName), 1);\n }\n if (!subspaceNames.includes(targetSubspaceName)) {\n subspaceNames.push(targetSubspaceName);\n }\n return subspaceNames;\n });\n\n return {\n content: [\n {\n type: 'text',\n text:\n `Project \"${projectName}\" migrated to subspace \"${targetSubspaceName}\" successfully. ` +\n `You can ask whether user wants to run \"rush update --subspace ${targetSubspaceName}\" to update the project. ` +\n `If user says \"yes\" you can run \"rush update --subspace ${targetSubspaceName}\" directly for them.`\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseTool, type CallToolResult } from './base.tool';
|
|
2
|
+
export declare class RushProjectDetailsTool extends BaseTool {
|
|
3
|
+
constructor();
|
|
4
|
+
executeAsync({ projectName }: {
|
|
5
|
+
projectName: string;
|
|
6
|
+
}): Promise<CallToolResult>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=project-details.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-details.tool.d.ts","sourceRoot":"","sources":["../../src/tools/project-details.tool.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,sBAAuB,SAAQ,QAAQ;;IAWrC,YAAY,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CAuC7F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.RushProjectDetailsTool = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const common_1 = require("../utilities/common");
|
|
8
|
+
const base_tool_1 = require("./base.tool");
|
|
9
|
+
class RushProjectDetailsTool extends base_tool_1.BaseTool {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
name: 'rush_project_details',
|
|
13
|
+
description: 'Returns the complete project details in JSON format for a given rush project.',
|
|
14
|
+
schema: {
|
|
15
|
+
projectName: zod_1.z.string().describe('The name of the project to get details for')
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async executeAsync({ projectName }) {
|
|
20
|
+
const rushConfiguration = await (0, common_1.getRushConfiguration)();
|
|
21
|
+
const project = rushConfiguration.getProjectByName(projectName);
|
|
22
|
+
if (!project) {
|
|
23
|
+
throw new Error(`Project ${projectName} not found`);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: JSON.stringify({
|
|
30
|
+
packageJson: project.packageJson,
|
|
31
|
+
/**
|
|
32
|
+
* Example: `C:\MyRepo\libraries\my-project`
|
|
33
|
+
*/
|
|
34
|
+
projectFolder: project.projectFolder,
|
|
35
|
+
/**
|
|
36
|
+
* Example: `libraries/my-project`
|
|
37
|
+
*/
|
|
38
|
+
projectRelativeFolder: project.projectRelativeFolder,
|
|
39
|
+
/**
|
|
40
|
+
* Example: `C:\MyRepo\libraries\my-project\config\rush`
|
|
41
|
+
*/
|
|
42
|
+
projectRushConfigFolder: project.projectRushConfigFolder,
|
|
43
|
+
/**
|
|
44
|
+
* Example: `my-subspace`
|
|
45
|
+
*/
|
|
46
|
+
projectSubspaceName: project.subspace.subspaceName
|
|
47
|
+
}, null, 2)
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.RushProjectDetailsTool = RushProjectDetailsTool;
|
|
54
|
+
//# sourceMappingURL=project-details.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-details.tool.js","sourceRoot":"","sources":["../../src/tools/project-details.tool.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,6BAAwB;AAGxB,gDAA2D;AAC3D,2CAA4D;AAE5D,MAAa,sBAAuB,SAAQ,oBAAQ;IAClD;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EAAE,+EAA+E;YAC5F,MAAM,EAAE;gBACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;aAC/E;SACF,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,EAAE,WAAW,EAA2B;QAChE,MAAM,iBAAiB,GAAsB,MAAM,IAAA,6BAAoB,GAAE,CAAC;QAC1E,MAAM,OAAO,GAAyC,iBAAiB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAEtG,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,WAAW,WAAW,YAAY,CAAC,CAAC;QACtD,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;wBACE,WAAW,EAAE,OAAO,CAAC,WAAW;wBAChC;;2BAEG;wBACH,aAAa,EAAE,OAAO,CAAC,aAAa;wBACpC;;2BAEG;wBACH,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;wBACpD;;2BAEG;wBACH,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;wBACxD;;2BAEG;wBACH,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY;qBACnD,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAlDD,wDAkDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { z } from 'zod';\nimport type { RushConfiguration, RushConfigurationProject } from '@rushstack/rush-sdk';\n\nimport { getRushConfiguration } from '../utilities/common';\nimport { BaseTool, type CallToolResult } from './base.tool';\n\nexport class RushProjectDetailsTool extends BaseTool {\n public constructor() {\n super({\n name: 'rush_project_details',\n description: 'Returns the complete project details in JSON format for a given rush project.',\n schema: {\n projectName: z.string().describe('The name of the project to get details for')\n }\n });\n }\n\n public async executeAsync({ projectName }: { projectName: string }): Promise<CallToolResult> {\n const rushConfiguration: RushConfiguration = await getRushConfiguration();\n const project: RushConfigurationProject | undefined = rushConfiguration.getProjectByName(projectName);\n\n if (!project) {\n throw new Error(`Project ${projectName} not found`);\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n packageJson: project.packageJson,\n /**\n * Example: `C:\\MyRepo\\libraries\\my-project`\n */\n projectFolder: project.projectFolder,\n /**\n * Example: `libraries/my-project`\n */\n projectRelativeFolder: project.projectRelativeFolder,\n /**\n * Example: `C:\\MyRepo\\libraries\\my-project\\config\\rush`\n */\n projectRushConfigFolder: project.projectRushConfigFolder,\n /**\n * Example: `my-subspace`\n */\n projectSubspaceName: project.subspace.subspaceName\n },\n null,\n 2\n )\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseTool, type CallToolResult } from './base.tool';
|
|
2
|
+
export declare const selectionParamsSet: ReadonlySet<string>;
|
|
3
|
+
export declare class RushCommandValidatorTool extends BaseTool {
|
|
4
|
+
constructor();
|
|
5
|
+
executeAsync({ commandName, subCommandName, args }: {
|
|
6
|
+
commandName: string;
|
|
7
|
+
subCommandName: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
}): Promise<CallToolResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=rush-command-validator.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rush-command-validator.tool.d.ts","sourceRoot":"","sources":["../../src/tools/rush-command-validator.tool.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAajD,CAAC;AAEH,qBAAa,wBAAyB,SAAQ,QAAQ;;IAkBvC,YAAY,CAAC,EACxB,WAAW,EACX,cAAc,EACd,IAAI,EACL,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,GAAG,OAAO,CAAC,cAAc,CAAC;CA2D5B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.RushCommandValidatorTool = exports.selectionParamsSet = void 0;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const common_1 = require("../utilities/common");
|
|
13
|
+
const base_tool_1 = require("./base.tool");
|
|
14
|
+
exports.selectionParamsSet = new Set([
|
|
15
|
+
'-t',
|
|
16
|
+
'--to',
|
|
17
|
+
'--to-except',
|
|
18
|
+
'-T',
|
|
19
|
+
'--from',
|
|
20
|
+
'-f',
|
|
21
|
+
'--only',
|
|
22
|
+
'-o',
|
|
23
|
+
'--impacted-by',
|
|
24
|
+
'-i',
|
|
25
|
+
'--impacted-by-except',
|
|
26
|
+
'-I'
|
|
27
|
+
]);
|
|
28
|
+
class RushCommandValidatorTool extends base_tool_1.BaseTool {
|
|
29
|
+
constructor() {
|
|
30
|
+
super({
|
|
31
|
+
name: 'rush_command_validator',
|
|
32
|
+
description: 'Validates Rush commands before execution by checking command format and ensuring compliance with Rush command standards. This tool helps prevent invalid command usage and provides guidance on proper parameter selection.',
|
|
33
|
+
schema: {
|
|
34
|
+
commandName: zod_1.z.enum(['rush', 'rushx']).describe('The main command to execute (rush or rushx)'),
|
|
35
|
+
subCommandName: zod_1.z
|
|
36
|
+
.string()
|
|
37
|
+
.describe('The Rush subcommand to validate (install, update, add, remove, purge, list, build, etc.)'),
|
|
38
|
+
args: zod_1.z.array(zod_1.z.string()).describe('The arguments to validate for the subcommand')
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async executeAsync({ commandName, subCommandName, args }) {
|
|
43
|
+
var _a;
|
|
44
|
+
const rushConfiguration = await (0, common_1.getRushConfiguration)();
|
|
45
|
+
const commandLineJson = await node_core_library_1.JsonFile.loadAsync(path_1.default.resolve(rushConfiguration.commonFolder, 'config', 'rush', 'command-line.json'));
|
|
46
|
+
const conditionSubCommandNames = new Set((_a = commandLineJson.commands) === null || _a === void 0 ? void 0 : _a.filter((command) => command.commandKind !== 'global').map((command) => command.name));
|
|
47
|
+
if (conditionSubCommandNames.has(subCommandName) && !args.some((arg) => exports.selectionParamsSet.has(arg))) {
|
|
48
|
+
return {
|
|
49
|
+
isError: true,
|
|
50
|
+
content: [
|
|
51
|
+
{
|
|
52
|
+
type: 'text',
|
|
53
|
+
text: `Please add selection parameters like ${Array.from(exports.selectionParamsSet).join(', ')} to the command and re-validate. The package name should be retrieved from the package.json file in your project folder.`
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
for (const [index, arg] of args.entries()) {
|
|
59
|
+
if (exports.selectionParamsSet.has(arg)) {
|
|
60
|
+
const packageName = args[index + 1];
|
|
61
|
+
const isValidPackage = packageName === '.' || rushConfiguration.projects.some((p) => p.packageName === packageName);
|
|
62
|
+
if (!isValidPackage) {
|
|
63
|
+
return {
|
|
64
|
+
isError: true,
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: `The package "${packageName}" does not exist in the Rush workspace. You can retrive package name from 'package.json' file in the project folder.`
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const commandStr = `${commandName} ${subCommandName} ${args.join(' ')}`;
|
|
76
|
+
const text = `Command "${commandStr}" validated successfully, you can ${commandName === 'rushx' || subCommandName === 'add' ? 'enter the project folder and ' : ''}execute it now.`;
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: 'text',
|
|
81
|
+
text
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.RushCommandValidatorTool = RushCommandValidatorTool;
|
|
88
|
+
//# sourceMappingURL=rush-command-validator.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rush-command-validator.tool.js","sourceRoot":"","sources":["../../src/tools/rush-command-validator.tool.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,6BAAwB;AACxB,oEAAwD;AACxD,gDAAwB;AAIxB,gDAA2D;AAC3D,2CAA4D;AAE/C,QAAA,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IAC7D,IAAI;IACJ,MAAM;IACN,aAAa;IACb,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,eAAe;IACf,IAAI;IACJ,sBAAsB;IACtB,IAAI;CACL,CAAC,CAAC;AAEH,MAAa,wBAAyB,SAAQ,oBAAQ;IACpD;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,wBAAwB;YAC9B,WAAW,EACT,6NAA6N;YAC/N,MAAM,EAAE;gBACN,WAAW,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,6CAA6C,CAAC;gBAC9F,cAAc,EAA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kB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChC,MAAM,WAAW,GAAW,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC5C,MAAM,cAAc,GAClB,WAAW,KAAK,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC;gBAE/F,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE;4BACP;gCACE,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,gBAAgB,WAAW,sHAAsH;6BACxJ;yBACF;qBACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAW,GAAG,WAAW,IAAI,cAAc,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,GAAW,YAAY,UAAU,qCACzC,WAAW,KAAK,OAAO,IAAI,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,EAC1F,iBAAiB,CAAC;QAElB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI;iBACL;aACF;SACF,CAAC;IACJ,CAAC;CACF;AArFD,4DAqFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { z } from 'zod';\nimport { JsonFile } from '@rushstack/node-core-library';\nimport path from 'path';\nimport type { ICommandLineJson } from '@rushstack/rush-sdk/lib/api/CommandLineJson';\nimport type { RushConfiguration } from '@rushstack/rush-sdk';\n\nimport { getRushConfiguration } from '../utilities/common';\nimport { BaseTool, type CallToolResult } from './base.tool';\n\nexport const selectionParamsSet: ReadonlySet<string> = new Set([\n '-t',\n '--to',\n '--to-except',\n '-T',\n '--from',\n '-f',\n '--only',\n '-o',\n '--impacted-by',\n '-i',\n '--impacted-by-except',\n '-I'\n]);\n\nexport class RushCommandValidatorTool extends BaseTool {\n public constructor() {\n super({\n name: 'rush_command_validator',\n description:\n 'Validates Rush commands before execution by checking command format and ensuring compliance with Rush command standards. This tool helps prevent invalid command usage and provides guidance on proper parameter selection.',\n schema: {\n commandName: z.enum(['rush', 'rushx']).describe('The main command to execute (rush or rushx)'),\n subCommandName: z\n .string()\n .describe(\n 'The Rush subcommand to validate (install, update, add, remove, purge, list, build, etc.)'\n ),\n args: z.array(z.string()).describe('The arguments to validate for the subcommand')\n }\n });\n }\n\n public async executeAsync({\n commandName,\n subCommandName,\n args\n }: {\n commandName: string;\n subCommandName: string;\n args: string[];\n }): Promise<CallToolResult> {\n const rushConfiguration: RushConfiguration = await getRushConfiguration();\n const commandLineJson: ICommandLineJson = await JsonFile.loadAsync(\n path.resolve(rushConfiguration.commonFolder, 'config', 'rush', 'command-line.json')\n );\n const conditionSubCommandNames: Set<string> = new Set(\n commandLineJson.commands\n ?.filter((command) => command.commandKind !== 'global')\n .map((command) => command.name)\n );\n\n if (conditionSubCommandNames.has(subCommandName) && !args.some((arg) => selectionParamsSet.has(arg))) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Please add selection parameters like ${Array.from(selectionParamsSet).join(\n ', '\n )} to the command and re-validate. The package name should be retrieved from the package.json file in your project folder.`\n }\n ]\n };\n }\n\n for (const [index, arg] of args.entries()) {\n if (selectionParamsSet.has(arg)) {\n const packageName: string = args[index + 1];\n const isValidPackage: boolean =\n packageName === '.' || rushConfiguration.projects.some((p) => p.packageName === packageName);\n\n if (!isValidPackage) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `The package \"${packageName}\" does not exist in the Rush workspace. You can retrive package name from 'package.json' file in the project folder.`\n }\n ]\n };\n }\n }\n }\n\n const commandStr: string = `${commandName} ${subCommandName} ${args.join(' ')}`;\n const text: string = `Command \"${commandStr}\" validated successfully, you can ${\n commandName === 'rushx' || subCommandName === 'add' ? 'enter the project folder and ' : ''\n }execute it now.`;\n\n return {\n content: [\n {\n type: 'text',\n text\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseTool, type CallToolResult } from './base.tool';
|
|
2
|
+
export declare class RushWorkspaceDetailsTool extends BaseTool {
|
|
3
|
+
constructor();
|
|
4
|
+
executeAsync(): Promise<CallToolResult>;
|
|
5
|
+
private _getWorkspaceDetailsPrompt;
|
|
6
|
+
private _getRobotReadableWorkspaceDetails;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=workspace-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-details.d.ts","sourceRoot":"","sources":["../../src/tools/workspace-details.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,wBAAyB,SAAQ,QAAQ;;IAUvC,YAAY,IAAI,OAAO,CAAC,cAAc,CAAC;IAcpD,OAAO,CAAC,0BAA0B;IA2BlC,OAAO,CAAC,iCAAiC;CA+D1C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.RushWorkspaceDetailsTool = void 0;
|
|
6
|
+
const common_1 = require("../utilities/common");
|
|
7
|
+
const base_tool_1 = require("./base.tool");
|
|
8
|
+
class RushWorkspaceDetailsTool extends base_tool_1.BaseTool {
|
|
9
|
+
constructor() {
|
|
10
|
+
super({
|
|
11
|
+
name: 'rush_workspace_details',
|
|
12
|
+
description: 'Retrieves a comprehensive overview of the Rush monorepo project graph in an LLM-friendly format. Use it to answer questions about the current Rush workspace and architecture.',
|
|
13
|
+
schema: {}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async executeAsync() {
|
|
17
|
+
const rushConfiguration = await (0, common_1.getRushConfiguration)();
|
|
18
|
+
const projects = rushConfiguration.projects;
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: 'text',
|
|
23
|
+
text: this._getWorkspaceDetailsPrompt(rushConfiguration, projects)
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
_getWorkspaceDetailsPrompt(rushConfiguration, projects) {
|
|
29
|
+
return `
|
|
30
|
+
The following is a comprehensive representation of the Rush monorepo workspace. The information is organized into two sections:
|
|
31
|
+
|
|
32
|
+
1. WORKSPACE LEVEL: Contains global configuration information about the Rush workspace itself.
|
|
33
|
+
2. PROJECT LEVEL: Lists all projects in the monorepo with their detailed information.
|
|
34
|
+
|
|
35
|
+
WORKSPACE LEVEL information includes Rush version, pnpm version, and overall project count.
|
|
36
|
+
|
|
37
|
+
PROJECT LEVEL information is separated by <project_name></project_name> tags. Each project contains:
|
|
38
|
+
- its direct workspace dependencies package names, marked by "deps: [...]"
|
|
39
|
+
- its package name, marked by "packageName: [...]"
|
|
40
|
+
- its project type/category, marked by "projectType: [...]"
|
|
41
|
+
- its source file location, marked by "projectFolder: [...]"
|
|
42
|
+
- its scripts/commands, marked by "scripts: [...]"
|
|
43
|
+
- its version, marked by "version: [...]"
|
|
44
|
+
- additional metadata if available
|
|
45
|
+
|
|
46
|
+
This data is very important. Use it to analyze the workspace and understand the project graph. The user cannot see this data, so don't reference it directly. It is read-only information to help you understand the workspace.
|
|
47
|
+
|
|
48
|
+
${this._getRobotReadableWorkspaceDetails(rushConfiguration.rushConfigurationJson, projects)}
|
|
49
|
+
`.trim();
|
|
50
|
+
}
|
|
51
|
+
_getRobotReadableWorkspaceDetails(rushConfiguration, projects) {
|
|
52
|
+
let serializedWorkspace = '';
|
|
53
|
+
// Add workspace-level information with clearer section marking
|
|
54
|
+
serializedWorkspace += `======== WORKSPACE LEVEL INFORMATION ========\n`;
|
|
55
|
+
serializedWorkspace += `<RUSH_WORKSPACE>\n`;
|
|
56
|
+
serializedWorkspace += ` rushVersion: [${rushConfiguration.rushVersion}]\n`;
|
|
57
|
+
serializedWorkspace += ` pnpmVersion: [${rushConfiguration.pnpmVersion}]\n`;
|
|
58
|
+
serializedWorkspace += ` projectCount: [${projects.length}]\n`;
|
|
59
|
+
serializedWorkspace += `</RUSH_WORKSPACE>\n\n`;
|
|
60
|
+
serializedWorkspace += `======== PROJECT LEVEL INFORMATION ========\n`;
|
|
61
|
+
projects.forEach((project) => {
|
|
62
|
+
serializedWorkspace += `<${project.packageName}>\n`;
|
|
63
|
+
serializedWorkspace += ` packageName: [${project.packageName}]\n`;
|
|
64
|
+
serializedWorkspace += ` version: [${project.packageJson.version}]\n`;
|
|
65
|
+
serializedWorkspace += ` projectFolder: [${project.projectFolder}]\n`;
|
|
66
|
+
serializedWorkspace += ` subspaceName: [${project.subspace.subspaceName}]\n`;
|
|
67
|
+
const projectType = project.shouldPublish ? 'publishable' : 'local';
|
|
68
|
+
serializedWorkspace += ` projectType: [${projectType}]\n`;
|
|
69
|
+
const dependencies = project.dependencyProjects;
|
|
70
|
+
const depNames = Array.from(dependencies, (dep) => dep.packageName);
|
|
71
|
+
if (depNames.length === 0) {
|
|
72
|
+
serializedWorkspace += ` deps: []\n`;
|
|
73
|
+
}
|
|
74
|
+
else if (depNames.length <= 5) {
|
|
75
|
+
serializedWorkspace += ` deps: [${depNames.join(', ')}]\n`;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
serializedWorkspace += ` deps: [\n ${depNames.join(',\n ')}\n ]\n`;
|
|
79
|
+
}
|
|
80
|
+
if (project.packageJson.scripts) {
|
|
81
|
+
const scripts = Object.keys(project.packageJson.scripts);
|
|
82
|
+
if (scripts.length === 0) {
|
|
83
|
+
serializedWorkspace += ` scripts: []\n`;
|
|
84
|
+
}
|
|
85
|
+
else if (scripts.length <= 5) {
|
|
86
|
+
serializedWorkspace += ` scripts: [${scripts.join(', ')}]\n`;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
serializedWorkspace += ` scripts: [\n ${scripts.join(',\n ')}\n ]\n`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
serializedWorkspace += ` scripts: []\n`;
|
|
94
|
+
}
|
|
95
|
+
if (project.versionPolicyName) {
|
|
96
|
+
serializedWorkspace += ` versionPolicy: [${project.versionPolicyName}]\n`;
|
|
97
|
+
}
|
|
98
|
+
if (project.reviewCategory) {
|
|
99
|
+
serializedWorkspace += ` reviewCategory: [${project.reviewCategory}]\n`;
|
|
100
|
+
}
|
|
101
|
+
serializedWorkspace += `</${project.packageName}>\n\n`;
|
|
102
|
+
});
|
|
103
|
+
return serializedWorkspace;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.RushWorkspaceDetailsTool = RushWorkspaceDetailsTool;
|
|
107
|
+
//# sourceMappingURL=workspace-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-details.js","sourceRoot":"","sources":["../../src/tools/workspace-details.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,gDAA2D;AAC3D,2CAA4D;AAE5D,MAAa,wBAAyB,SAAQ,oBAAQ;IACpD;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,wBAAwB;YAC9B,WAAW,EACT,gLAAgL;YAClL,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,MAAM,iBAAiB,GAAsB,MAAM,IAAA,6BAAoB,GAAE,CAAC;QAC1E,MAAM,QAAQ,GAA+B,iBAAiB,CAAC,QAAQ,CAAC;QAExE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC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AAc,EAAE,CAAC;gBAC3B,mBAAmB,IAAI,sBAAsB,OAAO,CAAC,cAAc,KAAK,CAAC;YAC3E,CAAC;YAED,mBAAmB,IAAI,KAAK,OAAO,CAAC,WAAW,OAAO,CAAC;QACzD,CAAC,CAAC,CAAC;QAEH,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAlHD,4DAkHC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { RushConfiguration, RushConfigurationProject } from '@rushstack/rush-sdk';\nimport type { IRushConfigurationJson } from '@rushstack/rush-sdk/lib/api/RushConfiguration';\n\nimport { getRushConfiguration } from '../utilities/common';\nimport { BaseTool, type CallToolResult } from './base.tool';\n\nexport class RushWorkspaceDetailsTool extends BaseTool {\n public constructor() {\n super({\n name: 'rush_workspace_details',\n description:\n 'Retrieves a comprehensive overview of the Rush monorepo project graph in an LLM-friendly format. Use it to answer questions about the current Rush workspace and architecture.',\n schema: {}\n });\n }\n\n public async executeAsync(): Promise<CallToolResult> {\n const rushConfiguration: RushConfiguration = await getRushConfiguration();\n const projects: RushConfigurationProject[] = rushConfiguration.projects;\n\n return {\n content: [\n {\n type: 'text',\n text: this._getWorkspaceDetailsPrompt(rushConfiguration, projects)\n }\n ]\n };\n }\n\n private _getWorkspaceDetailsPrompt(\n rushConfiguration: RushConfiguration,\n projects: RushConfigurationProject[]\n ): string {\n return `\nThe following is a comprehensive representation of the Rush monorepo workspace. The information is organized into two sections:\n\n1. WORKSPACE LEVEL: Contains global configuration information about the Rush workspace itself.\n2. PROJECT LEVEL: Lists all projects in the monorepo with their detailed information.\n\nWORKSPACE LEVEL information includes Rush version, pnpm version, and overall project count.\n\nPROJECT LEVEL information is separated by <project_name></project_name> tags. Each project contains:\n- its direct workspace dependencies package names, marked by \"deps: [...]\"\n- its package name, marked by \"packageName: [...]\"\n- its project type/category, marked by \"projectType: [...]\"\n- its source file location, marked by \"projectFolder: [...]\"\n- its scripts/commands, marked by \"scripts: [...]\"\n- its version, marked by \"version: [...]\"\n- additional metadata if available\n\nThis data is very important. Use it to analyze the workspace and understand the project graph. The user cannot see this data, so don't reference it directly. It is read-only information to help you understand the workspace.\n\n${this._getRobotReadableWorkspaceDetails(rushConfiguration.rushConfigurationJson, projects)}\n`.trim();\n }\n\n private _getRobotReadableWorkspaceDetails(\n rushConfiguration: IRushConfigurationJson,\n projects: RushConfigurationProject[]\n ): string {\n let serializedWorkspace: string = '';\n\n // Add workspace-level information with clearer section marking\n serializedWorkspace += `======== WORKSPACE LEVEL INFORMATION ========\\n`;\n serializedWorkspace += `<RUSH_WORKSPACE>\\n`;\n serializedWorkspace += ` rushVersion: [${rushConfiguration.rushVersion}]\\n`;\n serializedWorkspace += ` pnpmVersion: [${rushConfiguration.pnpmVersion}]\\n`;\n serializedWorkspace += ` projectCount: [${projects.length}]\\n`;\n serializedWorkspace += `</RUSH_WORKSPACE>\\n\\n`;\n serializedWorkspace += `======== PROJECT LEVEL INFORMATION ========\\n`;\n\n projects.forEach((project) => {\n serializedWorkspace += `<${project.packageName}>\\n`;\n\n serializedWorkspace += ` packageName: [${project.packageName}]\\n`;\n serializedWorkspace += ` version: [${project.packageJson.version}]\\n`;\n serializedWorkspace += ` projectFolder: [${project.projectFolder}]\\n`;\n serializedWorkspace += ` subspaceName: [${project.subspace.subspaceName}]\\n`;\n\n const projectType: string = project.shouldPublish ? 'publishable' : 'local';\n serializedWorkspace += ` projectType: [${projectType}]\\n`;\n\n const dependencies: ReadonlySet<RushConfigurationProject> = project.dependencyProjects;\n const depNames: string[] = Array.from(dependencies, (dep) => dep.packageName);\n\n if (depNames.length === 0) {\n serializedWorkspace += ` deps: []\\n`;\n } else if (depNames.length <= 5) {\n serializedWorkspace += ` deps: [${depNames.join(', ')}]\\n`;\n } else {\n serializedWorkspace += ` deps: [\\n ${depNames.join(',\\n ')}\\n ]\\n`;\n }\n\n if (project.packageJson.scripts) {\n const scripts: string[] = Object.keys(project.packageJson.scripts);\n if (scripts.length === 0) {\n serializedWorkspace += ` scripts: []\\n`;\n } else if (scripts.length <= 5) {\n serializedWorkspace += ` scripts: [${scripts.join(', ')}]\\n`;\n } else {\n serializedWorkspace += ` scripts: [\\n ${scripts.join(',\\n ')}\\n ]\\n`;\n }\n } else {\n serializedWorkspace += ` scripts: []\\n`;\n }\n\n if (project.versionPolicyName) {\n serializedWorkspace += ` versionPolicy: [${project.versionPolicyName}]\\n`;\n }\n\n if (project.reviewCategory) {\n serializedWorkspace += ` reviewCategory: [${project.reviewCategory}]\\n`;\n }\n\n serializedWorkspace += `</${project.packageName}>\\n\\n`;\n });\n\n return serializedWorkspace;\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IExecutableSpawnSyncOptions } from '@rushstack/node-core-library';
|
|
2
|
+
interface ICommandResult {
|
|
3
|
+
status: number;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class CommandExecutionError extends Error {
|
|
10
|
+
constructor(command: string, args: string[], stderr: string, status: number);
|
|
11
|
+
}
|
|
12
|
+
export declare class CommandRunner {
|
|
13
|
+
private static readonly _commandCache;
|
|
14
|
+
private static _resolveCommand;
|
|
15
|
+
private static _executeCommandAsync;
|
|
16
|
+
static runRushCommandAsync(args: string[], options?: IExecutableSpawnSyncOptions): Promise<ICommandResult>;
|
|
17
|
+
static runRushXCommandAsync(args: string[], options?: IExecutableSpawnSyncOptions): Promise<ICommandResult>;
|
|
18
|
+
static runGitCommandAsync(args: string[], options?: IExecutableSpawnSyncOptions): Promise<ICommandResult>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=command-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.d.ts","sourceRoot":"","sources":["../../src/utilities/command-runner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAE5F,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAInF;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAyC;IAE9E,OAAO,CAAC,MAAM,CAAC,eAAe;mBAoBT,oBAAoB;WAwBrB,mBAAmB,CACrC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,cAAc,CAAC;WAIN,oBAAoB,CACtC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,cAAc,CAAC;WAIN,kBAAkB,CACpC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,cAAc,CAAC;CAG3B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CommandRunner = exports.CommandExecutionError = void 0;
|
|
6
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
7
|
+
class CommandExecutionError extends Error {
|
|
8
|
+
constructor(command, args, stderr, status) {
|
|
9
|
+
super(`Command "${command} ${args.join(' ')}" failed with status ${status}:\n${stderr}`);
|
|
10
|
+
this.name = 'CommandExecutionError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.CommandExecutionError = CommandExecutionError;
|
|
14
|
+
class CommandRunner {
|
|
15
|
+
static _resolveCommand(command) {
|
|
16
|
+
var _a;
|
|
17
|
+
const cachedPath = this._commandCache.get(command);
|
|
18
|
+
if (cachedPath === null) {
|
|
19
|
+
throw new Error(`Command "${command}" not found in system PATH`);
|
|
20
|
+
}
|
|
21
|
+
if (cachedPath) {
|
|
22
|
+
return cachedPath;
|
|
23
|
+
}
|
|
24
|
+
const resolvedPath = (_a = node_core_library_1.Executable.tryResolve(command)) !== null && _a !== void 0 ? _a : null;
|
|
25
|
+
this._commandCache.set(command, resolvedPath);
|
|
26
|
+
if (!resolvedPath) {
|
|
27
|
+
throw new Error(`Command "${command}" not found in system PATH`);
|
|
28
|
+
}
|
|
29
|
+
return resolvedPath;
|
|
30
|
+
}
|
|
31
|
+
static async _executeCommandAsync(command, args, options) {
|
|
32
|
+
var _a;
|
|
33
|
+
const commandPath = this._resolveCommand(command);
|
|
34
|
+
const result = node_core_library_1.Executable.spawnSync(commandPath, args, options);
|
|
35
|
+
const status = (_a = result.status) !== null && _a !== void 0 ? _a : 1;
|
|
36
|
+
if (status !== 0) {
|
|
37
|
+
throw new CommandExecutionError(command, args, result.stderr, status);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
status,
|
|
41
|
+
stdout: result.stdout,
|
|
42
|
+
stderr: result.stderr,
|
|
43
|
+
command,
|
|
44
|
+
args
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
static async runRushCommandAsync(args, options) {
|
|
48
|
+
return this._executeCommandAsync('rush', args, options);
|
|
49
|
+
}
|
|
50
|
+
static async runRushXCommandAsync(args, options) {
|
|
51
|
+
return this._executeCommandAsync('rushx', args, options);
|
|
52
|
+
}
|
|
53
|
+
static async runGitCommandAsync(args, options) {
|
|
54
|
+
return this._executeCommandAsync('git', args, options);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.CommandRunner = CommandRunner;
|
|
58
|
+
CommandRunner._commandCache = new Map();
|
|
59
|
+
//# sourceMappingURL=command-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.js","sourceRoot":"","sources":["../../src/utilities/command-runner.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA4F;AAU5F,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAmB,OAAe,EAAE,IAAc,EAAE,MAAc,EAAE,MAAc;QAChF,KAAK,CAAC,YAAY,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,MAAM,MAAM,MAAM,EAAE,CAAC,CAAC;QACzF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC;AAED,MAAa,aAAa;IAGhB,MAAM,CAAC,eAAe,CAAC,OAAe;;QAC5C,MAAM,UAAU,GAA8B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9E,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,4BAA4B,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,YAAY,GAAkB,MAAA,8BAAU,CAAC,UAAU,CAAC,OAAO,CAAC,mCAAI,IAAI,CAAC;QAC3E,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAE9C,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,4BAA4B,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,oBAAoB,CACvC,OAAe,EACf,IAAc,EACd,OAAqC;;QAErC,MAAM,WAAW,GAAW,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAE1D,MAAM,MAAM,GAA2C,8BAAU,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAExG,MAAM,MAAM,GAAW,MAAA,MAAM,CAAC,MAAM,mCAAI,CAAC,CAAC;QAE1C,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,qBAAqB,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxE,CAAC;QAED,OAAO;YACL,MAAM;YACN,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO;YACP,IAAI;SACL,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,mBAAmB,CACrC,IAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,oBAAoB,CACtC,IAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,kBAAkB,CACpC,IAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;;AAlEH,sCAmEC;AAlEyB,2BAAa,GAA+B,IAAI,GAAG,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as child_process from 'child_process';\nimport { Executable, type IExecutableSpawnSyncOptions } from '@rushstack/node-core-library';\n\ninterface ICommandResult {\n status: number;\n stdout: string;\n stderr: string;\n command: string;\n args: string[];\n}\n\nexport class CommandExecutionError extends Error {\n public constructor(command: string, args: string[], stderr: string, status: number) {\n super(`Command \"${command} ${args.join(' ')}\" failed with status ${status}:\\n${stderr}`);\n this.name = 'CommandExecutionError';\n }\n}\n\nexport class CommandRunner {\n private static readonly _commandCache: Map<string, string | null> = new Map();\n\n private static _resolveCommand(command: string): string {\n const cachedPath: string | null | undefined = this._commandCache.get(command);\n if (cachedPath === null) {\n throw new Error(`Command \"${command}\" not found in system PATH`);\n }\n\n if (cachedPath) {\n return cachedPath;\n }\n\n const resolvedPath: string | null = Executable.tryResolve(command) ?? null;\n this._commandCache.set(command, resolvedPath);\n\n if (!resolvedPath) {\n throw new Error(`Command \"${command}\" not found in system PATH`);\n }\n\n return resolvedPath;\n }\n\n private static async _executeCommandAsync(\n command: string,\n args: string[],\n options?: IExecutableSpawnSyncOptions\n ): Promise<ICommandResult> {\n const commandPath: string = this._resolveCommand(command);\n\n const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(commandPath, args, options);\n\n const status: number = result.status ?? 1;\n\n if (status !== 0) {\n throw new CommandExecutionError(command, args, result.stderr, status);\n }\n\n return {\n status,\n stdout: result.stdout,\n stderr: result.stderr,\n command,\n args\n };\n }\n\n public static async runRushCommandAsync(\n args: string[],\n options?: IExecutableSpawnSyncOptions\n ): Promise<ICommandResult> {\n return this._executeCommandAsync('rush', args, options);\n }\n\n public static async runRushXCommandAsync(\n args: string[],\n options?: IExecutableSpawnSyncOptions\n ): Promise<ICommandResult> {\n return this._executeCommandAsync('rushx', args, options);\n }\n\n public static async runGitCommandAsync(\n args: string[],\n options?: IExecutableSpawnSyncOptions\n ): Promise<ICommandResult> {\n return this._executeCommandAsync('git', args, options);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utilities/common.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,iBAAiB,CAMtE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.getRushConfiguration = void 0;
|
|
39
|
+
const getRushConfiguration = async () => {
|
|
40
|
+
// Since the MCP server is not always started from the directory of the Rush monorepo,
|
|
41
|
+
// it’s necessary to use dynamic import to load the Rush SDK.
|
|
42
|
+
const Rush = await Promise.resolve().then(() => __importStar(require('@rushstack/rush-sdk')));
|
|
43
|
+
const rushConfiguration = Rush.RushConfiguration.loadFromDefaultLocation();
|
|
44
|
+
return rushConfiguration;
|
|
45
|
+
};
|
|
46
|
+
exports.getRushConfiguration = getRushConfiguration;
|
|
47
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/utilities/common.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKpD,MAAM,oBAAoB,GAAG,KAAK,IAAgC,EAAE;IACzE,sFAAsF;IACtF,6DAA6D;IAC7D,MAAM,IAAI,GAAmB,wDAAa,qBAAqB,GAAC,CAAC;IACjE,MAAM,iBAAiB,GAAsB,IAAI,CAAC,iBAAiB,CAAC,uBAAuB,EAAE,CAAC;IAC9F,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as RushLib from '@rushstack/rush-sdk';\nimport type { RushConfiguration } from '@rushstack/rush-sdk';\n\nexport const getRushConfiguration = async (): Promise<RushConfiguration> => {\n // Since the MCP server is not always started from the directory of the Rush monorepo,\n // it’s necessary to use dynamic import to load the Rush SDK.\n const Rush: typeof RushLib = await import('@rushstack/rush-sdk');\n const rushConfiguration: RushConfiguration = Rush.RushConfiguration.loadFromDefaultLocation();\n return rushConfiguration;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utilities/log.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAA2B,MAAM,qBAAqB,CAAC;AAExE,eAAO,MAAM,QAAQ,EAAE,QAA8E,CAAC;AAGtG,wBAAgB,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAEjE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.terminal = void 0;
|
|
6
|
+
exports.log = log;
|
|
7
|
+
const terminal_1 = require("@rushstack/terminal");
|
|
8
|
+
exports.terminal = new terminal_1.Terminal(new terminal_1.ConsoleTerminalProvider({ verboseEnabled: true }));
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
function log(message, ...optionalParams) {
|
|
11
|
+
exports.terminal.writeErrorLine(message, ...optionalParams);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utilities/log.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAO3D,kBAEC;AAPD,kDAAwE;AAE3D,QAAA,QAAQ,GAAa,IAAI,mBAAQ,CAAC,IAAI,kCAAuB,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAEtG,8DAA8D;AAC9D,SAAgB,GAAG,CAAC,OAAa,EAAE,GAAG,cAAqB;IACzD,gBAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC;AACtD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';\n\nexport const terminal: Terminal = new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function log(message?: any, ...optionalParams: any[]): void {\n terminal.writeErrorLine(message, ...optionalParams);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A Model Context Protocol server implementation for Rush",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,14 +17,18 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "~1.10.2",
|
|
21
|
+
"zod": "~3.24.3",
|
|
22
|
+
"@rushstack/terminal": "0.15.3",
|
|
23
|
+
"@rushstack/rush-sdk": "5.153.1",
|
|
20
24
|
"@rushstack/node-core-library": "5.13.1",
|
|
21
|
-
"@rushstack/ts-command-line": "5.0.1"
|
|
22
|
-
"@rushstack/terminal": "0.15.3"
|
|
25
|
+
"@rushstack/ts-command-line": "5.0.1"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"typescript": "~5.8.2",
|
|
26
|
-
"@
|
|
27
|
-
"local-node-rig": "1.0.0"
|
|
29
|
+
"@types/node": "20.17.19",
|
|
30
|
+
"local-node-rig": "1.0.0",
|
|
31
|
+
"@rushstack/heft": "0.73.5"
|
|
28
32
|
},
|
|
29
33
|
"scripts": {
|
|
30
34
|
"build": "heft build --clean",
|