@booki-aui/readiness 0.2.4 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @booki/readiness
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#184](https://github.com/Walgermo/booki/pull/184) [`eb83ef8`](https://github.com/Walgermo/booki/commit/eb83ef87b6a3eaa8c91e63a27879710904361cd2) Thanks [@Walgermo](https://github.com/Walgermo)! - Preserve fractional basis points when calculating invoice and voucher tax. Payment batch approval and release now require a real calendar date. Aging reports, filtered money columns and party drill-downs calculate totals exactly and refuse totals outside the safe minor-unit range.
8
+
9
+ New working-paper proposals receive opaque, durable IDs. Read the ID from the proposal or bridge result when accepting, rejecting or withdrawing it. Existing pending proposals keep their IDs. HTML-backed papers preserve callout editability and list item identities. In the editor, Alt+Down focuses the command or mention list. Arrow keys, Home and End navigate, Enter selects, and Escape returns to the text without changing it.
10
+
11
+ Conformance checks on an empty bridge now report an incomplete result and return `conforms: false`. Run the check after the screen mounts.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#186](https://github.com/Walgermo/booki/pull/186) [`c735db6`](https://github.com/Walgermo/booki/commit/c735db698802f13d18b7aa698a07a5bd49099f5d) Thanks [@Walgermo](https://github.com/Walgermo)! - Preserve the classification of HTML callouts, such as `data-callout="warning"`, when a working paper is opened and saved.
16
+
17
+ Keep editor buttons in place during pointer clicks below open suggestions. Rejected aging filters now preserve the report and CSV. Unrepresentable aging reports show an issue, and a hidden money column with an unrepresentable total no longer prevents other columns from rendering.
18
+
19
+ Conformance checks skip the person-only probe until the screen has mounted controls.
20
+
21
+ ## 0.2.5
22
+
23
+ ### Patch Changes
24
+
25
+ - [#171](https://github.com/Walgermo/booki/pull/171) [`99d0d1c`](https://github.com/Walgermo/booki/commit/99d0d1c582b19048f88c2c2929b62825b2e9cc8b) Thanks [@Walgermo](https://github.com/Walgermo)! - `IconButton`: an icon button named by what it does. `label` is required ("Delete line 2"); it is the button's accessible name and tooltip, so an agent presses it by those words and a screen reader says them, and the icon is hidden. Pass any icon, such as `<TrashIcon />` from `@booki-aui/icons/react`; `showLabel` adds the label as visible text. It is ui-sdk's Button underneath, so `data-agent-confirm` and pending states work as on any button. Readiness now calls a nameless icon-only button that and points to `IconButton`, and flags a Booki icon shown at a size other than 16 or 20 px (minor, 1 point).
26
+
3
27
  ## 0.2.4
4
28
 
5
29
  ### Patch Changes
package/README.md CHANGED
@@ -158,7 +158,7 @@ The checks, with the section each enforces:
158
158
 
159
159
  | Id | § | Level | What it checks |
160
160
  | --- | --- | --- | --- |
161
- | `bridge-shape` | 2 | MUST | `snapshot`, `act` and `subscribe` are functions, and `snapshot` returns an array. |
161
+ | `bridge-shape` | 2 | MUST | `snapshot`, `act` and `subscribe` are functions, and `snapshot` returns an array with mounted controls. An empty array skips this check. |
162
162
  | `snapshot-named` | 3.1 | MUST | Every component has a `ref`, `component`, `label` and string `actions`; labels are unique. |
163
163
  | `snapshot-values` | 3.2 | MUST | Minor-unit values are integers or `null`; dates (and a date control's `value`) are `YYYY-MM-DD` or `null`, at every level, lists included. |
164
164
  | `snapshot-secrets` | 3.5 | MUST | The snapshot holds none of the literal `secrets` and no secret pattern (the same finder as the audit; amounts in minor units are not read as account numbers). |
@@ -174,7 +174,7 @@ The checks, with the section each enforces:
174
174
  Each check returns `pass`, `fail` or `skip`. A **skip** means the suite had no
175
175
  input for the check, not that the check passed: no `drive`, `closedList`,
176
176
  `server` or `secrets` option was given, or the bridge has no components to
177
- probe. `conforms` is `false` only when a MUST check fails. The report lists the
177
+ probe. `conforms` is `false` when a MUST check fails or the bridge has no mounted controls. An empty screen reports an incomplete check. The report lists the
178
178
  passes, failures and skips, so give every option you can.
179
179
 
180
180
  The suite does not yet cover the per-language refusals (spec 10.4) or the
@@ -211,8 +211,9 @@ Each check names the Agent Contract section it enforces.
211
211
  | Fields that share one name | §3.1, §4.1 | Two or more fields of one role with the same name (one finding per group): the agent has to count. | 2 / 8 |
212
212
  | Field missing from the bridge | §3.1, §4.1 | On a page whose bridge has a snapshot: a named field a person can use (textbox, searchbox, combobox, listbox, spinbutton, checkbox, radio group, switch, slider) that no bridge entry covers, so an agent on the bridge cannot operate it. A field is covered when its name equals an entry's `label`, or when it sits inside the element of a bridge component: ui-sdk marks a component's root with `data-slot="<component>"` and its other parts with `data-slot="<component>-<part>"`, so the outermost such element of each kind counts. When the page has more of those elements than the snapshot has entries of that kind, only one named by an entry's label counts. A radio is covered by its group's name and reported once, as the group. Disabled fields, fields inside `data-agent-hidden` and the hidden inputs above are skipped, and the check does not run when the snapshot was cut short (a `more` entry). | 5 / 30 |
213
213
  | Focusable element that is not a control | §3.1, §4.1 | An element with `tabindex` ≥ 0 that the tree calls a cell or plain text, such as a grid cell that opens an editor on click. | 3 / 12 |
214
- | Button without a name | §3.1, §4.1 | A button whose name is empty. | 3 / 12 |
214
+ | Button without a name | §3.1, §4.1 | A button whose name is empty. One that shows only an icon (an SVG, an image or an icon font) is called an icon-only button, and the report points to `IconButton` from `@booki-aui/react`, whose `label` is required. | 3 / 12 |
215
215
  | Button named by an icon font | §3.1, §4.1 | A button whose name is an icon ligature (`close`, `content_copy`, `more_vert`, any snake_case word), or any single lowercase word drawn in an icon font. | 2 / 10 |
216
+ | Icon at a size it is not drawn for | §3.1 | A Booki icon (`svg[data-icon]` from `@booki-aui/icons`) shown at a size other than 16 or 20 px, where its lines blur. It changes nothing an agent reads. | 1 / 3 |
216
217
  | Figures only in pixels | §3.3 | A canvas or SVG chart, visible to the agent, whose name, description, fallback content and the table in its figure hold fewer than two numbers. Icons (small, inside a button or link, or fewer than three shapes) and `aria-hidden` charts are skipped. | 10 / 30 |
217
218
  | Irreversible button without a gate | §5.2 | A button or link that posts, pays, sends, approves, creates, submits, releases or signs (Bokfør, Opprett, Godkjenn, Betal, Send, Attester, Signer, Overfør, Post, Pay, Approve, Submit, Release, Sign off, …) with no `data-agent-confirm` on it or an ancestor, and no `confirm` on its bridge button. | 10 / 20 |
218
219
  | Secret readable by the agent | §3.5 | A Norwegian account number (mod 11), an IBAN (mod 97), a KID next to the word KID (mod 10 or 11), a US routing number next to "routing" (ABA) or a card number next to "card"/"kort" (Luhn) in the accessibility snapshot or the bridge's snapshot. Only numbers with valid check digits count, so amounts, dates and invoice numbers do not. A value inside `data-agent-secret` on a page with a bridge is redacted by the bridge and not reported. | 8 / 16 |
@@ -112,6 +112,17 @@ var RULES = {
112
112
  points: 2,
113
113
  cap: 10
114
114
  },
115
+ "icon-size": {
116
+ id: "icon-size",
117
+ title: "Icon at a size it is not drawn for",
118
+ contract: "\xA73.1 (presentation)",
119
+ severity: "minor",
120
+ why: "Booki's icons are drawn for 16 and 20 px. In between, their lines fall between pixels and blur, so a status icon beside a figure reads as a smudge. It does not change what an agent reads, which is why it costs little.",
121
+ fix: "Show the icon at size={16} or size={20}, and let the button or row around it take the space.",
122
+ booki: "size={16 | 20} on any @booki-aui/icons component",
123
+ points: 1,
124
+ cap: 3
125
+ },
115
126
  "chart-pixels-only": {
116
127
  id: "chart-pixels-only",
117
128
  title: "Figures only in pixels",
@@ -351,6 +362,23 @@ function describeElement(element2) {
351
362
  );
352
363
  });
353
364
  };
