@agiflowai/scaffold-mcp 1.0.27 → 1.2.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.
@@ -1,17 +1,15 @@
1
- const require_ListScaffoldingMethodsTool = require('./ListScaffoldingMethodsTool-DBwZzJTA.cjs');
2
- let __agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
1
+ const require_ListScaffoldingMethodsTool = require("./ListScaffoldingMethodsTool-CYZtpU-W.cjs");
2
+ let _agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
3
3
  let zod = require("zod");
4
4
  let node_path = require("node:path");
5
- node_path = require_ListScaffoldingMethodsTool.__toESM(node_path);
5
+ node_path = require_ListScaffoldingMethodsTool.__toESM(node_path, 1);
6
6
  let js_yaml = require("js-yaml");
7
- js_yaml = require_ListScaffoldingMethodsTool.__toESM(js_yaml);
7
+ js_yaml = require_ListScaffoldingMethodsTool.__toESM(js_yaml, 1);
8
8
  let node_fs = require("node:fs");
9
- let __composio_json_schema_to_zod = require("@composio/json-schema-to-zod");
9
+ let _composio_json_schema_to_zod = require("@composio/json-schema-to-zod");
10
10
  let node_fs_promises = require("node:fs/promises");
11
- node_fs_promises = require_ListScaffoldingMethodsTool.__toESM(node_fs_promises);
12
11
  let node_os = require("node:os");
13
- node_os = require_ListScaffoldingMethodsTool.__toESM(node_os);
14
-
12
+ node_os = require_ListScaffoldingMethodsTool.__toESM(node_os, 1);
15
13
  //#region src/services/BoilerplateGeneratorService.ts
16
14
  /**
17
15
  * Service for generating boilerplate configurations in scaffold.yaml files
@@ -79,11 +77,11 @@ var BoilerplateGeneratorService = class {
79
77
  async generateBoilerplate(options) {
80
78
  const { templateName, boilerplateName, description, instruction, targetFolder, variables, includes = [] } = options;
81
79
  const templatePath = node_path.join(this.templatesPath, templateName);
82
- await (0, __agiflowai_aicode_utils.ensureDir)(templatePath);
80
+ await (0, _agiflowai_aicode_utils.ensureDir)(templatePath);
83
81
  const scaffoldYamlPath = node_path.join(templatePath, "scaffold.yaml");
84
82
  let scaffoldConfig = {};
85
- if (await (0, __agiflowai_aicode_utils.pathExists)(scaffoldYamlPath)) {
86
- const yamlContent = await (0, __agiflowai_aicode_utils.readFile)(scaffoldYamlPath, "utf-8");
83
+ if (await (0, _agiflowai_aicode_utils.pathExists)(scaffoldYamlPath)) {
84
+ const yamlContent = await (0, _agiflowai_aicode_utils.readFile)(scaffoldYamlPath, "utf-8");
87
85
  scaffoldConfig = js_yaml.load(yamlContent);
88
86
  }
89
87
  if (!scaffoldConfig.boilerplate) scaffoldConfig.boilerplate = [];
@@ -113,7 +111,7 @@ var BoilerplateGeneratorService = class {
113
111
  };
114
112
  if (instruction) boilerplateDefinition.instruction = instruction;
115
113
  scaffoldConfig.boilerplate.push(boilerplateDefinition);
116
- await (0, __agiflowai_aicode_utils.writeFile)(scaffoldYamlPath, this.dumpYamlWithLiteralBlocks(scaffoldConfig), "utf-8");
114
+ await (0, _agiflowai_aicode_utils.writeFile)(scaffoldYamlPath, this.dumpYamlWithLiteralBlocks(scaffoldConfig), "utf-8");
117
115
  return {
118
116
  success: true,
119
117
  message: `Boilerplate '${boilerplateName}' added to ${scaffoldYamlPath}`,
@@ -125,13 +123,13 @@ var BoilerplateGeneratorService = class {
125
123
  * List all templates (directories in templates folder)
126
124
  */
