@agiflowai/scaffold-mcp 0.5.0 → 1.0.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.
Files changed (30) hide show
  1. package/README.md +11 -71
  2. package/dist/ScaffoldConfigLoader-CI0T6zdG.js +142 -0
  3. package/dist/{ScaffoldConfigLoader-DzcV5a_c.cjs → ScaffoldConfigLoader-DQMCLVGD.cjs} +1 -1
  4. package/dist/ScaffoldConfigLoader-DhthV6xq.js +3 -0
  5. package/dist/{ScaffoldService-BgFWAOLQ.cjs → ScaffoldService-B-L4gwHt.cjs} +6 -0
  6. package/dist/ScaffoldService-Cx4ZonaT.cjs +3 -0
  7. package/dist/ScaffoldService-DVsusUh5.js +3 -0
  8. package/dist/ScaffoldService-QgQKHMM-.js +290 -0
  9. package/dist/TemplateService-BZRt3NI8.cjs +3 -0
  10. package/dist/TemplateService-CiZJA06s.js +79 -0
  11. package/dist/TemplateService-DropYdp8.js +3 -0
  12. package/dist/VariableReplacementService-B3qARIC9.js +66 -0
  13. package/dist/{VariableReplacementService-YUpL5nAC.cjs → VariableReplacementService-BrJ1PdKm.cjs} +1 -1
  14. package/dist/VariableReplacementService-D8C-IsP-.js +3 -0
  15. package/dist/cli.cjs +1363 -0
  16. package/dist/cli.d.cts +1 -0
  17. package/dist/cli.d.ts +1 -0
  18. package/dist/cli.js +1355 -0
  19. package/dist/index.cjs +32 -3144
  20. package/dist/index.d.cts +798 -0
  21. package/dist/index.d.ts +799 -0
  22. package/dist/index.js +7 -0
  23. package/dist/stdio-Cz5aRdvr.cjs +2210 -0
  24. package/dist/stdio-Dmpwju2k.js +2074 -0
  25. package/package.json +19 -4
  26. package/dist/ScaffoldService-BvD9WvRi.cjs +0 -3
  27. package/dist/TemplateService-B5EZjPB0.cjs +0 -3
  28. /package/dist/{ScaffoldConfigLoader-1Pcv9cxm.cjs → ScaffoldConfigLoader-BrmvENTo.cjs} +0 -0
  29. /package/dist/{TemplateService-_KpkoLfZ.cjs → TemplateService-DRubcvS9.cjs} +0 -0
  30. /package/dist/{VariableReplacementService-ClshNY_C.cjs → VariableReplacementService-BL84vnKk.cjs} +0 -0
