@geonosis/walk 2.2.0 → 2.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/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # @geonosis/walk
2
2
 
3
- The customer walk as a gate. Nine computed-DOM probes over a list of URLs, one JSON report, and an
4
- exit code that tells a run that could not happen from a page that was clean.
3
+ Through the front door: `geonosis walk` — the metapackage pins this and every other kit tool at ONE
4
+ version, and passes the exit code through unchanged.
5
+
6
+ The customer walk as a gate. Thirteen computed-DOM probes over a list of URLs, one JSON report, and
7
+ an exit code that tells a run that could not happen from a page that was clean.
5
8
 
6
9
  It exists because a screenshot lies. A cream chip on a cream page photographs exactly like a chip
7
10
  that is there; thirteen copies of one placeholder SVG photograph as thirteen icons; a full product
@@ -23,7 +26,7 @@ npx geonosis-walk https://example.test/ https://example.test/products/x --report
23
26
  Two is why there are three. A tool that answered "no findings" for a browser it could not launch
24
27
  would pass hardest exactly when it was broken.
25
28
 
26
- ## The nine probes
29
+ ## The thirteen probes
27
30
 
28
31
  | id | What it reads | Needs |
29
32
  |---|---|---|
@@ -36,12 +39,21 @@ would pass hardest exactly when it was broken.
36
39
  | `ops-leakage` | The rendered text of a scope, against patterns that name internal choices. Scope is what separates a leak from a footnote. | **`patterns`** |
37
40
  | `buy-box-above-fold` | `getBoundingClientRect()` at the walk's viewport: the buy box below the element it must precede, or below the fold. | **`selector`** |
38
41
  | `error-page-status` | A page whose rendered text matches an error-surface pattern, served with a healthy status. Every curl-style health check, uptime monitor and load balancer reads such a page as fine. | **`patterns`** |
39
-
40
- The six in bold **refuse the run** when the option is missing, naming it (D-031). None of the six
41
- can have a default that is true of a repo which has not configured it — what a company can stand
42
- behind, which entities exist, what its signed-in header looks like, which words mean "operations",
43
- where its buy box is, what its error surface says — and a probe that ran with an empty list would
44
- report a clean page for every repo that never set one up.
42
+ | `thin-page` | The words a reader is actually shown in a scope, counted after layout, against a floor. A page with a heading, a layout and a 200 that answers nothing reads as fine to every other gate. | **`minWords`** |
43
+ | `empty-section` | A container carrying a heading and no body text and no media — a promise with nothing under it. | **`selector`** |
44
+ | `money-format` | Money-shaped strings in the page's text nodes, against the shapes this repo accepts. `£24` beside `£24.00` is two answers to what a price looks like here. | **`accept`** |
45
+ | `orphan-url` | Which walked URLs nothing in the walk links to. The one probe with a report-level half: `run` records each page's links, `finish` names the pages nothing pointed at. | nothing (`entry` lists the deliberately unlinked) |
46
+
47
+ The nine in bold **refuse the run** when the option is missing, naming it (D-031). None of them can
48
+ have a default that is true of a repo which has not configured it — what a company can stand behind,
49
+ which entities exist, what its signed-in header looks like, which words mean "operations", where its
50
+ buy box is, what its error surface says, how much a page owes a reader, which containers are
51
+ sections, what a price looks like — and a probe that ran with an empty list would report a clean
52
+ page for every repo that never set one up.
53
+
54
+ The last four are the `content-integrity` class: a page that renders correctly and says nothing.
55
+ Four defects of one audit were filed under `fabricated-claim`'s forbidden-string engine for want of
56
+ it, which is one class borrowing another's mechanism.
45
57
 
46
58
  ## Configuration
47
59
 
@@ -51,7 +51,9 @@ var inPage = (job) => {
51
51
  const box = element.getBoundingClientRect();
52
52
  return box.width > 0 && box.height > 0 && getComputedStyle(element).visibility !== "hidden";
53
53
  },
54
- textOf: (element) => element.innerText ?? element.textContent ?? ""
54
+ textOf: (element) => element.innerText ?? element.textContent ?? "",
55
+ /** How many words a reader is shown — the count `thin-page` and `empty-section` are about. */
56
+ wordsIn: (text) => text.split(/\s+/).filter((one) => one !== "").length
55
57
  };
