@agiflowai/scaffold-mcp 0.6.0 → 1.0.1

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-B3En_m4t.cjs +3 -0
  6. package/dist/{ScaffoldService-BgFWAOLQ.cjs → ScaffoldService-BwDmXt83.cjs} +17 -8
  7. package/dist/ScaffoldService-CJ3vNmAj.js +3 -0
  8. package/dist/ScaffoldService-DB7-Cyod.js +293 -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-BAwTGv_R.js +3 -0
  13. package/dist/{VariableReplacementService-YUpL5nAC.cjs → VariableReplacementService-CroHkMha.cjs} +1 -1
  14. package/dist/{VariableReplacementService-ClshNY_C.cjs → VariableReplacementService-D0QnWKUW.cjs} +2 -2
  15. package/dist/VariableReplacementService-DRxd9ILB.js +66 -0
  16. package/dist/cli.cjs +779 -0
  17. package/dist/cli.d.cts +1 -0
  18. package/dist/cli.d.ts +1 -0
  19. package/dist/cli.js +774 -0
  20. package/dist/index.cjs +38 -3208
  21. package/dist/index.d.cts +814 -0
  22. package/dist/index.d.ts +815 -0
  23. package/dist/index.js +137 -0
  24. package/dist/stdio-Bxn4A1IU.js +2073 -0
  25. package/dist/stdio-TGsG8akc.cjs +2178 -0
  26. package/package.json +19 -5
  27. package/dist/ScaffoldService-BvD9WvRi.cjs +0 -3
  28. package/dist/TemplateService-B5EZjPB0.cjs +0 -3
  29. /package/dist/{ScaffoldConfigLoader-1Pcv9cxm.cjs → ScaffoldConfigLoader-BrmvENTo.cjs} +0 -0
  30. /package/dist/{TemplateService-_KpkoLfZ.cjs → TemplateService-DRubcvS9.cjs} +0 -0
