blastproof 0.36.0 → 0.37.0
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/cli.js +93 -24
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -915,6 +915,10 @@ function isDialogRef(ref) {
|
|
|
915
915
|
if (ref === void 0) return false;
|
|
916
916
|
return DIALOG_REF.test(ref.trim().replace(/^\[/, "").replace(/^ref=/, "").replace(/\]$/, ""));
|
|
917
917
|
}
|
|
918
|
+
function isDialogSnapshot(snapshot) {
|
|
919
|
+
const first = snapshot.split("\n", 1)[0] ?? "";
|
|
920
|
+
return /^- alertdialog ".*" \[native .+\]:$/.test(first);
|
|
921
|
+
}
|
|
918
922
|
function quoted(text) {
|
|
919
923
|
return `"${text.replace(/\s*\n\s*/g, " ").replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
920
924
|
}
|
|
@@ -1080,7 +1084,9 @@ var DialogWatch = class {
|
|
|
1080
1084
|
if (!open) return void 0;
|
|
1081
1085
|
const out = [
|
|
1082
1086
|
`- alertdialog ${quoted(nameOf(open))} [native ${open.kind}]:`,
|
|
1083
|
-
//
|
|
1087
|
+
// Context for every model. Not the guarantee: a claim about the page passed
|
|
1088
|
+
// on it (#218), so `judge()` fails one by rule (`isDialogSnapshot`,
|
|
1089
|
+
// `behindTheDialog`).
|
|
1084
1090
|
" - text: The page behind this dialog cannot be seen until the dialog is answered."
|
|
1085
1091
|
];
|
|
1086
1092
|
for (const control of controlsOf(open)) {
|
|
@@ -2581,10 +2587,14 @@ async function getUncommittedFiles(cwd = process.cwd()) {
|
|
|
2581
2587
|
if (from) paths.add(from.replace(/\\/g, "/"));
|
|
2582
2588
|
}
|
|
2583
2589
|
return [...paths].sort();
|
|
2584
|
-
} catch {
|
|
2585
|
-
|
|
2590
|
+
} catch (error) {
|
|
2591
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2592
|
+
return { unreadable: message.split(/\r?\n/).find((line) => line.trim() !== "")?.trim() ?? "git status failed" };
|
|
2586
2593
|
}
|
|
2587
2594
|
}
|
|
2595
|
+
function uncommittedPaths(files) {
|
|
2596
|
+
return Array.isArray(files) ? files : [];
|
|
2597
|
+
}
|
|
2588
2598
|
|
|
2589
2599
|
// src/impact.ts
|
|
2590
2600
|
import picomatch from "picomatch";
|
|
@@ -2660,10 +2670,7 @@ function printUncommitted(uncommitted, changedFiles, config, baseRef, into) {
|
|
|
2660
2670
|
emitWarning(uncommittedWarning(uncommitted, changedFiles, config, baseRef), into);
|
|
2661
2671
|
}
|
|
2662
2672
|
function uncommittedWarning(uncommitted, changedFiles, config, baseRef) {
|
|
2663
|
-
const
|
|
2664
|
-
const routes = config.routes ?? {};
|
|
2665
|
-
const ignore = config.ignore ?? [];
|
|
2666
|
-
const findings = uncommitted.filter((file) => !inDiff.has(file)).map((file) => ({ file, impact: mapImpact([file], routes, ignore) })).filter(({ impact }) => impact.ignoredFiles.length === 0);
|
|
2673
|
+
const findings = classifyUncommitted(uncommitted, changedFiles, config);
|
|
2667
2674
|
if (findings.length === 0) return void 0;
|
|
2668
2675
|
return {
|
|
2669
2676
|
kind: "uncommitted",
|
|
@@ -2677,6 +2684,15 @@ function uncommittedWarning(uncommitted, changedFiles, config, baseRef) {
|
|
|
2677
2684
|
spaced: true
|
|
2678
2685
|
};
|
|
2679
2686
|
}
|
|
2687
|
+
function unclassifiedUncommitted(uncommitted, changedFiles, config) {
|
|
2688
|
+
return classifyUncommitted(uncommitted, changedFiles, config).filter(({ impact }) => impact.unmappedFiles.length > 0).map(({ file }) => file);
|
|
2689
|
+
}
|
|
2690
|
+
function classifyUncommitted(uncommitted, changedFiles, config) {
|
|
2691
|
+
const inDiff = new Set(changedFiles.map((file) => file.replace(/\\/g, "/")));
|
|
2692
|
+
const routes = config.routes ?? {};
|
|
2693
|
+
const ignore = config.ignore ?? [];
|
|
2694
|
+
return uncommitted.filter((file) => !inDiff.has(file)).map((file) => ({ file, impact: mapImpact([file], routes, ignore) })).filter(({ impact }) => impact.ignoredFiles.length === 0);
|
|
2695
|
+
}
|
|
2680
2696
|
|
|
2681
2697
|
// src/llm/brain.ts
|
|
2682
2698
|
import { APICallError as APICallError2, generateObject, NoObjectGeneratedError, RetryError } from "ai";
|
|
@@ -2745,7 +2761,7 @@ Be strict about what the step asks, not about withholding a pass you can plainly
|
|
|
2745
2761
|
|
|
2746
2762
|
\`[redacted NAME]\` marks the value of {{env.NAME}}, deliberately withheld from you. Seeing one is expected. A field holding a label is filled, not empty, so do not fail a step on the grounds that a value was redacted. The same label is the same value, and two different labels are two different values: a step expecting \`[redacted A]\` is not satisfied by a page showing \`[redacted B]\`. This applies only to the redaction itself: everything else the step asks for must still be visibly satisfied by the snapshot, and a step you genuinely cannot check against what you were shown still fails.`;
|
|
2747
2763
|
}
|
|
2748
|
-
function assertUserPrompt(step, expectation, snapshot, stepHistory) {
|
|
2764
|
+
function assertUserPrompt(step, expectation, snapshot, stepHistory, dialog = false) {
|
|
2749
2765
|
const parts = [`Step under test: ${step}`];
|
|
2750
2766
|
if (stepHistory && stepHistory.length > 0) {
|
|
2751
2767
|
parts.push(
|
|
@@ -2760,9 +2776,15 @@ function assertUserPrompt(step, expectation, snapshot, stepHistory) {
|
|
|
2760
2776
|
"",
|
|
2761
2777
|
"Page accessibility snapshot:",
|
|
2762
2778
|
snapshot,
|
|
2763
|
-
""
|
|
2764
|
-
"Does the snapshot establish that the step's own outcome holds?"
|
|
2779
|
+
""
|
|
2765
2780
|
);
|
|
2781
|
+
if (dialog) {
|
|
2782
|
+
parts.push(
|
|
2783
|
+
"This snapshot is a native browser dialog, and nothing else: the page behind it cannot be seen until the dialog is answered. Say where the outcome would be seen. Only the dialog itself (its message, its buttons, its field) can show anything here.",
|
|
2784
|
+
""
|
|
2785
|
+
);
|
|
2786
|
+
}
|
|
2787
|
+
parts.push("Does the snapshot establish that the step's own outcome holds?");
|
|
2766
2788
|
return parts.join("\n");
|
|
2767
2789
|
}
|
|
2768
2790
|
function firstJudgeQuestion() {
|
|
@@ -3079,6 +3101,14 @@ var assertJudgmentSchema = z2.object({
|
|
|
3079
3101
|
"Whether the snapshot shows that outcome. The expectation is only a claim offered in support; it never replaces the step. False if any part of the outcome the step asks for is not shown, or cannot be assessed from this snapshot. An action the step names (click, dismiss, submit) is how its outcome is reached, not part of it: an outcome that holds passes whether or not that action was needed. An outcome that is an absence (gone, closed, dismissed, removed) is shown by the thing being absent. Where the step says the outcome appears (in the confirmation, in the list, for this order) is part of it: a value found only somewhere else on the page is false."
|
|
3080
3102
|
)
|
|
3081
3103
|
});
|
|
3104
|
+
var assertDialogJudgmentSchema = z2.object({
|
|
3105
|
+
outcome: assertJudgmentSchema.shape.outcome,
|
|
3106
|
+
seen: z2.enum(["dialog", "page"]).describe(
|
|
3107
|
+
'Where that outcome would be seen. "dialog" if every part of it is shown by the native dialog itself: its message, its buttons, its field, that it is open. "page" if any part of it concerns the page behind the dialog, which cannot be seen while the dialog is open.'
|
|
3108
|
+
),
|
|
3109
|
+
reason: assertJudgmentSchema.shape.reason,
|
|
3110
|
+
pass: assertJudgmentSchema.shape.pass
|
|
3111
|
+
});
|
|
3082
3112
|
var generatedTestSchema = z2.object({
|
|
3083
3113
|
summary: z2.string().min(1).describe('One line naming the user journey this test covers, e.g. "Applying a discount updates the cart total".'),
|
|
3084
3114
|
steps: z2.array(z2.string().min(1)).min(1).describe(
|
|
@@ -3194,8 +3224,25 @@ function createBrain(model, generate = generateObject, budget, firstJudge) {
|
|
|
3194
3224
|
}));
|
|
3195
3225
|
const judgedStep = placeholdersAsLabels(step);
|
|
3196
3226
|
const claim = placeholdersAsLabels(expectation);
|
|
3197
|
-
const
|
|
3227
|
+
const dialog = isDialogSnapshot(snapshot);
|
|
3228
|
+
const prompt = assertUserPrompt(judgedStep, claim, snapshot, asJudged, dialog);
|
|
3198
3229
|
const label = (judgment) => secretMismatch(judgedStep, snapshot, asJudged, usedEarlier ?? [], judgment);
|
|
3230
|
+
if (dialog) {
|
|
3231
|
+
const result2 = await countedGenerate(generate, budget, {
|
|
3232
|
+
model,
|
|
3233
|
+
schema: assertDialogJudgmentSchema,
|
|
3234
|
+
system: assertSystemPrompt(),
|
|
3235
|
+
prompt,
|
|
3236
|
+
temperature: 0
|
|
3237
|
+
});
|
|
3238
|
+
const parsed2 = assertDialogJudgmentSchema.safeParse(result2.object);
|
|
3239
|
+
if (!parsed2.success) {
|
|
3240
|
+
throw new MalformedModelOutputError(
|
|
3241
|
+
`Model returned an invalid assert judgment: ${parsed2.error.issues[0]?.message ?? "unknown"}`
|
|
3242
|
+
);
|
|
3243
|
+
}
|
|
3244
|
+
return label(behindTheDialog(parsed2.data));
|
|
3245
|
+
}
|
|
3199
3246
|
if (firstJudge) {
|
|
3200
3247
|
const decided = await firstJudgment(firstJudge, budget, { step: judgedStep, claim, snapshot, prompt }, label);
|
|
3201
3248
|
if (decided) return decided;
|
|
@@ -3217,6 +3264,11 @@ function createBrain(model, generate = generateObject, budget, firstJudge) {
|
|
|
3217
3264
|
}
|
|
3218
3265
|
};
|
|
3219
3266
|
}
|
|
3267
|
+
var BEHIND_THE_DIALOG = "the page behind the native dialog cannot be seen until the dialog is answered, so this step cannot be judged now";
|
|
3268
|
+
function behindTheDialog(judgment) {
|
|
3269
|
+
if (judgment.seen !== "page") return judgment;
|
|
3270
|
+
return { ...judgment, pass: false, reason: `${BEHIND_THE_DIALOG}. (The judge had said: ${judgment.reason})` };
|
|
3271
|
+
}
|
|
3220
3272
|
function secretMismatch(judgedStep, snapshot, judgedRecord, usedEarlier, judgment) {
|
|
3221
3273
|
if (!judgment.pass) return judgment;
|
|
3222
3274
|
const onPage = labelledVariables(snapshot);
|
|
@@ -4203,7 +4255,7 @@ function reportNearMissedSecrets(variables, warnings) {
|
|
|
4203
4255
|
);
|
|
4204
4256
|
}
|
|
4205
4257
|
}
|
|
4206
|
-
async function finalize(results, skipped, options, sessionDir, secretsHeld, nearMissedSecrets, warnings, durationMs,
|
|
4258
|
+
async function finalize(results, skipped, options, sessionDir, secretsHeld, nearMissedSecrets, warnings, durationMs, unclassified, incomplete, spend, firstJudgeLog) {
|
|
4207
4259
|
if (results.length > 0) printSummary(results);
|
|
4208
4260
|
reportNearMissedSecrets(nearMissedSecrets, warnings);
|
|
4209
4261
|
if (spend) console.log(formatSpendLine(spend));
|
|
@@ -4248,22 +4300,32 @@ async function finalize(results, skipped, options, sessionDir, secretsHeld, near
|
|
|
4248
4300
|
console.log(`HTML report: ${path11.relative(options.cwd, target)}`);
|
|
4249
4301
|
}
|
|
4250
4302
|
if (incomplete) return EXIT_FAILED;
|
|
4251
|
-
if (reportUnclassified(options,
|
|
4303
|
+
if (reportUnclassified(options, unclassified)) return EXIT_FAILED;
|
|
4252
4304
|
if (options.minScore !== void 0) {
|
|
4253
4305
|
return computeScore(results) >= options.minScore ? EXIT_OK : EXIT_FAILED;
|
|
4254
4306
|
}
|
|
4255
4307
|
return results.some((result) => result.status === "failed") ? EXIT_FAILED : EXIT_OK;
|
|
4256
4308
|
}
|
|
4257
|
-
function reportUnclassified(options,
|
|
4258
|
-
|
|
4259
|
-
|
|
4309
|
+
function reportUnclassified(options, unclassified) {
|
|
4310
|
+
if (!options.failOnUnmapped || !unclassified) return false;
|
|
4311
|
+
const unreadable = unclassified.unreadable !== void 0;
|
|
4312
|
+
if (unreadable) {
|
|
4313
|
+
console.error(`error: --fail-on-unmapped could not read the working tree: ${unclassified.unreadable}`);
|
|
4314
|
+
console.error("Run `git status` to see why, or run without --fail-on-unmapped.");
|
|
4315
|
+
}
|
|
4316
|
+
const { diff, uncommitted } = unclassified;
|
|
4317
|
+
if (diff.length + uncommitted.length === 0) return unreadable;
|
|
4260
4318
|
console.error(
|
|
4261
|
-
`error: ${
|
|
4319
|
+
`error: ${diff.length + uncommitted.length} changed file(s) match no routes: or ignore: glob, so their blast radius is unknown:`
|
|
4262
4320
|
);
|
|
4263
|
-
for (const file of
|
|
4321
|
+
for (const file of diff) console.error(` ${file}`);
|
|
4322
|
+
for (const file of uncommitted) console.error(` ${file} (uncommitted)`);
|
|
4264
4323
|
console.error(
|
|
4265
4324
|
"Map them in routes: if they can affect a page, or list them in ignore: if they cannot."
|
|
4266
4325
|
);
|
|
4326
|
+
if (uncommitted.length > 0) {
|
|
4327
|
+
console.error("An uncommitted file that is not part of this change can be stashed or added to .gitignore.");
|
|
4328
|
+
}
|
|
4267
4329
|
return true;
|
|
4268
4330
|
}
|
|
4269
4331
|
function declaredConfigRoutes(config) {
|
|
@@ -4349,6 +4411,7 @@ async function runCommand(options) {
|
|
|
4349
4411
|
return EXIT_USAGE;
|
|
4350
4412
|
}
|
|
4351
4413
|
let impact;
|
|
4414
|
+
let unclassified;
|
|
4352
4415
|
let changedCount = 0;
|
|
4353
4416
|
if (impacted) {
|
|
4354
4417
|
let changedFiles;
|
|
@@ -4363,7 +4426,13 @@ async function runCommand(options) {
|
|
|
4363
4426
|
}
|
|
4364
4427
|
impact = mapImpact(changedFiles, config.routes ?? {}, config.ignore ?? []);
|
|
4365
4428
|
changedCount = changedFiles.length;
|
|
4366
|
-
|
|
4429
|
+
const uncommitted = await getUncommittedFiles(options.cwd);
|
|
4430
|
+
printUncommitted(uncommittedPaths(uncommitted), changedFiles, config, base, warnings);
|
|
4431
|
+
unclassified = {
|
|
4432
|
+
diff: impact.unmappedFiles,
|
|
4433
|
+
uncommitted: unclassifiedUncommitted(uncommittedPaths(uncommitted), changedFiles, config),
|
|
4434
|
+
...Array.isArray(uncommitted) ? {} : { unreadable: uncommitted.unreadable }
|
|
4435
|
+
};
|
|
4367
4436
|
}
|
|
4368
4437
|
const testsDir = path11.join(options.cwd, TESTS_RELATIVE_DIR);
|
|
4369
4438
|
let files;
|
|
@@ -4422,7 +4491,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
4422
4491
|
for (const broken of results) console.error(` ${broken.file}: ${broken.reason ?? "invalid"}`);
|
|
4423
4492
|
return EXIT_FAILED;
|
|
4424
4493
|
}
|
|
4425
|
-
return reportUnclassified(options,
|
|
4494
|
+
return reportUnclassified(options, unclassified) ? EXIT_FAILED : EXIT_OK;
|
|
4426
4495
|
}
|
|
4427
4496
|
const sessionDir = path11.join(options.cwd, ".blastproof", "reports", sessionId());
|
|
4428
4497
|
const startedAt = Date.now();
|
|
@@ -4430,7 +4499,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
4430
4499
|
console.log(
|
|
4431
4500
|
impact ? "No impacted tests to run." : "No tests matched the given filters."
|
|
4432
4501
|
);
|
|
4433
|
-
return finalize(results, selection.unroutedSkipped, options, sessionDir, false, [], warnings, Date.now() - startedAt,
|
|
4502
|
+
return finalize(results, selection.unroutedSkipped, options, sessionDir, false, [], warnings, Date.now() - startedAt, unclassified);
|
|
4434
4503
|
}
|
|
4435
4504
|
let decide;
|
|
4436
4505
|
try {
|
|
@@ -4566,7 +4635,7 @@ ${results.length} test file(s) could not be parsed:`);
|
|
|
4566
4635
|
runMask.nearMissedVariables(),
|
|
4567
4636
|
warnings,
|
|
4568
4637
|
Date.now() - startedAt,
|
|
4569
|
-
|
|
4638
|
+
unclassified,
|
|
4570
4639
|
incomplete,
|
|
4571
4640
|
// The command that constructed the budget is the one that reports it
|
|
4572
4641
|
// (design report-what-it-spent, D2). `test` hands one budget to both of its
|
|
@@ -4615,7 +4684,7 @@ async function resolveTargets(options, config, suite) {
|
|
|
4615
4684
|
const base = options.base ?? "main";
|
|
4616
4685
|
const changedFiles = await getChangedFiles(base, options.cwd);
|
|
4617
4686
|
const impact = mapImpact(changedFiles, config.routes ?? {}, config.ignore ?? []);
|
|
4618
|
-
printUncommitted(await getUncommittedFiles(options.cwd), changedFiles, config, base);
|
|
4687
|
+
printUncommitted(uncommittedPaths(await getUncommittedFiles(options.cwd)), changedFiles, config, base);
|
|
4619
4688
|
const filesForRoute = (route) => changedFiles.filter(
|
|
4620
4689
|
(file) => mapImpact([file], config.routes ?? {}, config.ignore ?? []).affectedRoutes.includes(route)
|
|
4621
4690
|
);
|
|
@@ -4909,7 +4978,7 @@ function parsePositiveNumber(flag) {
|
|
|
4909
4978
|
};
|
|
4910
4979
|
}
|
|
4911
4980
|
var program = new Command();
|
|
4912
|
-
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.
|
|
4981
|
+
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.37.0");
|
|
4913
4982
|
program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
|
|
4914
4983
|
try {
|
|
4915
4984
|
const result = await initProject(process.cwd());
|