@aarwitz/tapp 0.19.2 → 0.20.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tapp",
3
3
  "description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
4
- "version": "0.19.2",
4
+ "version": "0.20.0",
5
5
  "author": {
6
6
  "name": "Aaron Horowitz",
7
7
  "url": "https://github.com/aarwitz"
@@ -24,7 +24,7 @@
24
24
  "command": "npx",
25
25
  "args": [
26
26
  "-y",
27
- "@aarwitz/tapp@0.19.2",
27
+ "@aarwitz/tapp@0.20.0",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
@@ -98,6 +98,11 @@ export const ISSUE_CATEGORY = {
98
98
  unresolvable_host: "broken_link",
99
99
  mailto_no_mx: "broken_link",
100
100
  outbound_unavailable: "broken_link",
101
+ // Not a broken link: a third party refusing an automated browser. Kept in the taxonomy so it
102
+ // is reported and counted, but never as something that is known to be broken.
103
+ link_unverifiable: "broken_link",
104
+ // A control that could not be reached to be tested: a coverage hole, stated rather than hidden.
105
+ control_unprobed: "unresponsive_element",
101
106
  dead_end: "navigation_dead_end",
102
107
  navigation_loop: "repeated_loop",
103
108
  navigation_trap: "navigation_dead_end",
@@ -246,7 +251,10 @@ export function buildQaReport(markersFilePath, { platform = "ios", target = null
246
251
  } else if (t.startsWith("OCQA_STATE:{")) {
247
252
  try {
248
253
  const s = JSON.parse(t.slice("OCQA_STATE:".length));
249
- if (typeof s.screen === "string" && s.screen.trim()) screens.add(s.screen);
254
+ // Coverage counts distinct observed states, not distinct headings: a modal, a drawer and
255
+ // the page behind them share a heading but are three different things to have reached.
256
+ // The signature is only present on captures recorded by a build that emits it.
257
+ if (typeof s.screen === "string" && s.screen.trim()) screens.add(s.signature ? `${s.screen}::${s.signature}` : s.screen);
250
258
  if (typeof s.screen === "string" && s.screen.trim() && Number.isFinite(s.elements)) {
251
259
  screenElementCounts[s.screen] = Math.max(screenElementCounts[s.screen] || 0, s.elements);
252
260
  }
@@ -22,7 +22,17 @@ import { execFileSync } from "child_process";
22
22
 
23
23
  const CLICK_SETTLE_MS = 700;
24
24
  export const NAV_TIMEOUT_MS = 15_000;
25
- const BUTTONS_PER_PAGE = 4;
25
+ // How many of a page's buttons get the dead-control probe. Four was a flat cap regardless of the
26
+ // budget asked for, so `--actions 60` still examined four buttons on a page with fifteen and
27
+ // returned having barely looked. The probe is the expensive part of a run — each click has to be
28
+ // observed and any navigation undone — so it still has a ceiling, but a larger budget now buys a
29
+ // deeper look instead of being left on the table.
30
+ const BUTTONS_PER_PAGE_MIN = 4;
31
+ const BUTTONS_PER_PAGE_MAX = 12;
32
+ export function webButtonsPerPage(maxActions = 40) {
33
+ const budgeted = Math.ceil(Number(maxActions) / 6);
34
+ return Math.max(BUTTONS_PER_PAGE_MIN, Math.min(BUTTONS_PER_PAGE_MAX, budgeted));
35
+ }
26
36
  const OUTBOUND_LINK_LIMIT = 10;
27
37
  const WATCH_ACTION_DELAY_MS = 350;
28
38
  // A page's visible signature (waitForWebStability's basis) can go quiet before an async-injected
@@ -337,6 +347,48 @@ export async function submitWebLogin(page, beforeClick = null) {
337
347
  return false;
338
348
  }
339
349
 
350
+ // How many distinct in-page states one URL may contribute before we stop splitting it. A
351
+ // carousel, a live counter or a shuffling feed would otherwise mint states forever; past the cap
352
+ // the route collapses to its heading, which is the behaviour this replaced.
353
+ export const MAX_STATES_PER_ROUTE = 8;
354
+
355
+ /**
356
+ * What is on screen right now, as a stable digest.
357
+ *
358
+ * A screen used to be identified by its heading, else its title, else its URL — so opening a
359
+ * modal, a drawer, a tab or an accordion, none of which change the heading, left tapp looking at
360
+ * "the same screen". The frontier gained nothing, exploration drained early, coverage undercounted,
361
+ * and the recording showed one near-identical frame for the whole run.
362
+ *
363
+ * The digest is over the *identities of visible controls and fields*, sorted and deduped, so it
364
+ * does not move when text reflows, a counter ticks, or the same controls are painted in a
365
+ * different order. Content that is merely text is deliberately ignored: it changes constantly on
366
+ * real sites and says nothing about what can be done here.
367
+ */
368
+ export function webStateSignature(info) {
369
+ const parts = [];
370
+ for (const control of info?.controls || []) {
371
+ const label = String(control?.label || "").replace(/\s+/g, " ").trim().toLowerCase().slice(0, 60);
372
+ const id = String(control?.id || control?.cssId || control?.testId || "").trim().toLowerCase().slice(0, 60);
373
+ if (label || id) parts.push(`${control?.kind || "control"}:${id || label}`);
374
+ }
375
+ for (const field of info?.inputs || []) {
376
+ const name = String(field?.id || field?.name || field?.label || field?.placeholder || "").trim().toLowerCase().slice(0, 60);
377
+ if (name) parts.push(`field:${name}`);
378
+ }
379
+ if (!parts.length) return "";
380
+ const unique = [...new Set(parts)].sort();
381
+ // Short, stable, and not a language runtime's hash — those differ across versions.
382
+ let h1 = 0x811c9dc5;
383
+ let h2 = 0x01000193;
384
+ const text = unique.join("|");
385
+ for (let i = 0; i < text.length; i += 1) {
386
+ h1 = Math.imul(h1 ^ text.charCodeAt(i), 0x01000193) >>> 0;
387
+ h2 = Math.imul(h2 + text.charCodeAt(i) + 1, 0x85ebca6b) >>> 0;
388
+ }
389
+ return `${h1.toString(36)}${h2.toString(36)}`.slice(0, 12);
390
+ }
391
+
340
392
  export function webScreenTitle(info, fallback) {
341
393
  return String(info?.heading || info?.title || fallback || "").trim();
342
394
  }
@@ -752,6 +804,9 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
752
804
  let probeCapHit = false;
753
805
  let actions = 0;
754
806
  let screenCount = 0;
807
+ // Which distinct on-screen states each route has produced, so one route cannot mint states
808
+ // without limit when something on it never settles.
809
+ const signaturesByRoute = new Map();
755
810
  let lastScreen = null;
756
811
  let pendingNavigation = null;
757
812
  let loginTried = false;
@@ -859,9 +914,19 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
859
914
 
860
915
  const key = screenKey();
861
916
  const screen = webScreenTitle(info, key);
862
- const evidenceKey = `${key}::${screen}`;
917
+ // A modal, drawer, tab or wizard step rarely changes the heading, so identity also carries
918
+ // what is on screen. Past MAX_STATES_PER_ROUTE distinct signatures a route stops splitting:
919
+ // something on it is non-deterministic and would otherwise mint states forever.
920
+ const signature = webStateSignature(info);
921
+ const seenHere = signaturesByRoute.get(key) || new Set();
922
+ if (signature && seenHere.size < MAX_STATES_PER_ROUTE) {
923
+ seenHere.add(signature);
924
+ signaturesByRoute.set(key, seenHere);
925
+ }
926
+ const splitting = signature && (seenHere.has(signature) || seenHere.size < MAX_STATES_PER_ROUTE);
927
+ const evidenceKey = splitting ? `${key}::${screen}::${signature}` : `${key}::${screen}`;
863
928
  currentScreen = screen;
864
- emit("STATE", { t: Date.now() - startedAtMs, screen, url: key, elements: info.controlCount, role: webScreenRole(screen, info.inputs), controls: info.controls, inputs: info.inputs, settled: !info.busy });
929
+ emit("STATE", { t: Date.now() - startedAtMs, screen, url: key, ...(signature ? { signature } : {}), elements: info.controlCount, role: webScreenRole(screen, info.inputs), controls: info.controls, inputs: info.inputs, settled: !info.busy });
865
930
  const completedNavigation = pendingNavigation;
866
931
  const transitionFrom = webTransitionOrigin(completedNavigation, lastScreen);
867
932
  const transitionAction = completedNavigation?.action || lastActionTarget;
@@ -1078,7 +1143,11 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1078
1143
  const u = new URL(link.href);
1079
1144
  if (!/^https?:$/.test(u.protocol)) continue;
1080
1145
  if (u.origin !== start.origin) {
1081
- const clean = u.origin + u.pathname;
1146
+ // Keep the query: for a great many links the query *is* the resource
1147
+ // (`/items?itemName=…`, `/search?q=…`, store and marketplace pages), and checking
1148
+ // the path alone reports a confident 404 for a link that works. Only the fragment
1149
+ // is dropped, since it names a place within an already-fetched page.
1150
+ const clean = u.origin + u.pathname + u.search;
1082
1151
  if (!outboundLinks.has(clean)) outboundLinks.set(clean, { label: link.label, screen: ob.screen, sourceUrl: start.origin + ob.key });
1083
1152
  continue;
1084
1153
  }
@@ -1093,8 +1162,9 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1093
1162
  // of the iOS dead-button detector). Navigations are undone so BFS order holds.
1094
1163
  const buttons = page.locator("button:visible, [role=button]:visible, input[type=submit]:visible, summary:visible");
1095
1164
  const buttonTotal = await buttons.count().catch(() => 0);
1096
- const n = Math.min(buttonTotal, BUTTONS_PER_PAGE);
1097
- if (buttonTotal > BUTTONS_PER_PAGE) probeCapHit = true;
1165
+ const buttonsPerPage = webButtonsPerPage(maxActions);
1166
+ const n = Math.min(buttonTotal, buttonsPerPage);
1167
+ if (buttonTotal > buttonsPerPage) probeCapHit = true;
1098
1168
  for (let i = 0; i < n && actions < maxActions && Date.now() < deadline; i++) {
1099
1169
  const b = buttons.nth(i);
1100
1170
  const label = webControlLabel({
@@ -1108,7 +1178,7 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1108
1178
  // Capture only durable, user-visible semantics around this control. A global
1109
1179
  // MutationObserver is intentionally avoided: carousels, chat launchers, and live
1110
1180
  // counters can mutate while an unrelated dead button is clicked, creating verdict jitter.
1111
- const beforeState = await captureWebControlState(page, b);
1181
+ let beforeState = await captureWebControlState(page, b);
1112
1182
  actions += 1;
1113
1183
  lastActionTarget = label;
1114
1184
  emitAction({ type: "tap", target: label, screen: webActionScreen(ob), narrative: `Tapped "${label}"` });
@@ -1119,6 +1189,32 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1119
1189
  clickSucceeded = true;
1120
1190
  } catch {}
1121
1191
  if (!clickSucceeded) {
1192
+ // Something is covering this control — almost always a modal, drawer or cookie banner
1193
+ // opened by a button probed moments ago. Every remaining control on the page used to
1194
+ // be clicked into that overlay and silently skipped, so a page with a modal reported
1195
+ // no dead controls at all however many it had. Clear the overlay and try once more.
1196
+ await page.keyboard.press("Escape").catch(() => {});
1197
+ await waitForWebStability(page);
1198
+ try {
1199
+ await b.click({ timeout: 2000 });
1200
+ clickSucceeded = true;
1201
+ } catch {
1202
+ // Escape did not dismiss it. Reloading is the reliable reset, and the BFS frontier
1203
+ // is keyed by route rather than by page object, so it stays valid.
1204
+ await page.goto(beforeState.url, { waitUntil: "domcontentloaded" }).catch(() => {});
1205
+ await waitForWebStability(page);
1206
+ // The reload is itself a change, so the pre-reload snapshot would make any control
1207
+ // look like it did something. Judge this click against the page as it is now.
1208
+ beforeState = await captureWebControlState(page, b);
1209
+ try {
1210
+ await b.click({ timeout: 2000 });
1211
+ clickSucceeded = true;
1212
+ } catch {}
1213
+ }
1214
+ }
1215
+ if (!clickSucceeded) {
1216
+ // Say so rather than leaving a silent hole in the coverage.
1217
+ issue("control_unprobed", "low", `Control "${label}" could not be clicked — something kept covering it`, ob.screen, label);
1122
1218
  progress();
1123
1219
  continue;
1124
1220
  }
@@ -1172,7 +1268,20 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1172
1268
  continue;
1173
1269
  }
1174
1270
  if (nav && typeof nav.status === "function" && nav.status() >= 400) {
1175
- issue("broken_link", "medium", `Outbound link returns HTTP ${nav.status()}: ${href.slice(0, 100)}`, meta.screen, href, meta.sourceUrl);
1271
+ const status = nav.status();
1272
+ // 401/403/429 from a third party is almost always its bot defence answering an
1273
+ // automated browser, not a link that is broken for the people who click it. npm,
1274
+ // LinkedIn, Instagram and Cloudflare-fronted sites all do this. Reporting it as a
1275
+ // broken link is a false positive that teaches people to distrust the real ones, so
1276
+ // say what was actually observed and leave the judgement to a human.
1277
+ const botDefence = status === 401 || status === 403 || status === 429;
1278
+ if (botDefence) {
1279
+ issue("link_unverifiable", "low",
1280
+ `Outbound link could not be verified — ${new URL(href).hostname} answered HTTP ${status} to an automated browser (usually bot protection, not a broken link): ${href.slice(0, 100)}`,
1281
+ meta.screen, href, meta.sourceUrl);
1282
+ continue;
1283
+ }
1284
+ issue("broken_link", "medium", `Outbound link returns HTTP ${status}: ${href.slice(0, 100)}`, meta.screen, href, meta.sourceUrl);
1176
1285
  continue;
1177
1286
  }
1178
1287
  await auditPage.waitForTimeout(400); // let client-rendered shells paint their copy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.19.2",
3
+ "version": "0.20.0",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
6
6
  "license": "MIT",