blastproof 0.30.0 → 0.31.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/README.md CHANGED
@@ -104,7 +104,7 @@ That test failed 3 runs of 3 written as one step, and passed 3 of 3 written this
104
104
  Not supported yet:
105
105
 
106
106
  - **`iframe` content** — a hosted payment widget is invisible, so an embedded checkout cannot be driven end to end
107
- - **hover, scroll-to, drag and drop, file upload**
107
+ - **scroll-to, drag and drop, file upload**
108
108
  - **multiple tabs**, and native `alert` / `confirm` dialogs
109
109
 
110
110
  **Windows is untested.** Development and CI run on Linux and macOS. Nothing is known to be broken and reports are welcome ([#8](https://github.com/hamc/blastproof/issues/8)).
package/dist/cli.js CHANGED
@@ -646,6 +646,12 @@ async function performResolvedAction(page, action, ctx) {
646
646
  await locator.click();
647
647
  return `ok: clicked ${describeTarget(target)}`;
648
648
  }
649
+ case "hover": {
650
+ const target = requireTarget(action);
651
+ const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);
652
+ await locator.hover();
653
+ return `ok: hovered ${describeTarget(target)}`;
654
+ }
649
655
  case "fill": {
650
656
  const target = requireTarget(action);
651
657
  const value = resolve(requireValue(action), ctx);
@@ -987,6 +993,19 @@ async function pageChangedWithin(page, takeSnapshot, view, seen, withinMs) {
987
993
  }
988
994
  return void 0;
989
995
  }
996
+ var NOTE_MAX_LINES = 4;
997
+ function pageChangeNote(before, after) {
998
+ const beforeLines = before.split("\n");
999
+ const afterLines = after.split("\n");
1000
+ const kept = { before: new Set(beforeLines), after: new Set(afterLines) };
1001
+ const removed = beforeLines.filter((line) => !kept.after.has(line));
1002
+ const added = afterLines.filter((line) => !kept.before.has(line));
1003
+ const changed = removed.length + added.length;
1004
+ if (changed === 0) return " (after it, the page did not change at all)";
1005
+ if (changed > NOTE_MAX_LINES) return void 0;
1006
+ const lines = [...removed.map((line) => `- ${line.trim()}`), ...added.map((line) => `+ ${line.trim()}`)];
1007
+ return ` (after it, the only change on the page: ${lines.join("; ")})`;
1008
+ }
990
1009
  async function executeTest(page, test, options) {
991
1010
  const {
992
1011
  brain,
@@ -1035,6 +1054,8 @@ async function executeTest(page, test, options) {
1035
1054
  let lastSnapshot;
1036
1055
  let lookedAgain = false;
1037
1056
  const recovery = new StepRecovery(step);
1057
+ const agentRecord = [];
1058
+ let pageActedOn;
1038
1059
  try {
1039
1060
  while (true) {
1040
1061
  if (iterations >= maxIterationsPerStep) {
@@ -1052,6 +1073,15 @@ async function executeTest(page, test, options) {
1052
1073
  const refs = indexRefs(maskedSnap);
1053
1074
  const pageSnap = withoutRefs(maskedSnap);
1054
1075
  recovery.observe(pageSnap);
1076
+ if (pageActedOn !== void 0) {
1077
+ const note = pageChangeNote(pageActedOn, pageSnap);
1078
+ const acted = agentRecord[agentRecord.length - 1];
1079
+ if (note !== void 0 && acted !== void 0 && lastResult !== void 0) {
1080
+ acted.result += note;
1081
+ lastResult += note;
1082
+ }
1083
+ pageActedOn = void 0;
1084
+ }
1055
1085
  let action;
1056
1086
  try {
1057
1087
  action = await brain.nextAction({
@@ -1061,7 +1091,7 @@ async function executeTest(page, test, options) {
1061
1091
  lastResult: lastResult === void 0 ? void 0 : mask(lastResult),
1062
1092
  // Already masked when recorded, on the same boundary as everything
1063
1093
  // else crossing into a prompt (design contained-recovery, D2).
1064
- stepHistory: recovery.stepHistory(),
1094
+ stepHistory: agentRecord.map((entry) => ({ ...entry })),
1065
1095
  retriesLeft: maxRetries - failedAttempts,
1066
1096
  iterationsLeft: maxIterationsPerStep - iterations
1067
1097
  });
@@ -1145,6 +1175,9 @@ async function executeTest(page, test, options) {
1145
1175
  continue;
1146
1176
  }
1147
1177
  const result = judgment.pass ? `ok: assertion passed: ${judgment.reason}` : `assertion failed: ${judgment.reason}`;
1178
+ if (!judgment.pass) {
1179
+ agentRecord.push({ action: `assert "${mask(expectation)}"`, result: mask(result) });
1180
+ }
1148
1181
  emitAction(index, shown(), result);
1149
1182
  if (judgment.pass) {
1150
1183
  lastResult = result;
@@ -1187,6 +1220,8 @@ async function executeTest(page, test, options) {
1187
1220
  });
1188
1221
  lastResult = result;
1189
1222
  recovery.record(action, mask(describeAction(action)), mask(result));
1223
+ agentRecord.push({ action: mask(describeAction(action)), result: mask(result) });
1224
+ pageActedOn = pageSnap;
1190
1225
  emitAction(index, action, result);
1191
1226
  } catch (error) {
1192
1227
  failedAttempts++;
@@ -2019,7 +2054,7 @@ Rules:
2019
2054
  - Return exactly ONE action per response. Never batch actions.
2020
2055
  - Placeholders like {{env.SOME_NAME}} are secrets that are filled in after you answer. Pass them through in your action exactly as written, never expanded, never guessed at.
2021
2056
  - Pick target elements exclusively from the current snapshot. Every element there carries a ref, like \`[ref=f1e25]\`: name your target by that ref, and give its role and name exactly as that same line shows them (the text after the colon when it has no quoted name). The ref decides which element is acted on, so copy it from the line of the element you mean; a role or name that does not match that line is refused. Refs change when the page changes, so always take them from the current snapshot. Never invent CSS selectors or guess elements not in the snapshot.
2022
- - Use "navigate" only with a URL or path as value. Use "fill" to type into textboxes/inputs. Use "press" for keyboard keys (value e.g. "Enter"). Use "select" for dropdowns (value = option label).
2057
+ - Use "navigate" only with a URL or path as value. Use "fill" to type into textboxes/inputs. Use "press" for keyboard keys (value e.g. "Enter"). Use "select" for dropdowns (value = option label). Use "hover" to point at an element without clicking it, when a menu, tooltip or control appears only on hover.
2023
2058
  - Use "assert" with an expectation to verify page state (visible text, counts, URLs). Assertions never modify the page.
2024
2059
  - A step that begins with "verify", "check", "confirm", "ensure", "assert", "expect", "validate", "make sure" or "see that" only looks. Never click or press in it: making the page show what the step checks would hide the very thing it checks. Assert what the page shows, navigate if what it names is on another page, or fail. It closes on a passing assertion, never on "done". This is enforced: a click, a press or "done" in such a step is refused.
2025
2060
  - Return "done" when the current step's outcome holds \u2014 including when it already held before you acted, or was achieved by your previous action. "Already true" is done, never failure. Do not return "done" for work belonging to later steps.
@@ -2353,7 +2388,7 @@ import { z as z2 } from "zod";
2353
2388
  function absentAsNull(schema) {
2354
2389
  return schema.nullable().transform((value) => value ?? void 0);
2355
2390
  }
2356
- var ACTION_NAMES = ["navigate", "click", "fill", "press", "select", "assert", "done", "fail"];
2391
+ var ACTION_NAMES = ["navigate", "click", "fill", "press", "select", "hover", "assert", "done", "fail"];
2357
2392
  var agentActionSchema = z2.object({
2358
2393
  action: z2.enum(ACTION_NAMES).describe("The next browser action to perform for the current step."),
2359
2394
  target: absentAsNull(
@@ -4148,7 +4183,7 @@ function parsePositiveNumber(flag) {
4148
4183
  };
4149
4184
  }
4150
4185
  var program = new Command();
4151
- program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.30.0");
4186
+ program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.31.0");
4152
4187
  program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
4153
4188
  try {
4154
4189
  const result = await initProject(process.cwd());