365
+ const glyph = (el) => {
366
+ const family = getComputedStyle(el).fontFamily;
367
+ const classes = typeof el.className === "string" ? el.className : "";
368
+ return iconPattern.test(family) || /(^|\s)(material-(icons|symbols)[\w-]*|icon[\w-]*|[\w-]+-icon|fa|fa-[\w-]+|glyphicon[\w-]*)(\s|$)/i.test(classes);
369
+ };
370
+ const labelText = (el) => {
371
+ let text = "";
372
+ for (const node of el.childNodes) {
373
+ if (node.nodeType === 3) text += node.textContent ?? "";
374
+ else if (node.nodeType === 1) {
375
+ const child = node;
376
+ if (child.getAttribute("aria-hidden") === "true" || glyph(child)) continue;
377
+ text += labelText(child);
378
+ }
379
+ }
380
+ return text;
381
+ };
354
382
  const html = (el) => {
355
383
  const copy = el.cloneNode(true);
356
384
  const text = copy.outerHTML.replace(/\s+/g, " ");
@@ -382,6 +410,7 @@ function describeElement(element2) {
382
410
  confirm: confirmHost ? confirmHost.getAttribute("data-agent-confirm") || "(marked)" : null,
383
411
  secret: element2.closest("[data-agent-secret]") !== null,
384
412
  iconFont: usesIconFont(element2),
413
+ iconOnly: !clean(labelText(element2)) && (element2.querySelector("svg, img") !== null || usesIconFont(element2)),
385
414
  disabled: element2.disabled === true || element2.getAttribute("aria-disabled") === "true",
386
415
  hidden: hiddenFromPeople(element2)
387
416
  };
@@ -522,6 +551,18 @@ function bridgeCoverage(element2, entries) {
522
551
  group
523
552
  };
524
553
  }
