@untools/devflow 0.2.11 → 0.2.12
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/agent/client.d.ts +50 -0
- package/dist/agent/client.d.ts.map +1 -0
- package/dist/agent/client.js +52 -0
- package/dist/agent/client.js.map +1 -0
- package/dist/auth/github-token.d.ts +16 -0
- package/dist/auth/github-token.d.ts.map +1 -0
- package/dist/auth/github-token.js +69 -0
- package/dist/auth/github-token.js.map +1 -0
- package/dist/auth/oauth.d.ts +16 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +146 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +363 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +78 -0
- package/dist/config.js.map +1 -0
- package/dist/copilot/client.d.ts +75 -0
- package/dist/copilot/client.d.ts.map +1 -0
- package/dist/copilot/client.js +226 -0
- package/dist/copilot/client.js.map +1 -0
- package/dist/copilot/flows/base.d.ts +47 -0
- package/dist/copilot/flows/base.d.ts.map +1 -0
- package/dist/copilot/flows/base.js +235 -0
- package/dist/copilot/flows/base.js.map +1 -0
- package/dist/copilot/flows/explain.d.ts +5 -0
- package/dist/copilot/flows/explain.d.ts.map +1 -0
- package/dist/copilot/flows/explain.js +76 -0
- package/dist/copilot/flows/explain.js.map +1 -0
- package/dist/copilot/flows/feature.d.ts +5 -0
- package/dist/copilot/flows/feature.d.ts.map +1 -0
- package/dist/copilot/flows/feature.js +83 -0
- package/dist/copilot/flows/feature.js.map +1 -0
- package/dist/copilot/flows/fix-bug.d.ts +5 -0
- package/dist/copilot/flows/fix-bug.d.ts.map +1 -0
- package/dist/copilot/flows/fix-bug.js +56 -0
- package/dist/copilot/flows/fix-bug.js.map +1 -0
- package/dist/copilot/flows/index.d.ts +17 -0
- package/dist/copilot/flows/index.d.ts.map +1 -0
- package/dist/copilot/flows/index.js +41 -0
- package/dist/copilot/flows/index.js.map +1 -0
- package/dist/copilot/flows/review-pr.d.ts +5 -0
- package/dist/copilot/flows/review-pr.d.ts.map +1 -0
- package/dist/copilot/flows/review-pr.js +84 -0
- package/dist/copilot/flows/review-pr.js.map +1 -0
- package/dist/copilot/session-registry.d.ts +12 -0
- package/dist/copilot/session-registry.d.ts.map +1 -0
- package/dist/copilot/session-registry.js +39 -0
- package/dist/copilot/session-registry.js.map +1 -0
- package/dist/copilot/tools/files.d.ts +53 -0
- package/dist/copilot/tools/files.d.ts.map +1 -0
- package/dist/copilot/tools/files.js +250 -0
- package/dist/copilot/tools/files.js.map +1 -0
- package/dist/copilot/tools/git.d.ts +37 -0
- package/dist/copilot/tools/git.d.ts.map +1 -0
- package/dist/copilot/tools/git.js +246 -0
- package/dist/copilot/tools/git.js.map +1 -0
- package/dist/copilot/tools/github.d.ts +36 -0
- package/dist/copilot/tools/github.d.ts.map +1 -0
- package/dist/copilot/tools/github.js +216 -0
- package/dist/copilot/tools/github.js.map +1 -0
- package/dist/copilot/tools/index.d.ts +26 -0
- package/dist/copilot/tools/index.d.ts.map +1 -0
- package/dist/copilot/tools/index.js +25 -0
- package/dist/copilot/tools/index.js.map +1 -0
- package/dist/copilot/tools/progress.d.ts +19 -0
- package/dist/copilot/tools/progress.d.ts.map +1 -0
- package/dist/copilot/tools/progress.js +87 -0
- package/dist/copilot/tools/progress.js.map +1 -0
- package/dist/copilot/tools/tests.d.ts +29 -0
- package/dist/copilot/tools/tests.d.ts.map +1 -0
- package/dist/copilot/tools/tests.js +136 -0
- package/dist/copilot/tools/tests.js.map +1 -0
- package/dist/copilot/tools/utils.d.ts +14 -0
- package/dist/copilot/tools/utils.d.ts.map +1 -0
- package/dist/copilot/tools/utils.js +89 -0
- package/dist/copilot/tools/utils.js.map +1 -0
- package/dist/credentials.d.ts +21 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +62 -0
- package/dist/credentials.js.map +1 -0
- package/dist/devflow/client.d.ts +16 -0
- package/dist/devflow/client.d.ts.map +1 -0
- package/dist/devflow/client.js +61 -0
- package/dist/devflow/client.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/pinga/client.d.ts +16 -0
- package/dist/pinga/client.d.ts.map +1 -0
- package/dist/pinga/client.js +61 -0
- package/dist/pinga/client.js.map +1 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/verify-full-flow.d.ts +2 -0
- package/dist/verify-full-flow.d.ts.map +1 -0
- package/dist/verify-full-flow.js +81 -0
- package/dist/verify-full-flow.js.map +1 -0
- package/package.json +8 -1
- package/.versionrc.json +0 -53
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { readFile, writeFile, fileExists, listFiles, } from "./utils.js";
|
|
3
|
+
export class FileManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.maxDefaultSize = 1024 * 1024; // 1MB
|
|
6
|
+
}
|
|
7
|
+
async readFile(input) {
|
|
8
|
+
try {
|
|
9
|
+
const fullPath = path.join(input.repoPath, input.filePath);
|
|
10
|
+
const exists = await fileExists(fullPath);
|
|
11
|
+
if (!exists) {
|
|
12
|
+
return {
|
|
13
|
+
success: false,
|
|
14
|
+
size: 0,
|
|
15
|
+
error: `File not found: ${input.filePath}`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const content = await readFile(fullPath);
|
|
19
|
+
const size = Buffer.byteLength(content);
|
|
20
|
+
const maxSize = input.maxSize || this.maxDefaultSize;
|
|
21
|
+
let truncated = false;
|
|
22
|
+
let finalContent = content;
|
|
23
|
+
if (size > maxSize) {
|
|
24
|
+
finalContent = content.substring(0, maxSize);
|
|
25
|
+
truncated = true;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
success: true,
|
|
29
|
+
content: finalContent,
|
|
30
|
+
size,
|
|
31
|
+
truncated,
|
|
32
|
+
language: this.detectLanguage(input.filePath),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return {
|
|
37
|
+
success: false,
|
|
38
|
+
size: 0,
|
|
39
|
+
error: error instanceof Error ? error.message : String(error),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async writeFile(input) {
|
|
44
|
+
try {
|
|
45
|
+
const fullPath = path.join(input.repoPath, input.filePath);
|
|
46
|
+
const content = input.content;
|
|
47
|
+
const bytesWritten = Buffer.byteLength(content);
|
|
48
|
+
await writeFile(fullPath, content);
|
|
49
|
+
return {
|
|
50
|
+
success: true,
|
|
51
|
+
filePath: input.filePath,
|
|
52
|
+
bytesWritten,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
filePath: input.filePath,
|
|
59
|
+
bytesWritten: 0,
|
|
60
|
+
error: error instanceof Error ? error.message : String(error),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async listFiles(input) {
|
|
65
|
+
try {
|
|
66
|
+
let pattern;
|
|
67
|
+
if (input.pattern) {
|
|
68
|
+
// Convert glob-like pattern to regex
|
|
69
|
+
const regexPattern = input.pattern
|
|
70
|
+
.replace(/\./g, "\\.")
|
|
71
|
+
.replace(/\*/g, ".*")
|
|
72
|
+
.replace(/\?/g, ".");
|
|
73
|
+
pattern = new RegExp(regexPattern);
|
|
74
|
+
}
|
|
75
|
+
const files = await listFiles(input.repoPath, pattern);
|
|
76
|
+
const maxResults = input.maxResults || 100;
|
|
77
|
+
const truncated = files.length > maxResults;
|
|
78
|
+
const finalFiles = files.slice(0, maxResults);
|
|
79
|
+
return {
|
|
80
|
+
success: true,
|
|
81
|
+
files: finalFiles,
|
|
82
|
+
count: finalFiles.length,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
files: [],
|
|
89
|
+
count: 0,
|
|
90
|
+
error: error instanceof Error ? error.message : String(error),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
detectLanguage(filePath) {
|
|
95
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
96
|
+
const languageMap = {
|
|
97
|
+
".ts": "typescript",
|
|
98
|
+
".tsx": "typescript",
|
|
99
|
+
".js": "javascript",
|
|
100
|
+
".jsx": "javascript",
|
|
101
|
+
".py": "python",
|
|
102
|
+
".go": "go",
|
|
103
|
+
".rs": "rust",
|
|
104
|
+
".java": "java",
|
|
105
|
+
".cpp": "cpp",
|
|
106
|
+
".c": "c",
|
|
107
|
+
".h": "c",
|
|
108
|
+
".hpp": "cpp",
|
|
109
|
+
".json": "json",
|
|
110
|
+
".yaml": "yaml",
|
|
111
|
+
".yml": "yaml",
|
|
112
|
+
".xml": "xml",
|
|
113
|
+
".html": "html",
|
|
114
|
+
".css": "css",
|
|
115
|
+
".scss": "scss",
|
|
116
|
+
".sh": "bash",
|
|
117
|
+
".md": "markdown",
|
|
118
|
+
".sql": "sql",
|
|
119
|
+
};
|
|
120
|
+
return languageMap[ext] || "text";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Factory function for Copilot SDK tool definition - Read File
|
|
124
|
+
export function createReadFileTool(options) {
|
|
125
|
+
const fileManager = new FileManager();
|
|
126
|
+
return {
|
|
127
|
+
name: "read_file",
|
|
128
|
+
description: "Read contents of a file from a repository",
|
|
129
|
+
parameters: {
|
|
130
|
+
type: "object",
|
|
131
|
+
properties: {
|
|
132
|
+
repoPath: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "Repository path",
|
|
135
|
+
},
|
|
136
|
+
filePath: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "File path relative to repository root",
|
|
139
|
+
},
|
|
140
|
+
maxSize: {
|
|
141
|
+
type: "number",
|
|
142
|
+
description: "Maximum file size to read in bytes (default: 1MB)",
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
required: ["repoPath", "filePath"],
|
|
146
|
+
},
|
|
147
|
+
handler: async (input) => {
|
|
148
|
+
try {
|
|
149
|
+
if (options?.localPath)
|
|
150
|
+
input.repoPath = options.localPath;
|
|
151
|
+
return await fileManager.readFile(input);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
return {
|
|
155
|
+
success: false,
|
|
156
|
+
size: 0,
|
|
157
|
+
error: error instanceof Error ? error.message : String(error),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Factory function for Copilot SDK tool definition - Write File
|
|
164
|
+
export function createWriteFileTool(options) {
|
|
165
|
+
const fileManager = new FileManager();
|
|
166
|
+
return {
|
|
167
|
+
name: "write_file",
|
|
168
|
+
description: "Write or update a file in a repository",
|
|
169
|
+
parameters: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: {
|
|
172
|
+
repoPath: {
|
|
173
|
+
type: "string",
|
|
174
|
+
description: "Repository path",
|
|
175
|
+
},
|
|
176
|
+
filePath: {
|
|
177
|
+
type: "string",
|
|
178
|
+
description: "File path relative to repository root",
|
|
179
|
+
},
|
|
180
|
+
content: {
|
|
181
|
+
type: "string",
|
|
182
|
+
description: "File content",
|
|
183
|
+
},
|
|
184
|
+
createDirs: {
|
|
185
|
+
type: "boolean",
|
|
186
|
+
description: "Create parent directories if they don't exist",
|
|
187
|
+
default: true,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
required: ["repoPath", "filePath", "content"],
|
|
191
|
+
},
|
|
192
|
+
handler: async (input) => {
|
|
193
|
+
try {
|
|
194
|
+
if (options?.localPath)
|
|
195
|
+
input.repoPath = options.localPath;
|
|
196
|
+
return await fileManager.writeFile(input);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return {
|
|
200
|
+
success: false,
|
|
201
|
+
filePath: input.filePath,
|
|
202
|
+
bytesWritten: 0,
|
|
203
|
+
error: error instanceof Error ? error.message : String(error),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// Factory function for Copilot SDK tool definition - List Files
|
|
210
|
+
export function createListFilesTool(options) {
|
|
211
|
+
const fileManager = new FileManager();
|
|
212
|
+
return {
|
|
213
|
+
name: "list_files",
|
|
214
|
+
description: "List files in a repository directory",
|
|
215
|
+
parameters: {
|
|
216
|
+
type: "object",
|
|
217
|
+
properties: {
|
|
218
|
+
repoPath: {
|
|
219
|
+
type: "string",
|
|
220
|
+
description: "Repository path",
|
|
221
|
+
},
|
|
222
|
+
pattern: {
|
|
223
|
+
type: "string",
|
|
224
|
+
description: "File pattern to match (glob-like syntax)",
|
|
225
|
+
},
|
|
226
|
+
maxResults: {
|
|
227
|
+
type: "number",
|
|
228
|
+
description: "Maximum number of results to return (default: 100)",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
required: ["repoPath"],
|
|
232
|
+
},
|
|
233
|
+
handler: async (input) => {
|
|
234
|
+
try {
|
|
235
|
+
if (options?.localPath)
|
|
236
|
+
input.repoPath = options.localPath;
|
|
237
|
+
return await fileManager.listFiles(input);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
return {
|
|
241
|
+
success: false,
|
|
242
|
+
files: [],
|
|
243
|
+
count: 0,
|
|
244
|
+
error: error instanceof Error ? error.message : String(error),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/copilot/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QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,OAAgC;IAClE,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IAEtC,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,sCAAsC;QACnD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iBAAiB;iBAC/B;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0CAA0C;iBACxD;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oDAAoD;iBAClE;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB;QACD,OAAO,EAAE,KAAK,EAAE,KAAqB,EAA4B,EAAE;YACjE,IAAI,CAAC;gBACH,IAAI,OAAO,EAAE,SAAS;oBAAE,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;gBAC3D,OAAO,MAAM,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,EAAE;oBACT,KAAK,EAAE,CAAC;oBACR,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface GitOperationInput {
|
|
2
|
+
action: "clone" | "create_branch" | "commit" | "push" | "pull" | "status";
|
|
3
|
+
repo: string;
|
|
4
|
+
branchName?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
remote?: string;
|
|
7
|
+
author?: {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface GitOperationResult {
|
|
13
|
+
action: string;
|
|
14
|
+
success: boolean;
|
|
15
|
+
output?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
branchName?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class GitTool {
|
|
20
|
+
private gitInstances;
|
|
21
|
+
private getGit;
|
|
22
|
+
clone(repoUrl: string, targetPath: string, branch?: string): Promise<GitOperationResult>;
|
|
23
|
+
createBranch(repoPath: string, branchName: string, fromBranch?: string): Promise<GitOperationResult>;
|
|
24
|
+
commit(repoPath: string, message: string, author?: {
|
|
25
|
+
name: string;
|
|
26
|
+
email: string;
|
|
27
|
+
}): Promise<GitOperationResult>;
|
|
28
|
+
push(repoPath: string, remote?: string, branch?: string): Promise<GitOperationResult>;
|
|
29
|
+
pull(repoPath: string, remote?: string, branch?: string): Promise<GitOperationResult>;
|
|
30
|
+
getStatus(repoPath: string): Promise<GitOperationResult>;
|
|
31
|
+
getCurrentBranch(repoPath: string): Promise<string>;
|
|
32
|
+
cleanup(repoPath: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare function createGitOperationsTool(options?: {
|
|
35
|
+
localPath?: string;
|
|
36
|
+
}): any;
|
|
37
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/copilot/tools/git.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,GAAG,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,C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M,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/C;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CA8H7E"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import simpleGit from "simple-git";
|
|
2
|
+
import { getRepoPath, executeCommand, ToolError, removeDirectory, } from "./utils.js";
|
|
3
|
+
export class GitTool {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.gitInstances = new Map();
|
|
6
|
+
}
|
|
7
|
+
getGit(repoPath) {
|
|
8
|
+
if (!this.gitInstances.has(repoPath)) {
|
|
9
|
+
this.gitInstances.set(repoPath, simpleGit(repoPath));
|
|
10
|
+
}
|
|
11
|
+
return this.gitInstances.get(repoPath);
|
|
12
|
+
}
|
|
13
|
+
async clone(repoUrl, targetPath, branch) {
|
|
14
|
+
try {
|
|
15
|
+
const args = [repoUrl, targetPath];
|
|
16
|
+
if (branch) {
|
|
17
|
+
args.push("--branch", branch);
|
|
18
|
+
}
|
|
19
|
+
executeCommand(`git clone ${args.join(" ")}`);
|
|
20
|
+
return {
|
|
21
|
+
action: "clone",
|
|
22
|
+
success: true,
|
|
23
|
+
output: `Cloned ${repoUrl} to ${targetPath}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new ToolError(`Failed to clone repository: ${error}`, "git_clone");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async createBranch(repoPath, branchName, fromBranch = "main") {
|
|
31
|
+
try {
|
|
32
|
+
const git = this.getGit(repoPath);
|
|
33
|
+
// Ensure we're on a clean state
|
|
34
|
+
await git.fetch();
|
|
35
|
+
await git.checkout(fromBranch);
|
|
36
|
+
// Create and checkout new branch
|
|
37
|
+
await git.checkoutLocalBranch(branchName);
|
|
38
|
+
return {
|
|
39
|
+
action: "create_branch",
|
|
40
|
+
success: true,
|
|
41
|
+
branchName,
|
|
42
|
+
output: `Created branch ${branchName}`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new ToolError(`Failed to create branch: ${error}`, "git_create_branch");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async commit(repoPath, message, author) {
|
|
50
|
+
try {
|
|
51
|
+
const git = this.getGit(repoPath);
|
|
52
|
+
// Check if there are changes to commit
|
|
53
|
+
const status = await git.status();
|
|
54
|
+
if (status.files.length === 0) {
|
|
55
|
+
return {
|
|
56
|
+
action: "commit",
|
|
57
|
+
success: true,
|
|
58
|
+
output: "No changes to commit",
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Stage all changes
|
|
62
|
+
await git.add(".");
|
|
63
|
+
// Configure author if provided
|
|
64
|
+
if (author) {
|
|
65
|
+
await git.addConfig("user.name", author.name);
|
|
66
|
+
await git.addConfig("user.email", author.email);
|
|
67
|
+
}
|
|
68
|
+
// Commit
|
|
69
|
+
const result = await git.commit(message);
|
|
70
|
+
return {
|
|
71
|
+
action: "commit",
|
|
72
|
+
success: true,
|
|
73
|
+
output: `Committed with hash: ${result.commit}`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new ToolError(`Failed to commit: ${error}`, "git_commit");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async push(repoPath, remote = "origin", branch) {
|
|
81
|
+
try {
|
|
82
|
+
const git = this.getGit(repoPath);
|
|
83
|
+
// Get current branch if not specified
|
|
84
|
+
if (!branch) {
|
|
85
|
+
const branchResult = await git.revparse(["--abbrev-ref", "HEAD"]);
|
|
86
|
+
branch = branchResult.trim();
|
|
87
|
+
}
|
|
88
|
+
await git.push(remote, branch);
|
|
89
|
+
return {
|
|
90
|
+
action: "push",
|
|
91
|
+
success: true,
|
|
92
|
+
output: `Pushed branch ${branch} to ${remote}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
throw new ToolError(`Failed to push: ${error}`, "git_push");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async pull(repoPath, remote = "origin", branch) {
|
|
100
|
+
try {
|
|
101
|
+
const git = this.getGit(repoPath);
|
|
102
|
+
if (branch) {
|
|
103
|
+
await git.pull(remote, branch);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
await git.pull();
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
action: "pull",
|
|
110
|
+
success: true,
|
|
111
|
+
output: `Pulled latest changes from ${remote}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new ToolError(`Failed to pull: ${error}`, "git_pull");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async getStatus(repoPath) {
|
|
119
|
+
try {
|
|
120
|
+
const git = this.getGit(repoPath);
|
|
121
|
+
const status = await git.status();
|
|
122
|
+
return {
|
|
123
|
+
action: "status",
|
|
124
|
+
success: true,
|
|
125
|
+
output: JSON.stringify(status, null, 2),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
throw new ToolError(`Failed to get status: ${error}`, "git_status");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async getCurrentBranch(repoPath) {
|
|
133
|
+
try {
|
|
134
|
+
const git = this.getGit(repoPath);
|
|
135
|
+
const branch = await git.revparse(["--abbrev-ref", "HEAD"]);
|
|
136
|
+
return branch.trim();
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new ToolError(`Failed to get current branch: ${error}`, "git_current_branch");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async cleanup(repoPath) {
|
|
143
|
+
try {
|
|
144
|
+
this.gitInstances.delete(repoPath);
|
|
145
|
+
await removeDirectory(repoPath);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.warn(`Failed to cleanup repo: ${error}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Factory function for Copilot SDK tool definition
|
|
153
|
+
export function createGitOperationsTool(options) {
|
|
154
|
+
const gitTool = new GitTool();
|
|
155
|
+
return {
|
|
156
|
+
name: "git_operations",
|
|
157
|
+
description: "Perform git operations like clone, branch, commit, push",
|
|
158
|
+
parameters: {
|
|
159
|
+
type: "object",
|
|
160
|
+
properties: {
|
|
161
|
+
action: {
|
|
162
|
+
type: "string",
|
|
163
|
+
enum: ["clone", "create_branch", "commit", "push", "pull", "status"],
|
|
164
|
+
description: "Git operation to perform",
|
|
165
|
+
},
|
|
166
|
+
repo: {
|
|
167
|
+
type: "string",
|
|
168
|
+
description: "Repository URL (for clone) or local path (for others)",
|
|
169
|
+
},
|
|
170
|
+
branchName: {
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "Branch name (for create_branch)",
|
|
173
|
+
},
|
|
174
|
+
message: {
|
|
175
|
+
type: "string",
|
|
176
|
+
description: "Commit message (for commit)",
|
|
177
|
+
},
|
|
178
|
+
remote: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Remote name (default: origin)",
|
|
181
|
+
},
|
|
182
|
+
author: {
|
|
183
|
+
type: "object",
|
|
184
|
+
description: "Author info for commits",
|
|
185
|
+
properties: {
|
|
186
|
+
name: { type: "string" },
|
|
187
|
+
email: { type: "string" },
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
required: ["action", "repo"],
|
|
192
|
+
},
|
|
193
|
+
handler: async (input) => {
|
|
194
|
+
try {
|
|
195
|
+
switch (input.action) {
|
|
196
|
+
case "clone": {
|
|
197
|
+
// If localPath is set, we don't clone, we just return success pointing to local path
|
|
198
|
+
if (options?.localPath) {
|
|
199
|
+
return {
|
|
200
|
+
action: "clone",
|
|
201
|
+
success: true,
|
|
202
|
+
output: `Using local path: ${options.localPath} (Skipped clone)`,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const repoPath = await getRepoPath(input.repo);
|
|
206
|
+
return await gitTool.clone(input.repo, repoPath);
|
|
207
|
+
}
|
|
208
|
+
case "create_branch": {
|
|
209
|
+
const repoPath = await getRepoPath(input.repo, undefined, options?.localPath);
|
|
210
|
+
if (!input.branchName) {
|
|
211
|
+
throw new ToolError("branchName required for create_branch", "git_operations");
|
|
212
|
+
}
|
|
213
|
+
return await gitTool.createBranch(repoPath, input.branchName);
|
|
214
|
+
}
|
|
215
|
+
case "commit": {
|
|
216
|
+
const repoPath = await getRepoPath(input.repo, undefined, options?.localPath);
|
|
217
|
+
if (!input.message) {
|
|
218
|
+
throw new ToolError("message required for commit", "git_operations");
|
|
219
|
+
}
|
|
220
|
+
return await gitTool.commit(repoPath, input.message, input.author);
|
|
221
|
+
}
|
|
222
|
+
case "push": {
|
|
223
|
+
const repoPath = await getRepoPath(input.repo, undefined, options?.localPath);
|
|
224
|
+
return await gitTool.push(repoPath, input.remote, input.branchName);
|
|
225
|
+
}
|
|
226
|
+
case "pull": {
|
|
227
|
+
const repoPath = await getRepoPath(input.repo, undefined, options?.localPath);
|
|
228
|
+
return await gitTool.pull(repoPath, input.remote, input.branchName);
|
|
229
|
+
}
|
|
230
|
+
case "status": {
|
|
231
|
+
const repoPath = await getRepoPath(input.repo, undefined, options?.localPath);
|
|
232
|
+
return await gitTool.getStatus(repoPath);
|
|
233
|
+
}
|
|
234
|
+
default:
|
|
235
|
+
throw new ToolError(`Unknown action: ${input.action}`, "git_operations");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
if (error instanceof ToolError)
|
|
240
|
+
throw error;
|
|
241
|
+
throw new ToolError(`Git operation failed: ${error}`, "git_operations");
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/copilot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
|
+
body: string;
|
|
5
|
+
head: string;
|
|
6
|
+
base?: string;
|
|
7
|
+
draft?: boolean;
|
|
8
|
+
labels?: string[];
|
|
9
|
+
assignees?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface OpenPRResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
prNumber?: number;
|
|
14
|
+
prUrl?: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface PRInfo {
|
|
18
|
+
number: number;
|
|
19
|
+
title: string;
|
|
20
|
+
state: string;
|
|
21
|
+
url: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
author: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class GitHubPRManager {
|
|
26
|
+
private octokit;
|
|
27
|
+
constructor(token: string);
|
|
28
|
+
openPullRequest(input: OpenPRInput): Promise<OpenPRResult>;
|
|
29
|
+
getPullRequest(repo: string, prNumber: number): Promise<OpenPRResult & Partial<PRInfo>>;
|
|
30
|
+
listPullRequests(repo: string, state?: "open" | "closed" | "all", maxResults?: number): Promise<OpenPRResult & {
|
|
31
|
+
prs?: PRInfo[];
|
|
32
|
+
}>;
|
|
33
|
+
closePullRequest(repo: string, prNumber: number): Promise<OpenPRResult>;
|
|
34
|
+
}
|
|
35
|
+
export declare function createOpenPullRequestTool(userToken?: string, encryptionKey?: string): any;
|
|
36
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/copilot/tools/github.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,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