@agiflowai/scaffold-mcp 1.0.26 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ListScaffoldingMethodsTool-DBwZzJTA.cjs → ListScaffoldingMethodsTool-CYZtpU-W.cjs} +109 -126
- package/dist/{ListScaffoldingMethodsTool-D6BkKQyK.mjs → ListScaffoldingMethodsTool-DxdrPlcb.mjs} +32 -44
- package/dist/{claudeCode-B6CWgRYJ.cjs → claudeCode-BxcEboyM.cjs} +54 -57
- package/dist/{claudeCode-Dozuzn4S.mjs → claudeCode-DNgNiLlL.mjs} +7 -10
- package/dist/cli.cjs +141 -147
- package/dist/cli.mjs +9 -15
- package/dist/{geminiCli-COS3X1P7.cjs → geminiCli--s1Qy7ZP.cjs} +35 -37
- package/dist/{geminiCli-CzgQDDMl.mjs → geminiCli-CcrZEqsz.mjs} +3 -5
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +3 -7
- package/dist/index.d.mts +3 -9
- package/dist/index.mjs +4 -5
- package/dist/{shared-oDx2Btq0.mjs → shared-BVYIN3Is.mjs} +4 -10
- package/dist/{shared-fkWett9D.cjs → shared-QxPXh-L-.cjs} +17 -23
- package/dist/{src-sY88BbkJ.mjs → src-BEwgHhCT.mjs} +12 -30
- package/dist/{src-DxoKQE4s.cjs → src-oF_UdSBu.cjs} +59 -77
- package/dist/{tools-DsnQImJ1.cjs → tools-CVSZSirE.cjs} +103 -109
- package/dist/{tools-t-HMGLVh.mjs → tools-Cl06aoBi.mjs} +13 -19
- package/package.json +21 -21
package/dist/cli.cjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_ListScaffoldingMethodsTool = require(
|
|
3
|
-
const require_src = require(
|
|
4
|
-
const require_tools = require(
|
|
5
|
-
let
|
|
2
|
+
const require_ListScaffoldingMethodsTool = require("./ListScaffoldingMethodsTool-CYZtpU-W.cjs");
|
|
3
|
+
const require_src = require("./src-oF_UdSBu.cjs");
|
|
4
|
+
const require_tools = require("./tools-CVSZSirE.cjs");
|
|
5
|
+
let _agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
|
-
node_path = require_ListScaffoldingMethodsTool.__toESM(node_path);
|
|
7
|
+
node_path = require_ListScaffoldingMethodsTool.__toESM(node_path, 1);
|
|
8
8
|
let commander = require("commander");
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
|
|
9
|
+
let _agiflowai_coding_agent_bridge = require("@agiflowai/coding-agent-bridge");
|
|
10
|
+
let _agiflowai_hooks_adapter = require("@agiflowai/hooks-adapter");
|
|
12
11
|
//#region src/commands/boilerplate.ts
|
|
13
12
|
/**
|
|
14
13
|
* Boilerplate CLI command
|
|
@@ -16,40 +15,40 @@ let __agiflowai_hooks_adapter = require("@agiflowai/hooks-adapter");
|
|
|
16
15
|
const boilerplateCommand = new commander.Command("boilerplate").description("Manage boilerplate templates");
|
|
17
16
|
boilerplateCommand.command("list").description("List all available boilerplate templates").option("-c, --cursor <cursor>", "Pagination cursor for next page").action(async (options) => {
|
|
18
17
|
try {
|
|
19
|
-
const templatesDir = await
|
|
18
|
+
const templatesDir = await _agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
20
19
|
if (!templatesDir) {
|
|
21
|
-
|
|
20
|
+
_agiflowai_aicode_utils.messages.error("Templates folder not found. Create a templates folder or specify templatesPath in toolkit.yaml");
|
|
22
21
|
process.exit(1);
|
|
23
22
|
}
|
|
24
23
|
const { boilerplates, nextCursor } = await new require_tools.BoilerplateService(templatesDir).listBoilerplates(options.cursor);
|
|
25
24
|
if (boilerplates.length === 0) {
|
|
26
|
-
|
|
25
|
+
_agiflowai_aicode_utils.messages.warning("No boilerplate templates found.");
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
_agiflowai_aicode_utils.print.header(`\n${_agiflowai_aicode_utils.icons.package} Available Boilerplate Templates:\n`);
|
|
30
29
|
for (const bp of boilerplates) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
_agiflowai_aicode_utils.print.highlight(` ${bp.name}`);
|
|
31
|
+
_agiflowai_aicode_utils.print.debug(` ${bp.description}`);
|
|
32
|
+
_agiflowai_aicode_utils.print.debug(` Target: ${bp.target_folder}`);
|
|
34
33
|
const required = typeof bp.variables_schema === "object" && bp.variables_schema !== null && "required" in bp.variables_schema ? bp.variables_schema.required : [];
|
|
35
|
-
if (required && required.length > 0)
|
|
36
|
-
|
|
34
|
+
if (required && required.length > 0) _agiflowai_aicode_utils.print.debug(` Required: ${required.join(", ")}`);
|
|
35
|
+
_agiflowai_aicode_utils.print.newline();
|
|
37
36
|
}
|
|
38
37
|
if (nextCursor) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
_agiflowai_aicode_utils.print.newline();
|
|
39
|
+
_agiflowai_aicode_utils.print.info(`${_agiflowai_aicode_utils.icons.info} More results available. Use --cursor to fetch next page:`);
|
|
40
|
+
_agiflowai_aicode_utils.print.debug(` scaffold-mcp boilerplate list --cursor "${nextCursor}"`);
|
|
42
41
|
}
|
|
43
42
|
} catch (error) {
|
|
44
|
-
|
|
43
|
+
_agiflowai_aicode_utils.messages.error("Error listing boilerplates:", error);
|
|
45
44
|
process.exit(1);
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
47
|
boilerplateCommand.command("create <boilerplateName>").description("Create a new project from a boilerplate template").option("-v, --vars <json>", "JSON string containing variables for the boilerplate").option("-m, --monolith", "Create as monolith project at workspace root with toolkit.yaml (default: false, creates as monorepo with project.json)").option("-t, --target-folder <path>", "Override target folder (defaults to boilerplate targetFolder for monorepo, workspace root for monolith)").option("--verbose", "Enable verbose logging").action(async (boilerplateName, options) => {
|
|
49
48
|
try {
|
|
50
|
-
const templatesDir = await
|
|
49
|
+
const templatesDir = await _agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
51
50
|
if (!templatesDir) {
|
|
52
|
-
|
|
51
|
+
_agiflowai_aicode_utils.messages.error("Templates folder not found. Create a templates folder or specify templatesPath in toolkit.yaml");
|
|
53
52
|
process.exit(1);
|
|
54
53
|
}
|
|
55
54
|
const boilerplateService = new require_tools.BoilerplateService(templatesDir);
|
|
@@ -57,8 +56,8 @@ boilerplateCommand.command("create <boilerplateName>").description("Create a new
|
|
|
57
56
|
if (options.vars) try {
|
|
58
57
|
variables = JSON.parse(options.vars);
|
|
59
58
|
} catch (error) {
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
_agiflowai_aicode_utils.messages.error("Error parsing variables JSON:", error);
|
|
60
|
+
_agiflowai_aicode_utils.messages.hint("Example: --vars '{\"appName\": \"my-app\", \"description\": \"My application\"}'");
|
|
62
61
|
process.exit(1);
|
|
63
62
|
}
|
|
64
63
|
const boilerplate = await boilerplateService.getBoilerplate(boilerplateName);
|
|
@@ -66,31 +65,31 @@ boilerplateCommand.command("create <boilerplateName>").description("Create a new
|
|
|
66
65
|
let allBoilerplates = [];
|
|
67
66
|
let cursor;
|
|
68
67
|
do {
|
|
69
|
-
const result
|
|
70
|
-
allBoilerplates = allBoilerplates.concat(result
|
|
71
|
-
cursor = result
|
|
68
|
+
const result = await boilerplateService.listBoilerplates(cursor);
|
|
69
|
+
allBoilerplates = allBoilerplates.concat(result.boilerplates);
|
|
70
|
+
cursor = result.nextCursor;
|
|
72
71
|
} while (cursor);
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
_agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
|
|
73
|
+
_agiflowai_aicode_utils.print.warning(`Available boilerplates: ${allBoilerplates.map((b) => b.name).join(", ")}`);
|
|
75
74
|
process.exit(1);
|
|
76
75
|
}
|
|
77
76
|
const required = typeof boilerplate.variables_schema === "object" && boilerplate.variables_schema !== null && "required" in boilerplate.variables_schema ? boilerplate.variables_schema.required : [];
|
|
78
77
|
const missing = required.filter((key) => !variables[key]);
|
|
79
78
|
if (missing.length > 0) {
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
_agiflowai_aicode_utils.messages.error(`Missing required variables: ${missing.join(", ")}`);
|
|
80
|
+
_agiflowai_aicode_utils.messages.hint(`Use --vars with a JSON object containing: ${missing.join(", ")}`);
|
|
82
81
|
const exampleVars = {};
|
|
83
82
|
for (const key of required) if (key === "appName" || key === "packageName") exampleVars[key] = "my-app";
|
|
84
83
|
else if (key === "description") exampleVars[key] = "My application description";
|
|
85
84
|
else exampleVars[key] = `<${key}>`;
|
|
86
|
-
|
|
85
|
+
_agiflowai_aicode_utils.print.debug(`Example: scaffold-mcp boilerplate create ${boilerplateName} --vars '${JSON.stringify(exampleVars)}'`);
|
|
87
86
|
process.exit(1);
|
|
88
87
|
}
|
|
89
88
|
if (options.verbose) {
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
_agiflowai_aicode_utils.print.info(`${_agiflowai_aicode_utils.icons.wrench} Boilerplate: ${boilerplateName}`);
|
|
90
|
+
_agiflowai_aicode_utils.print.info(`${_agiflowai_aicode_utils.icons.chart} Variables: ${JSON.stringify(variables, null, 2)}`);
|
|
92
91
|
}
|
|
93
|
-
|
|
92
|
+
_agiflowai_aicode_utils.messages.loading(`Creating project from boilerplate '${boilerplateName}'...`);
|
|
94
93
|
const result = await boilerplateService.useBoilerplate({
|
|
95
94
|
boilerplateName,
|
|
96
95
|
variables,
|
|
@@ -98,9 +97,9 @@ boilerplateCommand.command("create <boilerplateName>").description("Create a new
|
|
|
98
97
|
targetFolderOverride: options.targetFolder
|
|
99
98
|
});
|
|
100
99
|
if (result.success) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (result.createdFiles && result.createdFiles.length > 0)
|
|
100
|
+
_agiflowai_aicode_utils.messages.success("Project created successfully!");
|
|
101
|
+
_agiflowai_aicode_utils.print.info(result.message);
|
|
102
|
+
if (result.createdFiles && result.createdFiles.length > 0) _agiflowai_aicode_utils.sections.createdFiles(result.createdFiles);
|
|
104
103
|
const projectName = variables.appName || variables.packageName;
|
|
105
104
|
if (projectName) {
|
|
106
105
|
const targetFolder = options.targetFolder || (options.monolith ? "." : boilerplate.target_folder);
|
|
@@ -110,43 +109,42 @@ boilerplateCommand.command("create <boilerplateName>").description("Create a new
|
|
|
110
109
|
"pnpm install",
|
|
111
110
|
"pnpm dev"
|
|
112
111
|
];
|
|
113
|
-
|
|
112
|
+
_agiflowai_aicode_utils.sections.nextSteps(steps);
|
|
114
113
|
}
|
|
115
114
|
} else {
|
|
116
|
-
|
|
115
|
+
_agiflowai_aicode_utils.messages.error(`Failed to create project: ${result.message}`);
|
|
117
116
|
process.exit(1);
|
|
118
117
|
}
|
|
119
118
|
} catch (error) {
|
|
120
|
-
|
|
119
|
+
_agiflowai_aicode_utils.messages.error("Error creating project:", error);
|
|
121
120
|
if (options.verbose) console.error("Stack trace:", error.stack);
|
|
122
121
|
process.exit(1);
|
|
123
122
|
}
|
|
124
123
|
});
|
|
125
124
|
boilerplateCommand.command("info <boilerplateName>").description("Show detailed information about a boilerplate template").action(async (boilerplateName) => {
|
|
126
125
|
try {
|
|
127
|
-
const templatesDir = await
|
|
126
|
+
const templatesDir = await _agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
128
127
|
if (!templatesDir) {
|
|
129
|
-
|
|
128
|
+
_agiflowai_aicode_utils.messages.error("Templates folder not found. Create a templates folder or specify templatesPath in toolkit.yaml");
|
|
130
129
|
process.exit(1);
|
|
131
130
|
}
|
|
132
131
|
const bp = await new require_tools.BoilerplateService(templatesDir).getBoilerplate(boilerplateName);
|
|
133
132
|
if (!bp) {
|
|
134
|
-
|
|
133
|
+
_agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
|
|
135
134
|
process.exit(1);
|
|
136
135
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
_agiflowai_aicode_utils.print.header(`\n${_agiflowai_aicode_utils.icons.package} Boilerplate: ${bp.name}\n`);
|
|
137
|
+
_agiflowai_aicode_utils.print.debug(`Description: ${bp.description}`);
|
|
138
|
+
_agiflowai_aicode_utils.print.debug(`Template Path: ${bp.template_path}`);
|
|
139
|
+
_agiflowai_aicode_utils.print.debug(`Target Folder: ${bp.target_folder}`);
|
|
140
|
+
_agiflowai_aicode_utils.print.header(`\n${_agiflowai_aicode_utils.icons.config} Variables Schema:`);
|
|
142
141
|
console.log(JSON.stringify(bp.variables_schema, null, 2));
|
|
143
|
-
if (bp.includes && bp.includes.length > 0)
|
|
142
|
+
if (bp.includes && bp.includes.length > 0) _agiflowai_aicode_utils.sections.list(`${_agiflowai_aicode_utils.icons.folder} Included Files:`, bp.includes);
|
|
144
143
|
} catch (error) {
|
|
145
|
-
|
|
144
|
+
_agiflowai_aicode_utils.messages.error("Error getting boilerplate info:", error);
|
|
146
145
|
process.exit(1);
|
|
147
146
|
}
|
|
148
147
|
});
|
|
149
|
-
|
|
150
148
|
//#endregion
|
|
151
149
|
//#region src/commands/mcp-serve.ts
|
|
152
150
|
/**
|
|
@@ -180,7 +178,7 @@ function isRecord(value) {
|
|
|
180
178
|
*/
|
|
181
179
|
function parseLlmToolOption(value, flagName) {
|
|
182
180
|
if (!value) return void 0;
|
|
183
|
-
if (!(0,
|
|
181
|
+
if (!(0, _agiflowai_coding_agent_bridge.isValidLlmTool)(value)) throw new Error(`Invalid ${flagName}: ${value}. Supported: ${_agiflowai_coding_agent_bridge.SUPPORTED_LLM_TOOLS.join(", ")}`);
|
|
184
182
|
return value;
|
|
185
183
|
}
|
|
186
184
|
/**
|
|
@@ -217,12 +215,12 @@ async function startServer(handler) {
|
|
|
217
215
|
throw new Error(`Failed to start transport: ${error instanceof Error ? error.message : String(error)}`);
|
|
218
216
|
}
|
|
219
217
|
const shutdown = async (signal) => {
|
|
220
|
-
|
|
218
|
+
_agiflowai_aicode_utils.print.error(`\nReceived ${signal}, shutting down gracefully...`);
|
|
221
219
|
try {
|
|
222
220
|
await handler.stop();
|
|
223
221
|
process.exit(0);
|
|
224
222
|
} catch (error) {
|
|
225
|
-
|
|
223
|
+
_agiflowai_aicode_utils.print.error("Error during shutdown:", error instanceof Error ? error : String(error));
|
|
226
224
|
process.exit(1);
|
|
227
225
|
}
|
|
228
226
|
};
|
|
@@ -230,23 +228,23 @@ async function startServer(handler) {
|
|
|
230
228
|
try {
|
|
231
229
|
await shutdown("SIGINT");
|
|
232
230
|
} catch (error) {
|
|
233
|
-
|
|
231
|
+
_agiflowai_aicode_utils.print.error("Unexpected shutdown error:", error instanceof Error ? error : String(error));
|
|
234
232
|
}
|
|
235
233
|
});
|
|
236
234
|
process.on("SIGTERM", async () => {
|
|
237
235
|
try {
|
|
238
236
|
await shutdown("SIGTERM");
|
|
239
237
|
} catch (error) {
|
|
240
|
-
|
|
238
|
+
_agiflowai_aicode_utils.print.error("Unexpected shutdown error:", error instanceof Error ? error : String(error));
|
|
241
239
|
}
|
|
242
240
|
});
|
|
243
241
|
}
|
|
244
242
|
/**
|
|
245
243
|
* MCP Serve command
|
|
246
244
|
*/
|
|
247
|
-
const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio, http, or sse").option("-p, --port <port>", "Port to listen on (http/sse only)", (val) => parseInt(val, 10)).option("--host <host>", "Host to bind to (http/sse only)").option("--admin-enable", "Enable admin tools (generate-boilerplate)", false).option("--prompt-as-skill", "Render prompts with skill front matter for Claude Code skills", false).option("--fallback-tool <tool>", `Fallback LLM tool for scaffold operations. Supported: ${
|
|
245
|
+
const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio, http, or sse").option("-p, --port <port>", "Port to listen on (http/sse only)", (val) => parseInt(val, 10)).option("--host <host>", "Host to bind to (http/sse only)").option("--admin-enable", "Enable admin tools (generate-boilerplate)", false).option("--prompt-as-skill", "Render prompts with skill front matter for Claude Code skills", false).option("--fallback-tool <tool>", `Fallback LLM tool for scaffold operations. Supported: ${_agiflowai_coding_agent_bridge.SUPPORTED_LLM_TOOLS.join(", ")}`).option("--fallback-tool-config <json>", "JSON config for fallback tool (e.g., '{\"model\":\"claude-sonnet-4-6\"}')").action(async (options) => {
|
|
248
246
|
try {
|
|
249
|
-
const fileConfig = (await
|
|
247
|
+
const fileConfig = (await _agiflowai_aicode_utils.TemplatesManagerService.readToolkitConfig())?.["scaffold-mcp"]?.["mcp-serve"] ?? {};
|
|
250
248
|
const transportType = (options.type ?? fileConfig.type ?? "stdio").toLowerCase();
|
|
251
249
|
const adminEnable = options.adminEnable || fileConfig.adminEnable || false;
|
|
252
250
|
const promptAsSkill = options.promptAsSkill || fileConfig.promptAsSkill || false;
|
|
@@ -255,9 +253,9 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
|
|
|
255
253
|
const fallbackToolConfig = options.fallbackToolConfig ? parseJsonConfig(options.fallbackToolConfig, "--fallback-tool-config") : configuredFallback.config;
|
|
256
254
|
let isMonolith = false;
|
|
257
255
|
try {
|
|
258
|
-
isMonolith = (await
|
|
256
|
+
isMonolith = (await _agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).type === "monolith";
|
|
259
257
|
} catch (error) {
|
|
260
|
-
|
|
258
|
+
_agiflowai_aicode_utils.print.info(`No project config found, defaulting to monorepo mode: ${error instanceof Error ? error.message : String(error)}`);
|
|
261
259
|
isMonolith = false;
|
|
262
260
|
}
|
|
263
261
|
const serverOptions = {
|
|
@@ -285,15 +283,14 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
|
|
|
285
283
|
host
|
|
286
284
|
}));
|
|
287
285
|
} else {
|
|
288
|
-
|
|
286
|
+
_agiflowai_aicode_utils.print.error(`Unknown transport type: ${transportType}. Use: stdio, http, or sse`);
|
|
289
287
|
process.exit(1);
|
|
290
288
|
}
|
|
291
289
|
} catch (error) {
|
|
292
|
-
|
|
290
|
+
_agiflowai_aicode_utils.print.error("Failed to start MCP server:", error instanceof Error ? error : String(error));
|
|
293
291
|
process.exit(1);
|
|
294
292
|
}
|
|
295
293
|
});
|
|
296
|
-
|
|
297
294
|
//#endregion
|
|
298
295
|
//#region src/commands/scaffold.ts
|
|
299
296
|
/**
|
|
@@ -303,15 +300,15 @@ const scaffoldCommand = new commander.Command("scaffold").description("Add featu
|
|
|
303
300
|
scaffoldCommand.command("list [projectPath]").description("List available scaffolding methods for a project or template").option("-t, --template <name>", "Template name (e.g., nextjs-15, typescript-mcp-package)").option("-c, --cursor <cursor>", "Pagination cursor for next page").action(async (projectPath, options) => {
|
|
304
301
|
try {
|
|
305
302
|
if (!projectPath && !options.template) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
303
|
+
_agiflowai_aicode_utils.messages.error("Either projectPath or --template option must be provided");
|
|
304
|
+
_agiflowai_aicode_utils.messages.hint("Examples:");
|
|
305
|
+
_agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold list ./my-project");
|
|
306
|
+
_agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold list --template nextjs-15");
|
|
310
307
|
process.exit(1);
|
|
311
308
|
}
|
|
312
|
-
const templatesDir = await
|
|
309
|
+
const templatesDir = await _agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
313
310
|
if (!templatesDir) {
|
|
314
|
-
|
|
311
|
+
_agiflowai_aicode_utils.messages.error("Templates folder not found. Create a templates folder or specify templatesPath in toolkit.yaml");
|
|
315
312
|
process.exit(1);
|
|
316
313
|
}
|
|
317
314
|
const scaffoldingMethodsService = new require_ListScaffoldingMethodsTool.ScaffoldingMethodsService(new require_ListScaffoldingMethodsTool.FileSystemService(), templatesDir);
|
|
@@ -319,9 +316,9 @@ scaffoldCommand.command("list [projectPath]").description("List available scaffo
|
|
|
319
316
|
let displayName;
|
|
320
317
|
if (projectPath) {
|
|
321
318
|
const absolutePath = node_path.default.resolve(projectPath);
|
|
322
|
-
if (!await
|
|
323
|
-
|
|
324
|
-
|
|
319
|
+
if (!await _agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(absolutePath)) {
|
|
320
|
+
_agiflowai_aicode_utils.messages.error(`No project configuration found in ${absolutePath}`);
|
|
321
|
+
_agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root\nOr use --template option to list methods for a specific template");
|
|
325
322
|
process.exit(1);
|
|
326
323
|
}
|
|
327
324
|
result = await scaffoldingMethodsService.listScaffoldingMethods(absolutePath, options.cursor);
|
|
@@ -332,47 +329,47 @@ scaffoldCommand.command("list [projectPath]").description("List available scaffo
|
|
|
332
329
|
}
|
|
333
330
|
const methods = result.methods;
|
|
334
331
|
if (methods.length === 0) {
|
|
335
|
-
|
|
332
|
+
_agiflowai_aicode_utils.messages.warning(`No scaffolding methods available for ${displayName}.`);
|
|
336
333
|
return;
|
|
337
334
|
}
|
|
338
|
-
|
|
335
|
+
_agiflowai_aicode_utils.print.header(`\n${_agiflowai_aicode_utils.icons.wrench} Available Scaffolding Methods for ${displayName}:\n`);
|
|
339
336
|
for (const method of methods) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (method.variables_schema.required && method.variables_schema.required.length > 0)
|
|
343
|
-
|
|
337
|
+
_agiflowai_aicode_utils.print.highlight(` ${method.name}`);
|
|
338
|
+
_agiflowai_aicode_utils.print.debug(` ${method.instruction || method.description || "No description available"}`);
|
|
339
|
+
if (method.variables_schema.required && method.variables_schema.required.length > 0) _agiflowai_aicode_utils.print.debug(` Required: ${method.variables_schema.required.join(", ")}`);
|
|
340
|
+
_agiflowai_aicode_utils.print.newline();
|
|
344
341
|
}
|
|
345
342
|
if (result.nextCursor) {
|
|
346
|
-
|
|
347
|
-
|
|
343
|
+
_agiflowai_aicode_utils.print.newline();
|
|
344
|
+
_agiflowai_aicode_utils.print.info(`${_agiflowai_aicode_utils.icons.info} More results available. Use --cursor to fetch next page:`);
|
|
348
345
|
const cursorOption = `--cursor "${result.nextCursor}"`;
|
|
349
|
-
if (projectPath)
|
|
350
|
-
else
|
|
346
|
+
if (projectPath) _agiflowai_aicode_utils.print.debug(` scaffold-mcp scaffold list ${projectPath} ${cursorOption}`);
|
|
347
|
+
else _agiflowai_aicode_utils.print.debug(` scaffold-mcp scaffold list --template ${options.template} ${cursorOption}`);
|
|
351
348
|
}
|
|
352
349
|
} catch (error) {
|
|
353
|
-
|
|
350
|
+
_agiflowai_aicode_utils.messages.error("Error listing scaffolding methods:", error);
|
|
354
351
|
process.exit(1);
|
|
355
352
|
}
|
|
356
353
|
});
|
|
357
354
|
scaffoldCommand.command("add <featureName>").description("Add a feature to an existing project").option("-p, --project <path>", "Project path", process.cwd()).option("-v, --vars <json>", "JSON string containing variables for the feature").option("--verbose", "Enable verbose logging").action(async (featureName, options) => {
|
|
358
355
|
try {
|
|
359
356
|
const projectPath = node_path.default.resolve(options.project);
|
|
360
|
-
if (!await
|
|
361
|
-
|
|
362
|
-
|
|
357
|
+
if (!await _agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
|
|
358
|
+
_agiflowai_aicode_utils.messages.error(`No project configuration found in ${projectPath}`);
|
|
359
|
+
_agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root");
|
|
363
360
|
process.exit(1);
|
|
364
361
|
}
|
|
365
362
|
let variables = {};
|
|
366
363
|
if (options.vars) try {
|
|
367
364
|
variables = JSON.parse(options.vars);
|
|
368
365
|
} catch (error) {
|
|
369
|
-
|
|
370
|
-
|
|
366
|
+
_agiflowai_aicode_utils.messages.error("Error parsing variables JSON:", error);
|
|
367
|
+
_agiflowai_aicode_utils.messages.hint("Example: --vars '{\"componentName\": \"UserProfile\", \"description\": \"User profile component\"}'");
|
|
371
368
|
process.exit(1);
|
|
372
369
|
}
|
|
373
|
-
const templatesDir = await
|
|
370
|
+
const templatesDir = await _agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
374
371
|
if (!templatesDir) {
|
|
375
|
-
|
|
372
|
+
_agiflowai_aicode_utils.messages.error("Templates folder not found. Create a templates folder or specify templatesPath in toolkit.yaml");
|
|
376
373
|
process.exit(1);
|
|
377
374
|
}
|
|
378
375
|
const scaffoldingMethodsService = new require_ListScaffoldingMethodsTool.ScaffoldingMethodsService(new require_ListScaffoldingMethodsTool.FileSystemService(), templatesDir);
|
|
@@ -385,73 +382,73 @@ scaffoldCommand.command("add <featureName>").description("Add a feature to an ex
|
|
|
385
382
|
} while (cursor);
|
|
386
383
|
const method = allMethods.find((m) => m.name === featureName);
|
|
387
384
|
if (!method) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
385
|
+
_agiflowai_aicode_utils.messages.error(`Scaffold method '${featureName}' not found.`);
|
|
386
|
+
_agiflowai_aicode_utils.print.warning(`Available methods: ${allMethods.map((m) => m.name).join(", ")}`);
|
|
387
|
+
_agiflowai_aicode_utils.print.debug(`Run 'scaffold-mcp scaffold list ${options.project}' to see all available methods`);
|
|
391
388
|
process.exit(1);
|
|
392
389
|
}
|
|
393
390
|
const required = typeof method.variables_schema === "object" && method.variables_schema !== null && "required" in method.variables_schema ? method.variables_schema.required : [];
|
|
394
391
|
const missing = required.filter((key) => !variables[key]);
|
|
395
392
|
if (missing.length > 0) {
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
_agiflowai_aicode_utils.messages.error(`❌ Missing required variables: ${missing.join(", ")}`);
|
|
394
|
+
_agiflowai_aicode_utils.messages.hint(`💡 Use --vars with a JSON object containing: ${missing.join(", ")}`);
|
|
398
395
|
const exampleVars = {};
|
|
399
396
|
for (const key of required) if (key.includes("Name")) exampleVars[key] = "MyFeature";
|
|
400
397
|
else if (key === "description") exampleVars[key] = "Feature description";
|
|
401
398
|
else exampleVars[key] = `<${key}>`;
|
|
402
|
-
|
|
399
|
+
_agiflowai_aicode_utils.print.debug(`Example: scaffold-mcp scaffold add ${featureName} --project ${options.project} --vars '${JSON.stringify(exampleVars)}'`);
|
|
403
400
|
process.exit(1);
|
|
404
401
|
}
|
|
405
402
|
if (options.verbose) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
403
|
+
_agiflowai_aicode_utils.print.info(`🔧 Feature: ${featureName}`);
|
|
404
|
+
_agiflowai_aicode_utils.print.info(`📊 Variables: ${JSON.stringify(variables, null, 2)}`);
|
|
405
|
+
_agiflowai_aicode_utils.print.info(`📁 Project Path: ${projectPath}`);
|
|
409
406
|
}
|
|
410
|
-
|
|
407
|
+
_agiflowai_aicode_utils.print.info(`🚀 Adding '${featureName}' to project...`);
|
|
411
408
|
const result = await scaffoldingMethodsService.useScaffoldMethod({
|
|
412
409
|
projectPath,
|
|
413
410
|
scaffold_feature_name: featureName,
|
|
414
411
|
variables
|
|
415
412
|
});
|
|
416
413
|
if (result.success) {
|
|
417
|
-
|
|
414
|
+
_agiflowai_aicode_utils.messages.success("✅ Feature added successfully!");
|
|
418
415
|
if (result.createdFiles && result.createdFiles.length > 0) {
|
|
419
|
-
|
|
416
|
+
_agiflowai_aicode_utils.print.header("\n📁 Created files:");
|
|
420
417
|
result.createdFiles.forEach((file) => {
|
|
421
|
-
|
|
418
|
+
_agiflowai_aicode_utils.print.debug(` - ${file}`);
|
|
422
419
|
});
|
|
423
420
|
}
|
|
424
421
|
if (result.warnings && result.warnings.length > 0) {
|
|
425
|
-
|
|
422
|
+
_agiflowai_aicode_utils.messages.warning("\n⚠️ Warnings:");
|
|
426
423
|
result.warnings.forEach((warning) => {
|
|
427
|
-
|
|
424
|
+
_agiflowai_aicode_utils.print.debug(` - ${warning}`);
|
|
428
425
|
});
|
|
429
426
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
427
|
+
_agiflowai_aicode_utils.print.header("\n📋 Next steps:");
|
|
428
|
+
_agiflowai_aicode_utils.print.debug(" - Review the generated files");
|
|
429
|
+
_agiflowai_aicode_utils.print.debug(" - Update imports if necessary");
|
|
430
|
+
_agiflowai_aicode_utils.print.debug(" - Run tests to ensure everything works");
|
|
434
431
|
} else {
|
|
435
|
-
|
|
432
|
+
_agiflowai_aicode_utils.messages.error(`❌ Failed to add feature: ${result.message}`);
|
|
436
433
|
process.exit(1);
|
|
437
434
|
}
|
|
438
435
|
} catch (error) {
|
|
439
|
-
|
|
436
|
+
_agiflowai_aicode_utils.messages.error(`❌ Error adding feature: ${error.message}`);
|
|
440
437
|
process.exit(1);
|
|
441
438
|
}
|
|
442
439
|
});
|
|
443
440
|
scaffoldCommand.command("info <featureName>").description("Show detailed information about a scaffold method").option("-p, --project <path>", "Project path").option("-t, --template <name>", "Template name (e.g., nextjs-15, typescript-mcp-package)").action(async (featureName, options) => {
|
|
444
441
|
try {
|
|
445
442
|
if (!options.project && !options.template) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
443
|
+
_agiflowai_aicode_utils.messages.error("Either --project or --template option must be provided");
|
|
444
|
+
_agiflowai_aicode_utils.messages.hint("Examples:");
|
|
445
|
+
_agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold info scaffold-route --project ./my-app");
|
|
446
|
+
_agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold info scaffold-route --template nextjs-15");
|
|
450
447
|
process.exit(1);
|
|
451
448
|
}
|
|
452
|
-
const templatesDir = await
|
|
449
|
+
const templatesDir = await _agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
453
450
|
if (!templatesDir) {
|
|
454
|
-
|
|
451
|
+
_agiflowai_aicode_utils.messages.error("Templates folder not found. Create a templates folder or specify templatesPath in toolkit.yaml");
|
|
455
452
|
process.exit(1);
|
|
456
453
|
}
|
|
457
454
|
const scaffoldingMethodsService = new require_ListScaffoldingMethodsTool.ScaffoldingMethodsService(new require_ListScaffoldingMethodsTool.FileSystemService(), templatesDir);
|
|
@@ -459,9 +456,9 @@ scaffoldCommand.command("info <featureName>").description("Show detailed informa
|
|
|
459
456
|
let cursor;
|
|
460
457
|
if (options.project) {
|
|
461
458
|
const projectPath = node_path.default.resolve(options.project);
|
|
462
|
-
if (!await
|
|
463
|
-
|
|
464
|
-
|
|
459
|
+
if (!await _agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
|
|
460
|
+
_agiflowai_aicode_utils.messages.error(`No project configuration found in ${projectPath}`);
|
|
461
|
+
_agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root\nOr use --template option to view info for a specific template");
|
|
465
462
|
process.exit(1);
|
|
466
463
|
}
|
|
467
464
|
do {
|
|
@@ -476,28 +473,27 @@ scaffoldCommand.command("info <featureName>").description("Show detailed informa
|
|
|
476
473
|
} while (cursor);
|
|
477
474
|
const method = allMethods.find((m) => m.name === featureName);
|
|
478
475
|
if (!method) {
|
|
479
|
-
|
|
476
|
+
_agiflowai_aicode_utils.messages.error(`❌ Scaffold method '${featureName}' not found.`);
|
|
480
477
|
process.exit(1);
|
|
481
478
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
479
|
+
_agiflowai_aicode_utils.print.header(`\n🔧 Scaffold Method: ${method.name}\n`);
|
|
480
|
+
_agiflowai_aicode_utils.print.debug(`Description: ${method.description}`);
|
|
481
|
+
_agiflowai_aicode_utils.print.header("\n📝 Variables Schema:");
|
|
482
|
+
_agiflowai_aicode_utils.print.debug(JSON.stringify(method.variables_schema, null, 2));
|
|
486
483
|
const includes = "includes" in method ? method.includes : [];
|
|
487
484
|
if (includes && includes.length > 0) {
|
|
488
|
-
|
|
485
|
+
_agiflowai_aicode_utils.print.header("\n📁 Files to be created:");
|
|
489
486
|
includes.forEach((include) => {
|
|
490
487
|
const parts = include.split(">>");
|
|
491
|
-
if (parts.length === 2)
|
|
492
|
-
else
|
|
488
|
+
if (parts.length === 2) _agiflowai_aicode_utils.print.debug(` - ${parts[1].trim()}`);
|
|
489
|
+
else _agiflowai_aicode_utils.print.debug(` - ${include}`);
|
|
493
490
|
});
|
|
494
491
|
}
|
|
495
492
|
} catch (error) {
|
|
496
|
-
|
|
493
|
+
_agiflowai_aicode_utils.messages.error(`❌ Error getting scaffold info: ${error.message}`);
|
|
497
494
|
process.exit(1);
|
|
498
495
|
}
|
|
499
496
|
});
|
|
500
|
-
|
|
501
497
|
//#endregion
|
|
502
498
|
//#region src/commands/hook.ts
|
|
503
499
|
/**
|
|
@@ -563,23 +559,23 @@ function resolveFallbackConfig(config) {
|
|
|
563
559
|
/**
|
|
564
560
|
* Hook command for executing scaffold hooks
|
|
565
561
|
*/
|
|
566
|
-
const hookCommand = new commander.Command("hook").description("Execute scaffold hooks for AI agent integrations").option("--type <agentAndMethod>", "Hook type: <agent>.<method> (e.g., claude-code.postToolUse, gemini-cli.postToolUse)").option("--marker <tag>", "Scaffold marker tag to scan for in phantom code check").option("--fallback-tool <tool>", `Fallback LLM tool for scaffold operations. Supported: ${
|
|
562
|
+
const hookCommand = new commander.Command("hook").description("Execute scaffold hooks for AI agent integrations").option("--type <agentAndMethod>", "Hook type: <agent>.<method> (e.g., claude-code.postToolUse, gemini-cli.postToolUse)").option("--marker <tag>", "Scaffold marker tag to scan for in phantom code check").option("--fallback-tool <tool>", `Fallback LLM tool for scaffold operations. Supported: ${_agiflowai_coding_agent_bridge.SUPPORTED_LLM_TOOLS.join(", ")}`).option("--fallback-tool-config <json>", "JSON config for the fallback tool (e.g., '{\"model\":\"claude-sonnet-4-6\"}')").action(async (options) => {
|
|
567
563
|
try {
|
|
568
564
|
if (!options.type) throw new Error("--type option is required. Examples: claude-code.preToolUse, claude-code.postToolUse, gemini-cli.postToolUse");
|
|
569
|
-
const { agent, hookMethod } = (0,
|
|
570
|
-
const methodConfig = ((await
|
|
565
|
+
const { agent, hookMethod } = (0, _agiflowai_hooks_adapter.parseHookType)(options.type);
|
|
566
|
+
const methodConfig = ((await _agiflowai_aicode_utils.TemplatesManagerService.readToolkitConfig())?.["scaffold-mcp"]?.hook)?.[agent]?.[hookMethod];
|
|
571
567
|
const marker = options.marker ?? "@scaffold-generated";
|
|
572
568
|
const configuredFallback = resolveFallbackConfig(methodConfig);
|
|
573
569
|
const fallbackToolStr = options.fallbackTool ?? methodConfig?.["fallback-tool"] ?? methodConfig?.["llm-tool"] ?? configuredFallback.tool;
|
|
574
570
|
const fallbackToolConfig = options.fallbackToolConfig ? parseJsonConfigOption(options.fallbackToolConfig, "--fallback-tool-config") : methodConfig?.["fallback-tool-config"] ?? methodConfig?.["tool-config"] ?? configuredFallback.config;
|
|
575
|
-
if (fallbackToolStr && !(0,
|
|
571
|
+
if (fallbackToolStr && !(0, _agiflowai_coding_agent_bridge.isValidLlmTool)(fallbackToolStr)) throw new Error(`Invalid --fallback-tool: ${fallbackToolStr}. Supported: ${_agiflowai_coding_agent_bridge.SUPPORTED_LLM_TOOLS.join(", ")}`);
|
|
576
572
|
const adapterConfig = {};
|
|
577
573
|
if (fallbackToolConfig) adapterConfig.tool_config = fallbackToolConfig;
|
|
578
574
|
if (fallbackToolStr) adapterConfig.llm_tool = fallbackToolStr;
|
|
579
575
|
const resolvedAdapterConfig = Object.keys(adapterConfig).length > 0 ? adapterConfig : void 0;
|
|
580
576
|
if (!isHookMethod(hookMethod)) process.exit(0);
|
|
581
|
-
if (agent ===
|
|
582
|
-
const hookModule = await Promise.resolve().then(() => require("./claudeCode-
|
|
577
|
+
if (agent === _agiflowai_coding_agent_bridge.CLAUDE_CODE) {
|
|
578
|
+
const hookModule = await Promise.resolve().then(() => require("./claudeCode-BxcEboyM.cjs"));
|
|
583
579
|
const claudeCallbacks = [];
|
|
584
580
|
if (hookModule.UseScaffoldMethodHook) {
|
|
585
581
|
const hookInstance = new hookModule.UseScaffoldMethodHook();
|
|
@@ -592,9 +588,9 @@ const hookCommand = new commander.Command("hook").description("Execute scaffold
|
|
|
592
588
|
if (hookFn) claudeCallbacks.push(hookFn.bind(hookInstance));
|
|
593
589
|
}
|
|
594
590
|
if (claudeCallbacks.length === 0) process.exit(0);
|
|
595
|
-
await new
|
|
596
|
-
} else if (agent ===
|
|
597
|
-
const hookModule = await Promise.resolve().then(() => require("./geminiCli
|
|
591
|
+
await new _agiflowai_hooks_adapter.ClaudeCodeAdapter().executeMultiple(claudeCallbacks, resolvedAdapterConfig);
|
|
592
|
+
} else if (agent === _agiflowai_coding_agent_bridge.GEMINI_CLI) {
|
|
593
|
+
const hookModule = await Promise.resolve().then(() => require("./geminiCli--s1Qy7ZP.cjs"));
|
|
598
594
|
const geminiCallbacks = [];
|
|
599
595
|
if (hookModule.UseScaffoldMethodHook) {
|
|
600
596
|
const hookInstance = new hookModule.UseScaffoldMethodHook();
|
|
@@ -602,14 +598,13 @@ const hookCommand = new commander.Command("hook").description("Execute scaffold
|
|
|
602
598
|
if (hookFn) geminiCallbacks.push(hookFn.bind(hookInstance));
|
|
603
599
|
}
|
|
604
600
|
if (geminiCallbacks.length === 0) process.exit(0);
|
|
605
|
-
await new
|
|
606
|
-
} else throw new Error(`Unsupported agent: ${agent}. Supported: ${
|
|
601
|
+
await new _agiflowai_hooks_adapter.GeminiCliAdapter().executeMultiple(geminiCallbacks, resolvedAdapterConfig);
|
|
602
|
+
} else throw new Error(`Unsupported agent: ${agent}. Supported: ${_agiflowai_coding_agent_bridge.CLAUDE_CODE}, ${_agiflowai_coding_agent_bridge.GEMINI_CLI}`);
|
|
607
603
|
} catch (error) {
|
|
608
|
-
|
|
604
|
+
_agiflowai_aicode_utils.print.error(`Hook error: ${error instanceof Error ? error.message : String(error)}`);
|
|
609
605
|
process.exit(1);
|
|
610
606
|
}
|
|
611
607
|
});
|
|
612
|
-
|
|
613
608
|
//#endregion
|
|
614
609
|
//#region src/cli.ts
|
|
615
610
|
/**
|
|
@@ -625,5 +620,4 @@ async function main() {
|
|
|
625
620
|
await program.parseAsync(process.argv);
|
|
626
621
|
}
|
|
627
622
|
main();
|
|
628
|
-
|
|
629
|
-
//#endregion
|
|
623
|
+
//#endregion
|