@agiflowai/scaffold-mcp 0.6.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +11 -71
  2. package/dist/ScaffoldConfigLoader-CI0T6zdG.js +142 -0
  3. package/dist/{ScaffoldConfigLoader-DzcV5a_c.cjs → ScaffoldConfigLoader-DQMCLVGD.cjs} +1 -1
  4. package/dist/ScaffoldConfigLoader-DhthV6xq.js +3 -0
  5. package/dist/ScaffoldService-B3En_m4t.cjs +3 -0
  6. package/dist/{ScaffoldService-BgFWAOLQ.cjs → ScaffoldService-BwDmXt83.cjs} +17 -8
  7. package/dist/ScaffoldService-CJ3vNmAj.js +3 -0
  8. package/dist/ScaffoldService-DB7-Cyod.js +293 -0
  9. package/dist/TemplateService-BZRt3NI8.cjs +3 -0
  10. package/dist/TemplateService-CiZJA06s.js +79 -0
  11. package/dist/TemplateService-DropYdp8.js +3 -0
  12. package/dist/VariableReplacementService-BAwTGv_R.js +3 -0
  13. package/dist/{VariableReplacementService-YUpL5nAC.cjs → VariableReplacementService-CroHkMha.cjs} +1 -1
  14. package/dist/{VariableReplacementService-ClshNY_C.cjs → VariableReplacementService-D0QnWKUW.cjs} +2 -2
  15. package/dist/VariableReplacementService-DRxd9ILB.js +66 -0
  16. package/dist/cli.cjs +779 -0
  17. package/dist/cli.d.cts +1 -0
  18. package/dist/cli.d.ts +1 -0
  19. package/dist/cli.js +774 -0
  20. package/dist/index.cjs +38 -3208
  21. package/dist/index.d.cts +814 -0
  22. package/dist/index.d.ts +815 -0
  23. package/dist/index.js +137 -0
  24. package/dist/stdio-Bxn4A1IU.js +2073 -0
  25. package/dist/stdio-TGsG8akc.cjs +2178 -0
  26. package/package.json +19 -5
  27. package/dist/ScaffoldService-BvD9WvRi.cjs +0 -3
  28. package/dist/TemplateService-B5EZjPB0.cjs +0 -3
  29. /package/dist/{ScaffoldConfigLoader-1Pcv9cxm.cjs → ScaffoldConfigLoader-BrmvENTo.cjs} +0 -0
  30. /package/dist/{TemplateService-_KpkoLfZ.cjs → TemplateService-DRubcvS9.cjs} +0 -0
@@ -0,0 +1,79 @@
1
+ import { log } from "@agiflowai/aicode-utils";
2
+ import { Liquid } from "liquidjs";
3
+
4
+ //#region src/services/TemplateService.ts
5
+ var TemplateService = class {
6
+ liquid;
7
+ constructor() {
8
+ this.liquid = new Liquid({
9
+ strictFilters: false,
10
+ strictVariables: false
11
+ });
12
+ this.setupCustomFilters();
13
+ log.info("TemplateService initialized");
14
+ }
15
+ toPascalCase(str) {
16
+ const camelCase = str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "");
17
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
18
+ }
19
+ setupCustomFilters() {
20
+ this.liquid.registerFilter("camelCase", (str) => {
21
+ return str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "");
22
+ });
23
+ this.liquid.registerFilter("pascalCase", (str) => {
24
+ return this.toPascalCase(str);
25
+ });
26
+ this.liquid.registerFilter("titleCase", (str) => {
27
+ return this.toPascalCase(str);
28
+ });
29
+ this.liquid.registerFilter("kebabCase", (str) => {
30
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
31
+ });
32
+ this.liquid.registerFilter("snakeCase", (str) => {
33
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
34
+ });
35
+ this.liquid.registerFilter("upperCase", (str) => {
36
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toUpperCase();
37
+ });
38
+ this.liquid.registerFilter("lower", (str) => str.toLowerCase());
39
+ this.liquid.registerFilter("upper", (str) => str.toUpperCase());
40
+ this.liquid.registerFilter("pluralize", (str) => {
41
+ if (str.endsWith("y")) return `${str.slice(0, -1)}ies`;
42
+ else if (str.endsWith("s") || str.endsWith("sh") || str.endsWith("ch") || str.endsWith("x") || str.endsWith("z")) return `${str}es`;
43
+ else return `${str}s`;
44
+ });
45
+ this.liquid.registerFilter("singularize", (str) => {
46
+ if (str.endsWith("ies")) return `${str.slice(0, -3)}y`;
47
+ else if (str.endsWith("es")) return str.slice(0, -2);
48
+ else if (str.endsWith("s") && !str.endsWith("ss")) return str.slice(0, -1);
49
+ else return str;
50
+ });
51
+ this.liquid.registerFilter("strip", (str) => {
52
+ return str.trim();
53
+ });
54
+ }
55
+ renderString(template, variables) {
56
+ try {
57
+ log.debug("Rendering template", {
58
+ variables,
59
+ templatePreview: template.substring(0, 100)
60
+ });
61
+ const result = this.liquid.parseAndRenderSync(template, variables);
62
+ log.debug("Rendered template", { resultPreview: result.substring(0, 100) });
63
+ return result;
64
+ } catch (error) {
65
+ log.error("LiquidJS rendering error", {
66
+ error: error instanceof Error ? error.message : String(error),
67
+ templatePreview: template.substring(0, 200),
68
+ variables
69
+ });
70
+ return template;
71
+ }
72
+ }
73
+ containsTemplateVariables(content) {
74
+ return [/\{\{.*?\}\}/, /\{%.*?%\}/].some((pattern) => pattern.test(content));
75
+ }
76
+ };
77
+
78
+ //#endregion
79
+ export { TemplateService };
@@ -0,0 +1,3 @@
1
+ import { TemplateService } from "./TemplateService-CiZJA06s.js";
2
+
3
+ export { TemplateService };
@@ -0,0 +1,3 @@
1
+ import { VariableReplacementService } from "./VariableReplacementService-DRxd9ILB.js";
2
+
3
+ export { VariableReplacementService };
@@ -1,3 +1,3 @@
1
- const require_VariableReplacementService = require('./VariableReplacementService-ClshNY_C.cjs');
1
+ const require_VariableReplacementService = require('./VariableReplacementService-D0QnWKUW.cjs');
2
2
 
