@tsed/cli 7.0.0-beta.5 → 7.0.0-beta.7
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/ts-mode.js +10 -0
- package/lib/esm/bin/tsed.js +1 -1
- package/lib/esm/commands/init/config/FeaturesPrompt.js +6 -7
- package/lib/esm/commands/init/config/InitSchema.js +331 -302
- package/lib/esm/commands/init/prompts/getFeaturesPrompt.js +1 -1
- package/lib/esm/commands/mcp/resources/index.js +2 -1
- package/lib/esm/commands/mcp/resources/initOptionsResource.js +93 -0
- package/lib/esm/commands/mcp/schema/InitMCPSchema.js +1 -1
- package/lib/esm/commands/mcp/tools/index.js +1 -2
- package/lib/esm/commands/mcp/tools/initProjectTool.js +1 -1
- package/lib/esm/commands/run/RunCmd.js +2 -0
- package/lib/esm/processors/transformConfigFile.js +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/bin/ts-mode.d.ts +1 -0
- package/lib/types/bin/tsed.d.ts +1 -1
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +1 -7
- package/lib/types/commands/mcp/resources/initOptionsResource.d.ts +1 -0
- package/lib/types/commands/mcp/tools/index.d.ts +344 -1
- package/package.json +7 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { initOptionsResource } from "./initOptionsResource.js";
|
|
1
2
|
import { projectInfoResource } from "./projectInfoResource.js";
|
|
2
3
|
import { serverInfoResource } from "./serverInfoResource.js";
|
|
3
|
-
export default [serverInfoResource, projectInfoResource];
|
|
4
|
+
export default [serverInfoResource, projectInfoResource, initOptionsResource];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineResource } from "@tsed/cli-mcp";
|
|
2
|
+
import { InitMCPSchema } from "../schema/InitMCPSchema.js";
|
|
3
|
+
function stripCliFlags(payload) {
|
|
4
|
+
if (Array.isArray(payload)) {
|
|
5
|
+
return payload.map(stripCliFlags);
|
|
6
|
+
}
|
|
7
|
+
if (payload && typeof payload === "object") {
|
|
8
|
+
return Object.entries(payload).reduce((acc, [key, value]) => {
|
|
9
|
+
if (key === "x-opt") {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
acc[key] = stripCliFlags(value);
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
return payload;
|
|
17
|
+
}
|
|
18
|
+
function buildSection(key, property) {
|
|
19
|
+
const title = property["x-label"] || "";
|
|
20
|
+
if (!title) {
|
|
21
|
+
return "";
|
|
22
|
+
}
|
|
23
|
+
const choices = property["x-choices"] || property["items"]?.["x-choices"] || property["enum"] || [];
|
|
24
|
+
if (!choices.length) {
|
|
25
|
+
return `${title}?\n`;
|
|
26
|
+
}
|
|
27
|
+
const lines = [title + (property.type === "array" ? "(multiple choices possible)" : "")];
|
|
28
|
+
const loop = (items, indent) => {
|
|
29
|
+
if (!Array.isArray(items)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (const entry of items) {
|
|
33
|
+
const label = entry.label || entry.value;
|
|
34
|
+
if (!label) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
lines.push(`${" ".repeat(indent)}- ${label}`);
|
|
38
|
+
if (entry.items?.length) {
|
|
39
|
+
loop(entry.items, indent + 4);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
loop(choices, 4);
|
|
44
|
+
lines.push("");
|
|
45
|
+
const xSchemaPath = `#/schema.properties.${key}`;
|
|
46
|
+
if (property["x-choices"] || property["items"]?.["x-choices"]) {
|
|
47
|
+
const xChoicesPath = property.type === "array" ? `${xSchemaPath}.items.x-choices` : `${xSchemaPath}.x-choices`;
|
|
48
|
+
lines.push(`> LLM note only: labels/values mapping is here \`${xChoicesPath}\` and schema is here \`${xSchemaPath}\``);
|
|
49
|
+
lines.push("");
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
lines.push(`> LLM note only: schema is here \`${xSchemaPath}\``);
|
|
53
|
+
lines.push("");
|
|
54
|
+
}
|
|
55
|
+
return lines.join("\n");
|
|
56
|
+
}
|
|
57
|
+
function buildInstructions(schema) {
|
|
58
|
+
const properties = schema.properties || {};
|
|
59
|
+
return Object.entries(properties)
|
|
60
|
+
.map(([key, definition], index) => {
|
|
61
|
+
const property = definition;
|
|
62
|
+
const result = buildSection(key, property);
|
|
63
|
+
return result ? `${index + 1}) ${result}` : property;
|
|
64
|
+
})
|
|
65
|
+
.join("\n");
|
|
66
|
+
}
|
|
67
|
+
export const initOptionsResource = defineResource({
|
|
68
|
+
name: "init-options",
|
|
69
|
+
uri: "tsed://init/options",
|
|
70
|
+
title: "Inspect Ts.ED init options",
|
|
71
|
+
description: "Returns curated Ts.ED init instructions plus the machine-readable schema so assistants can gather user preferences then call `init-project`. Show humans only the labels; use the provided mapping to translate back to enum values.",
|
|
72
|
+
mimeType: "application/json",
|
|
73
|
+
async handler(uri) {
|
|
74
|
+
const rawSchema = InitMCPSchema().omit("cwd", "tsedVersion").toJSON({
|
|
75
|
+
useAlias: false,
|
|
76
|
+
customKeys: true
|
|
77
|
+
});
|
|
78
|
+
const schema = stripCliFlags(rawSchema);
|
|
79
|
+
const payload = {
|
|
80
|
+
instructions: buildInstructions(schema),
|
|
81
|
+
schema
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
contents: [
|
|
85
|
+
{
|
|
86
|
+
uri: uri.href,
|
|
87
|
+
mimeType: "application/json",
|
|
88
|
+
text: JSON.stringify(payload, null, 2)
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
});
|
|
@@ -5,5 +5,5 @@ export const InitMCPSchema = () => {
|
|
|
5
5
|
.object({
|
|
6
6
|
cwd: s.string().required().description("Current working directory to initialize Ts.ED project")
|
|
7
7
|
})
|
|
8
|
-
.merge(InitSchema().omit("root", "skipPrompt", "file"));
|
|
8
|
+
.merge(InitSchema().omit("root", "skipPrompt", "file", "GH_TOKEN"));
|
|
9
9
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { projectInfoResource } from "../resources/projectInfoResource.js";
|
|
2
1
|
import { generateTool } from "./generateTool.js";
|
|
3
2
|
import { getTemplateTool } from "./getTemplateTool.js";
|
|
4
3
|
import { initProjectTool } from "./initProjectTool.js";
|
|
5
4
|
import { listTemplatesTool } from "./listTemplatesTool.js";
|
|
6
5
|
import { setWorkspaceTool } from "./setWorkspaceTool.js";
|
|
7
|
-
export default [setWorkspaceTool,
|
|
6
|
+
export default [setWorkspaceTool, listTemplatesTool, getTemplateTool, generateTool, initProjectTool];
|
|
@@ -7,7 +7,7 @@ import { InitMCPSchema } from "../schema/InitMCPSchema.js";
|
|
|
7
7
|
export const initProjectTool = defineTool({
|
|
8
8
|
name: "init-project",
|
|
9
9
|
title: "Initialize Ts.ED project",
|
|
10
|
-
description: "Initialize a new Ts.ED project in the current workspace
|
|
10
|
+
description: "Initialize a new Ts.ED project in the current workspace. Fetch `tsed://init/options`, ask the user which platform, features, and other options they want, then pass the selected values here along with `cwd`.",
|
|
11
11
|
inputSchema: InitMCPSchema,
|
|
12
12
|
outputSchema: s.object({
|
|
13
13
|
files: s.array().items(s.string()).description("List of generated files."),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliFs, command, inject, normalizePath, ProjectPackageJson } from "@tsed/cli-core";
|
|
2
|
+
import { logger } from "@tsed/di";
|
|
2
3
|
import { CliRunScript } from "../../services/CliRunScript.js";
|
|
3
4
|
export class RunCmd {
|
|
4
5
|
constructor() {
|
|
@@ -10,6 +11,7 @@ export class RunCmd {
|
|
|
10
11
|
const cmd = "node";
|
|
11
12
|
const args = ["--import", "@swc-node/register/esm-register"];
|
|
12
13
|
const path = normalizePath("src/bin/index.ts");
|
|
14
|
+
logger().info(`Run ${cmd} ${[...args, path, ctx.command, ...ctx.rawArgs].join(" ")}`);
|
|
13
15
|
await this.runScript.run(cmd, [...args, path, ctx.command, ...ctx.rawArgs], {
|
|
14
16
|
env: process.env
|
|
15
17
|
});
|