127
125
  async listTemplates() {
128
- return (await (0, __agiflowai_aicode_utils.readdir)(this.templatesPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
126
+ return (await (0, _agiflowai_aicode_utils.readdir)(this.templatesPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
129
127
  }
130
128
  /**
131
129
  * Check if a template exists
132
130
  */
133
131
  async templateExists(templateName) {
134
- return (0, __agiflowai_aicode_utils.pathExists)(node_path.join(this.templatesPath, templateName));
132
+ return (0, _agiflowai_aicode_utils.pathExists)(node_path.join(this.templatesPath, templateName));
135
133
  }
136
134
  /**
137
135
  * Create or update a template file for a boilerplate
@@ -139,17 +137,17 @@ var BoilerplateGeneratorService = class {
139
137
  async createTemplateFile(options) {
140
138
  const { templateName, filePath, content, sourceFile, header } = options;
141
139
  const templatePath = node_path.join(this.templatesPath, templateName);
142
- if (!await (0, __agiflowai_aicode_utils.pathExists)(templatePath)) return {
140
+ if (!await (0, _agiflowai_aicode_utils.pathExists)(templatePath)) return {
143
141
  success: false,
144
142
  message: `Template directory '${templateName}' does not exist at ${templatePath}`
145
143
  };
146
144
  let fileContent = content || "";
147
145
  if (sourceFile) {
148
- if (!await (0, __agiflowai_aicode_utils.pathExists)(sourceFile)) return {
146
+ if (!await (0, _agiflowai_aicode_utils.pathExists)(sourceFile)) return {
149
147
  success: false,
150
148
  message: `Source file '${sourceFile}' does not exist`
151
149
  };
152
- fileContent = await (0, __agiflowai_aicode_utils.readFile)(sourceFile, "utf-8");
150
+ fileContent = await (0, _agiflowai_aicode_utils.readFile)(sourceFile, "utf-8");
153
151
  }
154
152
  if (!fileContent && !sourceFile) return {
155
153
  success: false,
@@ -157,10 +155,10 @@ var BoilerplateGeneratorService = class {
157
155
  };
158
156
  const templateFilePath = filePath.endsWith(".liquid") ? filePath : `${filePath}.liquid`;
159
157
  const fullPath = node_path.join(templatePath, templateFilePath);
160
- await (0, __agiflowai_aicode_utils.ensureDir)(node_path.dirname(fullPath));
158
+ await (0, _agiflowai_aicode_utils.ensureDir)(node_path.dirname(fullPath));
161
159
  let finalContent = fileContent;
162
160
  if (header) finalContent = `${header}\n\n${fileContent}`;
163
- await (0, __agiflowai_aicode_utils.writeFile)(fullPath, finalContent, "utf-8");
161
+ await (0, _agiflowai_aicode_utils.writeFile)(fullPath, finalContent, "utf-8");
164
162
  return {
165
163
  success: true,
166
164
  message: "Template file created successfully",
@@ -169,7 +167,6 @@ var BoilerplateGeneratorService = class {
169
167
  };
170
168
  }
171
169
  };
172
-
173
170
  //#endregion
174
171
  //#region src/services/BoilerplateService.ts
175
172
  var BoilerplateService = class {
@@ -191,12 +188,12 @@ var BoilerplateService = class {
191
188
  const templateDirs = await this.discoverTemplateDirectories();
192
189
  for (const templatePath of templateDirs) {
193
190
  const scaffoldYamlPath = node_path.join(this.templatesPath, templatePath, "scaffold.yaml");
194
- if ((0, __agiflowai_aicode_utils.pathExistsSync)(scaffoldYamlPath)) try {
195
- const scaffoldContent = (0, __agiflowai_aicode_utils.readFileSync)(scaffoldYamlPath, "utf8");
191
+ if ((0, _agiflowai_aicode_utils.pathExistsSync)(scaffoldYamlPath)) try {
192
+ const scaffoldContent = (0, _agiflowai_aicode_utils.readFileSync)(scaffoldYamlPath, "utf8");
196
193
  const scaffoldConfig = js_yaml.load(scaffoldContent);
197
194
  if (scaffoldConfig.boilerplate) for (const boilerplate of scaffoldConfig.boilerplate) {
198
195
  if (!boilerplate.targetFolder) {
199
- __agiflowai_aicode_utils.log.warn(`Skipping boilerplate '${boilerplate.name}' in ${templatePath}: targetFolder is required in scaffold.yaml`);
196
+ _agiflowai_aicode_utils.log.warn(`Skipping boilerplate '${boilerplate.name}' in ${templatePath}: targetFolder is required in scaffold.yaml`);
200
197
  continue;
201
198
  }
202
199
  boilerplates.push({
@@ -210,7 +207,7 @@ var BoilerplateService = class {
210
207
  });
211
208
  }
212
209
  } catch (error) {
213
- __agiflowai_aicode_utils.log.warn(`Failed to load scaffold.yaml for ${templatePath}:`, error);
210
+ _agiflowai_aicode_utils.log.warn(`Failed to load scaffold.yaml for ${templatePath}:`, error);
214
211
  }
215
212
  }
216
213
  return boilerplates;
@@ -236,14 +233,14 @@ var BoilerplateService = class {
236
233
  async discoverTemplateDirectories() {
237
234
  const templateDirs = [];
238
235
  const findTemplates = (dir, baseDir = "") => {
239
- if (!(0, __agiflowai_aicode_utils.pathExistsSync)(dir)) return;
236
+ if (!(0, _agiflowai_aicode_utils.pathExistsSync)(dir)) return;
240
237
  const items = (0, node_fs.readdirSync)(dir);
241
238
  const hasPackageJson = items.includes("package.json") || items.includes("package.json.liquid");
242
239
  const hasScaffoldYaml = items.includes("scaffold.yaml");
243
240
  if (hasPackageJson && hasScaffoldYaml) templateDirs.push(baseDir);
244
241
  for (const item of items) {
245
242
  const itemPath = node_path.join(dir, item);
246
- if ((0, __agiflowai_aicode_utils.statSync)(itemPath).isDirectory() && !item.startsWith(".") && item !== "node_modules") findTemplates(itemPath, baseDir ? node_path.join(baseDir, item) : item);
243
+ if ((0, _agiflowai_aicode_utils.statSync)(itemPath).isDirectory() && !item.startsWith(".") && item !== "node_modules") findTemplates(itemPath, baseDir ? node_path.join(baseDir, item) : item);
247
244
  }
248
245
  };
249
246
  findTemplates(this.templatesPath);
@@ -256,18 +253,18 @@ var BoilerplateService = class {
256
253
  let { boilerplateName, variables, monolith, targetFolderOverride } = request;
257
254
  let projectConfig = null;
258
255
  if (monolith === void 0 || monolith && !boilerplateName) try {
259
- projectConfig = await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd());
256
+ projectConfig = await _agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd());
260
257
  } catch (_error) {}
261
258
  if (monolith === void 0) if (projectConfig) {
262
259
  monolith = projectConfig.type === "monolith";
263
- __agiflowai_aicode_utils.log.info(`Auto-detected project type: ${projectConfig.type}`);
260
+ _agiflowai_aicode_utils.log.info(`Auto-detected project type: ${projectConfig.type}`);
264
261
  } else {
265
262
  monolith = false;
266
- __agiflowai_aicode_utils.log.info("No project configuration found, defaulting to monorepo mode");
263
+ _agiflowai_aicode_utils.log.info("No project configuration found, defaulting to monorepo mode");
267
264
  }
268
265
  if (monolith && !boilerplateName) if (projectConfig) {
269
266
  boilerplateName = projectConfig.sourceTemplate;
270
- __agiflowai_aicode_utils.log.info(`Using boilerplate from toolkit.yaml: ${boilerplateName}`);
267
+ _agiflowai_aicode_utils.log.info(`Using boilerplate from toolkit.yaml: ${boilerplateName}`);
271
268
  } else return {
272
269
  success: false,
273
270
  message: "Failed to read boilerplate name from toolkit.yaml: No project configuration found"
@@ -312,10 +309,10 @@ var BoilerplateService = class {
312
309
  marker: request.marker
313
310
  });
314
311
  if (!result.success) return result;
315
- if (monolith) await __agiflowai_aicode_utils.ProjectConfigResolver.createToolkitYaml(boilerplate.template_path);
312
+ if (monolith) await _agiflowai_aicode_utils.ProjectConfigResolver.createToolkitYaml(boilerplate.template_path);
316
313
  else {
317
314
  const projectPath = node_path.join(targetFolder, folderName);
318
- await __agiflowai_aicode_utils.ProjectConfigResolver.createProjectJson(projectPath, folderName, boilerplate.template_path);
315
+ await _agiflowai_aicode_utils.ProjectConfigResolver.createProjectJson(projectPath, folderName, boilerplate.template_path);
319
316
  }
320
317
  const processedInstruction = boilerplate.instruction ? this.processBoilerplateInstruction(boilerplate.instruction, variables) : "";
321
318
  let enhancedMessage = result.message;
@@ -359,14 +356,14 @@ var BoilerplateService = class {
359
356
  validateBoilerplateVariables(boilerplate, variables) {
360
357
  const errors = [];
361
358
  try {
362
- (0, __composio_json_schema_to_zod.jsonSchemaToZod)(boilerplate.variables_schema).parse(variables);
359
+ (0, _composio_json_schema_to_zod.jsonSchemaToZod)(boilerplate.variables_schema).parse(variables);
363
360
  return {
364
361
  isValid: true,
365
362
  errors: []
366
363
  };
367
364
  } catch (error) {
368
365
  if (error instanceof zod.z.ZodError) {
369
- const zodErrors = error.errors.map((err) => {
366
+ const zodErrors = error.issues.map((err) => {
370
367
  return `${err.path.length > 0 ? err.path.join(".") : "root"}: ${err.message}`;
371
368
  });
372
369
  errors.push(...zodErrors);
@@ -378,7 +375,6 @@ var BoilerplateService = class {
378
375
  }
379
376
  }
380
377
  };
381
-
382
378
  //#endregion
383
379
  //#region src/services/ScaffoldGeneratorService.ts
384
380
  /**
@@ -447,11 +443,11 @@ var ScaffoldGeneratorService = class {
447
443
  async generateFeatureScaffold(options) {
448
444
  const { templateName, featureName, description, instruction, variables, includes = [], patterns = [] } = options;
449
445
  const templatePath = node_path.join(this.templatesPath, templateName);
450
- await (0, __agiflowai_aicode_utils.ensureDir)(templatePath);
446
+ await (0, _agiflowai_aicode_utils.ensureDir)(templatePath);
451
447
  const scaffoldYamlPath = node_path.join(templatePath, "scaffold.yaml");
452
448
  let scaffoldConfig = {};
453
- if (await (0, __agiflowai_aicode_utils.pathExists)(scaffoldYamlPath)) {
454
- const yamlContent = await (0, __agiflowai_aicode_utils.readFile)(scaffoldYamlPath, "utf-8");
449
+ if (await (0, _agiflowai_aicode_utils.pathExists)(scaffoldYamlPath)) {
450
+ const yamlContent = await (0, _agiflowai_aicode_utils.readFile)(scaffoldYamlPath, "utf-8");
455
451
  scaffoldConfig = js_yaml.load(yamlContent);
456
452
  }
457
453
  if (!scaffoldConfig.features) scaffoldConfig.features = [];
@@ -481,7 +477,7 @@ var ScaffoldGeneratorService = class {
481
477
  if (instruction) featureDefinition.instruction = instruction;
482
478
  if (patterns && patterns.length > 0) featureDefinition.patterns = patterns;
483
479
  scaffoldConfig.features.push(featureDefinition);
484
- await (0, __agiflowai_aicode_utils.writeFile)(scaffoldYamlPath, this.dumpYamlWithLiteralBlocks(scaffoldConfig), "utf-8");
480
+ await (0, _agiflowai_aicode_utils.writeFile)(scaffoldYamlPath, this.dumpYamlWithLiteralBlocks(scaffoldConfig), "utf-8");
485
481
  return {
486
482
  success: true,
487
483
  message: `Feature '${featureName}' added to ${scaffoldYamlPath}`,
@@ -493,16 +489,15 @@ var ScaffoldGeneratorService = class {
493
489
  * List all templates (directories in templates folder)
494
490
  */
495
491
  async listTemplates() {
496
- return (await (0, __agiflowai_aicode_utils.readdir)(this.templatesPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
492
+ return (await (0, _agiflowai_aicode_utils.readdir)(this.templatesPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
497
493
  }
498
494
  /**
499
495
  * Check if a template exists
500
496
  */
501
497
  async templateExists(templateName) {
502
- return (0, __agiflowai_aicode_utils.pathExists)(node_path.join(this.templatesPath, templateName));
498
+ return (0, _agiflowai_aicode_utils.pathExists)(node_path.join(this.templatesPath, templateName));
503
499
  }
504
500
  };
505
-
506
501
  //#endregion
507
502
  //#region src/tools/GenerateBoilerplateFileTool.ts
508
503
  /**
@@ -664,7 +659,7 @@ Use this after generate-boilerplate or generate-feature-scaffold to create the a
664
659
  try {
665
660
  let { templateName } = args;
666
661
  if (this.isMonolith && !templateName) try {
667
- templateName = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
662
+ templateName = (await _agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
668
663
  } catch (error) {
669
664
  return {
670
665
  content: [{
@@ -713,7 +708,6 @@ Use this after generate-boilerplate or generate-feature-scaffold to create the a
713
708
  }
714
709
  }
715
710
  };
716
-
717
711
  //#endregion
718
712
  //#region src/tools/GenerateBoilerplateTool.ts
719
713
  /**
@@ -897,7 +891,7 @@ Use this to add custom boilerplate configurations for frameworks not yet support
897
891
  try {
898
892
  let { templateName, targetFolder } = args;
899
893
  if (this.isMonolith && !templateName) try {
900
- templateName = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
894
+ templateName = (await _agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
901
895
  } catch (error) {
902
896
  return {
903
897
  content: [{
@@ -959,7 +953,6 @@ Use this to add custom boilerplate configurations for frameworks not yet support
959
953
  }
960
954
  }
961
955
  };
962
-
963
956
  //#endregion
964
957
  //#region src/tools/GenerateFeatureScaffoldTool.ts
965
958
  /**
@@ -1124,7 +1117,7 @@ Use this to add custom feature scaffolds (pages, components, services, etc.) for
1124
1117
  try {
1125
1118
  let { templateName } = args;
1126
1119
  if (this.isMonolith && !templateName) try {
1127
- templateName = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
1120
+ templateName = (await _agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
1128
1121
  } catch (error) {
1129
1122
  return {
1130
1123
  content: [{
@@ -1178,11 +1171,9 @@ Use this to add custom feature scaffolds (pages, components, services, etc.) for
1178
1171
  }
1179
1172
  }
1180
1173
  };
1181
-
1182
1174
  //#endregion
1183
1175
  //#region src/instructions/tools/list-boilerplates/description.md?raw
1184
1176
  var description_default$1 = "{% if isMonolith %}\nNot available for monolith projects. Monolith uses a single template defined in `.toolkit/settings.yaml`.\n\nUse `list-scaffolding-methods` for available features instead.\n{% else %}\nLists all available project boilerplates for creating new applications, APIs, or packages in the monorepo.\n\nEach boilerplate includes:\n- Complete project template with starter files\n- Variable schema for customization\n- Target directory information (e.g., apps/, packages/)\n- Required and optional configuration options\n\nUse this FIRST when creating new projects to understand available templates and their requirements.\n{% endif %}\n";
1185
-
1186
1177
  //#endregion
1187
1178
  //#region src/tools/ListBoilerplatesTool.ts
1188
1179
  var ListBoilerplatesTool = class ListBoilerplatesTool {
@@ -1235,11 +1226,9 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
1235
1226
  }
1236
1227
  }
1237
1228
  };
1238
-
1239
1229
  //#endregion
1240
1230
  //#region src/instructions/tools/use-boilerplate/description.md?raw
1241
1231
  var description_default = "{% if isMonolith %}\nThis tool is not available for monolith projects.\n\nMonolith projects use a single template specified in `.toolkit/settings.yaml` (`sourceTemplate`). The template cannot be changed through this tool - it's determined by the workspace configuration.\n\nUse `list-scaffolding-methods` and `use-scaffold-method` to add features to your monolith project instead.\n{% else %}\nCreates a new project from a boilerplate template with the specified variables.\n\n**For Monorepo Projects Only:**\nThis tool creates new sub-projects (apps, packages) in your monorepo. Each project can use a different template.\n\nThis tool will:\n- Generate all necessary files from the selected boilerplate template\n- Replace template variables with provided values\n- Create the project in targetFolder/projectName (e.g., apps/my-new-app)\n- Set up initial configuration files (package.json, tsconfig.json, etc.)\n- Create project.json with sourceTemplate reference\n\nIMPORTANT:\n- Always call `list-boilerplates` first to get the exact variable schema\n- Follow the schema exactly - required fields must be provided\n- Use kebab-case for project names (e.g., \"my-new-app\", not \"MyNewApp\")\n- The tool will validate all variables against the schema before proceeding\n- Each new project can use a different boilerplate template\n{% endif %}\n";
1242
-
1243
1232
  //#endregion
1244
1233
  //#region src/tools/UseBoilerplateTool.ts
1245
1234
  var UseBoilerplateTool = class UseBoilerplateTool {
@@ -1323,12 +1312,28 @@ The boilerplate provides a starting point - you may need to add features or cust
1323
1312
  }
1324
1313
  }
1325
1314
  };
1326
-
1315
+ //#endregion
1316
+ //#region src/utils/scaffoldPendingLog.ts
1317
+ async function writePendingScaffoldLog(config) {
1318
+ const { scaffoldId, projectPath, featureName, generatedFiles } = config;
1319
+ try {
1320
+ const logEntry = {
1321
+ timestamp: Date.now(),
1322
+ scaffoldId,
1323
+ projectPath,
1324
+ featureName,
1325
+ generatedFiles,
1326
+ operation: "scaffold"
1327
+ };
1328
+ await (0, node_fs_promises.appendFile)(node_path.join(node_os.tmpdir(), `scaffold-mcp-pending-${scaffoldId}.jsonl`), `${JSON.stringify(logEntry)}\n`, "utf-8");
1329
+ } catch (error) {
1330
+ console.error("Failed to write pending scaffold log:", error);
1331
+ }
1332
+ }
1327
1333
  //#endregion
1328
1334
  //#region src/tools/UseScaffoldMethodTool.ts
1329
1335
  var UseScaffoldMethodTool = class UseScaffoldMethodTool {
1330
1336
  static TOOL_NAME = "use-scaffold-method";
1331
- static TEMP_LOG_DIR = node_os.tmpdir();
1332
1337
  fileSystemService;
1333
1338
  scaffoldingMethodsService;
1334
1339
  isMonolith;
@@ -1338,25 +1343,6 @@ var UseScaffoldMethodTool = class UseScaffoldMethodTool {
1338
1343
  this.isMonolith = isMonolith;
1339
1344
  }
1340
1345
  /**
1341
- * Write scaffold execution info to temp log file for hook processing
1342
- */
1343
- async writePendingScaffoldLog(scaffoldId, projectPath, featureName, generatedFiles) {
1344
- try {
1345
- const logEntry = {
1346
- timestamp: Date.now(),
1347
- scaffoldId,
1348
- projectPath,
1349
- featureName,
1350
- generatedFiles,
1351
- operation: "scaffold"
1352
- };
1353
- const tempLogFile = node_path.join(UseScaffoldMethodTool.TEMP_LOG_DIR, `scaffold-mcp-pending-${scaffoldId}.jsonl`);
1354
- await node_fs_promises.appendFile(tempLogFile, `${JSON.stringify(logEntry)}\n`, "utf-8");
1355
- } catch (error) {
1356
- console.error("Failed to write pending scaffold log:", error);
1357
- }
1358
- }
1359
- /**
1360
1346
  * Get the tool definition for MCP
1361
1347
  */
1362
1348
  getDefinition() {
@@ -1420,8 +1406,13 @@ IMPORTANT:
1420
1406
  variables,
1421
1407
  marker
1422
1408
  });
1423
- const scaffoldId = (0, __agiflowai_aicode_utils.generateStableId)(6);
1424
- if (result.createdFiles && result.createdFiles.length > 0) await this.writePendingScaffoldLog(scaffoldId, resolvedProjectPath, scaffold_feature_name, result.createdFiles);
1409
+ const scaffoldId = (0, _agiflowai_aicode_utils.generateStableId)(6);
1410
+ if (result.createdFiles && result.createdFiles.length > 0) await writePendingScaffoldLog({
1411
+ scaffoldId,
1412
+ projectPath: resolvedProjectPath,
1413
+ featureName: scaffold_feature_name,
1414
+ generatedFiles: result.createdFiles
1415
+ });
1425
1416
  return { content: [{
1426
1417
  type: "text",
1427
1418
  text: `${result.message}
@@ -1449,7 +1440,6 @@ Do not skip the implementation step - the scaffolded files contain templates tha
1449
1440
  }
1450
1441
  }
1451
1442
  };
1452
-
1453
1443
  //#endregion
1454
1444
  //#region src/tools/WriteToFileTool.ts
1455
1445
  var WriteToFileTool = class WriteToFileTool {
@@ -1458,6 +1448,13 @@ var WriteToFileTool = class WriteToFileTool {
1458
1448
  constructor() {
1459
1449
  this.fileSystemService = new require_ListScaffoldingMethodsTool.FileSystemService();
1460
1450
  }
1451
+ resolveWorkspaceFilePath(filePath) {
1452
+ const workspaceRoot = node_path.default.resolve(process.cwd());
1453
+ const resolvedPath = node_path.default.resolve(workspaceRoot, filePath);
1454
+ const relativeToWorkspace = node_path.default.relative(workspaceRoot, resolvedPath);
1455
+ if (!(!relativeToWorkspace.startsWith(`..${node_path.default.sep}`) && relativeToWorkspace !== ".." && !node_path.default.isAbsolute(relativeToWorkspace))) throw new Error(`Path "${filePath}" is outside the workspace directory`);
1456
+ return resolvedPath;
1457
+ }
1461
1458
  /**
1462
1459
  * Get the tool definition for MCP
1463
1460
  */
@@ -1473,14 +1470,14 @@ This tool will:
1473
1470
  - Overwrite existing files with new content
1474
1471
 
1475
1472
  Parameters:
1476
- - file_path: Absolute or relative path to the target file
1473
+ - file_path: Absolute or relative path to a file inside the current workspace
1477
1474
  - content: The content to write to the file`,
1478
1475
  inputSchema: {
1479
1476
  type: "object",
1480
1477
  properties: {
1481
1478
  file_path: {
1482
1479
  type: "string",
1483
- description: "Path to the file to write (absolute or relative to current working directory)"
1480
+ description: "Path to the file to write within the current workspace directory"
1484
1481
  },
1485
1482
  content: {
1486
1483
  type: "string",
@@ -1500,7 +1497,7 @@ Parameters:
1500
1497
  const { file_path, content } = args;
1501
1498
  if (!file_path) throw new Error("Missing required parameter: file_path");
1502
1499
  if (content === void 0 || content === null) throw new Error("Missing required parameter: content");
1503
- const resolvedPath = node_path.default.isAbsolute(file_path) ? file_path : node_path.default.resolve(process.cwd(), file_path);
1500
+ const resolvedPath = this.resolveWorkspaceFilePath(file_path);
1504
1501
  const dirPath = node_path.default.dirname(resolvedPath);
1505
1502
  await this.fileSystemService.ensureDir(dirPath);
1506
1503
  await this.fileSystemService.writeFile(resolvedPath, content);
@@ -1519,65 +1516,70 @@ Parameters:
1519
1516
  }
1520
1517
  }
1521
1518
  };
1522
-
1523
1519
  //#endregion
1524
- Object.defineProperty(exports, 'BoilerplateGeneratorService', {
1525
- enumerable: true,
1526
- get: function () {
1527
- return BoilerplateGeneratorService;
1528
- }
1520
+ Object.defineProperty(exports, "BoilerplateGeneratorService", {
1521
+ enumerable: true,
1522
+ get: function() {
1523
+ return BoilerplateGeneratorService;
1524
+ }
1529
1525
  });
1530
- Object.defineProperty(exports, 'BoilerplateService', {
1531
- enumerable: true,
1532
- get: function () {
1533
- return BoilerplateService;
1534
- }
1526
+ Object.defineProperty(exports, "BoilerplateService", {
1527
+ enumerable: true,
1528
+ get: function() {
1529
+ return BoilerplateService;
1530
+ }
1535
1531
  });
1536
- Object.defineProperty(exports, 'GenerateBoilerplateFileTool', {
1537
- enumerable: true,
1538
- get: function () {
1539
- return GenerateBoilerplateFileTool;
1540
- }
1532
+ Object.defineProperty(exports, "GenerateBoilerplateFileTool", {
1533
+ enumerable: true,
1534
+ get: function() {
1535
+ return GenerateBoilerplateFileTool;
1536
+ }
1541
1537
  });
1542
- Object.defineProperty(exports, 'GenerateBoilerplateTool', {
1543
- enumerable: true,
1544
- get: function () {
1545
- return GenerateBoilerplateTool;
1546
- }
1538
+ Object.defineProperty(exports, "GenerateBoilerplateTool", {
1539
+ enumerable: true,
1540
+ get: function() {
1541
+ return GenerateBoilerplateTool;
1542
+ }
1547
1543
  });
1548
- Object.defineProperty(exports, 'GenerateFeatureScaffoldTool', {
1549
- enumerable: true,
1550
- get: function () {
1551
- return GenerateFeatureScaffoldTool;
1552
- }
1544
+ Object.defineProperty(exports, "GenerateFeatureScaffoldTool", {
1545
+ enumerable: true,
1546
+ get: function() {
1547
+ return GenerateFeatureScaffoldTool;
1548
+ }
1553
1549
  });
1554
- Object.defineProperty(exports, 'ListBoilerplatesTool', {
1555
- enumerable: true,
1556
- get: function () {
1557
- return ListBoilerplatesTool;
1558
- }
1550
+ Object.defineProperty(exports, "ListBoilerplatesTool", {
1551
+ enumerable: true,
1552
+ get: function() {
1553
+ return ListBoilerplatesTool;
1554
+ }
1559
1555
  });
1560
- Object.defineProperty(exports, 'ScaffoldGeneratorService', {
1561
- enumerable: true,
1562
- get: function () {
1563
- return ScaffoldGeneratorService;
1564
- }
1556
+ Object.defineProperty(exports, "ScaffoldGeneratorService", {
1557
+ enumerable: true,
1558
+ get: function() {
1559
+ return ScaffoldGeneratorService;
1560
+ }
1565
1561
  });
1566
- Object.defineProperty(exports, 'UseBoilerplateTool', {
1567
- enumerable: true,
1568
- get: function () {
1569
- return UseBoilerplateTool;
1570
- }
1562
+ Object.defineProperty(exports, "UseBoilerplateTool", {
1563
+ enumerable: true,
1564
+ get: function() {
1565
+ return UseBoilerplateTool;
1566
+ }
1571
1567
  });
1572
- Object.defineProperty(exports, 'UseScaffoldMethodTool', {
1573
- enumerable: true,
1574
- get: function () {
1575
- return UseScaffoldMethodTool;
1576
- }
1568
+ Object.defineProperty(exports, "UseScaffoldMethodTool", {
1569
+ enumerable: true,
1570
+ get: function() {
1571
+ return UseScaffoldMethodTool;
1572
+ }
1573
+ });
1574
+ Object.defineProperty(exports, "WriteToFileTool", {
1575
+ enumerable: true,
1576
+ get: function() {
1577
+ return WriteToFileTool;
1578
+ }
1579
+ });
1580
+ Object.defineProperty(exports, "writePendingScaffoldLog", {
1581
+ enumerable: true,
1582
+ get: function() {
1583
+ return writePendingScaffoldLog;
1584
+ }
1577
1585
  });
1578
- Object.defineProperty(exports, 'WriteToFileTool', {
1579
- enumerable: true,
1580
- get: function () {
1581
- return WriteToFileTool;
1582
- }
1583
- });