554
+ function findOffSizeIcons() {
555
+ const drawn = [16, 20];
556
+ const out = [];
557
+ for (const svg of document.querySelectorAll("svg[data-icon]")) {
558
+ const box = svg.getBoundingClientRect();
559
+ if (box.width <= 1 || box.height <= 1) continue;
560
+ const size = Math.round(box.width * 10) / 10;
561
+ if (drawn.includes(size)) continue;
562
+ out.push({ name: svg.getAttribute("data-icon") ?? "", size, html: svg.outerHTML.slice(0, 160) });
563
+ }
564
+ return out;
565
+ }
525
566
  function findFocusableNonControls() {
526
567
  const native = "a[href], button, input, select, textarea, summary, details, iframe, audio, video, [contenteditable=''], [contenteditable=true]";
527
568
  const neutral = /* @__PURE__ */ new Set([
@@ -606,6 +647,7 @@ var DESCRIBE = inPage(describeElement);
606
647
  var READ_BRIDGE = inPage(readBridge);
607
648
  var FIND_FOCUSABLE = inPage(findFocusableNonControls);
608
649
  var FIND_CHARTS = inPage(findCharts);
650
+ var FIND_OFF_SIZE_ICONS = inPage(findOffSizeIcons);
609
651
  var ONLY_IN_SECRETS = inPage(onlyInSecrets);
610
652
  var BRIDGE_COVERAGE = inPage(bridgeCoverage);
611
653
  var BROKEN_NAME = /\[object \w+\]|\bundefined\b|\bnull\b|\bNaN\b/;
@@ -850,7 +892,12 @@ async function check(page, url = page.url()) {
850
892
  const name = node.name.trim();
851
893
  if (node.role === "button" && !name) {
852
894
  const info = await describe(page, node);
853
- findings.push({ rule: "button-unnamed", message: "A button with no name.", element: element(node, info) });
895
+ findings.push({
896
+ rule: "button-unnamed",
897
+ message: info?.iconOnly ? "An icon-only button with no name." : "A button with no name.",
898
+ element: element(node, info),
899
+ booki: info?.iconOnly ? 'IconButton from @booki-aui/react: label is required ("Delete line 2")' : void 0
900
+ });
854
901
  continue;
855
902
  }
856
903
  if (node.role !== "link") {
@@ -878,6 +925,13 @@ async function check(page, url = page.url()) {
878
925
  }
879
926
  }
880
927
  }
928
+ for (const icon of await page.evaluate(FIND_OFF_SIZE_ICONS)) {
929
+ findings.push({
930
+ rule: "icon-size",
931
+ message: `The "${icon.name}" icon is shown at ${icon.size} px; it is drawn for 16 and 20.`,
932
+ element: { role: "img", name: icon.name, html: icon.html }
933
+ });
934
+ }
881
935
  const charts = await page.evaluate(FIND_CHARTS);
882
936
  const chartLocator = page.locator("canvas, svg");
883
937
  for (const chart of charts) {
@@ -1019,8 +1073,10 @@ function toConsole(report) {
1019
1073
  out.push(
1020
1074
  `${sevMark(rule.severity)} ${bold(rule.title)} ${dim(`(${rule.contract}) \u2212${d.points}`)} \xD7${list.length}`
1021
1075
  );
1022
- for (const f of list.slice(0, 6))
1076
+ for (const f of list.slice(0, 6)) {
1023
1077
  out.push(` ${f.message}${f.element?.selector ? dim(` ${f.element.selector}`) : ""}`);
1078
+ if (f.booki && f.booki !== rule.booki) out.push(` ${dim("Booki:")} ${f.booki}`);
1079
+ }
1024
1080
  if (list.length > 6) out.push(dim(` \u2026 and ${list.length - 6} more`));
1025
1081
  out.push(` ${dim("Fix:")} ${rule.fix}`);
1026
1082
  if (rule.booki) out.push(` ${dim("Booki:")} ${rule.booki}`);
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  toConsole,
5
5
  toHtml,
6
6
  toJson
7
- } from "./chunk-ZQPEUBPL.js";
7
+ } from "./chunk-SCZED25V.js";
8
8
  import "./chunk-PRRNS5HS.js";
9
9
 
10
10
  // src/cli.ts
@@ -38,6 +38,7 @@ var checks = [
38
38
  if (missing.length > 0) return fail(`Missing functions: ${missing.join(", ")}.`);
39
39
  const snap = await target.bridge.snapshot();
40
40
  if (!Array.isArray(snap)) return fail("snapshot() must return an array of components.");
41
+ if (snap.length === 0) return skip("No mounted controls. Mount the screen before running conformance.");
41
42
  return pass(`snapshot, act and subscribe are functions; snapshot returns ${snap.length} components.`);
42
43
  }
43
44
  },
@@ -221,6 +222,7 @@ var checks = [
221
222
  level: "MUST",
222
223
  run: async (target) => {
223
224
  const snap = await components(target);
225
+ if (!snap.length) return skip("No mounted controls to check for person-only actions.");
224
226
  const offered = snap.flatMap((c) => c.actions.filter((a) => PERSON_ACTION.test(a)).map((a) => `${c.ref}.${a}`));
225
227
  if (offered.length > 0) {
226
228
  return fail(`An agent is offered person-only actions: ${offered.join(", ")}.`);
@@ -334,14 +336,16 @@ async function runConformance(target) {
334
336
  const passed = checks2.filter((c) => c.status === "pass").length;
335
337
  const failed = checks2.filter((c) => c.status === "fail").length;
336
338
  const skipped = checks2.filter((c) => c.status === "skip").length;
337
- const conforms = !checks2.some((c) => c.level === "MUST" && c.status === "fail");
339
+ const measured = checks2.find((c) => c.id === "bridge-shape")?.status === "pass";
340
+ const conforms = measured && !checks2.some((c) => c.level === "MUST" && c.status === "fail");
338
341
  return { contract: "0.1", checks: checks2, passed, failed, skipped, conforms };
339
342
  }
340
343
  function formatConformance(report) {
341
344
  const lines = report.checks.map((c) => `${c.status.toUpperCase()} \xA7${c.section} ${c.id} ${c.message}`);
342
- const verdict = report.conforms ? "Conforms" : "Does not conform";
345
+ const empty = report.checks.some((c) => c.id === "bridge-shape" && c.status === "skip");
346
+ const verdict = empty ? "Incomplete conformance check for" : report.conforms ? "Conforms to" : "Does not conform to";
343
347
  lines.push(
344
- `${verdict} to the Agent Contract ${report.contract}: ${report.passed} passed, ${report.failed} failed, ${report.skipped} skipped.`
348
+ `${verdict} the Agent Contract ${report.contract}: ${report.passed} passed, ${report.failed} failed, ${report.skipped} skipped.`
345
349
  );
346
350
  return lines.join("\n");
347
351
  }
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ type ElementInfo = {
18
18
  secret: boolean;
19
19
  /** The element or a descendant uses an icon font, by family or class. */
20
20
  iconFont: boolean;
21
+ /** The element shows only an icon (an svg, img or icon font) and no text of its own. */
22
+ iconOnly: boolean;
21
23
  disabled: boolean;
22
24
  /**
23
25
  * Out of reach of a person and an agent: aria-hidden or inert on it or an
@@ -32,7 +34,7 @@ type ElementInfo = {
32
34
  * enforces (spec/agent-contract.md), why it matters to an agent, the fix, and
33
35
  * how much it can take off the score.
34
36
  */
35
- type RuleId = "bridge-missing" | "bridge-unnamed-control" | "bridge-person-action" | "field-unnamed" | "field-broken-name" | "field-ambiguous" | "field-not-on-bridge" | "focusable-without-role" | "button-unnamed" | "button-icon-name" | "chart-pixels-only" | "irreversible-ungated" | "secret-visible" | "snapshot-size";
37
+ type RuleId = "bridge-missing" | "bridge-unnamed-control" | "bridge-person-action" | "field-unnamed" | "field-broken-name" | "field-ambiguous" | "field-not-on-bridge" | "focusable-without-role" | "button-unnamed" | "button-icon-name" | "icon-size" | "chart-pixels-only" | "irreversible-ungated" | "secret-visible" | "snapshot-size";
36
38
  type Severity = "critical" | "serious" | "moderate" | "minor";
37
39
  type Rule = {
38
40
  id: RuleId;
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  toConsole,
14
14
  toHtml,
15
15
  toJson
16
- } from "./chunk-ZQPEUBPL.js";
16
+ } from "./chunk-SCZED25V.js";
17
17
  import {
18
18
  PERSON_ACTION,
19
19
  findSecrets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@booki-aui/readiness",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
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",