56
58
  if (job.kind === "contrast") {
57
59
  const rgb = {
@@ -182,6 +184,39 @@ var inPage = (job) => {
182
184
  selector: dom.selectorOf(element)
183
185
  }));
184
186
  }
187
+ if (job.kind === "matches") {
188
+ const scope = job.scope === "" ? document.body : document.querySelector(job.scope);
189
+ const hits = [];
190
+ if (scope === null) return hits;
191
+ const walker = document.createTreeWalker(scope, 4);
192
+ let node = walker.nextNode();
193
+ while (node !== null) {
194
+ const parent = node.parentElement;
195
+ const text = node.nodeValue ?? "";
196
+ if (parent !== null && text.trim() !== "" && dom.shown(parent)) {
197
+ for (const pattern of job.patterns) {
198
+ const matcher = new RegExp(pattern, `${job.flags}g`);
199
+ let found = matcher.exec(text);
200
+ while (found !== null) {
201
+ const matched = found[0];
202
+ if (matched === "") break;
203
+ hits.push({ pattern, selector: dom.selectorOf(parent), text: matched });
204
+ found = matcher.exec(text);
205
+ }
206
+ }
207
+ }
208
+ node = walker.nextNode();
209
+ }
210
+ return hits;
211
+ }
212
+ if (job.kind === "prose") {
213
+ return [...document.querySelectorAll(job.selector)].filter((element) => dom.shown(element)).map((element) => ({
214
+ headingWords: [...element.querySelectorAll(job.headingSelector)].filter((heading) => dom.shown(heading)).reduce((total, heading) => total + dom.wordsIn(dom.textOf(heading)), 0),
215
+ media: [...element.querySelectorAll(job.mediaSelector)].filter((one) => dom.shown(one)).length,
216
+ selector: dom.selectorOf(element),
217
+ words: dom.wordsIn(dom.textOf(element))
218
+ }));
219
+ }
185
220
  if (job.kind === "present") {
186
221
  return job.selectors.map((selector) => ({
187
222
  present: document.querySelector(selector) !== null,
@@ -222,6 +257,13 @@ var requireStrings = (probe, options, name) => {
222
257
  }
223
258
  return value;
224
259
  };
260
+ var requireNumber = (probe, options, name) => {
261
+ const value = options[name];
262
+ if (typeof value !== "number" || !Number.isFinite(value)) {
263
+ throw new WalkError(`${probe}: needs a "${name}" number in the walk options`);
264
+ }
265
+ return value;
266
+ };
225
267
  var ALLOWED_FLAGS = /* @__PURE__ */ new Set(["i", "m", "s", "u"]);
226
268
  var patternFlags = (probe, options) => {
227
269
  const flags = stringOption(probe, options, "flags", "");
@@ -292,6 +334,41 @@ var buyBoxAboveFold = {
292
334
  }
293
335
  };
294
336
 
337
+ // src/probes/empty-section.ts
338
+ var emptySection = {
339
+ class: "content-integrity",
340
+ id: "empty-section",
341
+ needs: (options) => {
342
+ stringOption("empty-section", options, "selector");
343
+ },
344
+ run: async (page, { options, url }) => {
345
+ const headingSelector = stringOption(
346
+ "empty-section",
347
+ options,
348
+ "headingSelector",
349
+ "h1,h2,h3,h4,h5,h6"
350
+ );
351
+ const hits = await collect(page, {
352
+ headingSelector,
353
+ kind: "prose",
354
+ mediaSelector: stringOption(
355
+ "empty-section",
356
+ options,
357
+ "mediaSelector",
358
+ "img,svg,video,iframe,canvas"
359
+ ),
360
+ selector: stringOption("empty-section", options, "selector")
361
+ });
362
+ return hits.filter((hit) => hit.headingWords > 0 && hit.words <= hit.headingWords && hit.media === 0).map((hit) => ({
363
+ class: "content-integrity",
364
+ evidence: `the section renders ${hit.headingWords} heading word(s) and nothing else \u2014 no body text, no media`,
365
+ selector: hit.selector,
366
+ severity: "major",
367
+ url
368
+ }));
369
+ }
370
+ };
371
+
295
372
  // src/probes/error-page-status.ts
296
373
  var errorPageStatus = {
297
374
  class: "error-page-status",
@@ -467,6 +544,37 @@ var statusOf = async (page, memo, target) => {
467
544
  return status;
468
545
  };
469
546
 
547
+ // src/probes/money-format.ts
548
+ var AMOUNT = String.raw`\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{1,2})?`;
549
+ var MONEY = String.raw`[€$£¥₺]\s?${AMOUNT}|${AMOUNT}\s?(?:USD|EUR|GBP|TRY|JPY)\b`;
550
+ var moneyFormat = {
551
+ class: "content-integrity",
552
+ id: "money-format",
553
+ needs: (options) => {
554
+ const accept = requireStrings("money-format", options, "accept");
555
+ assertPatterns("money-format", accept, patternFlags("money-format", options));
556
+ },
557
+ run: async (page, { options, url }) => {
558
+ const flags = patternFlags("money-format", options);
559
+ const accept = requireStrings("money-format", options, "accept").map(
560
+ (pattern) => new RegExp(`^(?:${pattern})$`, flags)
561
+ );
562
+ const hits = await collect(page, {
563
+ flags,
564
+ kind: "matches",
565
+ patterns: [stringOption("money-format", options, "find", MONEY)],
566
+ scope: stringOption("money-format", options, "scope", "")
567
+ });
568
+ return hits.filter((hit) => !accept.some((one) => one.test(hit.text.trim()))).map((hit) => ({
569
+ class: "content-integrity",
570
+ evidence: `"${hit.text}" is money in a shape this repo does not accept`,
571
+ selector: hit.selector,
572
+ severity: "major",
573
+ url
574
+ }));
575
+ }
576
+ };
577
+
470
578
  // src/probes/ops-leakage.ts
471
579
  var opsLeakage = {
472
580
  class: "ops-leakage",
@@ -492,6 +600,52 @@ var opsLeakage = {
492
600
  }
493
601
  };
494
602
 
603
+ // src/probes/orphan-url.ts
604
+ var MEMO = "orphan-url:linked";
605
+ var linkedIn = (memo) => {
606
+ const seen = memo.get(MEMO);
607
+ if (seen instanceof Set) return seen;
608
+ const fresh = /* @__PURE__ */ new Set();
609
+ memo.set(MEMO, fresh);
610
+ return fresh;
611
+ };
612
+ var bare = (url) => {
613
+ try {
614
+ const parsed = new URL(url);
615
+ return `${parsed.origin}${parsed.pathname.replace(/\/index\.html?$/, "/")}`;
616
+ } catch {
617
+ return url;
618
+ }
619
+ };
620
+ var orphanUrl = {
621
+ class: "content-integrity",
622
+ finish: ({ memo, options, urls }) => {
623
+ if (urls.length < 2) return [];
624
+ const linked = linkedIn(memo);
625
+ const entry = stringsOption(options, "entry", []).map(bare);
626
+ return urls.filter((url) => !linked.has(bare(url)) && !entry.includes(bare(url))).map((url) => ({
627
+ class: "content-integrity",
628
+ evidence: `no page in this walk links to ${bare(url)} \u2014 it is reachable only by being handed the URL`,
629
+ severity: "major",
630
+ url
631
+ }));
632
+ },
633
+ id: "orphan-url",
634
+ run: async (page, { memo, options, url }) => {
635
+ const linked = linkedIn(memo);
636
+ const here = bare(url);
637
+ for (const hit of await collect(page, {
638
+ kind: "links",
639
+ selector: stringOption("orphan-url", options, "selector", 'a,[role="link"]')
640
+ })) {
641
+ if (hit.resolved === "") continue;
642
+ const target = bare(hit.resolved);
643
+ if (target !== here) linked.add(target);
644
+ }
645
+ return [];
646
+ }
647
+ };
648
+
495
649
  // src/probes/placeholder-asset.ts
496
650
  var placeholderAsset = {
497
651
  class: "placeholder-asset",
@@ -558,17 +712,52 @@ var stubOnlyEntity = {
558
712
  }
559
713
  };
560
714
 
715
+ // src/probes/thin-page.ts
716
+ var thinPage = {
717
+ class: "content-integrity",
718
+ id: "thin-page",
719
+ needs: (options) => {
720
+ requireNumber("thin-page", options, "minWords");
721
+ },
722
+ run: async (page, { options, url }) => {
723
+ const minWords = requireNumber("thin-page", options, "minWords");
724
+ const scope = stringOption("thin-page", options, "scope", "body");
725
+ const hits = await collect(page, {
726
+ headingSelector: stringOption("thin-page", options, "headingSelector", "h1,h2,h3,h4,h5,h6"),
727
+ kind: "prose",
728
+ mediaSelector: stringOption(
729
+ "thin-page",
730
+ options,
731
+ "mediaSelector",
732
+ "img,svg,video,iframe,canvas"
733
+ ),
734
+ selector: scope
735
+ });
736
+ return hits.filter((hit) => hit.words < minWords).map((hit) => ({
737
+ class: "content-integrity",
738
+ evidence: `${scope} renders ${hit.words} word(s), ${hit.headingWords} of them headings \u2014 the floor is ${minWords}`,
739
+ ...hit.selector === "" ? {} : { selector: hit.selector },
740
+ severity: "major",
741
+ url
742
+ }));
743
+ }
744
+ };
745
+
561
746
  // src/probes/index.ts
562
747
  var PROBES = [
563
748
  buyBoxAboveFold,
749
+ emptySection,
564
750
  errorPageStatus,
565
751
  fabricatedClaim,
566
752
  fakeSession,
567
753
  lightOnLight,
568
754
  linkIntegrity,
755
+ moneyFormat,
569
756
  opsLeakage,
757
+ orphanUrl,
570
758
  placeholderAsset,
571
- stubOnlyEntity
759
+ stubOnlyEntity,
760
+ thinPage
572
761
  ];
573
762
  var probeById = (id) => {
574
763
  const probe = PROBES.find((one) => one.id === id);
@@ -726,6 +915,13 @@ var walk = async ({
726
915
  } finally {
727
916
  if (browser === void 0) await own.close();
728
917
  }
918
+ for (const probe of probes) {
919
+ for (const finding of probe.finish?.({ memo, options: options[probe.id] ?? {}, urls }) ?? []) {
920
+ const page = pages.find((one) => one.url === finding.url);
921
+ if (page === void 0) pages.push({ findings: [finding], url: finding.url });
922
+ else page.findings.push(finding);
923
+ }
924
+ }
729
925
  const counts = {};
730
926
  for (const probe of probes) counts[probe.class] = 0;
731
927
  for (const page of pages) {
package/dist/index.d.ts CHANGED
@@ -1,17 +1,21 @@
1
1
  import { Page, Browser } from 'playwright';
2
2
 
3
3
  /**
4
- * The nine defect classes the walk is mechanical about.
4
+ * The ten defect classes the walk is mechanical about.
5
5
  *
6
6
  * Six are a storefront CX audit's own groups, generalised; `light-on-light` is that audit's
7
7
  * browser-proof probe (a cream chip on a cream page reads as broken, and the screenshot says it is
8
8
  * fine), `buy-box-above-fold` is one of its groups promoted to a class, and `error-page-status`
9
- * came from an error surface served with a 200, which every health check read as healthy. What the nine do NOT cover — a number that disagrees with a number on another page, copy
9
+ * came from an error surface served with a 200, which every health check read as healthy.
10
+ * `content-integrity` is the tenth: a page that renders correctly and says nothing — a section with
11
+ * a heading and no body, a price in a shape the repo does not write, a page nothing links to. Four
12
+ * of an audit's own defects were filed under `fabricated-claim`'s forbidden-string engine for want
13
+ * of it, which is a class borrowing another class's mechanism. What the ten do NOT cover — a number that disagrees with a number on another page, copy
10
14
  * that promises a control nobody built, four levels of taxonomy for fourteen products — is in
11
15
  * `docs/walk-review-inventory-2026-08-30.md`, and stays the walker's judgement. A green walk report
12
16
  * is not a clean surface.
13
17
  */
14
- type DefectClass = 'buy-box-above-fold' | 'error-page-status' | 'fabricated-claim' | 'fake-session' | 'light-on-light' | 'link-integrity' | 'ops-leakage' | 'placeholder-asset' | 'stub-only-entity';
18
+ type DefectClass = 'buy-box-above-fold' | 'content-integrity' | 'error-page-status' | 'fabricated-claim' | 'fake-session' | 'light-on-light' | 'link-integrity' | 'ops-leakage' | 'placeholder-asset' | 'stub-only-entity';
15
19
  /** `blocking` breaks trust or the buy path; `major` confuses the buyer; `minor` is polish. */
16
20
  type Severity = 'blocking' | 'major' | 'minor';
17
21
  /**
@@ -60,6 +64,19 @@ type Probe = {
60
64
  */
61
65
  needs?: (options: Record<string, unknown>) => void;
62
66
  run: (page: Page, context: ProbeContext) => Promise<Finding[]>;
67
+ /**
68
+ * The reading no single page can make. `orphan-url` is the reason it exists: whether anything
69
+ * links to a page is a fact about the whole walk, and a probe handed one page at a time can only
70
+ * record what it saw. Called once, after every page, with the pages walked; each finding is filed
71
+ * against the page whose `url` it names.
72
+ */
73
+ finish?: (context: FinishContext) => Finding[];
74
+ };
75
+ /** What a probe knows once the walk is over: its own memo, its options, and where it went. */
76
+ type FinishContext = {
77
+ memo: Map<string, unknown>;
78
+ options: Record<string, unknown>;
79
+ urls: string[];
63
80
  };
64
81
  type PageReport = {
65
82
  findings: Finding[];
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  parseViewport,
11
11
  probeById,
12
12
  walk
13
- } from "./chunk-KB2R6USR.js";
13
+ } from "./chunk-VCGYSFL5.js";
14
14
  export {
15
15
  DEFAULT_PROBES,
16
16
  PROBES,
package/dist/walk-cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ PROBES,
2
3
  WalkError,
3
4
  configPath,
4
5
  configShape,
@@ -7,7 +8,7 @@ import {
7
8
  parseViewport,
8
9
  probeById,
9
10
  walk
10
- } from "./chunk-KB2R6USR.js";
11
+ } from "./chunk-VCGYSFL5.js";
11
12
 
12
13
  // src/walk-cli.ts
13
14
  import { mkdirSync, writeFileSync } from "fs";
@@ -49,11 +50,16 @@ not run. The report is written for 0 and 1, and never for 2 \u2014 a tool that r
49
50
  for a browser it could not launch would pass hardest exactly when it is broken.`;
50
51
  var line = (finding) => `${finding.severity} ${finding.class} ${finding.url}${finding.selector === void 0 ? "" : ` ${finding.selector}`}
51
52
  ${finding.evidence}`;
53
+ var denominator = (report) => {
54
+ const ran = new Set(report.probes);
55
+ const silent = PROBES.filter((probe) => !ran.has(probe.id)).map((probe) => probe.id);
56
+ return `${ran.size} of ${PROBES.length} probe(s) ran${silent.length === 0 ? "" : ` \u2014 never looked for: ${silent.join(", ")}`}`;
57
+ };
52
58
  var summarise = (report) => [
53
59
  ...report.pages.flatMap((page) => page.findings.map(line)),
54
60
  "",
55
61
  ...Object.entries(report.counts).map(([name, count]) => `${count} ${name}`),
56
- `${report.pages.length} page(s), ${findingsIn(report)} finding(s)`
62
+ `${report.pages.length} page(s), ${findingsIn(report)} finding(s), ${denominator(report)}`
57
63
  ].join("\n");
58
64
  var main = async () => {
59
65
  const args = process.argv.slice(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geonosis/walk",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "description": "The customer walk as a gate: eight computed-DOM probes over a list of URLs, one JSON report, and an exit code that tells a could-not-run from a clean page.",
6
6
  "keywords": [