3
3
  exports.VariableReplacementService = require_VariableReplacementService.VariableReplacementService;
@@ -1,8 +1,8 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- let node_path = require("node:path");
3
- node_path = require_chunk.__toESM(node_path);
4
2
  let __agiflowai_aicode_utils = require("@agiflowai/aicode-utils");
5
3
  __agiflowai_aicode_utils = require_chunk.__toESM(__agiflowai_aicode_utils);
4
+ let node_path = require("node:path");
5
+ node_path = require_chunk.__toESM(node_path);
6
6
 
7
7
  //#region src/services/VariableReplacementService.ts
8
8
  var VariableReplacementService = class {
@@ -0,0 +1,66 @@
1
+ import { log } from "@agiflowai/aicode-utils";
2
+ import path from "node:path";
3
+
4
+ //#region src/services/VariableReplacementService.ts
5
+ var VariableReplacementService = class {
6
+ binaryExtensions = [
7
+ ".png",
8
+ ".jpg",
9
+ ".jpeg",
10
+ ".gif",
11
+ ".ico",
12
+ ".woff",
13
+ ".woff2",
14
+ ".ttf",
15
+ ".eot",
16
+ ".pdf",
17
+ ".zip",
18
+ ".tar",
19
+ ".gz",
20
+ ".exe",
21
+ ".dll",
22
+ ".so",
23
+ ".dylib"
24
+ ];
25
+ constructor(fileSystem, templateService) {
26
+ this.fileSystem = fileSystem;
27
+ this.templateService = templateService;
28
+ }
29
+ async processFilesForVariableReplacement(dirPath, variables) {
30
+ let items = [];
31
+ try {
32
+ items = await this.fileSystem.readdir(dirPath);
33
+ } catch (error) {
34
+ log.warn(`Skipping directory ${dirPath}: ${error}`);
35
+ return;
36
+ }
37
+ for (const item of items) {
38
+ if (!item) continue;
39
+ const itemPath = path.join(dirPath, item);
40
+ try {
41
+ const stat = await this.fileSystem.stat(itemPath);
42
+ if (stat.isDirectory()) await this.processFilesForVariableReplacement(itemPath, variables);
43
+ else if (stat.isFile()) await this.replaceVariablesInFile(itemPath, variables);
44
+ } catch (error) {
45
+ log.warn(`Skipping item ${itemPath}: ${error}`);
46
+ }
47
+ }
48
+ }
49
+ async replaceVariablesInFile(filePath, variables) {
50
+ try {
51
+ if (this.isBinaryFile(filePath)) return;
52
+ const content = await this.fileSystem.readFile(filePath, "utf8");
53
+ const renderedContent = this.templateService.renderString(content, variables);
54
+ await this.fileSystem.writeFile(filePath, renderedContent, "utf8");
55
+ } catch (error) {
56
+ log.warn(`Skipping file ${filePath}: ${error}`);
57
+ }
58
+ }
59
+ isBinaryFile(filePath) {
60
+ const ext = path.extname(filePath).toLowerCase();
61
+ return this.binaryExtensions.includes(ext);
62
+ }
63
+ };
64
+
65
+ //#endregion
66
+ export { VariableReplacementService };