@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,216 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/rest";
|
|
2
|
+
import { ToolError } from "./utils.js";
|
|
3
|
+
export class GitHubPRManager {
|
|
4
|
+
constructor(token) {
|
|
5
|
+
this.octokit = new Octokit({ auth: token });
|
|
6
|
+
}
|
|
7
|
+
async openPullRequest(input) {
|
|
8
|
+
try {
|
|
9
|
+
const [owner, repo] = input.repo.split("/");
|
|
10
|
+
if (!owner || !repo) {
|
|
11
|
+
throw new ToolError("Invalid repo format. Use: owner/repo", "open_pull_request");
|
|
12
|
+
}
|
|
13
|
+
const response = await this.octokit.pulls.create({
|
|
14
|
+
owner,
|
|
15
|
+
repo,
|
|
16
|
+
title: input.title,
|
|
17
|
+
body: input.body,
|
|
18
|
+
head: input.head,
|
|
19
|
+
base: input.base || "main",
|
|
20
|
+
draft: input.draft || false,
|
|
21
|
+
});
|
|
22
|
+
// Add labels if provided
|
|
23
|
+
if (input.labels && input.labels.length > 0) {
|
|
24
|
+
try {
|
|
25
|
+
await this.octokit.issues.addLabels({
|
|
26
|
+
owner,
|
|
27
|
+
repo,
|
|
28
|
+
issue_number: response.data.number,
|
|
29
|
+
labels: input.labels,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.warn(`Failed to add labels: ${error}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Assign users if provided
|
|
37
|
+
if (input.assignees && input.assignees.length > 0) {
|
|
38
|
+
try {
|
|
39
|
+
await this.octokit.issues.addAssignees({
|
|
40
|
+
owner,
|
|
41
|
+
repo,
|
|
42
|
+
issue_number: response.data.number,
|
|
43
|
+
assignees: input.assignees,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.warn(`Failed to add assignees: ${error}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
prNumber: response.data.number,
|
|
53
|
+
prUrl: response.data.html_url,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: errorMsg,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async getPullRequest(repo, prNumber) {
|
|
65
|
+
try {
|
|
66
|
+
const [owner, repoName] = repo.split("/");
|
|
67
|
+
const response = await this.octokit.pulls.get({
|
|
68
|
+
owner,
|
|
69
|
+
repo: repoName,
|
|
70
|
+
pull_number: prNumber,
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
prNumber: response.data.number,
|
|
75
|
+
prUrl: response.data.html_url,
|
|
76
|
+
title: response.data.title,
|
|
77
|
+
state: response.data.state,
|
|
78
|
+
createdAt: response.data.created_at,
|
|
79
|
+
author: response.data.user?.login || "unknown",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: error instanceof Error ? error.message : String(error),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async listPullRequests(repo, state = "open", maxResults = 10) {
|
|
90
|
+
try {
|
|
91
|
+
const [owner, repoName] = repo.split("/");
|
|
92
|
+
const response = await this.octokit.pulls.list({
|
|
93
|
+
owner,
|
|
94
|
+
repo: repoName,
|
|
95
|
+
state,
|
|
96
|
+
per_page: maxResults,
|
|
97
|
+
});
|
|
98
|
+
const prs = response.data.map((pr) => ({
|
|
99
|
+
number: pr.number,
|
|
100
|
+
title: pr.title,
|
|
101
|
+
state: pr.state,
|
|
102
|
+
url: pr.html_url,
|
|
103
|
+
createdAt: pr.created_at,
|
|
104
|
+
author: pr.user?.login || "unknown",
|
|
105
|
+
}));
|
|
106
|
+
return {
|
|
107
|
+
success: true,
|
|
108
|
+
prs,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: error instanceof Error ? error.message : String(error),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async closePullRequest(repo, prNumber) {
|
|
119
|
+
try {
|
|
120
|
+
const [owner, repoName] = repo.split("/");
|
|
121
|
+
const response = await this.octokit.pulls.update({
|
|
122
|
+
owner,
|
|
123
|
+
repo: repoName,
|
|
124
|
+
pull_number: prNumber,
|
|
125
|
+
state: "closed",
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
success: true,
|
|
129
|
+
prNumber: response.data.number,
|
|
130
|
+
prUrl: response.data.html_url,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
error: error instanceof Error ? error.message : String(error),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Factory function for Copilot SDK tool definition
|
|
142
|
+
export function createOpenPullRequestTool(userToken, encryptionKey) {
|
|
143
|
+
// Support both managed SaaS (user token provided) and self-hosted (env var)
|
|
144
|
+
let token = userToken;
|
|
145
|
+
if (!token) {
|
|
146
|
+
token = process.env.GITHUB_TOKEN;
|
|
147
|
+
if (token) {
|
|
148
|
+
console.log("[GitHub Tool] Using GITHUB_TOKEN from environment (self-hosted mode)");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.log("[GitHub Tool] Using provided user token (managed SaaS mode)");
|
|
153
|
+
}
|
|
154
|
+
if (!token) {
|
|
155
|
+
throw new ToolError("GITHUB_TOKEN environment variable not set and no user credentials provided. " +
|
|
156
|
+
"For managed SaaS: ensure user GitHub token is configured. " +
|
|
157
|
+
"For self-hosted: set GITHUB_TOKEN environment variable.", "github");
|
|
158
|
+
}
|
|
159
|
+
const prManager = new GitHubPRManager(token);
|
|
160
|
+
return {
|
|
161
|
+
name: "open_pull_request",
|
|
162
|
+
description: "Open a pull request on GitHub",
|
|
163
|
+
parameters: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
repo: {
|
|
167
|
+
type: "string",
|
|
168
|
+
description: "Repository in format: owner/repo",
|
|
169
|
+
},
|
|
170
|
+
title: {
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "Pull request title",
|
|
173
|
+
},
|
|
174
|
+
body: {
|
|
175
|
+
type: "string",
|
|
176
|
+
description: "Pull request description/body",
|
|
177
|
+
},
|
|
178
|
+
head: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Source branch name",
|
|
181
|
+
},
|
|
182
|
+
base: {
|
|
183
|
+
type: "string",
|
|
184
|
+
description: "Target branch (default: main)",
|
|
185
|
+
},
|
|
186
|
+
draft: {
|
|
187
|
+
type: "boolean",
|
|
188
|
+
description: "Create as draft PR",
|
|
189
|
+
default: false,
|
|
190
|
+
},
|
|
191
|
+
labels: {
|
|
192
|
+
type: "array",
|
|
193
|
+
items: { type: "string" },
|
|
194
|
+
description: "Labels to add to the PR",
|
|
195
|
+
},
|
|
196
|
+
assignees: {
|
|
197
|
+
type: "array",
|
|
198
|
+
items: { type: "string" },
|
|
199
|
+
description: "GitHub usernames to assign to the PR",
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
required: ["repo", "title", "body", "head"],
|
|
203
|
+
},
|
|
204
|
+
handler: async (input) => {
|
|
205
|
+
try {
|
|
206
|
+
return await prManager.openPullRequest(input);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (error instanceof ToolError)
|
|
210
|
+
throw error;
|
|
211
|
+
throw new ToolError(`Failed to open PR: ${error}`, "open_pull_request");
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../src/copilot/tools/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA6BvC,MAAM,OAAO,eAAe;IAG1B,YAAY,KAAa;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAkB;QACtC,IAAI,CAAC;YACH,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAE5C,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACpB,MAAM,IAAI,SAAS,CACjB,sCAAsC,EACtC,mBAAmB,CACpB,CAAC;YACJ,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MA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|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createGitOperationsTool, GitTool } from "./git.js";
|
|
2
|
+
import { createTestRunnerTool, TestRunner } from "./tests.js";
|
|
3
|
+
import { createReadFileTool, createWriteFileTool, createListFilesTool, FileManager } from "./files.js";
|
|
4
|
+
import { createOpenPullRequestTool, GitHubPRManager } from "./github.js";
|
|
5
|
+
import { createProgressUpdateTool, ProgressTracker } from "./progress.js";
|
|
6
|
+
import { ToolError, executeCommand, ensureRepoStoragePath, getRepoPath } from "./utils.js";
|
|
7
|
+
export { createGitOperationsTool, GitTool };
|
|
8
|
+
export type { GitOperationInput, GitOperationResult } from "./git.js";
|
|
9
|
+
export { createTestRunnerTool, TestRunner };
|
|
10
|
+
export type { TestRunInput, TestRunResult } from "./tests.js";
|
|
11
|
+
export { createReadFileTool, createWriteFileTool, createListFilesTool, FileManager, };
|
|
12
|
+
export type { ReadFileInput, ReadFileResult, WriteFileInput, WriteFileResult, ListFilesInput, ListFilesResult, } from "./files.js";
|
|
13
|
+
export { createOpenPullRequestTool, GitHubPRManager };
|
|
14
|
+
export type { OpenPRInput, OpenPRResult } from "./github.js";
|
|
15
|
+
export { createProgressUpdateTool, ProgressTracker };
|
|
16
|
+
export type { ProgressUpdateInput, ProgressUpdateResult } from "./progress.js";
|
|
17
|
+
export { ToolError, executeCommand, ensureRepoStoragePath, getRepoPath };
|
|
18
|
+
export interface ToolOptions {
|
|
19
|
+
githubToken?: string;
|
|
20
|
+
encryptionKey?: string;
|
|
21
|
+
localPath?: string;
|
|
22
|
+
devflowUrl?: string;
|
|
23
|
+
devflowSecret?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function getAllTools(options?: ToolOptions): any[];
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/copilot/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,OAAO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,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,WAAgB,GAAG,GAAG,EAAE,CAU5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Export all custom tool definitions and factories
|
|
2
|
+
import { createGitOperationsTool, GitTool } from "./git.js";
|
|
3
|
+
import { createTestRunnerTool, TestRunner } from "./tests.js";
|
|
4
|
+
import { createReadFileTool, createWriteFileTool, createListFilesTool, FileManager, } from "./files.js";
|
|
5
|
+
import { createOpenPullRequestTool, GitHubPRManager } from "./github.js";
|
|
6
|
+
import { createProgressUpdateTool, ProgressTracker } from "./progress.js";
|
|
7
|
+
import { ToolError, executeCommand, ensureRepoStoragePath, getRepoPath, } from "./utils.js";
|
|
8
|
+
export { createGitOperationsTool, GitTool };
|
|
9
|
+
export { createTestRunnerTool, TestRunner };
|
|
10
|
+
export { createReadFileTool, createWriteFileTool, createListFilesTool, FileManager, };
|
|
11
|
+
export { createOpenPullRequestTool, GitHubPRManager };
|
|
12
|
+
export { createProgressUpdateTool, ProgressTracker };
|
|
13
|
+
export { ToolError, executeCommand, ensureRepoStoragePath, getRepoPath };
|
|
14
|
+
export function getAllTools(options = {}) {
|
|
15
|
+
return [
|
|
16
|
+
// createGitOperationsTool(options), // Using built-in git tools
|
|
17
|
+
createTestRunnerTool(),
|
|
18
|
+
// createReadFileTool(options), // Using built-in file tools
|
|
19
|
+
// createWriteFileTool(options), // Using built-in file tools
|
|
20
|
+
// createListFilesTool(options), // Using built-in file tools
|
|
21
|
+
createOpenPullRequestTool(options.githubToken, options.encryptionKey),
|
|
22
|
+
createProgressUpdateTool(options.devflowUrl, options.devflowSecret),
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cop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completed" | "failed";
|
|
4
|
+
step: string;
|
|
5
|
+
progress: number;
|
|
6
|
+
details?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ProgressUpdateResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class ProgressTracker {
|
|
14
|
+
private devflowClient;
|
|
15
|
+
constructor(devflowApiUrl: string, devflowApiSecret: string);
|
|
16
|
+
sendUpdate(input: ProgressUpdateInput): Promise<ProgressUpdateResult>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createProgressUpdateTool(apiUrl?: string, apiSecret?: string): any;
|
|
19
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/copilot/tools/progress.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAIrD,UAAU,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuB5E;AAGD,wBAAgB,wBAAwB,CACtC,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,GAAG,CAiEL"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import DevflowClient from "../../devflow/client.js";
|
|
2
|
+
export class ProgressTracker {
|
|
3
|
+
constructor(devflowApiUrl, devflowApiSecret) {
|
|
4
|
+
this.devflowClient = new DevflowClient(devflowApiUrl, devflowApiSecret);
|
|
5
|
+
}
|
|
6
|
+
async sendUpdate(input) {
|
|
7
|
+
try {
|
|
8
|
+
await this.devflowClient.sendProgressUpdate({
|
|
9
|
+
taskId: input.taskId,
|
|
10
|
+
status: input.status,
|
|
11
|
+
step: input.step,
|
|
12
|
+
progress: Math.max(0, Math.min(1, input.progress)), // Clamp 0-1
|
|
13
|
+
details: input.details,
|
|
14
|
+
error: input.error,
|
|
15
|
+
timestamp: Date.now(),
|
|
16
|
+
});
|
|
17
|
+
return { success: true };
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
21
|
+
console.error(`Failed to send progress update: ${errorMsg}`);
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
error: errorMsg,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Factory function for Copilot SDK tool definition
|
|
30
|
+
export function createProgressUpdateTool(apiUrl, apiSecret) {
|
|
31
|
+
const devflowUrl = apiUrl || process.env.DEVFLOW_API_URL;
|
|
32
|
+
const devflowSecret = apiSecret || process.env.DEVFLOW_API_SECRET;
|
|
33
|
+
if (!devflowUrl || !devflowSecret) {
|
|
34
|
+
console.warn("DEVFLOW_API_URL or DEVFLOW_API_SECRET not configured. Progress updates will fail.");
|
|
35
|
+
}
|
|
36
|
+
const progressTracker = new ProgressTracker(devflowUrl || "http://localhost:3000", devflowSecret || "");
|
|
37
|
+
return {
|
|
38
|
+
name: "send_progress_update",
|
|
39
|
+
description: "Send progress update back to DevFlow for user notification",
|
|
40
|
+
parameters: {
|
|
41
|
+
type: "object",
|
|
42
|
+
properties: {
|
|
43
|
+
taskId: {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "Task identifier from the original command",
|
|
46
|
+
},
|
|
47
|
+
status: {
|
|
48
|
+
type: "string",
|
|
49
|
+
enum: ["in_progress", "completed", "failed"],
|
|
50
|
+
description: "Current task status",
|
|
51
|
+
},
|
|
52
|
+
step: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "Description of the current step",
|
|
55
|
+
},
|
|
56
|
+
progress: {
|
|
57
|
+
type: "number",
|
|
58
|
+
description: "Progress percentage as decimal (0-1)",
|
|
59
|
+
minimum: 0,
|
|
60
|
+
maximum: 1,
|
|
61
|
+
},
|
|
62
|
+
details: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "Additional details about the current step",
|
|
65
|
+
},
|
|
66
|
+
error: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Error message if status is 'failed'",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
required: ["taskId", "status", "step", "progress"],
|
|
72
|
+
},
|
|
73
|
+
handler: async (input) => {
|
|
74
|
+
try {
|
|
75
|
+
return await progressTracker.sendUpdate(input);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error(`Progress update handler error: ${error}`);
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
error: error instanceof Error ? error.message : String(error),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../../src/copilot/tools/progress.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,yBAAyB,CAAC;AAiBpD,MAAM,OAAO,eAAe;IAG1B,YAAY,aAAqB,EAAE,gBAAwB;QACzD,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAA0B;Q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KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface TestRunInput {
|
|
2
|
+
repoPath: string;
|
|
3
|
+
testCommand?: string;
|
|
4
|
+
pattern?: string;
|
|
5
|
+
coverage?: boolean;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TestRunResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
output: string;
|
|
11
|
+
stderr?: string;
|
|
12
|
+
exitCode: number;
|
|
13
|
+
duration: number;
|
|
14
|
+
testsPassed?: number;
|
|
15
|
+
testsFailed?: number;
|
|
16
|
+
coverage?: {
|
|
17
|
+
lines: number;
|
|
18
|
+
statements: number;
|
|
19
|
+
functions: number;
|
|
20
|
+
branches: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare class TestRunner {
|
|
24
|
+
detectPackageManager(repoPath: string): Promise<"npm" | "yarn" | "pnpm">;
|
|
25
|
+
runTests(input: TestRunInput): Promise<TestRunResult>;
|
|
26
|
+
findTestFiles(repoPath: string, pattern?: string): Promise<string[]>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createTestRunnerTool(): any;
|
|
29
|
+
//# sourceMappingURL=tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/copilot/tools/tests.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,qBAAa,UAAU;IACf,oBAAoB,CACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAoB7B,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IA4DrD,aAAa,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAA2C,GACnD,OAAO,CAAC,MAAM,EAAE,CAAC;CAiBrB;AAGD,wBAAgB,oBAAoB,IAAI,GAAG,CA8C1C"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { executeCommand, ToolError } from "./utils.js";
|
|
2
|
+
export class TestRunner {
|
|
3
|
+
async detectPackageManager(repoPath) {
|
|
4
|
+
try {
|
|
5
|
+
// Check for lock files
|
|
6
|
+
const { readFile } = await import("fs/promises");
|
|
7
|
+
try {
|
|
8
|
+
await readFile(`${repoPath}/pnpm-lock.yaml`);
|
|
9
|
+
return "pnpm";
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
try {
|
|
13
|
+
await readFile(`${repoPath}/yarn.lock`);
|
|
14
|
+
return "yarn";
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return "npm"; // Default to npm
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return "npm";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async runTests(input) {
|
|
26
|
+
const startTime = Date.now();
|
|
27
|
+
try {
|
|
28
|
+
const repoPath = input.repoPath;
|
|
29
|
+
const pm = await this.detectPackageManager(repoPath);
|
|
30
|
+
let command = input.testCommand;
|
|
31
|
+
if (!command) {
|
|
32
|
+
// Build default test command based on package manager
|
|
33
|
+
const baseCommand = `${pm} ${pm === "npm" ? "run" : ""} test`;
|
|
34
|
+
let fullCommand = baseCommand;
|
|
35
|
+
if (input.pattern && pm === "npm") {
|
|
36
|
+
fullCommand += ` -- ${input.pattern}`;
|
|
37
|
+
}
|
|
38
|
+
else if (input.pattern) {
|
|
39
|
+
fullCommand += ` ${input.pattern}`;
|
|
40
|
+
}
|
|
41
|
+
if (input.coverage) {
|
|
42
|
+
if (pm === "npm") {
|
|
43
|
+
fullCommand = `${pm} run test -- --coverage`;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
fullCommand += " --coverage";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
command = fullCommand;
|
|
50
|
+
}
|
|
51
|
+
const output = executeCommand(command, repoPath, input.timeout || 120000);
|
|
52
|
+
const duration = Date.now() - startTime;
|
|
53
|
+
// Try to parse test results from output
|
|
54
|
+
const testsPassed = (output.match(/passed/gi) || []).length;
|
|
55
|
+
const testsFailed = (output.match(/failed/gi) || []).length;
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
output,
|
|
59
|
+
exitCode: 0,
|
|
60
|
+
duration,
|
|
61
|
+
testsPassed,
|
|
62
|
+
testsFailed,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const duration = Date.now() - startTime;
|
|
67
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
output: errorMsg,
|
|
71
|
+
exitCode: 1,
|
|
72
|
+
duration,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async findTestFiles(repoPath, pattern = "**/*.{test,spec}.{js,ts,jsx,tsx}") {
|
|
77
|
+
try {
|
|
78
|
+
const { execSync } = await import("child_process");
|
|
79
|
+
const files = execSync(`find ${repoPath} -name "*.test.*" -o -name "*.spec.*"`, {
|
|
80
|
+
encoding: "utf-8",
|
|
81
|
+
})
|
|
82
|
+
.split("\n")
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
return files;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new ToolError(`Failed to find test files: ${error}`, "find_tests");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Factory function for Copilot SDK tool definition
|
|
92
|
+
export function createTestRunnerTool() {
|
|
93
|
+
const testRunner = new TestRunner();
|
|
94
|
+
return {
|
|
95
|
+
name: "run_tests",
|
|
96
|
+
description: "Run test suite for a repository and capture results",
|
|
97
|
+
parameters: {
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: {
|
|
100
|
+
repoPath: {
|
|
101
|
+
type: "string",
|
|
102
|
+
description: "Local repository path",
|
|
103
|
+
},
|
|
104
|
+
testCommand: {
|
|
105
|
+
type: "string",
|
|
106
|
+
description: "Custom test command (default: npm test or yarn test)",
|
|
107
|
+
},
|
|
108
|
+
pattern: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Test file pattern or specific test to run",
|
|
111
|
+
},
|
|
112
|
+
coverage: {
|
|
113
|
+
type: "boolean",
|
|
114
|
+
description: "Generate coverage report",
|
|
115
|
+
default: false,
|
|
116
|
+
},
|
|
117
|
+
timeout: {
|
|
118
|
+
type: "number",
|
|
119
|
+
description: "Test timeout in milliseconds (default: 120000)",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
required: ["repoPath"],
|
|
123
|
+
},
|
|
124
|
+
handler: async (input) => {
|
|
125
|
+
try {
|
|
126
|
+
return await testRunner.runTests(input);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (error instanceof ToolError)
|
|
130
|
+
throw error;
|
|
131
|
+
throw new ToolError(`Test execution failed: ${error}`, "run_tests");
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests.js","sourceRoot":"","sources":["../../../src/copilot/tools/tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA2BvD,MAAM,OAAO,UAAU;IACrB,KAAK,CAAC,oBAAoB,CACxB,QAAgB;QAEhB,IAAI,CAAC;YACH,uBAAuB;YACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;YACjD,IAAI,CAAC;gBACH,MAAM,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,CAAC,CAAC;gBAC7C,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC;oBACH,MAAM,QAAQ,CAAC,GAAG,QAAQ,YAAY,CAAC,CAAC;oBACxC,OAAO,MAAM,CAAC;gBAChB,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,KAAK,CAAC,CAAC,iBAAiB;gBACjC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAmB;QAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAChC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAErD,IAAI,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC;YAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,sDAAsD;gBACtD,MAAM,WAAW,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,KAAK,CAAC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WAAW,EAAE,0BAA0B;oBACvC,OAAO,EAAE,KAAK;iBACf;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gDAAgD;iBAC9D;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB;QACD,OAAO,EAAE,KAAK,EAAE,KAAmB,EAA0B,EAAE;YAC7D,IAAI,CAAC;gBACH,OAAO,MAAM,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,SAAS;oBAAE,MAAM,KAAK,CAAC;gBAC5C,MAAM,IAAI,SAAS,CACjB,0BAA0B,KAAK,EAAE,EACjC,WAAW,CACZ,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class ToolError extends Error {
|
|
2
|
+
tool: string;
|
|
3
|
+
code?: string | undefined;
|
|
4
|
+
constructor(message: string, tool: string, code?: string | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare function ensureRepoStoragePath(): Promise<string>;
|
|
7
|
+
export declare function getRepoPath(repo: string, storagePath?: string, localPath?: string): Promise<string>;
|
|
8
|
+
export declare function executeCommand(command: string, cwd?: string, timeout?: number): string;
|
|
9
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
10
|
+
export declare function readFile(filePath: string): Promise<string>;
|
|
11
|
+
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
12
|
+
export declare function listFiles(dirPath: string, pattern?: RegExp): Promise<string[]>;
|
|
13
|
+
export declare function removeDirectory(dirPath: string): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/copilot/tools/utils.ts"],"names":[],"mappings":"AAKA,qBAAa,SAAU,SAAQ,KAAK;IAGzB,IAAI,EAAE,MAAM;IACZ,IAAI,CAAC,EAAE,MAAM;gBAFpB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAW7D;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,GAAE,MAAc,GACtB,MAAM,CAcR;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUhE;AAED,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUpE"}
|