@aarwitz/tapp 0.19.3 → 0.20.1

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.3",
4
+ "version": "0.20.1",
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.3",
27
+ "@aarwitz/tapp@0.20.1",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/bin/tapp.js CHANGED
@@ -138,8 +138,16 @@ function looksLikeCapture(value) {
138
138
  const raw = String(value || "").trim();
139
139
  if (!raw || raw.startsWith("-") || /^https?:\/\//i.test(raw)) return false;
140
140
  if (raw === "latest") return true;
141
- const marked = (dir) => { try { return fs.existsSync(path.join(dir, "ocqa-markers.txt")); } catch { return false; } };
142
- return marked(path.resolve(raw)) || marked(path.join(tappHome, "captures", raw));
141
+ // Markers, or a recording: a replayed Flow writes video and no markers, and reading it back is
142
+ // exactly what this is for.
143
+ const RECORDINGS = ["exploration.webm", "replay.webm", "exploration.mp4", "replay.mp4", "exploration.mov"];
144
+ const readable = (dir) => {
145
+ try {
146
+ if (fs.existsSync(path.join(dir, "ocqa-markers.txt"))) return true;
147
+ return RECORDINGS.some((name) => fs.existsSync(path.join(dir, name)));
148
+ } catch { return false; }
149
+ };
150
+ return readable(path.resolve(raw)) || readable(path.join(tappHome, "captures", raw));
143
151
  }
144
152
 
145
153
  function artifactKind(file) {
package/browser/app.js CHANGED
@@ -416,10 +416,13 @@ async function finishTranscript(name, job) {
416
416
  const files = await api(`/api/captures/${encodeURIComponent(id)}/files`);
417
417
  if (files.shots?.length) {
418
418
  pushLine({ kind: "shots", shots: files.shots.slice(0, 3).map((shot) => ({ src: captureUrl(id, shot.src), href: captureUrl(id, shot.src), caption: shot.caption })) });
419
- // The stage keeps the run's final screen until something newer replaces it.
420
- if (!state.live?.active) {
419
+ // The stage keeps the run's final screen until something newer replaces it — but only
420
+ // when the run never put a live frame there. Evidence screenshots are full-page, so a
421
+ // long marketing page becomes a tall sliver once it is fitted to the stage; the viewport
422
+ // frame the run was already showing is the better picture of where it ended.
423
+ const image = $("#live-frame-image");
424
+ if (!state.live?.active && !image.getAttribute("src")) {
421
425
  const last = files.shots.at(-1);
422
- const image = $("#live-frame-image");
423
426
  image.onload = () => { $("#live-frame-loading").classList.add("hidden"); $("#device-placeholder").classList.add("hidden"); };
424
427
  image.src = captureUrl(id, last.src);
425
428
  $("#live-screen-title").textContent = last.caption || "";
@@ -837,7 +837,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
837
837
  // Hand the page's screenshot to the progress channel: the Studio's device stage polls
838
838
  // the job's latest frame, and without this an audit watches an empty panel for its
839
839
  // whole run while the real screenshots sit in the capture.
840
- onPage: (page, n) => progress({ phase: "explore", text: `Audited ${page.url} — ${page.findings.length} finding(s)`, current: n, total: pages, ...(page.screenshot ? { screenshot: page.screenshot } : {}) }),
840
+ onPage: (page, n) => progress({ phase: "explore", text: `Audited ${page.url} — ${page.findings.length} finding(s)`, current: n, total: pages, ...(page.frame || page.screenshot ? { screenshot: page.frame || page.screenshot } : {}) }),
841
841
  });
842
842
  logUsage("audit.done", {
843
843
  visitor: (visitorId || "operator").slice(0, 8), host: safeHost(target.href),
@@ -29,13 +29,17 @@ export function resolveCapture(target = "") {
29
29
  try { entries = fs.readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory()); } catch { return null; }
30
30
  const newest = entries
31
31
  .map((e) => ({ dir: path.join(root, e.name), at: fs.statSync(path.join(root, e.name)).mtimeMs }))
32
- .sort((a, b) => b.at - a.at)[0];
32
+ .sort((a, b) => b.at - a.at)
33
+ .find(({ dir }) => fs.existsSync(path.join(dir, "ocqa-markers.txt")) || !!findRecording(dir));
33
34
  return newest ? newest.dir : null;
34
35
  }
36
+ // A replayed Flow records video but writes no markers, so "has markers" was too narrow a test
37
+ // and `look` refused to open the very recordings it exists to read.
38
+ const readable = (dir) => fs.existsSync(path.join(dir, "ocqa-markers.txt")) || !!findRecording(dir);
35
39
  const direct = path.resolve(value);
36
- if (fs.existsSync(path.join(direct, "ocqa-markers.txt"))) return direct;
40
+ if (readable(direct)) return direct;
37
41
  const byId = path.join(root, value);
38
- if (fs.existsSync(path.join(byId, "ocqa-markers.txt"))) return byId;
42
+ if (readable(byId)) return byId;
39
43
  return null;
40
44
  }
41
45
 
@@ -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
  }
@@ -260,11 +260,17 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
260
260
  // Where this page's screenshot landed, so a live viewer can show the page being audited
261
261
  // instead of an empty panel. Absolute, because that is what the progress channel forwards.
262
262
  let statePath = "";
263
+ let framePath = "";
263
264
  if (capture) {
264
265
  capture.states += 1;
265
266
  const stateName = `state_${capture.states}_${slug(target.pathname === "/" ? (controls.title || "home") : target.pathname)}.png`;
266
267
  statePath = path.join(capture.dir, stateName);
267
268
  await page.screenshot({ path: statePath, fullPage: true }).catch(() => page.screenshot({ path: statePath }).catch(() => {}));
269
+ // Evidence wants the whole page; a live viewer wants what a person would be looking at. A
270
+ // full-page shot of a long marketing page is a tall sliver once it is fitted into a
271
+ // device stage, so write a viewport-shaped frame alongside it for anything watching.
272
+ framePath = path.join(capture.dir, `frame_${capture.states}.png`);
273
+ await page.screenshot({ path: framePath }).catch(() => { framePath = statePath; });
268
274
  capture.emit("STATE", { screen, url: page.url(), elements: controls.controlCount, role: "page", controls: controls.dead.map((d) => d.label).filter(Boolean).slice(0, 40), inputs: [], settled: true, screenshot: stateName });
269
275
  for (const f of findings) {
270
276
  if (f.selector) {
@@ -290,6 +296,7 @@ async function auditOnePage(context, target, { timeoutMs, linkCheckLimit, captur
290
296
  ...(controls.wiringUnverifiable ? { wiringUnverifiable: controls.wiringUnverifiable } : {}),
291
297
  findings,
292
298
  ...(statePath ? { screenshot: statePath } : {}),
299
+ ...(framePath ? { frame: framePath } : {}),
293
300
  links: allowedLinks,
294
301
  };
295
302
  } finally {
@@ -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;
@@ -1097,8 +1162,9 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1097
1162
  // of the iOS dead-button detector). Navigations are undone so BFS order holds.
1098
1163
  const buttons = page.locator("button:visible, [role=button]:visible, input[type=submit]:visible, summary:visible");
1099
1164
  const buttonTotal = await buttons.count().catch(() => 0);
1100
- const n = Math.min(buttonTotal, BUTTONS_PER_PAGE);
1101
- 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;
1102
1168
  for (let i = 0; i < n && actions < maxActions && Date.now() < deadline; i++) {
1103
1169
  const b = buttons.nth(i);
1104
1170
  const label = webControlLabel({
@@ -1112,7 +1178,7 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1112
1178
  // Capture only durable, user-visible semantics around this control. A global
1113
1179
  // MutationObserver is intentionally avoided: carousels, chat launchers, and live
1114
1180
  // counters can mutate while an unrelated dead button is clicked, creating verdict jitter.
1115
- const beforeState = await captureWebControlState(page, b);
1181
+ let beforeState = await captureWebControlState(page, b);
1116
1182
  actions += 1;
1117
1183
  lastActionTarget = label;
1118
1184
  emitAction({ type: "tap", target: label, screen: webActionScreen(ob), narrative: `Tapped "${label}"` });
@@ -1123,6 +1189,32 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1123
1189
  clickSucceeded = true;
1124
1190
  } catch {}
1125
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);
1126
1218
  progress();
1127
1219
  continue;
1128
1220
  }
@@ -1176,7 +1268,20 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
1176
1268
  continue;
1177
1269
  }
1178
1270
  if (nav && typeof nav.status === "function" && nav.status() >= 400) {
1179
- 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);
1180
1285
  continue;
1181
1286
  }
1182
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.3",
3
+ "version": "0.20.1",
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",