agex 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -0
- package/dist/cli.js +588 -19
- package/dist/index.js +16 -6
- package/package.json +9 -4
- package/assets/assets/assets/cursor.js +0 -192
- package/assets/assets/assets/effects.js +0 -1586
- package/assets/scripts/scripts/ab-close-disabled.sh +0 -5
- package/assets/scripts/scripts/ab-close.sh +0 -130
- package/assets/scripts/scripts/ab-fx.sh +0 -3
- package/assets/scripts/scripts/ab-move.sh +0 -19
- package/assets/scripts/scripts/ab-not-found.sh +0 -33
- package/assets/scripts/scripts/ab-open.sh +0 -17
- package/assets/scripts/scripts/ab-proof.sh +0 -126
- package/assets/scripts/scripts/ab-record-disabled.sh +0 -3
- package/assets/scripts/scripts/ab-record-start-disabled.sh +0 -2
- package/assets/scripts/scripts/ab-record-start.sh +0 -18
- package/assets/scripts/scripts/ab-record-stop-disabled.sh +0 -2
- package/assets/scripts/scripts/ab-record-stop.sh +0 -5
- package/assets/scripts/scripts/ab-record.sh +0 -43
- package/assets/scripts/scripts/ab-screenshot.sh +0 -9
- package/assets/scripts/scripts/agent-browser-wrapper.sh +0 -6
- package/assets/scripts/scripts/fx-annotation.sh +0 -13
- package/assets/scripts/scripts/fx-arrow.sh +0 -12
- package/assets/scripts/scripts/fx-circle.sh +0 -13
- package/assets/scripts/scripts/fx-clear.sh +0 -3
- package/assets/scripts/scripts/fx-highlight.sh +0 -32
- package/assets/scripts/scripts/fx-spotlight.sh +0 -13
- package/assets/scripts/scripts/fx-title.sh +0 -11
- package/assets/scripts/scripts/fx-wait.sh +0 -3
- package/dist/cli.d.ts +0 -6
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/browse.d.ts.map +0 -1
- package/dist/commands/browse.js +0 -112
- package/dist/commands/browse.js.map +0 -1
- package/dist/commands/prove-pr.d.ts.map +0 -1
- package/dist/commands/prove-pr.js +0 -120
- package/dist/commands/prove-pr.js.map +0 -1
- package/dist/commands/prove.d.ts.map +0 -1
- package/dist/commands/prove.js +0 -138
- package/dist/commands/prove.js.map +0 -1
- package/dist/commands/review.d.ts.map +0 -1
- package/dist/commands/review.js +0 -82
- package/dist/commands/review.js.map +0 -1
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -132
- package/dist/commands/run.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,592 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
import {
|
|
3
|
+
AGENT_NAMES,
|
|
4
|
+
APPROVAL_POLICIES,
|
|
5
|
+
OUTPUT_MODES,
|
|
6
|
+
detectDefaultBranch,
|
|
7
|
+
isAgexError,
|
|
8
|
+
prove,
|
|
9
|
+
proveOptionsSchema,
|
|
10
|
+
provePr,
|
|
11
|
+
runAgent,
|
|
12
|
+
runReview,
|
|
13
|
+
validate,
|
|
14
|
+
viewportStringSchema
|
|
15
|
+
} from "./chunk-FCCNIKUD.js";
|
|
16
|
+
|
|
17
|
+
// src/cli.ts
|
|
18
|
+
import { defineCommand as defineCommand6, runMain } from "citty";
|
|
19
|
+
|
|
20
|
+
// src/commands/browse.ts
|
|
21
|
+
import { defineCommand } from "citty";
|
|
22
|
+
import { execa } from "execa";
|
|
23
|
+
async function installBrowser() {
|
|
24
|
+
console.log("[agex browse] Browser not found. Installing Chromium...");
|
|
25
|
+
await execa("npx", ["--yes", "playwright", "install", "chromium"], { stdio: "inherit" });
|
|
26
|
+
console.log("[agex browse] Browser installed successfully.");
|
|
27
|
+
}
|
|
28
|
+
async function runAgentBrowser(browserArgs) {
|
|
29
|
+
try {
|
|
30
|
+
const result = await execa("npx", ["--yes", "agent-browser", ...browserArgs], {
|
|
31
|
+
stdio: "pipe",
|
|
32
|
+
env: { ...process.env }
|
|
33
|
+
});
|
|
34
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
35
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
36
|
+
return { success: true, needsBrowserInstall: false };
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const execaError = error;
|
|
39
|
+
const output = `${execaError.stdout ?? ""}${execaError.stderr ?? ""}`;
|
|
40
|
+
if (output.includes("Executable doesn't exist") || output.includes("npx playwright install")) {
|
|
41
|
+
return { success: false, needsBrowserInstall: true };
|
|
42
|
+
}
|
|
43
|
+
if (execaError.stdout) process.stdout.write(execaError.stdout);
|
|
44
|
+
if (execaError.stderr) process.stderr.write(execaError.stderr);
|
|
45
|
+
return { success: false, needsBrowserInstall: false };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var browse_default = defineCommand({
|
|
49
|
+
meta: {
|
|
50
|
+
name: "browse",
|
|
51
|
+
description: "Browser automation via agent-browser"
|
|
52
|
+
},
|
|
53
|
+
args: {
|
|
54
|
+
install: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Force reinstall browser",
|
|
57
|
+
default: false
|
|
20
58
|
},
|
|
59
|
+
_: {
|
|
60
|
+
type: "positional",
|
|
61
|
+
description: "agent-browser command and arguments",
|
|
62
|
+
required: false
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async run({ args, rawArgs }) {
|
|
66
|
+
const browserArgs = rawArgs.filter((arg) => arg !== "--install");
|
|
67
|
+
if (browserArgs.length === 0) {
|
|
68
|
+
console.log(`
|
|
69
|
+
agex browse - Browser automation via agent-browser
|
|
70
|
+
|
|
71
|
+
USAGE:
|
|
72
|
+
agex browse <command> [options]
|
|
73
|
+
|
|
74
|
+
COMMANDS:
|
|
75
|
+
All agent-browser commands are supported. Common ones:
|
|
76
|
+
|
|
77
|
+
open <url> Navigate to URL
|
|
78
|
+
snapshot [-i] Get accessibility tree (use -i for interactive elements)
|
|
79
|
+
click @e1 Click element by ref
|
|
80
|
+
fill @e2 "text" Fill input by ref
|
|
81
|
+
screenshot [path] Take screenshot
|
|
82
|
+
close Close browser
|
|
83
|
+
|
|
84
|
+
OPTIONS:
|
|
85
|
+
--install Force reinstall browser
|
|
86
|
+
|
|
87
|
+
EXAMPLES:
|
|
88
|
+
agex browse open https://example.com
|
|
89
|
+
agex browse snapshot -i
|
|
90
|
+
agex browse click @e1
|
|
91
|
+
agex browse fill @e2 "hello@example.com"
|
|
92
|
+
agex browse screenshot page.png
|
|
93
|
+
agex browse close
|
|
94
|
+
|
|
95
|
+
For full documentation, run: npx agent-browser --help
|
|
96
|
+
Or visit: https://github.com/vercel-labs/agent-browser
|
|
97
|
+
`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (args.install) {
|
|
101
|
+
await installBrowser();
|
|
102
|
+
if (browserArgs.length === 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const firstRun = await runAgentBrowser(browserArgs);
|
|
107
|
+
if (firstRun.success) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (firstRun.needsBrowserInstall) {
|
|
111
|
+
await installBrowser();
|
|
112
|
+
try {
|
|
113
|
+
await execa("npx", ["--yes", "agent-browser", ...browserArgs], {
|
|
114
|
+
stdio: "inherit",
|
|
115
|
+
env: { ...process.env }
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
const exitCode = error.exitCode ?? 1;
|
|
119
|
+
process.exit(exitCode);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// src/commands/prove.ts
|
|
128
|
+
import { defineCommand as defineCommand2 } from "citty";
|
|
129
|
+
var prove_default = defineCommand2({
|
|
130
|
+
meta: {
|
|
131
|
+
name: "prove",
|
|
132
|
+
description: "Prove visual assertions with screenshots"
|
|
133
|
+
},
|
|
134
|
+
args: {
|
|
135
|
+
assertion: {
|
|
136
|
+
type: "positional",
|
|
137
|
+
description: "The assertion to prove",
|
|
138
|
+
required: true
|
|
139
|
+
},
|
|
140
|
+
agent: {
|
|
141
|
+
type: "string",
|
|
142
|
+
alias: "a",
|
|
143
|
+
description: "Agent to use: cursor (default), claude, codex",
|
|
144
|
+
default: "cursor"
|
|
145
|
+
},
|
|
146
|
+
url: {
|
|
147
|
+
type: "string",
|
|
148
|
+
alias: "u",
|
|
149
|
+
description: "URL to navigate to"
|
|
150
|
+
},
|
|
151
|
+
output: {
|
|
152
|
+
type: "string",
|
|
153
|
+
alias: "o",
|
|
154
|
+
description: "Output directory",
|
|
155
|
+
default: "./prove-results"
|
|
156
|
+
},
|
|
157
|
+
video: {
|
|
158
|
+
type: "boolean",
|
|
159
|
+
description: "Enable video recording",
|
|
160
|
+
default: true
|
|
161
|
+
},
|
|
162
|
+
screenshots: {
|
|
163
|
+
type: "boolean",
|
|
164
|
+
description: "Enable screenshots",
|
|
165
|
+
default: true
|
|
166
|
+
},
|
|
167
|
+
model: {
|
|
168
|
+
type: "string",
|
|
169
|
+
alias: "m",
|
|
170
|
+
description: "Model to use"
|
|
171
|
+
},
|
|
172
|
+
timeout: {
|
|
173
|
+
type: "string",
|
|
174
|
+
alias: "t",
|
|
175
|
+
description: "Timeout in milliseconds",
|
|
176
|
+
default: "300000"
|
|
177
|
+
},
|
|
178
|
+
viewport: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Viewport size (WxH)",
|
|
181
|
+
default: "1920x1080"
|
|
182
|
+
},
|
|
183
|
+
headless: {
|
|
184
|
+
type: "boolean",
|
|
185
|
+
description: "Run headless",
|
|
186
|
+
default: true
|
|
187
|
+
},
|
|
188
|
+
browser: {
|
|
189
|
+
type: "string",
|
|
190
|
+
alias: "b",
|
|
191
|
+
description: "Browser mode: mcp (default) or cli (agent-browser)",
|
|
192
|
+
default: "mcp"
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
async run({ args }) {
|
|
196
|
+
if (!AGENT_NAMES.includes(args.agent)) {
|
|
197
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
const viewportResult = viewportStringSchema.safeParse(args.viewport);
|
|
201
|
+
if (!viewportResult.success) {
|
|
202
|
+
console.error(`Invalid viewport: "${args.viewport}". Use format "WIDTHxHEIGHT" (e.g. "1920x1080")`);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
const options = {
|
|
206
|
+
agent: args.agent,
|
|
207
|
+
url: args.url,
|
|
208
|
+
outputDir: args.output,
|
|
209
|
+
video: args.video,
|
|
210
|
+
screenshots: args.screenshots,
|
|
211
|
+
model: args.model,
|
|
212
|
+
timeout: args.timeout ? parseInt(args.timeout, 10) : void 0,
|
|
213
|
+
viewport: viewportResult.data,
|
|
214
|
+
headless: args.headless
|
|
215
|
+
};
|
|
216
|
+
const validated = validate(proveOptionsSchema, options);
|
|
217
|
+
if (!validated.success) {
|
|
218
|
+
console.error(`Invalid options: ${validated.error}`);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
console.log("========================================");
|
|
222
|
+
console.log("agex prove");
|
|
223
|
+
console.log("========================================");
|
|
224
|
+
console.log(`Workspace: ${process.cwd()}`);
|
|
225
|
+
console.log(`Agent: ${options.agent}`);
|
|
226
|
+
console.log(`Task: ${args.assertion}`);
|
|
227
|
+
if (options.url) {
|
|
228
|
+
console.log(`URL: ${options.url}`);
|
|
229
|
+
}
|
|
230
|
+
console.log("========================================\n");
|
|
231
|
+
try {
|
|
232
|
+
const result = await prove(args.assertion, options);
|
|
233
|
+
console.log("\n========================================");
|
|
234
|
+
if (result.verdict === "pass") {
|
|
235
|
+
console.log("\u2705 PASS");
|
|
236
|
+
} else if (result.verdict === "fail") {
|
|
237
|
+
console.log("\u274C FAIL");
|
|
238
|
+
} else {
|
|
239
|
+
console.log("\u23ED\uFE0F SKIP");
|
|
240
|
+
}
|
|
241
|
+
console.log(`Reason: ${result.reason}`);
|
|
242
|
+
console.log(`Duration: ${result.durationMs}ms`);
|
|
243
|
+
console.log(`Output: ${result.outputDir}`);
|
|
244
|
+
console.log("========================================");
|
|
245
|
+
process.exit(result.verdict === "pass" ? 0 : 1);
|
|
246
|
+
} catch (err) {
|
|
247
|
+
if (isAgexError(err)) {
|
|
248
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
249
|
+
} else {
|
|
250
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
251
|
+
}
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// src/commands/prove-pr.ts
|
|
258
|
+
import { defineCommand as defineCommand3 } from "citty";
|
|
259
|
+
var prove_pr_default = defineCommand3({
|
|
260
|
+
meta: {
|
|
261
|
+
name: "prove-pr",
|
|
262
|
+
description: "Prove PR changes work with screenshots and evidence"
|
|
263
|
+
},
|
|
264
|
+
args: {
|
|
265
|
+
base: {
|
|
266
|
+
type: "string",
|
|
267
|
+
description: "Base branch/commit to compare against (auto-detected if omitted)"
|
|
268
|
+
},
|
|
269
|
+
agent: {
|
|
270
|
+
type: "string",
|
|
271
|
+
alias: "a",
|
|
272
|
+
description: "Agent to use: cursor (default), claude, codex",
|
|
273
|
+
default: "cursor"
|
|
274
|
+
},
|
|
275
|
+
url: {
|
|
276
|
+
type: "string",
|
|
277
|
+
alias: "u",
|
|
278
|
+
description: "Dev server URL for visual testing"
|
|
279
|
+
},
|
|
280
|
+
output: {
|
|
281
|
+
type: "string",
|
|
282
|
+
alias: "o",
|
|
283
|
+
description: "Output directory",
|
|
284
|
+
default: "./prove-pr-results"
|
|
285
|
+
},
|
|
286
|
+
hypotheses: {
|
|
287
|
+
type: "string",
|
|
288
|
+
description: "Number of hypotheses to generate",
|
|
289
|
+
default: "5"
|
|
290
|
+
},
|
|
291
|
+
model: {
|
|
292
|
+
type: "string",
|
|
293
|
+
alias: "m",
|
|
294
|
+
description: "Model to use"
|
|
295
|
+
},
|
|
296
|
+
viewport: {
|
|
297
|
+
type: "string",
|
|
298
|
+
description: "Viewport size (WxH)",
|
|
299
|
+
default: "1920x1080"
|
|
300
|
+
},
|
|
301
|
+
hint: {
|
|
302
|
+
type: "string",
|
|
303
|
+
description: "Additional prompt hint for hypothesis generation"
|
|
304
|
+
},
|
|
305
|
+
timeout: {
|
|
306
|
+
type: "string",
|
|
307
|
+
alias: "t",
|
|
308
|
+
description: "Timeout in milliseconds",
|
|
309
|
+
default: "300000"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
async run({ args }) {
|
|
313
|
+
if (!AGENT_NAMES.includes(args.agent)) {
|
|
314
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
const viewportResult = viewportStringSchema.safeParse(args.viewport);
|
|
318
|
+
if (!viewportResult.success) {
|
|
319
|
+
console.error(`Invalid viewport: "${args.viewport}". Use format "WIDTHxHEIGHT" (e.g. "1920x1080")`);
|
|
320
|
+
process.exit(1);
|
|
321
|
+
}
|
|
322
|
+
const hypothesesCount = parseInt(args.hypotheses, 10);
|
|
323
|
+
if (isNaN(hypothesesCount) || hypothesesCount <= 0) {
|
|
324
|
+
console.error(`Invalid hypotheses count: "${args.hypotheses}". Must be a positive integer.`);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
const request = {
|
|
328
|
+
baseRef: args.base,
|
|
329
|
+
agent: args.agent,
|
|
330
|
+
url: args.url,
|
|
331
|
+
outputDir: args.output,
|
|
332
|
+
hypothesesCount,
|
|
333
|
+
model: args.model,
|
|
334
|
+
viewport: viewportResult.data,
|
|
335
|
+
hint: args.hint,
|
|
336
|
+
timeoutMs: args.timeout ? parseInt(args.timeout, 10) : void 0
|
|
337
|
+
};
|
|
338
|
+
console.log("========================================");
|
|
339
|
+
console.log("agex prove-pr");
|
|
340
|
+
console.log("========================================");
|
|
341
|
+
console.log(`Base: ${request.baseRef || "(auto-detect)"}`);
|
|
342
|
+
console.log(`Agent: ${request.agent}`);
|
|
343
|
+
console.log(`Hypotheses: ${hypothesesCount}`);
|
|
344
|
+
if (request.url) console.log(`URL: ${request.url}`);
|
|
345
|
+
console.log(`Output: ${request.outputDir}`);
|
|
346
|
+
console.log("========================================\n");
|
|
347
|
+
try {
|
|
348
|
+
const result = await provePr(request);
|
|
349
|
+
console.log("\n========================================");
|
|
350
|
+
console.log("RESULTS");
|
|
351
|
+
console.log("========================================");
|
|
352
|
+
console.log(`\u2705 Passed: ${result.summary.pass}`);
|
|
353
|
+
console.log(`\u274C Failed: ${result.summary.fail}`);
|
|
354
|
+
console.log(`\u23ED\uFE0F Skipped: ${result.summary.skip}`);
|
|
355
|
+
console.log(`Duration: ${(result.durationMs / 1e3).toFixed(1)}s`);
|
|
356
|
+
console.log(`Output: ${result.outputDir}`);
|
|
357
|
+
console.log("========================================");
|
|
358
|
+
process.exit(result.summary.fail === 0 ? 0 : 1);
|
|
359
|
+
} catch (err) {
|
|
360
|
+
if (isAgexError(err)) {
|
|
361
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
362
|
+
} else {
|
|
363
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
364
|
+
}
|
|
365
|
+
process.exit(1);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// src/commands/review.ts
|
|
371
|
+
import { defineCommand as defineCommand4 } from "citty";
|
|
372
|
+
var review_default = defineCommand4({
|
|
373
|
+
meta: {
|
|
374
|
+
name: "review",
|
|
375
|
+
description: "Review code changes"
|
|
376
|
+
},
|
|
377
|
+
args: {
|
|
378
|
+
base: {
|
|
379
|
+
type: "string",
|
|
380
|
+
description: "Base branch/commit to compare against (auto-detected if omitted)"
|
|
381
|
+
},
|
|
382
|
+
agent: {
|
|
383
|
+
type: "string",
|
|
384
|
+
alias: "a",
|
|
385
|
+
description: "Agent to use: cursor, claude, codex",
|
|
386
|
+
required: true
|
|
387
|
+
},
|
|
388
|
+
model: {
|
|
389
|
+
type: "string",
|
|
390
|
+
alias: "m",
|
|
391
|
+
description: "Model to use"
|
|
392
|
+
},
|
|
393
|
+
worktree: {
|
|
394
|
+
type: "boolean",
|
|
395
|
+
description: "Include worktree changes",
|
|
396
|
+
default: true
|
|
397
|
+
},
|
|
398
|
+
hypotheses: {
|
|
399
|
+
type: "string",
|
|
400
|
+
description: "Number of hypotheses to generate"
|
|
401
|
+
},
|
|
402
|
+
hint: {
|
|
403
|
+
type: "string",
|
|
404
|
+
description: "Additional prompt hint"
|
|
405
|
+
},
|
|
406
|
+
timeout: {
|
|
407
|
+
type: "string",
|
|
408
|
+
alias: "t",
|
|
409
|
+
description: "Timeout in milliseconds",
|
|
410
|
+
default: "300000"
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
async run({ args }) {
|
|
414
|
+
if (!AGENT_NAMES.includes(args.agent)) {
|
|
415
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
418
|
+
if (args.hypotheses) {
|
|
419
|
+
const h = parseInt(args.hypotheses, 10);
|
|
420
|
+
if (isNaN(h) || h <= 0) {
|
|
421
|
+
console.error(`Invalid hypotheses count: "${args.hypotheses}". Must be a positive integer.`);
|
|
422
|
+
process.exit(1);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
const base = args.base || detectDefaultBranch();
|
|
427
|
+
await runReview({
|
|
428
|
+
baseRef: base,
|
|
429
|
+
agent: args.agent,
|
|
430
|
+
model: args.model,
|
|
431
|
+
includeWorktree: args.worktree,
|
|
432
|
+
hypotheses: args.hypotheses ? parseInt(args.hypotheses, 10) : void 0,
|
|
433
|
+
promptHint: args.hint,
|
|
434
|
+
timeoutMs: args.timeout ? parseInt(args.timeout, 10) : void 0
|
|
435
|
+
});
|
|
436
|
+
} catch (err) {
|
|
437
|
+
if (isAgexError(err)) {
|
|
438
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
439
|
+
} else {
|
|
440
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
441
|
+
}
|
|
442
|
+
process.exit(1);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// src/commands/run.ts
|
|
448
|
+
import { defineCommand as defineCommand5 } from "citty";
|
|
449
|
+
function formatOutput(result, mode, wasStreamed) {
|
|
450
|
+
switch (mode) {
|
|
451
|
+
case "json":
|
|
452
|
+
return JSON.stringify(result.json, null, 2);
|
|
453
|
+
case "text":
|
|
454
|
+
return wasStreamed ? null : result.formattedText;
|
|
455
|
+
case "debug":
|
|
456
|
+
return `${result.text}
|
|
457
|
+
|
|
458
|
+
---AGEX_JSON---
|
|
459
|
+
${JSON.stringify(result.json, null, 2)}`;
|
|
460
|
+
default:
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
var run_default = defineCommand5({
|
|
465
|
+
meta: {
|
|
466
|
+
name: "run",
|
|
467
|
+
description: "Execute AI agent tasks"
|
|
468
|
+
},
|
|
469
|
+
args: {
|
|
470
|
+
prompt: {
|
|
471
|
+
type: "positional",
|
|
472
|
+
description: "The prompt to execute",
|
|
473
|
+
required: true
|
|
474
|
+
},
|
|
475
|
+
agent: {
|
|
476
|
+
type: "string",
|
|
477
|
+
alias: "a",
|
|
478
|
+
description: "Agent to use: cursor, claude, codex (auto-detected if not specified)"
|
|
479
|
+
},
|
|
480
|
+
model: {
|
|
481
|
+
type: "string",
|
|
482
|
+
alias: "m",
|
|
483
|
+
description: "Model to use"
|
|
484
|
+
},
|
|
485
|
+
install: {
|
|
486
|
+
type: "boolean",
|
|
487
|
+
description: "Run install command before agent",
|
|
488
|
+
default: false
|
|
489
|
+
},
|
|
490
|
+
installCommand: {
|
|
491
|
+
type: "string",
|
|
492
|
+
description: "Custom install command"
|
|
493
|
+
},
|
|
494
|
+
requireApiKey: {
|
|
495
|
+
type: "boolean",
|
|
496
|
+
description: "Require API key",
|
|
497
|
+
default: false
|
|
498
|
+
},
|
|
499
|
+
approveMcps: {
|
|
500
|
+
type: "boolean",
|
|
501
|
+
description: "Auto-approve MCPs",
|
|
502
|
+
default: true
|
|
503
|
+
},
|
|
504
|
+
browser: {
|
|
505
|
+
type: "boolean",
|
|
506
|
+
description: "Enable browser",
|
|
507
|
+
default: true
|
|
508
|
+
},
|
|
509
|
+
stream: {
|
|
510
|
+
type: "boolean",
|
|
511
|
+
description: "Enable streaming output",
|
|
512
|
+
default: true
|
|
513
|
+
},
|
|
514
|
+
mode: {
|
|
515
|
+
type: "string",
|
|
516
|
+
description: "Output mode: text, json, debug",
|
|
517
|
+
default: "text"
|
|
518
|
+
},
|
|
519
|
+
approval: {
|
|
520
|
+
type: "string",
|
|
521
|
+
description: "Approval policy: never, on-request, on-failure, untrusted"
|
|
522
|
+
},
|
|
523
|
+
timeout: {
|
|
524
|
+
type: "string",
|
|
525
|
+
description: "Timeout in milliseconds",
|
|
526
|
+
default: "300000"
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
async run({ args }) {
|
|
530
|
+
if (args.agent && !AGENT_NAMES.includes(args.agent)) {
|
|
531
|
+
console.error(`Invalid agent: "${args.agent}". Must be one of: ${AGENT_NAMES.join(", ")}`);
|
|
532
|
+
process.exit(1);
|
|
533
|
+
}
|
|
534
|
+
if (!OUTPUT_MODES.includes(args.mode)) {
|
|
535
|
+
console.error(`Invalid mode: "${args.mode}". Must be one of: ${OUTPUT_MODES.join(", ")}`);
|
|
536
|
+
process.exit(1);
|
|
537
|
+
}
|
|
538
|
+
if (args.approval && !APPROVAL_POLICIES.includes(args.approval)) {
|
|
539
|
+
console.error(`Invalid approval policy: "${args.approval}". Must be one of: ${APPROVAL_POLICIES.join(", ")}`);
|
|
540
|
+
process.exit(1);
|
|
541
|
+
}
|
|
542
|
+
const outputMode = args.mode;
|
|
543
|
+
const quietOutput = outputMode === "json";
|
|
544
|
+
const streamOutput = quietOutput ? false : args.stream;
|
|
545
|
+
const request = {
|
|
546
|
+
agent: args.agent,
|
|
547
|
+
prompt: args.prompt,
|
|
548
|
+
model: args.model,
|
|
549
|
+
install: args.install,
|
|
550
|
+
installCommand: args.installCommand,
|
|
551
|
+
requireApiKey: args.requireApiKey,
|
|
552
|
+
approveMcps: args.approveMcps,
|
|
553
|
+
browser: args.browser,
|
|
554
|
+
streamOutput,
|
|
555
|
+
quietOutput,
|
|
556
|
+
approvalPolicy: args.approval,
|
|
557
|
+
timeoutMs: args.timeout ? parseInt(args.timeout, 10) : void 0
|
|
558
|
+
};
|
|
559
|
+
try {
|
|
560
|
+
const result = await runAgent(request);
|
|
561
|
+
const output = formatOutput(result, outputMode, streamOutput);
|
|
562
|
+
if (output !== null) {
|
|
563
|
+
process.stdout.write(`${output}
|
|
564
|
+
`);
|
|
565
|
+
}
|
|
566
|
+
} catch (err) {
|
|
567
|
+
if (isAgexError(err)) {
|
|
568
|
+
console.error(`Error [${err.code}]: ${err.message}`);
|
|
569
|
+
} else {
|
|
570
|
+
console.error(`Unexpected error: ${err instanceof Error ? err.message : String(err)}`);
|
|
571
|
+
}
|
|
572
|
+
process.exit(1);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// src/cli.ts
|
|
578
|
+
var main = defineCommand6({
|
|
579
|
+
meta: {
|
|
580
|
+
name: "agex",
|
|
581
|
+
version: "0.1.2",
|
|
582
|
+
description: "AI-powered automation toolkit"
|
|
583
|
+
},
|
|
584
|
+
subCommands: {
|
|
585
|
+
browse: browse_default,
|
|
586
|
+
prove: prove_default,
|
|
587
|
+
"prove-pr": prove_pr_default,
|
|
588
|
+
review: review_default,
|
|
589
|
+
run: run_default
|
|
590
|
+
}
|
|
21
591
|
});
|
|
22
592
|
runMain(main);
|
|
23
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
AgexError,
|
|
3
|
+
isAgexError,
|
|
4
|
+
prove,
|
|
5
|
+
provePr,
|
|
6
|
+
runAgent,
|
|
7
|
+
runReview
|
|
8
|
+
} from "./chunk-FCCNIKUD.js";
|
|
9
|
+
export {
|
|
10
|
+
AgexError,
|
|
11
|
+
isAgexError,
|
|
12
|
+
prove,
|
|
13
|
+
provePr,
|
|
14
|
+
runAgent,
|
|
15
|
+
runReview
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agex",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
"agex": "dist/cli.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"dist",
|
|
11
|
+
"dist/cli.js",
|
|
12
|
+
"dist/cli.js.map",
|
|
13
|
+
"dist/index.js",
|
|
14
|
+
"dist/index.js.map",
|
|
15
|
+
"dist/index.d.ts",
|
|
16
|
+
"dist/chunk-*.js",
|
|
12
17
|
"assets"
|
|
13
18
|
],
|
|
14
19
|
"dependencies": {
|
|
@@ -21,15 +26,15 @@
|
|
|
21
26
|
"typescript": "^5.9.3",
|
|
22
27
|
"vitest": "^2.1.9",
|
|
23
28
|
"agex-agent": "0.1.0",
|
|
24
|
-
"agex-browse": "0.1.0",
|
|
25
29
|
"agex-core": "0.1.0",
|
|
30
|
+
"agex-browse": "0.1.0",
|
|
26
31
|
"agex-prove": "0.1.0",
|
|
27
32
|
"agex-prove-pr": "0.1.0",
|
|
28
33
|
"agex-review": "0.1.0"
|
|
29
34
|
},
|
|
30
35
|
"scripts": {
|
|
31
36
|
"build": "tsc -p tsconfig.json",
|
|
32
|
-
"bundle": "tsup && mkdir -p ./assets && cp -r ../browse/assets ./assets/assets && cp -r ../browse/scripts ./assets/scripts",
|
|
37
|
+
"bundle": "rm -rf dist assets && tsup && mkdir -p ./assets/assets ./assets/scripts && cp -r ../browse/assets/ ./assets/assets/ && cp -r ../browse/scripts/ ./assets/scripts/ && cp ../../README.md ./README.md",
|
|
33
38
|
"test": "vitest run"
|
|
34
39
|
}
|
|
35
40
|
}
|