codowave 0.2.2 → 0.2.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/index.mjs +8558 -0
- package/package.json +3 -4
- package/dist/cli.js +0 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +0 -1335
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
DELETED
|
@@ -1,1335 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
-
};
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// src/utils/error.ts
|
|
12
|
-
import pc from "picocolors";
|
|
13
|
-
function getErrorMessage(err) {
|
|
14
|
-
if (err instanceof CodowaveError) {
|
|
15
|
-
return err.getFormattedMessage();
|
|
16
|
-
}
|
|
17
|
-
if (err instanceof Error) {
|
|
18
|
-
const message = err.message;
|
|
19
|
-
if (message.includes("ECONNREFUSED") || message.includes("ENOTFOUND")) {
|
|
20
|
-
return `Unable to connect to the Codowave API. Please check your internet connection and try again.`;
|
|
21
|
-
}
|
|
22
|
-
if (message.includes("401") || message.includes("unauthorized")) {
|
|
23
|
-
return `Authentication failed. Please run 'codowave init' to re-authenticate.`;
|
|
24
|
-
}
|
|
25
|
-
if (message.includes("403") || message.includes("forbidden")) {
|
|
26
|
-
return `Access denied. You don't have permission to perform this action.`;
|
|
27
|
-
}
|
|
28
|
-
if (message.includes("404") || message.includes("not found")) {
|
|
29
|
-
return `The requested resource was not found. Please check the repository or issue number and try again.`;
|
|
30
|
-
}
|
|
31
|
-
if (message.includes("rate limit")) {
|
|
32
|
-
return `Rate limit exceeded. Please wait a moment and try again.`;
|
|
33
|
-
}
|
|
34
|
-
return message;
|
|
35
|
-
}
|
|
36
|
-
return String(err);
|
|
37
|
-
}
|
|
38
|
-
function handleError(err, context) {
|
|
39
|
-
const message = getErrorMessage(err);
|
|
40
|
-
const prefix = context ? `[${context}] ` : "";
|
|
41
|
-
console.error(`
|
|
42
|
-
${pc.red("\u2716")} ${prefix}${message}
|
|
43
|
-
`);
|
|
44
|
-
if (err instanceof CodowaveError && err.code) {
|
|
45
|
-
console.error(pc.gray(`Error code: ${err.code}`));
|
|
46
|
-
}
|
|
47
|
-
if (process.env["NODE_ENV"] === "development" && err instanceof Error && err.stack) {
|
|
48
|
-
console.error(pc.gray(err.stack));
|
|
49
|
-
}
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
var CodowaveError, ConfigError, APIError, ErrorCodes;
|
|
53
|
-
var init_error = __esm({
|
|
54
|
-
"src/utils/error.ts"() {
|
|
55
|
-
"use strict";
|
|
56
|
-
CodowaveError = class extends Error {
|
|
57
|
-
constructor(message, code, context) {
|
|
58
|
-
super(message);
|
|
59
|
-
this.code = code;
|
|
60
|
-
this.context = context;
|
|
61
|
-
this.name = "CodowaveError";
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Returns a formatted error message with optional context
|
|
65
|
-
*/
|
|
66
|
-
getFormattedMessage() {
|
|
67
|
-
let msg = this.message;
|
|
68
|
-
if (this.context && Object.keys(this.context).length > 0) {
|
|
69
|
-
msg += `
|
|
70
|
-
|
|
71
|
-
Context: ${JSON.stringify(this.context, null, 2)}`;
|
|
72
|
-
}
|
|
73
|
-
return msg;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
ConfigError = class extends CodowaveError {
|
|
77
|
-
constructor(message, context) {
|
|
78
|
-
super(message, "CONFIG_ERROR", context);
|
|
79
|
-
this.name = "ConfigError";
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
APIError = class extends CodowaveError {
|
|
83
|
-
constructor(message, statusCode, context) {
|
|
84
|
-
super(message, "API_ERROR", context);
|
|
85
|
-
this.statusCode = statusCode;
|
|
86
|
-
this.name = "APIError";
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
ErrorCodes = {
|
|
90
|
-
CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
|
|
91
|
-
INVALID_CONFIG: "INVALID_CONFIG",
|
|
92
|
-
REPO_NOT_CONFIGURED: "REPO_NOT_CONFIGURED",
|
|
93
|
-
API_ERROR: "API_ERROR",
|
|
94
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
95
|
-
AUTH_ERROR: "AUTH_ERROR",
|
|
96
|
-
INVALID_ISSUE_FORMAT: "INVALID_ISSUE_FORMAT",
|
|
97
|
-
RUN_FAILED: "RUN_FAILED"
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// src/config.ts
|
|
103
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
104
|
-
import { join } from "path";
|
|
105
|
-
import { homedir } from "os";
|
|
106
|
-
import { z } from "zod";
|
|
107
|
-
function readConfig() {
|
|
108
|
-
if (!existsSync(CONFIG_FILE)) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
const raw = readFileSync(CONFIG_FILE, "utf-8");
|
|
113
|
-
const json = JSON.parse(raw);
|
|
114
|
-
const parsed = ConfigSchema.safeParse(json);
|
|
115
|
-
if (!parsed.success) {
|
|
116
|
-
const issues = parsed.error.issues.map((i) => ` - ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
117
|
-
console.warn(`[config] Config validation failed:
|
|
118
|
-
${issues}`);
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
return parsed.data;
|
|
122
|
-
} catch (err) {
|
|
123
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
124
|
-
console.warn(`[config] Failed to read ${CONFIG_FILE}: ${message}`);
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function readConfigOrThrow() {
|
|
129
|
-
const config = readConfig();
|
|
130
|
-
if (!config) {
|
|
131
|
-
throw new ConfigError(
|
|
132
|
-
"No Codowave config found. Run `codowave init` to get started.",
|
|
133
|
-
{ suggestion: "Run 'codowave init' to configure your API key and repositories" }
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
return config;
|
|
137
|
-
}
|
|
138
|
-
function writeConfig(config) {
|
|
139
|
-
if (!existsSync(CONFIG_DIR)) {
|
|
140
|
-
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
141
|
-
}
|
|
142
|
-
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
143
|
-
}
|
|
144
|
-
function updateConfig(updates) {
|
|
145
|
-
const current = readConfig() ?? {
|
|
146
|
-
apiKey: "",
|
|
147
|
-
apiUrl: "https://api.codowave.com",
|
|
148
|
-
repos: [],
|
|
149
|
-
autopilot: false,
|
|
150
|
-
labels: ["codowave-agent"]
|
|
151
|
-
};
|
|
152
|
-
const merged = {
|
|
153
|
-
...current,
|
|
154
|
-
...updates
|
|
155
|
-
};
|
|
156
|
-
writeConfig(merged);
|
|
157
|
-
return merged;
|
|
158
|
-
}
|
|
159
|
-
function getConfigPath() {
|
|
160
|
-
return CONFIG_FILE;
|
|
161
|
-
}
|
|
162
|
-
var AIProviderSchema, ConfigSchema, CONFIG_DIR, CONFIG_FILE;
|
|
163
|
-
var init_config = __esm({
|
|
164
|
-
"src/config.ts"() {
|
|
165
|
-
"use strict";
|
|
166
|
-
init_error();
|
|
167
|
-
AIProviderSchema = z.object({
|
|
168
|
-
provider: z.enum(["openai", "anthropic", "minimax", "ollama", "custom"]),
|
|
169
|
-
apiKey: z.string().min(1),
|
|
170
|
-
model: z.string().default(""),
|
|
171
|
-
baseUrl: z.string().url().optional()
|
|
172
|
-
});
|
|
173
|
-
ConfigSchema = z.object({
|
|
174
|
-
apiKey: z.string().min(1),
|
|
175
|
-
apiUrl: z.string().url().default("https://api.codowave.com"),
|
|
176
|
-
repos: z.array(
|
|
177
|
-
z.object({
|
|
178
|
-
owner: z.string(),
|
|
179
|
-
name: z.string(),
|
|
180
|
-
id: z.string().optional()
|
|
181
|
-
})
|
|
182
|
-
).default([]),
|
|
183
|
-
ai: AIProviderSchema.optional(),
|
|
184
|
-
autopilot: z.boolean().default(false),
|
|
185
|
-
labels: z.array(z.string()).default(["codowave-agent"])
|
|
186
|
-
});
|
|
187
|
-
CONFIG_DIR = join(homedir(), ".codowave");
|
|
188
|
-
CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// src/commands/init.tsx
|
|
193
|
-
var init_exports = {};
|
|
194
|
-
__export(init_exports, {
|
|
195
|
-
initCommand: () => initCommand
|
|
196
|
-
});
|
|
197
|
-
import { Command } from "commander";
|
|
198
|
-
import pc3 from "picocolors";
|
|
199
|
-
var initCommand;
|
|
200
|
-
var init_init = __esm({
|
|
201
|
-
"src/commands/init.tsx"() {
|
|
202
|
-
"use strict";
|
|
203
|
-
init_config();
|
|
204
|
-
initCommand = new Command("init").description("Initialize Codowave and connect your GitHub repositories").requiredOption("--api-key <key>", "Codowave API key").option("--api-url <url>", "Codowave API URL", "https://api.codowave.com").option("--github-app-id <id>", "GitHub App ID").option("--github-app-private-key <path>", "GitHub App private key file path").option("--repos <repos>", "Comma-separated list of repos (owner/repo)").option("--no-autopilot", "Disable autopilot mode").option("--labels <labels>", "Comma-separated labels", "status/approved,status/in-progress,status/merged").action(async (opts) => {
|
|
205
|
-
let repos = [];
|
|
206
|
-
if (opts.repos) {
|
|
207
|
-
repos = opts.repos.split(",").map((r) => {
|
|
208
|
-
const [owner, name] = r.trim().split("/");
|
|
209
|
-
if (!owner || !name) {
|
|
210
|
-
console.log(pc3.red(`
|
|
211
|
-
\u274C Invalid repo format: ${r}. Use owner/repo
|
|
212
|
-
`));
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
return { owner, name };
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
const labels = opts.labels.split(",").map((l) => l.trim()).filter(Boolean);
|
|
219
|
-
const config = {
|
|
220
|
-
apiKey: opts.apiKey,
|
|
221
|
-
apiUrl: opts.apiUrl,
|
|
222
|
-
githubAppId: opts.githubAppId || "",
|
|
223
|
-
githubAppPrivateKey: opts.githubAppPrivateKey || "",
|
|
224
|
-
repos,
|
|
225
|
-
autopilot: opts.autopilot !== false,
|
|
226
|
-
labels
|
|
227
|
-
};
|
|
228
|
-
writeConfig(config);
|
|
229
|
-
console.log(pc3.green("\n\u2705 Codowave initialized successfully!\n"));
|
|
230
|
-
console.log(` API URL: ${pc3.cyan(config.apiUrl)}`);
|
|
231
|
-
console.log(` Repos: ${pc3.cyan(config.repos.map((r) => `${r.owner}/${r.name}`).join(", ") || "none")}`);
|
|
232
|
-
console.log(` Autopilot: ${pc3.cyan(config.autopilot ? "enabled" : "disabled")}`);
|
|
233
|
-
console.log(pc3.gray(`
|
|
234
|
-
Config: ${getConfigPath()}
|
|
235
|
-
`));
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// src/commands/run.ts
|
|
241
|
-
var run_exports = {};
|
|
242
|
-
__export(run_exports, {
|
|
243
|
-
runCommand: () => runCommand
|
|
244
|
-
});
|
|
245
|
-
import { Command as Command2 } from "commander";
|
|
246
|
-
import pc4 from "picocolors";
|
|
247
|
-
function parseIssue(input) {
|
|
248
|
-
const urlMatch = input.match(/github\.com\/([^/]+)\/([^/]+)\/issues\/(\d+)/);
|
|
249
|
-
if (urlMatch && urlMatch[1] && urlMatch[2] && urlMatch[3]) {
|
|
250
|
-
return { owner: urlMatch[1], repo: urlMatch[2], number: parseInt(urlMatch[3], 10) };
|
|
251
|
-
}
|
|
252
|
-
const repoMatch = input.match(/([^/]+)\/([^#]+)#(\d+)/);
|
|
253
|
-
if (repoMatch && repoMatch[1] && repoMatch[2] && repoMatch[3]) {
|
|
254
|
-
return { owner: repoMatch[1], repo: repoMatch[2], number: parseInt(repoMatch[3], 10) };
|
|
255
|
-
}
|
|
256
|
-
const numMatch = input.match(/^(\d+)$/);
|
|
257
|
-
if (numMatch && numMatch[1]) {
|
|
258
|
-
return { owner: "", repo: "", number: parseInt(numMatch[1], 10) };
|
|
259
|
-
}
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
async function triggerRun(config, issue) {
|
|
263
|
-
const apiUrl = config.apiUrl;
|
|
264
|
-
const apiKey = config.apiKey;
|
|
265
|
-
const repoConfig = config.repos.find(
|
|
266
|
-
(r) => r.owner === issue.owner && r.name === issue.repo
|
|
267
|
-
);
|
|
268
|
-
if (!repoConfig) {
|
|
269
|
-
throw new ConfigError(
|
|
270
|
-
`Repository ${issue.owner}/${issue.repo} is not configured.`,
|
|
271
|
-
{
|
|
272
|
-
suggestion: `Run 'codowave config add-repo ${issue.owner}/${issue.repo}' to add this repository`,
|
|
273
|
-
configuredRepos: config.repos.map((r) => `${r.owner}/${r.name}`)
|
|
274
|
-
}
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
let response;
|
|
278
|
-
try {
|
|
279
|
-
response = await fetch(`${apiUrl}/api/runs`, {
|
|
280
|
-
method: "POST",
|
|
281
|
-
headers: {
|
|
282
|
-
"Content-Type": "application/json",
|
|
283
|
-
Authorization: `Bearer ${apiKey}`
|
|
284
|
-
},
|
|
285
|
-
body: JSON.stringify({
|
|
286
|
-
repositoryId: repoConfig.id,
|
|
287
|
-
issueNumber: issue.number
|
|
288
|
-
})
|
|
289
|
-
});
|
|
290
|
-
} catch {
|
|
291
|
-
throw new CodowaveError(
|
|
292
|
-
`Failed to connect to Codowave API at ${apiUrl}`,
|
|
293
|
-
ErrorCodes.NETWORK_ERROR,
|
|
294
|
-
{ suggestion: "Check your internet connection and verify the API URL in your config." }
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
if (!response.ok) {
|
|
298
|
-
let errorMessage = `API returned status ${response.status}`;
|
|
299
|
-
let errorBody = {};
|
|
300
|
-
try {
|
|
301
|
-
errorBody = await response.json();
|
|
302
|
-
errorMessage = errorBody["error"] || errorBody["message"] || errorMessage;
|
|
303
|
-
} catch {
|
|
304
|
-
errorMessage = response.statusText || errorMessage;
|
|
305
|
-
}
|
|
306
|
-
if (response.status === 401) {
|
|
307
|
-
throw new CodowaveError(
|
|
308
|
-
`Authentication failed: ${errorMessage}`,
|
|
309
|
-
ErrorCodes.AUTH_ERROR,
|
|
310
|
-
{ suggestion: "Run 'codowave init' to re-authenticate." }
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
if (response.status === 403) {
|
|
314
|
-
throw new CodowaveError(
|
|
315
|
-
`Access denied: ${errorMessage}`,
|
|
316
|
-
ErrorCodes.AUTH_ERROR,
|
|
317
|
-
{ suggestion: "You don't have permission to trigger runs for this repository." }
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
if (response.status === 404) {
|
|
321
|
-
throw new CodowaveError(
|
|
322
|
-
`Resource not found: ${errorMessage}`,
|
|
323
|
-
ErrorCodes.API_ERROR,
|
|
324
|
-
{ suggestion: "The repository or issue may no longer exist." }
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
const errorText = await response.text();
|
|
328
|
-
throw new APIError(
|
|
329
|
-
`Failed to trigger run: ${response.status} ${response.statusText}`,
|
|
330
|
-
response.status,
|
|
331
|
-
{ response: errorText, issueNumber: issue.number, repo: `${issue.owner}/${issue.repo}` }
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
const data = await response.json();
|
|
335
|
-
return data.runId;
|
|
336
|
-
}
|
|
337
|
-
function createDemoRun(issue) {
|
|
338
|
-
const runId = `run-${Date.now()}`;
|
|
339
|
-
const run = {
|
|
340
|
-
id: runId,
|
|
341
|
-
repo: issue.owner && issue.repo ? `${issue.owner}/${issue.repo}` : "CodowaveAI/Codowave",
|
|
342
|
-
status: "in_progress",
|
|
343
|
-
issue: `#${issue.number}`,
|
|
344
|
-
branchName: `agent/issue-${issue.number}`,
|
|
345
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
346
|
-
stages: [
|
|
347
|
-
{ name: "context", status: "pending" },
|
|
348
|
-
{ name: "planning", status: "pending" },
|
|
349
|
-
{ name: "implementation", status: "pending" },
|
|
350
|
-
{ name: "testing", status: "pending" },
|
|
351
|
-
{ name: "pr-creation", status: "pending" }
|
|
352
|
-
]
|
|
353
|
-
};
|
|
354
|
-
demoRuns.set(runId, run);
|
|
355
|
-
return run;
|
|
356
|
-
}
|
|
357
|
-
function streamDemoRun(run) {
|
|
358
|
-
const stages = ["context", "planning", "implementation", "testing", "pr-creation"];
|
|
359
|
-
let currentStage = 0;
|
|
360
|
-
console.log(pc4.bold("\n=== Starting Run ===\n"));
|
|
361
|
-
console.log(pc4.bold("Run ID: ") + run.id);
|
|
362
|
-
console.log(pc4.bold("Repo: ") + run.repo);
|
|
363
|
-
console.log(pc4.bold("Issue: ") + run.issue);
|
|
364
|
-
console.log(pc4.bold("Branch: ") + run.branchName);
|
|
365
|
-
console.log("");
|
|
366
|
-
const interval = setInterval(() => {
|
|
367
|
-
if (currentStage >= stages.length) {
|
|
368
|
-
clearInterval(interval);
|
|
369
|
-
run.status = "completed";
|
|
370
|
-
run.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
371
|
-
run.prNumber = 100 + Math.floor(Math.random() * 50);
|
|
372
|
-
run.prTitle = `feat: Implement issue #${run.issue}`;
|
|
373
|
-
console.log(pc4.green("\n\u2713 Run completed successfully!"));
|
|
374
|
-
console.log(pc4.bold("\n=== Result ===\n"));
|
|
375
|
-
console.log(pc4.bold("PR: ") + `#${run.prNumber} - ${run.prTitle}`);
|
|
376
|
-
console.log(pc4.bold("Branch: ") + run.branchName);
|
|
377
|
-
console.log("");
|
|
378
|
-
process.exit(0);
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const stageName = stages[currentStage];
|
|
382
|
-
const stage = run.stages.find((s) => s.name === stageName);
|
|
383
|
-
if (stage) {
|
|
384
|
-
stage.status = "running";
|
|
385
|
-
console.log(pc4.blue(`
|
|
386
|
-
--- ${stageName} ---`));
|
|
387
|
-
setTimeout(() => {
|
|
388
|
-
stage.status = "completed";
|
|
389
|
-
stage.logs = `${stageName} completed successfully`;
|
|
390
|
-
currentStage++;
|
|
391
|
-
}, 1e3 + Math.random() * 2e3);
|
|
392
|
-
} else {
|
|
393
|
-
currentStage++;
|
|
394
|
-
}
|
|
395
|
-
}, 500);
|
|
396
|
-
process.on("SIGINT", () => {
|
|
397
|
-
clearInterval(interval);
|
|
398
|
-
run.status = "cancelled";
|
|
399
|
-
console.log(pc4.yellow("\n\n\u26A0 Run cancelled"));
|
|
400
|
-
process.exit(1);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
var demoRuns, runCommand;
|
|
404
|
-
var init_run = __esm({
|
|
405
|
-
"src/commands/run.ts"() {
|
|
406
|
-
"use strict";
|
|
407
|
-
init_config();
|
|
408
|
-
init_error();
|
|
409
|
-
demoRuns = /* @__PURE__ */ new Map();
|
|
410
|
-
runCommand = new Command2("run").description("Trigger Codowave to process a GitHub issue").argument("<issue>", "GitHub issue number, URL (https://github.com/owner/repo/issues/123), or owner/repo#123").option("-r, --repo <owner/repo>", "Target repository (e.g. owner/repo)").option("-s, --stream", "Stream run progress (SSE)", false).action(async (_issueArg, _options) => {
|
|
411
|
-
try {
|
|
412
|
-
const parsed = parseIssue(_issueArg);
|
|
413
|
-
if (!parsed) {
|
|
414
|
-
console.error(pc4.red("\nInvalid issue format. Expected one of:"));
|
|
415
|
-
console.error(pc4.gray(" \u2022 Issue number: 123"));
|
|
416
|
-
console.error(pc4.gray(" \u2022 Full URL: https://github.com/owner/repo/issues/123"));
|
|
417
|
-
console.error(pc4.gray(" \u2022 Short form: owner/repo#123"));
|
|
418
|
-
console.error(pc4.gray(" \u2022 With repo flag: --repo owner/repo 123"));
|
|
419
|
-
process.exit(1);
|
|
420
|
-
}
|
|
421
|
-
if (_options.repo) {
|
|
422
|
-
const parts = _options.repo.split("/");
|
|
423
|
-
parsed.owner = parts[0] || "";
|
|
424
|
-
parsed.repo = parts[1] || "";
|
|
425
|
-
}
|
|
426
|
-
let config = null;
|
|
427
|
-
try {
|
|
428
|
-
config = readConfig();
|
|
429
|
-
} catch {
|
|
430
|
-
}
|
|
431
|
-
if (config && config.apiKey && config.repos.length > 0) {
|
|
432
|
-
console.log(pc4.blue("Connecting to Codowave API..."));
|
|
433
|
-
if (!parsed.owner || !parsed.repo) {
|
|
434
|
-
console.error(pc4.red("Repository required. Use -r option or include in issue URL."));
|
|
435
|
-
process.exit(1);
|
|
436
|
-
}
|
|
437
|
-
const runId = await triggerRun(config, parsed);
|
|
438
|
-
console.log(pc4.green(`\u2713 Run triggered: ${runId}`));
|
|
439
|
-
if (_options.stream) {
|
|
440
|
-
console.log(pc4.blue("\nStreaming run progress..."));
|
|
441
|
-
} else {
|
|
442
|
-
console.log(pc4.gray(`
|
|
443
|
-
Run started. Use \`codowave status ${runId}\` to check progress.`));
|
|
444
|
-
}
|
|
445
|
-
} else {
|
|
446
|
-
console.log(pc4.yellow("\u26A0 No config found. Running in demo mode.\n"));
|
|
447
|
-
const run = createDemoRun(parsed);
|
|
448
|
-
if (_options.stream || !process.stdout.isTTY) {
|
|
449
|
-
streamDemoRun(run);
|
|
450
|
-
} else {
|
|
451
|
-
console.log(pc4.green(`\u2713 Run started: ${run.id}`));
|
|
452
|
-
console.log(pc4.gray(`
|
|
453
|
-
Use \`codowave status ${run.id}\` to check progress.`));
|
|
454
|
-
console.log(pc4.gray(`Use \`codowave logs ${run.id} -f\` to follow logs.`));
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
} catch (err) {
|
|
458
|
-
handleError(err, "run");
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
// src/commands/status.ts
|
|
465
|
-
var status_exports = {};
|
|
466
|
-
__export(status_exports, {
|
|
467
|
-
getRun: () => getRun,
|
|
468
|
-
statusCommand: () => statusCommand
|
|
469
|
-
});
|
|
470
|
-
import { Command as Command3 } from "commander";
|
|
471
|
-
import pc5 from "picocolors";
|
|
472
|
-
function initDemoData() {
|
|
473
|
-
if (demoRuns2.size === 0) {
|
|
474
|
-
const demoRun = {
|
|
475
|
-
id: "latest",
|
|
476
|
-
repo: "CodowaveAI/Codowave",
|
|
477
|
-
status: "in_progress",
|
|
478
|
-
issue: "#53: Implement CLI status and logs commands",
|
|
479
|
-
branchName: "agent/issue-53",
|
|
480
|
-
startedAt: new Date(Date.now() - 5 * 60 * 1e3).toISOString(),
|
|
481
|
-
stages: [
|
|
482
|
-
{ name: "context", status: "completed", logs: "Loaded 12 files, 3 PRs context" },
|
|
483
|
-
{ name: "planning", status: "completed", logs: "Generated implementation plan" },
|
|
484
|
-
{ name: "implementation", status: "running", logs: "Implementing status command..." },
|
|
485
|
-
{ name: "testing", status: "pending" },
|
|
486
|
-
{ name: "pr-creation", status: "pending" }
|
|
487
|
-
]
|
|
488
|
-
};
|
|
489
|
-
demoRuns2.set(demoRun.id, demoRun);
|
|
490
|
-
const completedRun = {
|
|
491
|
-
id: "abc-123-def",
|
|
492
|
-
repo: "CodowaveAI/Codowave",
|
|
493
|
-
status: "completed",
|
|
494
|
-
issue: "#52: Add authentication flow",
|
|
495
|
-
prNumber: 78,
|
|
496
|
-
prTitle: "feat: Add OAuth authentication flow",
|
|
497
|
-
branchName: "feat/auth-flow",
|
|
498
|
-
startedAt: new Date(Date.now() - 60 * 60 * 1e3).toISOString(),
|
|
499
|
-
completedAt: new Date(Date.now() - 45 * 60 * 1e3).toISOString(),
|
|
500
|
-
stages: [
|
|
501
|
-
{ name: "context", status: "completed" },
|
|
502
|
-
{ name: "planning", status: "completed" },
|
|
503
|
-
{ name: "implementation", status: "completed" },
|
|
504
|
-
{ name: "testing", status: "completed" },
|
|
505
|
-
{ name: "pr-creation", status: "completed" }
|
|
506
|
-
]
|
|
507
|
-
};
|
|
508
|
-
demoRuns2.set(completedRun.id, completedRun);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
function getRun(runId) {
|
|
512
|
-
initDemoData();
|
|
513
|
-
if (!runId) {
|
|
514
|
-
return Array.from(demoRuns2.values()).sort(
|
|
515
|
-
(a, b) => new Date(b.startedAt || 0).getTime() - new Date(a.startedAt || 0).getTime()
|
|
516
|
-
)[0];
|
|
517
|
-
}
|
|
518
|
-
return demoRuns2.get(runId);
|
|
519
|
-
}
|
|
520
|
-
function formatStatus(status) {
|
|
521
|
-
switch (status) {
|
|
522
|
-
case "pending":
|
|
523
|
-
return pc5.gray("pending");
|
|
524
|
-
case "in_progress":
|
|
525
|
-
return pc5.blue("in_progress");
|
|
526
|
-
case "completed":
|
|
527
|
-
return pc5.green("completed");
|
|
528
|
-
case "failed":
|
|
529
|
-
return pc5.red("failed");
|
|
530
|
-
case "cancelled":
|
|
531
|
-
return pc5.gray("cancelled");
|
|
532
|
-
default:
|
|
533
|
-
return pc5.gray(status);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
function formatStageStatus(status) {
|
|
537
|
-
switch (status) {
|
|
538
|
-
case "pending":
|
|
539
|
-
return pc5.gray("[ ]");
|
|
540
|
-
case "running":
|
|
541
|
-
return pc5.blue("[~]");
|
|
542
|
-
case "completed":
|
|
543
|
-
return pc5.green("[+]");
|
|
544
|
-
case "failed":
|
|
545
|
-
return pc5.red("[x]");
|
|
546
|
-
case "skipped":
|
|
547
|
-
return pc5.gray("[-]");
|
|
548
|
-
default:
|
|
549
|
-
return pc5.gray("[?]");
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
function formatDuration(startedAt, completedAt) {
|
|
553
|
-
if (!startedAt) return "";
|
|
554
|
-
const start = new Date(startedAt).getTime();
|
|
555
|
-
const end = completedAt ? new Date(completedAt).getTime() : Date.now();
|
|
556
|
-
const seconds = Math.floor((end - start) / 1e3);
|
|
557
|
-
if (seconds < 60) return `${seconds}s`;
|
|
558
|
-
const minutes = Math.floor(seconds / 60);
|
|
559
|
-
const remainingSeconds = seconds % 60;
|
|
560
|
-
if (minutes < 60) return `${minutes}m ${remainingSeconds}s`;
|
|
561
|
-
const hours = Math.floor(minutes / 60);
|
|
562
|
-
const remainingMinutes = minutes % 60;
|
|
563
|
-
return `${hours}h ${remainingMinutes}m`;
|
|
564
|
-
}
|
|
565
|
-
var demoRuns2, statusCommand;
|
|
566
|
-
var init_status = __esm({
|
|
567
|
-
"src/commands/status.ts"() {
|
|
568
|
-
"use strict";
|
|
569
|
-
init_error();
|
|
570
|
-
demoRuns2 = /* @__PURE__ */ new Map();
|
|
571
|
-
statusCommand = new Command3("status").description("Show the status of a Codowave run").argument("[run-id]", "Run ID (defaults to latest)").option("-r, --repo <owner/repo>", "Filter by repository").action(async (_runId, _options) => {
|
|
572
|
-
try {
|
|
573
|
-
const run = getRun(_runId);
|
|
574
|
-
if (!run) {
|
|
575
|
-
console.log(pc5.yellow("No runs found. Run `codowave run <issue>` to start a new run."));
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
if (_options?.repo && run.repo !== _options.repo) {
|
|
579
|
-
console.log(pc5.yellow("No run found for repository " + _options.repo));
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
console.log(pc5.bold("\n=== Run Status ===\n"));
|
|
583
|
-
console.log(pc5.bold("ID: ") + run.id);
|
|
584
|
-
console.log(pc5.bold("Repo: ") + run.repo);
|
|
585
|
-
console.log(pc5.bold("Issue: ") + run.issue);
|
|
586
|
-
console.log(pc5.bold("Status: ") + formatStatus(run.status));
|
|
587
|
-
console.log(pc5.bold("Branch: ") + (run.branchName || pc5.gray("(none)")));
|
|
588
|
-
if (run.prNumber) {
|
|
589
|
-
console.log(pc5.bold("PR: ") + "#" + run.prNumber + " - " + (run.prTitle || ""));
|
|
590
|
-
}
|
|
591
|
-
if (run.startedAt) {
|
|
592
|
-
console.log(pc5.bold("Started: ") + new Date(run.startedAt).toLocaleString());
|
|
593
|
-
}
|
|
594
|
-
if (run.completedAt) {
|
|
595
|
-
console.log(pc5.bold("Duration: ") + formatDuration(run.startedAt, run.completedAt));
|
|
596
|
-
} else if (run.startedAt) {
|
|
597
|
-
console.log(pc5.bold("Duration: ") + pc5.blue("running... ") + formatDuration(run.startedAt));
|
|
598
|
-
}
|
|
599
|
-
if (run.errorMessage) {
|
|
600
|
-
console.log(pc5.bold("Error: ") + pc5.red(run.errorMessage));
|
|
601
|
-
}
|
|
602
|
-
console.log(pc5.bold("\n=== Stages ===\n"));
|
|
603
|
-
for (const stage of run.stages) {
|
|
604
|
-
const statusIcon = formatStageStatus(stage.status);
|
|
605
|
-
const statusText = pc5.bold("[" + stage.status + "]");
|
|
606
|
-
console.log(" " + statusIcon + " " + pc5.bold(stage.name.padEnd(20)) + " " + statusText);
|
|
607
|
-
}
|
|
608
|
-
console.log("");
|
|
609
|
-
} catch (err) {
|
|
610
|
-
handleError(err, "status");
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
// src/commands/logs.ts
|
|
617
|
-
var logs_exports = {};
|
|
618
|
-
__export(logs_exports, {
|
|
619
|
-
logsCommand: () => logsCommand
|
|
620
|
-
});
|
|
621
|
-
import { Command as Command4 } from "commander";
|
|
622
|
-
import pc6 from "picocolors";
|
|
623
|
-
var logsCommand;
|
|
624
|
-
var init_logs = __esm({
|
|
625
|
-
"src/commands/logs.ts"() {
|
|
626
|
-
"use strict";
|
|
627
|
-
init_status();
|
|
628
|
-
init_error();
|
|
629
|
-
logsCommand = new Command4("logs").description("Stream logs for a Codowave run").argument("[run-id]", "Run ID (defaults to latest)").option("-f, --follow", "Follow log output (SSE stream)").option("-s, --stage <name>", "Show logs for a specific stage").option("--no-color", "Disable colored output").action(async (_runId, _options) => {
|
|
630
|
-
try {
|
|
631
|
-
const run = getRun(_runId);
|
|
632
|
-
if (!run) {
|
|
633
|
-
console.log(pc6.yellow("No runs found. Run `codowave run <issue>` to start a new run."));
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (_options?.stage) {
|
|
637
|
-
const stage = run.stages.find((s) => s.name === _options.stage);
|
|
638
|
-
if (!stage) {
|
|
639
|
-
console.log(pc6.red('Stage "' + _options.stage + '" not found.'));
|
|
640
|
-
console.log(pc6.gray("Available stages: ") + run.stages.map((s) => s.name).join(", "));
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
console.log(pc6.bold("\n=== Logs: " + stage.name + " ===\n"));
|
|
644
|
-
console.log(pc6.bold("Status: ") + stage.status);
|
|
645
|
-
if (stage.logs) {
|
|
646
|
-
console.log(pc6.gray("\n--- Output ---\n"));
|
|
647
|
-
console.log(stage.logs);
|
|
648
|
-
} else {
|
|
649
|
-
console.log(pc6.gray("\n(no logs available yet)"));
|
|
650
|
-
}
|
|
651
|
-
if (_options.follow && stage.status === "running") {
|
|
652
|
-
console.log(pc6.blue("\n--- Following live logs (Ctrl+C to exit) ---\n"));
|
|
653
|
-
console.log(pc6.gray("(Live streaming would connect to API SSE endpoint in production)"));
|
|
654
|
-
}
|
|
655
|
-
console.log("");
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
console.log(pc6.bold("\n=== Logs: " + run.id + " ===\n"));
|
|
659
|
-
console.log(pc6.bold("Issue: ") + run.issue);
|
|
660
|
-
console.log(pc6.bold("Status: ") + run.status);
|
|
661
|
-
console.log("");
|
|
662
|
-
for (const stage of run.stages) {
|
|
663
|
-
const statusIcon = stage.status === "completed" ? "[+]" : stage.status === "failed" ? "[x]" : stage.status === "running" ? "[~]" : "[ ]";
|
|
664
|
-
console.log(pc6.bold("\n" + statusIcon + " " + stage.name + "\n"));
|
|
665
|
-
if (stage.logs) {
|
|
666
|
-
console.log(stage.logs);
|
|
667
|
-
} else if (stage.status === "pending") {
|
|
668
|
-
console.log(pc6.gray("(pending)"));
|
|
669
|
-
} else if (stage.status === "running") {
|
|
670
|
-
console.log(pc6.blue("(running...)"));
|
|
671
|
-
} else if (stage.status === "skipped") {
|
|
672
|
-
console.log(pc6.gray("(skipped)"));
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
if (_options?.follow && run.status === "in_progress") {
|
|
676
|
-
console.log(pc6.blue("\n--- Following live logs (Ctrl+C to exit) ---\n"));
|
|
677
|
-
console.log(pc6.gray("(Live streaming would connect to API SSE endpoint in production)"));
|
|
678
|
-
let dots = 0;
|
|
679
|
-
const interval = setInterval(() => {
|
|
680
|
-
dots = (dots + 1) % 4;
|
|
681
|
-
process.stdout.write(pc6.blue("\r" + " ".repeat(dots) + " waiting for updates..."));
|
|
682
|
-
}, 500);
|
|
683
|
-
process.on("SIGINT", () => {
|
|
684
|
-
clearInterval(interval);
|
|
685
|
-
console.log(pc6.gray("\n\n(Stopped following)"));
|
|
686
|
-
process.exit(0);
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
console.log("");
|
|
690
|
-
} catch (err) {
|
|
691
|
-
handleError(err, "logs");
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
// src/commands/config-cmd.ts
|
|
698
|
-
var config_cmd_exports = {};
|
|
699
|
-
__export(config_cmd_exports, {
|
|
700
|
-
configCommand: () => configCommand
|
|
701
|
-
});
|
|
702
|
-
import { Command as Command5 } from "commander";
|
|
703
|
-
import pc7 from "picocolors";
|
|
704
|
-
var configCommand;
|
|
705
|
-
var init_config_cmd = __esm({
|
|
706
|
-
"src/commands/config-cmd.ts"() {
|
|
707
|
-
"use strict";
|
|
708
|
-
init_config();
|
|
709
|
-
configCommand = new Command5("config").description("Get or set Codowave configuration values");
|
|
710
|
-
configCommand.action(() => {
|
|
711
|
-
try {
|
|
712
|
-
const config = readConfig();
|
|
713
|
-
if (config) {
|
|
714
|
-
console.log(pc7.bold("\n\u2699\uFE0F Current Configuration:\n"));
|
|
715
|
-
console.log(` ${pc7.cyan("apiKey")}: ${config.apiKey ? pc7.green("\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022") + pc7.gray(" (hidden)") : pc7.yellow("not set")}`);
|
|
716
|
-
console.log(` ${pc7.cyan("apiUrl")}: ${config.apiUrl}`);
|
|
717
|
-
console.log(` ${pc7.cyan("autopilot")}: ${config.autopilot ? pc7.green("enabled") : pc7.yellow("disabled")}`);
|
|
718
|
-
console.log(` ${pc7.cyan("labels")}: ${config.labels?.join(", ") || pc7.yellow("not set")}`);
|
|
719
|
-
console.log(` ${pc7.cyan("repos")}: ${config.repos.length} repository(s) configured`);
|
|
720
|
-
console.log(pc7.gray("\n To reconfigure, run: ") + pc7.bold("codowave init") + pc7.gray("\n"));
|
|
721
|
-
} else {
|
|
722
|
-
console.log(pc7.yellow("\n\u26A0 No configuration found.\n"));
|
|
723
|
-
console.log(pc7.gray(" Run ") + pc7.bold("codowave init") + pc7.gray(" to get started.\n"));
|
|
724
|
-
}
|
|
725
|
-
} catch {
|
|
726
|
-
console.log(pc7.yellow("\n\u26A0 No configuration found.\n"));
|
|
727
|
-
console.log(pc7.gray(" Run ") + pc7.bold("codowave init") + pc7.gray(" to get started.\n"));
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
configCommand.command("list").description("List all available config options").action(() => {
|
|
731
|
-
console.log(pc7.bold("\n\u{1F4CB} Available Config Options:\n"));
|
|
732
|
-
console.log(` ${pc7.cyan("apiKey")} ${pc7.gray("\u2014 Your Codowave API key")}`);
|
|
733
|
-
console.log(` ${pc7.cyan("apiUrl")} ${pc7.gray("\u2014 API endpoint URL (default: https://api.codowave.com)")}`);
|
|
734
|
-
console.log(` ${pc7.cyan("repos")} ${pc7.gray("\u2014 List of configured repositories")}`);
|
|
735
|
-
console.log(` ${pc7.cyan("autopilot")} ${pc7.gray("\u2014 Enable/disable autopilot mode (true/false)")}`);
|
|
736
|
-
console.log(` ${pc7.cyan("labels")} ${pc7.gray("\u2014 GitHub labels for agent PRs (comma-separated)")}`);
|
|
737
|
-
console.log(` ${pc7.cyan("configPath")} ${pc7.gray("\u2014 Path to the config file")}`);
|
|
738
|
-
console.log("");
|
|
739
|
-
});
|
|
740
|
-
configCommand.command("get <key>").description("Get a config value").action((key) => {
|
|
741
|
-
try {
|
|
742
|
-
const config = readConfigOrThrow();
|
|
743
|
-
if (key === "configPath") {
|
|
744
|
-
console.log(pc7.green(getConfigPath()));
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
if (key === "repos") {
|
|
748
|
-
if (config.repos.length === 0) {
|
|
749
|
-
console.log(pc7.yellow("No repos configured."));
|
|
750
|
-
} else {
|
|
751
|
-
console.log(pc7.bold("\n\u{1F4E6} Configured Repositories:\n"));
|
|
752
|
-
config.repos.forEach((repo, index) => {
|
|
753
|
-
console.log(` ${index + 1}. ${pc7.cyan(`${repo.owner}/${repo.name}`)}`);
|
|
754
|
-
if (repo.id) {
|
|
755
|
-
console.log(` ${pc7.gray("ID: " + repo.id)}`);
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
console.log("");
|
|
759
|
-
}
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
if (key === "labels") {
|
|
763
|
-
if (config.labels.length === 0) {
|
|
764
|
-
console.log(pc7.yellow("No labels configured."));
|
|
765
|
-
} else {
|
|
766
|
-
console.log(pc7.bold("\n\u{1F3F7}\uFE0F Configured Labels:\n"));
|
|
767
|
-
config.labels.forEach((label, index) => {
|
|
768
|
-
console.log(` ${index + 1}. ${pc7.cyan(label)}`);
|
|
769
|
-
});
|
|
770
|
-
console.log("");
|
|
771
|
-
}
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
const value = config[key];
|
|
775
|
-
if (value === void 0) {
|
|
776
|
-
console.error(pc7.red(`\u2716 Unknown config key: ${key}`));
|
|
777
|
-
console.log(pc7.gray(` Run \`codowave config list\` to see available options.`));
|
|
778
|
-
process.exit(1);
|
|
779
|
-
}
|
|
780
|
-
console.log(value);
|
|
781
|
-
} catch (err) {
|
|
782
|
-
console.error(pc7.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
783
|
-
process.exit(1);
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
configCommand.command("set <key> <value>").description("Set a config value").action((key, value) => {
|
|
787
|
-
try {
|
|
788
|
-
const validKeys = ["apiKey", "apiUrl", "autopilot", "labels"];
|
|
789
|
-
if (!validKeys.includes(key)) {
|
|
790
|
-
console.error(pc7.red(`\u2716 Cannot set '${key}' directly.`));
|
|
791
|
-
console.log(pc7.gray(` For 'repos', use \`codowave repo add\` to manage repositories.`));
|
|
792
|
-
console.log(pc7.gray(` Run \`codowave config list\` to see available options.`));
|
|
793
|
-
process.exit(1);
|
|
794
|
-
}
|
|
795
|
-
if (key === "apiUrl") {
|
|
796
|
-
try {
|
|
797
|
-
new URL(value);
|
|
798
|
-
} catch {
|
|
799
|
-
console.error(pc7.red(`\u2716 Invalid URL: ${value}`));
|
|
800
|
-
process.exit(1);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
if (key === "autopilot") {
|
|
804
|
-
if (value !== "true" && value !== "false") {
|
|
805
|
-
console.error(pc7.red(`\u2716 Invalid value for autopilot: must be 'true' or 'false'`));
|
|
806
|
-
process.exit(1);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
if (key === "labels") {
|
|
810
|
-
const labels = value.split(",").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
811
|
-
const updates2 = { labels };
|
|
812
|
-
const newConfig2 = updateConfig(updates2);
|
|
813
|
-
console.log(pc7.green(`\u2713 Updated labels`));
|
|
814
|
-
console.log(pc7.gray(` labels = ${newConfig2.labels.join(", ")}`));
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
let typedValue = value;
|
|
818
|
-
if (key === "autopilot") {
|
|
819
|
-
typedValue = value === "true";
|
|
820
|
-
}
|
|
821
|
-
const updates = { [key]: typedValue };
|
|
822
|
-
const newConfig = updateConfig(updates);
|
|
823
|
-
console.log(pc7.green(`\u2713 Updated ${key}`));
|
|
824
|
-
if (key === "apiKey") {
|
|
825
|
-
console.log(pc7.gray(` ${key} = \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022`));
|
|
826
|
-
} else {
|
|
827
|
-
console.log(pc7.gray(` ${key} = ${newConfig[key]}`));
|
|
828
|
-
}
|
|
829
|
-
} catch (err) {
|
|
830
|
-
console.error(pc7.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
831
|
-
process.exit(1);
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
configCommand.command("show").description("Show all current config values").action(() => {
|
|
835
|
-
try {
|
|
836
|
-
const config = readConfigOrThrow();
|
|
837
|
-
console.log(pc7.bold("\n\u2699\uFE0F Current Configuration:\n"));
|
|
838
|
-
console.log(` ${pc7.cyan("apiKey")}: ${config.apiKey ? pc7.green("\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022") + pc7.gray(" (hidden)") : pc7.yellow("not set")}`);
|
|
839
|
-
console.log(` ${pc7.cyan("apiUrl")}: ${config.apiUrl}`);
|
|
840
|
-
console.log(` ${pc7.cyan("autopilot")}: ${config.autopilot ? pc7.green("enabled") : pc7.yellow("disabled")}`);
|
|
841
|
-
console.log(` ${pc7.cyan("labels")}: ${config.labels.join(", ") || pc7.yellow("not set")}`);
|
|
842
|
-
console.log(` ${pc7.cyan("repos")}: ${config.repos.length} repository(s) configured`);
|
|
843
|
-
console.log(` ${pc7.cyan("configPath")}: ${pc7.gray(getConfigPath())}`);
|
|
844
|
-
if (config.repos.length > 0) {
|
|
845
|
-
console.log(pc7.bold(pc7.gray("\n Repositories:")));
|
|
846
|
-
config.repos.forEach((repo) => {
|
|
847
|
-
console.log(` \u2022 ${repo.owner}/${repo.name}${repo.id ? pc7.gray(` (${repo.id})`) : ""}`);
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
if (config.labels.length > 0) {
|
|
851
|
-
console.log(pc7.bold(pc7.gray("\n Labels:")));
|
|
852
|
-
config.labels.forEach((label) => {
|
|
853
|
-
console.log(` \u2022 ${label}`);
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
console.log("");
|
|
857
|
-
} catch (err) {
|
|
858
|
-
console.error(pc7.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
859
|
-
process.exit(1);
|
|
860
|
-
}
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
// src/commands/connect.ts
|
|
866
|
-
var connect_exports = {};
|
|
867
|
-
__export(connect_exports, {
|
|
868
|
-
connectCommand: () => connectCommand,
|
|
869
|
-
performConnect: () => performConnect
|
|
870
|
-
});
|
|
871
|
-
import { Command as Command6 } from "commander";
|
|
872
|
-
import pc8 from "picocolors";
|
|
873
|
-
async function performConnect(accessToken) {
|
|
874
|
-
const config = updateConfig({
|
|
875
|
-
apiKey: accessToken,
|
|
876
|
-
apiUrl: PRO_API_URL
|
|
877
|
-
});
|
|
878
|
-
console.log(pc8.green("\u2713 Connected to Codowave Pro!"));
|
|
879
|
-
console.log(pc8.gray(` API URL: ${config.apiUrl}`));
|
|
880
|
-
}
|
|
881
|
-
var PRO_API_URL, connectCommand;
|
|
882
|
-
var init_connect = __esm({
|
|
883
|
-
"src/commands/connect.ts"() {
|
|
884
|
-
"use strict";
|
|
885
|
-
init_config();
|
|
886
|
-
PRO_API_URL = "https://api.codowave.com";
|
|
887
|
-
connectCommand = new Command6("connect").description("Connect to Codowave Pro (upgrade from OSS)").action(async () => {
|
|
888
|
-
try {
|
|
889
|
-
console.log(pc8.bold("\n\u{1F517} Codowave Connect\n"));
|
|
890
|
-
console.log(pc8.gray("This command upgrades your OSS installation to Codowave Pro.\n"));
|
|
891
|
-
const config = readConfig();
|
|
892
|
-
const isAlreadyPro = config?.apiUrl === PRO_API_URL;
|
|
893
|
-
if (isAlreadyPro) {
|
|
894
|
-
console.log(pc8.green("\u2713 You are already connected to Codowave Pro!"));
|
|
895
|
-
console.log(pc8.gray(` API URL: ${config?.apiUrl}`));
|
|
896
|
-
console.log("");
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
console.log(pc8.blue("Starting OAuth device flow...\n"));
|
|
900
|
-
console.log(pc8.gray(" 1. Requesting device code..."));
|
|
901
|
-
const deviceCode = `CODOWAVE-${Date.now().toString(36).toUpperCase()}`;
|
|
902
|
-
const verificationUri = "https://codowave.com/activate";
|
|
903
|
-
console.log(pc8.green("\n \u26A0\uFE0F Device Code: ") + pc8.bold(deviceCode));
|
|
904
|
-
console.log(pc8.gray("\n 2. Please visit: ") + pc8.cyan(verificationUri));
|
|
905
|
-
console.log(pc8.gray(" and enter the device code above.\n"));
|
|
906
|
-
console.log(pc8.yellow(" \u2139\uFE0F This is a stub implementation."));
|
|
907
|
-
console.log(pc8.gray(" In production, this would poll for OAuth completion.\n"));
|
|
908
|
-
console.log(pc8.blue(" 3. Would save Pro token and switch API URL...\n"));
|
|
909
|
-
console.log(pc8.bold("What would happen:\n"));
|
|
910
|
-
console.log(` \u2022 Save Pro API token to ${getConfigPath()}`);
|
|
911
|
-
console.log(` \u2022 Set apiUrl to ${PRO_API_URL}`);
|
|
912
|
-
console.log("");
|
|
913
|
-
console.log(pc8.gray("Run with ") + pc8.cyan("CODOWAVE_CONNECT=1") + pc8.gray(" to enable (not implemented yet)"));
|
|
914
|
-
console.log("");
|
|
915
|
-
} catch (err) {
|
|
916
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
917
|
-
console.error(pc8.red(`
|
|
918
|
-
\u2716 Error: ${message}
|
|
919
|
-
`));
|
|
920
|
-
process.exit(1);
|
|
921
|
-
}
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
});
|
|
925
|
-
|
|
926
|
-
// src/commands/repo-cmd.ts
|
|
927
|
-
var repo_cmd_exports = {};
|
|
928
|
-
__export(repo_cmd_exports, {
|
|
929
|
-
repoCommand: () => repoCommand
|
|
930
|
-
});
|
|
931
|
-
import { Command as Command7 } from "commander";
|
|
932
|
-
import pc9 from "picocolors";
|
|
933
|
-
var repoCommand;
|
|
934
|
-
var init_repo_cmd = __esm({
|
|
935
|
-
"src/commands/repo-cmd.ts"() {
|
|
936
|
-
"use strict";
|
|
937
|
-
init_config();
|
|
938
|
-
repoCommand = new Command7("repo").description("Manage GitHub repositories");
|
|
939
|
-
repoCommand.command("list").description("List all managed repositories").action(() => {
|
|
940
|
-
try {
|
|
941
|
-
const config = readConfigOrThrow();
|
|
942
|
-
if (config.repos.length === 0) {
|
|
943
|
-
console.log(pc9.yellow("\n\u26A0 No repositories configured.\n"));
|
|
944
|
-
console.log(pc9.gray(" Run ") + pc9.bold("codowave repo add <owner/repo>") + pc9.gray(" to add a repository.\n"));
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
console.log(pc9.bold("\n\u{1F4E6} Managed Repositories:\n"));
|
|
948
|
-
config.repos.forEach((repo, index) => {
|
|
949
|
-
console.log(` ${index + 1}. ${pc9.cyan(`${repo.owner}/${repo.name}`)}`);
|
|
950
|
-
if (repo.id) {
|
|
951
|
-
console.log(` ${pc9.gray("ID: " + repo.id)}`);
|
|
952
|
-
}
|
|
953
|
-
});
|
|
954
|
-
console.log("");
|
|
955
|
-
} catch (err) {
|
|
956
|
-
console.error(pc9.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
957
|
-
process.exit(1);
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
repoCommand.command("add <owner/repo>").description("Add a repository (format: owner/repo)").action((repoArg) => {
|
|
961
|
-
try {
|
|
962
|
-
const parts = repoArg.split("/");
|
|
963
|
-
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
964
|
-
console.error(pc9.red(`\u2716 Invalid repository format. Use: owner/repo`));
|
|
965
|
-
console.log(pc9.gray(" Example: codowave repo add octocat/Hello-World"));
|
|
966
|
-
process.exit(1);
|
|
967
|
-
}
|
|
968
|
-
const owner = parts[0];
|
|
969
|
-
const name = parts[1];
|
|
970
|
-
const config = readConfigOrThrow();
|
|
971
|
-
const exists = config.repos.some(
|
|
972
|
-
(r) => r.owner.toLowerCase() === owner.toLowerCase() && r.name.toLowerCase() === name.toLowerCase()
|
|
973
|
-
);
|
|
974
|
-
if (exists) {
|
|
975
|
-
console.error(pc9.red(`\u2716 Repository ${repoArg} is already configured.`));
|
|
976
|
-
process.exit(1);
|
|
977
|
-
}
|
|
978
|
-
const newRepo = { owner, name };
|
|
979
|
-
const updatedRepos = [...config.repos, newRepo];
|
|
980
|
-
updateConfig({ repos: updatedRepos });
|
|
981
|
-
console.log(pc9.green(`
|
|
982
|
-
\u2713 Added repository ${repoArg}
|
|
983
|
-
`));
|
|
984
|
-
} catch (err) {
|
|
985
|
-
console.error(pc9.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
986
|
-
process.exit(1);
|
|
987
|
-
}
|
|
988
|
-
});
|
|
989
|
-
repoCommand.command("remove <owner/repo>").description("Remove a repository (format: owner/repo)").action((repoArg) => {
|
|
990
|
-
try {
|
|
991
|
-
const parts = repoArg.split("/");
|
|
992
|
-
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
993
|
-
console.error(pc9.red(`\u2716 Invalid repository format. Use: owner/repo`));
|
|
994
|
-
console.log(pc9.gray(" Example: codowave repo remove octocat/Hello-World"));
|
|
995
|
-
process.exit(1);
|
|
996
|
-
}
|
|
997
|
-
const owner = parts[0];
|
|
998
|
-
const name = parts[1];
|
|
999
|
-
const config = readConfigOrThrow();
|
|
1000
|
-
const exists = config.repos.some(
|
|
1001
|
-
(r) => r.owner.toLowerCase() === owner.toLowerCase() && r.name.toLowerCase() === name.toLowerCase()
|
|
1002
|
-
);
|
|
1003
|
-
if (!exists) {
|
|
1004
|
-
console.error(pc9.red(`\u2716 Repository ${repoArg} is not configured.`));
|
|
1005
|
-
console.log(pc9.gray(" Run ") + pc9.bold("codowave repo list") + pc9.gray(" to see configured repositories.\n"));
|
|
1006
|
-
process.exit(1);
|
|
1007
|
-
}
|
|
1008
|
-
const updatedRepos = config.repos.filter(
|
|
1009
|
-
(r) => !(r.owner.toLowerCase() === owner.toLowerCase() && r.name.toLowerCase() === name.toLowerCase())
|
|
1010
|
-
);
|
|
1011
|
-
updateConfig({ repos: updatedRepos });
|
|
1012
|
-
console.log(pc9.green(`
|
|
1013
|
-
\u2713 Removed repository ${repoArg}
|
|
1014
|
-
`));
|
|
1015
|
-
} catch (err) {
|
|
1016
|
-
console.error(pc9.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
1017
|
-
process.exit(1);
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
|
|
1023
|
-
// src/commands/autopilot-cmd.ts
|
|
1024
|
-
var autopilot_cmd_exports = {};
|
|
1025
|
-
__export(autopilot_cmd_exports, {
|
|
1026
|
-
autopilotCommand: () => autopilotCommand
|
|
1027
|
-
});
|
|
1028
|
-
import { Command as Command8 } from "commander";
|
|
1029
|
-
import pc10 from "picocolors";
|
|
1030
|
-
var autopilotCommand;
|
|
1031
|
-
var init_autopilot_cmd = __esm({
|
|
1032
|
-
"src/commands/autopilot-cmd.ts"() {
|
|
1033
|
-
"use strict";
|
|
1034
|
-
init_config();
|
|
1035
|
-
autopilotCommand = new Command8("autopilot").description("Toggle autopilot mode");
|
|
1036
|
-
autopilotCommand.command("enable").description("Enable autopilot mode").action(() => {
|
|
1037
|
-
try {
|
|
1038
|
-
updateConfig({ autopilot: true });
|
|
1039
|
-
console.log(pc10.green("\n\u2713 Autopilot enabled\n"));
|
|
1040
|
-
console.log(pc10.gray(" Codowave will automatically process PRs and issues.\n"));
|
|
1041
|
-
} catch (err) {
|
|
1042
|
-
console.error(pc10.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
1043
|
-
process.exit(1);
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
autopilotCommand.command("disable").description("Disable autopilot mode").action(() => {
|
|
1047
|
-
try {
|
|
1048
|
-
updateConfig({ autopilot: false });
|
|
1049
|
-
console.log(pc10.green("\n\u2713 Autopilot disabled\n"));
|
|
1050
|
-
} catch (err) {
|
|
1051
|
-
console.error(pc10.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
1052
|
-
process.exit(1);
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
|
|
1058
|
-
// src/commands/labels-cmd.ts
|
|
1059
|
-
var labels_cmd_exports = {};
|
|
1060
|
-
__export(labels_cmd_exports, {
|
|
1061
|
-
labelsCommand: () => labelsCommand
|
|
1062
|
-
});
|
|
1063
|
-
import { Command as Command9 } from "commander";
|
|
1064
|
-
import pc11 from "picocolors";
|
|
1065
|
-
var labelsCommand;
|
|
1066
|
-
var init_labels_cmd = __esm({
|
|
1067
|
-
"src/commands/labels-cmd.ts"() {
|
|
1068
|
-
"use strict";
|
|
1069
|
-
init_config();
|
|
1070
|
-
labelsCommand = new Command9("labels").description("Configure GitHub labels for agent activity");
|
|
1071
|
-
labelsCommand.command("set <labels>").description("Set GitHub labels (comma-separated)").action((labelsArg) => {
|
|
1072
|
-
try {
|
|
1073
|
-
const labels = labelsArg.split(",").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
1074
|
-
if (labels.length === 0) {
|
|
1075
|
-
console.error(pc11.red("\u2716 No labels provided."));
|
|
1076
|
-
console.log(pc11.gray(" Example: codowave labels set codowave-agent,needs-review"));
|
|
1077
|
-
process.exit(1);
|
|
1078
|
-
}
|
|
1079
|
-
updateConfig({ labels });
|
|
1080
|
-
console.log(pc11.green("\n\u2713 Labels updated\n"));
|
|
1081
|
-
console.log(pc11.gray(" Labels: ") + pc11.cyan(labels.join(", ")) + "\n");
|
|
1082
|
-
} catch (err) {
|
|
1083
|
-
console.error(pc11.red(`\u2716 ${err instanceof Error ? err.message : String(err)}`));
|
|
1084
|
-
process.exit(1);
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
|
|
1090
|
-
// src/commands/runs-cmd.ts
|
|
1091
|
-
var runs_cmd_exports = {};
|
|
1092
|
-
__export(runs_cmd_exports, {
|
|
1093
|
-
runsCommand: () => runsCommand
|
|
1094
|
-
});
|
|
1095
|
-
import { Command as Command10 } from "commander";
|
|
1096
|
-
import pc12 from "picocolors";
|
|
1097
|
-
var runsCommand;
|
|
1098
|
-
var init_runs_cmd = __esm({
|
|
1099
|
-
"src/commands/runs-cmd.ts"() {
|
|
1100
|
-
"use strict";
|
|
1101
|
-
init_status();
|
|
1102
|
-
init_error();
|
|
1103
|
-
runsCommand = new Command10("runs").description("Manage Codowave runs");
|
|
1104
|
-
runsCommand.command("list").alias("ls").description("List recent runs").option("-l, --limit <number>", "Number of runs to show", "10").option("-r, --repo <owner/repo>", "Filter by repository").option("--status <status>", "Filter by status (pending, in_progress, completed, failed)").action(async (options) => {
|
|
1105
|
-
try {
|
|
1106
|
-
const limit = parseInt(options.limit || "10", 10);
|
|
1107
|
-
const demoRuns3 = [
|
|
1108
|
-
{
|
|
1109
|
-
id: "latest",
|
|
1110
|
-
repo: "CodowaveAI/Codowave",
|
|
1111
|
-
status: "in_progress",
|
|
1112
|
-
issue: "#53: Implement CLI status and logs commands",
|
|
1113
|
-
branchName: "agent/issue-53",
|
|
1114
|
-
startedAt: new Date(Date.now() - 5 * 60 * 1e3).toISOString(),
|
|
1115
|
-
stages: [
|
|
1116
|
-
{ name: "context", status: "completed" },
|
|
1117
|
-
{ name: "planning", status: "completed" },
|
|
1118
|
-
{ name: "implementation", status: "running" },
|
|
1119
|
-
{ name: "testing", status: "pending" },
|
|
1120
|
-
{ name: "pr-creation", status: "pending" }
|
|
1121
|
-
]
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
id: "abc-123-def",
|
|
1125
|
-
repo: "CodowaveAI/Codowave",
|
|
1126
|
-
status: "completed",
|
|
1127
|
-
issue: "#52: Add authentication flow",
|
|
1128
|
-
prNumber: 78,
|
|
1129
|
-
prTitle: "feat: Add OAuth authentication flow",
|
|
1130
|
-
branchName: "feat/auth-flow",
|
|
1131
|
-
startedAt: new Date(Date.now() - 60 * 60 * 1e3).toISOString(),
|
|
1132
|
-
completedAt: new Date(Date.now() - 45 * 60 * 1e3).toISOString(),
|
|
1133
|
-
stages: [
|
|
1134
|
-
{ name: "context", status: "completed" },
|
|
1135
|
-
{ name: "planning", status: "completed" },
|
|
1136
|
-
{ name: "implementation", status: "completed" },
|
|
1137
|
-
{ name: "testing", status: "completed" },
|
|
1138
|
-
{ name: "pr-creation", status: "completed" }
|
|
1139
|
-
]
|
|
1140
|
-
},
|
|
1141
|
-
{
|
|
1142
|
-
id: "xyz-789-ghi",
|
|
1143
|
-
repo: "CodowaveAI/Codowave",
|
|
1144
|
-
status: "failed",
|
|
1145
|
-
issue: "#51: Fix memory leak",
|
|
1146
|
-
branchName: "fix/memory-leak",
|
|
1147
|
-
startedAt: new Date(Date.now() - 120 * 60 * 1e3).toISOString(),
|
|
1148
|
-
completedAt: new Date(Date.now() - 100 * 60 * 1e3).toISOString(),
|
|
1149
|
-
errorMessage: "Test suite failed: 3 tests failed",
|
|
1150
|
-
stages: [
|
|
1151
|
-
{ name: "context", status: "completed" },
|
|
1152
|
-
{ name: "planning", status: "completed" },
|
|
1153
|
-
{ name: "implementation", status: "completed" },
|
|
1154
|
-
{ name: "testing", status: "failed" },
|
|
1155
|
-
{ name: "pr-creation", status: "skipped" }
|
|
1156
|
-
]
|
|
1157
|
-
}
|
|
1158
|
-
];
|
|
1159
|
-
let filteredRuns = demoRuns3;
|
|
1160
|
-
if (options.repo) {
|
|
1161
|
-
filteredRuns = filteredRuns.filter((r) => r.repo === options.repo);
|
|
1162
|
-
}
|
|
1163
|
-
if (options.status) {
|
|
1164
|
-
filteredRuns = filteredRuns.filter((r) => r.status === options.status);
|
|
1165
|
-
}
|
|
1166
|
-
filteredRuns = filteredRuns.slice(0, limit);
|
|
1167
|
-
if (filteredRuns.length === 0) {
|
|
1168
|
-
console.log(pc12.yellow("\nNo runs found.\n"));
|
|
1169
|
-
return;
|
|
1170
|
-
}
|
|
1171
|
-
console.log(pc12.bold("\n\u{1F4CB} Recent Runs\n"));
|
|
1172
|
-
console.log(
|
|
1173
|
-
pc12.gray(" ID ") + " " + pc12.gray("Status ") + " " + pc12.gray("Issue")
|
|
1174
|
-
);
|
|
1175
|
-
console.log(pc12.gray(" ").padEnd(60, "\u2500"));
|
|
1176
|
-
for (const run of filteredRuns) {
|
|
1177
|
-
const statusColor = run.status === "completed" ? pc12.green : run.status === "failed" ? pc12.red : run.status === "in_progress" ? pc12.blue : pc12.gray;
|
|
1178
|
-
console.log(
|
|
1179
|
-
` ${run.id.padEnd(13)} ${statusColor(run.status.padEnd(11))} ${run.issue.substring(0, 40)}`
|
|
1180
|
-
);
|
|
1181
|
-
}
|
|
1182
|
-
console.log("");
|
|
1183
|
-
} catch (err) {
|
|
1184
|
-
handleError(err, "runs list");
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1187
|
-
runsCommand.command("logs <run-id>").description("View logs for a specific run").option("-f, --follow", "Follow log output (stream)").option("-s, --stage <name>", "Show logs for a specific stage").action(async (runId, options) => {
|
|
1188
|
-
try {
|
|
1189
|
-
const run = getRun(runId);
|
|
1190
|
-
if (!run) {
|
|
1191
|
-
console.log(pc12.red(`Run "${runId}" not found.`));
|
|
1192
|
-
console.log(pc12.gray(" Run `codowave runs list` to see available runs.\n"));
|
|
1193
|
-
process.exit(1);
|
|
1194
|
-
}
|
|
1195
|
-
if (options.stage) {
|
|
1196
|
-
const stage = run.stages.find((s) => s.name === options.stage);
|
|
1197
|
-
if (!stage) {
|
|
1198
|
-
console.log(pc12.red(`Stage "${options.stage}" not found.`));
|
|
1199
|
-
console.log(pc12.gray("Available stages: ") + run.stages.map((s) => s.name).join(", "));
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
console.log(pc12.bold("\n=== Logs: " + stage.name + " ===\n"));
|
|
1203
|
-
console.log(pc12.bold("Status: ") + stage.status);
|
|
1204
|
-
if (stage.logs) {
|
|
1205
|
-
console.log(pc12.gray("\n--- Output ---\n"));
|
|
1206
|
-
console.log(stage.logs);
|
|
1207
|
-
} else {
|
|
1208
|
-
console.log(pc12.gray("\n(no logs available yet)"));
|
|
1209
|
-
}
|
|
1210
|
-
if (options.follow && stage.status === "running") {
|
|
1211
|
-
console.log(pc12.blue("\n--- Following live logs (Ctrl+C to exit) ---\n"));
|
|
1212
|
-
console.log(pc12.gray("(Live streaming would connect to API SSE endpoint in production)"));
|
|
1213
|
-
}
|
|
1214
|
-
console.log("");
|
|
1215
|
-
return;
|
|
1216
|
-
}
|
|
1217
|
-
console.log(pc12.bold("\n=== Logs: " + run.id + " ===\n"));
|
|
1218
|
-
console.log(pc12.bold("Issue: ") + run.issue);
|
|
1219
|
-
console.log(pc12.bold("Status: ") + run.status);
|
|
1220
|
-
console.log("");
|
|
1221
|
-
for (const stage of run.stages) {
|
|
1222
|
-
const statusIcon = stage.status === "completed" ? "[+]" : stage.status === "failed" ? "[x]" : stage.status === "running" ? "[~]" : "[ ]";
|
|
1223
|
-
console.log(pc12.bold("\n" + statusIcon + " " + stage.name + "\n"));
|
|
1224
|
-
if (stage.logs) {
|
|
1225
|
-
console.log(stage.logs);
|
|
1226
|
-
} else if (stage.status === "pending") {
|
|
1227
|
-
console.log(pc12.gray("(pending)"));
|
|
1228
|
-
} else if (stage.status === "running") {
|
|
1229
|
-
console.log(pc12.blue("(running...)"));
|
|
1230
|
-
} else if (stage.status === "skipped") {
|
|
1231
|
-
console.log(pc12.gray("(skipped)"));
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
if (options.follow && run.status === "in_progress") {
|
|
1235
|
-
console.log(pc12.blue("\n--- Following live logs (Ctrl+C to exit) ---\n"));
|
|
1236
|
-
console.log(pc12.gray("(Live streaming would connect to API SSE endpoint in production)"));
|
|
1237
|
-
}
|
|
1238
|
-
console.log("");
|
|
1239
|
-
} catch (err) {
|
|
1240
|
-
handleError(err, "runs logs");
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
runsCommand.action(() => {
|
|
1244
|
-
runsCommand.help();
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
});
|
|
1248
|
-
|
|
1249
|
-
// src/index.ts
|
|
1250
|
-
init_config();
|
|
1251
|
-
import { Command as Command11 } from "commander";
|
|
1252
|
-
import pc13 from "picocolors";
|
|
1253
|
-
|
|
1254
|
-
// src/utils/global-error.ts
|
|
1255
|
-
init_error();
|
|
1256
|
-
import process2 from "process";
|
|
1257
|
-
import pc2 from "picocolors";
|
|
1258
|
-
function setupGlobalErrorHandlers() {
|
|
1259
|
-
process2.on("uncaughtException", (err) => {
|
|
1260
|
-
console.error(pc2.red("\n\u{1F4A5} Unexpected Error"));
|
|
1261
|
-
console.error(pc2.gray(err.stack || ""));
|
|
1262
|
-
handleError(err, "uncaughtException");
|
|
1263
|
-
});
|
|
1264
|
-
process2.on("unhandledRejection", (reason, _promise) => {
|
|
1265
|
-
const message = reason instanceof Error ? reason.message : String(reason);
|
|
1266
|
-
const stack = reason instanceof Error ? reason.stack : void 0;
|
|
1267
|
-
console.error(pc2.red("\n\u{1F4A5} Unhandled Promise Rejection"));
|
|
1268
|
-
if (stack) {
|
|
1269
|
-
console.error(pc2.gray(stack));
|
|
1270
|
-
} else {
|
|
1271
|
-
console.error(pc2.gray(`Reason: ${message}`));
|
|
1272
|
-
}
|
|
1273
|
-
console.error(pc2.yellow("\nWarning: Unhandled promise rejections can cause instability."));
|
|
1274
|
-
console.error(pc2.gray("Please report this issue: https://github.com/CodowaveAI/Codowave/issues"));
|
|
1275
|
-
process2.exit(1);
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
// src/index.ts
|
|
1280
|
-
setupGlobalErrorHandlers();
|
|
1281
|
-
var { initCommand: initCommand2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
1282
|
-
var { runCommand: runCommand2 } = await Promise.resolve().then(() => (init_run(), run_exports));
|
|
1283
|
-
var { statusCommand: statusCommand2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
1284
|
-
var { logsCommand: logsCommand2 } = await Promise.resolve().then(() => (init_logs(), logs_exports));
|
|
1285
|
-
var { configCommand: configCommand2 } = await Promise.resolve().then(() => (init_config_cmd(), config_cmd_exports));
|
|
1286
|
-
var { connectCommand: connectCommand2 } = await Promise.resolve().then(() => (init_connect(), connect_exports));
|
|
1287
|
-
var { repoCommand: repoCommand2 } = await Promise.resolve().then(() => (init_repo_cmd(), repo_cmd_exports));
|
|
1288
|
-
var { autopilotCommand: autopilotCommand2 } = await Promise.resolve().then(() => (init_autopilot_cmd(), autopilot_cmd_exports));
|
|
1289
|
-
var { labelsCommand: labelsCommand2 } = await Promise.resolve().then(() => (init_labels_cmd(), labels_cmd_exports));
|
|
1290
|
-
var { runsCommand: runsCommand2 } = await Promise.resolve().then(() => (init_runs_cmd(), runs_cmd_exports));
|
|
1291
|
-
var VERSION = "0.1.0";
|
|
1292
|
-
var program = new Command11();
|
|
1293
|
-
program.name("codowave").description(
|
|
1294
|
-
pc13.bold("Codowave") + " \u2014 AI-powered coding agent for your GitHub repositories"
|
|
1295
|
-
).version(VERSION, "-v, --version", "Output the current version").helpOption("-h, --help", "Display help").addHelpText(
|
|
1296
|
-
"beforeAll",
|
|
1297
|
-
`
|
|
1298
|
-
${pc13.cyan(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557")}
|
|
1299
|
-
${pc13.cyan(" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D")}
|
|
1300
|
-
${pc13.cyan(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 ")}
|
|
1301
|
-
${pc13.cyan(" \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2554\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557")}
|
|
1302
|
-
`
|
|
1303
|
-
).option("--api-url <url>", "Override the Codowave API URL");
|
|
1304
|
-
program.addCommand(initCommand2);
|
|
1305
|
-
program.addCommand(runCommand2);
|
|
1306
|
-
program.addCommand(statusCommand2);
|
|
1307
|
-
program.addCommand(logsCommand2);
|
|
1308
|
-
program.addCommand(configCommand2);
|
|
1309
|
-
program.addCommand(connectCommand2);
|
|
1310
|
-
program.addCommand(repoCommand2);
|
|
1311
|
-
program.addCommand(autopilotCommand2);
|
|
1312
|
-
program.addCommand(labelsCommand2);
|
|
1313
|
-
program.addCommand(runsCommand2);
|
|
1314
|
-
program.configureOutput({
|
|
1315
|
-
writeErr: (str) => process.stderr.write(pc13.red(str))
|
|
1316
|
-
});
|
|
1317
|
-
var args = process.argv.slice(2);
|
|
1318
|
-
var isInitOrHelp = args[0] === "init" || args.includes("--help") || args.includes("-h") || args.includes("--version") || args.includes("-v") || args.length === 0;
|
|
1319
|
-
if (!isInitOrHelp) {
|
|
1320
|
-
const config = readConfig();
|
|
1321
|
-
if (!config) {
|
|
1322
|
-
console.warn(
|
|
1323
|
-
pc13.yellow(
|
|
1324
|
-
"\u26A0 No config found. Run " + pc13.bold("codowave init") + " to get started.\n"
|
|
1325
|
-
)
|
|
1326
|
-
);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
program.parseAsync(process.argv).catch((err) => {
|
|
1330
|
-
console.error(pc13.red(`
|
|
1331
|
-
\u2716 Error: ${err instanceof Error ? err.message : String(err)}
|
|
1332
|
-
`));
|
|
1333
|
-
process.exit(1);
|
|
1334
|
-
});
|
|
1335
|
-
//# sourceMappingURL=index.mjs.map
|