blastproof 0.24.0 → 0.26.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 +9 -6
- package/dist/chunk-DO4WZKLT.js +124 -0
- package/dist/chunk-DO4WZKLT.js.map +1 -0
- package/dist/cli.js +287 -68
- package/dist/cli.js.map +1 -1
- package/dist/snapshot-JISKGGMN.js +16 -0
- package/dist/snapshot-JISKGGMN.js.map +1 -0
- package/package.json +1 -1
- package/dist/snapshot-CAIB2OHX.js +0 -43
- package/dist/snapshot-CAIB2OHX.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
captureSnapshot,
|
|
4
|
+
indexRefs,
|
|
5
|
+
snapshotCutAt,
|
|
6
|
+
trimSnapshot,
|
|
7
|
+
withoutRefs
|
|
8
|
+
} from "./chunk-DO4WZKLT.js";
|
|
9
|
+
export {
|
|
10
|
+
captureSnapshot,
|
|
11
|
+
indexRefs,
|
|
12
|
+
snapshotCutAt,
|
|
13
|
+
trimSnapshot,
|
|
14
|
+
withoutRefs
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=snapshot-JISKGGMN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/runner/snapshot.ts
|
|
4
|
-
var DEFAULT_MAX_LINES = 200;
|
|
5
|
-
function indentOf(line) {
|
|
6
|
-
return line.length - line.trimStart().length;
|
|
7
|
-
}
|
|
8
|
-
function trimSnapshot(snapshotYaml, maxLines = DEFAULT_MAX_LINES) {
|
|
9
|
-
let lines = snapshotYaml.split("\n").filter((line) => line.trim().length > 0);
|
|
10
|
-
for (let pass = 0; pass < 5; pass++) {
|
|
11
|
-
const kept = [];
|
|
12
|
-
let removed = 0;
|
|
13
|
-
for (let i = 0; i < lines.length; i++) {
|
|
14
|
-
const line = lines[i];
|
|
15
|
-
const isContainer = line.trimEnd().endsWith(":");
|
|
16
|
-
if (isContainer) {
|
|
17
|
-
const next = lines[i + 1];
|
|
18
|
-
const hasChildren = next !== void 0 && indentOf(next) > indentOf(line);
|
|
19
|
-
if (!hasChildren) {
|
|
20
|
-
removed++;
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
kept.push(line);
|
|
25
|
-
}
|
|
26
|
-
lines = kept;
|
|
27
|
-
if (removed === 0) break;
|
|
28
|
-
}
|
|
29
|
-
if (lines.length > maxLines) {
|
|
30
|
-
lines = [...lines.slice(0, maxLines), `- ... (snapshot truncated after ${maxLines} lines)`];
|
|
31
|
-
}
|
|
32
|
-
return lines.join("\n");
|
|
33
|
-
}
|
|
34
|
-
async function captureSnapshot(page, options = {}) {
|
|
35
|
-
const raw = await page.locator("body").ariaSnapshot();
|
|
36
|
-
return `url: ${page.url()}
|
|
37
|
-
${trimSnapshot(raw, options.maxLines)}`;
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
captureSnapshot,
|
|
41
|
-
trimSnapshot
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=snapshot-CAIB2OHX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runner/snapshot.ts"],"sourcesContent":["import type { Page } from 'playwright';\n\nexport interface SnapshotOptions {\n /** Maximum number of snapshot lines sent to the LLM. Default 200. */\n maxLines?: number;\n}\n\nconst DEFAULT_MAX_LINES = 200;\n\nfunction indentOf(line: string): number {\n return line.length - line.trimStart().length;\n}\n\n/**\n * Trims an aria snapshot: drops empty containers (e.g. `- group:` with no children)\n * and caps the line count. Pure function, exported for tests.\n */\nexport function trimSnapshot(snapshotYaml: string, maxLines: number = DEFAULT_MAX_LINES): string {\n let lines = snapshotYaml.split('\\n').filter((line) => line.trim().length > 0);\n\n // Removing empty containers can empty their parents; iterate until stable (bounded).\n for (let pass = 0; pass < 5; pass++) {\n const kept: string[] = [];\n let removed = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n const isContainer = line.trimEnd().endsWith(':');\n if (isContainer) {\n const next = lines[i + 1];\n const hasChildren = next !== undefined && indentOf(next) > indentOf(line);\n if (!hasChildren) {\n removed++;\n continue;\n }\n }\n kept.push(line);\n }\n lines = kept;\n if (removed === 0) break;\n }\n\n if (lines.length > maxLines) {\n lines = [...lines.slice(0, maxLines), `- ... (snapshot truncated after ${maxLines} lines)`];\n }\n return lines.join('\\n');\n}\n\n/**\n * Captures the current page as a compact accessibility snapshot (design D1),\n * prefixed with the page URL so the model can reason about navigation.\n */\nexport async function captureSnapshot(page: Page, options: SnapshotOptions = {}): Promise<string> {\n const raw = await page.locator('body').ariaSnapshot();\n return `url: ${page.url()}\\n${trimSnapshot(raw, options.maxLines)}`;\n}\n"],"mappings":";;;AAOA,IAAM,oBAAoB;AAE1B,SAAS,SAAS,MAAsB;AACtC,SAAO,KAAK,SAAS,KAAK,UAAU,EAAE;AACxC;AAMO,SAAS,aAAa,cAAsB,WAAmB,mBAA2B;AAC/F,MAAI,QAAQ,aAAa,MAAM,IAAI,EAAE,OAAO,CAAC,SAAS,KAAK,KAAK,EAAE,SAAS,CAAC;AAG5E,WAAS,OAAO,GAAG,OAAO,GAAG,QAAQ;AACnC,UAAM,OAAiB,CAAC;AACxB,QAAI,UAAU;AACd,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,YAAM,OAAO,MAAM,CAAC;AACpB,YAAM,cAAc,KAAK,QAAQ,EAAE,SAAS,GAAG;AAC/C,UAAI,aAAa;AACf,cAAM,OAAO,MAAM,IAAI,CAAC;AACxB,cAAM,cAAc,SAAS,UAAa,SAAS,IAAI,IAAI,SAAS,IAAI;AACxE,YAAI,CAAC,aAAa;AAChB;AACA;AAAA,QACF;AAAA,MACF;AACA,WAAK,KAAK,IAAI;AAAA,IAChB;AACA,YAAQ;AACR,QAAI,YAAY,EAAG;AAAA,EACrB;AAEA,MAAI,MAAM,SAAS,UAAU;AAC3B,YAAQ,CAAC,GAAG,MAAM,MAAM,GAAG,QAAQ,GAAG,mCAAmC,QAAQ,SAAS;AAAA,EAC5F;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;AAMA,eAAsB,gBAAgB,MAAY,UAA2B,CAAC,GAAoB;AAChG,QAAM,MAAM,MAAM,KAAK,QAAQ,MAAM,EAAE,aAAa;AACpD,SAAO,QAAQ,KAAK,IAAI,CAAC;AAAA,EAAK,aAAa,KAAK,QAAQ,QAAQ,CAAC;AACnE;","names":[]}
|