@agiflowai/scaffold-mcp 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +49 -16
- package/dist/cli.js +49 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +1 -1
- package/dist/{stdio-Bxn4A1IU.js → stdio-BheRzmRj.js} +89 -19
- package/dist/{stdio-TGsG8akc.cjs → stdio-DM_C4xbZ.cjs} +89 -19
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
3
|
-
const require_stdio = require('./stdio-
|
|
3
|
+
const require_stdio = require('./stdio-DM_C4xbZ.cjs');
|
|
4
4
|
require('./ScaffoldConfigLoader-BrmvENTo.cjs');
|
|
5
5
|
require('./ScaffoldService-BwDmXt83.cjs');
|
|
6
6
|
const require_TemplateService = require('./TemplateService-DRubcvS9.cjs');
|
|
@@ -19,7 +19,7 @@ __modelcontextprotocol_sdk_types_js = require_chunk.__toESM(__modelcontextprotoc
|
|
|
19
19
|
//#region package.json
|
|
20
20
|
var name = "@agiflowai/scaffold-mcp";
|
|
21
21
|
var description = "MCP server for scaffolding applications with boilerplate templates";
|
|
22
|
-
var version = "1.0.
|
|
22
|
+
var version = "1.0.2";
|
|
23
23
|
var license = "AGPL-3.0";
|
|
24
24
|
var author = "AgiflowIO";
|
|
25
25
|
var repository = {
|
|
@@ -118,9 +118,9 @@ var package_default = {
|
|
|
118
118
|
* Boilerplate CLI command
|
|
119
119
|
*/
|
|
120
120
|
const boilerplateCommand = new commander.Command("boilerplate").description("Manage boilerplate templates");
|
|
121
|
-
boilerplateCommand.command("list").description("List all available boilerplate templates").action(async () => {
|
|
121
|
+
boilerplateCommand.command("list").description("List all available boilerplate templates").option("-c, --cursor <cursor>", "Pagination cursor for next page").action(async (options) => {
|
|
122
122
|
try {
|
|
123
|
-
const { boilerplates } = await new require_stdio.BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath()).listBoilerplates();
|
|
123
|
+
const { boilerplates, nextCursor } = await new require_stdio.BoilerplateService(await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath()).listBoilerplates(options.cursor);
|
|
124
124
|
if (boilerplates.length === 0) {
|
|
125
125
|
__agiflowai_aicode_utils.messages.warning("No boilerplate templates found.");
|
|
126
126
|
return;
|
|
@@ -134,6 +134,11 @@ boilerplateCommand.command("list").description("List all available boilerplate t
|
|
|
134
134
|
if (required && required.length > 0) __agiflowai_aicode_utils.print.debug(` Required: ${required.join(", ")}`);
|
|
135
135
|
__agiflowai_aicode_utils.print.newline();
|
|
136
136
|
}
|
|
137
|
+
if (nextCursor) {
|
|
138
|
+
__agiflowai_aicode_utils.print.newline();
|
|
139
|
+
__agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.info} More results available. Use --cursor to fetch next page:`);
|
|
140
|
+
__agiflowai_aicode_utils.print.debug(` scaffold-mcp boilerplate list --cursor "${nextCursor}"`);
|
|
141
|
+
}
|
|
137
142
|
} catch (error) {
|
|
138
143
|
__agiflowai_aicode_utils.messages.error("Error listing boilerplates:", error);
|
|
139
144
|
process.exit(1);
|
|
@@ -152,9 +157,15 @@ boilerplateCommand.command("create <boilerplateName>").description("Create a new
|
|
|
152
157
|
}
|
|
153
158
|
const boilerplate = await boilerplateService.getBoilerplate(boilerplateName);
|
|
154
159
|
if (!boilerplate) {
|
|
155
|
-
|
|
160
|
+
let allBoilerplates = [];
|
|
161
|
+
let cursor;
|
|
162
|
+
do {
|
|
163
|
+
const result$1 = await boilerplateService.listBoilerplates(cursor);
|
|
164
|
+
allBoilerplates = allBoilerplates.concat(result$1.boilerplates);
|
|
165
|
+
cursor = result$1.nextCursor;
|
|
166
|
+
} while (cursor);
|
|
156
167
|
__agiflowai_aicode_utils.messages.error(`Boilerplate '${boilerplateName}' not found.`);
|
|
157
|
-
__agiflowai_aicode_utils.print.warning(`Available boilerplates: ${
|
|
168
|
+
__agiflowai_aicode_utils.print.warning(`Available boilerplates: ${allBoilerplates.map((b) => b.name).join(", ")}`);
|
|
158
169
|
process.exit(1);
|
|
159
170
|
}
|
|
160
171
|
const required = typeof boilerplate.variables_schema === "object" && boilerplate.variables_schema !== null && "required" in boilerplate.variables_schema ? boilerplate.variables_schema.required : [];
|
|
@@ -601,7 +612,7 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
|
|
|
601
612
|
* Scaffold CLI command
|
|
602
613
|
*/
|
|
603
614
|
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) => {
|
|
615
|
+
scaffoldCommand.command("list [projectPath]").description("List available scaffolding methods for a project or template").option("-t, --template <name>", "Template name (e.g., nextjs-15, typescript-mcp-package)").option("-c, --cursor <cursor>", "Pagination cursor for next page").action(async (projectPath, options) => {
|
|
605
616
|
try {
|
|
606
617
|
if (!projectPath && !options.template) {
|
|
607
618
|
__agiflowai_aicode_utils.messages.error("Either projectPath or --template option must be provided");
|
|
@@ -621,10 +632,10 @@ scaffoldCommand.command("list [projectPath]").description("List available scaffo
|
|
|
621
632
|
__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
633
|
process.exit(1);
|
|
623
634
|
}
|
|
624
|
-
result = await scaffoldingMethodsService.listScaffoldingMethods(absolutePath);
|
|
635
|
+
result = await scaffoldingMethodsService.listScaffoldingMethods(absolutePath, options.cursor);
|
|
625
636
|
displayName = projectPath;
|
|
626
637
|
} else {
|
|
627
|
-
result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template);
|
|
638
|
+
result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template, options.cursor);
|
|
628
639
|
displayName = `template: ${options.template}`;
|
|
629
640
|
}
|
|
630
641
|
const methods = result.methods;
|
|
@@ -639,6 +650,13 @@ scaffoldCommand.command("list [projectPath]").description("List available scaffo
|
|
|
639
650
|
if (method.variables_schema.required && method.variables_schema.required.length > 0) __agiflowai_aicode_utils.print.debug(` Required: ${method.variables_schema.required.join(", ")}`);
|
|
640
651
|
__agiflowai_aicode_utils.print.newline();
|
|
641
652
|
}
|
|
653
|
+
if (result.nextCursor) {
|
|
654
|
+
__agiflowai_aicode_utils.print.newline();
|
|
655
|
+
__agiflowai_aicode_utils.print.info(`${__agiflowai_aicode_utils.icons.info} More results available. Use --cursor to fetch next page:`);
|
|
656
|
+
const cursorOption = `--cursor "${result.nextCursor}"`;
|
|
657
|
+
if (projectPath) __agiflowai_aicode_utils.print.debug(` scaffold-mcp scaffold list ${projectPath} ${cursorOption}`);
|
|
658
|
+
else __agiflowai_aicode_utils.print.debug(` scaffold-mcp scaffold list --template ${options.template} ${cursorOption}`);
|
|
659
|
+
}
|
|
642
660
|
} catch (error) {
|
|
643
661
|
__agiflowai_aicode_utils.messages.error("Error listing scaffolding methods:", error);
|
|
644
662
|
process.exit(1);
|
|
@@ -662,11 +680,17 @@ scaffoldCommand.command("add <featureName>").description("Add a feature to an ex
|
|
|
662
680
|
}
|
|
663
681
|
const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
664
682
|
const scaffoldingMethodsService = new require_stdio.ScaffoldingMethodsService(new require_stdio.FileSystemService(), templatesDir);
|
|
665
|
-
|
|
666
|
-
|
|
683
|
+
let allMethods = [];
|
|
684
|
+
let cursor;
|
|
685
|
+
do {
|
|
686
|
+
const listResult = await scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
687
|
+
allMethods = allMethods.concat(listResult.methods);
|
|
688
|
+
cursor = listResult.nextCursor;
|
|
689
|
+
} while (cursor);
|
|
690
|
+
const method = allMethods.find((m) => m.name === featureName);
|
|
667
691
|
if (!method) {
|
|
668
692
|
__agiflowai_aicode_utils.messages.error(`Scaffold method '${featureName}' not found.`);
|
|
669
|
-
__agiflowai_aicode_utils.print.warning(`Available methods: ${
|
|
693
|
+
__agiflowai_aicode_utils.print.warning(`Available methods: ${allMethods.map((m) => m.name).join(", ")}`);
|
|
670
694
|
__agiflowai_aicode_utils.print.debug(`Run 'scaffold-mcp scaffold list ${options.project}' to see all available methods`);
|
|
671
695
|
process.exit(1);
|
|
672
696
|
}
|
|
@@ -727,7 +751,8 @@ scaffoldCommand.command("info <featureName>").description("Show detailed informa
|
|
|
727
751
|
}
|
|
728
752
|
const templatesDir = await __agiflowai_aicode_utils.TemplatesManagerService.findTemplatesPath();
|
|
729
753
|
const scaffoldingMethodsService = new require_stdio.ScaffoldingMethodsService(new require_stdio.FileSystemService(), templatesDir);
|
|
730
|
-
let
|
|
754
|
+
let allMethods = [];
|
|
755
|
+
let cursor;
|
|
731
756
|
if (options.project) {
|
|
732
757
|
const projectPath = node_path.default.resolve(options.project);
|
|
733
758
|
if (!await __agiflowai_aicode_utils.ProjectConfigResolver.hasConfiguration(projectPath)) {
|
|
@@ -735,9 +760,17 @@ scaffoldCommand.command("info <featureName>").description("Show detailed informa
|
|
|
735
760
|
__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
761
|
process.exit(1);
|
|
737
762
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
763
|
+
do {
|
|
764
|
+
const result = await scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
765
|
+
allMethods = allMethods.concat(result.methods);
|
|
766
|
+
cursor = result.nextCursor;
|
|
767
|
+
} while (cursor);
|
|
768
|
+
} else do {
|
|
769
|
+
const result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template, cursor);
|
|
770
|
+
allMethods = allMethods.concat(result.methods);
|
|
771
|
+
cursor = result.nextCursor;
|
|
772
|
+
} while (cursor);
|
|
773
|
+
const method = allMethods.find((m) => m.name === featureName);
|
|
741
774
|
if (!method) {
|
|
742
775
|
__agiflowai_aicode_utils.messages.error(`❌ Scaffold method '${featureName}' not found.`);
|
|
743
776
|
process.exit(1);
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { BoilerplateService, FileSystemService, GenerateBoilerplateFileTool, GenerateBoilerplateTool, GenerateFeatureScaffoldTool, HttpTransportHandler, ListBoilerplatesTool, ListScaffoldingMethodsTool, ScaffoldingMethodsService, SseTransportHandler, StdioTransportHandler, UseBoilerplateTool, UseScaffoldMethodTool, WriteToFileTool } from "./stdio-
|
|
2
|
+
import { BoilerplateService, FileSystemService, GenerateBoilerplateFileTool, GenerateBoilerplateTool, GenerateFeatureScaffoldTool, HttpTransportHandler, ListBoilerplatesTool, ListScaffoldingMethodsTool, ScaffoldingMethodsService, SseTransportHandler, StdioTransportHandler, UseBoilerplateTool, UseScaffoldMethodTool, WriteToFileTool } from "./stdio-BheRzmRj.js";
|
|
3
3
|
import "./ScaffoldConfigLoader-CI0T6zdG.js";
|
|
4
4
|
import "./ScaffoldService-DB7-Cyod.js";
|
|
5
5
|
import { TemplateService } from "./TemplateService-CiZJA06s.js";
|
|
@@ -13,7 +13,7 @@ import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema
|
|
|
13
13
|
//#region package.json
|
|
14
14
|
var name = "@agiflowai/scaffold-mcp";
|
|
15
15
|
var description = "MCP server for scaffolding applications with boilerplate templates";
|
|
16
|
-
var version = "1.0.
|
|
16
|
+
var version = "1.0.2";
|
|
17
17
|
var license = "AGPL-3.0";
|
|
18
18
|
var author = "AgiflowIO";
|
|
19
19
|
var repository = {
|
|
@@ -112,9 +112,9 @@ var package_default = {
|
|
|
112
112
|
* Boilerplate CLI command
|
|
113
113
|
*/
|
|
114
114
|
const boilerplateCommand = new Command("boilerplate").description("Manage boilerplate templates");
|
|
115
|
-
boilerplateCommand.command("list").description("List all available boilerplate templates").action(async () => {
|
|
115
|
+
boilerplateCommand.command("list").description("List all available boilerplate templates").option("-c, --cursor <cursor>", "Pagination cursor for next page").action(async (options) => {
|
|
116
116
|
try {
|
|
117
|
-
const { boilerplates } = await new BoilerplateService(await TemplatesManagerService.findTemplatesPath()).listBoilerplates();
|
|
117
|
+
const { boilerplates, nextCursor } = await new BoilerplateService(await TemplatesManagerService.findTemplatesPath()).listBoilerplates(options.cursor);
|
|
118
118
|
if (boilerplates.length === 0) {
|
|
119
119
|
messages.warning("No boilerplate templates found.");
|
|
120
120
|
return;
|
|
@@ -128,6 +128,11 @@ boilerplateCommand.command("list").description("List all available boilerplate t
|
|
|
128
128
|
if (required && required.length > 0) print.debug(` Required: ${required.join(", ")}`);
|
|
129
129
|
print.newline();
|
|
130
130
|
}
|
|
131
|
+
if (nextCursor) {
|
|
132
|
+
print.newline();
|
|
133
|
+
print.info(`${icons.info} More results available. Use --cursor to fetch next page:`);
|
|
134
|
+
print.debug(` scaffold-mcp boilerplate list --cursor "${nextCursor}"`);
|
|
135
|
+
}
|
|
131
136
|
} catch (error) {
|
|
132
137
|
messages.error("Error listing boilerplates:", error);
|
|
133
138
|
process.exit(1);
|
|
@@ -146,9 +151,15 @@ boilerplateCommand.command("create <boilerplateName>").description("Create a new
|
|
|
146
151
|
}
|
|
147
152
|
const boilerplate = await boilerplateService.getBoilerplate(boilerplateName);
|
|
148
153
|
if (!boilerplate) {
|
|
149
|
-
|
|
154
|
+
let allBoilerplates = [];
|
|
155
|
+
let cursor;
|
|
156
|
+
do {
|
|
157
|
+
const result$1 = await boilerplateService.listBoilerplates(cursor);
|
|
158
|
+
allBoilerplates = allBoilerplates.concat(result$1.boilerplates);
|
|
159
|
+
cursor = result$1.nextCursor;
|
|
160
|
+
} while (cursor);
|
|
150
161
|
messages.error(`Boilerplate '${boilerplateName}' not found.`);
|
|
151
|
-
print.warning(`Available boilerplates: ${
|
|
162
|
+
print.warning(`Available boilerplates: ${allBoilerplates.map((b) => b.name).join(", ")}`);
|
|
152
163
|
process.exit(1);
|
|
153
164
|
}
|
|
154
165
|
const required = typeof boilerplate.variables_schema === "object" && boilerplate.variables_schema !== null && "required" in boilerplate.variables_schema ? boilerplate.variables_schema.required : [];
|
|
@@ -595,7 +606,7 @@ const mcpServeCommand = new Command("mcp-serve").description("Start MCP server w
|
|
|
595
606
|
* Scaffold CLI command
|
|
596
607
|
*/
|
|
597
608
|
const scaffoldCommand = new Command("scaffold").description("Add features to existing projects");
|
|
598
|
-
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) => {
|
|
609
|
+
scaffoldCommand.command("list [projectPath]").description("List available scaffolding methods for a project or template").option("-t, --template <name>", "Template name (e.g., nextjs-15, typescript-mcp-package)").option("-c, --cursor <cursor>", "Pagination cursor for next page").action(async (projectPath, options) => {
|
|
599
610
|
try {
|
|
600
611
|
if (!projectPath && !options.template) {
|
|
601
612
|
messages.error("Either projectPath or --template option must be provided");
|
|
@@ -615,10 +626,10 @@ scaffoldCommand.command("list [projectPath]").description("List available scaffo
|
|
|
615
626
|
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");
|
|
616
627
|
process.exit(1);
|
|
617
628
|
}
|
|
618
|
-
result = await scaffoldingMethodsService.listScaffoldingMethods(absolutePath);
|
|
629
|
+
result = await scaffoldingMethodsService.listScaffoldingMethods(absolutePath, options.cursor);
|
|
619
630
|
displayName = projectPath;
|
|
620
631
|
} else {
|
|
621
|
-
result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template);
|
|
632
|
+
result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template, options.cursor);
|
|
622
633
|
displayName = `template: ${options.template}`;
|
|
623
634
|
}
|
|
624
635
|
const methods = result.methods;
|
|
@@ -633,6 +644,13 @@ scaffoldCommand.command("list [projectPath]").description("List available scaffo
|
|
|
633
644
|
if (method.variables_schema.required && method.variables_schema.required.length > 0) print.debug(` Required: ${method.variables_schema.required.join(", ")}`);
|
|
634
645
|
print.newline();
|
|
635
646
|
}
|
|
647
|
+
if (result.nextCursor) {
|
|
648
|
+
print.newline();
|
|
649
|
+
print.info(`${icons.info} More results available. Use --cursor to fetch next page:`);
|
|
650
|
+
const cursorOption = `--cursor "${result.nextCursor}"`;
|
|
651
|
+
if (projectPath) print.debug(` scaffold-mcp scaffold list ${projectPath} ${cursorOption}`);
|
|
652
|
+
else print.debug(` scaffold-mcp scaffold list --template ${options.template} ${cursorOption}`);
|
|
653
|
+
}
|
|
636
654
|
} catch (error) {
|
|
637
655
|
messages.error("Error listing scaffolding methods:", error);
|
|
638
656
|
process.exit(1);
|
|
@@ -656,11 +674,17 @@ scaffoldCommand.command("add <featureName>").description("Add a feature to an ex
|
|
|
656
674
|
}
|
|
657
675
|
const templatesDir = await TemplatesManagerService.findTemplatesPath();
|
|
658
676
|
const scaffoldingMethodsService = new ScaffoldingMethodsService(new FileSystemService(), templatesDir);
|
|
659
|
-
|
|
660
|
-
|
|
677
|
+
let allMethods = [];
|
|
678
|
+
let cursor;
|
|
679
|
+
do {
|
|
680
|
+
const listResult = await scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
681
|
+
allMethods = allMethods.concat(listResult.methods);
|
|
682
|
+
cursor = listResult.nextCursor;
|
|
683
|
+
} while (cursor);
|
|
684
|
+
const method = allMethods.find((m) => m.name === featureName);
|
|
661
685
|
if (!method) {
|
|
662
686
|
messages.error(`Scaffold method '${featureName}' not found.`);
|
|
663
|
-
print.warning(`Available methods: ${
|
|
687
|
+
print.warning(`Available methods: ${allMethods.map((m) => m.name).join(", ")}`);
|
|
664
688
|
print.debug(`Run 'scaffold-mcp scaffold list ${options.project}' to see all available methods`);
|
|
665
689
|
process.exit(1);
|
|
666
690
|
}
|
|
@@ -721,7 +745,8 @@ scaffoldCommand.command("info <featureName>").description("Show detailed informa
|
|
|
721
745
|
}
|
|
722
746
|
const templatesDir = await TemplatesManagerService.findTemplatesPath();
|
|
723
747
|
const scaffoldingMethodsService = new ScaffoldingMethodsService(new FileSystemService(), templatesDir);
|
|
724
|
-
let
|
|
748
|
+
let allMethods = [];
|
|
749
|
+
let cursor;
|
|
725
750
|
if (options.project) {
|
|
726
751
|
const projectPath = path.resolve(options.project);
|
|
727
752
|
if (!await ProjectConfigResolver.hasConfiguration(projectPath)) {
|
|
@@ -729,9 +754,17 @@ scaffoldCommand.command("info <featureName>").description("Show detailed informa
|
|
|
729
754
|
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");
|
|
730
755
|
process.exit(1);
|
|
731
756
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
757
|
+
do {
|
|
758
|
+
const result = await scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
759
|
+
allMethods = allMethods.concat(result.methods);
|
|
760
|
+
cursor = result.nextCursor;
|
|
761
|
+
} while (cursor);
|
|
762
|
+
} else do {
|
|
763
|
+
const result = await scaffoldingMethodsService.listScaffoldingMethodsByTemplate(options.template, cursor);
|
|
764
|
+
allMethods = allMethods.concat(result.methods);
|
|
765
|
+
cursor = result.nextCursor;
|
|
766
|
+
} while (cursor);
|
|
767
|
+
const method = allMethods.find((m) => m.name === featureName);
|
|
735
768
|
if (!method) {
|
|
736
769
|
messages.error(`❌ Scaffold method '${featureName}' not found.`);
|
|
737
770
|
process.exit(1);
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_stdio = require('./stdio-
|
|
2
|
+
const require_stdio = require('./stdio-DM_C4xbZ.cjs');
|
|
3
3
|
const require_ScaffoldConfigLoader = require('./ScaffoldConfigLoader-BrmvENTo.cjs');
|
|
4
4
|
const require_ScaffoldService = require('./ScaffoldService-BwDmXt83.cjs');
|
|
5
5
|
const require_TemplateService = require('./TemplateService-DRubcvS9.cjs');
|
package/dist/index.d.cts
CHANGED
|
@@ -108,6 +108,12 @@ interface UseBoilerplateRequest {
|
|
|
108
108
|
}
|
|
109
109
|
interface ListBoilerplateResponse {
|
|
110
110
|
boilerplates: BoilerplateInfo[];
|
|
111
|
+
nextCursor?: string;
|
|
112
|
+
_meta?: {
|
|
113
|
+
total: number;
|
|
114
|
+
offset: number;
|
|
115
|
+
limit: number;
|
|
116
|
+
};
|
|
111
117
|
}
|
|
112
118
|
//#endregion
|
|
113
119
|
//#region src/types/interfaces.d.ts
|
|
@@ -226,9 +232,11 @@ declare class BoilerplateService {
|
|
|
226
232
|
private scaffoldService;
|
|
227
233
|
constructor(templatesPath: string);
|
|
228
234
|
/**
|
|
229
|
-
* Scans all scaffold.yaml files and returns available boilerplates
|
|
235
|
+
* Scans all scaffold.yaml files and returns available boilerplates with pagination
|
|
236
|
+
* @param cursor - Optional pagination cursor
|
|
237
|
+
* @returns Paginated list of boilerplates
|
|
230
238
|
*/
|
|
231
|
-
listBoilerplates(): Promise<ListBoilerplateResponse>;
|
|
239
|
+
listBoilerplates(cursor?: string): Promise<ListBoilerplateResponse>;
|
|
232
240
|
/**
|
|
233
241
|
* Dynamically discovers template directories by finding all directories
|
|
234
242
|
* that contain both package.json and scaffold.yaml files
|
|
@@ -353,6 +361,12 @@ interface ListScaffoldingMethodsResult {
|
|
|
353
361
|
sourceTemplate: string;
|
|
354
362
|
templatePath: string;
|
|
355
363
|
methods: ScaffoldMethod[];
|
|
364
|
+
nextCursor?: string;
|
|
365
|
+
_meta?: {
|
|
366
|
+
total: number;
|
|
367
|
+
offset: number;
|
|
368
|
+
limit: number;
|
|
369
|
+
};
|
|
356
370
|
}
|
|
357
371
|
interface UseScaffoldMethodRequest {
|
|
358
372
|
projectPath: string;
|
|
@@ -364,12 +378,12 @@ declare class ScaffoldingMethodsService {
|
|
|
364
378
|
private templatesRootPath;
|
|
365
379
|
private templateService;
|
|
366
380
|
constructor(fileSystem: IFileSystemService, templatesRootPath: string);
|
|
367
|
-
listScaffoldingMethods(projectPath: string): Promise<ListScaffoldingMethodsResult>;
|
|
368
|
-
listScaffoldingMethodsByTemplate(templateName: string): Promise<ListScaffoldingMethodsResult>;
|
|
381
|
+
listScaffoldingMethods(projectPath: string, cursor?: string): Promise<ListScaffoldingMethodsResult>;
|
|
382
|
+
listScaffoldingMethodsByTemplate(templateName: string, cursor?: string): Promise<ListScaffoldingMethodsResult>;
|
|
369
383
|
/**
|
|
370
384
|
* Gets scaffolding methods with instructions rendered using provided variables
|
|
371
385
|
*/
|
|
372
|
-
listScaffoldingMethodsWithVariables(projectPath: string, variables: Record<string, any
|
|
386
|
+
listScaffoldingMethodsWithVariables(projectPath: string, variables: Record<string, any>, cursor?: string): Promise<ListScaffoldingMethodsResult>;
|
|
373
387
|
/**
|
|
374
388
|
* Processes scaffold instruction with template service
|
|
375
389
|
*/
|
|
@@ -591,7 +605,7 @@ declare class ListBoilerplatesTool {
|
|
|
591
605
|
/**
|
|
592
606
|
* Execute the tool
|
|
593
607
|
*/
|
|
594
|
-
execute(
|
|
608
|
+
execute(args?: Record<string, any>): Promise<CallToolResult>;
|
|
595
609
|
}
|
|
596
610
|
//#endregion
|
|
597
611
|
//#region src/tools/ListScaffoldingMethodsTool.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,12 @@ interface UseBoilerplateRequest {
|
|
|
109
109
|
}
|
|
110
110
|
interface ListBoilerplateResponse {
|
|
111
111
|
boilerplates: BoilerplateInfo[];
|
|
112
|
+
nextCursor?: string;
|
|
113
|
+
_meta?: {
|
|
114
|
+
total: number;
|
|
115
|
+
offset: number;
|
|
116
|
+
limit: number;
|
|
117
|
+
};
|
|
112
118
|
}
|
|
113
119
|
//#endregion
|
|
114
120
|
//#region src/types/interfaces.d.ts
|
|
@@ -227,9 +233,11 @@ declare class BoilerplateService {
|
|
|
227
233
|
private scaffoldService;
|
|
228
234
|
constructor(templatesPath: string);
|
|
229
235
|
/**
|
|
230
|
-
* Scans all scaffold.yaml files and returns available boilerplates
|
|
236
|
+
* Scans all scaffold.yaml files and returns available boilerplates with pagination
|
|
237
|
+
* @param cursor - Optional pagination cursor
|
|
238
|
+
* @returns Paginated list of boilerplates
|
|
231
239
|
*/
|
|
232
|
-
listBoilerplates(): Promise<ListBoilerplateResponse>;
|
|
240
|
+
listBoilerplates(cursor?: string): Promise<ListBoilerplateResponse>;
|
|
233
241
|
/**
|
|
234
242
|
* Dynamically discovers template directories by finding all directories
|
|
235
243
|
* that contain both package.json and scaffold.yaml files
|
|
@@ -354,6 +362,12 @@ interface ListScaffoldingMethodsResult {
|
|
|
354
362
|
sourceTemplate: string;
|
|
355
363
|
templatePath: string;
|
|
356
364
|
methods: ScaffoldMethod[];
|
|
365
|
+
nextCursor?: string;
|
|
366
|
+
_meta?: {
|
|
367
|
+
total: number;
|
|
368
|
+
offset: number;
|
|
369
|
+
limit: number;
|
|
370
|
+
};
|
|
357
371
|
}
|
|
358
372
|
interface UseScaffoldMethodRequest {
|
|
359
373
|
projectPath: string;
|
|
@@ -365,12 +379,12 @@ declare class ScaffoldingMethodsService {
|
|
|
365
379
|
private templatesRootPath;
|
|
366
380
|
private templateService;
|
|
367
381
|
constructor(fileSystem: IFileSystemService, templatesRootPath: string);
|
|
368
|
-
listScaffoldingMethods(projectPath: string): Promise<ListScaffoldingMethodsResult>;
|
|
369
|
-
listScaffoldingMethodsByTemplate(templateName: string): Promise<ListScaffoldingMethodsResult>;
|
|
382
|
+
listScaffoldingMethods(projectPath: string, cursor?: string): Promise<ListScaffoldingMethodsResult>;
|
|
383
|
+
listScaffoldingMethodsByTemplate(templateName: string, cursor?: string): Promise<ListScaffoldingMethodsResult>;
|
|
370
384
|
/**
|
|
371
385
|
* Gets scaffolding methods with instructions rendered using provided variables
|
|
372
386
|
*/
|
|
373
|
-
listScaffoldingMethodsWithVariables(projectPath: string, variables: Record<string, any
|
|
387
|
+
listScaffoldingMethodsWithVariables(projectPath: string, variables: Record<string, any>, cursor?: string): Promise<ListScaffoldingMethodsResult>;
|
|
374
388
|
/**
|
|
375
389
|
* Processes scaffold instruction with template service
|
|
376
390
|
*/
|
|
@@ -592,7 +606,7 @@ declare class ListBoilerplatesTool {
|
|
|
592
606
|
/**
|
|
593
607
|
* Execute the tool
|
|
594
608
|
*/
|
|
595
|
-
execute(
|
|
609
|
+
execute(args?: Record<string, any>): Promise<CallToolResult>;
|
|
596
610
|
}
|
|
597
611
|
//#endregion
|
|
598
612
|
//#region src/tools/ListScaffoldingMethodsTool.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoilerplateGeneratorService, BoilerplateService, FileSystemService, GenerateBoilerplateFileTool, GenerateBoilerplateTool, GenerateFeatureScaffoldTool, HttpTransportHandler, ListBoilerplatesTool, ListScaffoldingMethodsTool, ScaffoldGeneratorService, ScaffoldingMethodsService, SseTransportHandler, StdioTransportHandler, UseBoilerplateTool, UseScaffoldMethodTool, WriteToFileTool } from "./stdio-
|
|
1
|
+
import { BoilerplateGeneratorService, BoilerplateService, FileSystemService, GenerateBoilerplateFileTool, GenerateBoilerplateTool, GenerateFeatureScaffoldTool, HttpTransportHandler, ListBoilerplatesTool, ListScaffoldingMethodsTool, ScaffoldGeneratorService, ScaffoldingMethodsService, SseTransportHandler, StdioTransportHandler, UseBoilerplateTool, UseScaffoldMethodTool, WriteToFileTool } from "./stdio-BheRzmRj.js";
|
|
2
2
|
import { ScaffoldConfigLoader } from "./ScaffoldConfigLoader-CI0T6zdG.js";
|
|
3
3
|
import { ScaffoldProcessingService, ScaffoldService } from "./ScaffoldService-DB7-Cyod.js";
|
|
4
4
|
import { TemplateService } from "./TemplateService-CiZJA06s.js";
|
|
@@ -18,6 +18,56 @@ import express from "express";
|
|
|
18
18
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
19
19
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
20
20
|
|
|
21
|
+
//#region src/utils/pagination.ts
|
|
22
|
+
var PaginationHelper = class PaginationHelper {
|
|
23
|
+
/**
|
|
24
|
+
* Default page size for pagination
|
|
25
|
+
*/
|
|
26
|
+
static DEFAULT_PAGE_SIZE = 10;
|
|
27
|
+
/**
|
|
28
|
+
* Decodes a cursor string to extract the start index
|
|
29
|
+
* @param cursor - String representing the start index (e.g., "10")
|
|
30
|
+
* @returns Start index or 0 if invalid/undefined
|
|
31
|
+
*/
|
|
32
|
+
static decodeCursor(cursor) {
|
|
33
|
+
if (!cursor) return 0;
|
|
34
|
+
const index = Number.parseInt(cursor, 10);
|
|
35
|
+
if (Number.isNaN(index) || index < 0) return 0;
|
|
36
|
+
return index;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Encodes an index into a cursor string
|
|
40
|
+
* @param index - Start index to encode
|
|
41
|
+
* @returns Cursor string (e.g., "10")
|
|
42
|
+
*/
|
|
43
|
+
static encodeCursor(index) {
|
|
44
|
+
return index.toString();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Paginates an array of items
|
|
48
|
+
* @param items - All items to paginate
|
|
49
|
+
* @param cursor - Optional cursor representing the start index
|
|
50
|
+
* @param pageSize - Number of items per page (default: 10)
|
|
51
|
+
* @param includeMeta - Whether to include metadata in response (default: true)
|
|
52
|
+
* @returns Paginated result with items and optional nextCursor
|
|
53
|
+
*/
|
|
54
|
+
static paginate(items, cursor, pageSize = PaginationHelper.DEFAULT_PAGE_SIZE, includeMeta = true) {
|
|
55
|
+
const startIndex = PaginationHelper.decodeCursor(cursor);
|
|
56
|
+
const endIndex = startIndex + pageSize;
|
|
57
|
+
const result = {
|
|
58
|
+
items: items.slice(startIndex, endIndex),
|
|
59
|
+
nextCursor: endIndex < items.length ? PaginationHelper.encodeCursor(endIndex) : void 0
|
|
60
|
+
};
|
|
61
|
+
if (includeMeta) result._meta = {
|
|
62
|
+
total: items.length,
|
|
63
|
+
offset: startIndex,
|
|
64
|
+
limit: pageSize
|
|
65
|
+
};
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
21
71
|
//#region src/services/FileSystemService.ts
|
|
22
72
|
var FileSystemService = class {
|
|
23
73
|
async pathExists(path$2) {
|
|
@@ -59,9 +109,11 @@ var BoilerplateService = class {
|
|
|
59
109
|
this.scaffoldService = new ScaffoldService(fileSystemService, new ScaffoldConfigLoader(fileSystemService, this.templateService), new VariableReplacementService(fileSystemService, this.templateService), templatesPath);
|
|
60
110
|
}
|
|
61
111
|
/**
|
|
62
|
-
* Scans all scaffold.yaml files and returns available boilerplates
|
|
112
|
+
* Scans all scaffold.yaml files and returns available boilerplates with pagination
|
|
113
|
+
* @param cursor - Optional pagination cursor
|
|
114
|
+
* @returns Paginated list of boilerplates
|
|
63
115
|
*/
|
|
64
|
-
async listBoilerplates() {
|
|
116
|
+
async listBoilerplates(cursor) {
|
|
65
117
|
const boilerplates = [];
|
|
66
118
|
const templateDirs = await this.discoverTemplateDirectories();
|
|
67
119
|
for (const templatePath of templateDirs) {
|
|
@@ -88,7 +140,12 @@ var BoilerplateService = class {
|
|
|
88
140
|
log.warn(`Failed to load scaffold.yaml for ${templatePath}:`, error);
|
|
89
141
|
}
|
|
90
142
|
}
|
|
91
|
-
|
|
143
|
+
const paginatedResult = PaginationHelper.paginate(boilerplates, cursor);
|
|
144
|
+
return {
|
|
145
|
+
boilerplates: paginatedResult.items,
|
|
146
|
+
nextCursor: paginatedResult.nextCursor,
|
|
147
|
+
_meta: paginatedResult._meta
|
|
148
|
+
};
|
|
92
149
|
}
|
|
93
150
|
/**
|
|
94
151
|
* Dynamically discovers template directories by finding all directories
|
|
@@ -175,9 +232,12 @@ var BoilerplateService = class {
|
|
|
175
232
|
const projectPath = path$1.join(targetFolder, folderName);
|
|
176
233
|
await ProjectConfigResolver.createProjectJson(projectPath, folderName, boilerplate.template_path);
|
|
177
234
|
}
|
|
235
|
+
const processedInstruction = boilerplate.instruction ? this.processBoilerplateInstruction(boilerplate.instruction, variables) : "";
|
|
236
|
+
let enhancedMessage = result.message;
|
|
237
|
+
if (processedInstruction) enhancedMessage += `\n\nPlease follow this **instruction**:\n${processedInstruction}`;
|
|
178
238
|
return {
|
|
179
239
|
success: result.success,
|
|
180
|
-
message:
|
|
240
|
+
message: enhancedMessage,
|
|
181
241
|
warnings: result.warnings,
|
|
182
242
|
createdFiles: result.createdFiles,
|
|
183
243
|
existingFiles: result.existingFiles
|
|
@@ -1223,7 +1283,10 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
|
|
|
1223
1283
|
description: description.trim(),
|
|
1224
1284
|
inputSchema: {
|
|
1225
1285
|
type: "object",
|
|
1226
|
-
properties: {
|
|
1286
|
+
properties: { cursor: {
|
|
1287
|
+
type: "string",
|
|
1288
|
+
description: "Optional pagination cursor to fetch the next page of results. Omit to fetch the first page."
|
|
1289
|
+
} },
|
|
1227
1290
|
additionalProperties: false
|
|
1228
1291
|
}
|
|
1229
1292
|
};
|
|
@@ -1231,9 +1294,10 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
|
|
|
1231
1294
|
/**
|
|
1232
1295
|
* Execute the tool
|
|
1233
1296
|
*/
|
|
1234
|
-
async execute(
|
|
1297
|
+
async execute(args = {}) {
|
|
1235
1298
|
try {
|
|
1236
|
-
const
|
|
1299
|
+
const { cursor } = args;
|
|
1300
|
+
const result = await this.boilerplateService.listBoilerplates(cursor);
|
|
1237
1301
|
return { content: [{
|
|
1238
1302
|
type: "text",
|
|
1239
1303
|
text: JSON.stringify(result, null, 2)
|
|
@@ -1263,12 +1327,12 @@ var ScaffoldingMethodsService = class {
|
|
|
1263
1327
|
this.templatesRootPath = templatesRootPath;
|
|
1264
1328
|
this.templateService = new TemplateService();
|
|
1265
1329
|
}
|
|
1266
|
-
async listScaffoldingMethods(projectPath) {
|
|
1330
|
+
async listScaffoldingMethods(projectPath, cursor) {
|
|
1267
1331
|
const absoluteProjectPath = path.resolve(projectPath);
|
|
1268
1332
|
const sourceTemplate = (await ProjectConfigResolver.resolveProjectConfig(absoluteProjectPath)).sourceTemplate;
|
|
1269
|
-
return this.listScaffoldingMethodsByTemplate(sourceTemplate);
|
|
1333
|
+
return this.listScaffoldingMethodsByTemplate(sourceTemplate, cursor);
|
|
1270
1334
|
}
|
|
1271
|
-
async listScaffoldingMethodsByTemplate(templateName) {
|
|
1335
|
+
async listScaffoldingMethodsByTemplate(templateName, cursor) {
|
|
1272
1336
|
const templatePath = await this.findTemplatePath(templateName);
|
|
1273
1337
|
if (!templatePath) throw new Error(`Template not found for sourceTemplate: ${templateName}`);
|
|
1274
1338
|
const fullTemplatePath = path.join(this.templatesRootPath, templatePath);
|
|
@@ -1292,17 +1356,20 @@ var ScaffoldingMethodsService = class {
|
|
|
1292
1356
|
generator: feature.generator
|
|
1293
1357
|
});
|
|
1294
1358
|
});
|
|
1359
|
+
const paginatedResult = PaginationHelper.paginate(methods, cursor);
|
|
1295
1360
|
return {
|
|
1296
1361
|
sourceTemplate: templateName,
|
|
1297
1362
|
templatePath,
|
|
1298
|
-
methods
|
|
1363
|
+
methods: paginatedResult.items,
|
|
1364
|
+
nextCursor: paginatedResult.nextCursor,
|
|
1365
|
+
_meta: paginatedResult._meta
|
|
1299
1366
|
};
|
|
1300
1367
|
}
|
|
1301
1368
|
/**
|
|
1302
1369
|
* Gets scaffolding methods with instructions rendered using provided variables
|
|
1303
1370
|
*/
|
|
1304
|
-
async listScaffoldingMethodsWithVariables(projectPath, variables) {
|
|
1305
|
-
const result = await this.listScaffoldingMethods(projectPath);
|
|
1371
|
+
async listScaffoldingMethodsWithVariables(projectPath, variables, cursor) {
|
|
1372
|
+
const result = await this.listScaffoldingMethods(projectPath, cursor);
|
|
1306
1373
|
const processedMethods = result.methods.map((method) => ({
|
|
1307
1374
|
...method,
|
|
1308
1375
|
instruction: method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : void 0
|
|
@@ -1414,7 +1481,7 @@ var ScaffoldingMethodsService = class {
|
|
|
1414
1481
|
success: true,
|
|
1415
1482
|
message: `
|
|
1416
1483
|
Successfully scaffolded ${scaffold_feature_name} in ${projectPath}.
|
|
1417
|
-
Please follow this **instruction**: \n ${method.instruction}.
|
|
1484
|
+
Please follow this **instruction**: \n ${method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : ""}.
|
|
1418
1485
|
-> Create or update the plan based on the instruction.
|
|
1419
1486
|
`,
|
|
1420
1487
|
warnings: result.warnings,
|
|
@@ -1443,7 +1510,10 @@ var ListScaffoldingMethodsTool = class ListScaffoldingMethodsTool {
|
|
|
1443
1510
|
*/
|
|
1444
1511
|
getDefinition() {
|
|
1445
1512
|
const description = this.templateService.renderString(description_default$1, { isMonolith: this.isMonolith });
|
|
1446
|
-
const properties = {
|
|
1513
|
+
const properties = { cursor: {
|
|
1514
|
+
type: "string",
|
|
1515
|
+
description: "Optional pagination cursor to fetch the next page of results. Omit to fetch the first page."
|
|
1516
|
+
} };
|
|
1447
1517
|
if (!this.isMonolith) {
|
|
1448
1518
|
properties.projectPath = {
|
|
1449
1519
|
type: "string",
|
|
@@ -1469,18 +1539,18 @@ var ListScaffoldingMethodsTool = class ListScaffoldingMethodsTool {
|
|
|
1469
1539
|
*/
|
|
1470
1540
|
async execute(args) {
|
|
1471
1541
|
try {
|
|
1472
|
-
const { projectPath, templateName } = args;
|
|
1542
|
+
const { projectPath, templateName, cursor } = args;
|
|
1473
1543
|
let result;
|
|
1474
1544
|
if (this.isMonolith) try {
|
|
1475
1545
|
const resolvedTemplateName = (await ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
|
|
1476
|
-
result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(resolvedTemplateName);
|
|
1546
|
+
result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(resolvedTemplateName, cursor);
|
|
1477
1547
|
} catch (error) {
|
|
1478
1548
|
throw new Error(`Failed to read template name from configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
1479
1549
|
}
|
|
1480
1550
|
else {
|
|
1481
1551
|
if (!projectPath && !templateName) throw new Error("Either projectPath or templateName must be provided");
|
|
1482
|
-
if (projectPath) result = await this.scaffoldingMethodsService.listScaffoldingMethods(projectPath);
|
|
1483
|
-
else result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(templateName);
|
|
1552
|
+
if (projectPath) result = await this.scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
1553
|
+
else result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(templateName, cursor);
|
|
1484
1554
|
}
|
|
1485
1555
|
return { content: [{
|
|
1486
1556
|
type: "text",
|
|
@@ -28,6 +28,56 @@ __modelcontextprotocol_sdk_server_sse_js = require_chunk.__toESM(__modelcontextp
|
|
|
28
28
|
let __modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
29
29
|
__modelcontextprotocol_sdk_server_stdio_js = require_chunk.__toESM(__modelcontextprotocol_sdk_server_stdio_js);
|
|
30
30
|
|
|
31
|
+
//#region src/utils/pagination.ts
|
|
32
|
+
var PaginationHelper = class PaginationHelper {
|
|
33
|
+
/**
|
|
34
|
+
* Default page size for pagination
|
|
35
|
+
*/
|
|
36
|
+
static DEFAULT_PAGE_SIZE = 10;
|
|
37
|
+
/**
|
|
38
|
+
* Decodes a cursor string to extract the start index
|
|
39
|
+
* @param cursor - String representing the start index (e.g., "10")
|
|
40
|
+
* @returns Start index or 0 if invalid/undefined
|
|
41
|
+
*/
|
|
42
|
+
static decodeCursor(cursor) {
|
|
43
|
+
if (!cursor) return 0;
|
|
44
|
+
const index = Number.parseInt(cursor, 10);
|
|
45
|
+
if (Number.isNaN(index) || index < 0) return 0;
|
|
46
|
+
return index;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Encodes an index into a cursor string
|
|
50
|
+
* @param index - Start index to encode
|
|
51
|
+
* @returns Cursor string (e.g., "10")
|
|
52
|
+
*/
|
|
53
|
+
static encodeCursor(index) {
|
|
54
|
+
return index.toString();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Paginates an array of items
|
|
58
|
+
* @param items - All items to paginate
|
|
59
|
+
* @param cursor - Optional cursor representing the start index
|
|
60
|
+
* @param pageSize - Number of items per page (default: 10)
|
|
61
|
+
* @param includeMeta - Whether to include metadata in response (default: true)
|
|
62
|
+
* @returns Paginated result with items and optional nextCursor
|
|
63
|
+
*/
|
|
64
|
+
static paginate(items, cursor, pageSize = PaginationHelper.DEFAULT_PAGE_SIZE, includeMeta = true) {
|
|
65
|
+
const startIndex = PaginationHelper.decodeCursor(cursor);
|
|
66
|
+
const endIndex = startIndex + pageSize;
|
|
67
|
+
const result = {
|
|
68
|
+
items: items.slice(startIndex, endIndex),
|
|
69
|
+
nextCursor: endIndex < items.length ? PaginationHelper.encodeCursor(endIndex) : void 0
|
|
70
|
+
};
|
|
71
|
+
if (includeMeta) result._meta = {
|
|
72
|
+
total: items.length,
|
|
73
|
+
offset: startIndex,
|
|
74
|
+
limit: pageSize
|
|
75
|
+
};
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
31
81
|
//#region src/services/FileSystemService.ts
|
|
32
82
|
var FileSystemService = class {
|
|
33
83
|
async pathExists(path$2) {
|
|
@@ -69,9 +119,11 @@ var BoilerplateService = class {
|
|
|
69
119
|
this.scaffoldService = new require_ScaffoldService.ScaffoldService(fileSystemService, new require_ScaffoldConfigLoader.ScaffoldConfigLoader(fileSystemService, this.templateService), new require_VariableReplacementService.VariableReplacementService(fileSystemService, this.templateService), templatesPath);
|
|
70
120
|
}
|
|
71
121
|
/**
|
|
72
|
-
* Scans all scaffold.yaml files and returns available boilerplates
|
|
122
|
+
* Scans all scaffold.yaml files and returns available boilerplates with pagination
|
|
123
|
+
* @param cursor - Optional pagination cursor
|
|
124
|
+
* @returns Paginated list of boilerplates
|
|
73
125
|
*/
|
|
74
|
-
async listBoilerplates() {
|
|
126
|
+
async listBoilerplates(cursor) {
|
|
75
127
|
const boilerplates = [];
|
|
76
128
|
const templateDirs = await this.discoverTemplateDirectories();
|
|
77
129
|
for (const templatePath of templateDirs) {
|
|
@@ -98,7 +150,12 @@ var BoilerplateService = class {
|
|
|
98
150
|
__agiflowai_aicode_utils.log.warn(`Failed to load scaffold.yaml for ${templatePath}:`, error);
|
|
99
151
|
}
|
|
100
152
|
}
|
|
101
|
-
|
|
153
|
+
const paginatedResult = PaginationHelper.paginate(boilerplates, cursor);
|
|
154
|
+
return {
|
|
155
|
+
boilerplates: paginatedResult.items,
|
|
156
|
+
nextCursor: paginatedResult.nextCursor,
|
|
157
|
+
_meta: paginatedResult._meta
|
|
158
|
+
};
|
|
102
159
|
}
|
|
103
160
|
/**
|
|
104
161
|
* Dynamically discovers template directories by finding all directories
|
|
@@ -185,9 +242,12 @@ var BoilerplateService = class {
|
|
|
185
242
|
const projectPath = node_path.join(targetFolder, folderName);
|
|
186
243
|
await __agiflowai_aicode_utils.ProjectConfigResolver.createProjectJson(projectPath, folderName, boilerplate.template_path);
|
|
187
244
|
}
|
|
245
|
+
const processedInstruction = boilerplate.instruction ? this.processBoilerplateInstruction(boilerplate.instruction, variables) : "";
|
|
246
|
+
let enhancedMessage = result.message;
|
|
247
|
+
if (processedInstruction) enhancedMessage += `\n\nPlease follow this **instruction**:\n${processedInstruction}`;
|
|
188
248
|
return {
|
|
189
249
|
success: result.success,
|
|
190
|
-
message:
|
|
250
|
+
message: enhancedMessage,
|
|
191
251
|
warnings: result.warnings,
|
|
192
252
|
createdFiles: result.createdFiles,
|
|
193
253
|
existingFiles: result.existingFiles
|
|
@@ -1233,7 +1293,10 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
|
|
|
1233
1293
|
description: description.trim(),
|
|
1234
1294
|
inputSchema: {
|
|
1235
1295
|
type: "object",
|
|
1236
|
-
properties: {
|
|
1296
|
+
properties: { cursor: {
|
|
1297
|
+
type: "string",
|
|
1298
|
+
description: "Optional pagination cursor to fetch the next page of results. Omit to fetch the first page."
|
|
1299
|
+
} },
|
|
1237
1300
|
additionalProperties: false
|
|
1238
1301
|
}
|
|
1239
1302
|
};
|
|
@@ -1241,9 +1304,10 @@ var ListBoilerplatesTool = class ListBoilerplatesTool {
|
|
|
1241
1304
|
/**
|
|
1242
1305
|
* Execute the tool
|
|
1243
1306
|
*/
|
|
1244
|
-
async execute(
|
|
1307
|
+
async execute(args = {}) {
|
|
1245
1308
|
try {
|
|
1246
|
-
const
|
|
1309
|
+
const { cursor } = args;
|
|
1310
|
+
const result = await this.boilerplateService.listBoilerplates(cursor);
|
|
1247
1311
|
return { content: [{
|
|
1248
1312
|
type: "text",
|
|
1249
1313
|
text: JSON.stringify(result, null, 2)
|
|
@@ -1273,12 +1337,12 @@ var ScaffoldingMethodsService = class {
|
|
|
1273
1337
|
this.templatesRootPath = templatesRootPath;
|
|
1274
1338
|
this.templateService = new require_TemplateService.TemplateService();
|
|
1275
1339
|
}
|
|
1276
|
-
async listScaffoldingMethods(projectPath) {
|
|
1340
|
+
async listScaffoldingMethods(projectPath, cursor) {
|
|
1277
1341
|
const absoluteProjectPath = node_path.default.resolve(projectPath);
|
|
1278
1342
|
const sourceTemplate = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(absoluteProjectPath)).sourceTemplate;
|
|
1279
|
-
return this.listScaffoldingMethodsByTemplate(sourceTemplate);
|
|
1343
|
+
return this.listScaffoldingMethodsByTemplate(sourceTemplate, cursor);
|
|
1280
1344
|
}
|
|
1281
|
-
async listScaffoldingMethodsByTemplate(templateName) {
|
|
1345
|
+
async listScaffoldingMethodsByTemplate(templateName, cursor) {
|
|
1282
1346
|
const templatePath = await this.findTemplatePath(templateName);
|
|
1283
1347
|
if (!templatePath) throw new Error(`Template not found for sourceTemplate: ${templateName}`);
|
|
1284
1348
|
const fullTemplatePath = node_path.default.join(this.templatesRootPath, templatePath);
|
|
@@ -1302,17 +1366,20 @@ var ScaffoldingMethodsService = class {
|
|
|
1302
1366
|
generator: feature.generator
|
|
1303
1367
|
});
|
|
1304
1368
|
});
|
|
1369
|
+
const paginatedResult = PaginationHelper.paginate(methods, cursor);
|
|
1305
1370
|
return {
|
|
1306
1371
|
sourceTemplate: templateName,
|
|
1307
1372
|
templatePath,
|
|
1308
|
-
methods
|
|
1373
|
+
methods: paginatedResult.items,
|
|
1374
|
+
nextCursor: paginatedResult.nextCursor,
|
|
1375
|
+
_meta: paginatedResult._meta
|
|
1309
1376
|
};
|
|
1310
1377
|
}
|
|
1311
1378
|
/**
|
|
1312
1379
|
* Gets scaffolding methods with instructions rendered using provided variables
|
|
1313
1380
|
*/
|
|
1314
|
-
async listScaffoldingMethodsWithVariables(projectPath, variables) {
|
|
1315
|
-
const result = await this.listScaffoldingMethods(projectPath);
|
|
1381
|
+
async listScaffoldingMethodsWithVariables(projectPath, variables, cursor) {
|
|
1382
|
+
const result = await this.listScaffoldingMethods(projectPath, cursor);
|
|
1316
1383
|
const processedMethods = result.methods.map((method) => ({
|
|
1317
1384
|
...method,
|
|
1318
1385
|
instruction: method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : void 0
|
|
@@ -1424,7 +1491,7 @@ var ScaffoldingMethodsService = class {
|
|
|
1424
1491
|
success: true,
|
|
1425
1492
|
message: `
|
|
1426
1493
|
Successfully scaffolded ${scaffold_feature_name} in ${projectPath}.
|
|
1427
|
-
Please follow this **instruction**: \n ${method.instruction}.
|
|
1494
|
+
Please follow this **instruction**: \n ${method.instruction ? this.processScaffoldInstruction(method.instruction, variables) : ""}.
|
|
1428
1495
|
-> Create or update the plan based on the instruction.
|
|
1429
1496
|
`,
|
|
1430
1497
|
warnings: result.warnings,
|
|
@@ -1453,7 +1520,10 @@ var ListScaffoldingMethodsTool = class ListScaffoldingMethodsTool {
|
|
|
1453
1520
|
*/
|
|
1454
1521
|
getDefinition() {
|
|
1455
1522
|
const description = this.templateService.renderString(description_default$1, { isMonolith: this.isMonolith });
|
|
1456
|
-
const properties = {
|
|
1523
|
+
const properties = { cursor: {
|
|
1524
|
+
type: "string",
|
|
1525
|
+
description: "Optional pagination cursor to fetch the next page of results. Omit to fetch the first page."
|
|
1526
|
+
} };
|
|
1457
1527
|
if (!this.isMonolith) {
|
|
1458
1528
|
properties.projectPath = {
|
|
1459
1529
|
type: "string",
|
|
@@ -1479,18 +1549,18 @@ var ListScaffoldingMethodsTool = class ListScaffoldingMethodsTool {
|
|
|
1479
1549
|
*/
|
|
1480
1550
|
async execute(args) {
|
|
1481
1551
|
try {
|
|
1482
|
-
const { projectPath, templateName } = args;
|
|
1552
|
+
const { projectPath, templateName, cursor } = args;
|
|
1483
1553
|
let result;
|
|
1484
1554
|
if (this.isMonolith) try {
|
|
1485
1555
|
const resolvedTemplateName = (await __agiflowai_aicode_utils.ProjectConfigResolver.resolveProjectConfig(process.cwd())).sourceTemplate;
|
|
1486
|
-
result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(resolvedTemplateName);
|
|
1556
|
+
result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(resolvedTemplateName, cursor);
|
|
1487
1557
|
} catch (error) {
|
|
1488
1558
|
throw new Error(`Failed to read template name from configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
1489
1559
|
}
|
|
1490
1560
|
else {
|
|
1491
1561
|
if (!projectPath && !templateName) throw new Error("Either projectPath or templateName must be provided");
|
|
1492
|
-
if (projectPath) result = await this.scaffoldingMethodsService.listScaffoldingMethods(projectPath);
|
|
1493
|
-
else result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(templateName);
|
|
1562
|
+
if (projectPath) result = await this.scaffoldingMethodsService.listScaffoldingMethods(projectPath, cursor);
|
|
1563
|
+
else result = await this.scaffoldingMethodsService.listScaffoldingMethodsByTemplate(templateName, cursor);
|
|
1494
1564
|
}
|
|
1495
1565
|
return { content: [{
|
|
1496
1566
|
type: "text",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agiflowai/scaffold-mcp",
|
|
3
3
|
"description": "MCP server for scaffolding applications with boilerplate templates",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"author": "AgiflowIO",
|
|
7
7
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"pino": "^10.0.0",
|
|
49
49
|
"pino-pretty": "^13.1.1",
|
|
50
50
|
"zod": "3.25.76",
|
|
51
|
-
"@agiflowai/aicode-utils": "1.0.
|
|
51
|
+
"@agiflowai/aicode-utils": "1.0.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/express": "^5.0.0",
|