package/dist/index.cjs CHANGED
@@ -1,3144 +1,32 @@
1
- #!/usr/bin/env node
2
- const require_chunk = require('./chunk-CUT6urMc.cjs');
3
- const require_ScaffoldConfigLoader = require('./ScaffoldConfigLoader-1Pcv9cxm.cjs');
4
- const require_ScaffoldService = require('./ScaffoldService-BgFWAOLQ.cjs');
5
- const require_TemplateService = require('./TemplateService-_KpkoLfZ.cjs');
6
- const require_VariableReplacementService = require('./VariableReplacementService-ClshNY_C.cjs');
7
- let commander = require("commander");
8
- commander = require_chunk.__toESM(commander);
9
- let node_path = require("node:path");
10
- node_path = require_chunk.__toESM(node_path);
11
- let fs_extra = require("fs-extra");
12
- fs_extra = require_chunk.__toESM(fs_extra);
13
- let __agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
14
- __agiflowai_aicode_utils = require_chunk.__toESM(__agiflowai_aicode_utils);
15
- let node_child_process = require("node:child_process");
16
- node_child_process = require_chunk.__toESM(node_child_process);
17
- let node_util = require("node:util");
18
- node_util = require_chunk.__toESM(node_util);
19
- let __composio_json_schema_to_zod = require("@composio/json-schema-to-zod");
20
- __composio_json_schema_to_zod = require_chunk.__toESM(__composio_json_schema_to_zod);
21
- let js_yaml = require("js-yaml");
22
- js_yaml = require_chunk.__toESM(js_yaml);
23
- let zod = require("zod");
24
- zod = require_chunk.__toESM(zod);
25
- let __modelcontextprotocol_sdk_server_index_js = require("@modelcontextprotocol/sdk/server/index.js");
26
- __modelcontextprotocol_sdk_server_index_js = require_chunk.__toESM(__modelcontextprotocol_sdk_server_index_js);
27
- let __modelcontextprotocol_sdk_types_js = require("@modelcontextprotocol/sdk/types.js");
28
- __modelcontextprotocol_sdk_types_js = require_chunk.__toESM(__modelcontextprotocol_sdk_types_js);
29
- let node_crypto = require("node:crypto");
30
- node_crypto = require_chunk.__toESM(node_crypto);
31
- let __modelcontextprotocol_sdk_server_streamableHttp_js = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
32
- __modelcontextprotocol_sdk_server_streamableHttp_js = require_chunk.__toESM(__modelcontextprotocol_sdk_server_streamableHttp_js);
33
- let express = require("express");
34
- express = require_chunk.__toESM(express);
35
- let __modelcontextprotocol_sdk_server_sse_js = require("@modelcontextprotocol/sdk/server/sse.js");
36
- __modelcontextprotocol_sdk_server_sse_js = require_chunk.__toESM(__modelcontextprotocol_sdk_server_sse_js);
37
- let __modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
38
- __modelcontextprotocol_sdk_server_stdio_js = require_chunk.__toESM(__modelcontextprotocol_sdk_server_stdio_js);
39
-
40
- //#region src/utils/git.ts
41
- const execAsync = (0, node_util.promisify)(node_child_process.exec);
42
- /**
43
- * Parse GitHub URL to detect if it's a subdirectory
44
- * Supports formats:
45
- * - https://github.com/user/repo
46
- * - https://github.com/user/repo/tree/branch/path/to/dir
47
- * - https://github.com/user/repo/tree/main/path/to/dir
48
- */
49
- function parseGitHubUrl(url) {
50
- const treeMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)$/);
51
- const blobMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+)$/);
52
- const rootMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/);
53
- if (treeMatch || blobMatch) {
54
- const match = treeMatch || blobMatch;
55
- return {
56
- owner: match[1],
57
- repo: match[2],
58
- repoUrl: `https://github.com/${match[1]}/${match[2]}.git`,
59
- branch: match[3],
60
- subdirectory: match[4],
61
- isSubdirectory: true
62
- };
63
- }
64
- if (rootMatch) return {
65
- owner: rootMatch[1],
66
- repo: rootMatch[2],
67
- repoUrl: `https://github.com/${rootMatch[1]}/${rootMatch[2]}.git`,
68
- isSubdirectory: false
69
- };
70
- return {
71
- repoUrl: url,
72
- isSubdirectory: false
73
- };
74
- }
75
- /**
76
- * Clone a subdirectory from a git repository using sparse checkout
77
- */
78
- async function cloneSubdirectory(repoUrl, branch, subdirectory, targetFolder) {
79
- const tempFolder = `${targetFolder}.tmp`;
80
- try {
81
- await execAsync(`git init "${tempFolder}"`);
82
- await execAsync(`git -C "${tempFolder}" remote add origin ${repoUrl}`);
83
- await execAsync(`git -C "${tempFolder}" config core.sparseCheckout true`);
84
- const sparseCheckoutFile = node_path.default.join(tempFolder, ".git", "info", "sparse-checkout");
85
- await fs_extra.writeFile(sparseCheckoutFile, `${subdirectory}\n`);
86
- await execAsync(`git -C "${tempFolder}" pull --depth=1 origin ${branch}`);
87
- const sourceDir = node_path.default.join(tempFolder, subdirectory);
88
- if (!await fs_extra.pathExists(sourceDir)) throw new Error(`Subdirectory '${subdirectory}' not found in repository at branch '${branch}'`);
89
- await fs_extra.move(sourceDir, targetFolder);
90
- await fs_extra.remove(tempFolder);
91
- } catch (error) {
92
- if (await fs_extra.pathExists(tempFolder)) await fs_extra.remove(tempFolder);
93
- throw error;
94
- }
95
- }
96
- /**
97
- * Clone entire repository
98
- */
99
- async function cloneRepository(repoUrl, targetFolder) {
100
- await execAsync(`git clone ${repoUrl} "${targetFolder}"`);
101
- const gitFolder = node_path.default.join(targetFolder, ".git");
102
- if (await fs_extra.pathExists(gitFolder)) await fs_extra.remove(gitFolder);
103
- }
104
- /**
105
- * Fetch directory listing from GitHub API
106
- */
107
- async function fetchGitHubDirectoryContents(owner, repo, path$6, branch = "main") {
108
- const url = `https://api.github.com/repos/${owner}/${repo}/contents/${path$6}?ref=${branch}`;
109
- const response = await fetch(url, { headers: {
110
- Accept: "application/vnd.github.v3+json",
111
- "User-Agent": "scaffold-mcp"
112
- } });
113
- if (!response.ok) throw new Error(`Failed to fetch directory contents: ${response.statusText}`);
114
- const data = await response.json();
115
- if (!Array.isArray(data)) throw new Error("Expected directory but got file");
116
- return data.map((item) => ({
117
- name: item.name,
118
- type: item.type,
119
- path: item.path
120
- }));
121
- }
122
-
123
- //#endregion
124
- //#region src/cli/add.ts
125
- /**
126
- * Add command - add a template to templates folder
127
- */
128
- const addCommand = new commander.Command("add").description("Add a template to templates folder").requiredOption("--name <name>", "Template name").requiredOption("--url <url>", "URL of the template repository to download").option("--path <path>", "Path to templates folder", "./templates").option("--type <type>", "Template type: boilerplate or scaffold", "boilerplate").action(async (options) => {
129
- try {
130
- const templatesPath = node_path.default.resolve(options.path);
131
- const templateType = options.type.toLowerCase();
132
- const templateName = options.name;
133
- const templateUrl = options.url;
134
- if (templateType !== "boilerplate" && templateType !== "scaffold") {
135
- __agiflowai_aicode_utils.messages.error("Invalid template type. Use: boilerplate or scaffold");
136
- process.exit(1);
137
- }
138
- const targetFolder = node_path.default.join(templatesPath, `${templateType}s`, templateName);
139
- if (await fs_extra.pathExists(targetFolder)) {
140
- __agiflowai_aicode_utils.messages.error(`Template '${templateName}' already exists at ${targetFolder}`);
141
- process.exit(1);
142
- }
143
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.download} Downloading template '${templateName}' from ${templateUrl}...`);
144
- await fs_extra.ensureDir(node_path.default.dirname(targetFolder));
145
- const parsedUrl = parseGitHubUrl(templateUrl);
146
- try {
147
- if (parsedUrl.isSubdirectory && parsedUrl.branch && parsedUrl.subdirectory) {
148
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.folder} Detected subdirectory: ${parsedUrl.subdirectory} (branch: ${parsedUrl.branch})`);
149
- await cloneSubdirectory(parsedUrl.repoUrl, parsedUrl.branch, parsedUrl.subdirectory, targetFolder);
150
- } else await cloneRepository(parsedUrl.repoUrl, targetFolder);
151
- __agiflowai_aicode_utils.messages.success(`Template '${templateName}' added successfully!`);
152
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.folder} Template location:`);
153
- __agiflowai_aicode_utils.print.indent(targetFolder);
154
- const configFiles = [node_path.default.join(targetFolder, "boilerplate.yaml"), node_path.default.join(targetFolder, "scaffold.yaml")];
155
- let hasConfig = false;
156
- for (const configFile of configFiles) if (await fs_extra.pathExists(configFile)) {
157
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.config} Configuration file found:`);
158
- __agiflowai_aicode_utils.print.indent(node_path.default.basename(configFile));
159
- hasConfig = true;
160
- break;
161
- }
162
- if (!hasConfig) {
163
- __agiflowai_aicode_utils.messages.warning("Warning: No configuration file found (boilerplate.yaml or scaffold.yaml)");
164
- __agiflowai_aicode_utils.print.indent("You may need to create one manually.");
165
- }
166
- __agiflowai_aicode_utils.sections.nextSteps([`Review the template in ${targetFolder}`, `Test it with: scaffold-mcp ${templateType} list`]);
167
- } catch (error) {
168
- if (error.message.includes("not found") || error.message.includes("command not found")) __agiflowai_aicode_utils.messages.error("git command not found. Please install git first.");
169
- else if (error.message.includes("Authentication failed")) __agiflowai_aicode_utils.messages.error("Authentication failed. Make sure you have access to the repository.");
170
- else if (error.message.includes("Repository not found")) __agiflowai_aicode_utils.messages.error("Repository not found. Check the URL and try again.");
171
- else __agiflowai_aicode_utils.messages.error("Failed to clone repository:", error);
172
- process.exit(1);
173
- }
174
- } catch (error) {
175
- __agiflowai_aicode_utils.messages.error("Error adding template:", error);
176
- process.exit(1);
177
- }
178
- });
179
-
180
- //#endregion
181
- //#region src/services/FileSystemService.ts
182
- var FileSystemService = class {
183
- async pathExists(path$6) {
184
- return fs_extra.default.pathExists(path$6);
185
- }
186
- async readFile(path$6, encoding = "utf8") {
187
- return fs_extra.default.readFile(path$6, encoding);
188
- }
189
- async readJson(path$6) {
190
- return fs_extra.default.readJson(path$6);
191
- }
192
- async writeFile(path$6, content, encoding = "utf8") {
193
- return fs_extra.default.writeFile(path$6, content, encoding);
194
- }
195
- async ensureDir(path$6) {
196
- return fs_extra.default.ensureDir(path$6);
197
- }
198
- async copy(src, dest) {
199
- return fs_extra.default.copy(src, dest);
200
- }
201
- async readdir(path$6) {
202
- return fs_extra.default.readdir(path$6);
203
- }
204
- async stat(path$6) {
205
- return fs_extra.default.stat(path$6);
206
- }
207
- };
208
-
209
- //#endregion
210
- //#region src/services/BoilerplateService.ts
211
- var BoilerplateService = class {
212
- templatesPath;
213
- templateService;
214
- scaffoldService;
215
- constructor(templatesPath) {
216
- this.templatesPath = templatesPath;
217
- this.templateService = new require_TemplateService.TemplateService();
218
- const fileSystemService = new FileSystemService();
219
- this.scaffoldService = new require_ScaffoldService.ScaffoldService(fileSystemService, new require_ScaffoldConfigLoader.ScaffoldConfigLoader(fileSystemService, this.templateService), new require_VariableReplacementService.VariableReplacementService(fileSystemService, this.templateService), templatesPath);
220
- }
221
- /**
222
- * Scans all scaffold.yaml files and returns available boilerplates
223
- */
224
- async listBoilerplates() {
225
- const boilerplates = [];
226
- const templateDirs = await this.discoverTemplateDirectories();
227
- for (const templatePath of templateDirs) {
228
- const scaffoldYamlPath = node_path.join(this.templatesPath, templatePath, "scaffold.yaml");
229
- if (fs_extra.existsSync(scaffoldYamlPath)) try {
230
- const scaffoldContent = fs_extra.readFileSync(scaffoldYamlPath, "utf8");
231
- const scaffoldConfig = js_yaml.load(scaffoldContent);
232
- if (scaffoldConfig.boilerplate) for (const boilerplate of scaffoldConfig.boilerplate) {
233
- if (!boilerplate.targetFolder) {
234
- __agiflowai_aicode_utils.log.warn(`Skipping boilerplate '${boilerplate.name}' in ${templatePath}: targetFolder is required in scaffold.yaml`);
235
- continue;
236
- }
237
- boilerplates.push({
238
- name: boilerplate.name,
239
- description: boilerplate.description,
240
- instruction: boilerplate.instruction,
241
- variables_schema: boilerplate.variables_schema,
242
- template_path: templatePath,
243
- target_folder: boilerplate.targetFolder,
244
- includes: boilerplate.includes
245
- });
246
- }
247
- } catch (error) {
248
- __agiflowai_aicode_utils.log.warn(`Failed to load scaffold.yaml for ${templatePath}:`, error);
249
- }
250
- }
251
- return { boilerplates };
252
- }
253
- /**
254
- * Dynamically discovers template directories by finding all directories
255
- * that contain both package.json and scaffold.yaml files
256
- */
257
- async discoverTemplateDirectories() {
258
- const templateDirs = [];
259
- const findTemplates = (dir, baseDir = "") => {
260
- if (!fs_extra.existsSync(dir)) return;
261
- const items = fs_extra.readdirSync(dir);
262
- const hasPackageJson = items.includes("package.json") || items.includes("package.json.liquid");
263
- const hasScaffoldYaml = items.includes("scaffold.yaml");
264
- if (hasPackageJson && hasScaffoldYaml) templateDirs.push(baseDir);
265
- for (const item of items) {
266
- const itemPath = node_path.join(dir, item);
267
- if (fs_extra.statSync(itemPath).isDirectory() && !item.startsWith(".") && item !== "node_modules") findTemplates(itemPath, baseDir ? node_path.join(baseDir, item) : item);
268
- }
269
- };
270
- findTemplates(this.templatesPath);
271
- return templateDirs;
272
- }
273
- /**
274
- * Executes a specific boilerplate with provided variables
275
- */
276
- async useBoilerplate(request) {
277
- const { boilerplateName, variables, monolith = false, targetFolderOverride } = request;
278
- const boilerplateList = await this.listBoilerplates();
279
- const boilerplate = boilerplateList.boilerplates.find((b) => b.name === boilerplateName);
280
- if (!boilerplate) return {
281
- success: false,
282
- message: `Boilerplate '${boilerplateName}' not found. Available boilerplates: ${boilerplateList.boilerplates.map((b) => b.name).join(", ")}`
283
- };
284
- const validationResult = this.validateBoilerplateVariables(boilerplate, variables);
285
- if (!validationResult.isValid) return {
286
- success: false,
287
- message: `Validation failed: ${validationResult.errors.join(", ")}`
288
- };
289
- const packageName = variables.packageName || variables.appName;
290
- if (!packageName) return {
291
- success: false,
292
- message: "Missing required parameter: packageName or appName"
293
- };
294
- const folderName = packageName.includes("/") ? packageName.split("/")[1] : packageName;
295
- const targetFolder = targetFolderOverride || (monolith ? "." : boilerplate.target_folder);
296
- try {
297
- const result = await this.scaffoldService.useBoilerplate({
298
- projectName: folderName,
299
- packageName,
300
- targetFolder,
301
- templateFolder: boilerplate.template_path,
302
- boilerplateName,
303
- variables: {
304
- ...variables,
305
- packageName,
306
- appName: folderName,
307
- sourceTemplate: boilerplate.template_path
308
- }
309
- });
310
- if (!result.success) return result;
311
- if (monolith) await __agiflowai_aicode_utils.ProjectConfigResolver.createToolkitYaml(boilerplate.template_path);
312
- else {
313
- const projectPath = node_path.join(targetFolder, folderName);
314
- await __agiflowai_aicode_utils.ProjectConfigResolver.createProjectJson(projectPath, folderName, boilerplate.template_path);
315
- }
316
- return {
317
- success: result.success,
318
- message: result.message,
319
- warnings: result.warnings,
320
- createdFiles: result.createdFiles,
321
- existingFiles: result.existingFiles
322
- };
323
- } catch (error) {
324
- return {
325
- success: false,
326
- message: `Failed to scaffold boilerplate: ${error instanceof Error ? error.message : String(error)}`
327
- };
328
- }
329
- }
330
- /**
331
- * Gets a specific boilerplate configuration by name with optional variable rendering
332
- */
333
- async getBoilerplate(name, variables) {
334
- const boilerplate = (await this.listBoilerplates()).boilerplates.find((b) => b.name === name);
335
- if (!boilerplate) return null;
336
- if (variables && this.templateService.containsTemplateVariables(boilerplate.instruction)) return {
337
- ...boilerplate,
338
- instruction: this.templateService.renderString(boilerplate.instruction, variables)
339
- };
340
- return boilerplate;
341
- }
342
- /**
343
- * Processes boilerplate instruction with template service
344
- */
345
- processBoilerplateInstruction(instruction, variables) {
346
- if (this.templateService.containsTemplateVariables(instruction)) return this.templateService.renderString(instruction, variables);
347
- return instruction;
348
- }
349
- /**
350
- * Validates boilerplate variables against schema using Zod
351
- */
352
- validateBoilerplateVariables(boilerplate, variables) {
353
- const errors = [];
354
- try {
355
- (0, __composio_json_schema_to_zod.jsonSchemaToZod)(boilerplate.variables_schema).parse(variables);
356
- return {
357
- isValid: true,
358
- errors: []
359
- };
360
- } catch (error) {
361
- if (error instanceof zod.z.ZodError) {
362
- const zodErrors = error.errors.map((err) => {
363
- return `${err.path.length > 0 ? err.path.join(".") : "root"}: ${err.message}`;
364
- });
365
- errors.push(...zodErrors);
366
- } else errors.push(`Validation error: ${error instanceof Error ? error.message : String(error)}`);
367
- return {
368
- isValid: false,
369
- errors
370
- };
371
- }
372
- }
373
- };
374
-
375
- //#endregion
376
- //#region src/cli/boilerplate.ts
377
- /**
378
- * Boilerplate CLI command
379
- */
380
- const boilerplateCommand = new commander.Command("boilerplate").description("Manage boilerplate templates");
381
- boilerplateCommand.command("list").description("List all available boilerplate templates").action(async () => {
382
- try {
383
- const { boilerplates } = await new BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath()).listBoilerplates();
384
- if (boilerplates.length === 0) {
385
- __agiflowai_aicode_utils.messages.warning("No boilerplate templates found.");
386
- return;
387
- }
388
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.package} Available Boilerplate Templates:\n`);
389
- for (const bp of boilerplates) {
390
- __agiflowai_aicode_utils.print.highlight(` ${bp.name}`);
391
- __agiflowai_aicode_utils.print.debug(` ${bp.description}`);
392
- __agiflowai_aicode_utils.print.debug(` Target: ${bp.target_folder}`);
393
- const required = typeof bp.variables_schema === "object" && bp.variables_schema !== null && "required" in bp.variables_schema ? bp.variables_schema.required : [];
394
- if (required && required.length > 0) __agiflowai_aicode_utils.print.debug(` Required: ${required.join(", ")}`);
395
- __agiflowai_aicode_utils.print.newline();
396
- }
397
- } catch (error) {
398
- __agiflowai_aicode_utils.messages.error("Error listing boilerplates:", error);
399
- process.exit(1);
400
- }
401
- });
402
- 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) => {
403
- try {
404
- const boilerplateService = new BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath());
405
- let variables = {};
406
- if (options.vars) try {
407
- variables = JSON.parse(options.vars);
408
- } catch (error) {
409
- __agiflowai_aicode_utils.messages.error("Error parsing variables JSON:", error);
410
- __agiflowai_aicode_utils.messages.hint("Example: --vars '{\"appName\": \"my-app\", \"description\": \"My application\"}'");
411
- process.exit(1);
412
- }
413
- const boilerplate = await boilerplateService.getBoilerplate(boilerplateName);
414
- if (!boilerplate) {
415
- const { boilerplates } = await boilerplateService.listBoilerplates();
416
- __agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
417
- __agiflowai_aicode_utils.print.warning(`Available boilerplates: ${boilerplates.map((b) => b.name).join(", ")}`);
418
- process.exit(1);
419
- }
420
- const required = typeof boilerplate.variables_schema === "object" && boilerplate.variables_schema !== null && "required" in boilerplate.variables_schema ? boilerplate.variables_schema.required : [];
421
- const missing = required.filter((key) => !variables[key]);
422
- if (missing.length > 0) {
423
- __agiflowai_aicode_utils.messages.error(`Missing required variables: ${missing.join(", ")}`);
424
- __agiflowai_aicode_utils.messages.hint(`Use --vars with a JSON object containing: ${missing.join(", ")}`);
425
- const exampleVars = {};
426
- for (const key of required) if (key === "appName" || key === "packageName") exampleVars[key] = "my-app";
427
- else if (key === "description") exampleVars[key] = "My application description";
428
- else exampleVars[key] = `<${key}>`;
429
- __agiflowai_aicode_utils.print.debug(`Example: scaffold-mcp boilerplate create ${boilerplateName} --vars '${JSON.stringify(exampleVars)}'`);
430
- process.exit(1);
431
- }
432
- if (options.verbose) {
433
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.wrench} Boilerplate: ${boilerplateName}`);
434
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.chart} Variables: ${JSON.stringify(variables, null, 2)}`);
435
- }
436
- __agiflowai_aicode_utils.messages.loading(`Creating project from boilerplate '${boilerplateName}'...`);
437
- const result = await boilerplateService.useBoilerplate({
438
- boilerplateName,
439
- variables,
440
- monolith: options.monolith,
441
- targetFolderOverride: options.targetFolder
442
- });
443
- if (result.success) {
444
- __agiflowai_aicode_utils.messages.success("Project created successfully!");
445
- __agiflowai_aicode_utils.print.info(result.message);
446
- if (result.createdFiles && result.createdFiles.length > 0) __agiflowai_aicode_utils.sections.createdFiles(result.createdFiles);
447
- const projectName = variables.appName || variables.packageName;
448
- if (projectName) {
449
- const targetFolder = options.targetFolder || (options.monolith ? "." : boilerplate.target_folder);
450
- const projectPath = options.monolith ? "." : `${targetFolder}/${projectName}`;
451
- const steps = projectPath === "." ? ["pnpm install", "pnpm dev"] : [
452
- `cd ${projectPath}`,
453
- "pnpm install",
454
- "pnpm dev"
455
- ];
456
- __agiflowai_aicode_utils.sections.nextSteps(steps);
457
- }
458
- } else {
459
- __agiflowai_aicode_utils.messages.error(`Failed to create project: ${result.message}`);
460
- process.exit(1);
461
- }
462
- } catch (error) {
463
- __agiflowai_aicode_utils.messages.error("Error creating project:", error);
464
- if (options.verbose) console.error("Stack trace:", error.stack);
465
- process.exit(1);
466
- }
467
- });
468
- boilerplateCommand.command("info <boilerplateName>").description("Show detailed information about a boilerplate template").action(async (boilerplateName) => {
469
- try {
470
- const bp = await new BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath()).getBoilerplate(boilerplateName);
471
- if (!bp) {
472
- __agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
473
- process.exit(1);
474
- }
475
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.package} Boilerplate: ${bp.name}\n`);
476
- __agiflowai_aicode_utils.print.debug(`Description: ${bp.description}`);
477
- __agiflowai_aicode_utils.print.debug(`Template Path: ${bp.template_path}`);
478
- __agiflowai_aicode_utils.print.debug(`Target Folder: ${bp.target_folder}`);
479
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.config} Variables Schema:`);
480
- console.log(JSON.stringify(bp.variables_schema, null, 2));
481
- if (bp.includes && bp.includes.length > 0) __agiflowai_aicode_utils.sections.list(`${__agiflowai_aicode_utils.icons.folder} Included Files:`, bp.includes);
482
- } catch (error) {
483
- __agiflowai_aicode_utils.messages.error("Error getting boilerplate info:", error);
484
- process.exit(1);
485
- }
486
- });
487
-
488
- //#endregion
489
- //#region src/cli/init.ts
490
- /**
491
- * Find the workspace root by searching upwards for .git folder
492
- */
493
- async function findWorkspaceRoot(startPath = process.cwd()) {
494
- let currentPath = node_path.default.resolve(startPath);
495
- const rootPath = node_path.default.parse(currentPath).root;
496
- while (true) {
497
- const gitPath = node_path.default.join(currentPath, ".git");
498
- if (await fs_extra.pathExists(gitPath)) return currentPath;
499
- if (currentPath === rootPath) return process.cwd();
500
- currentPath = node_path.default.dirname(currentPath);
501
- }
502
- }
503
- const DEFAULT_TEMPLATE_REPO = {
504
- owner: "AgiFlow",
505
- repo: "aicode-toolkit",
506
- branch: "main",
507
- path: "templates"
508
- };
509
- /**
510
- * Download templates from GitHub repository
511
- */
512
- async function downloadTemplates(templatesPath) {
513
- try {
514
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.download} Fetching templates from ${DEFAULT_TEMPLATE_REPO.owner}/${DEFAULT_TEMPLATE_REPO.repo}...`);
515
- const templateDirs = (await fetchGitHubDirectoryContents(DEFAULT_TEMPLATE_REPO.owner, DEFAULT_TEMPLATE_REPO.repo, DEFAULT_TEMPLATE_REPO.path, DEFAULT_TEMPLATE_REPO.branch)).filter((item) => item.type === "dir");
516
- if (templateDirs.length === 0) {
517
- __agiflowai_aicode_utils.messages.warning("No templates found in repository");
518
- return;
519
- }
520
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.folder} Found ${templateDirs.length} template(s)`);
521
- for (const template of templateDirs) {
522
- const targetFolder = node_path.default.join(templatesPath, template.name);
523
- if (await fs_extra.pathExists(targetFolder)) {
524
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.skip} Skipping ${template.name} (already exists)`);
525
- continue;
526
- }
527
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.download} Downloading ${template.name}...`);
528
- await cloneSubdirectory(`https://github.com/${DEFAULT_TEMPLATE_REPO.owner}/${DEFAULT_TEMPLATE_REPO.repo}.git`, DEFAULT_TEMPLATE_REPO.branch, template.path, targetFolder);
529
- __agiflowai_aicode_utils.print.success(`${__agiflowai_aicode_utils.icons.check} Downloaded ${template.name}`);
530
- }
531
- __agiflowai_aicode_utils.print.success(`\n${__agiflowai_aicode_utils.icons.check} All templates downloaded successfully!`);
532
- } catch (error) {
533
- throw new Error(`Failed to download templates: ${error.message}`);
534
- }
535
- }
536
- /**
537
- * Init command - initialize templates folder
538
- */
539
- const initCommand = new commander.Command("init").description("Initialize templates folder structure at workspace root").option("--no-download", "Skip downloading templates from repository").option("--path <path>", "Custom path for templates folder (relative to workspace root)").action(async (options) => {
540
- try {
541
- const workspaceRoot = await findWorkspaceRoot();
542
- const templatesPath = options.path ? node_path.default.join(workspaceRoot, options.path) : node_path.default.join(workspaceRoot, "templates");
543
- __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.rocket} Initializing templates folder at: ${templatesPath}`);
544
- await fs_extra.ensureDir(templatesPath);
545
- await fs_extra.writeFile(node_path.default.join(templatesPath, "README.md"), `# Templates
546
-
547
- This folder contains boilerplate templates and scaffolding methods for your projects.
548
-
549
- ## Templates
550
-
551
- Templates are organized by framework/technology and include configuration files (\`scaffold.yaml\`) that define:
552
- - Boilerplates: Full project starter templates
553
- - Features: Code scaffolding methods for adding new features to existing projects
554
-
555
- ## Adding More Templates
556
-
557
- Use the \`add\` command to add templates from remote repositories:
558
-
559
- \`\`\`bash
560
- scaffold-mcp add --name my-template --url https://github.com/user/template
561
- \`\`\`
562
-
563
- Or add templates from subdirectories:
564
-
565
- \`\`\`bash
566
- scaffold-mcp add --name nextjs-template --url https://github.com/user/repo/tree/main/templates/nextjs
567
- \`\`\`
568
-
569
- ## Creating Custom Templates
570
-
571
- Each template should have a \`scaffold.yaml\` configuration file defining:
572
- - \`boilerplate\`: Array of boilerplate configurations
573
- - \`features\`: Array of feature scaffold configurations
574
-
575
- Template files use Liquid syntax for variable placeholders: \`{{ variableName }}\`
576
-
577
- See existing templates for examples and documentation for more details.
578
- `);
579
- __agiflowai_aicode_utils.print.success(`${__agiflowai_aicode_utils.icons.check} Templates folder created!`);
580
- if (options.download !== false) await downloadTemplates(templatesPath);
581
- else __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.skip} Skipping template download (use --download to enable)`);
582
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.folder} Templates location:`);
583
- __agiflowai_aicode_utils.print.indent(templatesPath);
584
- const nextSteps = [];
585
- if (options.download === false) {
586
- nextSteps.push(`Download templates: scaffold-mcp init --download`);
587
- nextSteps.push(`Add templates manually: scaffold-mcp add --name <name> --url <url>`);
588
- } else {
589
- nextSteps.push(`List available boilerplates: scaffold-mcp boilerplate list`);
590
- nextSteps.push(`Add more templates: scaffold-mcp add --name <name> --url <url>`);
591
- }
592
- __agiflowai_aicode_utils.sections.nextSteps(nextSteps);
593
- } catch (error) {
594
- __agiflowai_aicode_utils.messages.error(`Error initializing templates folder: ${error.message}`);
595
- process.exit(1);
596
- }
597
- });
598
-
599
- //#endregion
600
- //#region src/prompts/GenerateBoilerplatePrompt.ts
601
- /**
602
- * Prompt for generating boilerplates
603
- */
604
- var GenerateBoilerplatePrompt = class GenerateBoilerplatePrompt {
605
- static PROMPT_NAME = "generate-boilerplate";
606
- /**
607
- * Get the prompt definition for MCP
608
- */
609
- getDefinition() {
610
- return {
611
- name: GenerateBoilerplatePrompt.PROMPT_NAME,
612
- description: "Generate a new boilerplate template configuration",
613
- arguments: [{
614
- name: "request",
615
- description: "Describe the boilerplate template you want to create",
616
- required: false
617
- }]
618
- };
619
- }
620
- /**
621
- * Get the prompt messages
622
- */
623
- getMessages(args) {
624
- const userRequest = args?.request || "";
625
- return [{
626
- role: "user",
627
- content: {
628
- type: "text",
629
- text: `You are helping create a new boilerplate template configuration using the scaffold-mcp MCP tools.
630
-
631
- ${userRequest ? `User request: ${userRequest}\n` : ""}
632
- Your task:
633
-
634
- 1. **Gather Information**: Ask for any missing details:
635
- - Framework/technology (e.g., "React Vite", "Express API", "Next.js 15")
636
- - Template name (kebab-case, e.g., "react-vite", "nextjs-15")
637
- - Boilerplate name (prefixed with "scaffold-", e.g., "scaffold-vite-app")
638
- - Target folder (e.g., "apps", "packages")
639
- - Project type (app, library, service, etc.)
640
- - Required variables (at minimum: appName or packageName)
641
- - Files to include in the template
642
-
643
- 2. **Use MCP Tools** in order:
644
- - \`generate-boilerplate\` - Creates the boilerplate configuration
645
- - \`generate-boilerplate-file\` - Creates each template file
646
- - \`list-boilerplates\` - Verify it appears
647
- - \`use-boilerplate\` - Test the boilerplate
648
-
649
- Important:
650
- - Template naming: Use kebab-case (e.g., "react-vite", "express-api")
651
- - Boilerplate naming: Prefix with "scaffold-" (e.g., "scaffold-vite-app")
652
- - Target folder: "apps" for applications, "packages" for libraries
653
- - Include files explicitly - avoid wildcards
654
- - Template syntax: use {{ variableName }}
655
-
656
- **Description Field Guidelines (CRITICAL)**:
657
- The description should be a comprehensive multi-paragraph overview (3-5 sentences):
658
- - Paragraph 1: Core technology stack and primary value proposition
659
- - Paragraph 2: Target use cases and ideal project types
660
- - Paragraph 3: Key integrations or special features (if applicable)
661
-
662
- Example:
663
- "A modern React SPA template powered by Vite for lightning-fast HMR, featuring TanStack Router for type-safe routing and TanStack Query for server state management.
664
- Perfect for building data-driven dashboards, admin panels, and interactive web applications requiring client-side routing and real-time data synchronization.
665
-
666
- Includes Agiflow Config Management System integration with systematic environment variable naming (VITE_{CATEGORY}_{SUBCATEGORY}_{PROPERTY}) and auto-generated configuration templates for cloud deployment."
667
-
668
- **Instruction Field Guidelines (CRITICAL)**:
669
- The instruction should be a detailed multi-section guide that helps AI understand the codebase:
670
-
671
- 1. **File purposes** section: List each major file/directory with its purpose
672
- Format: "- path/to/file: Description of what this file does"
673
-
674
- 2. **How to use the scaffolded code** section: Step-by-step workflows
675
- Format: Numbered list with specific examples
676
- - How to add routes/pages
677
- - How to fetch data
678
- - How to handle authentication
679
- - How to configure environment variables
680
-
681
- 3. **Design patterns to follow** section: Key architectural decisions
682
- Format: "- Pattern Name: Explanation and when to use it"
683
- - Routing patterns
684
- - State management patterns
685
- - Data fetching patterns
686
- - Error handling patterns
687
- - Performance optimization patterns
688
-
689
- Example structure:
690
- "[Framework] application template with [key technologies].
691
-
692
- File purposes:
693
- - package.json: NPM package configuration with [framework] and dependencies
694
- - src/main.tsx: Application entry point with [setup details]
695
- - src/routes/: Route definitions following [pattern]
696
- [... list all major files ...]
697
-
698
- How to use the scaffolded code:
699
- 1. Routes: Create new routes by [specific instructions with example]
700
- 2. Data Fetching: Use [specific pattern] for [use case]
701
- 3. Authentication: Use [specific components/modules] for user management
702
- [... numbered steps for common tasks ...]
703
-
704
- Design patterns to follow:
705
- - File-based Routing: Use directory structure in src/routes/ to define URL paths
706
- - Type-safe Routes: Leverage [framework] type inference for params
707
- - State Management: Use [library] for server state, [library] for client state
708
- [... list key patterns with explanations ...]"
709
-
710
- Template File Content Guidelines:
711
- - Keep content MINIMAL and business-agnostic
712
- - Focus on structure and patterns, not business logic
713
- - Use placeholder/generic examples only
714
- - Include essential boilerplate code only
715
- - Let AI fill in specific logic later
716
- - Add clear headers with design patterns and coding standards`
717
- }
718
- }];
719
- }
720
- };
721
-
722
- //#endregion
723
- //#region src/prompts/GenerateFeatureScaffoldPrompt.ts
724
- /**
725
- * Prompt for generating feature scaffolds
726
- */
727
- var GenerateFeatureScaffoldPrompt = class GenerateFeatureScaffoldPrompt {
728
- static PROMPT_NAME = "generate-feature-scaffold";
729
- /**
730
- * Get the prompt definition for MCP
731
- */
732
- getDefinition() {
733
- return {
734
- name: GenerateFeatureScaffoldPrompt.PROMPT_NAME,
735
- description: "Generate a new feature scaffold configuration",
736
- arguments: [{
737
- name: "request",
738
- description: "Describe the feature scaffold you want to create",
739
- required: false
740
- }]
741
- };
742
- }
743
- /**
744
- * Get the prompt messages
745
- */
746
- getMessages(args) {
747
- const userRequest = args?.request || "";
748
- return [{
749
- role: "user",
750
- content: {
751
- type: "text",
752
- text: `You are helping create a new feature scaffold configuration using the scaffold-mcp MCP tools.
753
-
754
- ${userRequest ? `User request: ${userRequest}\n` : ""}
755
- Your task:
756
-
757
- 1. **Gather Information**: Ask for any missing details:
758
- - Template name (e.g., "nextjs-15", "react-vite")
759
- - Feature name (prefixed with "scaffold-", e.g., "scaffold-nextjs-page")
760
- - Feature type (page, component, service, etc.)
761
- - Variables needed
762
- - Files to include
763
-
764
- 2. **Use MCP Tools** in order:
765
- - \`generate-feature-scaffold\` - Creates the feature configuration
766
- - \`generate-boilerplate-file\` - Creates each template file
767
- - \`list-scaffolding-methods\` - Verify it appears
768
- - \`use-scaffold-method\` - Test the feature
769
-
770
- Important:
771
- - Feature names: prefix with "scaffold-"
772
- - Conditional includes: use "file.tsx?withLayout=true"
773
- - Template syntax: use {{ variableName }}
774
-
775
- **Description Field Guidelines (CRITICAL)**:
776
- The description should explain what the feature scaffold generates (2-3 sentences):
777
- - Sentence 1: What type of code it generates (component, page, service, etc.)
778
- - Sentence 2: Key features or capabilities included
779
- - Sentence 3: Primary use cases or when to use it
780
-
781
- Example:
782
- "Generate a new service class for TypeScript libraries following best practices. Creates a service class with interface, implementation, and unit tests. Perfect for creating reusable service modules with dependency injection patterns."
783
-
784
- **Instruction Field Guidelines (CRITICAL)**:
785
- The instruction should provide specific guidance for using the generated feature:
786
-
787
- 1. **Pattern explanation**: Describe the architectural pattern used
788
- 2. **File organization**: Where files should be placed
789
- 3. **Naming conventions**: How to name things (PascalCase, camelCase, etc.)
790
- 4. **Usage guidelines**: How to use the generated code
791
- 5. **Testing approach**: How to test the feature
792
-
793
- Example structure:
794
- "[Feature type] follow a [pattern name] pattern with [key characteristics].
795
- [Explanation of how it works and integrates with the project].
796
- Place [files] in [directory].
797
- For [features with X], define [Y] in [Z] for better separation of concerns.
798
- [Feature names] should be [case style] and [suffix/prefix rules].
799
- Write comprehensive [tests/docs] for all [public methods/exports]."
800
-
801
- Keep it concise but informative - focus on the patterns and conventions that AI needs to understand to work with the generated code effectively.
802
-
803
- Template File Content Guidelines:
804
- - Keep content MINIMAL and business-agnostic
805
- - Focus on structure and patterns, not business logic
806
- - Use placeholder/generic examples only
807
- - Include essential boilerplate code only
808
- - Let AI fill in specific logic later
809
- - Add clear headers with design patterns and coding standards`
810
- }
811
- }];
812
- }
813
- };
814
-
815
- //#endregion
816
- //#region src/prompts/ScaffoldApplicationPrompt.ts
817
- /**
818
- * Prompt for scaffolding a new application using boilerplate templates
819
- */
820
- var ScaffoldApplicationPrompt = class ScaffoldApplicationPrompt {
821
- static PROMPT_NAME = "scaffold-application";
822
- /**
823
- * Get the prompt definition for MCP
824
- */
825
- getDefinition() {
826
- return {
827
- name: ScaffoldApplicationPrompt.PROMPT_NAME,
828
- description: "Scaffold a new application from a boilerplate template",
829
- arguments: [{
830
- name: "request",
831
- description: "Describe the application you want to create (optional)",
832
- required: false
833
- }]
834
- };
835
- }
836
- /**
837
- * Get the prompt messages
838
- */
839
- getMessages(args) {
840
- const userRequest = args?.request || "";
841
- return [{
842
- role: "user",
843
- content: {
844
- type: "text",
845
- text: `You are helping create a new application using the scaffold-mcp MCP tools.
846
-
847
- ${userRequest ? `User request: ${userRequest}\n` : ""}
848
- Your task is to scaffold a new application by following this workflow:
849
-
850
- ## Step 1: List Available Boilerplates
851
- Use the \`list-boilerplates\` tool to see all available project templates.
852
-
853
- **What to look for:**
854
- - Boilerplate name (e.g., "scaffold-nextjs-app", "scaffold-vite-app")
855
- - Description of what the boilerplate creates
856
- - Target folder where projects will be created (e.g., "apps", "packages")
857
- - Required and optional variables in the variables_schema
858
-
859
- ## Step 2: Gather Required Information
860
- Based on the selected boilerplate's variables_schema, collect:
861
- - **Project name**: Must be kebab-case (e.g., "my-new-app", not "MyNewApp")
862
- - **Required variables**: All variables marked as required: true
863
- - **Optional variables**: Variables with required: false (ask user if needed)
864
-
865
- Common variables:
866
- - \`appName\` or \`packageName\`: The project name (kebab-case)
867
- - \`description\`: Brief description of what the project does
868
- - \`author\`: Author name
869
-
870
- ## Step 3: Execute the Boilerplate
871
- Use the \`use-boilerplate\` tool with:
872
- - \`boilerplateName\`: Exact name from list-boilerplates response
873
- - \`variables\`: Object matching the variables_schema exactly
874
-
875
- **Example:**
876
- \`\`\`json
877
- {
878
- "boilerplateName": "scaffold-nextjs-app",
879
- "variables": {
880
- "appName": "my-dashboard",
881
- "description": "Admin dashboard for managing users",
882
- "author": "John Doe"
883
- }
884
- }
885
- \`\`\`
886
-
887
- ## Important Guidelines:
888
- - **Always call \`list-boilerplates\` first** to see available options and their schemas
889
- - **Use exact variable names** from the schema (case-sensitive)
890
- - **Provide all required variables** - the tool will fail if any are missing
891
- - **Use kebab-case for project names** (e.g., "user-dashboard", not "UserDashboard")
892
- - The tool will create the project in the appropriate directory automatically
893
- - After creation, inform the user where the project was created
894
-
895
- ## Step 4: Review and Add Features (If Needed)
896
- After the boilerplate is created, **consider if additional features are needed**:
897
- 1. **READ** the generated project structure to understand what was created
898
- 2. **REVIEW** the user's request to see if they asked for specific features (e.g., "with tool for X", "with prompt for Y")
899
- 3. **If features are needed**:
900
- - Use \`list-scaffolding-methods\` with the new project path
901
- - Use \`use-scaffold-method\` to add tools, services, prompts, etc.
902
- - **IMPLEMENT** the actual logic in the scaffolded feature files
903
- - **REGISTER** the features in \`src/server/index.ts\`
904
- 4. **Install dependencies**: Remind user to run \`pnpm install\`
905
- 5. **Report** the complete setup including any features added
906
-
907
- ## Example Workflow:
908
- 1. Call \`list-boilerplates\` → See available templates
909
- 2. Ask user which template to use (or infer from request)
910
- 3. Collect required variables based on schema
911
- 4. Call \`use-boilerplate\` with boilerplateName and variables
912
- 5. **Review if user requested specific features (tools, prompts, etc.)**
913
- 6. **If features needed**: Add them using \`list-scaffolding-methods\` and \`use-scaffold-method\`
914
- 7. **READ and IMPLEMENT** the scaffolded feature files with actual logic
915
- 8. Report success and next steps to the user`
916
- }
917
- }];
918
- }
919
- };
920
-
921
- //#endregion
922
- //#region src/prompts/ScaffoldFeaturePrompt.ts
923
- /**
924
- * Prompt for scaffolding a new feature in an existing project
925
- */
926
- var ScaffoldFeaturePrompt = class ScaffoldFeaturePrompt {
927
- static PROMPT_NAME = "scaffold-feature";
928
- /**
929
- * Get the prompt definition for MCP
930
- */
931
- getDefinition() {
932
- return {
933
- name: ScaffoldFeaturePrompt.PROMPT_NAME,
934
- description: "Scaffold a new feature (page, component, service, etc.) in an existing project",
935
- arguments: [{
936
- name: "request",
937
- description: "Describe the feature you want to add (optional)",
938
- required: false
939
- }, {
940
- name: "projectPath",
941
- description: "Path to the project (e.g., \"apps/my-app\") - optional if can be inferred",
942
- required: false
943
- }]
944
- };
945
- }
946
- /**
947
- * Get the prompt messages
948
- */
949
- getMessages(args) {
950
- const userRequest = args?.request || "";
951
- const projectPath = args?.projectPath || "";
952
- return [{
953
- role: "user",
954
- content: {
955
- type: "text",
956
- text: `You are helping add a new feature to an existing project using the scaffold-mcp MCP tools.
957
-
958
- ${userRequest ? `User request: ${userRequest}\n` : ""}${projectPath ? `Project path: ${projectPath}\n` : ""}
959
- Your task is to scaffold a new feature by following this workflow:
960
-
961
- ## Step 1: Identify the Project
962
- Determine the project path where the feature will be added:
963
- - If projectPath is provided, use it
964
- - Otherwise, ask the user or infer from context (e.g., "apps/my-app", "packages/my-lib")
965
- - The path should point to a directory containing a \`project.json\` file
966
-
967
- ## Step 2: List Available Scaffolding Methods
968
- Use the \`list-scaffolding-methods\` tool with the projectPath.
969
-
970
- **What to look for:**
971
- - Feature name (e.g., "scaffold-nextjs-page", "scaffold-react-component")
972
- - Description of what files/code it generates
973
- - Required and optional variables in the variables_schema
974
- - The template type (derived from project's sourceTemplate)
975
-
976
- **Example:**
977
- \`\`\`json
978
- {
979
- "projectPath": "apps/my-dashboard"
980
- }
981
- \`\`\`
982
-
983
- ## Step 3: Gather Required Information
984
- Based on the selected scaffolding method's variables_schema, collect:
985
- - **Feature-specific variables**: Name, path, type, etc.
986
- - **Required variables**: All variables marked as required: true
987
- - **Optional variables**: Variables with required: false (ask user if needed)
988
-
989
- Common variables:
990
- - \`componentName\` / \`pageName\` / \`serviceName\`: Name in PascalCase
991
- - \`componentPath\` / \`pagePath\`: Where to place the file (may use kebab-case)
992
- - Boolean flags: \`withTests\`, \`withLayout\`, \`withStyles\`, etc.
993
-
994
- ## Step 4: Execute the Scaffolding Method
995
- Use the \`use-scaffold-method\` tool with:
996
- - \`projectPath\`: Same path from step 1
997
- - \`scaffold_feature_name\`: Exact name from list-scaffolding-methods response
998
- - \`variables\`: Object matching the variables_schema exactly
999
-
1000
- **Example:**
1001
- \`\`\`json
1002
- {
1003
- "projectPath": "apps/my-dashboard",
1004
- "scaffold_feature_name": "scaffold-nextjs-page",
1005
- "variables": {
1006
- "pageName": "UserProfile",
1007
- "pagePath": "user/profile",
1008
- "withLayout": true,
1009
- "withTests": false
1010
- }
1011
- }
1012
- \`\`\`
1013
-
1014
- ## Important Guidelines:
1015
- - **Always call \`list-scaffolding-methods\` first** with the projectPath
1016
- - **Use exact variable names** from the schema (case-sensitive)
1017
- - **Provide all required variables** - the tool will fail if any are missing
1018
- - **Follow naming conventions**:
1019
- - Component/Page/Service names: PascalCase (e.g., "UserProfile")
1020
- - File paths: kebab-case or as specified in schema (e.g., "user/profile")
1021
- - **Conditional files**: Files with \`?condition=true\` are only included when the variable is true
1022
- - The tool will create files in the appropriate locations automatically
1023
- - After creation, inform the user what files were created
1024
-
1025
- ## Step 5: Review and Implement Generated Files
1026
- After scaffolding completes, **you MUST**:
1027
- 1. **READ** all generated files to understand their structure
1028
- 2. **IMPLEMENT** the actual business logic:
1029
- - Replace TODO comments with real code
1030
- - Replace template placeholders with actual implementation
1031
- - Add the specific functionality described in the user's request
1032
- 3. **REGISTER** the feature in appropriate files:
1033
- - Import and register tools in \`src/server/index.ts\`
1034
- - Export new modules from \`index.ts\` files
1035
- - Update any necessary configuration files
1036
- 4. **TEST** to ensure the implementation works correctly
1037
- 5. **DO NOT SKIP** this step - scaffolded files are templates that need actual code
1038
-
1039
- ## Example Workflow:
1040
- 1. Identify project path (provided or ask user)
1041
- 2. Call \`list-scaffolding-methods\` → See available features for this project
1042
- 3. Ask user which feature to add (or infer from request)
1043
- 4. Collect required variables based on schema
1044
- 5. Call \`use-scaffold-method\` with projectPath, scaffold_feature_name, and variables
1045
- 6. **READ the generated files and IMPLEMENT the actual logic**
1046
- 7. **REGISTER the feature in server/index.ts and other config files**
1047
- 8. Report success and list created files with implementation details`
1048
- }
1049
- }];
1050
- }
1051
- };
1052
-
1053
- //#endregion
1054
- //#region src/services/BoilerplateGeneratorService.ts
1055
- /**
1056
- * Service for generating boilerplate configurations in scaffold.yaml files
1057
- */
1058
- var BoilerplateGeneratorService = class {
1059
- templatesPath;
1060
- constructor(templatesPath) {
1061
- this.templatesPath = templatesPath;
1062
- }
1063
- /**
1064
- * Custom YAML dumper that forces literal block style (|) for description and instruction fields
1065
- */
1066
- dumpYamlWithLiteralBlocks(config) {
1067
- const LiteralBlockType = new js_yaml.Type("tag:yaml.org,2002:str", {
1068
- kind: "scalar",
1069
- construct: (data) => data,
1070
- represent: (data) => {
1071
- return data;
1072
- },
1073
- defaultStyle: "|"
1074
- });
1075
- const LITERAL_SCHEMA = js_yaml.DEFAULT_SCHEMA.extend([LiteralBlockType]);
1076
- const processedConfig = this.processConfigForLiteralBlocks(config);
1077
- return js_yaml.dump(processedConfig, {
1078
- schema: LITERAL_SCHEMA,
1079
- indent: 2,
1080
- lineWidth: -1,
1081
- noRefs: true,
1082
- sortKeys: false,
1083
- styles: { "!!str": "literal" },
1084
- replacer: (key, value) => {
1085
- if ((key === "description" || key === "instruction") && typeof value === "string") return value;
1086
- return value;
1087
- }
1088
- });
1089
- }
1090
- /**
1091
- * Process config to ensure description and instruction use literal block style
1092
- */
1093
- processConfigForLiteralBlocks(config) {
1094
- const processed = JSON.parse(JSON.stringify(config));
1095
- if (processed.boilerplate) processed.boilerplate = processed.boilerplate.map((bp) => {
1096
- const newBp = { ...bp };
1097
- if (newBp.description && typeof newBp.description === "string") newBp.description = this.ensureMultilineFormat(newBp.description);
1098
- if (newBp.instruction && typeof newBp.instruction === "string") newBp.instruction = this.ensureMultilineFormat(newBp.instruction);
1099
- return newBp;
1100
- });
1101
- if (processed.features) processed.features = processed.features.map((feature) => {
1102
- const newFeature = { ...feature };
1103
- if (newFeature.description && typeof newFeature.description === "string") newFeature.description = this.ensureMultilineFormat(newFeature.description);
1104
- if (newFeature.instruction && typeof newFeature.instruction === "string") newFeature.instruction = this.ensureMultilineFormat(newFeature.instruction);
1105
- return newFeature;
1106
- });
1107
- return processed;
1108
- }
1109
- /**
1110
- * Ensure string is properly formatted for YAML literal blocks
1111
- */
1112
- ensureMultilineFormat(text) {
1113
- return text.trim();
1114
- }
1115
- /**
1116
- * Generate or update a boilerplate configuration in scaffold.yaml
1117
- */
1118
- async generateBoilerplate(options) {
1119
- const { templateName, boilerplateName, description, instruction, targetFolder, variables, includes = [] } = options;
1120
- const templatePath = node_path.join(this.templatesPath, templateName);
1121
- await fs_extra.ensureDir(templatePath);
1122
- const scaffoldYamlPath = node_path.join(templatePath, "scaffold.yaml");
1123
- let scaffoldConfig = {};
1124
- if (await fs_extra.pathExists(scaffoldYamlPath)) {
1125
- const yamlContent$1 = await fs_extra.readFile(scaffoldYamlPath, "utf-8");
1126
- scaffoldConfig = js_yaml.load(yamlContent$1);
1127
- }
1128
- if (!scaffoldConfig.boilerplate) scaffoldConfig.boilerplate = [];
1129
- if (scaffoldConfig.boilerplate.findIndex((b) => b.name === boilerplateName) !== -1) return {
1130
- success: false,
1131
- message: `Boilerplate '${boilerplateName}' already exists in ${scaffoldYamlPath}`
1132
- };
1133
- const requiredVars = variables.filter((v) => v.required).map((v) => v.name);
1134
- const boilerplateDefinition = {
1135
- name: boilerplateName,
1136
- targetFolder,
1137
- description,
1138
- variables_schema: {
1139
- type: "object",
1140
- properties: variables.reduce((acc, v) => {
1141
- acc[v.name] = {
1142
- type: v.type,
1143
- description: v.description
1144
- };
1145
- if (v.default !== void 0) acc[v.name].default = v.default;
1146
- return acc;
1147
- }, {}),
1148
- required: requiredVars,
1149
- additionalProperties: false
1150
- },
1151
- includes: includes.length > 0 ? includes : []
1152
- };
1153
- if (instruction) boilerplateDefinition.instruction = instruction;
1154
- scaffoldConfig.boilerplate.push(boilerplateDefinition);
1155
- const yamlContent = this.dumpYamlWithLiteralBlocks(scaffoldConfig);
1156
- await fs_extra.writeFile(scaffoldYamlPath, yamlContent, "utf-8");
1157
- return {
1158
- success: true,
1159
- message: `Boilerplate '${boilerplateName}' added to ${scaffoldYamlPath}`,
1160
- templatePath,
1161
- scaffoldYamlPath
1162
- };
1163
- }
1164
- /**
1165
- * List all templates (directories in templates folder)
1166
- */
1167
- async listTemplates() {
1168
- return (await fs_extra.readdir(this.templatesPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1169
- }
1170
- /**
1171
- * Check if a template exists
1172
- */
1173
- async templateExists(templateName) {
1174
- const templatePath = node_path.join(this.templatesPath, templateName);
1175
- return fs_extra.pathExists(templatePath);
1176
- }
1177
- /**
1178
- * Create or update a template file for a boilerplate
1179
- */
1180
- async createTemplateFile(options) {
1181
- const { templateName, filePath, content, sourceFile, header } = options;
1182
- const templatePath = node_path.join(this.templatesPath, templateName);
1183
- if (!await fs_extra.pathExists(templatePath)) return {
1184
- success: false,
1185
- message: `Template directory '${templateName}' does not exist at ${templatePath}`
1186
- };
1187
- let fileContent = content || "";
1188
- if (sourceFile) {
1189
- if (!await fs_extra.pathExists(sourceFile)) return {
1190
- success: false,
1191
- message: `Source file '${sourceFile}' does not exist`
1192
- };
1193
- fileContent = await fs_extra.readFile(sourceFile, "utf-8");
1194
- }
1195
- if (!fileContent && !sourceFile) return {
1196
- success: false,
1197
- message: "Either content or sourceFile must be provided"
1198
- };
1199
- const templateFilePath = filePath.endsWith(".liquid") ? filePath : `${filePath}.liquid`;
1200
- const fullPath = node_path.join(templatePath, templateFilePath);
1201
- await fs_extra.ensureDir(node_path.dirname(fullPath));
1202
- let finalContent = fileContent;
1203
- if (header) finalContent = `${header}\n\n${fileContent}`;
1204
- await fs_extra.writeFile(fullPath, finalContent, "utf-8");
1205
- return {
1206
- success: true,
1207
- message: "Template file created successfully",
1208
- filePath: templateFilePath,
1209
- fullPath
1210
- };
1211
- }
1212
- };
1213
-
1214
- //#endregion
1215
- //#region src/tools/GenerateBoilerplateFileTool.ts
1216
- /**
1217
- * Tool to generate template files for boilerplates and features
1218
- */
1219
- var GenerateBoilerplateFileTool = class GenerateBoilerplateFileTool {
1220
- static TOOL_NAME = "generate-boilerplate-file";
1221
- boilerplateGeneratorService;
1222
- constructor(templatesPath) {
1223
- this.boilerplateGeneratorService = new BoilerplateGeneratorService(templatesPath);
1224
- }
1225
- /**
1226
- * Get the tool definition for MCP
1227
- */
1228
- getDefinition() {
1229
- return {
1230
- name: GenerateBoilerplateFileTool.TOOL_NAME,
1231
- description: `Create or update template files for boilerplates or features in the specified template directory.
1232
-
1233
- This tool:
1234
- - Creates template files with .liquid extension for variable substitution
1235
- - Supports creating nested directory structures
1236
- - Can create files from source files (copying and converting to templates)
1237
- - Validates that the template directory exists
1238
- - Works for both boilerplate includes and feature scaffold includes
1239
-
1240
- IMPORTANT - Always add header comments:
1241
- - For code files (*.ts, *.tsx, *.js, *.jsx), ALWAYS include a header parameter with design patterns, coding standards, and things to avoid
1242
- - Headers help AI understand and follow established patterns when working with generated code
1243
- - Use the header parameter to document the architectural decisions and best practices
1244
-
1245
- Use this after generate-boilerplate or generate-feature-scaffold to create the actual template files referenced in the includes array.`,
1246
- inputSchema: {
1247
- type: "object",
1248
- properties: {
1249
- templateName: {
1250
- type: "string",
1251
- description: "Name of the template folder (must already exist)"
1252
- },
1253
- filePath: {
1254
- type: "string",
1255
- description: "Path of the file to create within the template (e.g., \"package.json\", \"src/app/page.tsx\")"
1256
- },
1257
- content: {
1258
- type: "string",
1259
- description: `Content of the template file using Liquid template syntax.
1260
-
1261
- LIQUID SYNTAX:
1262
- - Variables: {{ variableName }} - Replaced with actual values
1263
- - Conditionals: {% if condition %}...{% endif %} - Conditional rendering
1264
- - Else: {% if condition %}...{% else %}...{% endif %}
1265
- - Elsif: {% if condition %}...{% elsif other %}...{% endif %}
1266
- - Equality: {% if var == 'value' %}...{% endif %}
1267
-
1268
- AVAILABLE FILTERS:
1269
- You can transform variables using these filters with the pipe (|) syntax:
1270
-
1271
- Case Conversion:
1272
- - {{ name | camelCase }} - Convert to camelCase (myVariableName)
1273
- - {{ name | pascalCase }} - Convert to PascalCase (MyVariableName)
1274
- - {{ name | titleCase }} - Convert to TitleCase (alias for pascalCase)
1275
- - {{ name | kebabCase }} - Convert to kebab-case (my-variable-name)
1276
- - {{ name | snakeCase }} - Convert to snake_case (my_variable_name)
1277
- - {{ name | upperCase }} - Convert to UPPER_CASE (MY_VARIABLE_NAME)
1278
- - {{ name | lower }} or {{ name | downcase }} - Convert to lowercase
1279
- - {{ name | upper }} or {{ name | upcase }} - Convert to UPPERCASE
1280
-
1281
- String Manipulation:
1282
- - {{ name | strip }} - Remove leading/trailing whitespace
1283
- - {{ name | replace: "old", "new" }} - Replace text (e.g., replace: "Tool", "")
1284
- - {{ name | pluralize }} - Add plural suffix (simple: book → books, class → classes)
1285
- - {{ name | singularize }} - Remove plural suffix (simple: books → book)
1286
-
1287
- Chaining Filters:
1288
- - {{ toolName | downcase | replace: "tool", "" | strip }} - Combine multiple filters
1289
-
1290
- Example with variables and conditionals:
1291
- {
1292
- "name": "{{ packageName }}",{% if withFeature %}
1293
- "feature": "enabled",{% endif %}
1294
- "dependencies": {
1295
- "core": "1.0.0"{% if withOptional %},
1296
- "optional": "2.0.0"{% endif %}
1297
- }
1298
- }
1299
-
1300
- Example with filters:
1301
- export class {{ serviceName | pascalCase }} {
1302
- private {{ serviceName | camelCase }}: string;
1303
-
1304
- constructor() {
1305
- this.{{ serviceName | camelCase }} = "{{ serviceName | kebabCase }}";
1306
- }
1307
- }
1308
-
1309
- IMPORTANT - Keep content minimal and business-agnostic:
1310
- - Focus on structure and patterns, not specific business logic
1311
- - Use placeholder data and generic examples
1312
- - Include only essential boilerplate code
1313
- - Demonstrate the pattern, not a complete implementation
1314
- - Let AI fill in business-specific logic later
1315
-
1316
- Example (good - minimal):
1317
- export function {{ functionName }}() {
1318
- // TODO: Implement logic
1319
- return null;
1320
- }
1321
-
1322
- Example (bad - too specific):
1323
- export function calculateTax(income: number) {
1324
- const federalRate = 0.22;
1325
- const stateRate = 0.05;
1326
- return income * (federalRate + stateRate);
1327
- }`
1328
- },
1329
- sourceFile: {
1330
- type: "string",
1331
- description: "Optional: Path to a source file to copy and convert to a template"
1332
- },
1333
- header: {
1334
- type: "string",
1335
- description: `Optional: Header comment to add at the top of the file to provide AI hints about design patterns, coding standards, and best practices.
1336
-
1337
- Example format for TypeScript/JavaScript files:
1338
- /**
1339
- * {{ componentName }} Component
1340
- *
1341
- * DESIGN PATTERNS:
1342
- * - Component pattern description
1343
- * - Architecture decisions
1344
- *
1345
- * CODING STANDARDS:
1346
- * - Naming conventions
1347
- * - Required elements
1348
- *
1349
- * AVOID:
1350
- * - Common pitfalls
1351
- * - Anti-patterns
1352
- */
1353
-
1354
- The header helps AI understand and follow established patterns when working with generated code.`
1355
- }
1356
- },
1357
- required: ["templateName", "filePath"],
1358
- additionalProperties: false
1359
- }
1360
- };
1361
- }
1362
- /**
1363
- * Execute the tool
1364
- */
1365
- async execute(args) {
1366
- try {
1367
- const result = await this.boilerplateGeneratorService.createTemplateFile(args);
1368
- if (!result.success) return {
1369
- content: [{
1370
- type: "text",
1371
- text: result.message
1372
- }],
1373
- isError: true
1374
- };
1375
- return { content: [{
1376
- type: "text",
1377
- text: JSON.stringify({
1378
- success: true,
1379
- message: result.message,
1380
- filePath: result.filePath,
1381
- fullPath: result.fullPath,
1382
- sourceFile: args.sourceFile || null
1383
- }, null, 2)
1384
- }] };
1385
- } catch (error) {
1386
- return {
1387
- content: [{
1388
- type: "text",
1389
- text: `Error creating template file: ${error instanceof Error ? error.message : String(error)}`
1390
- }],
1391
- isError: true
1392
- };
1393
- }
1394
- }
1395
- };
1396
-
1397
- //#endregion
1398
- //#region src/tools/GenerateBoilerplateTool.ts
1399
- /**
1400
- * Tool to generate a new boilerplate configuration in scaffold.yaml
1401
- */
1402
- var GenerateBoilerplateTool = class GenerateBoilerplateTool {
1403
- static TOOL_NAME = "generate-boilerplate";
1404
- boilerplateGeneratorService;
1405
- constructor(templatesPath) {
1406
- this.boilerplateGeneratorService = new BoilerplateGeneratorService(templatesPath);
1407
- }
1408
- /**
1409
- * Get the tool definition for MCP
1410
- */
1411
- getDefinition() {
1412
- return {
1413
- name: GenerateBoilerplateTool.TOOL_NAME,
1414
- description: `Add a new boilerplate configuration to a template's scaffold.yaml file.
1415
-
1416
- This tool:
1417
- - Creates or updates scaffold.yaml in the specified template directory
1418
- - Adds a boilerplate entry with proper schema following the nextjs-15 pattern
1419
- - Validates the boilerplate name doesn't already exist
1420
- - Creates the template directory if it doesn't exist
1421
-
1422
- Use this to add custom boilerplate configurations for frameworks not yet supported or for your specific project needs.`,
1423
- inputSchema: {
1424
- type: "object",
1425
- properties: {
1426
- templateName: {
1427
- type: "string",
1428
- description: "Name of the template folder (kebab-case, e.g., \"my-framework\")"
1429
- },
1430
- boilerplateName: {
1431
- type: "string",
1432
- description: "Name of the boilerplate (kebab-case, e.g., \"scaffold-my-app\")"
1433
- },
1434
- targetFolder: {
1435
- type: "string",
1436
- description: "Target folder where projects will be created (e.g., \"apps\", \"packages\")"
1437
- },
1438
- description: {
1439
- type: "string",
1440
- description: `Detailed description of what this boilerplate creates and its key features.
1441
-
1442
- STRUCTURE (3-5 sentences in multiple paragraphs):
1443
- - Paragraph 1: Core technology stack and primary value proposition
1444
- - Paragraph 2: Target use cases and ideal project types
1445
- - Paragraph 3: Key integrations or special features (if applicable)
1446
-
1447
- Example: "A modern React SPA template powered by Vite for lightning-fast HMR, featuring TanStack Router for type-safe routing and TanStack Query for server state management.
1448
- Perfect for building data-driven dashboards, admin panels, and interactive web applications requiring client-side routing and real-time data synchronization.
1449
-
1450
- Includes Agiflow Config Management System integration with systematic environment variable naming (VITE_{CATEGORY}_{SUBCATEGORY}_{PROPERTY}) and auto-generated configuration templates for cloud deployment."`
1451
- },
1452
- instruction: {
1453
- type: "string",
1454
- description: `Optional detailed instructions about the generated files, their purposes, and how to work with them.
1455
-
1456
- STRUCTURE (Multi-section guide):
1457
-
1458
- 1. **File purposes** section:
1459
- List each major file/directory with its purpose
1460
- Format: "- path/to/file: Description of what this file does"
1461
-
1462
- 2. **How to use the scaffolded code** section:
1463
- Step-by-step workflows for common tasks
1464
- Format: Numbered list with specific examples
1465
- - How to add routes/pages
1466
- - How to fetch data
1467
- - How to handle authentication
1468
- - How to configure environment variables
1469
-
1470
- 3. **Design patterns to follow** section:
1471
- Key architectural decisions and conventions
1472
- Format: "- Pattern Name: Explanation and when to use it"
1473
- - Routing patterns
1474
- - State management patterns
1475
- - Data fetching patterns
1476
- - Error handling patterns
1477
- - Performance optimization patterns
1478
-
1479
- Example: "[Framework] application template with [key technologies].
1480
-
1481
- File purposes:
1482
- - package.json: NPM package configuration with [framework] and dependencies
1483
- - src/main.tsx: Application entry point with [setup details]
1484
- - src/routes/: Route definitions following [pattern]
1485
- [... list all major files ...]
1486
-
1487
- How to use the scaffolded code:
1488
- 1. Routes: Create new routes by [specific instructions with example]
1489
- 2. Data Fetching: Use [specific pattern] for [use case]
1490
- 3. Authentication: Use [specific components/modules] for user management
1491
- [... numbered steps for common tasks ...]
1492
-
1493
- Design patterns to follow:
1494
- - File-based Routing: Use directory structure in src/routes/ to define URL paths
1495
- - Type-safe Routes: Leverage [framework] type inference for params
1496
- - State Management: Use [library] for server state, [library] for client state
1497
- [... list key patterns with explanations ...]"`
1498
- },
1499
- variables: {
1500
- type: "array",
1501
- description: "Array of variable definitions for the boilerplate",
1502
- items: {
1503
- type: "object",
1504
- properties: {
1505
- name: {
1506
- type: "string",
1507
- description: "Variable name (camelCase)"
1508
- },
1509
- description: {
1510
- type: "string",
1511
- description: "Variable description"
1512
- },
1513
- type: {
1514
- type: "string",
1515
- enum: [
1516
- "string",
1517
- "number",
1518
- "boolean"
1519
- ],
1520
- description: "Variable type"
1521
- },
1522
- required: {
1523
- type: "boolean",
1524
- description: "Whether this variable is required"
1525
- },
1526
- default: { description: "Optional default value for the variable" }
1527
- },
1528
- required: [
1529
- "name",
1530
- "description",
1531
- "type",
1532
- "required"
1533
- ]
1534
- }
1535
- },
1536
- includes: {
1537
- type: "array",
1538
- description: `Array of specific file paths to include in the boilerplate (highly recommended to list explicitly).
1539
-
1540
- Examples:
1541
- - ["package.json", "tsconfig.json", "src/index.ts"] - Explicit file list (recommended)
1542
- - ["**/*"] - Include all files (not recommended, too broad)
1543
-
1544
- Best practices:
1545
- - List each file explicitly for clarity and control
1546
- - Use relative paths from the template root
1547
- - Include configuration files (package.json, tsconfig.json, etc.)
1548
- - Include source files (src/index.ts, src/app/page.tsx, etc.)
1549
- - Avoid wildcards unless you have a good reason
1550
-
1551
- See templates/nextjs-15/scaffold.yaml for a good example of explicit file listing.`,
1552
- items: { type: "string" }
1553
- }
1554
- },
1555
- required: [
1556
- "templateName",
1557
- "boilerplateName",
1558
- "description",
1559
- "targetFolder",
1560
- "variables"
1561
- ],
1562
- additionalProperties: false
1563
- }
1564
- };
1565
- }
1566
- /**
1567
- * Execute the tool
1568
- */
1569
- async execute(args) {
1570
- try {
1571
- const result = await this.boilerplateGeneratorService.generateBoilerplate(args);
1572
- if (!result.success) return {
1573
- content: [{
1574
- type: "text",
1575
- text: result.message
1576
- }],
1577
- isError: true
1578
- };
1579
- return { content: [{
1580
- type: "text",
1581
- text: JSON.stringify({
1582
- success: true,
1583
- message: result.message,
1584
- templatePath: result.templatePath,
1585
- scaffoldYamlPath: result.scaffoldYamlPath,
1586
- nextSteps: [
1587
- "Use generate-boilerplate-file tool to create template files for the includes array",
1588
- "Customize the template files with Liquid variable placeholders ({{ variableName }})",
1589
- `Test with: scaffold-mcp boilerplate create ${args.boilerplateName} --vars '{"appName":"test"}'`
1590
- ]
1591
- }, null, 2)
1592
- }] };
1593
- } catch (error) {
1594
- return {
1595
- content: [{
1596
- type: "text",
1597
- text: `Error generating boilerplate: ${error instanceof Error ? error.message : String(error)}`
1598
- }],
1599
- isError: true
1600
- };
1601
- }
1602
- }
1603
- };
1604
-
1605
- //#endregion
1606
- //#region src/services/ScaffoldGeneratorService.ts
1607
- /**
1608
- * Service for generating feature scaffold configurations in scaffold.yaml files
1609
- */
1610
- var ScaffoldGeneratorService = class {
1611
- templatesPath;
1612
- constructor(templatesPath) {
1613
- this.templatesPath = templatesPath;
1614
- }
1615
- /**
1616
- * Custom YAML dumper that forces literal block style (|) for description and instruction fields
1617
- */
1618
- dumpYamlWithLiteralBlocks(config) {
1619
- const LiteralBlockType = new js_yaml.Type("tag:yaml.org,2002:str", {
1620
- kind: "scalar",
1621
- construct: (data) => data,
1622
- represent: (data) => {
1623
- return data;
1624
- },
1625
- defaultStyle: "|"
1626
- });
1627
- const LITERAL_SCHEMA = js_yaml.DEFAULT_SCHEMA.extend([LiteralBlockType]);
1628
- const processedConfig = this.processConfigForLiteralBlocks(config);
1629
- return js_yaml.dump(processedConfig, {
1630
- schema: LITERAL_SCHEMA,
1631
- indent: 2,
1632
- lineWidth: -1,
1633
- noRefs: true,
1634
- sortKeys: false,
1635
- styles: { "!!str": "literal" },
1636
- replacer: (key, value) => {
1637
- if ((key === "description" || key === "instruction") && typeof value === "string") return value;
1638
- return value;
1639
- }
1640
- });
1641
- }
1642
- /**
1643
- * Process config to ensure description and instruction use literal block style
1644
- */
1645
- processConfigForLiteralBlocks(config) {
1646
- const processed = JSON.parse(JSON.stringify(config));
1647
- if (processed.boilerplate) processed.boilerplate = processed.boilerplate.map((bp) => {
1648
- const newBp = { ...bp };
1649
- if (newBp.description && typeof newBp.description === "string") newBp.description = this.ensureMultilineFormat(newBp.description);
1650
- if (newBp.instruction && typeof newBp.instruction === "string") newBp.instruction = this.ensureMultilineFormat(newBp.instruction);
1651
- return newBp;
1652
- });
1653
- if (processed.features) processed.features = processed.features.map((feature) => {
1654
- const newFeature = { ...feature };
1655
- if (newFeature.description && typeof newFeature.description === "string") newFeature.description = this.ensureMultilineFormat(newFeature.description);
1656
- if (newFeature.instruction && typeof newFeature.instruction === "string") newFeature.instruction = this.ensureMultilineFormat(newFeature.instruction);
1657
- return newFeature;
1658
- });
1659
- return processed;
1660
- }
1661
- /**
1662
- * Ensure string is properly formatted for YAML literal blocks
1663
- */
1664
- ensureMultilineFormat(text) {
1665
- return text.trim();
1666
- }
1667
- /**
1668
- * Generate or update a feature configuration in scaffold.yaml
1669
- */
1670
- async generateFeatureScaffold(options) {
1671
- const { templateName, featureName, description, instruction, variables, includes = [], patterns = [] } = options;
1672
- const templatePath = node_path.join(this.templatesPath, templateName);
1673
- await fs_extra.ensureDir(templatePath);
1674
- const scaffoldYamlPath = node_path.join(templatePath, "scaffold.yaml");
1675
- let scaffoldConfig = {};
1676
- if (await fs_extra.pathExists(scaffoldYamlPath)) {
1677
- const yamlContent$1 = await fs_extra.readFile(scaffoldYamlPath, "utf-8");
1678
- scaffoldConfig = js_yaml.load(yamlContent$1);
1679
- }
1680
- if (!scaffoldConfig.features) scaffoldConfig.features = [];
1681
- if (scaffoldConfig.features.findIndex((f) => f.name === featureName) !== -1) return {
1682
- success: false,
1683
- message: `Feature '${featureName}' already exists in ${scaffoldYamlPath}`
1684
- };
1685
- const requiredVars = variables.filter((v) => v.required).map((v) => v.name);
1686
- const featureDefinition = {
1687
- name: featureName,
1688
- description,
1689
- variables_schema: {
1690
- type: "object",
1691
- properties: variables.reduce((acc, v) => {
1692
- acc[v.name] = {
1693
- type: v.type,
1694
- description: v.description
1695
- };
1696
- if (v.default !== void 0) acc[v.name].default = v.default;
1697
- return acc;
1698
- }, {}),
1699
- required: requiredVars,
1700
- additionalProperties: false
1701
- },
1702
- includes: includes.length > 0 ? includes : []
1703
- };
1704
- if (instruction) featureDefinition.instruction = instruction;
1705
- if (patterns && patterns.length > 0) featureDefinition.patterns = patterns;
1706
- scaffoldConfig.features.push(featureDefinition);
1707
- const yamlContent = this.dumpYamlWithLiteralBlocks(scaffoldConfig);
1708
- await fs_extra.writeFile(scaffoldYamlPath, yamlContent, "utf-8");
1709
- return {
1710
- success: true,
1711
- message: `Feature '${featureName}' added to ${scaffoldYamlPath}`,
1712
- templatePath,
1713
- scaffoldYamlPath
1714
- };
1715
- }
1716
- /**
1717
- * List all templates (directories in templates folder)
1718
- */
1719
- async listTemplates() {
1720
- return (await fs_extra.readdir(this.templatesPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1721
- }
1722
- /**
1723
- * Check if a template exists
1724
- */
1725
- async templateExists(templateName) {
1726
- const templatePath = node_path.join(this.templatesPath, templateName);
1727
- return fs_extra.pathExists(templatePath);
1728
- }
1729
- };
1730
-
1731
- //#endregion
1732
- //#region src/tools/GenerateFeatureScaffoldTool.ts
1733
- /**
1734
- * Tool to generate a new feature scaffold configuration in scaffold.yaml
1735
- */
1736
- var GenerateFeatureScaffoldTool = class GenerateFeatureScaffoldTool {
1737
- static TOOL_NAME = "generate-feature-scaffold";
1738
- scaffoldGeneratorService;
1739
- constructor(templatesPath) {
1740
- this.scaffoldGeneratorService = new ScaffoldGeneratorService(templatesPath);
1741
- }
1742
- /**
1743
- * Get the tool definition for MCP
1744
- */
1745
- getDefinition() {
1746
- return {
1747
- name: GenerateFeatureScaffoldTool.TOOL_NAME,
1748
- description: `Add a new feature scaffold configuration to a template's scaffold.yaml file.
1749
-
1750
- This tool:
1751
- - Creates or updates scaffold.yaml in the specified template directory
1752
- - Adds a feature entry with proper schema following the nextjs-15 pattern
1753
- - Validates the feature name doesn't already exist
1754
- - Creates the template directory if it doesn't exist
1755
-
1756
- Use this to add custom feature scaffolds (pages, components, services, etc.) for frameworks not yet supported or for your specific project needs.`,
1757
- inputSchema: {
1758
- type: "object",
1759
- properties: {
1760
- templateName: {
1761
- type: "string",
1762
- description: "Name of the template folder (kebab-case, e.g., \"nextjs-15\")"
1763
- },
1764
- featureName: {
1765
- type: "string",
1766
- description: "Name of the feature (kebab-case, e.g., \"scaffold-nextjs-page\")"
1767
- },
1768
- description: {
1769
- type: "string",
1770
- description: `Detailed description of what this feature creates and its key capabilities.
1771
-
1772
- STRUCTURE (2-3 sentences):
1773
- - Sentence 1: What type of code it generates (component, page, service, etc.)
1774
- - Sentence 2: Key features or capabilities included
1775
- - Sentence 3: Primary use cases or when to use it
1776
-
1777
- Example: "Generate a new service class for TypeScript libraries following best practices. Creates a service class with interface, implementation, and unit tests. Perfect for creating reusable service modules with dependency injection patterns."`
1778
- },
1779
- instruction: {
1780
- type: "string",
1781
- description: `Optional detailed instructions about the generated files, their purposes, and how to work with them.
1782
-
1783
- STRUCTURE (Concise multi-aspect guide):
1784
-
1785
- 1. **Pattern explanation**: Describe the architectural pattern used
1786
- 2. **File organization**: Where files should be placed
1787
- 3. **Naming conventions**: How to name things (PascalCase, camelCase, etc.)
1788
- 4. **Usage guidelines**: How to use the generated code
1789
- 5. **Testing approach**: How to test the feature
1790
-
1791
- Example: "Services follow a class-based pattern with optional interface separation. The service class implements business logic and can be dependency injected. Place services in src/services/ directory. For services with interfaces, define the interface in src/types/interfaces/ for better separation of concerns. Service names should be PascalCase and end with 'Service' suffix. Write comprehensive unit tests for all public methods."`
1792
- },
1793
- variables: {
1794
- type: "array",
1795
- description: "Array of variable definitions for the feature",
1796
- items: {
1797
- type: "object",
1798
- properties: {
1799
- name: {
1800
- type: "string",
1801
- description: "Variable name (camelCase)"
1802
- },
1803
- description: {
1804
- type: "string",
1805
- description: "Variable description"
1806
- },
1807
- type: {
1808
- type: "string",
1809
- enum: [
1810
- "string",
1811
- "number",
1812
- "boolean"
1813
- ],
1814
- description: "Variable type"
1815
- },
1816
- required: {
1817
- type: "boolean",
1818
- description: "Whether this variable is required"
1819
- },
1820
- default: { description: "Optional default value for the variable" }
1821
- },
1822
- required: [
1823
- "name",
1824
- "description",
1825
- "type",
1826
- "required"
1827
- ]
1828
- }
1829
- },
1830
- includes: {
1831
- type: "array",
1832
- description: `Array of specific file paths to include in the feature (highly recommended to list explicitly).
1833
-
1834
- Supports advanced syntax:
1835
- - Basic: "src/app/page/page.tsx" - Always included
1836
- - Conditional: "src/app/page/layout.tsx?withLayout=true" - Only included when withLayout variable is true
1837
- - Multiple conditions: "file.tsx?withLayout=true&withTests=true" - Use & to combine conditions
1838
- - Path mapping: "source.tsx->target/path.tsx" - Map source template file to different target path
1839
- - Combined: "source.tsx->{{ pagePath }}/page.tsx?withPage=true" - Combine path mapping with variables and conditions
1840
-
1841
- Examples:
1842
- - ["src/components/Button.tsx", "src/components/Button.test.tsx"] - Explicit file list (recommended)
1843
- - ["src/app/page/page.tsx", "src/app/page/layout.tsx?withLayout=true"] - Conditional include
1844
- - ["template.tsx->src/app/{{ pagePath }}/page.tsx"] - Dynamic path with variables
1845
-
1846
- Best practices:
1847
- - List each file explicitly for clarity and control
1848
- - Use relative paths from the template root
1849
- - Use conditional includes with ?variableName=value for optional files
1850
- - Use path mapping with -> when source and target paths differ
1851
- - Use {{ variableName }} in target paths for dynamic file placement
1852
- - Avoid wildcards unless you have a good reason`,
1853
- items: { type: "string" }
1854
- },
1855
- patterns: {
1856
- type: "array",
1857
- description: `Optional array of glob patterns to match existing files that this feature works with.
1858
-
1859
- Used to help identify where this feature can be applied in a project.
1860
-
1861
- Examples:
1862
- - ["src/app/**/page.tsx", "src/app/**/layout.tsx"] - Next.js app router files
1863
- - ["src/components/**/*.tsx"] - React component files
1864
- - ["src/services/**/*.ts"] - Service files
1865
-
1866
- Best practices:
1867
- - Use glob patterns that match the file types this feature works with
1868
- - Keep patterns specific enough to be meaningful but broad enough to be useful
1869
- - Consider both the feature's output and input files`,
1870
- items: { type: "string" }
1871
- }
1872
- },
1873
- required: [
1874
- "templateName",
1875
- "featureName",
1876
- "description",
1877
- "variables"
1878
- ],
1879
- additionalProperties: false
1880
- }
1881
- };
1882
- }
1883
- /**
1884
- * Execute the tool
1885
- */
1886
- async execute(args) {
1887
- try {
1888
- const result = await this.scaffoldGeneratorService.generateFeatureScaffold(args);
1889
- if (!result.success) return {
1890
- content: [{
1891
- type: "text",
1892
- text: result.message
1893
- }],
1894
- isError: true
1895
- };
1896
- return { content: [{
1897
- type: "text",
1898
- text: JSON.stringify({
1899
- success: true,
1900
- message: result.message,
1901
- templatePath: result.templatePath,
1902
- scaffoldYamlPath: result.scaffoldYamlPath,
1903
- nextSteps: [
1904
- "Use generate-boilerplate-file tool to create template files for the includes array",
1905
- "Customize the template files with Liquid variable placeholders ({{ variableName }})",
1906
- "Create the generator file if it uses custom logic (referenced in the generator field)",
1907
- `Test with: scaffold-mcp feature create ${args.featureName} --vars '{"appName":"test"}'`
1908
- ]
1909
- }, null, 2)
1910
- }] };
1911
- } catch (error) {
1912
- return {
1913
- content: [{
1914
- type: "text",
1915
- text: `Error generating feature scaffold: ${error instanceof Error ? error.message : String(error)}`
1916
- }],
1917
- isError: true
1918
- };
1919
- }
1920
- }
1921
- };
1922
-
1923
- //#endregion
1924
- //#region src/tools/ListBoilerplatesTool.ts
1925
- var ListBoilerplatesTool = class ListBoilerplatesTool {
1926
- static TOOL_NAME = "list-boilerplates";
1927
- boilerplateService;
1928
- constructor(templatesPath) {
1929
- this.boilerplateService = new BoilerplateService(templatesPath);
1930
- }
1931
- /**
1932
- * Get the tool definition for MCP
1933
- */
1934
- getDefinition() {
1935
- return {
1936
- name: ListBoilerplatesTool.TOOL_NAME,
1937
- description: `Lists all available project boilerplates for creating new applications, APIs, or packages in the monorepo.
1938
-
1939
- Each boilerplate includes:
1940
- - Complete project template with starter files
1941
- - Variable schema for customization
1942
- - Target directory information
1943
- - Required and optional configuration options
1944
-
1945
- Use this FIRST when creating new projects to understand available templates and their requirements.`,
1946
- inputSchema: {
1947
- type: "object",
1948
- properties: {},
1949
- additionalProperties: false
1950
- }
1951
- };
1952
- }
1953
- /**
1954
- * Execute the tool
1955
- */
1956
- async execute(_args = {}) {
1957
- try {
1958
- const result = await this.boilerplateService.listBoilerplates();
1959
- return { content: [{
1960
- type: "text",
1961
- text: JSON.stringify(result, null, 2)
1962
- }] };
1963
- } catch (error) {
1964
- return {
1965
- content: [{
1966
- type: "text",
1967
- text: `Error listing boilerplates: ${error instanceof Error ? error.message : String(error)}`
1968
- }],
1969
- isError: true
1970
- };
1971
- }
1972
- }
1973
- };
1974
-
1975
- //#endregion
1976
- //#region src/services/ScaffoldingMethodsService.ts
1977
- var ScaffoldingMethodsService = class {
1978
- templateService;
1979
- constructor(fileSystem, templatesRootPath) {
1980
- this.fileSystem = fileSystem;
1981
- this.templatesRootPath = templatesRootPath;
1982
- this.templateService = new require_TemplateService.TemplateService();
1983
- }
1984
- async listScaffoldingMethods(projectPath) {
1985
- const absoluteProjectPath = node_path.default.resolve(projectPath);
1986
- const sourceTemplate = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(absoluteProjectPath)).sourceTemplate;
1987
- const templatePath = await this.findTemplatePath(sourceTemplate);
1988
- if (!templatePath) throw new Error(`Template not found for sourceTemplate: ${sourceTemplate}`);
1989
- const fullTemplatePath = node_path.default.join(this.templatesRootPath, templatePath);
1990
- const scaffoldYamlPath = node_path.default.join(fullTemplatePath, "scaffold.yaml");
1991
- if (!await this.fileSystem.pathExists(scaffoldYamlPath)) throw new Error(`scaffold.yaml not found at ${scaffoldYamlPath}`);
1992
- const scaffoldContent = await this.fileSystem.readFile(scaffoldYamlPath, "utf8");
1993
- const architectConfig = js_yaml.default.load(scaffoldContent);
1994
- const methods = [];
1995
- if (architectConfig.features && Array.isArray(architectConfig.features)) architectConfig.features.forEach((feature) => {
1996
- if (feature.name) methods.push({
1997
- name: feature.name,
1998
- description: feature.description || "",
1999
- instruction: feature.instruction || "",
2000
- variables_schema: feature.variables_schema || {
2001
- type: "object",
2002
- properties: {},
2003
- required: [],
2004
- additionalProperties: false
2005
- },
2006
- generator: feature.generator
2007
- });
2008
- });
2009
- return {
2010
- sourceTemplate,
2011
- templatePath,
2012
- methods
2013
- };
2014
- }
2015
- /**
2016
- * Gets scaffolding methods with instructions rendered using provided variables
2017
- */
2018
- async listScaffoldingMethodsWithVariables(projectPath, variables) {
2019
- const result = await this.listScaffoldingMethods(projectPath);
2020
- const processedMethods = result.methods.map((method) => ({
2021
- ...method,
2022
- instruction: method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : void 0
2023
- }));
2024
- return {
2025
- ...result,
2026
- methods: processedMethods
2027
- };
2028
- }
2029
- /**
2030
- * Processes scaffold instruction with template service
2031
- */
2032
- processScaffoldInstruction(instruction, variables) {
2033
- if (this.templateService.containsTemplateVariables(instruction)) return this.templateService.renderString(instruction, variables);
2034
- return instruction;
2035
- }
2036
- async findTemplatePath(sourceTemplate) {
2037
- const templateDirs = await this.discoverTemplateDirs();
2038
- if (templateDirs.includes(sourceTemplate)) return sourceTemplate;
2039
- for (const templateDir of templateDirs) {
2040
- const templatePath = node_path.default.join(this.templatesRootPath, templateDir);
2041
- const scaffoldYamlPath = node_path.default.join(templatePath, "scaffold.yaml");
2042
- if (await this.fileSystem.pathExists(scaffoldYamlPath)) try {
2043
- const scaffoldContent = await this.fileSystem.readFile(scaffoldYamlPath, "utf8");
2044
- const architectConfig = js_yaml.default.load(scaffoldContent);
2045
- if (architectConfig.boilerplate && Array.isArray(architectConfig.boilerplate)) {
2046
- for (const boilerplate of architectConfig.boilerplate) if (boilerplate.name?.includes(sourceTemplate)) return templateDir;
2047
- }
2048
- } catch (error) {
2049
- __agiflowai_aicode_utils.log.warn(`Failed to read scaffold.yaml at ${scaffoldYamlPath}:`, error);
2050
- }
2051
- }
2052
- return null;
2053
- }
2054
- /**
2055
- * Dynamically discovers all template directories
2056
- * Supports both flat structure (templates/nextjs-15) and nested structure (templates/apps/nextjs-15)
2057
- **/
2058
- async discoverTemplateDirs() {
2059
- const templateDirs = [];
2060
- try {
2061
- const items = await this.fileSystem.readdir(this.templatesRootPath);
2062
- for (const item of items) {
2063
- const itemPath = node_path.default.join(this.templatesRootPath, item);
2064
- if (!(await this.fileSystem.stat(itemPath)).isDirectory()) continue;
2065
- const scaffoldYamlPath = node_path.default.join(itemPath, "scaffold.yaml");
2066
- if (await this.fileSystem.pathExists(scaffoldYamlPath)) {
2067
- templateDirs.push(item);
2068
- continue;
2069
- }
2070
- try {
2071
- const subItems = await this.fileSystem.readdir(itemPath);
2072
- for (const subItem of subItems) {
2073
- const subItemPath = node_path.default.join(itemPath, subItem);
2074
- if (!(await this.fileSystem.stat(subItemPath)).isDirectory()) continue;
2075
- const subScaffoldYamlPath = node_path.default.join(subItemPath, "scaffold.yaml");
2076
- if (await this.fileSystem.pathExists(subScaffoldYamlPath)) {
2077
- const relativePath = node_path.default.join(item, subItem);
2078
- templateDirs.push(relativePath);
2079
- }
2080
- }
2081
- } catch (error) {
2082
- __agiflowai_aicode_utils.log.warn(`Failed to read subdirectories in ${itemPath}:`, error);
2083
- }
2084
- }
2085
- } catch (error) {
2086
- __agiflowai_aicode_utils.log.warn(`Failed to read templates root directory ${this.templatesRootPath}:`, error);
2087
- }
2088
- return templateDirs;
2089
- }
2090
- async useScaffoldMethod(request) {
2091
- const { projectPath, scaffold_feature_name, variables } = request;
2092
- const scaffoldingMethods = await this.listScaffoldingMethods(projectPath);
2093
- const method = scaffoldingMethods.methods.find((m) => m.name === scaffold_feature_name);
2094
- if (!method) {
2095
- const availableMethods = scaffoldingMethods.methods.map((m) => m.name).join(", ");
2096
- throw new Error(`Scaffold method '${scaffold_feature_name}' not found. Available methods: ${availableMethods}`);
2097
- }
2098
- const ScaffoldService$1 = (await Promise.resolve().then(() => require("./ScaffoldService-BvD9WvRi.cjs"))).ScaffoldService;
2099
- const ScaffoldConfigLoader$1 = (await Promise.resolve().then(() => require("./ScaffoldConfigLoader-DzcV5a_c.cjs"))).ScaffoldConfigLoader;
2100
- const VariableReplacementService$1 = (await Promise.resolve().then(() => require("./VariableReplacementService-YUpL5nAC.cjs"))).VariableReplacementService;
2101
- const TemplateService$1 = (await Promise.resolve().then(() => require("./TemplateService-B5EZjPB0.cjs"))).TemplateService;
2102
- const templateService = new TemplateService$1();
2103
- const scaffoldConfigLoader = new ScaffoldConfigLoader$1(this.fileSystem, templateService);
2104
- const variableReplacer = new VariableReplacementService$1(this.fileSystem, templateService);
2105
- const scaffoldService = new ScaffoldService$1(this.fileSystem, scaffoldConfigLoader, variableReplacer, this.templatesRootPath);
2106
- const absoluteProjectPath = node_path.default.resolve(projectPath);
2107
- const projectName = node_path.default.basename(absoluteProjectPath);
2108
- const result = await scaffoldService.useFeature({
2109
- projectPath: absoluteProjectPath,
2110
- templateFolder: scaffoldingMethods.templatePath,
2111
- featureName: scaffold_feature_name,
2112
- variables: {
2113
- ...variables,
2114
- appPath: absoluteProjectPath,
2115
- appName: projectName
2116
- }
2117
- });
2118
- if (!result.success) throw new Error(result.message);
2119
- return {
2120
- success: true,
2121
- message: `
2122
- Successfully scaffolded ${scaffold_feature_name} in ${projectPath}.
2123
- Please follow this **instruction**: \n ${method.instruction}.
2124
- -> Create or update the plan based on the instruction.
2125
- `,
2126
- warnings: result.warnings,
2127
- createdFiles: result.createdFiles,
2128
- existingFiles: result.existingFiles
2129
- };
2130
- }
2131
- };
2132
-
2133
- //#endregion
2134
- //#region src/tools/ListScaffoldingMethodsTool.ts
2135
- var ListScaffoldingMethodsTool = class ListScaffoldingMethodsTool {
2136
- static TOOL_NAME = "list-scaffolding-methods";
2137
- fileSystemService;
2138
- scaffoldingMethodsService;
2139
- constructor(templatesPath) {
2140
- this.fileSystemService = new FileSystemService();
2141
- this.scaffoldingMethodsService = new ScaffoldingMethodsService(this.fileSystemService, templatesPath);
2142
- }
2143
- /**
2144
- * Get the tool definition for MCP
2145
- */
2146
- getDefinition() {
2147
- return {
2148
- name: ListScaffoldingMethodsTool.TOOL_NAME,
2149
- description: `Lists all available scaffolding methods (features) that can be added to an existing project.
2150
-
2151
- This tool:
2152
- - Reads the project's sourceTemplate from project.json (monorepo) or toolkit.yaml (monolith)
2153
- - Returns available features for that template type
2154
- - Provides variable schemas for each scaffolding method
2155
- - Shows descriptions of what each method creates
2156
-
2157
- Use this FIRST when adding features to existing projects to understand:
2158
- - What scaffolding methods are available
2159
- - What variables each method requires
2160
- - What files/features will be generated
2161
-
2162
- Example methods might include:
2163
- - Adding new React routes (for React apps)
2164
- - Creating API endpoints (for backend projects)
2165
- - Adding new components (for frontend projects)
2166
- - Setting up database models (for API projects)`,
2167
- inputSchema: {
2168
- type: "object",
2169
- properties: { projectPath: {
2170
- type: "string",
2171
- description: "Absolute path to the project directory (for monorepo: containing project.json; for monolith: workspace root with toolkit.yaml)"
2172
- } },
2173
- required: ["projectPath"],
2174
- additionalProperties: false
2175
- }
2176
- };
2177
- }
2178
- /**
2179
- * Execute the tool
2180
- */
2181
- async execute(args) {
2182
- try {
2183
- const { projectPath } = args;
2184
- if (!projectPath) throw new Error("Missing required parameter: projectPath");
2185
- const result = await this.scaffoldingMethodsService.listScaffoldingMethods(projectPath);
2186
- return { content: [{
2187
- type: "text",
2188
- text: JSON.stringify(result, null, 2)
2189
- }] };
2190
- } catch (error) {
2191
- return {
2192
- content: [{
2193
- type: "text",
2194
- text: `Error listing scaffolding methods: ${error instanceof Error ? error.message : String(error)}`
2195
- }],
2196
- isError: true
2197
- };
2198
- }
2199
- }
2200
- };
2201
-
2202
- //#endregion
2203
- //#region src/tools/UseBoilerplateTool.ts
2204
- var UseBoilerplateTool = class UseBoilerplateTool {
2205
- static TOOL_NAME = "use-boilerplate";
2206
- boilerplateService;
2207
- constructor(templatesPath) {
2208
- this.boilerplateService = new BoilerplateService(templatesPath);
2209
- }
2210
- /**
2211
- * Get the tool definition for MCP
2212
- */
2213
- getDefinition() {
2214
- return {
2215
- name: UseBoilerplateTool.TOOL_NAME,
2216
- description: `Creates a new project from a boilerplate template with the specified variables.
2217
-
2218
- This tool will:
2219
- - Generate all necessary files from the template
2220
- - Replace template variables with provided values
2221
- - Create the project in the appropriate directory (monorepo or monolith)
2222
- - Set up initial configuration files (package.json, tsconfig.json, etc.)
2223
- - Create toolkit.yaml (monolith) or project.json (monorepo) with sourceTemplate
2224
-
2225
- IMPORTANT:
2226
- - Always call \`list-boilerplates\` first to get the exact variable schema
2227
- - Follow the schema exactly - required fields must be provided
2228
- - Use kebab-case for project names (e.g., "my-new-app", not "MyNewApp")
2229
- - The tool will validate all variables against the schema before proceeding
2230
- - For monolith projects, use monolith: true to create at workspace root
2231
- - For monorepo projects, files are created in targetFolder/projectName`,
2232
- inputSchema: {
2233
- type: "object",
2234
- properties: {
2235
- boilerplateName: {
2236
- type: "string",
2237
- description: "Exact name of the boilerplate to use (from list-boilerplates response)"
2238
- },
2239
- variables: {
2240
- type: "object",
2241
- description: "Variables object matching the boilerplate's variables_schema exactly"
2242
- },
2243
- monolith: {
2244
- type: "boolean",
2245
- description: "If true, creates project at workspace root with toolkit.yaml. If false or omitted, creates in targetFolder/projectName with project.json (monorepo mode)"
2246
- },
2247
- targetFolderOverride: {
2248
- type: "string",
2249
- description: "Optional override for target folder. If not provided, uses boilerplate targetFolder (monorepo) or workspace root (monolith)"
2250
- }
2251
- },
2252
- required: ["boilerplateName", "variables"],
2253
- additionalProperties: false
2254
- }
2255
- };
2256
- }
2257
- /**
2258
- * Execute the tool
2259
- */
2260
- async execute(args) {
2261
- try {
2262
- const { boilerplateName, variables, monolith, targetFolderOverride } = args;
2263
- if (!boilerplateName) throw new Error("Missing required parameter: boilerplateName");
2264
- if (!variables) throw new Error("Missing required parameter: variables");
2265
- const request = {
2266
- boilerplateName,
2267
- variables,
2268
- monolith,
2269
- targetFolderOverride
2270
- };
2271
- return { content: [{
2272
- type: "text",
2273
- text: `${(await this.boilerplateService.useBoilerplate(request)).message}
2274
-
2275
- IMPORTANT - Next Steps:
2276
- 1. READ the generated project files to understand their structure
2277
- 2. Review the boilerplate configuration and understand what was created
2278
- 3. If the project requires additional features, use list-scaffolding-methods to see available options
2279
- 4. Install dependencies (pnpm install) before testing or building
2280
- 5. Follow the project's README for setup instructions
2281
-
2282
- The boilerplate provides a starting point - you may need to add features or customize the generated code based on the project requirements.`
2283
- }] };
2284
- } catch (error) {
2285
- return {
2286
- content: [{
2287
- type: "text",
2288
- text: `Error using boilerplate: ${error instanceof Error ? error.message : String(error)}`
2289
- }],
2290
- isError: true
2291
- };
2292
- }
2293
- }
2294
- };
2295
-
2296
- //#endregion
2297
- //#region src/tools/UseScaffoldMethodTool.ts
2298
- var UseScaffoldMethodTool = class UseScaffoldMethodTool {
2299
- static TOOL_NAME = "use-scaffold-method";
2300
- fileSystemService;
2301
- scaffoldingMethodsService;
2302
- constructor(templatesPath) {
2303
- this.fileSystemService = new FileSystemService();
2304
- this.scaffoldingMethodsService = new ScaffoldingMethodsService(this.fileSystemService, templatesPath);
2305
- }
2306
- /**
2307
- * Get the tool definition for MCP
2308
- */
2309
- getDefinition() {
2310
- return {
2311
- name: UseScaffoldMethodTool.TOOL_NAME,
2312
- description: `Generates and adds a specific feature to an existing project using a scaffolding method.
2313
-
2314
- This tool will:
2315
- - Generate files based on the selected scaffolding method
2316
- - Replace template variables with provided values
2317
- - Add files to the appropriate locations in the project
2318
- - Follow the project's existing patterns and conventions
2319
- - Update imports and exports as needed
2320
-
2321
- IMPORTANT:
2322
- - Always call \`list-scaffolding-methods\` first to see available methods and their schemas
2323
- - Use the exact scaffold method name from the list response
2324
- - Provide variables that match the method's variables_schema exactly
2325
- - The tool validates all inputs before generating code
2326
- `,
2327
- inputSchema: {
2328
- type: "object",
2329
- properties: {
2330
- projectPath: {
2331
- type: "string",
2332
- description: "Absolute path to the project directory (for monorepo: containing project.json; for monolith: workspace root with toolkit.yaml)"
2333
- },
2334
- scaffold_feature_name: {
2335
- type: "string",
2336
- description: "Exact name of the scaffold method to use (from list-scaffolding-methods response)"
2337
- },
2338
- variables: {
2339
- type: "object",
2340
- description: "Variables object matching the scaffold method's variables_schema exactly"
2341
- }
2342
- },
2343
- required: [
2344
- "projectPath",
2345
- "scaffold_feature_name",
2346
- "variables"
2347
- ],
2348
- additionalProperties: false
2349
- }
2350
- };
2351
- }
2352
- /**
2353
- * Execute the tool
2354
- */
2355
- async execute(args) {
2356
- try {
2357
- const { projectPath, scaffold_feature_name, variables } = args;
2358
- if (!projectPath) throw new Error("Missing required parameter: projectPath");
2359
- if (!scaffold_feature_name) throw new Error("Missing required parameter: scaffold_feature_name");
2360
- if (!variables) throw new Error("Missing required parameter: variables");
2361
- return { content: [{
2362
- type: "text",
2363
- text: `${(await this.scaffoldingMethodsService.useScaffoldMethod({
2364
- projectPath,
2365
- scaffold_feature_name,
2366
- variables
2367
- })).message}
2368
-
2369
- IMPORTANT - Next Steps:
2370
- 1. READ the generated files to understand their structure and template placeholders
2371
- 2. IMPLEMENT the actual business logic according to the feature's purpose (replace TODOs and template variables)
2372
- 3. REGISTER the feature in the appropriate files (e.g., import and register tools in server/index.ts, export from index.ts)
2373
- 4. TEST the implementation to ensure it works correctly
2374
- 5. Only after completing the implementation should you move to other tasks
2375
-
2376
- Do not skip the implementation step - the scaffolded files contain templates that need actual code.`
2377
- }] };
2378
- } catch (error) {
2379
- return {
2380
- content: [{
2381
- type: "text",
2382
- text: `Error using scaffold method: ${error instanceof Error ? error.message : String(error)}`
2383
- }],
2384
- isError: true
2385
- };
2386
- }
2387
- }
2388
- };
2389
-
2390
- //#endregion
2391
- //#region src/tools/WriteToFileTool.ts
2392
- var WriteToFileTool = class WriteToFileTool {
2393
- static TOOL_NAME = "write-to-file";
2394
- fileSystemService;
2395
- constructor() {
2396
- this.fileSystemService = new FileSystemService();
2397
- }
2398
- /**
2399
- * Get the tool definition for MCP
2400
- */
2401
- getDefinition() {
2402
- return {
2403
- name: WriteToFileTool.TOOL_NAME,
2404
- description: `Writes content to a file, creating the file and any necessary directories if they don't exist.
2405
-
2406
- This tool will:
2407
- - Create the target file if it doesn't exist
2408
- - Create any necessary parent directories
2409
- - Write the provided content to the file
2410
- - Overwrite existing files with new content
2411
-
2412
- Parameters:
2413
- - file_path: Absolute or relative path to the target file
2414
- - content: The content to write to the file`,
2415
- inputSchema: {
2416
- type: "object",
2417
- properties: {
2418
- file_path: {
2419
- type: "string",
2420
- description: "Path to the file to write (absolute or relative to current working directory)"
2421
- },
2422
- content: {
2423
- type: "string",
2424
- description: "Content to write to the file"
2425
- }
2426
- },
2427
- required: ["file_path", "content"],
2428
- additionalProperties: false
2429
- }
2430
- };
2431
- }
2432
- /**
2433
- * Execute the tool
2434
- */
2435
- async execute(args) {
2436
- try {
2437
- const { file_path, content } = args;
2438
- if (!file_path) throw new Error("Missing required parameter: file_path");
2439
- if (content === void 0 || content === null) throw new Error("Missing required parameter: content");
2440
- const resolvedPath = node_path.default.isAbsolute(file_path) ? file_path : node_path.default.resolve(process.cwd(), file_path);
2441
- const dirPath = node_path.default.dirname(resolvedPath);
2442
- await this.fileSystemService.ensureDir(dirPath);
2443
- await this.fileSystemService.writeFile(resolvedPath, content);
2444
- return { content: [{
2445
- type: "text",
2446
- text: `Successfully wrote content to file: ${resolvedPath}`
2447
- }] };
2448
- } catch (error) {
2449
- return {
2450
- content: [{
2451
- type: "text",
2452
- text: `Error writing to file: ${error instanceof Error ? error.message : String(error)}`
2453
- }],
2454
- isError: true
2455
- };
2456
- }
2457
- }
2458
- };
2459
-
2460
- //#endregion
2461
- //#region src/server/index.ts
2462
- function createServer(options = {}) {
2463
- const { adminEnabled = false } = options;
2464
- const templatesPath = __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPathSync();
2465
- const listBoilerplatesTool = new ListBoilerplatesTool(templatesPath);
2466
- const useBoilerplateTool = new UseBoilerplateTool(templatesPath);
2467
- const listScaffoldingMethodsTool = new ListScaffoldingMethodsTool(templatesPath);
2468
- const useScaffoldMethodTool = new UseScaffoldMethodTool(templatesPath);
2469
- const writeToFileTool = new WriteToFileTool();
2470
- const generateBoilerplateTool = adminEnabled ? new GenerateBoilerplateTool(templatesPath) : null;
2471
- const generateBoilerplateFileTool = adminEnabled ? new GenerateBoilerplateFileTool(templatesPath) : null;
2472
- const generateFeatureScaffoldTool = adminEnabled ? new GenerateFeatureScaffoldTool(templatesPath) : null;
2473
- const generateBoilerplatePrompt = adminEnabled ? new GenerateBoilerplatePrompt() : null;
2474
- const generateFeatureScaffoldPrompt = adminEnabled ? new GenerateFeatureScaffoldPrompt() : null;
2475
- const scaffoldApplicationPrompt = new ScaffoldApplicationPrompt();
2476
- const scaffoldFeaturePrompt = new ScaffoldFeaturePrompt();
2477
- const server = new __modelcontextprotocol_sdk_server_index_js.Server({
2478
- name: "scaffold-mcp",
2479
- version: "0.4.0"
2480
- }, {
2481
- instructions: `Use this MCP server to create new project and adding a new feature (pages, component, services, etc...).
2482
-
2483
- ## Workflow:
2484
-
2485
- 1. **Creating New Project**: Use \`list-boilerplates\` → \`use-boilerplate\`
2486
- 2. **Adding Features**: Use \`list-scaffolding-methods\` → \`use-scaffold-method\`
2487
-
2488
- ## AI Usage Guidelines:
2489
-
2490
- - Always call \`list-boilerplates\` first when creating new projects to see available options
2491
- - Always call \`list-scaffolding-methods\` first when adding features to understand what's available
2492
- - Follow the exact variable schema provided - validation will fail if required fields are missing
2493
- - Use kebab-case for project names (e.g., "my-new-app")
2494
- - The tools automatically handle file placement, imports, and code generation
2495
- - Check the returned JSON schemas to understand required vs optional variables` + (adminEnabled ? `
2496
-
2497
- ## Admin Mode (Template Generation):
2498
-
2499
- When creating custom boilerplate templates for frameworks not yet supported:
2500
-
2501
- 1. **Create Boilerplate Configuration**: Use \`generate-boilerplate\` to add a new boilerplate entry to a template's scaffold.yaml
2502
- - Specify template name, boilerplate name, description, target folder, and variable schema
2503
- - This creates the scaffold.yaml structure following the nextjs-15 pattern
2504
- - Optional: Add detailed instruction about file purposes and design patterns
2505
-
2506
- 2. **Create Feature Configuration**: Use \`generate-feature-scaffold\` to add a new feature entry to a template's scaffold.yaml
2507
- - Specify template name, feature name, generator, description, and variable schema
2508
- - This creates the scaffold.yaml structure for feature scaffolds (pages, components, etc.)
2509
- - Optional: Add detailed instruction about file purposes and design patterns
2510
- - Optional: Specify patterns to match existing files this feature works with
2511
-
2512
- 3. **Create Template Files**: Use \`generate-boilerplate-file\` to create the actual template files
2513
- - Create files referenced in the boilerplate's or feature's includes array
2514
- - Use {{ variableName }} syntax for Liquid variable placeholders
2515
- - Can copy from existing source files or provide content directly
2516
- - Files automatically get .liquid extension
2517
-
2518
- 4. **Test the Template**: Use \`list-boilerplates\`/\`list-scaffolding-methods\` and \`use-boilerplate\`/\`use-scaffold-method\` to verify your template works
2519
-
2520
- Example workflow for boilerplate:
2521
- \`\`\`
2522
- 1. generate-boilerplate { templateName: "react-vite", boilerplateName: "scaffold-vite-app", ... }
2523
- 2. generate-boilerplate-file { templateName: "react-vite", filePath: "package.json", content: "..." }
2524
- 3. generate-boilerplate-file { templateName: "react-vite", filePath: "src/App.tsx", content: "..." }
2525
- 4. list-boilerplates (verify it appears)
2526
- 5. use-boilerplate { boilerplateName: "scaffold-vite-app", variables: {...} }
2527
- \`\`\`
2528
-
2529
- Example workflow for feature:
2530
- \`\`\`
2531
- 1. generate-feature-scaffold { templateName: "nextjs-15", featureName: "scaffold-nextjs-component", generator: "componentGenerator.ts", ... }
2532
- 2. generate-boilerplate-file { templateName: "nextjs-15", filePath: "src/components/Component.tsx", content: "..." }
2533
- 3. list-scaffolding-methods (verify it appears)
2534
- 4. use-scaffold-method { scaffoldName: "scaffold-nextjs-component", variables: {...} }
2535
- \`\`\`` : ""),
2536
- capabilities: {
2537
- tools: {},
2538
- prompts: {}
2539
- }
2540
- });
2541
- server.setRequestHandler(__modelcontextprotocol_sdk_types_js.ListToolsRequestSchema, async () => {
2542
- const tools = [
2543
- listBoilerplatesTool.getDefinition(),
2544
- useBoilerplateTool.getDefinition(),
2545
- listScaffoldingMethodsTool.getDefinition(),
2546
- useScaffoldMethodTool.getDefinition(),
2547
- writeToFileTool.getDefinition()
2548
- ];
2549
- if (adminEnabled) {
2550
- if (generateBoilerplateTool) tools.push(generateBoilerplateTool.getDefinition());
2551
- if (generateBoilerplateFileTool) tools.push(generateBoilerplateFileTool.getDefinition());
2552
- if (generateFeatureScaffoldTool) tools.push(generateFeatureScaffoldTool.getDefinition());
2553
- }
2554
- return { tools };
2555
- });
2556
- server.setRequestHandler(__modelcontextprotocol_sdk_types_js.CallToolRequestSchema, async (request) => {
2557
- const { name, arguments: args } = request.params;
2558
- if (name === ListBoilerplatesTool.TOOL_NAME) return await listBoilerplatesTool.execute(args || {});
2559
- if (name === UseBoilerplateTool.TOOL_NAME) return await useBoilerplateTool.execute(args || {});
2560
- if (name === ListScaffoldingMethodsTool.TOOL_NAME) return await listScaffoldingMethodsTool.execute(args || {});
2561
- if (name === UseScaffoldMethodTool.TOOL_NAME) return await useScaffoldMethodTool.execute(args || {});
2562
- if (name === WriteToFileTool.TOOL_NAME) return await writeToFileTool.execute(args || {});
2563
- if (name === GenerateBoilerplateTool.TOOL_NAME) {
2564
- if (!adminEnabled || !generateBoilerplateTool) throw new Error("Admin tools are not enabled. Use --admin-enable flag to enable.");
2565
- return await generateBoilerplateTool.execute(args);
2566
- }
2567
- if (name === GenerateBoilerplateFileTool.TOOL_NAME) {
2568
- if (!adminEnabled || !generateBoilerplateFileTool) throw new Error("Admin tools are not enabled. Use --admin-enable flag to enable.");
2569
- return await generateBoilerplateFileTool.execute(args);
2570
- }
2571
- if (name === GenerateFeatureScaffoldTool.TOOL_NAME) {
2572
- if (!adminEnabled || !generateFeatureScaffoldTool) throw new Error("Admin tools are not enabled. Use --admin-enable flag to enable.");
2573
- return await generateFeatureScaffoldTool.execute(args);
2574
- }
2575
- throw new Error(`Unknown tool: ${name}`);
2576
- });
2577
- server.setRequestHandler(__modelcontextprotocol_sdk_types_js.ListPromptsRequestSchema, async () => {
2578
- const prompts = [];
2579
- prompts.push(scaffoldApplicationPrompt.getDefinition());
2580
- prompts.push(scaffoldFeaturePrompt.getDefinition());
2581
- if (adminEnabled) {
2582
- if (generateBoilerplatePrompt) prompts.push(generateBoilerplatePrompt.getDefinition());
2583
- if (generateFeatureScaffoldPrompt) prompts.push(generateFeatureScaffoldPrompt.getDefinition());
2584
- }
2585
- return { prompts };
2586
- });
2587
- server.setRequestHandler(__modelcontextprotocol_sdk_types_js.GetPromptRequestSchema, async (request) => {
2588
- const { name, arguments: args } = request.params;
2589
- if (name === ScaffoldApplicationPrompt.PROMPT_NAME) return { messages: scaffoldApplicationPrompt.getMessages(args) };
2590
- if (name === ScaffoldFeaturePrompt.PROMPT_NAME) return { messages: scaffoldFeaturePrompt.getMessages(args) };
2591
- if (name === GenerateBoilerplatePrompt.PROMPT_NAME) {
2592
- if (!generateBoilerplatePrompt) throw new Error("Prompt not available");
2593
- return { messages: generateBoilerplatePrompt.getMessages(args) };
2594
- }
2595
- if (name === GenerateFeatureScaffoldPrompt.PROMPT_NAME) {
2596
- if (!generateFeatureScaffoldPrompt) throw new Error("Prompt not available");
2597
- return { messages: generateFeatureScaffoldPrompt.getMessages(args) };
2598
- }
2599
- throw new Error(`Unknown prompt: ${name}`);
2600
- });
2601
- return server;
2602
- }
2603
-
2604
- //#endregion
2605
- //#region src/transports/http.ts
2606
- /**
2607
- * HTTP session manager
2608
- */
2609
- var HttpFullSessionManager = class {
2610
- sessions = /* @__PURE__ */ new Map();
2611
- getSession(sessionId) {
2612
- return this.sessions.get(sessionId);
2613
- }
2614
- setSession(sessionId, transport, server) {
2615
- this.sessions.set(sessionId, {
2616
- transport,
2617
- server
2618
- });
2619
- }
2620
- deleteSession(sessionId) {
2621
- const session = this.sessions.get(sessionId);
2622
- if (session) session.server.close();
2623
- this.sessions.delete(sessionId);
2624
- }
2625
- hasSession(sessionId) {
2626
- return this.sessions.has(sessionId);
2627
- }
2628
- clear() {
2629
- for (const session of this.sessions.values()) session.server.close();
2630
- this.sessions.clear();
2631
- }
2632
- };
2633
- /**
2634
- * HTTP transport handler using Streamable HTTP (protocol version 2025-03-26)
2635
- * Provides stateful session management with resumability support
2636
- */
2637
- var HttpTransportHandler = class {
2638
- serverFactory;
2639
- app;
2640
- server = null;
2641
- sessionManager;
2642
- config;
2643
- constructor(serverFactory, config) {
2644
- this.serverFactory = typeof serverFactory === "function" ? serverFactory : () => serverFactory;
2645
- this.app = (0, express.default)();
2646
- this.sessionManager = new HttpFullSessionManager();
2647
- this.config = {
2648
- mode: config.mode,
2649
- port: config.port ?? 3e3,
2650
- host: config.host ?? "localhost"
2651
- };
2652
- this.setupMiddleware();
2653
- this.setupRoutes();
2654
- }
2655
- setupMiddleware() {
2656
- this.app.use(express.default.json());
2657
- }
2658
- setupRoutes() {
2659
- this.app.post("/mcp", async (req, res) => {
2660
- await this.handlePostRequest(req, res);
2661
- });
2662
- this.app.get("/mcp", async (req, res) => {
2663
- await this.handleGetRequest(req, res);
2664
- });
2665
- this.app.delete("/mcp", async (req, res) => {
2666
- await this.handleDeleteRequest(req, res);
2667
- });
2668
- this.app.get("/health", (_req, res) => {
2669
- res.json({
2670
- status: "ok",
2671
- transport: "http"
2672
- });
2673
- });
2674
- }
2675
- async handlePostRequest(req, res) {
2676
- const sessionId = req.headers["mcp-session-id"];
2677
- let transport;
2678
- if (sessionId && this.sessionManager.hasSession(sessionId)) transport = this.sessionManager.getSession(sessionId).transport;
2679
- else if (!sessionId && (0, __modelcontextprotocol_sdk_types_js.isInitializeRequest)(req.body)) {
2680
- const mcpServer = this.serverFactory();
2681
- transport = new __modelcontextprotocol_sdk_server_streamableHttp_js.StreamableHTTPServerTransport({
2682
- sessionIdGenerator: () => (0, node_crypto.randomUUID)(),
2683
- enableJsonResponse: true,
2684
- onsessioninitialized: (sessionId$1) => {
2685
- this.sessionManager.setSession(sessionId$1, transport, mcpServer);
2686
- }
2687
- });
2688
- transport.onclose = () => {
2689
- if (transport.sessionId) this.sessionManager.deleteSession(transport.sessionId);
2690
- };
2691
- await mcpServer.connect(transport);
2692
- } else {
2693
- res.status(400).json({
2694
- jsonrpc: "2.0",
2695
- error: {
2696
- code: -32e3,
2697
- message: "Bad Request: No valid session ID provided"
2698
- },
2699
- id: null
2700
- });
2701
- return;
2702
- }
2703
- await transport.handleRequest(req, res, req.body);
2704
- }
2705
- async handleGetRequest(req, res) {
2706
- const sessionId = req.headers["mcp-session-id"];
2707
- if (!sessionId || !this.sessionManager.hasSession(sessionId)) {
2708
- res.status(400).send("Invalid or missing session ID");
2709
- return;
2710
- }
2711
- await this.sessionManager.getSession(sessionId).transport.handleRequest(req, res);
2712
- }
2713
- async handleDeleteRequest(req, res) {
2714
- const sessionId = req.headers["mcp-session-id"];
2715
- if (!sessionId || !this.sessionManager.hasSession(sessionId)) {
2716
- res.status(400).send("Invalid or missing session ID");
2717
- return;
2718
- }
2719
- await this.sessionManager.getSession(sessionId).transport.handleRequest(req, res);
2720
- this.sessionManager.deleteSession(sessionId);
2721
- }
2722
- async start() {
2723
- return new Promise((resolve, reject) => {
2724
- try {
2725
- this.server = this.app.listen(this.config.port, this.config.host, () => {
2726
- console.error(`Scaffolding MCP server started on http://${this.config.host}:${this.config.port}/mcp`);
2727
- console.error(`Health check: http://${this.config.host}:${this.config.port}/health`);
2728
- resolve();
2729
- });
2730
- this.server.on("error", (error) => {
2731
- reject(error);
2732
- });
2733
- } catch (error) {
2734
- reject(error);
2735
- }
2736
- });
2737
- }
2738
- async stop() {
2739
- return new Promise((resolve, reject) => {
2740
- if (this.server) {
2741
- this.sessionManager.clear();
2742
- this.server.close((err) => {
2743
- if (err) reject(err);
2744
- else {
2745
- this.server = null;
2746
- resolve();
2747
- }
2748
- });
2749
- } else resolve();
2750
- });
2751
- }
2752
- getPort() {
2753
- return this.config.port;
2754
- }
2755
- getHost() {
2756
- return this.config.host;
2757
- }
2758
- };
2759
-
2760
- //#endregion
2761
- //#region src/transports/sse.ts
2762
- /**
2763
- * Session manager for SSE transports
2764
- */
2765
- var SseSessionManager = class {
2766
- sessions = /* @__PURE__ */ new Map();
2767
- getSession(sessionId) {
2768
- return this.sessions.get(sessionId)?.transport;
2769
- }
2770
- setSession(sessionId, transport, server) {
2771
- this.sessions.set(sessionId, {
2772
- transport,
2773
- server
2774
- });
2775
- }
2776
- deleteSession(sessionId) {
2777
- const session = this.sessions.get(sessionId);
2778
- if (session) session.server.close();
2779
- this.sessions.delete(sessionId);
2780
- }
2781
- hasSession(sessionId) {
2782
- return this.sessions.has(sessionId);
2783
- }
2784
- clear() {
2785
- for (const session of this.sessions.values()) session.server.close();
2786
- this.sessions.clear();
2787
- }
2788
- };
2789
- /**
2790
- * SSE (Server-Sent Events) transport handler
2791
- * Legacy transport for backwards compatibility (protocol version 2024-11-05)
2792
- * Uses separate endpoints: /sse for SSE stream (GET) and /messages for client messages (POST)
2793
- */
2794
- var SseTransportHandler = class {
2795
- serverFactory;
2796
- app;
2797
- server = null;
2798
- sessionManager;
2799
- config;
2800
- constructor(serverFactory, config) {
2801
- this.serverFactory = typeof serverFactory === "function" ? serverFactory : () => serverFactory;
2802
- this.app = (0, express.default)();
2803
- this.sessionManager = new SseSessionManager();
2804
- this.config = {
2805
- mode: config.mode,
2806
- port: config.port ?? 3e3,
2807
- host: config.host ?? "localhost"
2808
- };
2809
- this.setupMiddleware();
2810
- this.setupRoutes();
2811
- }
2812
- setupMiddleware() {
2813
- this.app.use(express.default.json());
2814
- }
2815
- setupRoutes() {
2816
- this.app.get("/sse", async (req, res) => {
2817
- await this.handleSseConnection(req, res);
2818
- });
2819
- this.app.post("/messages", async (req, res) => {
2820
- await this.handlePostMessage(req, res);
2821
- });
2822
- this.app.get("/health", (_req, res) => {
2823
- res.json({
2824
- status: "ok",
2825
- transport: "sse"
2826
- });
2827
- });
2828
- }
2829
- async handleSseConnection(_req, res) {
2830
- try {
2831
- const mcpServer = this.serverFactory();
2832
- const transport = new __modelcontextprotocol_sdk_server_sse_js.SSEServerTransport("/messages", res);
2833
- this.sessionManager.setSession(transport.sessionId, transport, mcpServer);
2834
- res.on("close", () => {
2835
- this.sessionManager.deleteSession(transport.sessionId);
2836
- });
2837
- await mcpServer.connect(transport);
2838
- console.error(`SSE session established: ${transport.sessionId}`);
2839
- } catch (error) {
2840
- console.error("Error handling SSE connection:", error);
2841
- if (!res.headersSent) res.status(500).send("Internal Server Error");
2842
- }
2843
- }
2844
- async handlePostMessage(req, res) {
2845
- const sessionId = req.query.sessionId;
2846
- if (!sessionId) {
2847
- res.status(400).send("Missing sessionId query parameter");
2848
- return;
2849
- }
2850
- const transport = this.sessionManager.getSession(sessionId);
2851
- if (!transport) {
2852
- res.status(404).send("No transport found for sessionId");
2853
- return;
2854
- }
2855
- try {
2856
- await transport.handlePostMessage(req, res, req.body);
2857
- } catch (error) {
2858
- console.error("Error handling post message:", error);
2859
- if (!res.headersSent) res.status(500).send("Internal Server Error");
2860
- }
2861
- }
2862
- async start() {
2863
- return new Promise((resolve, reject) => {
2864
- try {
2865
- this.server = this.app.listen(this.config.port, this.config.host, () => {
2866
- console.error(`Scaffolding MCP server started with SSE transport on http://${this.config.host}:${this.config.port}`);
2867
- console.error(`SSE endpoint: http://${this.config.host}:${this.config.port}/sse`);
2868
- console.error(`Messages endpoint: http://${this.config.host}:${this.config.port}/messages`);
2869
- console.error(`Health check: http://${this.config.host}:${this.config.port}/health`);
2870
- resolve();
2871
- });
2872
- this.server.on("error", (error) => {
2873
- reject(error);
2874
- });
2875
- } catch (error) {
2876
- reject(error);
2877
- }
2878
- });
2879
- }
2880
- async stop() {
2881
- return new Promise((resolve, reject) => {
2882
- if (this.server) {
2883
- this.sessionManager.clear();
2884
- this.server.close((err) => {
2885
- if (err) reject(err);
2886
- else {
2887
- this.server = null;
2888
- resolve();
2889
- }
2890
- });
2891
- } else resolve();
2892
- });
2893
- }
2894
- getPort() {
2895
- return this.config.port;
2896
- }
2897
- getHost() {
2898
- return this.config.host;
2899
- }
2900
- };
2901
-
2902
- //#endregion
2903
- //#region src/transports/stdio.ts
2904
- /**
2905
- * Stdio transport handler for MCP server
2906
- * Used for command-line and direct integrations
2907
- */
2908
- var StdioTransportHandler = class {
2909
- server;
2910
- transport = null;
2911
- constructor(server) {
2912
- this.server = server;
2913
- }
2914
- async start() {
2915
- this.transport = new __modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
2916
- await this.server.connect(this.transport);
2917
- console.error("Scaffolding MCP server started on stdio");
2918
- }
2919
- async stop() {
2920
- if (this.transport) {
2921
- await this.transport.close();
2922
- this.transport = null;
2923
- }
2924
- }
2925
- };
2926
-
2927
- //#endregion
2928
- //#region src/transports/types.ts
2929
- /**
2930
- * Transport mode types
2931
- */
2932
- let TransportMode = /* @__PURE__ */ function(TransportMode$1) {
2933
- TransportMode$1["STDIO"] = "stdio";
2934
- TransportMode$1["HTTP"] = "http";
2935
- TransportMode$1["SSE"] = "sse";
2936
- TransportMode$1["CLI"] = "cli";
2937
- return TransportMode$1;
2938
- }({});
2939
-
2940
- //#endregion
2941
- //#region src/cli/mcp-serve.ts
2942
- /**
2943
- * Start MCP server with given transport handler
2944
- */
2945
- async function startServer(handler) {
2946
- await handler.start();
2947
- const shutdown = async (signal) => {
2948
- console.error(`\nReceived ${signal}, shutting down gracefully...`);
2949
- try {
2950
- await handler.stop();
2951
- process.exit(0);
2952
- } catch (error) {
2953
- console.error("Error during shutdown:", error);
2954
- process.exit(1);
2955
- }
2956
- };
2957
- process.on("SIGINT", () => shutdown("SIGINT"));
2958
- process.on("SIGTERM", () => shutdown("SIGTERM"));
2959
- }
2960
- /**
2961
- * MCP Serve command
2962
- */
2963
- const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio, http, or sse", "stdio").option("-p, --port <port>", "Port to listen on (http/sse only)", (val) => parseInt(val, 10), 3e3).option("--host <host>", "Host to bind to (http/sse only)", "localhost").option("--admin-enable", "Enable admin tools (generate-boilerplate)", false).action(async (options) => {
2964
- try {
2965
- const transportType = options.type.toLowerCase();
2966
- const serverOptions = { adminEnabled: options.adminEnable };
2967
- if (transportType === "stdio") await startServer(new StdioTransportHandler(createServer(serverOptions)));
2968
- else if (transportType === "http") await startServer(new HttpTransportHandler(() => createServer(serverOptions), {
2969
- mode: TransportMode.HTTP,
2970
- port: options.port || Number(process.env.MCP_PORT) || 3e3,
2971
- host: options.host || process.env.MCP_HOST || "localhost"
2972
- }));
2973
- else if (transportType === "sse") await startServer(new SseTransportHandler(() => createServer(serverOptions), {
2974
- mode: TransportMode.SSE,
2975
- port: options.port || Number(process.env.MCP_PORT) || 3e3,
2976
- host: options.host || process.env.MCP_HOST || "localhost"
2977
- }));
2978
- else {
2979
- console.error(`Unknown transport type: ${transportType}. Use: stdio, http, or sse`);
2980
- process.exit(1);
2981
- }
2982
- } catch (error) {
2983
- console.error("Failed to start MCP server:", error);
2984
- process.exit(1);
2985
- }
2986
- });
2987
-
2988
- //#endregion
2989
- //#region src/cli/scaffold.ts
2990
- /**
2991
- * Scaffold CLI command
2992
- */
2993
- const scaffoldCommand = new commander.Command("scaffold").description("Add features to existing projects");
2994
- scaffoldCommand.command("list <projectPath>").description("List available scaffolding methods for a project").action(async (projectPath) => {
2995
- try {
2996
- const absolutePath = node_path.default.resolve(projectPath);
2997
- if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(absolutePath)) {
2998
- __agiflowai_aicode_utils.messages.error(`No project configuration found in ${absolutePath}`);
2999
- __agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root");
3000
- process.exit(1);
3001
- }
3002
- const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
3003
- const methods = (await new ScaffoldingMethodsService(new FileSystemService(), templatesDir).listScaffoldingMethods(absolutePath)).methods;
3004
- if (methods.length === 0) {
3005
- __agiflowai_aicode_utils.messages.warning("No scaffolding methods available for this project.");
3006
- return;
3007
- }
3008
- __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.wrench} Available Scaffolding Methods for ${projectPath}:\n`);
3009
- for (const method of methods) {
3010
- __agiflowai_aicode_utils.print.highlight(` ${method.name}`);
3011
- __agiflowai_aicode_utils.print.debug(` ${method.instruction || method.description || "No description available"}`);
3012
- if (method.variables_schema.required && method.variables_schema.required.length > 0) __agiflowai_aicode_utils.print.debug(` Required: ${method.variables_schema.required.join(", ")}`);
3013
- __agiflowai_aicode_utils.print.newline();
3014
- }
3015
- } catch (error) {
3016
- __agiflowai_aicode_utils.messages.error("Error listing scaffolding methods:", error);
3017
- process.exit(1);
3018
- }
3019
- });
3020
- 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) => {
3021
- try {
3022
- const projectPath = node_path.default.resolve(options.project);
3023
- if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
3024
- __agiflowai_aicode_utils.messages.error(`No project configuration found in ${projectPath}`);
3025
- __agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root");
3026
- process.exit(1);
3027
- }
3028
- let variables = {};
3029
- if (options.vars) try {
3030
- variables = JSON.parse(options.vars);
3031
- } catch (error) {
3032
- __agiflowai_aicode_utils.messages.error("Error parsing variables JSON:", error);
3033
- __agiflowai_aicode_utils.messages.hint("Example: --vars '{\"componentName\": \"UserProfile\", \"description\": \"User profile component\"}'");
3034
- process.exit(1);
3035
- }
3036
- const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
3037
- const scaffoldingMethodsService = new ScaffoldingMethodsService(new FileSystemService(), templatesDir);
3038
- const methods = (await scaffoldingMethodsService.listScaffoldingMethods(projectPath)).methods;
3039
- const method = methods.find((m) => m.name === featureName);
3040
- if (!method) {
3041
- __agiflowai_aicode_utils.messages.error(`Scaffold method '${featureName}' not found.`);
3042
- __agiflowai_aicode_utils.print.warning(`Available methods: ${methods.map((m) => m.name).join(", ")}`);
3043
- __agiflowai_aicode_utils.print.debug(`Run 'scaffold-mcp scaffold list ${options.project}' to see all available methods`);
3044
- process.exit(1);
3045
- }
3046
- const required = typeof method.variables_schema === "object" && method.variables_schema !== null && "required" in method.variables_schema ? method.variables_schema.required : [];
3047
- const missing = required.filter((key) => !variables[key]);
3048
- if (missing.length > 0) {
3049
- __agiflowai_aicode_utils.messages.error(`❌ Missing required variables: ${missing.join(", ")}`);
3050
- __agiflowai_aicode_utils.messages.hint(`💡 Use --vars with a JSON object containing: ${missing.join(", ")}`);
3051
- const exampleVars = {};
3052
- for (const key of required) if (key.includes("Name")) exampleVars[key] = "MyFeature";
3053
- else if (key === "description") exampleVars[key] = "Feature description";
3054
- else exampleVars[key] = `<${key}>`;
3055
- __agiflowai_aicode_utils.print.debug(`Example: scaffold-mcp scaffold add ${featureName} --project ${options.project} --vars '${JSON.stringify(exampleVars)}'`);
3056
- process.exit(1);
3057
- }
3058
- if (options.verbose) {
3059
- __agiflowai_aicode_utils.print.info(`🔧 Feature: ${featureName}`);
3060
- __agiflowai_aicode_utils.print.info(`📊 Variables: ${JSON.stringify(variables, null, 2)}`);
3061
- __agiflowai_aicode_utils.print.info(`📁 Project Path: ${projectPath}`);
3062
- }
3063
- __agiflowai_aicode_utils.print.info(`🚀 Adding '${featureName}' to project...`);
3064
- const result = await scaffoldingMethodsService.useScaffoldMethod({
3065
- projectPath,
3066
- scaffold_feature_name: featureName,
3067
- variables
3068
- });
3069
- if (result.success) {
3070
- __agiflowai_aicode_utils.messages.success("✅ Feature added successfully!");
3071
- console.log(result.message);
3072
- if (result.createdFiles && result.createdFiles.length > 0) {
3073
- __agiflowai_aicode_utils.print.header("\n📁 Created files:");
3074
- result.createdFiles.forEach((file) => __agiflowai_aicode_utils.print.debug(` - ${file}`));
3075
- }
3076
- if (result.warnings && result.warnings.length > 0) {
3077
- __agiflowai_aicode_utils.messages.warning("\n⚠️ Warnings:");
3078
- result.warnings.forEach((warning) => __agiflowai_aicode_utils.print.debug(` - ${warning}`));
3079
- }
3080
- __agiflowai_aicode_utils.print.header("\n📋 Next steps:");
3081
- __agiflowai_aicode_utils.print.debug(" - Review the generated files");
3082
- __agiflowai_aicode_utils.print.debug(" - Update imports if necessary");
3083
- __agiflowai_aicode_utils.print.debug(" - Run tests to ensure everything works");
3084
- } else {
3085
- __agiflowai_aicode_utils.messages.error(`❌ Failed to add feature: ${result.message}`);
3086
- process.exit(1);
3087
- }
3088
- } catch (error) {
3089
- __agiflowai_aicode_utils.messages.error(`❌ Error adding feature: ${error.message}`);
3090
- if (options.verbose) console.error("Stack trace:", error.stack);
3091
- process.exit(1);
3092
- }
3093
- });
3094
- scaffoldCommand.command("info <featureName>").description("Show detailed information about a scaffold method").option("-p, --project <path>", "Project path", process.cwd()).action(async (featureName, options) => {
3095
- try {
3096
- const projectPath = node_path.default.resolve(options.project);
3097
- if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
3098
- __agiflowai_aicode_utils.messages.error(`No project configuration found in ${projectPath}`);
3099
- __agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root");
3100
- process.exit(1);
3101
- }
3102
- const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
3103
- const method = (await new ScaffoldingMethodsService(new FileSystemService(), templatesDir).listScaffoldingMethods(projectPath)).methods.find((m) => m.name === featureName);
3104
- if (!method) {
3105
- __agiflowai_aicode_utils.messages.error(`❌ Scaffold method '${featureName}' not found.`);
3106
- process.exit(1);
3107
- }
3108
- __agiflowai_aicode_utils.print.header(`\n🔧 Scaffold Method: ${method.name}\n`);
3109
- __agiflowai_aicode_utils.print.debug(`Description: ${method.description}`);
3110
- __agiflowai_aicode_utils.print.header("\n📝 Variables Schema:");
3111
- console.log(JSON.stringify(method.variables_schema, null, 2));
3112
- const includes = "includes" in method ? method.includes : [];
3113
- if (includes && includes.length > 0) {
3114
- __agiflowai_aicode_utils.print.header("\n📁 Files to be created:");
3115
- includes.forEach((include) => {
3116
- const parts = include.split(">>");
3117
- if (parts.length === 2) __agiflowai_aicode_utils.print.debug(` - ${parts[1].trim()}`);
3118
- else __agiflowai_aicode_utils.print.debug(` - ${include}`);
3119
- });
3120
- }
3121
- } catch (error) {
3122
- __agiflowai_aicode_utils.messages.error(`❌ Error getting scaffold info: ${error.message}`);
3123
- process.exit(1);
3124
- }
3125
- });
3126
-
3127
- //#endregion
3128
- //#region src/index.ts
3129
- /**
3130
- * Main entry point
3131
- */
3132
- async function main() {
3133
- const program = new commander.Command();
3134
- program.name("scaffold-mcp").description("MCP server for scaffolding applications with boilerplate templates").version("0.4.0");
3135
- program.addCommand(mcpServeCommand);
3136
- program.addCommand(boilerplateCommand);
3137
- program.addCommand(scaffoldCommand);
3138
- program.addCommand(initCommand);
3139
- program.addCommand(addCommand);
3140
- await program.parseAsync(process.argv);
3141
- }
3142
- main();
3143
-
3144
- //#endregion
1
+ const require_stdio = require('./stdio-Cz5aRdvr.cjs');
2
+ const require_ScaffoldConfigLoader = require('./ScaffoldConfigLoader-BrmvENTo.cjs');
3
+ const require_ScaffoldService = require('./ScaffoldService-B-L4gwHt.cjs');
4
+ const require_TemplateService = require('./TemplateService-DRubcvS9.cjs');
5
+ const require_VariableReplacementService = require('./VariableReplacementService-BL84vnKk.cjs');
6
+
7
+ exports.BoilerplateGeneratorService = require_stdio.BoilerplateGeneratorService;
8
+ exports.BoilerplateService = require_stdio.BoilerplateService;
9
+ exports.FileSystemService = require_stdio.FileSystemService;
10
+ exports.GenerateBoilerplateFileTool = require_stdio.GenerateBoilerplateFileTool;
11
+ exports.GenerateBoilerplateTool = require_stdio.GenerateBoilerplateTool;
12
+ exports.GenerateFeatureScaffoldTool = require_stdio.GenerateFeatureScaffoldTool;
13
+ exports.HttpTransportHandler = require_stdio.HttpTransportHandler;
14
+ exports.ListBoilerplatesTool = require_stdio.ListBoilerplatesTool;
15
+ exports.ListScaffoldingMethodsTool = require_stdio.ListScaffoldingMethodsTool;
16
+ exports.ScaffoldConfigLoader = require_ScaffoldConfigLoader.ScaffoldConfigLoader;
17
+ exports.ScaffoldGeneratorService = require_stdio.ScaffoldGeneratorService;
18
+ exports.ScaffoldProcessingService = require_ScaffoldService.ScaffoldProcessingService;
19
+ exports.ScaffoldService = require_ScaffoldService.ScaffoldService;
20
+ exports.ScaffoldingMethodsService = require_stdio.ScaffoldingMethodsService;
21
+ exports.SseTransportHandler = require_stdio.SseTransportHandler;
22
+ exports.StdioTransportHandler = require_stdio.StdioTransportHandler;
23
+ exports.TemplateService = require_TemplateService.TemplateService;
24
+ exports.UseBoilerplateTool = require_stdio.UseBoilerplateTool;
25
+ exports.UseScaffoldMethodTool = require_stdio.UseScaffoldMethodTool;
26
+ exports.VariableReplacementService = require_VariableReplacementService.VariableReplacementService;
27
+ exports.WriteToFileTool = require_stdio.WriteToFileTool;
28
+ exports.cloneRepository = require_stdio.cloneRepository;
29
+ exports.cloneSubdirectory = require_stdio.cloneSubdirectory;
30
+ exports.fetchGitHubDirectoryContents = require_stdio.fetchGitHubDirectoryContents;
31
+ exports.findWorkspaceRoot = require_stdio.findWorkspaceRoot;
32
+ exports.parseGitHubUrl = require_stdio.parseGitHubUrl;