@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.
- package/README.md +11 -71
- package/dist/ScaffoldConfigLoader-CI0T6zdG.js +142 -0
- package/dist/{ScaffoldConfigLoader-DzcV5a_c.cjs → ScaffoldConfigLoader-DQMCLVGD.cjs} +1 -1
- package/dist/ScaffoldConfigLoader-DhthV6xq.js +3 -0
- package/dist/ScaffoldService-B3En_m4t.cjs +3 -0
- package/dist/{ScaffoldService-BgFWAOLQ.cjs → ScaffoldService-BwDmXt83.cjs} +17 -8
- package/dist/ScaffoldService-CJ3vNmAj.js +3 -0
- package/dist/ScaffoldService-DB7-Cyod.js +293 -0
- package/dist/TemplateService-BZRt3NI8.cjs +3 -0
- package/dist/TemplateService-CiZJA06s.js +79 -0
- package/dist/TemplateService-DropYdp8.js +3 -0
- package/dist/VariableReplacementService-BAwTGv_R.js +3 -0
- package/dist/{VariableReplacementService-YUpL5nAC.cjs → VariableReplacementService-CroHkMha.cjs} +1 -1
- package/dist/{VariableReplacementService-ClshNY_C.cjs → VariableReplacementService-D0QnWKUW.cjs} +2 -2
- package/dist/VariableReplacementService-DRxd9ILB.js +66 -0
- package/dist/cli.cjs +779 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +774 -0
- package/dist/index.cjs +38 -3208
- package/dist/index.d.cts +814 -0
- package/dist/index.d.ts +815 -0
- package/dist/index.js +137 -0
- package/dist/stdio-Bxn4A1IU.js +2073 -0
- package/dist/stdio-TGsG8akc.cjs +2178 -0
- package/package.json +19 -5
- package/dist/ScaffoldService-BvD9WvRi.cjs +0 -3
- package/dist/TemplateService-B5EZjPB0.cjs +0 -3
- /package/dist/{ScaffoldConfigLoader-1Pcv9cxm.cjs → ScaffoldConfigLoader-BrmvENTo.cjs} +0 -0
- /package/dist/{TemplateService-_KpkoLfZ.cjs → TemplateService-DRubcvS9.cjs} +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { BoilerplateGeneratorService, BoilerplateService, FileSystemService, GenerateBoilerplateFileTool, GenerateBoilerplateTool, GenerateFeatureScaffoldTool, HttpTransportHandler, ListBoilerplatesTool, ListScaffoldingMethodsTool, ScaffoldGeneratorService, ScaffoldingMethodsService, SseTransportHandler, StdioTransportHandler, UseBoilerplateTool, UseScaffoldMethodTool, WriteToFileTool } from "./stdio-Bxn4A1IU.js";
|
|
2
|
+
import { ScaffoldConfigLoader } from "./ScaffoldConfigLoader-CI0T6zdG.js";
|
|
3
|
+
import { ScaffoldProcessingService, ScaffoldService } from "./ScaffoldService-DB7-Cyod.js";
|
|
4
|
+
import { TemplateService } from "./TemplateService-CiZJA06s.js";
|
|
5
|
+
import { VariableReplacementService } from "./VariableReplacementService-DRxd9ILB.js";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import * as fs$1 from "fs-extra";
|
|
8
|
+
import { execa } from "execa";
|
|
9
|
+
|
|
10
|
+
//#region src/utils/git.ts
|
|
11
|
+
/**
|
|
12
|
+
* Execute a git command safely using execa to prevent command injection
|
|
13
|
+
*/
|
|
14
|
+
async function execGit(args, cwd) {
|
|
15
|
+
try {
|
|
16
|
+
await execa("git", args, { cwd });
|
|
17
|
+
} catch (error) {
|
|
18
|
+
const execaError = error;
|
|
19
|
+
throw new Error(`Git command failed: ${execaError.stderr || execaError.message}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Find the workspace root by searching upwards for .git folder
|
|
24
|
+
* Returns null if no .git folder is found (indicating a new project setup is needed)
|
|
25
|
+
*/
|
|
26
|
+
async function findWorkspaceRoot(startPath = process.cwd()) {
|
|
27
|
+
let currentPath = path.resolve(startPath);
|
|
28
|
+
const rootPath = path.parse(currentPath).root;
|
|
29
|
+
while (true) {
|
|
30
|
+
const gitPath = path.join(currentPath, ".git");
|
|
31
|
+
if (await fs$1.pathExists(gitPath)) return currentPath;
|
|
32
|
+
if (currentPath === rootPath) return null;
|
|
33
|
+
currentPath = path.dirname(currentPath);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse GitHub URL to detect if it's a subdirectory
|
|
38
|
+
* Supports formats:
|
|
39
|
+
* - https://github.com/user/repo
|
|
40
|
+
* - https://github.com/user/repo/tree/branch/path/to/dir
|
|
41
|
+
* - https://github.com/user/repo/tree/main/path/to/dir
|
|
42
|
+
*/
|
|
43
|
+
function parseGitHubUrl(url) {
|
|
44
|
+
const treeMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)$/);
|
|
45
|
+
const blobMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+)$/);
|
|
46
|
+
const rootMatch = url.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
47
|
+
if (treeMatch || blobMatch) {
|
|
48
|
+
const match = treeMatch || blobMatch;
|
|
49
|
+
return {
|
|
50
|
+
owner: match?.[1],
|
|
51
|
+
repo: match?.[2],
|
|
52
|
+
repoUrl: `https://github.com/${match?.[1]}/${match?.[2]}.git`,
|
|
53
|
+
branch: match?.[3],
|
|
54
|
+
subdirectory: match?.[4],
|
|
55
|
+
isSubdirectory: true
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (rootMatch) return {
|
|
59
|
+
owner: rootMatch[1],
|
|
60
|
+
repo: rootMatch[2],
|
|
61
|
+
repoUrl: `https://github.com/${rootMatch[1]}/${rootMatch[2]}.git`,
|
|
62
|
+
isSubdirectory: false
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
repoUrl: url,
|
|
66
|
+
isSubdirectory: false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Clone a subdirectory from a git repository using sparse checkout
|
|
71
|
+
*/
|
|
72
|
+
async function cloneSubdirectory(repoUrl, branch, subdirectory, targetFolder) {
|
|
73
|
+
const tempFolder = `${targetFolder}.tmp`;
|
|
74
|
+
try {
|
|
75
|
+
await execGit(["init", tempFolder]);
|
|
76
|
+
await execGit([
|
|
77
|
+
"remote",
|
|
78
|
+
"add",
|
|
79
|
+
"origin",
|
|
80
|
+
repoUrl
|
|
81
|
+
], tempFolder);
|
|
82
|
+
await execGit([
|
|
83
|
+
"config",
|
|
84
|
+
"core.sparseCheckout",
|
|
85
|
+
"true"
|
|
86
|
+
], tempFolder);
|
|
87
|
+
const sparseCheckoutFile = path.join(tempFolder, ".git", "info", "sparse-checkout");
|
|
88
|
+
await fs$1.writeFile(sparseCheckoutFile, `${subdirectory}\n`);
|
|
89
|
+
await execGit([
|
|
90
|
+
"pull",
|
|
91
|
+
"--depth=1",
|
|
92
|
+
"origin",
|
|
93
|
+
branch
|
|
94
|
+
], tempFolder);
|
|
95
|
+
const sourceDir = path.join(tempFolder, subdirectory);
|
|
96
|
+
if (!await fs$1.pathExists(sourceDir)) throw new Error(`Subdirectory '${subdirectory}' not found in repository at branch '${branch}'`);
|
|
97
|
+
if (await fs$1.pathExists(targetFolder)) throw new Error(`Target folder already exists: ${targetFolder}`);
|
|
98
|
+
await fs$1.move(sourceDir, targetFolder);
|
|
99
|
+
await fs$1.remove(tempFolder);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (await fs$1.pathExists(tempFolder)) await fs$1.remove(tempFolder);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Clone entire repository
|
|
107
|
+
*/
|
|
108
|
+
async function cloneRepository(repoUrl, targetFolder) {
|
|
109
|
+
await execGit([
|
|
110
|
+
"clone",
|
|
111
|
+
repoUrl,
|
|
112
|
+
targetFolder
|
|
113
|
+
]);
|
|
114
|
+
const gitFolder = path.join(targetFolder, ".git");
|
|
115
|
+
if (await fs$1.pathExists(gitFolder)) await fs$1.remove(gitFolder);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Fetch directory listing from GitHub API
|
|
119
|
+
*/
|
|
120
|
+
async function fetchGitHubDirectoryContents(owner, repo, path$1, branch = "main") {
|
|
121
|
+
const url = `https://api.github.com/repos/${owner}/${repo}/contents/${path$1}?ref=${branch}`;
|
|
122
|
+
const response = await fetch(url, { headers: {
|
|
123
|
+
Accept: "application/vnd.github.v3+json",
|
|
124
|
+
"User-Agent": "scaffold-mcp"
|
|
125
|
+
} });
|
|
126
|
+
if (!response.ok) throw new Error(`Failed to fetch directory contents: ${response.statusText}`);
|
|
127
|
+
const data = await response.json();
|
|
128
|
+
if (!Array.isArray(data)) throw new Error("Expected directory but got file");
|
|
129
|
+
return data.map((item) => ({
|
|
130
|
+
name: item.name,
|
|
131
|
+
type: item.type,
|
|
132
|
+
path: item.path
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
export { BoilerplateGeneratorService, BoilerplateService, FileSystemService, GenerateBoilerplateFileTool, GenerateBoilerplateTool, GenerateFeatureScaffoldTool, HttpTransportHandler, ListBoilerplatesTool, ListScaffoldingMethodsTool, ScaffoldConfigLoader, ScaffoldGeneratorService, ScaffoldProcessingService, ScaffoldService, ScaffoldingMethodsService, SseTransportHandler, StdioTransportHandler, TemplateService, UseBoilerplateTool, UseScaffoldMethodTool, VariableReplacementService, WriteToFileTool, cloneRepository, cloneSubdirectory, fetchGitHubDirectoryContents, findWorkspaceRoot, parseGitHubUrl };
|