@tsed/cli 7.0.0-beta.3 → 7.0.0-beta.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/lib/esm/bin/tsed.js +3 -1
- package/lib/esm/commands/add/AddCmd.js +2 -1
- package/lib/esm/commands/generate/GenerateCmd.js +2 -1
- package/lib/esm/commands/index.js +3 -1
- package/lib/esm/commands/init/InitCmd.js +10 -103
- package/lib/esm/commands/init/InitOptionsCmd.js +17 -0
- package/lib/esm/commands/init/config/FeaturesPrompt.js +29 -29
- package/lib/esm/commands/init/config/InitSchema.js +297 -16
- package/lib/esm/commands/mcp/McpCommand.js +15 -0
- package/lib/esm/commands/mcp/schema/InitMCPSchema.js +9 -0
- package/lib/esm/{mcp → commands/mcp}/schema/ProjectPreferencesSchema.js +2 -2
- package/lib/esm/{mcp → commands/mcp}/tools/generateTool.js +3 -3
- package/lib/esm/{mcp → commands/mcp}/tools/getTemplateTool.js +2 -2
- package/lib/esm/{mcp → commands/mcp}/tools/index.js +2 -1
- package/lib/esm/commands/mcp/tools/initProjectTool.js +64 -0
- package/lib/esm/{mcp → commands/mcp}/tools/listTemplatesTool.js +2 -2
- package/lib/esm/commands/run/RunCmd.js +2 -1
- package/lib/esm/commands/template/CreateTemplateCommand.js +2 -1
- package/lib/esm/commands/update/UpdateCmd.js +3 -4
- package/lib/esm/index.js +2 -2
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/commands/index.d.ts +103 -1
- package/lib/types/commands/init/InitCmd.d.ts +1 -4
- package/lib/types/commands/init/InitOptionsCmd.d.ts +52 -0
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +25 -25
- package/lib/types/commands/init/config/InitSchema.d.ts +12 -7
- package/lib/types/commands/mcp/McpCommand.d.ts +52 -0
- package/lib/types/commands/mcp/schema/InitMCPSchema.d.ts +5 -0
- package/lib/types/{mcp → commands/mcp}/schema/ProjectPreferencesSchema.d.ts +2 -2
- package/lib/types/{mcp → commands/mcp}/tools/generateTool.d.ts +45 -17
- package/lib/types/{mcp → commands/mcp}/tools/getTemplateTool.d.ts +45 -17
- package/lib/types/commands/mcp/tools/initProjectTool.d.ts +116 -0
- package/lib/types/{mcp → commands/mcp}/tools/listTemplatesTool.d.ts +45 -17
- package/lib/types/{mcp → commands/mcp}/tools/setWorkspaceTool.d.ts +45 -17
- package/lib/types/index.d.ts +2 -2
- package/lib/types/interfaces/InitCmdOptions.d.ts +1 -1
- package/package.json +14 -14
- package/lib/esm/bin/tsed-mcp.js +0 -42
- package/lib/types/bin/tsed-mcp.d.ts +0 -2
- /package/lib/esm/{mcp → commands/mcp}/resources/index.js +0 -0
- /package/lib/esm/{mcp → commands/mcp}/resources/projectInfoResource.js +0 -0
- /package/lib/esm/{mcp → commands/mcp}/resources/serverInfoResource.js +0 -0
- /package/lib/esm/{mcp → commands/mcp}/tools/setWorkspaceTool.js +0 -0
- /package/lib/types/{mcp → commands/mcp}/resources/index.d.ts +0 -0
- /package/lib/types/{mcp → commands/mcp}/resources/projectInfoResource.d.ts +0 -0
- /package/lib/types/{mcp → commands/mcp}/resources/serverInfoResource.d.ts +0 -0
- /package/lib/types/{mcp → commands/mcp}/tools/index.d.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { s } from "@tsed/schema";
|
|
2
|
+
import { InitSchema } from "../../init/config/InitSchema.js";
|
|
3
|
+
export const InitMCPSchema = () => {
|
|
4
|
+
return s
|
|
5
|
+
.object({
|
|
6
|
+
cwd: s.string().required().description("Current working directory to initialize Ts.ED project")
|
|
7
|
+
})
|
|
8
|
+
.merge(InitSchema().omit("root", "skipPrompt", "file"));
|
|
9
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PackageManager } from "@tsed/cli-core";
|
|
2
2
|
import { s } from "@tsed/schema";
|
|
3
|
-
import { PlatformType } from "
|
|
4
|
-
import { ProjectConvention } from "
|
|
3
|
+
import { PlatformType } from "../../../interfaces/PlatformType.js";
|
|
4
|
+
import { ProjectConvention } from "../../../interfaces/ProjectConvention.js";
|
|
5
5
|
export const ProjectPreferenceSchema = s
|
|
6
6
|
.object({
|
|
7
7
|
convention: s.string().enum(ProjectConvention).description("Project convention (Ts.ED or Angular style)"),
|
|
@@ -2,9 +2,9 @@ import { ProjectPackageJson, validate } from "@tsed/cli-core";
|
|
|
2
2
|
import { defineTool } from "@tsed/cli-mcp";
|
|
3
3
|
import { inject } from "@tsed/di";
|
|
4
4
|
import { array, number, object, string } from "@tsed/schema";
|
|
5
|
-
import { CliProjectService } from "
|
|
6
|
-
import { CliTemplatesService } from "
|
|
7
|
-
import { mapDefaultTemplateOptions } from "
|
|
5
|
+
import { CliProjectService } from "../../../services/CliProjectService.js";
|
|
6
|
+
import { CliTemplatesService } from "../../../services/CliTemplatesService.js";
|
|
7
|
+
import { mapDefaultTemplateOptions } from "../../../services/mappers/mapDefaultTemplateOptions.js";
|
|
8
8
|
export const generateTool = defineTool({
|
|
9
9
|
name: "generate-file",
|
|
10
10
|
title: "Generate file",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineTool } from "@tsed/cli-mcp";
|
|
2
2
|
import { inject } from "@tsed/di";
|
|
3
3
|
import { s } from "@tsed/schema";
|
|
4
|
-
import { CliTemplatesService } from "
|
|
5
|
-
import { resolveSchema } from "
|
|
4
|
+
import { CliTemplatesService } from "../../../services/CliTemplatesService.js";
|
|
5
|
+
import { resolveSchema } from "../../../utils/resolveSchema.js";
|
|
6
6
|
export const getTemplateTool = defineTool({
|
|
7
7
|
name: "get-template",
|
|
8
8
|
title: "Get template",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { projectInfoResource } from "../resources/projectInfoResource.js";
|
|
2
2
|
import { generateTool } from "./generateTool.js";
|
|
3
3
|
import { getTemplateTool } from "./getTemplateTool.js";
|
|
4
|
+
import { initProjectTool } from "./initProjectTool.js";
|
|
4
5
|
import { listTemplatesTool } from "./listTemplatesTool.js";
|
|
5
6
|
import { setWorkspaceTool } from "./setWorkspaceTool.js";
|
|
6
|
-
export default [setWorkspaceTool, projectInfoResource, listTemplatesTool, getTemplateTool, generateTool];
|
|
7
|
+
export default [setWorkspaceTool, projectInfoResource, listTemplatesTool, getTemplateTool, generateTool, initProjectTool];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CliService, ProjectPackageJson } from "@tsed/cli-core";
|
|
2
|
+
import { defineTool } from "@tsed/cli-mcp";
|
|
3
|
+
import { context, inject } from "@tsed/di";
|
|
4
|
+
import { s } from "@tsed/schema";
|
|
5
|
+
import { CliTemplatesService } from "../../../services/CliTemplatesService.js";
|
|
6
|
+
import { InitMCPSchema } from "../schema/InitMCPSchema.js";
|
|
7
|
+
export const initProjectTool = defineTool({
|
|
8
|
+
name: "init-project",
|
|
9
|
+
title: "Initialize Ts.ED project",
|
|
10
|
+
description: "Initialize a new Ts.ED project in the current workspace (sans Listr/logs).",
|
|
11
|
+
inputSchema: InitMCPSchema,
|
|
12
|
+
outputSchema: s.object({
|
|
13
|
+
files: s.array().items(s.string()).description("List of generated files."),
|
|
14
|
+
count: s.number().description("Number of files generated."),
|
|
15
|
+
projectName: s.string().optional().description("Resolved project name."),
|
|
16
|
+
cwd: s.string().optional().description("Resolved workspace directory in which the project was initialized."),
|
|
17
|
+
logs: s.array().items(s.string()).optional().description("Execution logs"),
|
|
18
|
+
warnings: s.array().items(s.string()).optional().description("Non blocking warnings")
|
|
19
|
+
}),
|
|
20
|
+
async handler(input) {
|
|
21
|
+
const cliService = inject(CliService);
|
|
22
|
+
const projectPackage = inject(ProjectPackageJson);
|
|
23
|
+
const templates = inject(CliTemplatesService);
|
|
24
|
+
projectPackage.setCWD(input.cwd);
|
|
25
|
+
// If the current workspace already looks initialized, block to prevent accidental re-init
|
|
26
|
+
if (projectPackage.preferences?.packageManager) {
|
|
27
|
+
return {
|
|
28
|
+
content: [],
|
|
29
|
+
isError: true,
|
|
30
|
+
structuredContent: {
|
|
31
|
+
code: "E_PROJECT_ALREADY_INITIALIZED",
|
|
32
|
+
message: "This workspace already appears to be an initialized Ts.ED project.",
|
|
33
|
+
suggestion: "Use 'generate-file' to add new files, or call 'set-workspace' with a different folder to initialize a new project."
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const warnings = [];
|
|
38
|
+
// Build options and map context (skip prompts by default)
|
|
39
|
+
const initialOptions = {
|
|
40
|
+
skipPrompt: true,
|
|
41
|
+
...input
|
|
42
|
+
};
|
|
43
|
+
await cliService.exec("init", initialOptions, context());
|
|
44
|
+
// Collect rendered files from templates service (same pattern as generateTool)
|
|
45
|
+
const rendered = templates.getRenderedFiles();
|
|
46
|
+
const files = rendered.map((f) => f.outputPath);
|
|
47
|
+
const logs = [
|
|
48
|
+
`init:root:${projectPackage.cwd ?? "."}`,
|
|
49
|
+
`init:platform:${projectPackage.preferences.platform}`,
|
|
50
|
+
`files:${files.length}`
|
|
51
|
+
];
|
|
52
|
+
return {
|
|
53
|
+
content: [],
|
|
54
|
+
structuredContent: {
|
|
55
|
+
files,
|
|
56
|
+
count: files.length,
|
|
57
|
+
projectName: projectPackage.name,
|
|
58
|
+
cwd: projectPackage.cwd,
|
|
59
|
+
logs,
|
|
60
|
+
warnings: warnings.length ? warnings : undefined
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineTool } from "@tsed/cli-mcp";
|
|
2
2
|
import { inject } from "@tsed/di";
|
|
3
3
|
import { array, object, string } from "@tsed/schema";
|
|
4
|
-
import { CliTemplatesService } from "
|
|
5
|
-
import { summarizeSchema } from "
|
|
4
|
+
import { CliTemplatesService } from "../../../services/CliTemplatesService.js";
|
|
5
|
+
import { summarizeSchema } from "../../../utils/summarizeSchema.js";
|
|
6
6
|
export const listTemplatesTool = defineTool({
|
|
7
7
|
name: "list-templates",
|
|
8
8
|
title: "List templates",
|
|
@@ -97,9 +97,8 @@ export class UpdateCmd {
|
|
|
97
97
|
return version && isGreaterThan(version, this.cliPackage.version) ? version : this.cliPackage.version;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
command(
|
|
100
|
+
command({
|
|
101
|
+
token: UpdateCmd,
|
|
101
102
|
name: "update",
|
|
102
|
-
description: "Update all Ts.ED packages used by your project"
|
|
103
|
-
args: {},
|
|
104
|
-
options: {}
|
|
103
|
+
description: "Update all Ts.ED packages used by your project"
|
|
105
104
|
});
|
package/lib/esm/index.js
CHANGED
|
@@ -8,13 +8,13 @@ export * from "./commands/init/config/FeaturesPrompt.js";
|
|
|
8
8
|
export * from "./commands/init/config/FeaturesPrompt.js";
|
|
9
9
|
export * from "./commands/init/InitCmd.js";
|
|
10
10
|
export * from "./commands/init/prompts/getFeaturesPrompt.js";
|
|
11
|
+
export { default as resources } from "./commands/mcp/resources/index.js";
|
|
12
|
+
export { default as tools } from "./commands/mcp/tools/index.js";
|
|
11
13
|
export * from "./commands/update/UpdateCmd.js";
|
|
12
14
|
export * from "./constants/index.js";
|
|
13
15
|
export * from "./fn/exec.js";
|
|
14
16
|
export * from "./fn/render.js";
|
|
15
17
|
export * from "./interfaces/index.js";
|
|
16
|
-
export { default as resources } from "./mcp/resources/index.js";
|
|
17
|
-
export { default as tools } from "./mcp/tools/index.js";
|
|
18
18
|
export * from "./pipes/index.js";
|
|
19
19
|
export * from "./runtimes/index.js";
|
|
20
20
|
export * from "./services/CliProjectService.js";
|