@booki-aui/readiness 0.2.0 → 0.2.2
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/CHANGELOG.md +12 -0
- package/README.md +26 -2
- package/dist/{chunk-SSFV5SRX.js → chunk-2ZR5XHHK.js} +22 -11
- package/dist/cli.js +4 -3
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @booki/readiness
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#125](https://github.com/Walgermo/booki/pull/125) [`815a6ad`](https://github.com/Walgermo/booki/commit/815a6ad8b7506ca0d1b1b939f622c967c125564b) Thanks [@Walgermo](https://github.com/Walgermo)! - A page whose bridge (window.agent, or a WebMCP snapshot tool) has no controls but which has fields of its own (plain selects and text areas that are not on the bridge) no longer scores 100. Each such field is now reported as `field-not-on-bridge`, as it already was when the bridge had some controls. A page with an empty bridge and nothing else to judge is still "not measured".
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#117](https://github.com/Walgermo/booki/pull/117) [`cd2641e`](https://github.com/Walgermo/booki/commit/cd2641ed58e1663d7d65efbd3932c4628643a86b) Thanks [@Walgermo](https://github.com/Walgermo)! - A page whose bridge has no controls and that has no fields or charts no longer reads as a pass. The console prints "no score", the HTML report says nothing was measured, and the JSON report gets `measured: false`, `grade: "not measured"` and a `notMeasured` text that points to opening the form first and calling `check(page)`. A page without a bridge but with fields is still scored, with `bridge-missing`. `score` stays in the JSON. `--fail-under` exits 1 for an unmeasured page.
|
|
14
|
+
|
|
3
15
|
## 0.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -189,8 +189,8 @@ not sufficient.
|
|
|
189
189
|
column header, a CSS selector and the element's HTML), why it matters to an
|
|
190
190
|
agent, the fix, and Booki's control for it when one exists. It ends with the
|
|
191
191
|
bridge's controls and actions and the full snapshot a browser agent reads.
|
|
192
|
-
- **JSON:** the same data: `score`, `grade`, `
|
|
193
|
-
`metrics`, `bridge`. The raw snapshot is left out unless you pass
|
|
192
|
+
- **JSON:** the same data: `score`, `grade`, `measured`, `deductions`,
|
|
193
|
+
`findings`, `metrics`, `bridge`. The raw snapshot is left out unless you pass
|
|
194
194
|
`--snapshot`.
|
|
195
195
|
|
|
196
196
|
Secrets the tool finds are masked (`86•••••••47`) everywhere in the output,
|
|
@@ -240,6 +240,30 @@ lets an agent act through named actions instead of guessing. A page with a
|
|
|
240
240
|
bridge loses 5 points for each field the bridge leaves out, up to 30, so a
|
|
241
241
|
bridge that offers only part of the screen no longer scores 100.
|
|
242
242
|
|
|
243
|
+
### When nothing was measured
|
|
244
|
+
|
|
245
|
+
The command line never clicks. A form that appears only after a row is
|
|
246
|
+
selected or a button is pressed is not on the page it loads, so the bridge has
|
|
247
|
+
no controls and the page has no fields or charts for the other checks to judge.
|
|
248
|
+
A page without a bridge but with fields is still scored (and gets
|
|
249
|
+
`bridge-missing`). A bridge with no controls on a page that has fields of its
|
|
250
|
+
own is scored too: each field is reported as `field-not-on-bridge`, so it is
|
|
251
|
+
not a pass. When nothing is there to judge, the tool prints `no score` instead of a figure, the HTML report says the same,
|
|
252
|
+
and the JSON report has `measured: false`, `grade: "not measured"` and a
|
|
253
|
+
`notMeasured` text. `score` stays in the JSON so its shape does not change,
|
|
254
|
+
but it is not a pass. With `--fail-under`, an unmeasured page exits with code 1.
|
|
255
|
+
|
|
256
|
+
Open the form first, then check the open page:
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import { check } from "@booki-aui/readiness"
|
|
260
|
+
|
|
261
|
+
await page.getByRole("row", { name: "Invoice 1042" }).click()
|
|
262
|
+
await page.getByRole("button", { name: "Edit" }).click()
|
|
263
|
+
const report = await check(page)
|
|
264
|
+
if (!report.measured) throw new Error(report.notMeasured)
|
|
265
|
+
```
|
|
266
|
+
|
|
243
267
|
## Reference scores
|
|
244
268
|
|
|
245
269
|
Measured on this repository's benchmark pages (`apps/www`, built and served
|
|
@@ -444,16 +444,16 @@ async function readBridge() {
|
|
|
444
444
|
try {
|
|
445
445
|
if (typeof g.agent?.snapshot === "function") {
|
|
446
446
|
const components = toList(await g.agent.snapshot());
|
|
447
|
-
return { source: "window.agent", components, tools, error: null };
|
|
447
|
+
return { source: "window.agent", components, tools, snapshotRead: true, error: null };
|
|
448
448
|
}
|
|
449
449
|
const snapshotTool = (g.__readinessTools ?? []).find((tool) => tool.name === "snapshot");
|
|
450
450
|
if (snapshotTool?.execute) {
|
|
451
451
|
const components = toList(await snapshotTool.execute({}));
|
|
452
|
-
return { source: "webmcp", components, tools, error: null };
|
|
452
|
+
return { source: "webmcp", components, tools, snapshotRead: true, error: null };
|
|
453
453
|
}
|
|
454
|
-
return { source: tools.length ? "webmcp" : null, components: [], tools, error: null };
|
|
454
|
+
return { source: tools.length ? "webmcp" : null, components: [], tools, snapshotRead: false, error: null };
|
|
455
455
|
} catch (error) {
|
|
456
|
-
return { source: null, components: [], tools, error: String(error) };
|
|
456
|
+
return { source: null, components: [], tools, snapshotRead: false, error: String(error) };
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
function bridgeCoverage(element2, entries) {
|
|
@@ -683,6 +683,7 @@ async function audit(input, options = {}) {
|
|
|
683
683
|
await close();
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
|
+
var NOT_MEASURED = "Nothing measured: the bridge has no controls and the page has no fields or charts, so the checks had nothing to compare. The tool never clicks: a form that appears after a row is selected or a button is pressed is not on the page yet. Open the form first (a Playwright step), then call check(page) from @booki-aui/readiness.";
|
|
686
687
|
async function check(page, url = page.url()) {
|
|
687
688
|
const snapshot = await page.ariaSnapshot({ mode: "ai" });
|
|
688
689
|
const nodes = parseSnapshot(snapshot);
|
|
@@ -776,7 +777,7 @@ async function check(page, url = page.url()) {
|
|
|
776
777
|
}
|
|
777
778
|
const entries = raw.components.filter((c) => !c.offPage && c.component !== "more").map((c) => ({ component: String(c.component ?? ""), label: typeof c.label === "string" ? c.label : "" }));
|
|
778
779
|
const truncated = raw.components.some((c) => c.component === "more");
|
|
779
|
-
if (
|
|
780
|
+
if (raw.snapshotRead && !truncated) {
|
|
780
781
|
const norm = (text) => text.replace(/\s+/g, " ").trim().toLowerCase();
|
|
781
782
|
const labels = new Set(entries.map((e) => norm(e.label)).filter(Boolean));
|
|
782
783
|
const seenGroups = /* @__PURE__ */ new Set();
|
|
@@ -928,12 +929,15 @@ async function check(page, url = page.url()) {
|
|
|
928
929
|
for (const control of controls) control.label = redact(control.label);
|
|
929
930
|
const title = await page.title();
|
|
930
931
|
const result = score(findings);
|
|
932
|
+
const measured = bridge.components > 0 || fields.length > 0 || charts.length > 0;
|
|
931
933
|
return {
|
|
932
934
|
tool: { name: "@booki-aui/readiness", version: VERSION },
|
|
933
935
|
url,
|
|
934
936
|
title,
|
|
935
937
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
936
938
|
...result,
|
|
939
|
+
measured,
|
|
940
|
+
...measured ? {} : { grade: "not measured", notMeasured: NOT_MEASURED },
|
|
937
941
|
findings: sortFindings(findings),
|
|
938
942
|
metrics: {
|
|
939
943
|
snapshotChars: snapshot.length,
|
|
@@ -972,14 +976,19 @@ var red = paint("31");
|
|
|
972
976
|
var yellow = paint("33");
|
|
973
977
|
var green = paint("32");
|
|
974
978
|
function toConsole(report) {
|
|
975
|
-
const colour = report.score >= 85 ? green : report.score >= 60 ? yellow : red;
|
|
979
|
+
const colour = !report.measured ? yellow : report.score >= 85 ? green : report.score >= 60 ? yellow : red;
|
|
976
980
|
const out = [];
|
|
977
981
|
out.push(`${bold("Agent readiness")} ${report.url}`);
|
|
978
982
|
if (report.redirectedFrom) out.push(yellow(redirectNote(report)));
|
|
983
|
+
const headline = report.measured ? `${report.score}/100` : "no score";
|
|
979
984
|
out.push(
|
|
980
|
-
`${colour(bold(
|
|
985
|
+
`${colour(bold(headline))} ${colour(report.grade)} ${dim(`\xB7 ${report.findings.length} findings \xB7 snapshot \u2248 ${report.metrics.snapshotTokens.toLocaleString("en-US")} tokens \xB7 bridge: ${bridgeLine(report)}`)}`
|
|
981
986
|
);
|
|
982
987
|
out.push("");
|
|
988
|
+
if (!report.measured) {
|
|
989
|
+
out.push(yellow(report.notMeasured ?? ""));
|
|
990
|
+
out.push("");
|
|
991
|
+
}
|
|
983
992
|
const byRule = groupByRule(report.findings);
|
|
984
993
|
for (const d of report.deductions) {
|
|
985
994
|
const rule = RULES[d.rule];
|
|
@@ -994,7 +1003,7 @@ function toConsole(report) {
|
|
|
994
1003
|
if (rule.booki) out.push(` ${dim("Booki:")} ${rule.booki}`);
|
|
995
1004
|
out.push("");
|
|
996
1005
|
}
|
|
997
|
-
if (!report.findings.length) out.push(green("Nothing found that stops an agent on this page."));
|
|
1006
|
+
if (!report.findings.length && report.measured) out.push(green("Nothing found that stops an agent on this page."));
|
|
998
1007
|
return out.join("\n");
|
|
999
1008
|
}
|
|
1000
1009
|
function bridgeLine(report) {
|
|
@@ -1015,7 +1024,7 @@ function redirectNote(report) {
|
|
|
1015
1024
|
}
|
|
1016
1025
|
function toHtml(report) {
|
|
1017
1026
|
const byRule = groupByRule(report.findings);
|
|
1018
|
-
const tone = report.score >= 85 ? "good" : report.score >= 60 ? "warn" : "bad";
|
|
1027
|
+
const tone = !report.measured ? "warn" : report.score >= 85 ? "good" : report.score >= 60 ? "warn" : "bad";
|
|
1019
1028
|
const sections = report.deductions.map((d) => {
|
|
1020
1029
|
const rule = RULES[d.rule];
|
|
1021
1030
|
const items = (byRule.get(d.rule) ?? []).map((f) => {
|
|
@@ -1097,9 +1106,10 @@ details pre { white-space: pre-wrap; font: 12px/1.4 ui-monospace, Menlo, monospa
|
|
|
1097
1106
|
<h1>Agent readiness</h1>
|
|
1098
1107
|
<p class="url">${esc(report.title)} \xB7 <a href="${esc(report.url)}">${esc(report.url)}</a> \xB7 ${esc(report.checkedAt.slice(0, 16).replace("T", " "))} UTC</p>
|
|
1099
1108
|
${report.redirectedFrom ? `<p class="redirect"><strong>${esc(redirectNote(report))}</strong></p>` : ""}
|
|
1109
|
+
${report.measured ? "" : `<p class="redirect"><strong>${esc(report.notMeasured ?? "")}</strong></p>`}
|
|
1100
1110
|
|
|
1101
1111
|
<div class="summary">
|
|
1102
|
-
<div class="score tone-${tone}">${report.score}<small>/100</small
|
|
1112
|
+
<div class="score tone-${tone}">${report.measured ? `${report.score}<small>/100</small>` : `<small>no score</small>`}<div style="font-size:15px;font-weight:600;margin-top:6px">${esc(report.grade)}</div></div>
|
|
1103
1113
|
<dl class="facts">
|
|
1104
1114
|
<div><dt>Findings</dt><dd>${report.findings.length}</dd></div>
|
|
1105
1115
|
<div><dt>Snapshot</dt><dd>\u2248 ${report.metrics.snapshotTokens.toLocaleString("en-US")} tokens</dd></div>
|
|
@@ -1112,10 +1122,11 @@ ${report.redirectedFrom ? `<p class="redirect"><strong>${esc(redirectNote(report
|
|
|
1112
1122
|
|
|
1113
1123
|
<div class="block">
|
|
1114
1124
|
<h2>Score</h2>
|
|
1125
|
+
${report.measured ? "" : `<p class="muted"><strong>Not measured.</strong> There is no score: the bridge had no controls and the page has no fields or charts.</p>`}
|
|
1115
1126
|
<p class="muted">100, minus each rule's points per finding, capped per rule. 85 and up: ready. 60 to 84: partly ready. Below 60: not ready.</p>
|
|
1116
1127
|
<table><thead><tr><th>Rule</th><th>Contract</th><th class="num">Found</th><th class="num">Points</th></tr></thead><tbody>
|
|
1117
1128
|
${report.deductions.map((d) => `<tr><td><a href="#${d.rule}">${esc(RULES[d.rule].title)}</a></td><td>${esc(RULES[d.rule].contract)}</td><td class="num">${d.findings}</td><td class="num">\u2212${d.points}</td></tr>`).join("")}
|
|
1118
|
-
${report.deductions.length ? "" : `<tr><td colspan="4"
|
|
1129
|
+
${report.deductions.length ? "" : `<tr><td colspan="4">${report.measured ? "Nothing found." : "Nothing found, and nothing measured."}</td></tr>`}
|
|
1119
1130
|
</tbody></table>
|
|
1120
1131
|
</div>
|
|
1121
1132
|
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
toConsole,
|
|
5
5
|
toHtml,
|
|
6
6
|
toJson
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-2ZR5XHHK.js";
|
|
8
8
|
import "./chunk-5SCOA3ZP.js";
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
@@ -28,7 +28,8 @@ Options
|
|
|
28
28
|
--wait-for <selector> Wait until this selector is on the page
|
|
29
29
|
--timeout <ms> Give up on loading the page (and --wait-for) after this long (default 30000)
|
|
30
30
|
--headed Show the browser
|
|
31
|
-
--fail-under <score> Exit with code 1 when the score is below this
|
|
31
|
+
--fail-under <score> Exit with code 1 when the score is below this,
|
|
32
|
+
or when nothing was measured (bridge with no controls)
|
|
32
33
|
--snapshot Include the full accessibility snapshot in the JSON
|
|
33
34
|
-h, --help This text
|
|
34
35
|
`;
|
|
@@ -86,7 +87,7 @@ JSON: ${json}
|
|
|
86
87
|
`);
|
|
87
88
|
}
|
|
88
89
|
const floor = values["fail-under"] ? Number(values["fail-under"]) : null;
|
|
89
|
-
return floor !== null && report.score < floor ? 1 : 0;
|
|
90
|
+
return floor !== null && (!report.measured || report.score < floor) ? 1 : 0;
|
|
90
91
|
}
|
|
91
92
|
main().then(
|
|
92
93
|
(code) => process.exit(code),
|
package/dist/index.d.ts
CHANGED
|
@@ -97,7 +97,15 @@ type Report = {
|
|
|
97
97
|
title: string;
|
|
98
98
|
checkedAt: string;
|
|
99
99
|
score: number;
|
|
100
|
-
grade: "ready" | "partly ready" | "not ready";
|
|
100
|
+
grade: "ready" | "partly ready" | "not ready" | "not measured";
|
|
101
|
+
/**
|
|
102
|
+
* False when the bridge has no controls and the page has no fields or charts:
|
|
103
|
+
* the form may not be open yet, so
|
|
104
|
+
* `score` rests on almost nothing and `grade` is "not measured".
|
|
105
|
+
*/
|
|
106
|
+
measured: boolean;
|
|
107
|
+
/** Set when `measured` is false: what to do instead. */
|
|
108
|
+
notMeasured?: string;
|
|
101
109
|
/** Points lost per rule. */
|
|
102
110
|
deductions: Array<{
|
|
103
111
|
rule: RuleId;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@booki-aui/readiness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Agent readiness check for accounting screens: what stops an AI agent on a page, scored 0-100 against the Agent Contract, with fixes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|