agex 0.2.3 → 0.2.4
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/{chunk-EN7TTESF.js → chunk-CY6NF2GO.js} +200 -12
- package/dist/cli.js +2 -2
- package/dist/index.js +2 -4
- package/package.json +9 -9
|
@@ -103,7 +103,7 @@ function formatMessage(level, prefix, message) {
|
|
|
103
103
|
function createLogger(prefix = "", level) {
|
|
104
104
|
const minLevel = level ?? getDefaultLevel();
|
|
105
105
|
const minOrder = LEVEL_ORDER[minLevel];
|
|
106
|
-
function
|
|
106
|
+
function log13(logLevel, message, ...args) {
|
|
107
107
|
if (LEVEL_ORDER[logLevel] < minOrder)
|
|
108
108
|
return;
|
|
109
109
|
const formatted = formatMessage(logLevel, prefix, message);
|
|
@@ -122,10 +122,10 @@ function createLogger(prefix = "", level) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
|
-
debug: (message, ...args) =>
|
|
126
|
-
info: (message, ...args) =>
|
|
127
|
-
warn: (message, ...args) =>
|
|
128
|
-
error: (message, ...args) =>
|
|
125
|
+
debug: (message, ...args) => log13("debug", message, ...args),
|
|
126
|
+
info: (message, ...args) => log13("info", message, ...args),
|
|
127
|
+
warn: (message, ...args) => log13("warn", message, ...args),
|
|
128
|
+
error: (message, ...args) => log13("error", message, ...args),
|
|
129
129
|
child: (childPrefix) => createLogger(prefix ? `${prefix}:${childPrefix}` : childPrefix, level)
|
|
130
130
|
};
|
|
131
131
|
}
|
|
@@ -636,8 +636,8 @@ function getErrorMap() {
|
|
|
636
636
|
|
|
637
637
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
638
638
|
var makeIssue = (params) => {
|
|
639
|
-
const { data, path:
|
|
640
|
-
const fullPath = [...
|
|
639
|
+
const { data, path: path8, errorMaps, issueData } = params;
|
|
640
|
+
const fullPath = [...path8, ...issueData.path || []];
|
|
641
641
|
const fullIssue = {
|
|
642
642
|
...issueData,
|
|
643
643
|
path: fullPath
|
|
@@ -753,11 +753,11 @@ var errorUtil;
|
|
|
753
753
|
|
|
754
754
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
755
755
|
var ParseInputLazyPath = class {
|
|
756
|
-
constructor(parent, value,
|
|
756
|
+
constructor(parent, value, path8, key) {
|
|
757
757
|
this._cachedPath = [];
|
|
758
758
|
this.parent = parent;
|
|
759
759
|
this.data = value;
|
|
760
|
-
this._path =
|
|
760
|
+
this._path = path8;
|
|
761
761
|
this._key = key;
|
|
762
762
|
}
|
|
763
763
|
get path() {
|
|
@@ -5200,11 +5200,11 @@ async function runWithStreaming({ commandSpec, request, agent, env, parser, time
|
|
|
5200
5200
|
process.stderr.write(chunk);
|
|
5201
5201
|
}
|
|
5202
5202
|
});
|
|
5203
|
-
const exitCode = await new Promise((
|
|
5203
|
+
const exitCode = await new Promise((resolve7) => {
|
|
5204
5204
|
child.on("close", (code) => {
|
|
5205
5205
|
if (timeoutHandle)
|
|
5206
5206
|
clearTimeout(timeoutHandle);
|
|
5207
|
-
|
|
5207
|
+
resolve7(timedOut ? DEFAULTS.TIMEOUT_EXIT_CODE : code ?? 1);
|
|
5208
5208
|
});
|
|
5209
5209
|
});
|
|
5210
5210
|
if (lineProcessor) {
|
|
@@ -6118,6 +6118,193 @@ var reviewRequestSchema = external_exports.object({
|
|
|
6118
6118
|
timeoutMs: external_exports.number().positive().optional()
|
|
6119
6119
|
});
|
|
6120
6120
|
|
|
6121
|
+
// ../prove-pr/dist/prove-pr.js
|
|
6122
|
+
import * as fs5 from "fs";
|
|
6123
|
+
import * as path7 from "path";
|
|
6124
|
+
|
|
6125
|
+
// ../prove-pr/dist/prompt.js
|
|
6126
|
+
function buildProvePrPrompt(gitContext, hypothesesPlan, outputDir, url) {
|
|
6127
|
+
const urlInstruction = url ? `
|
|
6128
|
+
Dev server URL: ${url}` : "";
|
|
6129
|
+
return `You are proving that code changes work correctly by gathering factual evidence.
|
|
6130
|
+
|
|
6131
|
+
GIT CONTEXT:
|
|
6132
|
+
${gitContext}
|
|
6133
|
+
|
|
6134
|
+
HYPOTHESES TO PROVE:
|
|
6135
|
+
${hypothesesPlan}
|
|
6136
|
+
${urlInstruction}
|
|
6137
|
+
|
|
6138
|
+
YOUR TASK:
|
|
6139
|
+
For each hypothesis (H1, H2, etc.), gather evidence to prove or disprove it.
|
|
6140
|
+
|
|
6141
|
+
HELPER SCRIPTS:
|
|
6142
|
+
- ./ab-open <url> # Open URL with viewport, recording, and effects
|
|
6143
|
+
- ./ab-screenshot <name> # Save screenshot to output dir
|
|
6144
|
+
- ./ab-close # Stop recording and close browser
|
|
6145
|
+
- ./ab-fx # Re-inject effects after navigation
|
|
6146
|
+
|
|
6147
|
+
AGENT-BROWSER COMMANDS:
|
|
6148
|
+
- agent-browser snapshot -i # Get interactive elements with refs (@e1, @e2)
|
|
6149
|
+
- agent-browser click @e1 # Click element
|
|
6150
|
+
- agent-browser fill @e2 "text" # Fill input
|
|
6151
|
+
- agent-browser get text @e1 # Get element text
|
|
6152
|
+
- agent-browser eval "<js>" # Run JavaScript
|
|
6153
|
+
- agent-browser wait @e1 # Wait for element
|
|
6154
|
+
|
|
6155
|
+
EVIDENCE GATHERING:
|
|
6156
|
+
- For visual/UI changes: Use ./ab-open and ./ab-screenshot
|
|
6157
|
+
- For behavior changes: Run the code, check logs, execute commands
|
|
6158
|
+
- For API changes: Make requests and verify responses
|
|
6159
|
+
- Use whatever combination makes sense for each hypothesis
|
|
6160
|
+
|
|
6161
|
+
INSTRUCTIONS:
|
|
6162
|
+
1. Work through each hypothesis systematically
|
|
6163
|
+
2. Take screenshots at key moments (use descriptive names like "H1-login-form.png")
|
|
6164
|
+
3. Run commands and capture output when relevant
|
|
6165
|
+
4. Document what you observe
|
|
6166
|
+
|
|
6167
|
+
OUTPUT FORMAT:
|
|
6168
|
+
For each hypothesis, output:
|
|
6169
|
+
[H1_VERDICT:PASS|FAIL|SKIP] - Brief explanation
|
|
6170
|
+
Evidence: <list what you captured>
|
|
6171
|
+
|
|
6172
|
+
After all hypotheses, output:
|
|
6173
|
+
[PROVE_PR_COMPLETE]
|
|
6174
|
+
Summary: X passed, Y failed, Z skipped`;
|
|
6175
|
+
}
|
|
6176
|
+
|
|
6177
|
+
// ../prove-pr/dist/verdict-parser.js
|
|
6178
|
+
function parseHypothesesVerdicts(output) {
|
|
6179
|
+
const verdicts = [];
|
|
6180
|
+
const regex = /\[H(\d+)_VERDICT:(PASS|FAIL|SKIP)\]\s*-?\s*([^\n]*)/gi;
|
|
6181
|
+
for (const match of output.matchAll(regex)) {
|
|
6182
|
+
const id = `H${match[1]}`;
|
|
6183
|
+
verdicts.push({
|
|
6184
|
+
id,
|
|
6185
|
+
hypothesis: "",
|
|
6186
|
+
verdict: match[2].toLowerCase(),
|
|
6187
|
+
reason: match[3]?.trim() || "",
|
|
6188
|
+
evidence: []
|
|
6189
|
+
});
|
|
6190
|
+
}
|
|
6191
|
+
return verdicts;
|
|
6192
|
+
}
|
|
6193
|
+
|
|
6194
|
+
// ../prove-pr/dist/report-builder.js
|
|
6195
|
+
function generateReport(result) {
|
|
6196
|
+
const lines = [
|
|
6197
|
+
"# Prove PR Report",
|
|
6198
|
+
"",
|
|
6199
|
+
`**Base:** ${result.baseRef}`,
|
|
6200
|
+
`**Duration:** ${(result.durationMs / 1e3).toFixed(1)}s`,
|
|
6201
|
+
`**Results:** ${result.summary.pass} passed, ${result.summary.fail} failed, ${result.summary.skip} skipped`,
|
|
6202
|
+
"",
|
|
6203
|
+
"## Hypothesis Verdicts",
|
|
6204
|
+
""
|
|
6205
|
+
];
|
|
6206
|
+
for (const h of result.hypotheses) {
|
|
6207
|
+
const icon = h.verdict === "pass" ? "\u2705" : h.verdict === "fail" ? "\u274C" : "\u23ED\uFE0F";
|
|
6208
|
+
lines.push(`### ${h.id} ${icon} ${h.verdict.toUpperCase()}`);
|
|
6209
|
+
lines.push(`> ${h.reason}`);
|
|
6210
|
+
lines.push("");
|
|
6211
|
+
}
|
|
6212
|
+
return lines.join("\n");
|
|
6213
|
+
}
|
|
6214
|
+
|
|
6215
|
+
// ../prove-pr/dist/prove-pr.js
|
|
6216
|
+
var log12 = createLogger("prove-pr");
|
|
6217
|
+
function createOutputDir2(baseDir) {
|
|
6218
|
+
const ts = timestamp();
|
|
6219
|
+
const dir = path7.resolve(baseDir, `prove-pr_${ts}`);
|
|
6220
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
6221
|
+
return dir;
|
|
6222
|
+
}
|
|
6223
|
+
async function provePr(request) {
|
|
6224
|
+
const baseRef = request.baseRef || detectDefaultBranch();
|
|
6225
|
+
const outputDir = createOutputDir2(request.outputDir);
|
|
6226
|
+
const { width, height } = request.viewport;
|
|
6227
|
+
log12.info(`proving PR: base=${baseRef} agent=${request.agent} hypotheses=${request.hypothesesCount}`);
|
|
6228
|
+
const startTime = Date.now();
|
|
6229
|
+
const gitContext = await buildGitContext(baseRef, true);
|
|
6230
|
+
log12.debug("generating hypotheses...");
|
|
6231
|
+
const planPrompt = buildPlanPrompt(gitContext, request.hypothesesCount, request.hint);
|
|
6232
|
+
const planResult = await runAgent({
|
|
6233
|
+
agent: request.agent,
|
|
6234
|
+
model: request.model,
|
|
6235
|
+
prompt: planPrompt,
|
|
6236
|
+
streamOutput: true,
|
|
6237
|
+
timeoutMs: request.timeoutMs
|
|
6238
|
+
});
|
|
6239
|
+
const hypothesesPlan = planResult.json.stdout;
|
|
6240
|
+
log12.debug("proving hypotheses with evidence...");
|
|
6241
|
+
const browserConfig = {
|
|
6242
|
+
output: {
|
|
6243
|
+
dir: outputDir,
|
|
6244
|
+
video: true,
|
|
6245
|
+
screenshots: true,
|
|
6246
|
+
viewport: { width, height },
|
|
6247
|
+
showCursor: true,
|
|
6248
|
+
effects: true
|
|
6249
|
+
}
|
|
6250
|
+
};
|
|
6251
|
+
const workspaceFiles = createWorkspaceFiles(browserConfig);
|
|
6252
|
+
const provePrompt = buildProvePrPrompt(gitContext, hypothesesPlan, outputDir, request.url);
|
|
6253
|
+
try {
|
|
6254
|
+
const proveResult = await runAgent({
|
|
6255
|
+
agent: request.agent,
|
|
6256
|
+
model: request.model,
|
|
6257
|
+
prompt: provePrompt,
|
|
6258
|
+
approveMcps: true,
|
|
6259
|
+
browser: true,
|
|
6260
|
+
streamOutput: true,
|
|
6261
|
+
approvalPolicy: "never",
|
|
6262
|
+
workspacePath: workspaceFiles.workspacePath,
|
|
6263
|
+
timeoutMs: request.timeoutMs
|
|
6264
|
+
});
|
|
6265
|
+
const durationMs = Date.now() - startTime;
|
|
6266
|
+
const verdicts = parseHypothesesVerdicts(proveResult.json.stdout);
|
|
6267
|
+
const summary = {
|
|
6268
|
+
pass: verdicts.filter((v) => v.verdict === "pass").length,
|
|
6269
|
+
fail: verdicts.filter((v) => v.verdict === "fail").length,
|
|
6270
|
+
skip: verdicts.filter((v) => v.verdict === "skip").length
|
|
6271
|
+
};
|
|
6272
|
+
const result = {
|
|
6273
|
+
baseRef,
|
|
6274
|
+
hypotheses: verdicts,
|
|
6275
|
+
summary,
|
|
6276
|
+
outputDir,
|
|
6277
|
+
durationMs
|
|
6278
|
+
};
|
|
6279
|
+
const report = generateReport(result);
|
|
6280
|
+
fs5.writeFileSync(path7.join(outputDir, "report.md"), report);
|
|
6281
|
+
fs5.writeFileSync(path7.join(outputDir, "result.json"), JSON.stringify(result, null, 2));
|
|
6282
|
+
fs5.writeFileSync(path7.join(outputDir, "hypotheses.txt"), hypothesesPlan);
|
|
6283
|
+
fs5.writeFileSync(path7.join(outputDir, "evidence.txt"), proveResult.json.stdout);
|
|
6284
|
+
log12.info(`prove-pr complete: ${summary.pass} passed, ${summary.fail} failed, ${summary.skip} skipped`);
|
|
6285
|
+
return result;
|
|
6286
|
+
} finally {
|
|
6287
|
+
workspaceFiles.cleanup();
|
|
6288
|
+
}
|
|
6289
|
+
}
|
|
6290
|
+
|
|
6291
|
+
// ../prove-pr/dist/validation.js
|
|
6292
|
+
var viewportSchema2 = external_exports.object({
|
|
6293
|
+
width: external_exports.number().int().positive(),
|
|
6294
|
+
height: external_exports.number().int().positive()
|
|
6295
|
+
});
|
|
6296
|
+
var provePrRequestSchema = external_exports.object({
|
|
6297
|
+
baseRef: external_exports.string().optional(),
|
|
6298
|
+
agent: external_exports.enum(AGENT_NAMES),
|
|
6299
|
+
url: external_exports.string().url("Invalid URL").optional(),
|
|
6300
|
+
outputDir: external_exports.string().min(1, "Output directory cannot be empty"),
|
|
6301
|
+
hypothesesCount: external_exports.number().int().positive("Hypotheses count must be a positive integer"),
|
|
6302
|
+
model: external_exports.string().optional(),
|
|
6303
|
+
viewport: viewportSchema2,
|
|
6304
|
+
hint: external_exports.string().optional(),
|
|
6305
|
+
timeoutMs: external_exports.number().positive("Timeout must be positive").optional()
|
|
6306
|
+
});
|
|
6307
|
+
|
|
6121
6308
|
export {
|
|
6122
6309
|
AgexError,
|
|
6123
6310
|
isAgexError,
|
|
@@ -6130,5 +6317,6 @@ export {
|
|
|
6130
6317
|
runAgent,
|
|
6131
6318
|
prove,
|
|
6132
6319
|
proveOptionsSchema,
|
|
6133
|
-
runReview
|
|
6320
|
+
runReview,
|
|
6321
|
+
provePr
|
|
6134
6322
|
};
|
package/dist/cli.js
CHANGED
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
isAgexError,
|
|
8
8
|
prove,
|
|
9
9
|
proveOptionsSchema,
|
|
10
|
+
provePr,
|
|
10
11
|
runAgent,
|
|
11
12
|
runReview,
|
|
12
13
|
validate,
|
|
13
14
|
viewportStringSchema
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CY6NF2GO.js";
|
|
15
16
|
|
|
16
17
|
// src/cli.ts
|
|
17
18
|
import { defineCommand as defineCommand6, runMain } from "citty";
|
|
@@ -255,7 +256,6 @@ var prove_default = defineCommand2({
|
|
|
255
256
|
|
|
256
257
|
// src/commands/prove-pr.ts
|
|
257
258
|
import { defineCommand as defineCommand3 } from "citty";
|
|
258
|
-
import { provePr } from "agex-prove-pr";
|
|
259
259
|
var prove_pr_default = defineCommand3({
|
|
260
260
|
meta: {
|
|
261
261
|
name: "prove-pr",
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agex",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"citty": "^0.2.0",
|
|
16
|
-
"execa": "^9.6.1"
|
|
17
|
-
"agex-agent": "0.1.0",
|
|
18
|
-
"agex-browse": "0.1.0",
|
|
19
|
-
"agex-prove-pr": "0.1.0",
|
|
20
|
-
"agex-review": "0.1.0",
|
|
21
|
-
"agex-prove": "0.1.0",
|
|
22
|
-
"agex-core": "0.1.0"
|
|
16
|
+
"execa": "^9.6.1"
|
|
23
17
|
},
|
|
24
18
|
"devDependencies": {
|
|
25
19
|
"@types/node": "^22.19.7",
|
|
26
20
|
"tsup": "^8.4.0",
|
|
27
21
|
"typescript": "^5.9.3",
|
|
28
|
-
"vitest": "^2.1.9"
|
|
22
|
+
"vitest": "^2.1.9",
|
|
23
|
+
"agex-agent": "0.1.0",
|
|
24
|
+
"agex-core": "0.1.0",
|
|
25
|
+
"agex-browse": "0.1.0",
|
|
26
|
+
"agex-prove-pr": "0.1.0",
|
|
27
|
+
"agex-review": "0.1.0",
|
|
28
|
+
"agex-prove": "0.1.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsc -p tsconfig.json",
|