package/dist/cli.cjs ADDED
@@ -0,0 +1,779 @@
1
+ #!/usr/bin/env node
2
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
3
+ const require_stdio = require('./stdio-TGsG8akc.cjs');
4
+ require('./ScaffoldConfigLoader-BrmvENTo.cjs');
5
+ require('./ScaffoldService-BwDmXt83.cjs');
6
+ const require_TemplateService = require('./TemplateService-DRubcvS9.cjs');
7
+ require('./VariableReplacementService-D0QnWKUW.cjs');
8
+ let commander = require("commander");
9
+ commander = require_chunk.__toESM(commander);
10
+ let __agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
11
+ __agiflowai_aicode_utils = require_chunk.__toESM(__agiflowai_aicode_utils);
12
+ let node_path = require("node:path");
13
+ node_path = require_chunk.__toESM(node_path);
14
+ let __modelcontextprotocol_sdk_server_index_js = require("@modelcontextprotocol/sdk/server/index.js");
15
+ __modelcontextprotocol_sdk_server_index_js = require_chunk.__toESM(__modelcontextprotocol_sdk_server_index_js);
16
+ let __modelcontextprotocol_sdk_types_js = require("@modelcontextprotocol/sdk/types.js");
17
+ __modelcontextprotocol_sdk_types_js = require_chunk.__toESM(__modelcontextprotocol_sdk_types_js);
18
+
19
+ //#region package.json
20
+ var name = "@agiflowai/scaffold-mcp";
21
+ var description = "MCP server for scaffolding applications with boilerplate templates";
22
+ var version = "1.0.0";
23
+ var license = "AGPL-3.0";
24
+ var author = "AgiflowIO";
25
+ var repository = {
26
+ "type": "git",
27
+ "url": "https://github.com/AgiFlow/aicode-toolkit.git",
28
+ "directory": "packages/scaffold-mcp"
29
+ };
30
+ var homepage = "https://github.com/AgiFlow/aicode-toolkit#readme";
31
+ var bugs = { "url": "https://github.com/AgiFlow/aicode-toolkit/issues" };
32
+ var keywords = [
33
+ "mcp",
34
+ "model-context-protocol",
35
+ "scaffold",
36
+ "boilerplate",
37
+ "template",
38
+ "code-generation",
39
+ "nextjs",
40
+ "react",
41
+ "vite"
42
+ ];
43
+ var bin = { "scaffold-mcp": "./dist/cli.cjs" };
44
+ var main$1 = "./dist/index.cjs";
45
+ var types = "./dist/index.d.cts";
46
+ var module$1 = "./dist/index.js";
47
+ var files = ["dist", "README.md"];
48
+ var scripts = {
49
+ "dev": "node --loader ts-node/esm src/cli.ts",
50
+ "build": "tsdown",
51
+ "test": "vitest --run",
52
+ "typecheck": "tsc --noEmit"
53
+ };
54
+ var dependencies = {
55
+ "@agiflowai/aicode-utils": "workspace:*",
56
+ "@composio/json-schema-to-zod": "0.1.15",
57
+ "@inquirer/prompts": "^7.8.6",
58
+ "@modelcontextprotocol/sdk": "1.19.1",
59
+ "chalk": "5.6.2",
60
+ "commander": "14.0.1",
61
+ "execa": "^9.5.2",
62
+ "express": "^4.21.2",
63
+ "fs-extra": "11.3.2",
64
+ "js-yaml": "4.1.0",
65
+ "liquidjs": "10.21.1",
66
+ "pino": "^10.0.0",
67
+ "pino-pretty": "^13.1.1",
68
+ "zod": "3.25.76"
69
+ };
70
+ var devDependencies = {
71
+ "@types/express": "^5.0.0",
72
+ "@types/fs-extra": "^11.0.4",
73
+ "@types/js-yaml": "^4.0.9",
74
+ "@types/node": "^22.0.0",
75
+ "tsdown": "^0.15.6",
76
+ "typescript": "5.9.3",
77
+ "unplugin-raw": "^0.6.3"
78
+ };
79
+ var publishConfig = { "access": "public" };
80
+ var type = "module";
81
+ var exports$1 = {
82
+ ".": {
83
+ "import": "./dist/index.js",
84
+ "require": "./dist/index.cjs"
85
+ },
86
+ "./cli": {
87
+ "import": "./dist/cli.js",
88
+ "require": "./dist/cli.cjs"
89
+ },
90
+ "./package.json": "./package.json"
91
+ };
92
+ var package_default = {
93
+ name,
94
+ description,
95
+ version,
96
+ license,
97
+ author,
98
+ repository,
99
+ homepage,
100
+ bugs,
101
+ keywords,
102
+ bin,
103
+ main: main$1,
104
+ types,
105
+ module: module$1,
106
+ files,
107
+ scripts,
108
+ dependencies,
109
+ devDependencies,
110
+ publishConfig,
111
+ type,
112
+ exports: exports$1
113
+ };
114
+
115
+ //#endregion
116
+ //#region src/commands/boilerplate.ts
117
+ /**
118
+ * Boilerplate CLI command
119
+ */
120
+ const boilerplateCommand = new commander.Command("boilerplate").description("Manage boilerplate templates");
121
+ boilerplateCommand.command("list").description("List all available boilerplate templates").action(async () => {
122
+ try {
123
+ const { boilerplates } = await new require_stdio.BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath()).listBoilerplates();
124
+ if (boilerplates.length === 0) {
125
+ __agiflowai_aicode_utils.messages.warning("No boilerplate templates found.");
126
+ return;
127
+ }
128
+ __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.package} Available Boilerplate Templates:\n`);
129
+ for (const bp of boilerplates) {
130
+ __agiflowai_aicode_utils.print.highlight(` ${bp.name}`);
131
+ __agiflowai_aicode_utils.print.debug(` ${bp.description}`);
132
+ __agiflowai_aicode_utils.print.debug(` Target: ${bp.target_folder}`);
133
+ const required = typeof bp.variables_schema === "object" && bp.variables_schema !== null && "required" in bp.variables_schema ? bp.variables_schema.required : [];
134
+ if (required && required.length > 0) __agiflowai_aicode_utils.print.debug(` Required: ${required.join(", ")}`);
135
+ __agiflowai_aicode_utils.print.newline();
136
+ }
137
+ } catch (error) {
138
+ __agiflowai_aicode_utils.messages.error("Error listing boilerplates:", error);
139
+ process.exit(1);
140
+ }
141
+ });
142
+ 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) => {
143
+ try {
144
+ const boilerplateService = new require_stdio.BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath());
145
+ let variables = {};
146
+ if (options.vars) try {
147
+ variables = JSON.parse(options.vars);
148
+ } catch (error) {
149
+ __agiflowai_aicode_utils.messages.error("Error parsing variables JSON:", error);
150
+ __agiflowai_aicode_utils.messages.hint("Example: --vars '{\"appName\": \"my-app\", \"description\": \"My application\"}'");
151
+ process.exit(1);
152
+ }
153
+ const boilerplate = await boilerplateService.getBoilerplate(boilerplateName);
154
+ if (!boilerplate) {
155
+ const { boilerplates } = await boilerplateService.listBoilerplates();
156
+ __agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
157
+ __agiflowai_aicode_utils.print.warning(`Available boilerplates: ${boilerplates.map((b) => b.name).join(", ")}`);
158
+ process.exit(1);
159
+ }
160
+ const required = typeof boilerplate.variables_schema === "object" && boilerplate.variables_schema !== null && "required" in boilerplate.variables_schema ? boilerplate.variables_schema.required : [];
161
+ const missing = required.filter((key) => !variables[key]);
162
+ if (missing.length > 0) {
163
+ __agiflowai_aicode_utils.messages.error(`Missing required variables: ${missing.join(", ")}`);
164
+ __agiflowai_aicode_utils.messages.hint(`Use --vars with a JSON object containing: ${missing.join(", ")}`);
165
+ const exampleVars = {};
166
+ for (const key of required) if (key === "appName" || key === "packageName") exampleVars[key] = "my-app";
167
+ else if (key === "description") exampleVars[key] = "My application description";
168
+ else exampleVars[key] = `<${key}>`;
169
+ __agiflowai_aicode_utils.print.debug(`Example: scaffold-mcp boilerplate create ${boilerplateName} --vars '${JSON.stringify(exampleVars)}'`);
170
+ process.exit(1);
171
+ }
172
+ if (options.verbose) {
173
+ __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.wrench} Boilerplate: ${boilerplateName}`);
174
+ __agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.chart} Variables: ${JSON.stringify(variables, null, 2)}`);
175
+ }
176
+ __agiflowai_aicode_utils.messages.loading(`Creating project from boilerplate '${boilerplateName}'...`);
177
+ const result = await boilerplateService.useBoilerplate({
178
+ boilerplateName,
179
+ variables,
180
+ monolith: options.monolith,
181
+ targetFolderOverride: options.targetFolder
182
+ });
183
+ if (result.success) {
184
+ __agiflowai_aicode_utils.messages.success("Project created successfully!");
185
+ __agiflowai_aicode_utils.print.info(result.message);
186
+ if (result.createdFiles && result.createdFiles.length > 0) __agiflowai_aicode_utils.sections.createdFiles(result.createdFiles);
187
+ const projectName = variables.appName || variables.packageName;
188
+ if (projectName) {
189
+ const targetFolder = options.targetFolder || (options.monolith ? "." : boilerplate.target_folder);
190
+ const projectPath = options.monolith ? "." : `${targetFolder}/${projectName}`;
191
+ const steps = projectPath === "." ? ["pnpm install", "pnpm dev"] : [
192
+ `cd ${projectPath}`,
193
+ "pnpm install",
194
+ "pnpm dev"
195
+ ];
196
+ __agiflowai_aicode_utils.sections.nextSteps(steps);
197
+ }
198
+ } else {
199
+ __agiflowai_aicode_utils.messages.error(`Failed to create project: ${result.message}`);
200
+ process.exit(1);
201
+ }
202
+ } catch (error) {
203
+ __agiflowai_aicode_utils.messages.error("Error creating project:", error);
204
+ if (options.verbose) console.error("Stack trace:", error.stack);
205
+ process.exit(1);
206
+ }
207
+ });
208
+ boilerplateCommand.command("info <boilerplateName>").description("Show detailed information about a boilerplate template").action(async (boilerplateName) => {
209
+ try {
210
+ const bp = await new require_stdio.BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath()).getBoilerplate(boilerplateName);
211
+ if (!bp) {
212
+ __agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
213
+ process.exit(1);
214
+ }
215
+ __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.package} Boilerplate: ${bp.name}\n`);
216
+ __agiflowai_aicode_utils.print.debug(`Description: ${bp.description}`);
217
+ __agiflowai_aicode_utils.print.debug(`Template Path: ${bp.template_path}`);
218
+ __agiflowai_aicode_utils.print.debug(`Target Folder: ${bp.target_folder}`);
219
+ __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.config} Variables Schema:`);
220
+ console.log(JSON.stringify(bp.variables_schema, null, 2));
221
+ if (bp.includes && bp.includes.length > 0) __agiflowai_aicode_utils.sections.list(`${__agiflowai_aicode_utils.icons.folder} Included Files:`, bp.includes);
222
+ } catch (error) {
223
+ __agiflowai_aicode_utils.messages.error("Error getting boilerplate info:", error);
224
+ process.exit(1);
225
+ }
226
+ });
227
+
228
+ //#endregion
229
+ //#region src/instructions/server.md?raw
230
+ var server_default = "Use this MCP server to {% if isMonolith %}create your monolith project and add features (pages, components, services, etc.){% else %}create new projects and add features (pages, components, services, etc.){% endif %}.\n\n## Workflow:\n{% if not isMonolith %}\n1. **Creating New Project**: Use `list-boilerplates` → `use-boilerplate`\n2. **Adding Features**: Use `list-scaffolding-methods` → `use-scaffold-method`\n{% else %}\n1. **Creating Project**: Use `use-boilerplate` (boilerplateName auto-detected from toolkit.yaml)\n2. **Adding Features**: Use `list-scaffolding-methods` → `use-scaffold-method`\n{% endif %}\n\n## AI Usage Guidelines:\n{% if not isMonolith %}\n- Always call `list-boilerplates` first when creating new projects to see available options\n{% endif %}\n- Always call `list-scaffolding-methods` first when adding features to understand what's available\n- Follow the exact variable schema provided - validation will fail if required fields are missing\n{% if not isMonolith %}\n- Use kebab-case for project names (e.g., \"my-new-app\")\n{% else %}\n- In monolith mode, parameters like `boilerplateName` and `templateName` are auto-detected from toolkit.yaml\n- You only need to provide `variables` when calling `use-boilerplate` or `use-scaffold-method`\n{% endif %}\n- The tools automatically handle file placement, imports, and code generation\n- Check the returned JSON schemas to understand required vs optional variables\n{% if adminEnabled %}\n\n## Admin Mode (Template Generation):\n\nWhen creating custom boilerplate templates for frameworks not yet supported:\n\n1. **Create Boilerplate Configuration**: Use `generate-boilerplate` to add a new boilerplate entry to a template's scaffold.yaml\n - Specify template name, boilerplate name, description, target folder, and variable schema\n - This creates the scaffold.yaml structure following the nextjs-15 pattern\n - Optional: Add detailed instruction about file purposes and design patterns\n\n2. **Create Feature Configuration**: Use `generate-feature-scaffold` to add a new feature entry to a template's scaffold.yaml\n - Specify template name, feature name, generator, description, and variable schema\n - This creates the scaffold.yaml structure for feature scaffolds (pages, components, etc.)\n - Optional: Add detailed instruction about file purposes and design patterns\n - Optional: Specify patterns to match existing files this feature works with\n\n3. **Create Template Files**: Use `generate-boilerplate-file` to create the actual template files\n - Create files referenced in the boilerplate's or feature's includes array\n - Use {{ variableName }} syntax for Liquid variable placeholders\n - Can copy from existing source files or provide content directly\n - Files automatically get .liquid extension\n\n4. **Test the Template**: Use `list-boilerplates`/`list-scaffolding-methods` and `use-boilerplate`/`use-scaffold-method` to verify your template works\n\nExample workflow for boilerplate:\n```\n1. generate-boilerplate { templateName: \"react-vite\", boilerplateName: \"scaffold-vite-app\", ... }\n2. generate-boilerplate-file { templateName: \"react-vite\", filePath: \"package.json\", content: \"...\" }\n3. generate-boilerplate-file { templateName: \"react-vite\", filePath: \"src/App.tsx\", content: \"...\" }\n4. list-boilerplates (verify it appears)\n5. use-boilerplate { boilerplateName: \"scaffold-vite-app\", variables: {...} }\n```\n\nExample workflow for feature:\n```\n1. generate-feature-scaffold { templateName: \"nextjs-15\", featureName: \"scaffold-nextjs-component\", generator: \"componentGenerator.ts\", ... }\n2. generate-boilerplate-file { templateName: \"nextjs-15\", filePath: \"src/components/Component.tsx\", content: \"...\" }\n3. list-scaffolding-methods (verify it appears)\n4. use-scaffold-method { scaffoldName: \"scaffold-nextjs-component\", variables: {...} }\n```\n{% endif %}\n";
231
+
232
+ //#endregion
233
+ //#region src/instructions/prompts/generate-boilerplate.md?raw
234
+ var generate_boilerplate_default = "You are helping create a new boilerplate template configuration using the scaffold-mcp MCP tools.\n\n{% if request %}User request: {{ request }}\n{% endif %}\nYour task:\n\n1. **Gather Information**: Ask for any missing details:\n - Framework/technology (e.g., \"React Vite\", \"Express API\", \"Next.js 15\")\n - Template name (kebab-case, e.g., \"react-vite\", \"nextjs-15\")\n - Boilerplate name (prefixed with \"scaffold-\", e.g., \"scaffold-vite-app\")\n {% if not isMonolith %}- Target folder (e.g., \"apps\", \"packages\"){% else %}- Target folder (defaults to \".\" for monolith mode){% endif %}\n - Project type (app, library, service, etc.)\n - Required variables (at minimum: appName or packageName)\n - Files to include in the template\n\n2. **Use MCP Tools** in order:\n - `generate-boilerplate` - Creates the boilerplate configuration\n - `generate-boilerplate-file` - Creates each template file\n {% if not isMonolith %}- `list-boilerplates` - Verify it appears{% endif %}\n - `use-boilerplate` - Test the boilerplate\n\nImportant:\n- Template naming: Use kebab-case (e.g., \"react-vite\", \"express-api\")\n- Boilerplate naming: Prefix with \"scaffold-\" (e.g., \"scaffold-vite-app\")\n{% if not isMonolith %}- Target folder: \"apps\" for applications, \"packages\" for libraries{% else %}- Target folder: \".\" for monolith projects (creates files at workspace root){% endif %}\n- Include files explicitly - avoid wildcards\n- Template syntax: use {{ variableName }}\n\n**Description Field Guidelines (CRITICAL)**:\nThe description should be a comprehensive multi-paragraph overview (3-5 sentences):\n- Paragraph 1: Core technology stack and primary value proposition\n- Paragraph 2: Target use cases and ideal project types\n- Paragraph 3: Key integrations or special features (if applicable)\n\nExample:\n\"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.\nPerfect for building data-driven dashboards, admin panels, and interactive web applications requiring client-side routing and real-time data synchronization.\n\nIncludes Agiflow Config Management System integration with systematic environment variable naming (VITE_{CATEGORY}_{SUBCATEGORY}_{PROPERTY}) and auto-generated configuration templates for cloud deployment.\"\n\n**Instruction Field Guidelines (CRITICAL)**:\nThe instruction should be a detailed multi-section guide that helps AI understand the codebase:\n\n1. **File purposes** section: List each major file/directory with its purpose\n Format: \"- path/to/file: Description of what this file does\"\n\n2. **How to use the scaffolded code** section: Step-by-step workflows\n Format: Numbered list with specific examples\n - How to add routes/pages\n - How to fetch data\n - How to handle authentication\n - How to configure environment variables\n\n3. **Design patterns to follow** section: Key architectural decisions\n Format: \"- Pattern Name: Explanation and when to use it\"\n - Routing patterns\n - State management patterns\n - Data fetching patterns\n - Error handling patterns\n - Performance optimization patterns\n\nExample structure:\n\"[Framework] application template with [key technologies].\n\nFile purposes:\n- package.json: NPM package configuration with [framework] and dependencies\n- src/main.tsx: Application entry point with [setup details]\n- src/routes/: Route definitions following [pattern]\n[... list all major files ...]\n\nHow to use the scaffolded code:\n1. Routes: Create new routes by [specific instructions with example]\n2. Data Fetching: Use [specific pattern] for [use case]\n3. Authentication: Use [specific components/modules] for user management\n[... numbered steps for common tasks ...]\n\nDesign patterns to follow:\n- File-based Routing: Use directory structure in src/routes/ to define URL paths\n- Type-safe Routes: Leverage [framework] type inference for params\n- State Management: Use [library] for server state, [library] for client state\n[... list key patterns with explanations ...]\"\n\nTemplate File Content Guidelines:\n- Keep content MINIMAL and business-agnostic\n- Focus on structure and patterns, not business logic\n- Use placeholder/generic examples only\n- Include essential boilerplate code only\n- Let AI fill in specific logic later\n- Add clear headers with design patterns and coding standards\n";
235
+
236
+ //#endregion
237
+ //#region src/prompts/GenerateBoilerplatePrompt.ts
238
+ /**
239
+ * Prompt for generating boilerplates
240
+ */
241
+ var GenerateBoilerplatePrompt = class GenerateBoilerplatePrompt {
242
+ static PROMPT_NAME = "generate-boilerplate";
243
+ templateService = new require_TemplateService.TemplateService();
244
+ constructor(isMonolith = false) {
245
+ this.isMonolith = isMonolith;
246
+ }
247
+ /**
248
+ * Get the prompt definition for MCP
249
+ */
250
+ getDefinition() {
251
+ return {
252
+ name: GenerateBoilerplatePrompt.PROMPT_NAME,
253
+ description: "Generate a new boilerplate template configuration",
254
+ arguments: [{
255
+ name: "request",
256
+ description: "Describe the boilerplate template you want to create",
257
+ required: false
258
+ }]
259
+ };
260
+ }
261
+ /**
262
+ * Get the prompt messages
263
+ */
264
+ getMessages(args) {
265
+ const request = args?.request || "";
266
+ return [{
267
+ role: "user",
268
+ content: {
269
+ type: "text",
270
+ text: this.templateService.renderString(generate_boilerplate_default, {
271
+ request,
272
+ isMonolith: this.isMonolith
273
+ })
274
+ }
275
+ }];
276
+ }
277
+ };
278
+
279
+ //#endregion
280
+ //#region src/instructions/prompts/generate-feature-scaffold.md?raw
281
+ var generate_feature_scaffold_default = "You are helping create a new feature scaffold configuration using the scaffold-mcp MCP tools.\n\n{% if request %}User request: {{ request }}\n{% endif %}\nYour task:\n\n1. **Gather Information**: Ask for any missing details:\n {% if not isMonolith %}- Template name (e.g., \"nextjs-15\", \"react-vite\"){% else %}- Template name (will be auto-detected from toolkit.yaml){% endif %}\n - Feature name (prefixed with \"scaffold-\", e.g., \"scaffold-nextjs-page\")\n - Feature type (page, component, service, etc.)\n - Variables needed\n - Files to include\n\n2. **Use MCP Tools** in order:\n - `generate-feature-scaffold` - Creates the feature configuration\n - `generate-boilerplate-file` - Creates each template file\n - `list-scaffolding-methods` - Verify it appears\n - `use-scaffold-method` - Test the feature\n\nImportant:\n- Feature names: prefix with \"scaffold-\"\n- Conditional includes: use \"file.tsx?withLayout=true\"\n- Template syntax: use {{ variableName }}\n{% if isMonolith %}- Template name will be auto-detected from toolkit.yaml{% endif %}\n\n**Description Field Guidelines (CRITICAL)**:\nThe description should explain what the feature scaffold generates (2-3 sentences):\n- Sentence 1: What type of code it generates (component, page, service, etc.)\n- Sentence 2: Key features or capabilities included\n- Sentence 3: Primary use cases or when to use it\n\nExample:\n\"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.\"\n\n**Instruction Field Guidelines (CRITICAL)**:\nThe instruction should provide specific guidance for using the generated feature:\n\n1. **Pattern explanation**: Describe the architectural pattern used\n2. **File organization**: Where files should be placed\n3. **Naming conventions**: How to name things (PascalCase, camelCase, etc.)\n4. **Usage guidelines**: How to use the generated code\n5. **Testing approach**: How to test the feature\n\nExample structure:\n\"[Feature type] follow a [pattern name] pattern with [key characteristics].\n[Explanation of how it works and integrates with the project].\nPlace [files] in [directory].\nFor [features with X], define [Y] in [Z] for better separation of concerns.\n[Feature names] should be [case style] and [suffix/prefix rules].\nWrite comprehensive [tests/docs] for all [public methods/exports].\"\n\nKeep it concise but informative - focus on the patterns and conventions that AI needs to understand to work with the generated code effectively.\n\nTemplate File Content Guidelines:\n- Keep content MINIMAL and business-agnostic\n- Focus on structure and patterns, not business logic\n- Use placeholder/generic examples only\n- Include essential boilerplate code only\n- Let AI fill in specific logic later\n- Add clear headers with design patterns and coding standards\n";
282
+
283
+ //#endregion
284
+ //#region src/prompts/GenerateFeatureScaffoldPrompt.ts
285
+ /**
286
+ * Prompt for generating feature scaffolds
287
+ */
288
+ var GenerateFeatureScaffoldPrompt = class GenerateFeatureScaffoldPrompt {
289
+ static PROMPT_NAME = "generate-feature-scaffold";
290
+ templateService = new require_TemplateService.TemplateService();
291
+ constructor(isMonolith = false) {
292
+ this.isMonolith = isMonolith;
293
+ }
294
+ /**
295
+ * Get the prompt definition for MCP
296
+ */
297
+ getDefinition() {
298
+ return {
299
+ name: GenerateFeatureScaffoldPrompt.PROMPT_NAME,
300
+ description: "Generate a new feature scaffold configuration",
301
+ arguments: [{
302
+ name: "request",
303
+ description: "Describe the feature scaffold you want to create",
304
+ required: false
305
+ }]
306
+ };
307
+ }
308
+ /**
309
+ * Get the prompt messages
310
+ */
311
+ getMessages(args) {
312
+ const request = args?.request || "";
313
+ return [{
314
+ role: "user",
315
+ content: {
316
+ type: "text",
317
+ text: this.templateService.renderString(generate_feature_scaffold_default, {
318
+ request,
319
+ isMonolith: this.isMonolith
320
+ })
321
+ }
322
+ }];
323
+ }
324
+ };
325
+
326
+ //#endregion
327
+ //#region src/instructions/prompts/scaffold-application.md?raw
328
+ var scaffold_application_default = "You are helping create a new {% if isMonolith %}monolith application{% else %}application{% endif %} using the scaffold-mcp MCP tools.\n\n{% if request %}User request: {{ request }}\n{% endif %}\nYour task is to scaffold a new application by following this workflow:\n\n## Step 1: {% if isMonolith %}Prepare to Create Application{% else %}List Available Boilerplates{% endif %}\n{% if isMonolith %}You will use the `use-boilerplate` tool to create your monolith application. The boilerplate name will be auto-detected from your toolkit.yaml file.{% else %}Use the `list-boilerplates` tool to see all available project templates.\n\n**What to look for:**\n- Boilerplate name (e.g., \"scaffold-nextjs-app\", \"scaffold-vite-app\")\n- Description of what the boilerplate creates\n- Target folder where projects will be created (e.g., \"apps\", \"packages\")\n- Required and optional variables in the variables_schema{% endif %}\n\n## Step 2: Gather Required Information\nBased on the {% if isMonolith %}toolkit.yaml{% else %}selected boilerplate's variables_schema{% endif %}, collect:\n{% if not isMonolith %}- **Project name**: Must be kebab-case (e.g., \"my-new-app\", not \"MyNewApp\")\n{% endif %}- **Required variables**: All variables marked as required: true\n- **Optional variables**: Variables with required: false (ask user if needed)\n\nCommon variables:\n- `appName` or `packageName`: The project name (kebab-case)\n- `description`: Brief description of what the project does\n- `author`: Author name\n\n## Step 3: Execute the Boilerplate\nUse the `use-boilerplate` tool with:\n{% if not isMonolith %}- `boilerplateName`: Exact name from list-boilerplates response\n{% endif %}- `variables`: Object matching the variables_schema exactly\n\n**Example:**\n```json\n{\n{% if not isMonolith %} \"boilerplateName\": \"scaffold-nextjs-app\",\n{% endif %} \"variables\": {\n \"appName\": \"my-dashboard\",\n \"description\": \"Admin dashboard for managing users\",\n \"author\": \"John Doe\"\n }\n}\n```\n\n## Important Guidelines:\n{% if not isMonolith %}- **Always call `list-boilerplates` first** to see available options and their schemas{% else %}- The boilerplate name is auto-detected from toolkit.yaml{% endif %}\n- **Use exact variable names** from the schema (case-sensitive)\n- **Provide all required variables** - the tool will fail if any are missing\n{% if not isMonolith %}- **Use kebab-case for project names** (e.g., \"user-dashboard\", not \"UserDashboard\")\n- The tool will create the project in the appropriate directory automatically{% else %}- The tool will create files at the workspace root{% endif %}\n- After creation, inform the user {% if isMonolith %}what files were created{% else %}where the project was created{% endif %}\n\n## Step 4: Review and Add Features (If Needed)\nAfter the boilerplate is created, **consider if additional features are needed**:\n1. **READ** the generated {% if isMonolith %}application{% else %}project{% endif %} structure to understand what was created\n2. **REVIEW** the user's request to see if they asked for specific features (e.g., \"with tool for X\", \"with prompt for Y\")\n3. **If features are needed**:\n - Use `list-scaffolding-methods`{% if not isMonolith %} with the new project path{% endif %}\n - Use `use-scaffold-method` to add tools, services, prompts, etc.\n - **IMPLEMENT** the actual logic in the scaffolded feature files\n - **REGISTER** the features in `src/server/index.ts`\n4. **Install dependencies**: Remind user to run `pnpm install`\n5. **Report** the complete setup including any features added\n\n## Example Workflow:\n{% if not isMonolith %}1. Call `list-boilerplates` → See available templates\n2. Ask user which template to use (or infer from request)\n3. Collect required variables based on schema\n4. Call `use-boilerplate` with boilerplateName and variables{% else %}1. Collect required variables based on toolkit.yaml variables_schema\n2. Call `use-boilerplate` with variables (boilerplateName auto-detected){% endif %}\n5. **Review if user requested specific features (tools, prompts, etc.)**\n6. **If features needed**: Add them using `list-scaffolding-methods` and `use-scaffold-method`\n7. **READ and IMPLEMENT** the scaffolded feature files with actual logic\n8. Report success and next steps to the user\n";
329
+
330
+ //#endregion
331
+ //#region src/prompts/ScaffoldApplicationPrompt.ts
332
+ /**
333
+ * Prompt for scaffolding a new application using boilerplate templates
334
+ */
335
+ var ScaffoldApplicationPrompt = class ScaffoldApplicationPrompt {
336
+ static PROMPT_NAME = "scaffold-application";
337
+ templateService = new require_TemplateService.TemplateService();
338
+ constructor(isMonolith = false) {
339
+ this.isMonolith = isMonolith;
340
+ }
341
+ /**
342
+ * Get the prompt definition for MCP
343
+ */
344
+ getDefinition() {
345
+ return {
346
+ name: ScaffoldApplicationPrompt.PROMPT_NAME,
347
+ description: "Scaffold a new application from a boilerplate template",
348
+ arguments: [{
349
+ name: "request",
350
+ description: "Describe the application you want to create (optional)",
351
+ required: false
352
+ }]
353
+ };
354
+ }
355
+ /**
356
+ * Get the prompt messages
357
+ */
358
+ getMessages(args) {
359
+ const request = args?.request || "";
360
+ return [{
361
+ role: "user",
362
+ content: {
363
+ type: "text",
364
+ text: this.templateService.renderString(scaffold_application_default, {
365
+ request,
366
+ isMonolith: this.isMonolith
367
+ })
368
+ }
369
+ }];
370
+ }
371
+ };
372
+
373
+ //#endregion
374
+ //#region src/instructions/prompts/scaffold-feature.md?raw
375
+ var scaffold_feature_default = "You are helping add a new feature to an existing project using the scaffold-mcp MCP tools.\n\n{% if request %}User request: {{ request }}\n{% endif %}{% if projectPath %}Project path: {{ projectPath }}\n{% endif %}\nYour task is to scaffold a new feature by following this workflow:\n\n## Step 1: Identify the Project\nDetermine the project path where the feature will be added:\n- If projectPath is provided, use it\n- Otherwise, ask the user or infer from context (e.g., \"apps/my-app\", \"packages/my-lib\")\n{% if isMonolith %}- In monolith mode, you can use the current working directory (no projectPath needed){% else %}- The path should point to a directory containing a `project.json` file{% endif %}\n\n## Step 2: List Available Scaffolding Methods\nUse the `list-scaffolding-methods` tool{% if not isMonolith %} with the projectPath{% endif %}.\n\n**What to look for:**\n- Feature name (e.g., \"scaffold-nextjs-page\", \"scaffold-react-component\")\n- Description of what files/code it generates\n- Required and optional variables in the variables_schema\n- The template type (derived from project's sourceTemplate)\n\n**Example:**\n```json\n{% if isMonolith %}{}{% else %}{\n \"projectPath\": \"apps/my-dashboard\"\n}{% endif %}\n```\n\n## Step 3: Gather Required Information\nBased on the selected scaffolding method's variables_schema, collect:\n- **Feature-specific variables**: Name, path, type, etc.\n- **Required variables**: All variables marked as required: true\n- **Optional variables**: Variables with required: false (ask user if needed)\n\nCommon variables:\n- `componentName` / `pageName` / `serviceName`: Name in PascalCase\n- `componentPath` / `pagePath`: Where to place the file (may use kebab-case)\n- Boolean flags: `withTests`, `withLayout`, `withStyles`, etc.\n\n## Step 4: Execute the Scaffolding Method\nUse the `use-scaffold-method` tool with:\n{% if not isMonolith %}- `projectPath`: Same path from step 1\n{% endif %}- `scaffold_feature_name`: Exact name from list-scaffolding-methods response\n- `variables`: Object matching the variables_schema exactly\n\n**Example:**\n```json\n{\n{% if not isMonolith %} \"projectPath\": \"apps/my-dashboard\",\n{% endif %} \"scaffold_feature_name\": \"scaffold-nextjs-page\",\n \"variables\": {\n \"pageName\": \"UserProfile\",\n \"pagePath\": \"user/profile\",\n \"withLayout\": true,\n \"withTests\": false\n }\n}\n```\n\n## Important Guidelines:\n- **Always call `list-scaffolding-methods` first**{% if not isMonolith %} with the projectPath{% endif %}\n- **Use exact variable names** from the schema (case-sensitive)\n- **Provide all required variables** - the tool will fail if any are missing\n- **Follow naming conventions**:\n - Component/Page/Service names: PascalCase (e.g., \"UserProfile\")\n - File paths: kebab-case or as specified in schema (e.g., \"user/profile\")\n- **Conditional files**: Files with `?condition=true` are only included when the variable is true\n- The tool will create files in the appropriate locations automatically\n- After creation, inform the user what files were created\n\n## Step 5: Review and Implement Generated Files\nAfter scaffolding completes, **you MUST**:\n1. **READ** all generated files to understand their structure\n2. **IMPLEMENT** the actual business logic:\n - Replace TODO comments with real code\n - Replace template placeholders with actual implementation\n - Add the specific functionality described in the user's request\n3. **REGISTER** the feature in appropriate files:\n - Import and register tools in `src/server/index.ts`\n - Export new modules from `index.ts` files\n - Update any necessary configuration files\n4. **TEST** to ensure the implementation works correctly\n5. **DO NOT SKIP** this step - scaffolded files are templates that need actual code\n\n## Example Workflow:\n1. Identify project path (provided or ask user){% if not isMonolith %}\n2. Call `list-scaffolding-methods` → See available features for this project{% else %}\n2. Call `list-scaffolding-methods` → See available features for your template{% endif %}\n3. Ask user which feature to add (or infer from request)\n4. Collect required variables based on schema\n5. Call `use-scaffold-method` with {% if not isMonolith %}projectPath, {% endif %}scaffold_feature_name, and variables\n6. **READ the generated files and IMPLEMENT the actual logic**\n7. **REGISTER the feature in server/index.ts and other config files**\n8. Report success and list created files with implementation details\n";
376
+
377
+ //#endregion
378
+ //#region src/prompts/ScaffoldFeaturePrompt.ts
379
+ /**
380
+ * Prompt for scaffolding a new feature in an existing project
381
+ */
382
+ var ScaffoldFeaturePrompt = class ScaffoldFeaturePrompt {
383
+ static PROMPT_NAME = "scaffold-feature";
384
+ templateService = new require_TemplateService.TemplateService();
385
+ constructor(isMonolith = false) {
386
+ this.isMonolith = isMonolith;
387
+ }
388
+ /**
389
+ * Get the prompt definition for MCP
390
+ */
391
+ getDefinition() {
392
+ return {
393
+ name: ScaffoldFeaturePrompt.PROMPT_NAME,
394
+ description: "Scaffold a new feature (page, component, service, etc.) in an existing project",
395
+ arguments: [{
396
+ name: "request",
397
+ description: "Describe the feature you want to add (optional)",
398
+ required: false
399
+ }, {
400
+ name: "projectPath",
401
+ description: "Path to the project (e.g., \"apps/my-app\") - optional if can be inferred",
402
+ required: false
403
+ }]
404
+ };
405
+ }
406
+ /**
407
+ * Get the prompt messages
408
+ */
409
+ getMessages(args) {
410
+ const request = args?.request || "";
411
+ const projectPath = args?.projectPath || "";
412
+ return [{
413
+ role: "user",
414
+ content: {
415
+ type: "text",
416
+ text: this.templateService.renderString(scaffold_feature_default, {
417
+ request,
418
+ projectPath,
419
+ isMonolith: this.isMonolith
420
+ })
421
+ }
422
+ }];
423
+ }
424
+ };
425
+
426
+ //#endregion
427
+ //#region src/server/index.ts
428
+ function createServer(options = {}) {
429
+ const { adminEnabled = false, isMonolith = false } = options;
430
+ const templatesPath = __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPathSync();
431
+ const listBoilerplatesTool = !isMonolith ? new require_stdio.ListBoilerplatesTool(templatesPath, isMonolith) : null;
432
+ const useBoilerplateTool = !isMonolith ? new require_stdio.UseBoilerplateTool(templatesPath, isMonolith) : null;
433
+ const listScaffoldingMethodsTool = new require_stdio.ListScaffoldingMethodsTool(templatesPath, isMonolith);
434
+ const useScaffoldMethodTool = new require_stdio.UseScaffoldMethodTool(templatesPath, isMonolith);
435
+ const writeToFileTool = new require_stdio.WriteToFileTool();
436
+ const generateBoilerplateTool = adminEnabled ? new require_stdio.GenerateBoilerplateTool(templatesPath, isMonolith) : null;
437
+ const generateBoilerplateFileTool = adminEnabled ? new require_stdio.GenerateBoilerplateFileTool(templatesPath, isMonolith) : null;
438
+ const generateFeatureScaffoldTool = adminEnabled ? new require_stdio.GenerateFeatureScaffoldTool(templatesPath, isMonolith) : null;
439
+ const generateBoilerplatePrompt = adminEnabled ? new GenerateBoilerplatePrompt(isMonolith) : null;
440
+ const generateFeatureScaffoldPrompt = adminEnabled ? new GenerateFeatureScaffoldPrompt(isMonolith) : null;
441
+ const scaffoldApplicationPrompt = new ScaffoldApplicationPrompt(isMonolith);
442
+ const scaffoldFeaturePrompt = new ScaffoldFeaturePrompt(isMonolith);
443
+ const instructions = new require_TemplateService.TemplateService().renderString(server_default, {
444
+ adminEnabled,
445
+ isMonolith
446
+ });
447
+ const server = new __modelcontextprotocol_sdk_server_index_js.Server({
448
+ name: "scaffold-mcp",
449
+ version: package_default.version
450
+ }, {
451
+ instructions,
452
+ capabilities: {
453
+ tools: {},
454
+ prompts: {}
455
+ }
456
+ });
457
+ server.setRequestHandler(__modelcontextprotocol_sdk_types_js.ListToolsRequestSchema, async () => {
458
+ const tools = [
459
+ listScaffoldingMethodsTool.getDefinition(),
460
+ useScaffoldMethodTool.getDefinition(),
461
+ writeToFileTool.getDefinition()
462
+ ];
463
+ if (!isMonolith) {
464
+ if (listBoilerplatesTool) tools.unshift(listBoilerplatesTool.getDefinition());
465
+ if (useBoilerplateTool) tools.splice(1, 0, useBoilerplateTool.getDefinition());
466
+ }
467
+ if (adminEnabled) {
468
+ if (generateBoilerplateTool) tools.push(generateBoilerplateTool.getDefinition());
469
+ if (generateBoilerplateFileTool) tools.push(generateBoilerplateFileTool.getDefinition());
470
+ if (generateFeatureScaffoldTool) tools.push(generateFeatureScaffoldTool.getDefinition());
471
+ }
472
+ return { tools };
473
+ });
474
+ server.setRequestHandler(__modelcontextprotocol_sdk_types_js.CallToolRequestSchema, async (request) => {
475
+ const { name: name$1, arguments: args } = request.params;
476
+ if (name$1 === require_stdio.ListBoilerplatesTool.TOOL_NAME) {
477
+ if (isMonolith || !listBoilerplatesTool) throw new Error("Boilerplate tools are not available for monolith projects");
478
+ return await listBoilerplatesTool.execute(args || {});
479
+ }
480
+ if (name$1 === require_stdio.UseBoilerplateTool.TOOL_NAME) {
481
+ if (isMonolith || !useBoilerplateTool) throw new Error("Boilerplate tools are not available for monolith projects");
482
+ return await useBoilerplateTool.execute(args || {});
483
+ }
484
+ if (name$1 === require_stdio.ListScaffoldingMethodsTool.TOOL_NAME) return await listScaffoldingMethodsTool.execute(args || {});
485
+ if (name$1 === require_stdio.UseScaffoldMethodTool.TOOL_NAME) return await useScaffoldMethodTool.execute(args || {});
486
+ if (name$1 === require_stdio.WriteToFileTool.TOOL_NAME) return await writeToFileTool.execute(args || {});
487
+ if (name$1 === require_stdio.GenerateBoilerplateTool.TOOL_NAME) {
488
+ if (!adminEnabled || !generateBoilerplateTool) throw new Error("Admin tools are not enabled. Use --admin-enable flag to enable.");
489
+ return await generateBoilerplateTool.execute(args);
490
+ }
491
+ if (name$1 === require_stdio.GenerateBoilerplateFileTool.TOOL_NAME) {
492
+ if (!adminEnabled || !generateBoilerplateFileTool) throw new Error("Admin tools are not enabled. Use --admin-enable flag to enable.");
493
+ return await generateBoilerplateFileTool.execute(args);
494
+ }
495
+ if (name$1 === require_stdio.GenerateFeatureScaffoldTool.TOOL_NAME) {
496
+ if (!adminEnabled || !generateFeatureScaffoldTool) throw new Error("Admin tools are not enabled. Use --admin-enable flag to enable.");
497
+ return await generateFeatureScaffoldTool.execute(args);
498
+ }
499
+ throw new Error(`Unknown tool: ${name$1}`);
500
+ });
501
+ server.setRequestHandler(__modelcontextprotocol_sdk_types_js.ListPromptsRequestSchema, async () => {
502
+ const prompts = [];
503
+ prompts.push(scaffoldApplicationPrompt.getDefinition());
504
+ prompts.push(scaffoldFeaturePrompt.getDefinition());
505
+ if (adminEnabled) {
506
+ if (generateBoilerplatePrompt) prompts.push(generateBoilerplatePrompt.getDefinition());
507
+ if (generateFeatureScaffoldPrompt) prompts.push(generateFeatureScaffoldPrompt.getDefinition());
508
+ }
509
+ return { prompts };
510
+ });
511
+ server.setRequestHandler(__modelcontextprotocol_sdk_types_js.GetPromptRequestSchema, async (request) => {
512
+ const { name: name$1, arguments: args } = request.params;
513
+ if (name$1 === ScaffoldApplicationPrompt.PROMPT_NAME) return { messages: scaffoldApplicationPrompt.getMessages(args) };
514
+ if (name$1 === ScaffoldFeaturePrompt.PROMPT_NAME) return { messages: scaffoldFeaturePrompt.getMessages(args) };
515
+ if (name$1 === GenerateBoilerplatePrompt.PROMPT_NAME) {
516
+ if (!generateBoilerplatePrompt) throw new Error("Prompt not available");
517
+ return { messages: generateBoilerplatePrompt.getMessages(args) };
518
+ }
519
+ if (name$1 === GenerateFeatureScaffoldPrompt.PROMPT_NAME) {
520
+ if (!generateFeatureScaffoldPrompt) throw new Error("Prompt not available");
521
+ return { messages: generateFeatureScaffoldPrompt.getMessages(args) };
522
+ }
523
+ throw new Error(`Unknown prompt: ${name$1}`);
524
+ });
525
+ return server;
526
+ }
527
+
528
+ //#endregion
529
+ //#region src/transports/types.ts
530
+ /**
531
+ * Transport mode types
532
+ */
533
+ let TransportMode = /* @__PURE__ */ function(TransportMode$1) {
534
+ TransportMode$1["STDIO"] = "stdio";
535
+ TransportMode$1["HTTP"] = "http";
536
+ TransportMode$1["SSE"] = "sse";
537
+ TransportMode$1["CLI"] = "cli";
538
+ return TransportMode$1;
539
+ }({});
540
+
541
+ //#endregion
542
+ //#region src/commands/mcp-serve.ts
543
+ /**
544
+ * Start MCP server with given transport handler
545
+ */
546
+ async function startServer(handler) {
547
+ await handler.start();
548
+ const shutdown = async (signal) => {
549
+ console.error(`\nReceived ${signal}, shutting down gracefully...`);
550
+ try {
551
+ await handler.stop();
552
+ process.exit(0);
553
+ } catch (error) {
554
+ console.error("Error during shutdown:", error);
555
+ process.exit(1);
556
+ }
557
+ };
558
+ process.on("SIGINT", () => shutdown("SIGINT"));
559
+ process.on("SIGTERM", () => shutdown("SIGTERM"));
560
+ }
561
+ /**
562
+ * MCP Serve command
563
+ */
564
+ 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) => {
565
+ try {
566
+ const transportType = options.type.toLowerCase();
567
+ let isMonolith = false;
568
+ try {
569
+ isMonolith = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).type === "monolith";
570
+ } catch {
571
+ isMonolith = false;
572
+ }
573
+ const serverOptions = {
574
+ adminEnabled: options.adminEnable,
575
+ isMonolith
576
+ };
577
+ if (transportType === "stdio") await startServer(new require_stdio.StdioTransportHandler(createServer(serverOptions)));
578
+ else if (transportType === "http") await startServer(new require_stdio.HttpTransportHandler(() => createServer(serverOptions), {
579
+ mode: TransportMode.HTTP,
580
+ port: options.port || Number(process.env.MCP_PORT) || 3e3,
581
+ host: options.host || process.env.MCP_HOST || "localhost"
582
+ }));
583
+ else if (transportType === "sse") await startServer(new require_stdio.SseTransportHandler(() => createServer(serverOptions), {
584
+ mode: TransportMode.SSE,
585
+ port: options.port || Number(process.env.MCP_PORT) || 3e3,
586
+ host: options.host || process.env.MCP_HOST || "localhost"
587
+ }));
588
+ else {
589
+ console.error(`Unknown transport type: ${transportType}. Use: stdio, http, or sse`);
590
+ process.exit(1);
591
+ }
592
+ } catch (error) {
593
+ console.error("Failed to start MCP server:", error);
594
+ process.exit(1);
595
+ }
596
+ });
597
+
598
+ //#endregion
599
+ //#region src/commands/scaffold.ts
600
+ /**
601
+ * Scaffold CLI command
602
+ */
603
+ const scaffoldCommand = new commander.Command("scaffold").description("Add features to existing projects");
604
+ scaffoldCommand.command("list [projectPath]").description("List available scaffolding methods for a project or template").option("-t, --template <name>", "Template name (e.g., nextjs-15, typescript-mcp-package)").action(async (projectPath, options) => {
605
+ try {
606
+ if (!projectPath && !options.template) {
607
+ __agiflowai_aicode_utils.messages.error("Either projectPath or --template option must be provided");
608
+ __agiflowai_aicode_utils.messages.hint("Examples:");
609
+ __agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold list ./my-project");
610
+ __agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold list --template nextjs-15");
611
+ process.exit(1);
612
+ }
613
+ const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
614
+ const scaffoldingMethodsService = new require_stdio.ScaffoldingMethodsService(new require_stdio.FileSystemService(), templatesDir);
615
+ let result;
616
+ let displayName;
617
+ if (projectPath) {
618
+ const absolutePath = node_path.default.resolve(projectPath);
619
+ if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(absolutePath)) {
620
+ __agiflowai_aicode_utils.messages.error(`No project configuration found in ${absolutePath}`);
621
+ __agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root\nOr use --template option to list methods for a specific template");
622
+ process.exit(1);
623
+ }
624
+ result = await scaffoldingMethodsService.listScaffoldingMethods(absolutePath);
625
+ displayName = projectPath;
626
+ } else {
627
+ result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template);
628
+ displayName = `template: ${options.template}`;
629
+ }
630
+ const methods = result.methods;
631
+ if (methods.length === 0) {
632
+ __agiflowai_aicode_utils.messages.warning(`No scaffolding methods available for ${displayName}.`);
633
+ return;
634
+ }
635
+ __agiflowai_aicode_utils.print.header(`\n${__agiflowai_aicode_utils.icons.wrench} Available Scaffolding Methods for ${displayName}:\n`);
636
+ for (const method of methods) {
637
+ __agiflowai_aicode_utils.print.highlight(` ${method.name}`);
638
+ __agiflowai_aicode_utils.print.debug(` ${method.instruction || method.description || "No description available"}`);
639
+ if (method.variables_schema.required && method.variables_schema.required.length > 0) __agiflowai_aicode_utils.print.debug(` Required: ${method.variables_schema.required.join(", ")}`);
640
+ __agiflowai_aicode_utils.print.newline();
641
+ }
642
+ } catch (error) {
643
+ __agiflowai_aicode_utils.messages.error("Error listing scaffolding methods:", error);
644
+ process.exit(1);
645
+ }
646
+ });
647
+ 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) => {
648
+ try {
649
+ const projectPath = node_path.default.resolve(options.project);
650
+ if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
651
+ __agiflowai_aicode_utils.messages.error(`No project configuration found in ${projectPath}`);
652
+ __agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root");
653
+ process.exit(1);
654
+ }
655
+ let variables = {};
656
+ if (options.vars) try {
657
+ variables = JSON.parse(options.vars);
658
+ } catch (error) {
659
+ __agiflowai_aicode_utils.messages.error("Error parsing variables JSON:", error);
660
+ __agiflowai_aicode_utils.messages.hint("Example: --vars '{\"componentName\": \"UserProfile\", \"description\": \"User profile component\"}'");
661
+ process.exit(1);
662
+ }
663
+ const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
664
+ const scaffoldingMethodsService = new require_stdio.ScaffoldingMethodsService(new require_stdio.FileSystemService(), templatesDir);
665
+ const methods = (await scaffoldingMethodsService.listScaffoldingMethods(projectPath)).methods;
666
+ const method = methods.find((m) => m.name === featureName);
667
+ if (!method) {
668
+ __agiflowai_aicode_utils.messages.error(`Scaffold method '${featureName}' not found.`);
669
+ __agiflowai_aicode_utils.print.warning(`Available methods: ${methods.map((m) => m.name).join(", ")}`);
670
+ __agiflowai_aicode_utils.print.debug(`Run 'scaffold-mcp scaffold list ${options.project}' to see all available methods`);
671
+ process.exit(1);
672
+ }
673
+ const required = typeof method.variables_schema === "object" && method.variables_schema !== null && "required" in method.variables_schema ? method.variables_schema.required : [];
674
+ const missing = required.filter((key) => !variables[key]);
675
+ if (missing.length > 0) {
676
+ __agiflowai_aicode_utils.messages.error(`❌ Missing required variables: ${missing.join(", ")}`);
677
+ __agiflowai_aicode_utils.messages.hint(`💡 Use --vars with a JSON object containing: ${missing.join(", ")}`);
678
+ const exampleVars = {};
679
+ for (const key of required) if (key.includes("Name")) exampleVars[key] = "MyFeature";
680
+ else if (key === "description") exampleVars[key] = "Feature description";
681
+ else exampleVars[key] = `<${key}>`;
682
+ __agiflowai_aicode_utils.print.debug(`Example: scaffold-mcp scaffold add ${featureName} --project ${options.project} --vars '${JSON.stringify(exampleVars)}'`);
683
+ process.exit(1);
684
+ }
685
+ if (options.verbose) {
686
+ __agiflowai_aicode_utils.print.info(`🔧 Feature: ${featureName}`);
687
+ __agiflowai_aicode_utils.print.info(`📊 Variables: ${JSON.stringify(variables, null, 2)}`);
688
+ __agiflowai_aicode_utils.print.info(`📁 Project Path: ${projectPath}`);
689
+ }
690
+ __agiflowai_aicode_utils.print.info(`🚀 Adding '${featureName}' to project...`);
691
+ const result = await scaffoldingMethodsService.useScaffoldMethod({
692
+ projectPath,
693
+ scaffold_feature_name: featureName,
694
+ variables
695
+ });
696
+ if (result.success) {
697
+ __agiflowai_aicode_utils.messages.success("✅ Feature added successfully!");
698
+ if (result.createdFiles && result.createdFiles.length > 0) {
699
+ __agiflowai_aicode_utils.print.header("\n📁 Created files:");
700
+ result.createdFiles.forEach((file) => __agiflowai_aicode_utils.print.debug(` - ${file}`));
701
+ }
702
+ if (result.warnings && result.warnings.length > 0) {
703
+ __agiflowai_aicode_utils.messages.warning("\n⚠️ Warnings:");
704
+ result.warnings.forEach((warning) => __agiflowai_aicode_utils.print.debug(` - ${warning}`));
705
+ }
706
+ __agiflowai_aicode_utils.print.header("\n📋 Next steps:");
707
+ __agiflowai_aicode_utils.print.debug(" - Review the generated files");
708
+ __agiflowai_aicode_utils.print.debug(" - Update imports if necessary");
709
+ __agiflowai_aicode_utils.print.debug(" - Run tests to ensure everything works");
710
+ } else {
711
+ __agiflowai_aicode_utils.messages.error(`❌ Failed to add feature: ${result.message}`);
712
+ process.exit(1);
713
+ }
714
+ } catch (error) {
715
+ __agiflowai_aicode_utils.messages.error(`❌ Error adding feature: ${error.message}`);
716
+ process.exit(1);
717
+ }
718
+ });
719
+ scaffoldCommand.command("info <featureName>").description("Show detailed information about a scaffold method").option("-p, --project <path>", "Project path").option("-t, --template <name>", "Template name (e.g., nextjs-15, typescript-mcp-package)").action(async (featureName, options) => {
720
+ try {
721
+ if (!options.project && !options.template) {
722
+ __agiflowai_aicode_utils.messages.error("Either --project or --template option must be provided");
723
+ __agiflowai_aicode_utils.messages.hint("Examples:");
724
+ __agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold info scaffold-route --project ./my-app");
725
+ __agiflowai_aicode_utils.print.debug(" scaffold-mcp scaffold info scaffold-route --template nextjs-15");
726
+ process.exit(1);
727
+ }
728
+ const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
729
+ const scaffoldingMethodsService = new require_stdio.ScaffoldingMethodsService(new require_stdio.FileSystemService(), templatesDir);
730
+ let result;
731
+ if (options.project) {
732
+ const projectPath = node_path.default.resolve(options.project);
733
+ if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
734
+ __agiflowai_aicode_utils.messages.error(`No project configuration found in ${projectPath}`);
735
+ __agiflowai_aicode_utils.messages.hint("For monorepo: ensure project.json exists with sourceTemplate field\nFor monolith: ensure toolkit.yaml exists at workspace root\nOr use --template option to view info for a specific template");
736
+ process.exit(1);
737
+ }
738
+ result = await scaffoldingMethodsService.listScaffoldingMethods(projectPath);
739
+ } else result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template);
740
+ const method = result.methods.find((m) => m.name === featureName);
741
+ if (!method) {
742
+ __agiflowai_aicode_utils.messages.error(`❌ Scaffold method '${featureName}' not found.`);
743
+ process.exit(1);
744
+ }
745
+ __agiflowai_aicode_utils.print.header(`\n🔧 Scaffold Method: ${method.name}\n`);
746
+ __agiflowai_aicode_utils.print.debug(`Description: ${method.description}`);
747
+ __agiflowai_aicode_utils.print.header("\n📝 Variables Schema:");
748
+ __agiflowai_aicode_utils.print.debug(JSON.stringify(method.variables_schema, null, 2));
749
+ const includes = "includes" in method ? method.includes : [];
750
+ if (includes && includes.length > 0) {
751
+ __agiflowai_aicode_utils.print.header("\n📁 Files to be created:");
752
+ includes.forEach((include) => {
753
+ const parts = include.split(">>");
754
+ if (parts.length === 2) __agiflowai_aicode_utils.print.debug(` - ${parts[1].trim()}`);
755
+ else __agiflowai_aicode_utils.print.debug(` - ${include}`);
756
+ });
757
+ }
758
+ } catch (error) {
759
+ __agiflowai_aicode_utils.messages.error(`❌ Error getting scaffold info: ${error.message}`);
760
+ process.exit(1);
761
+ }
762
+ });
763
+
764
+ //#endregion
765
+ //#region src/cli.ts
766
+ /**
767
+ * Main entry point
768
+ */
769
+ async function main() {
770
+ const program = new commander.Command();
771
+ program.name("scaffold-mcp").description("MCP server for scaffolding applications with boilerplate templates").version(package_default.version);
772
+ program.addCommand(mcpServeCommand);
773
+ program.addCommand(boilerplateCommand);
774
+ program.addCommand(scaffoldCommand);
775
+ await program.parseAsync(process.argv);
776
+ }
777
+ main();
778
+
779
+ //#endregion