@agiflowai/scaffold-mcp 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/dist/ListScaffoldingMethodsTool-BLTCwsd1.mjs +350 -0
- package/dist/ListScaffoldingMethodsTool-BuxKRbwi.cjs +376 -0
- package/dist/{ScaffoldConfigLoader-B-NLy6VP.cjs → ScaffoldConfigLoader-BB4_YUFL.cjs} +1 -1
- package/dist/{ScaffoldConfigLoader-SHk-KEje.mjs → ScaffoldConfigLoader-DKJtnrWT.mjs} +1 -1
- package/dist/ScaffoldService-BCjJE9yK.mjs +3 -0
- package/dist/ScaffoldService-Bhzxp5-C.cjs +3 -0
- package/dist/TemplateService-B1bd6iHw.mjs +3 -0
- package/dist/TemplateService-BrJGDvQt.cjs +3 -0
- package/dist/VariableReplacementService-BO-UYgcf.mjs +3 -0
- package/dist/{VariableReplacementService-DKaF2C9l.cjs → VariableReplacementService-CNimgwaq.cjs} +1 -1
- package/dist/cli.cjs +89 -11
- package/dist/cli.mjs +84 -6
- package/dist/index.cjs +9 -8
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +6 -5
- package/dist/{stdio-BGj_FLky.cjs → stdio-BcTSxlVH.cjs} +47 -367
- package/dist/{stdio-wAlpLC6l.mjs → stdio-DovjJsGY.mjs} +42 -347
- package/dist/useScaffoldMethod-Btc_9iCj.cjs +237 -0
- package/dist/useScaffoldMethod-C1hQdBVD.cjs +267 -0
- package/dist/useScaffoldMethod-CHJAsgA2.mjs +236 -0
- package/dist/useScaffoldMethod-CsBTssSw.mjs +263 -0
- package/package.json +6 -2
- package/dist/ScaffoldService-BNOyoqSb.cjs +0 -3
- package/dist/ScaffoldService-BNdfC21Z.mjs +0 -3
- package/dist/TemplateService-BRfzfaZs.mjs +0 -3
- package/dist/TemplateService-DqieT1Tq.cjs +0 -3
- package/dist/VariableReplacementService-BWCd-z7X.mjs +0 -3
- /package/dist/{ScaffoldConfigLoader-BDMJNI1o.mjs → ScaffoldConfigLoader-8YI7v2GJ.mjs} +0 -0
- /package/dist/{ScaffoldConfigLoader-Y_SBLPg7.cjs → ScaffoldConfigLoader-CQlXVksz.cjs} +0 -0
- /package/dist/{ScaffoldService-ChzxM0Yc.cjs → ScaffoldService-BPyiY_0B.cjs} +0 -0
- /package/dist/{ScaffoldService-BNuN00Fm.mjs → ScaffoldService-CgYunbKN.mjs} +0 -0
- /package/dist/{TemplateService-D3ydJR_R.cjs → TemplateService-CAD8jkoO.cjs} +0 -0
- /package/dist/{TemplateService-Cg5QV29n.mjs → TemplateService-CVDL2uqt.mjs} +0 -0
- /package/dist/{VariableReplacementService-DHIINRnJ.mjs → VariableReplacementService-B9RA8D0a.mjs} +0 -0
- /package/dist/{VariableReplacementService-CAjesAYq.cjs → VariableReplacementService-DDG5KZpb.cjs} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const require_ListScaffoldingMethodsTool = require('./ListScaffoldingMethodsTool-BuxKRbwi.cjs');
|
|
3
|
+
const require_ScaffoldConfigLoader = require('./ScaffoldConfigLoader-CQlXVksz.cjs');
|
|
4
|
+
const require_ScaffoldService = require('./ScaffoldService-BPyiY_0B.cjs');
|
|
5
|
+
const require_TemplateService = require('./TemplateService-CAD8jkoO.cjs');
|
|
6
|
+
const require_VariableReplacementService = require('./VariableReplacementService-DDG5KZpb.cjs');
|
|
6
7
|
let node_path = require("node:path");
|
|
7
8
|
node_path = require_chunk.__toESM(node_path);
|
|
8
9
|
let __agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
|
|
@@ -11,6 +12,10 @@ js_yaml = require_chunk.__toESM(js_yaml);
|
|
|
11
12
|
let node_fs = require("node:fs");
|
|
12
13
|
let __composio_json_schema_to_zod = require("@composio/json-schema-to-zod");
|
|
13
14
|
let zod = require("zod");
|
|
15
|
+
let node_fs_promises = require("node:fs/promises");
|
|
16
|
+
node_fs_promises = require_chunk.__toESM(node_fs_promises);
|
|
17
|
+
let node_os = require("node:os");
|
|
18
|
+
node_os = require_chunk.__toESM(node_os);
|
|
14
19
|
let node_crypto = require("node:crypto");
|
|
15
20
|
let __modelcontextprotocol_sdk_server_streamableHttp_js = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
16
21
|
let __modelcontextprotocol_sdk_types_js = require("@modelcontextprotocol/sdk/types.js");
|
|
@@ -177,85 +182,6 @@ var BoilerplateGeneratorService = class {
|
|
|
177
182
|
}
|
|
178
183
|
};
|
|
179
184
|
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/utils/pagination.ts
|
|
182
|
-
var PaginationHelper = class PaginationHelper {
|
|
183
|
-
/**
|
|
184
|
-
* Default page size for pagination
|
|
185
|
-
*/
|
|
186
|
-
static DEFAULT_PAGE_SIZE = 10;
|
|
187
|
-
/**
|
|
188
|
-
* Decodes a cursor string to extract the start index
|
|
189
|
-
* @param cursor - String representing the start index (e.g., "10")
|
|
190
|
-
* @returns Start index or 0 if invalid/undefined
|
|
191
|
-
*/
|
|
192
|
-
static decodeCursor(cursor) {
|
|
193
|
-
if (!cursor) return 0;
|
|
194
|
-
const index = Number.parseInt(cursor, 10);
|
|
195
|
-
if (Number.isNaN(index) || index < 0) return 0;
|
|
196
|
-
return index;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Encodes an index into a cursor string
|
|
200
|
-
* @param index - Start index to encode
|
|
201
|
-
* @returns Cursor string (e.g., "10")
|
|
202
|
-
*/
|
|
203
|
-
static encodeCursor(index) {
|
|
204
|
-
return index.toString();
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Paginates an array of items
|
|
208
|
-
* @param items - All items to paginate
|
|
209
|
-
* @param cursor - Optional cursor representing the start index
|
|
210
|
-
* @param pageSize - Number of items per page (default: 10)
|
|
211
|
-
* @param includeMeta - Whether to include metadata in response (default: true)
|
|
212
|
-
* @returns Paginated result with items and optional nextCursor
|
|
213
|
-
*/
|
|
214
|
-
static paginate(items, cursor, pageSize = PaginationHelper.DEFAULT_PAGE_SIZE, includeMeta = true) {
|
|
215
|
-
const startIndex = PaginationHelper.decodeCursor(cursor);
|
|
216
|
-
const endIndex = startIndex + pageSize;
|
|
217
|
-
const result = {
|
|
218
|
-
items: items.slice(startIndex, endIndex),
|
|
219
|
-
nextCursor: endIndex < items.length ? PaginationHelper.encodeCursor(endIndex) : void 0
|
|
220
|
-
};
|
|
221
|
-
if (includeMeta) result._meta = {
|
|
222
|
-
total: items.length,
|
|
223
|
-
offset: startIndex,
|
|
224
|
-
limit: pageSize
|
|
225
|
-
};
|
|
226
|
-
return result;
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/services/FileSystemService.ts
|
|
232
|
-
var FileSystemService = class {
|
|
233
|
-
async pathExists(path$2) {
|
|
234
|
-
return (0, __agiflowai_aicode_utils.pathExists)(path$2);
|
|
235
|
-
}
|
|
236
|
-
async readFile(path$2, encoding = "utf8") {
|
|
237
|
-
return (0, __agiflowai_aicode_utils.readFile)(path$2, encoding);
|
|
238
|
-
}
|
|
239
|
-
async readJson(path$2) {
|
|
240
|
-
return (0, __agiflowai_aicode_utils.readJson)(path$2);
|
|
241
|
-
}
|
|
242
|
-
async writeFile(path$2, content, encoding = "utf8") {
|
|
243
|
-
return (0, __agiflowai_aicode_utils.writeFile)(path$2, content, encoding);
|
|
244
|
-
}
|
|
245
|
-
async ensureDir(path$2) {
|
|
246
|
-
return (0, __agiflowai_aicode_utils.ensureDir)(path$2);
|
|
247
|
-
}
|
|
248
|
-
async copy(src, dest) {
|
|
249
|
-
return (0, __agiflowai_aicode_utils.copy)(src, dest);
|
|
250
|
-
}
|
|
251
|
-
async readdir(path$2) {
|
|
252
|
-
return (0, __agiflowai_aicode_utils.readdir)(path$2);
|
|
253
|
-
}
|
|
254
|
-
async stat(path$2) {
|
|
255
|
-
return (0, __agiflowai_aicode_utils.stat)(path$2);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
|
|
259
185
|
//#endregion
|
|
260
186
|
//#region src/services/BoilerplateService.ts
|
|
261
187
|
var BoilerplateService = class {
|
|
@@ -265,7 +191,7 @@ var BoilerplateService = class {
|
|
|
265
191
|
constructor(templatesPath) {
|
|
266
192
|
this.templatesPath = templatesPath;
|
|
267
193
|
this.templateService = new require_TemplateService.TemplateService();
|
|
268
|
-
const fileSystemService = new FileSystemService();
|
|
194
|
+
const fileSystemService = new require_ListScaffoldingMethodsTool.FileSystemService();
|
|
269
195
|
this.scaffoldService = new require_ScaffoldService.ScaffoldService(fileSystemService, new require_ScaffoldConfigLoader.ScaffoldConfigLoader(fileSystemService, this.templateService), new require_VariableReplacementService.VariableReplacementService(fileSystemService, this.templateService), templatesPath);
|
|
270
196
|
}
|
|
271
197
|
/**
|
|
@@ -300,7 +226,7 @@ var BoilerplateService = class {
|
|
|
300
226
|
__agiflowai_aicode_utils.log.warn(`Failed to load scaffold.yaml for ${templatePath}:`, error);
|
|
301
227
|
}
|
|
302
228
|
}
|
|
303
|
-
const paginatedResult = PaginationHelper.paginate(boilerplates, cursor);
|
|
229
|
+
const paginatedResult = require_ListScaffoldingMethodsTool.PaginationHelper.paginate(boilerplates, cursor);
|
|
304
230
|
return {
|
|
305
231
|
boilerplates: paginatedResult.items,
|
|
306
232
|
nextCursor: paginatedResult.nextCursor,
|
|
@@ -578,179 +504,6 @@ var ScaffoldGeneratorService = class {
|
|
|
578
504
|
}
|
|
579
505
|
};
|
|
580
506
|
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region src/services/ScaffoldingMethodsService.ts
|
|
583
|
-
var ScaffoldingMethodsService = class {
|
|
584
|
-
templateService;
|
|
585
|
-
constructor(fileSystem, templatesRootPath) {
|
|
586
|
-
this.fileSystem = fileSystem;
|
|
587
|
-
this.templatesRootPath = templatesRootPath;
|
|
588
|
-
this.templateService = new require_TemplateService.TemplateService();
|
|
589
|
-
}
|
|
590
|
-
async listScaffoldingMethods(projectPath, cursor) {
|
|
591
|
-
const absoluteProjectPath = node_path.default.resolve(projectPath);
|
|
592
|
-
const sourceTemplate = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(absoluteProjectPath)).sourceTemplate;
|
|
593
|
-
return this.listScaffoldingMethodsByTemplate(sourceTemplate, cursor);
|
|
594
|
-
}
|
|
595
|
-
async listScaffoldingMethodsByTemplate(templateName, cursor) {
|
|
596
|
-
const templatePath = await this.findTemplatePath(templateName);
|
|
597
|
-
if (!templatePath) throw new Error(`Template not found for sourceTemplate: ${templateName}`);
|
|
598
|
-
const fullTemplatePath = node_path.default.join(this.templatesRootPath, templatePath);
|
|
599
|
-
const scaffoldYamlPath = node_path.default.join(fullTemplatePath, "scaffold.yaml");
|
|
600
|
-
if (!await this.fileSystem.pathExists(scaffoldYamlPath)) throw new Error(`scaffold.yaml not found at ${scaffoldYamlPath}`);
|
|
601
|
-
const scaffoldContent = await this.fileSystem.readFile(scaffoldYamlPath, "utf8");
|
|
602
|
-
const architectConfig = js_yaml.default.load(scaffoldContent);
|
|
603
|
-
const methods = [];
|
|
604
|
-
if (architectConfig.features && Array.isArray(architectConfig.features)) architectConfig.features.forEach((feature) => {
|
|
605
|
-
const featureName = feature.name || `scaffold-${templateName}`;
|
|
606
|
-
methods.push({
|
|
607
|
-
name: featureName,
|
|
608
|
-
description: feature.description || "",
|
|
609
|
-
instruction: feature.instruction || "",
|
|
610
|
-
variables_schema: feature.variables_schema || {
|
|
611
|
-
type: "object",
|
|
612
|
-
properties: {},
|
|
613
|
-
required: [],
|
|
614
|
-
additionalProperties: false
|
|
615
|
-
},
|
|
616
|
-
generator: feature.generator
|
|
617
|
-
});
|
|
618
|
-
});
|
|
619
|
-
const paginatedResult = PaginationHelper.paginate(methods, cursor);
|
|
620
|
-
return {
|
|
621
|
-
sourceTemplate: templateName,
|
|
622
|
-
templatePath,
|
|
623
|
-
methods: paginatedResult.items,
|
|
624
|
-
nextCursor: paginatedResult.nextCursor,
|
|
625
|
-
_meta: paginatedResult._meta
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Gets scaffolding methods with instructions rendered using provided variables
|
|
630
|
-
*/
|
|
631
|
-
async listScaffoldingMethodsWithVariables(projectPath, variables, cursor) {
|
|
632
|
-
const result = await this.listScaffoldingMethods(projectPath, cursor);
|
|
633
|
-
const processedMethods = result.methods.map((method) => ({
|
|
634
|
-
...method,
|
|
635
|
-
instruction: method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : void 0
|
|
636
|
-
}));
|
|
637
|
-
return {
|
|
638
|
-
...result,
|
|
639
|
-
methods: processedMethods
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Processes scaffold instruction with template service
|
|
644
|
-
*/
|
|
645
|
-
processScaffoldInstruction(instruction, variables) {
|
|
646
|
-
if (this.templateService.containsTemplateVariables(instruction)) return this.templateService.renderString(instruction, variables);
|
|
647
|
-
return instruction;
|
|
648
|
-
}
|
|
649
|
-
async findTemplatePath(sourceTemplate) {
|
|
650
|
-
const templateDirs = await this.discoverTemplateDirs();
|
|
651
|
-
if (templateDirs.includes(sourceTemplate)) return sourceTemplate;
|
|
652
|
-
for (const templateDir of templateDirs) {
|
|
653
|
-
const templatePath = node_path.default.join(this.templatesRootPath, templateDir);
|
|
654
|
-
const scaffoldYamlPath = node_path.default.join(templatePath, "scaffold.yaml");
|
|
655
|
-
if (await this.fileSystem.pathExists(scaffoldYamlPath)) try {
|
|
656
|
-
const scaffoldContent = await this.fileSystem.readFile(scaffoldYamlPath, "utf8");
|
|
657
|
-
const architectConfig = js_yaml.default.load(scaffoldContent);
|
|
658
|
-
if (architectConfig.boilerplate && Array.isArray(architectConfig.boilerplate)) {
|
|
659
|
-
for (const boilerplate of architectConfig.boilerplate) if (boilerplate.name?.includes(sourceTemplate)) return templateDir;
|
|
660
|
-
}
|
|
661
|
-
} catch (error) {
|
|
662
|
-
__agiflowai_aicode_utils.log.warn(`Failed to read scaffold.yaml at ${scaffoldYamlPath}:`, error);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
return null;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Resolves the project path, handling both monorepo and monolith cases
|
|
669
|
-
* Uses ProjectConfigResolver to find the correct workspace/project root
|
|
670
|
-
*/
|
|
671
|
-
async resolveProjectPath(projectPath) {
|
|
672
|
-
const absolutePath = node_path.default.resolve(projectPath);
|
|
673
|
-
return (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(absolutePath)).workspaceRoot || absolutePath;
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Dynamically discovers all template directories
|
|
677
|
-
* Supports both flat structure (templates/nextjs-15) and nested structure (templates/apps/nextjs-15)
|
|
678
|
-
**/
|
|
679
|
-
async discoverTemplateDirs() {
|
|
680
|
-
const templateDirs = [];
|
|
681
|
-
try {
|
|
682
|
-
const items = await this.fileSystem.readdir(this.templatesRootPath);
|
|
683
|
-
for (const item of items) {
|
|
684
|
-
const itemPath = node_path.default.join(this.templatesRootPath, item);
|
|
685
|
-
if (!(await this.fileSystem.stat(itemPath)).isDirectory()) continue;
|
|
686
|
-
const scaffoldYamlPath = node_path.default.join(itemPath, "scaffold.yaml");
|
|
687
|
-
if (await this.fileSystem.pathExists(scaffoldYamlPath)) {
|
|
688
|
-
templateDirs.push(item);
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
try {
|
|
692
|
-
const subItems = await this.fileSystem.readdir(itemPath);
|
|
693
|
-
for (const subItem of subItems) {
|
|
694
|
-
const subItemPath = node_path.default.join(itemPath, subItem);
|
|
695
|
-
if (!(await this.fileSystem.stat(subItemPath)).isDirectory()) continue;
|
|
696
|
-
const subScaffoldYamlPath = node_path.default.join(subItemPath, "scaffold.yaml");
|
|
697
|
-
if (await this.fileSystem.pathExists(subScaffoldYamlPath)) {
|
|
698
|
-
const relativePath = node_path.default.join(item, subItem);
|
|
699
|
-
templateDirs.push(relativePath);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
} catch (error) {
|
|
703
|
-
__agiflowai_aicode_utils.log.warn(`Failed to read subdirectories in ${itemPath}:`, error);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
} catch (error) {
|
|
707
|
-
__agiflowai_aicode_utils.log.warn(`Failed to read templates root directory ${this.templatesRootPath}:`, error);
|
|
708
|
-
}
|
|
709
|
-
return templateDirs;
|
|
710
|
-
}
|
|
711
|
-
async useScaffoldMethod(request) {
|
|
712
|
-
const { projectPath, scaffold_feature_name, variables } = request;
|
|
713
|
-
const absoluteProjectPath = await this.resolveProjectPath(projectPath);
|
|
714
|
-
const scaffoldingMethods = await this.listScaffoldingMethods(absoluteProjectPath);
|
|
715
|
-
const method = scaffoldingMethods.methods.find((m) => m.name === scaffold_feature_name);
|
|
716
|
-
if (!method) {
|
|
717
|
-
const availableMethods = scaffoldingMethods.methods.map((m) => m.name).join(", ");
|
|
718
|
-
throw new Error(`Scaffold method '${scaffold_feature_name}' not found. Available methods: ${availableMethods}`);
|
|
719
|
-
}
|
|
720
|
-
const ScaffoldService$1 = (await Promise.resolve().then(() => require("./ScaffoldService-BNOyoqSb.cjs"))).ScaffoldService;
|
|
721
|
-
const ScaffoldConfigLoader$1 = (await Promise.resolve().then(() => require("./ScaffoldConfigLoader-B-NLy6VP.cjs"))).ScaffoldConfigLoader;
|
|
722
|
-
const VariableReplacementService$1 = (await Promise.resolve().then(() => require("./VariableReplacementService-DKaF2C9l.cjs"))).VariableReplacementService;
|
|
723
|
-
const TemplateService$1 = (await Promise.resolve().then(() => require("./TemplateService-DqieT1Tq.cjs"))).TemplateService;
|
|
724
|
-
const templateService = new TemplateService$1();
|
|
725
|
-
const scaffoldConfigLoader = new ScaffoldConfigLoader$1(this.fileSystem, templateService);
|
|
726
|
-
const variableReplacer = new VariableReplacementService$1(this.fileSystem, templateService);
|
|
727
|
-
const scaffoldService = new ScaffoldService$1(this.fileSystem, scaffoldConfigLoader, variableReplacer, this.templatesRootPath);
|
|
728
|
-
const projectName = node_path.default.basename(absoluteProjectPath);
|
|
729
|
-
const result = await scaffoldService.useFeature({
|
|
730
|
-
projectPath: absoluteProjectPath,
|
|
731
|
-
templateFolder: scaffoldingMethods.templatePath,
|
|
732
|
-
featureName: scaffold_feature_name,
|
|
733
|
-
variables: {
|
|
734
|
-
...variables,
|
|
735
|
-
appPath: absoluteProjectPath,
|
|
736
|
-
appName: projectName
|
|
737
|
-
}
|
|
738
|
-
});
|
|
739
|
-
if (!result.success) throw new Error(result.message);
|
|
740
|
-
return {
|
|
741
|
-
success: true,
|
|
742
|
-
message: `
|
|
743
|
-
Successfully scaffolded ${scaffold_feature_name} in ${projectPath}.
|
|
744
|
-
Please follow this **instruction**: \n ${method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : ""}.
|
|
745
|
-
-> Create or update the plan based on the instruction.
|
|
746
|
-
`,
|
|
747
|
-
warnings: result.warnings,
|
|
748
|
-
createdFiles: result.createdFiles,
|
|
749
|
-
existingFiles: result.existingFiles
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
|
|
754
507
|
//#endregion
|
|
755
508
|
//#region src/tools/GenerateBoilerplateFileTool.ts
|
|
756
509
|
/**
|
|
@@ -1429,7 +1182,7 @@ Use this to add custom feature scaffolds (pages, components, services, etc.) for
|
|
|
1429
1182
|
|
|
1430
1183
|
//#endregion
|
|
1431
1184
|
//#region src/instructions/tools/list-boilerplates/description.md?raw
|
|
1432
|
-
var description_default$
|
|
1185
|
+
var description_default$1 = "{% if isMonolith %}\nNot available for monolith projects. Monolith uses a single template defined in `toolkit.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";
|
|
1433
1186
|
|
|
1434
1187
|
//#endregion
|
|
1435
1188
|
//#region src/tools/ListBoilerplatesTool.ts
|
|
@@ -1447,7 +1200,7 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
|
|
|
1447
1200
|
* Get the tool definition for MCP
|
|
1448
1201
|
*/
|
|
1449
1202
|
getDefinition() {
|
|
1450
|
-
const description = this.templateService.renderString(description_default$
|
|
1203
|
+
const description = this.templateService.renderString(description_default$1, { isMonolith: this.isMonolith });
|
|
1451
1204
|
return {
|
|
1452
1205
|
name: ListBoilerplatesTool.TOOL_NAME,
|
|
1453
1206
|
description: description.trim(),
|
|
@@ -1484,87 +1237,6 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
|
|
|
1484
1237
|
}
|
|
1485
1238
|
};
|
|
1486
1239
|
|
|
1487
|
-
//#endregion
|
|
1488
|
-
//#region src/instructions/tools/list-scaffolding-methods/description.md?raw
|
|
1489
|
-
var description_default$1 = "Lists all available scaffolding methods (features) that can be added to an existing project{% if not isMonolith %} or for a specific template{% endif %}.\n\nThis tool:\n{% if isMonolith %}\n- Reads your project's sourceTemplate from toolkit.yaml at workspace root\n{% else %}\n- Reads the project's sourceTemplate from project.json (monorepo) or toolkit.yaml (monolith), OR\n- Directly uses the provided templateName to list available features\n{% endif %}\n- Returns available features for that template type\n- Provides variable schemas for each scaffolding method\n- Shows descriptions of what each method creates\n\nUse this FIRST when adding features to understand:\n- What scaffolding methods are available\n- What variables each method requires\n- What files/features will be generated\n\nExample methods might include:\n- Adding new React routes (for React apps)\n- Creating API endpoints (for backend projects)\n- Adding new components (for frontend projects)\n- Setting up database models (for API projects)\n";
|
|
1490
|
-
|
|
1491
|
-
//#endregion
|
|
1492
|
-
//#region src/tools/ListScaffoldingMethodsTool.ts
|
|
1493
|
-
var ListScaffoldingMethodsTool = class ListScaffoldingMethodsTool {
|
|
1494
|
-
static TOOL_NAME = "list-scaffolding-methods";
|
|
1495
|
-
fileSystemService;
|
|
1496
|
-
scaffoldingMethodsService;
|
|
1497
|
-
templateService;
|
|
1498
|
-
isMonolith;
|
|
1499
|
-
constructor(templatesPath, isMonolith = false) {
|
|
1500
|
-
this.fileSystemService = new FileSystemService();
|
|
1501
|
-
this.scaffoldingMethodsService = new ScaffoldingMethodsService(this.fileSystemService, templatesPath);
|
|
1502
|
-
this.templateService = new require_TemplateService.TemplateService();
|
|
1503
|
-
this.isMonolith = isMonolith;
|
|
1504
|
-
}
|
|
1505
|
-
/**
|
|
1506
|
-
* Get the tool definition for MCP
|
|
1507
|
-
*/
|
|
1508
|
-
getDefinition() {
|
|
1509
|
-
const description = this.templateService.renderString(description_default$1, { isMonolith: this.isMonolith });
|
|
1510
|
-
const properties = { cursor: {
|
|
1511
|
-
type: "string",
|
|
1512
|
-
description: "Optional pagination cursor to fetch the next page of results. Omit to fetch the first page."
|
|
1513
|
-
} };
|
|
1514
|
-
if (!this.isMonolith) {
|
|
1515
|
-
properties.projectPath = {
|
|
1516
|
-
type: "string",
|
|
1517
|
-
description: "Absolute path to the project directory (for monorepo: containing project.json; for monolith: workspace root with toolkit.yaml). Either projectPath or templateName is required."
|
|
1518
|
-
};
|
|
1519
|
-
properties.templateName = {
|
|
1520
|
-
type: "string",
|
|
1521
|
-
description: "Name of the template to list scaffolding methods for (e.g., \"nextjs-15\", \"typescript-mcp-package\"). Either projectPath or templateName is required."
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
return {
|
|
1525
|
-
name: ListScaffoldingMethodsTool.TOOL_NAME,
|
|
1526
|
-
description: description.trim(),
|
|
1527
|
-
inputSchema: {
|
|
1528
|
-
type: "object",
|
|
1529
|
-
properties,
|
|
1530
|
-
additionalProperties: false
|
|
1531
|
-
}
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Execute the tool
|
|
1536
|
-
*/
|
|
1537
|
-
async execute(args) {
|
|
1538
|
-
try {
|
|
1539
|
-
const { projectPath, templateName, cursor } = args;
|
|
1540
|
-
let result;
|
|
1541
|
-
if (this.isMonolith) try {
|
|
1542
|
-
const resolvedTemplateName = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
|
|
1543
|
-
result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(resolvedTemplateName, cursor);
|
|
1544
|
-
} catch (error) {
|
|
1545
|
-
throw new Error(`Failed to read template name from configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
1546
|
-
}
|
|
1547
|
-
else {
|
|
1548
|
-
if (!projectPath && !templateName) throw new Error("Either projectPath or templateName must be provided");
|
|
1549
|
-
if (projectPath) result = await this.scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
1550
|
-
else result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(templateName, cursor);
|
|
1551
|
-
}
|
|
1552
|
-
return { content: [{
|
|
1553
|
-
type: "text",
|
|
1554
|
-
text: JSON.stringify(result, null, 2)
|
|
1555
|
-
}] };
|
|
1556
|
-
} catch (error) {
|
|
1557
|
-
return {
|
|
1558
|
-
content: [{
|
|
1559
|
-
type: "text",
|
|
1560
|
-
text: `Error listing scaffolding methods: ${error instanceof Error ? error.message : String(error)}`
|
|
1561
|
-
}],
|
|
1562
|
-
isError: true
|
|
1563
|
-
};
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
|
|
1568
1240
|
//#endregion
|
|
1569
1241
|
//#region src/instructions/tools/use-boilerplate/description.md?raw
|
|
1570
1242
|
var description_default = "{% if isMonolith %}\nThis tool is not available for monolith projects.\n\nMonolith projects use a single template specified in `toolkit.yaml` (sourceTemplate field). 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";
|
|
@@ -1652,15 +1324,35 @@ The boilerplate provides a starting point - you may need to add features or cust
|
|
|
1652
1324
|
//#region src/tools/UseScaffoldMethodTool.ts
|
|
1653
1325
|
var UseScaffoldMethodTool = class UseScaffoldMethodTool {
|
|
1654
1326
|
static TOOL_NAME = "use-scaffold-method";
|
|
1327
|
+
static TEMP_LOG_DIR = node_os.tmpdir();
|
|
1655
1328
|
fileSystemService;
|
|
1656
1329
|
scaffoldingMethodsService;
|
|
1657
1330
|
isMonolith;
|
|
1658
1331
|
constructor(templatesPath, isMonolith = false) {
|
|
1659
|
-
this.fileSystemService = new FileSystemService();
|
|
1660
|
-
this.scaffoldingMethodsService = new ScaffoldingMethodsService(this.fileSystemService, templatesPath);
|
|
1332
|
+
this.fileSystemService = new require_ListScaffoldingMethodsTool.FileSystemService();
|
|
1333
|
+
this.scaffoldingMethodsService = new require_ListScaffoldingMethodsTool.ScaffoldingMethodsService(this.fileSystemService, templatesPath);
|
|
1661
1334
|
this.isMonolith = isMonolith;
|
|
1662
1335
|
}
|
|
1663
1336
|
/**
|
|
1337
|
+
* Write scaffold execution info to temp log file for hook processing
|
|
1338
|
+
*/
|
|
1339
|
+
async writePendingScaffoldLog(scaffoldId, projectPath, featureName, generatedFiles) {
|
|
1340
|
+
try {
|
|
1341
|
+
const logEntry = {
|
|
1342
|
+
timestamp: Date.now(),
|
|
1343
|
+
scaffoldId,
|
|
1344
|
+
projectPath,
|
|
1345
|
+
featureName,
|
|
1346
|
+
generatedFiles,
|
|
1347
|
+
operation: "scaffold"
|
|
1348
|
+
};
|
|
1349
|
+
const tempLogFile = node_path.join(UseScaffoldMethodTool.TEMP_LOG_DIR, `scaffold-mcp-pending-${scaffoldId}.jsonl`);
|
|
1350
|
+
await node_fs_promises.appendFile(tempLogFile, `${JSON.stringify(logEntry)}\n`, "utf-8");
|
|
1351
|
+
} catch (error) {
|
|
1352
|
+
console.error("Failed to write pending scaffold log:", error);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1664
1356
|
* Get the tool definition for MCP
|
|
1665
1357
|
*/
|
|
1666
1358
|
getDefinition() {
|
|
@@ -1714,13 +1406,16 @@ IMPORTANT:
|
|
|
1714
1406
|
try {
|
|
1715
1407
|
const { projectPath, scaffold_feature_name, variables } = args;
|
|
1716
1408
|
const resolvedProjectPath = this.isMonolith ? process.cwd() : projectPath;
|
|
1409
|
+
const result = await this.scaffoldingMethodsService.useScaffoldMethod({
|
|
1410
|
+
projectPath: resolvedProjectPath,
|
|
1411
|
+
scaffold_feature_name,
|
|
1412
|
+
variables
|
|
1413
|
+
});
|
|
1414
|
+
const scaffoldId = (0, __agiflowai_aicode_utils.generateStableId)(6);
|
|
1415
|
+
if (result.createdFiles && result.createdFiles.length > 0) await this.writePendingScaffoldLog(scaffoldId, resolvedProjectPath, scaffold_feature_name, result.createdFiles);
|
|
1717
1416
|
return { content: [{
|
|
1718
1417
|
type: "text",
|
|
1719
|
-
text: `${
|
|
1720
|
-
projectPath: resolvedProjectPath,
|
|
1721
|
-
scaffold_feature_name,
|
|
1722
|
-
variables
|
|
1723
|
-
})).message}
|
|
1418
|
+
text: `${result.message}
|
|
1724
1419
|
|
|
1725
1420
|
IMPORTANT - Next Steps:
|
|
1726
1421
|
1. READ the generated files to understand their structure and template placeholders
|
|
@@ -1730,6 +1425,9 @@ IMPORTANT - Next Steps:
|
|
|
1730
1425
|
5. Only after completing the implementation should you move to other tasks
|
|
1731
1426
|
|
|
1732
1427
|
Do not skip the implementation step - the scaffolded files contain templates that need actual code.`
|
|
1428
|
+
}, {
|
|
1429
|
+
type: "text",
|
|
1430
|
+
text: `SCAFFOLD_ID:${scaffoldId}`
|
|
1733
1431
|
}] };
|
|
1734
1432
|
} catch (error) {
|
|
1735
1433
|
return {
|
|
@@ -1749,7 +1447,7 @@ var WriteToFileTool = class WriteToFileTool {
|
|
|
1749
1447
|
static TOOL_NAME = "write-to-file";
|
|
1750
1448
|
fileSystemService;
|
|
1751
1449
|
constructor() {
|
|
1752
|
-
this.fileSystemService = new FileSystemService();
|
|
1450
|
+
this.fileSystemService = new require_ListScaffoldingMethodsTool.FileSystemService();
|
|
1753
1451
|
}
|
|
1754
1452
|
/**
|
|
1755
1453
|
* Get the tool definition for MCP
|
|
@@ -2149,12 +1847,6 @@ Object.defineProperty(exports, 'BoilerplateService', {
|
|
|
2149
1847
|
return BoilerplateService;
|
|
2150
1848
|
}
|
|
2151
1849
|
});
|
|
2152
|
-
Object.defineProperty(exports, 'FileSystemService', {
|
|
2153
|
-
enumerable: true,
|
|
2154
|
-
get: function () {
|
|
2155
|
-
return FileSystemService;
|
|
2156
|
-
}
|
|
2157
|
-
});
|
|
2158
1850
|
Object.defineProperty(exports, 'GenerateBoilerplateFileTool', {
|
|
2159
1851
|
enumerable: true,
|
|
2160
1852
|
get: function () {
|
|
@@ -2185,24 +1877,12 @@ Object.defineProperty(exports, 'ListBoilerplatesTool', {
|
|
|
2185
1877
|
return ListBoilerplatesTool;
|
|
2186
1878
|
}
|
|
2187
1879
|
});
|
|
2188
|
-
Object.defineProperty(exports, 'ListScaffoldingMethodsTool', {
|
|
2189
|
-
enumerable: true,
|
|
2190
|
-
get: function () {
|
|
2191
|
-
return ListScaffoldingMethodsTool;
|
|
2192
|
-
}
|
|
2193
|
-
});
|
|
2194
1880
|
Object.defineProperty(exports, 'ScaffoldGeneratorService', {
|
|
2195
1881
|
enumerable: true,
|
|
2196
1882
|
get: function () {
|
|
2197
1883
|
return ScaffoldGeneratorService;
|
|
2198
1884
|
}
|
|
2199
1885
|
});
|
|
2200
|
-
Object.defineProperty(exports, 'ScaffoldingMethodsService', {
|
|
2201
|
-
enumerable: true,
|
|
2202
|
-
get: function () {
|
|
2203
|
-
return ScaffoldingMethodsService;
|
|
2204
|
-
}
|
|
2205
|
-
});
|
|
2206
1886
|
Object.defineProperty(exports, 'SseTransportHandler', {
|
|
2207
1887
|
enumerable: true,
|
|
2208
1888
|
get: function () {
|