@aarwitz/tapp 0.17.26 → 0.18.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/.claude-plugin/plugin.json +2 -2
- package/AGENTS.md +43 -44
- package/README.md +32 -42
- package/bin/tapp.js +168 -99
- package/browser/app.css +220 -208
- package/browser/app.js +173 -20
- package/browser/index.html +118 -57
- package/browser/tokens.css +33 -25
- package/docs/BROWSER-PRODUCT.md +16 -8
- package/docs/BUSINESS-WORKFLOWS.md +134 -0
- package/docs/PRODUCT-ENGINE.md +5 -0
- package/mcp-server/src/browser-product.js +15 -3
- package/mcp-server/src/business-observation.d.ts +2 -0
- package/mcp-server/src/business-observation.js +25 -0
- package/mcp-server/src/business-workflow-files.js +36 -0
- package/mcp-server/src/business-workflow-runtime.js +47 -0
- package/mcp-server/src/business-workflows.d.ts +50 -0
- package/mcp-server/src/business-workflows.js +169 -0
- package/mcp-server/src/environment-capabilities.d.ts +16 -0
- package/mcp-server/src/environment-capabilities.js +78 -0
- package/mcp-server/src/index.js +546 -794
- package/mcp-server/src/product-operations.js +3 -1
- package/mcp-server/src/public-network.js +65 -0
- package/mcp-server/src/web-audit.js +131 -20
- package/mcp-server/src/web-explorer.js +119 -23
- package/mcp-server/src/web-flow.js +17 -4
- package/package.json +7 -1
- package/scripts/run-web-flow.js +4 -0
- package/skills/tapp/SKILL.md +14 -13
- package/skills/tapp/references/commands.md +73 -57
|
@@ -144,15 +144,22 @@ export async function installWebListenerTracking(context) {
|
|
|
144
144
|
// button works. Keep their source text: it is the only way to tell which
|
|
145
145
|
// controls such a handler actually claims.
|
|
146
146
|
const delegatedKey = Symbol.for("tapp.delegatedClickHandlers");
|
|
147
|
+
// How many click handlers the page attached anywhere: zero means its scripts have not run
|
|
148
|
+
// (deferred hydration), and "nothing is listening on this button" says nothing about the button.
|
|
149
|
+
const countKey = Symbol.for("tapp.clickListenerCount");
|
|
150
|
+
window[countKey] = 0;
|
|
147
151
|
const add = EventTarget.prototype.addEventListener;
|
|
148
152
|
const remove = EventTarget.prototype.removeEventListener;
|
|
149
153
|
EventTarget.prototype.addEventListener = function tappTrackedAdd(type, listener, options) {
|
|
154
|
+
if (type === "click" && listener) window[countKey] += 1;
|
|
150
155
|
if (type === "click" && this instanceof Element && listener) {
|
|
151
156
|
if (!this[key]) Object.defineProperty(this, key, { value: new Set(), configurable: true });
|
|
152
157
|
this[key].add(listener);
|
|
153
158
|
}
|
|
154
|
-
|
|
155
|
-
|
|
159
|
+
// Delegation targets: document, window, and the two elements a site-wide handler sits on.
|
|
160
|
+
const global = this === document || this === window || (document.body && this === document.body) || this === document.documentElement;
|
|
161
|
+
if (type === "click" && listener && global) {
|
|
162
|
+
const target = this === window ? window : this === document ? document : this;
|
|
156
163
|
if (!target[delegatedKey]) Object.defineProperty(target, delegatedKey, { value: new Set(), configurable: true });
|
|
157
164
|
try { target[delegatedKey].add(String(listener).slice(0, 4000)); } catch { /* exotic handler */ }
|
|
158
165
|
}
|
|
@@ -659,7 +666,16 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
659
666
|
const markersFd = fs.openSync(markersPath, "w");
|
|
660
667
|
const emit = (kind, payload) => fs.writeSync(markersFd, `OCQA_${kind}:${JSON.stringify(payload)}\n`);
|
|
661
668
|
const startedAtMs = Date.now();
|
|
662
|
-
const emitAction = (payload) =>
|
|
669
|
+
const emitAction = (payload) => {
|
|
670
|
+
emit("ACTION", { t: Date.now() - startedAtMs, ...payload });
|
|
671
|
+
narrate(payload.narrative || `${payload.type} ${payload.target}`, { screen: payload.screen });
|
|
672
|
+
};
|
|
673
|
+
// Live narration for hosts that render a transcript (Studio chat). Counts stay on the
|
|
674
|
+
// regular progress tick; this carries what the action was and, on a new state, its screenshot.
|
|
675
|
+
const narrate = (narrative, extra = {}) => {
|
|
676
|
+
if (!onProgress) return;
|
|
677
|
+
try { onProgress({ action: actions, max: maxActions, states: screenCount, narrative, ...extra }); } catch {}
|
|
678
|
+
};
|
|
663
679
|
|
|
664
680
|
const { chromium, devices } = await loadPlaywright();
|
|
665
681
|
const browser = await chromium.launch(webBrowserLaunchOptions(process.env, { watch }));
|
|
@@ -862,6 +878,7 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
862
878
|
screenshotFor.set(evidenceKey, { path: screenshotPath, busy: info.busy, route: key });
|
|
863
879
|
screenCount = screenshotFor.size;
|
|
864
880
|
await screenshotWithoutWebWatchUi(page, { path: screenshotPath }, watch).catch(() => {});
|
|
881
|
+
narrate(existingScreenshot ? `Settled on ${screen}` : `Reached ${screen}`, { screen, screenshot: screenshotPath });
|
|
865
882
|
// Deterministic per-page detectors run once per distinct screen.
|
|
866
883
|
if (webPageAppearsBlank(info)) issue("blank_screen", "high", "Page rendered no visible content", screen);
|
|
867
884
|
else {
|
|
@@ -1208,7 +1225,10 @@ export async function exploreWeb({ url, maxActions = 40, timeoutSec = 300, outDi
|
|
|
1208
1225
|
export function auditFindingsFromControls(controls = []) {
|
|
1209
1226
|
const findings = [];
|
|
1210
1227
|
for (const control of controls) {
|
|
1211
|
-
|
|
1228
|
+
// Never name a control by its evidence selector; an unlabelled control is said to be one.
|
|
1229
|
+
const where = control.label
|
|
1230
|
+
|| (control.identifier && /[#\[]/.test(control.identifier) ? control.identifier : "")
|
|
1231
|
+
|| `unlabelled <${control.tag || "control"}>`;
|
|
1212
1232
|
if (control.kind === "dead_anchor") {
|
|
1213
1233
|
findings.push({ type: "anchor_missing", severity: "medium",
|
|
1214
1234
|
title: `In-page link “${where}” points at #${control.fragment}, which is not on the page`, target: control.href });
|
|
@@ -1236,8 +1256,24 @@ export async function auditStructuralControls(page) {
|
|
|
1236
1256
|
const style = window.getComputedStyle(el);
|
|
1237
1257
|
return style.visibility !== "hidden" && style.display !== "none" && el.getClientRects().length > 0;
|
|
1238
1258
|
};
|
|
1239
|
-
const name = (el) =>
|
|
1259
|
+
const name = (el) => {
|
|
1260
|
+
const labelledBy = (el.getAttribute("aria-labelledby") || "").split(/\s+/).map((id) => id && document.getElementById(id)?.textContent).filter(Boolean).join(" ");
|
|
1261
|
+
const inner = el.querySelector("img[alt], svg[aria-label], [title]");
|
|
1262
|
+
const raw = el.getAttribute("aria-label") || labelledBy || el.textContent || el.getAttribute("title") || (inner && (inner.getAttribute("alt") || inner.getAttribute("aria-label") || inner.getAttribute("title"))) || el.getAttribute("value") || "";
|
|
1263
|
+
return String(raw).replace(/\s+/g, " ").trim().slice(0, 80);
|
|
1264
|
+
};
|
|
1240
1265
|
const selectorFor = (el) => el.id ? `#${el.id}` : el.getAttribute("data-testid") ? `[data-testid="${el.getAttribute("data-testid")}"]` : el.tagName.toLowerCase();
|
|
1266
|
+
// A short class is the best name an icon-only control has ("a.social-facebook").
|
|
1267
|
+
const classHint = (el) => { const c = [...el.classList].find((x) => /^[a-z][a-z0-9_-]{2,30}$/i.test(x) && !/^(active|btn|button|link|icon|item|elementor|wp|fa|fas|fab|far)$/i.test(x)); return c ? `${el.tagName.toLowerCase()}.${c}` : ""; };
|
|
1268
|
+
// Natively interactive without any script: the browser wires these itself.
|
|
1269
|
+
const nativelyWired = (el) => Boolean(el.closest("summary, details, select, option, label, input, textarea, video[controls], audio[controls]"));
|
|
1270
|
+
// A control that hosts a shadow root, or sits inside a third-party widget mount (accessibility
|
|
1271
|
+
// overlays, chat bubbles), is wired by that widget's own script where no page-level record
|
|
1272
|
+
// can see it.
|
|
1273
|
+
const widgetWired = (el) => {
|
|
1274
|
+
for (let node = el; node && node !== document.body; node = node.parentElement) if (node.shadowRoot) return true;
|
|
1275
|
+
return Boolean(el.closest('[id*="userway" i], [class*="userway" i], [id*="accessib" i], [class*="accessib" i], [id*="acsb" i], [class*="acsb" i], [id*="chat" i][class*="widget" i], iframe'));
|
|
1276
|
+
};
|
|
1241
1277
|
// Some controls are wired in CSS, not JavaScript: a menu that opens while
|
|
1242
1278
|
// its trigger is hovered or focused has no listener to find, and calling
|
|
1243
1279
|
// it dead is wrong. Collect the selectors that some rule reacts to — the
|
|
@@ -1276,10 +1312,9 @@ export async function auditStructuralControls(page) {
|
|
|
1276
1312
|
// this way (an outside-click closer, say) claims nothing and is ignored,
|
|
1277
1313
|
// rather than excusing every unwired control on the page.
|
|
1278
1314
|
const delegatedSelectors = [];
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
]) {
|
|
1315
|
+
const delegatedKey = Symbol.for("tapp.delegatedClickHandlers");
|
|
1316
|
+
const globalSources = [document, window, document.body, document.documentElement].flatMap((t) => [...((t && t[delegatedKey]) || [])]);
|
|
1317
|
+
for (const source of globalSources) {
|
|
1283
1318
|
for (const m of String(source).matchAll(/\.(?:closest|matches)\(\s*["'`]([^"'`]+)["'`]/g)) {
|
|
1284
1319
|
delegatedSelectors.push(m[1]);
|
|
1285
1320
|
}
|
|
@@ -1287,44 +1322,105 @@ export async function auditStructuralControls(page) {
|
|
|
1287
1322
|
const claimedByDelegate = (el) => delegatedSelectors.some((selector) => {
|
|
1288
1323
|
try { return el.matches(selector) || Boolean(el.closest(selector)); } catch { return false; }
|
|
1289
1324
|
});
|
|
1325
|
+
// jQuery registers one dispatcher per element and keeps `$(root).on("click", ".sel", fn)`'s
|
|
1326
|
+
// selector in its own registry, so neither the per-element listener record nor the handler's
|
|
1327
|
+
// source text says which controls it claims. WordPress/Elementor/Bootstrap sites wire menus,
|
|
1328
|
+
// accordions, sliders and review widgets this way; read the registry directly.
|
|
1329
|
+
const jq = window.jQuery && typeof window.jQuery._data === "function" ? window.jQuery : null;
|
|
1330
|
+
const jqHandlers = (node) => {
|
|
1331
|
+
let events;
|
|
1332
|
+
try { events = jq._data(node, "events"); } catch { events = null; }
|
|
1333
|
+
return events ? [...(events.click || []), ...(events.touchstart || []), ...(events.touchend || [])] : [];
|
|
1334
|
+
};
|
|
1335
|
+
const jqWired = (el) => {
|
|
1336
|
+
if (!jq) return false;
|
|
1337
|
+
for (let node = el; node; node = node.parentElement) {
|
|
1338
|
+
for (const h of jqHandlers(node)) {
|
|
1339
|
+
if (!h.selector) return true; // a direct handler on the control or an ancestor
|
|
1340
|
+
try { if (el.matches(h.selector) || el.closest(h.selector)) return true; } catch { /* bad selector */ }
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
for (const h of jqHandlers(document)) {
|
|
1344
|
+
if (!h.selector) continue;
|
|
1345
|
+
try { if (el.matches(h.selector) || el.closest(h.selector)) return true; } catch { /* bad selector */ }
|
|
1346
|
+
}
|
|
1347
|
+
return false;
|
|
1348
|
+
};
|
|
1349
|
+
// Everything that makes a control "alive": the same test for a button and for a link whose
|
|
1350
|
+
// href is a placeholder — a wired `<a href="#">` is a JavaScript control, not a dead link.
|
|
1351
|
+
const isWired = (el) => {
|
|
1352
|
+
if (nativelyWired(el) || widgetWired(el)) return true;
|
|
1353
|
+
for (let node = el; node && node !== document.body; node = node.parentElement) {
|
|
1354
|
+
if ((node[key] && node[key].size > 0) || typeof node.onclick === "function" || node.hasAttribute("onclick")) return true;
|
|
1355
|
+
}
|
|
1356
|
+
if (el.matches("button[type=submit], input[type=submit]") && el.closest("form")) return true;
|
|
1357
|
+
if (el.closest("label")) return true; // a label drives its own control
|
|
1358
|
+
if (opensSomethingOnHoverOrFocus(el)) return true;
|
|
1359
|
+
if (claimedByDelegate(el)) return true;
|
|
1360
|
+
if (jqWired(el)) return true;
|
|
1361
|
+
return false;
|
|
1362
|
+
};
|
|
1290
1363
|
|
|
1364
|
+
// Some sites delay every script until the first user interaction (WP Rocket, Perfmatters,
|
|
1365
|
+
// Flying Scripts). A read-only audit never interacts, so on such a page nothing is wired yet
|
|
1366
|
+
// and every control would be called dead. Detect the pattern and skip the wiring-dependent
|
|
1367
|
+
// checks; the report says they were not checked.
|
|
1368
|
+
const deferredScripts = document.querySelectorAll('script[type="rocketlazyloadscript"], script[data-rocket-type], script[type="pmdelayedscript"], script[type="javascript/blocked"], script[data-type="lazy"], script[type="lazy"]').length;
|
|
1369
|
+
const jqueryTagWithoutJquery = !window.jQuery && Boolean(document.querySelector('script[src*="jquery"]'));
|
|
1370
|
+
const generator = (document.querySelector('meta[name="generator"]')?.getAttribute("content") || "").toLowerCase();
|
|
1371
|
+
// Wix renders every control server-side and hydrates each component on its own schedule;
|
|
1372
|
+
// what has a handler at audit time is not what has one for a visitor.
|
|
1373
|
+
const lazyHydrationBuilder = generator.includes("wix") || Boolean(document.querySelector("#SITE_CONTAINER, [data-wix-site]"));
|
|
1374
|
+
const scriptsDeferred = deferredScripts > 0 || jqueryTagWithoutJquery;
|
|
1375
|
+
const clickListenerCount = window[Symbol.for("tapp.clickListenerCount")] || 0;
|
|
1376
|
+
const inlineHandlers = document.querySelectorAll("[onclick]").length;
|
|
1377
|
+
// A page with no scripts at all is static: a dead button there is dead. The hydration rule
|
|
1378
|
+
// is for pages that load scripts and attached nothing by the time the audit looked.
|
|
1379
|
+
const loadsScripts = document.querySelectorAll("script[src]").length > 0;
|
|
1380
|
+
// A global click handler whose source exposes no selector: delegation we cannot read.
|
|
1381
|
+
const opaqueGlobalHandlers = globalSources.filter((src) => !/\.(?:closest|matches)\(\s*["'`]/.test(String(src))).length;
|
|
1291
1382
|
const dead = [];
|
|
1292
1383
|
for (const el of document.querySelectorAll("a[href], button, [role=button], [aria-controls]")) {
|
|
1293
1384
|
if (!visible(el)) continue;
|
|
1294
1385
|
const label = name(el);
|
|
1386
|
+
const identifier = /^[a-z]+$/.test(selectorFor(el)) ? (classHint(el) || selectorFor(el)) : selectorFor(el);
|
|
1387
|
+
const tag = el.tagName.toLowerCase();
|
|
1295
1388
|
const href = el.getAttribute("href");
|
|
1296
1389
|
const ariaControls = el.getAttribute("aria-controls");
|
|
1297
1390
|
if (ariaControls && !document.getElementById(ariaControls)) {
|
|
1298
|
-
dead.push({ element: el, kind: "dangling_aria_controls", label, selector:
|
|
1391
|
+
dead.push({ element: el, kind: "dangling_aria_controls", label, identifier, tag, selector: identifier, controls: ariaControls });
|
|
1299
1392
|
continue;
|
|
1300
1393
|
}
|
|
1301
1394
|
if (href != null) {
|
|
1302
1395
|
if (href === "#" || href.trim() === "" || /^javascript:\s*(void\(0\))?;?$/i.test(href)) {
|
|
1303
|
-
dead.push({ element: el, kind: "placeholder_link", label, selector:
|
|
1396
|
+
if (!isWired(el)) dead.push({ element: el, kind: "placeholder_link", label, identifier, tag, selector: identifier, href });
|
|
1304
1397
|
} else if (href.startsWith("#")) {
|
|
1305
1398
|
const fragment = decodeURIComponent(href.slice(1));
|
|
1306
1399
|
const found = fragment && (document.getElementById(fragment) || document.getElementsByName(fragment).length > 0);
|
|
1307
|
-
if (!found) dead.push({ element: el, kind: "dead_anchor", label, selector:
|
|
1400
|
+
if (!found && !isWired(el)) dead.push({ element: el, kind: "dead_anchor", label, identifier, tag, selector: identifier, href, fragment });
|
|
1308
1401
|
}
|
|
1309
1402
|
continue;
|
|
1310
1403
|
}
|
|
1311
1404
|
// A button with nothing behind it: no listener on itself or an ancestor, no inline
|
|
1312
|
-
// handler,
|
|
1313
|
-
|
|
1314
|
-
for (let node = el; node && node !== document.body; node = node.parentElement) {
|
|
1315
|
-
if ((node[key] && node[key].size > 0) || typeof node.onclick === "function" || node.hasAttribute("onclick")) { wired = true; break; }
|
|
1316
|
-
}
|
|
1317
|
-
if (!wired && el.matches("button[type=submit], input[type=submit]") && el.closest("form")) wired = true;
|
|
1318
|
-
if (!wired && el.closest("label")) wired = true; // a label drives its own control
|
|
1319
|
-
if (!wired && opensSomethingOnHoverOrFocus(el)) wired = true;
|
|
1320
|
-
if (!wired && claimedByDelegate(el)) wired = true;
|
|
1321
|
-
if (!wired) dead.push({ element: el, kind: "unwired_control", label, selector: selectorFor(el) });
|
|
1405
|
+
// handler, not a submit inside a form, not CSS-, delegation- or jQuery-wired.
|
|
1406
|
+
if (!isWired(el)) dead.push({ element: el, kind: "unwired_control", label, identifier, tag, selector: identifier });
|
|
1322
1407
|
}
|
|
1323
1408
|
|
|
1324
1409
|
for (let i = 0; i < dead.length; i += 1) {
|
|
1325
1410
|
if (dead[i].element) { dead[i].element.setAttribute("data-tapp-audit", String(i + 1)); dead[i].selector = `[data-tapp-audit="${i + 1}"]`; delete dead[i].element; }
|
|
1326
1411
|
}
|
|
1327
|
-
|
|
1412
|
+
// Whether "no handler found" means anything on this page. Deferred scripts, or a page that
|
|
1413
|
+
// attached no click handler at all, make the check blind; three or more "dead" controls
|
|
1414
|
+
// under a global handler we cannot read is the signature of unreadable delegation
|
|
1415
|
+
// (Squarespace, Wix once hydrated), not of three dead buttons — a dead button is rare.
|
|
1416
|
+
const wiringDependent = dead.filter((d) => d.kind !== "dangling_aria_controls");
|
|
1417
|
+
let wiringUnverifiable = "";
|
|
1418
|
+
if (scriptsDeferred) wiringUnverifiable = "the page defers its scripts until a user interacts";
|
|
1419
|
+
else if (lazyHydrationBuilder && wiringDependent.length) wiringUnverifiable = "the site builder (Wix) hydrates controls lazily after rendering them";
|
|
1420
|
+
else if (loadsScripts && clickListenerCount === 0 && inlineHandlers === 0 && wiringDependent.length) wiringUnverifiable = "the page attached no click handler at all at audit time (deferred hydration)";
|
|
1421
|
+
else if (opaqueGlobalHandlers > 0 && wiringDependent.length >= 3) wiringUnverifiable = "a site-wide click handler the audit cannot read claims the controls";
|
|
1422
|
+
const kept = wiringUnverifiable ? dead.filter((d) => d.kind === "dangling_aria_controls") : dead;
|
|
1423
|
+
return { dead: kept, controlCount: document.querySelectorAll("a[href], button, [role=button]").length, title: document.title, scriptsDeferred, wiringUnverifiable: wiringUnverifiable || null };
|
|
1328
1424
|
});
|
|
1329
1425
|
}
|
|
1330
1426
|
|
|
@@ -153,6 +153,12 @@ export async function runWebRequestStep({ step, startUrl, vars = {}, timeout = D
|
|
|
153
153
|
init.body = JSON.stringify(substituteStructure(request.body, vars));
|
|
154
154
|
if (!Object.keys(headers).some((key) => key.toLowerCase() === "content-type")) headers["content-type"] = "application/json";
|
|
155
155
|
}
|
|
156
|
+
if (process.env.TAPP_ENFORCE_PUBLIC_EGRESS === "1") {
|
|
157
|
+
const { publicRequest } = await import("./public-network.js");
|
|
158
|
+
const response = await publicRequest(targetUrl, {method,headers,body:init.body,timeout:Number(request.timeoutMs) || timeout});
|
|
159
|
+
if (response.status !== Number(request.status ?? 200)) throw new Error(`${method} ${targetUrl.pathname} did not return the expected status`);
|
|
160
|
+
return { action:"request",target:`${method} ${targetUrl.pathname}`,status:"pass",detail:"" };
|
|
161
|
+
}
|
|
156
162
|
const response = await fetch(targetUrl, init);
|
|
157
163
|
const expected = Number(request.status ?? 200);
|
|
158
164
|
if (response.status !== expected) throw new Error(`${method} ${targetUrl.pathname} returned ${response.status}; expected ${expected}`);
|
|
@@ -284,7 +290,7 @@ export function resolveGateFlowUrl(declared, gateUrl) {
|
|
|
284
290
|
}
|
|
285
291
|
}
|
|
286
292
|
|
|
287
|
-
export async function runWebFlow({ flow, url, logPath, screenshotDir, playwright, device = "", viewport = "", urlIsFallback = false }) {
|
|
293
|
+
export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVideoDir, variables = {}, strictOrigin = false, playwright, device = "", viewport = "", urlIsFallback = false }) {
|
|
288
294
|
// urlIsFallback = the caller is a gate: the Flow's own page wins, rebased onto the gate's
|
|
289
295
|
// deployment (see resolveGateFlowUrl). An explicit caller url (CLI positional) still overrides.
|
|
290
296
|
const declaredUrl = flow.url || (/^https?:\/\//i.test(flow.app || "") ? flow.app : "");
|
|
@@ -296,12 +302,13 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, playwright
|
|
|
296
302
|
const loggedFlow = { ...flow, steps: [...setup, ...flow.steps, ...teardown] };
|
|
297
303
|
const log = new FlowLog({ logPath, flow: loggedFlow });
|
|
298
304
|
const pw = playwright || await loadPlaywright();
|
|
299
|
-
const
|
|
300
|
-
const
|
|
305
|
+
const { webBrowserLaunchOptions } = await import("./web-explorer.js");
|
|
306
|
+
const browser = await pw.chromium.launch(webBrowserLaunchOptions());
|
|
307
|
+
const context = await browser.newContext({...webContextOptions({ device, viewport, devices: pw.devices }),...(recordVideoDir ? {recordVideo:{dir:recordVideoDir}} : {})});
|
|
301
308
|
const page = await context.newPage();
|
|
302
309
|
const timeout = Number(flow.timeoutMs ?? flow.timeout) || DEFAULT_TIMEOUT;
|
|
303
310
|
page.setDefaultTimeout(timeout);
|
|
304
|
-
const vars = flowVariables(flow);
|
|
311
|
+
const vars = flowVariables(flow, variables);
|
|
305
312
|
let index = 0;
|
|
306
313
|
let failed = false;
|
|
307
314
|
|
|
@@ -328,6 +335,10 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, playwright
|
|
|
328
335
|
await page.goto(startUrl, { waitUntil: "domcontentloaded" });
|
|
329
336
|
await settle(page);
|
|
330
337
|
for (const step of flow.steps) {
|
|
338
|
+
if (strictOrigin && new URL(page.url()).origin !== new URL(startUrl).origin) {
|
|
339
|
+
emit({action:"origin",target:"connected app",status:"fail",detail:"The workflow left the connected app origin. Authorize a supported sign-in route before continuing."});
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
331
342
|
const outcome = await executeWebFlowStep({ page, step, vars, defaultTimeout: timeout });
|
|
332
343
|
emit(outcome);
|
|
333
344
|
if (outcome.status === "fail" && screenshotDir) {
|
|
@@ -343,6 +354,8 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, playwright
|
|
|
343
354
|
}
|
|
344
355
|
} finally {
|
|
345
356
|
await requestPhase(teardown);
|
|
357
|
+
// Test doubles for playwright may not model a context; a real one always closes.
|
|
358
|
+
if (typeof context.close === "function") await context.close().catch(() => {});
|
|
346
359
|
await browser.close().catch(() => {});
|
|
347
360
|
}
|
|
348
361
|
return log.finish({ url: startUrl });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aarwitz/tapp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./mcp-server/src/index.js",
|
|
13
13
|
"./product-operations": "./mcp-server/src/product-operations.js",
|
|
14
|
+
"./business-workflows": {
|
|
15
|
+
"types": "./mcp-server/src/business-workflows.d.ts",
|
|
16
|
+
"import": "./mcp-server/src/business-workflows.js"
|
|
17
|
+
},
|
|
18
|
+
"./business-workflow-runtime": "./mcp-server/src/business-workflow-runtime.js",
|
|
14
19
|
"./contracts": {
|
|
15
20
|
"types": "./mcp-server/src/release-contract.d.ts",
|
|
16
21
|
"import": "./mcp-server/src/contract-authoring.js"
|
|
@@ -21,6 +26,7 @@
|
|
|
21
26
|
"browser/",
|
|
22
27
|
"docs/BROWSER-PRODUCT.md",
|
|
23
28
|
"docs/PRODUCT-ENGINE.md",
|
|
29
|
+
"docs/BUSINESS-WORKFLOWS.md",
|
|
24
30
|
"docs/application-model.md",
|
|
25
31
|
"docs/scenarios.md",
|
|
26
32
|
"mcp-server/src/",
|
package/scripts/run-web-flow.js
CHANGED
|
@@ -24,6 +24,10 @@ try {
|
|
|
24
24
|
url: process.argv[3],
|
|
25
25
|
logPath,
|
|
26
26
|
screenshotDir,
|
|
27
|
+
...(process.env.TAPP_FLOW_RECORD_VIDEO === "1" ? {recordVideoDir:screenshotDir} : {}),
|
|
28
|
+
...(process.env.TAPP_WORKFLOW_REPLAY === "1" ? {strictOrigin:true,variables:{
|
|
29
|
+
TEST_RUN_ID:process.env.TEST_RUN_ID || "",TEST_EMAIL:process.env.OCQA_TEST_EMAIL || "",TEST_PASSWORD:process.env.OCQA_TEST_PASSWORD || "",
|
|
30
|
+
}} : {}),
|
|
27
31
|
device: process.env.TAPP_WEB_DEVICE || "",
|
|
28
32
|
viewport: process.env.TAPP_WEB_VIEWPORT || "",
|
|
29
33
|
});
|
package/skills/tapp/SKILL.md
CHANGED
|
@@ -12,13 +12,13 @@ screen or journey works from source inspection alone.
|
|
|
12
12
|
|
|
13
13
|
| Intent | Operation |
|
|
14
14
|
|---|---|
|
|
15
|
-
| See or screenshot one screen | `
|
|
16
|
-
| Inspect controls on the current screen | `tree` / `
|
|
17
|
-
| Reach a named screen/control | `
|
|
18
|
-
| Drive a specific journey |
|
|
15
|
+
| See or screenshot one screen | `look` / `tapp_look` |
|
|
16
|
+
| Inspect controls on the current screen | `look --tree` / `tapp_look {tree:true}` |
|
|
17
|
+
| Reach a named screen/control | `explore --goal` / `tapp_explore {goal}` (source + observed UI Map fast path) |
|
|
18
|
+
| Drive a specific journey | `tapp_session` start → act → end |
|
|
19
19
|
| Find bugs autonomously (owned app/environment; it clicks) | `explore` / `tapp_explore` |
|
|
20
|
-
| Check production or a site you do not own (never clicks) | `
|
|
21
|
-
| Preserve a journey |
|
|
20
|
+
| Check production or a site you do not own (never clicks) | `explore --read-only` / `tapp_explore {readOnly:true}` |
|
|
21
|
+
| Preserve a journey | `tapp_session {action:"save_flow"}`; replay it with `run` / `tapp_run` |
|
|
22
22
|
| Decide whether a merge passes policy | `ci`; exploration never decides this |
|
|
23
23
|
|
|
24
24
|
Prefer connected `tapp_*` MCP tools when available: they keep interactive sessions alive and return
|
|
@@ -35,7 +35,7 @@ When the user asks for a general first test of a repository:
|
|
|
35
35
|
3. If Tapp returns `target-selection-required`, present its actual choices and ask the user to pick.
|
|
36
36
|
Never guess among multiple targets. Re-run with the selected platform/target exactly as Tapp
|
|
37
37
|
instructs.
|
|
38
|
-
4. If a prerequisite is missing, call `
|
|
38
|
+
4. If a prerequisite is missing, call `tapp_doctor` when MCP is connected or run
|
|
39
39
|
`npx -y @aarwitz/tapp@latest doctor`, apply only the stated remediation that is in scope, and
|
|
40
40
|
retry once.
|
|
41
41
|
|
|
@@ -50,17 +50,17 @@ or owned HTTP(S) URL. Never explore a third-party web property: exploration clic
|
|
|
50
50
|
When the user names a screen, control, or UI condition, do not discover the app one screenshot at a
|
|
51
51
|
time. Start from the repository source, then use Tapp's observed navigation evidence:
|
|
52
52
|
|
|
53
|
-
1. In a source repository, run `npx -y @aarwitz/tapp@latest
|
|
54
|
-
selects the reviewed model target and prepares web, iOS, or Android from source. In an active MCP
|
|
55
|
-
session call `
|
|
56
|
-
`focus` without retyping the URL.
|
|
53
|
+
1. In a source repository, run `npx -y @aarwitz/tapp@latest explore --goal "<exact request>" [target]`;
|
|
54
|
+
it selects the reviewed model target and prepares web, iOS, or Android from source. In an active MCP
|
|
55
|
+
session call `tapp_explore {goal}`; for managed web, `tapp_session {action:"start"}` can also take
|
|
56
|
+
`projectDir` and `focus` without retyping the URL.
|
|
57
57
|
2. Tapp searches owned source, reconciles the likely surface with `.tapp/ui-map.json`, and executes
|
|
58
58
|
the shortest runtime-observed route in one call. Read its final tree before visual assertions.
|
|
59
59
|
3. If Tapp returns source evidence but no replayable route, inspect the cited file/line and relevant
|
|
60
60
|
router/navigation source. Do not wander blindly or invent a path; ground the map or drive only a
|
|
61
61
|
route supported by that source evidence.
|
|
62
62
|
|
|
63
|
-
A fresh repository needs one grounding exploration before `
|
|
63
|
+
A fresh repository needs one grounding exploration before `--goal` can replay a route. Source can
|
|
64
64
|
locate an unobserved surface, but it never authorizes unobserved taps.
|
|
65
65
|
|
|
66
66
|
Source establishes intent and location; the real UI establishes behavior. A URL-only target has no
|
|
@@ -78,7 +78,7 @@ ship verdict. Report:
|
|
|
78
78
|
- what Tapp explicitly did not check.
|
|
79
79
|
|
|
80
80
|
Evidence is the capture the command just returned. `~/.tapp/captures/` is shared by every project on
|
|
81
|
-
the machine; `
|
|
81
|
+
the machine; `tapp_report` shows only this project's and labels each with its provenance. Never
|
|
82
82
|
cite or reuse another project's capture, and never borrow one as a fixture — make a fresh one.
|
|
83
83
|
|
|
84
84
|
If `inconclusive: true`, explain the blocker. A login wall or missing test data is not a pass. Ask for
|
|
@@ -109,4 +109,5 @@ workaround to finish a straightforward task; a result reported `ok`/`inconclusiv
|
|
|
109
109
|
shouldn't have; or you're unsure whether something is a real app finding or a Tapp bug. One report
|
|
110
110
|
per issue; when unsure, file — a closed non-issue costs nothing, an unreported bug stays a bug.
|
|
111
111
|
|
|
112
|
+
Older verbs and tool names (`audit`, `focus`, `open`, `tree`, `tapp_session_start`, …) still work for one minor version and print their new form.
|
|
112
113
|
Read [references/commands.md](references/commands.md) only for exact CLI/MCP syntax, Flow replay, credentials, or platform prerequisites.
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
# Tapp command reference
|
|
2
2
|
|
|
3
|
+
Twelve verbs, one mental model: **explore → look → run/validate → plan → ci**. Older verbs
|
|
4
|
+
(`audit`, `focus`, `open`, `tree`, `shot`, `flow`, `task`, `contract`, `scenario`, `pr`, `map`,
|
|
5
|
+
`baseline`, `workflows`, `actor`, `install`, `build`, `apps`) still work for one minor version
|
|
6
|
+
and print their new form.
|
|
7
|
+
|
|
3
8
|
## Plain CLI
|
|
4
9
|
|
|
5
10
|
Run from the application repository. `[target]` is optional when Tapp can read the repository model
|
|
6
11
|
or detect one unambiguous target.
|
|
7
12
|
|
|
8
13
|
```bash
|
|
9
|
-
npx -y @aarwitz/tapp@latest init . --explore
|
|
10
|
-
npx -y @aarwitz/tapp@latest explore [target]
|
|
11
|
-
npx -y @aarwitz/tapp@latest
|
|
12
|
-
npx -y @aarwitz/tapp@latest
|
|
13
|
-
npx -y @aarwitz/tapp@latest tree [target] --json
|
|
14
|
-
npx -y @aarwitz/tapp@latest audit https://example.com --pages 5 --json # read-only: never clicks; safe on production or third-party sites
|
|
14
|
+
npx -y @aarwitz/tapp@latest init . --explore # detect targets, write the model + plan, explore once
|
|
15
|
+
npx -y @aarwitz/tapp@latest explore [target] # autonomous exploration → findings, map, evidence (observes; no verdict)
|
|
16
|
+
npx -y @aarwitz/tapp@latest explore --goal "Save storefront settings visible above keyboard" [target] # source-locate + shortest observed route
|
|
17
|
+
npx -y @aarwitz/tapp@latest explore --read-only https://example.com --pages 5 --json # never clicks: safe on production or a site you do not own
|
|
15
18
|
# several URLs or --urls FILE batch sites · --device "iPhone 13" audits the mobile rendering · --json FILE writes the result · exit 1 = defects found
|
|
16
|
-
npx -y @aarwitz/tapp@latest
|
|
19
|
+
npx -y @aarwitz/tapp@latest look [target] # one screen: summary + screenshot file
|
|
20
|
+
npx -y @aarwitz/tapp@latest look [target] --tree --json # + the accessibility tree (every element with --json)
|
|
17
21
|
npx -y @aarwitz/tapp@latest report latest
|
|
18
|
-
npx -y @aarwitz/tapp@latest doctor
|
|
22
|
+
npx -y @aarwitz/tapp@latest doctor # toolchain check · --install prebuilds the iOS harness (~2 min, once)
|
|
19
23
|
npx -y @aarwitz/tapp@latest feedback "short title" --body "what happened" --type bug|idea|question # draft; add --submit to file (public)
|
|
20
24
|
```
|
|
21
25
|
|
|
@@ -26,12 +30,12 @@ Platform examples:
|
|
|
26
30
|
npx -y @aarwitz/tapp@latest explore --platform web --target website --watch
|
|
27
31
|
npx -y @aarwitz/tapp@latest explore https://staging.example.com
|
|
28
32
|
|
|
29
|
-
# iOS: source repo, .app, or bundle id.
|
|
33
|
+
# iOS: source repo, .app, or bundle id. `look` with no target reads the booted simulator.
|
|
30
34
|
npx -y @aarwitz/tapp@latest explore MyApp.xcodeproj --platform ios
|
|
31
|
-
npx -y @aarwitz/tapp@latest
|
|
35
|
+
npx -y @aarwitz/tapp@latest look com.example.MyApp --platform ios
|
|
32
36
|
|
|
33
|
-
# Android source: select a modeled target; Tapp builds, installs, and
|
|
34
|
-
npx -y @aarwitz/tapp@latest
|
|
37
|
+
# Android source: select a modeled target; Tapp builds, installs, and reaches the goal.
|
|
38
|
+
npx -y @aarwitz/tapp@latest explore --goal "About screen" . --target demoapp
|
|
35
39
|
|
|
36
40
|
# Android black-box entry: app id is required; APK is optional if already installed.
|
|
37
41
|
npx -y @aarwitz/tapp@latest explore app-debug.apk --platform android --app-id com.example.app
|
|
@@ -40,45 +44,57 @@ npx -y @aarwitz/tapp@latest explore app-debug.apk --platform android --app-id co
|
|
|
40
44
|
Focused web evidence can perform one semantic interaction and wait for async content:
|
|
41
45
|
|
|
42
46
|
```bash
|
|
43
|
-
npx -y @aarwitz/tapp@latest
|
|
47
|
+
npx -y @aarwitz/tapp@latest look https://example.com --tap "Not now" --wait-for "Dashboard"
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
## MCP
|
|
50
|
+
## MCP tools (13)
|
|
47
51
|
|
|
48
52
|
- `tapp_init`: inspect or initialize a source repository; `operation:"explore"` prepares and explores.
|
|
49
|
-
- `
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- `
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
`
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- `
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
- `tapp_explore`: autonomous iOS, Android, or web exploration; observation only. `readOnly:true`
|
|
54
|
+
never clicks (production or a site you do not own); `goal:"…"` source-locates a named
|
|
55
|
+
screen/control and takes the shortest observed route in the active session.
|
|
56
|
+
- `tapp_look`: the current real surface — screen summary plus inline screenshot; `tree:true` adds
|
|
57
|
+
the accessibility tree (`full:true` for the complete raw element list when the default
|
|
58
|
+
≤160-element projection might omit the text you are checking for).
|
|
59
|
+
- `tapp_session`: one persistent journey. `action:"start"` → `tap|type|swipe|back|wait|tree|login`
|
|
60
|
+
→ `action:"end"`. `action:"save_flow"` keeps the driven journey as a Flow; `action:"draft_flow"`
|
|
61
|
+
proposes one from a goal (an untrusted draft until replayed). Sessions begin from a **cold**
|
|
62
|
+
launch: persisted data survives, but an app that gates each cold start behind sign-in shows its
|
|
63
|
+
login wall first — make `login` the first act (`tapp_look` warm-resumes the foregrounded app,
|
|
64
|
+
so it can look signed-in when a fresh session does not).
|
|
65
|
+
- `tapp_run`: replay a committed Flow, Task, contract, or Scenario; the kind comes from the file.
|
|
66
|
+
Keyless and deterministic.
|
|
67
|
+
- `tapp_validate`: check a Flow/Task/contract/Scenario without launching (`compile:true` shows the
|
|
68
|
+
executor form).
|
|
69
|
+
- `tapp_plan`: the release-plan lifecycle via `action`: `show|review|generate|validate|promote|pr|adopt|actor`.
|
|
70
|
+
`actor` stores roles and environment-variable **names**, never values.
|
|
71
|
+
- `tapp_map`: build, inspect, merge, and diff the persistent UI Map.
|
|
72
|
+
- `tapp_ci`: create a target-scoped baseline or render/install the reviewable CI workflow. The gate
|
|
73
|
+
itself runs from the CLI (`tapp ci`).
|
|
74
|
+
- `tapp_build`: `action:"build|install|list_simulators|boot"` — build and install an iOS app without
|
|
75
|
+
knowing its bundle id first, or manage the simulator.
|
|
76
|
+
- `tapp_report`: this project's captures and one capture's summary/evidence paths.
|
|
77
|
+
- `tapp_doctor`: toolchain and prerequisite check with exact remediation.
|
|
78
|
+
- `tapp_feedback`: draft (or, with the user's OK, submit) an issue about Tapp itself.
|
|
79
|
+
|
|
80
|
+
An iOS no-bundle-id MCP path is `tapp_build {action:"build", projectDir:"."}` followed by
|
|
81
|
+
`tapp_explore` with the returned `bundleId`. Android uses `androidAppId` and optional `apkPath`.
|
|
82
|
+
Web can use an explicit owned `url`, or `tapp_session {action:"start", projectDir:".", focus:"..."}`
|
|
83
|
+
can build/start one unambiguous owned browser target and stop it with `action:"end"`.
|
|
68
84
|
|
|
69
85
|
## Interactive session loop
|
|
70
86
|
|
|
71
87
|
```text
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
tapp_session {action:"start", appBundleId:"com.example.app", focus:"Save storefront settings visible above keyboard", projectDir:"."}
|
|
89
|
+
tapp_explore {goal:"Save storefront settings visible above keyboard"}
|
|
90
|
+
tapp_session {action:"tap", id:"Email"}
|
|
91
|
+
tapp_session {action:"type", text:"qa@example.com"}
|
|
92
|
+
tapp_session {action:"tap", id:"Password"}
|
|
93
|
+
tapp_session {action:"type", text:"..."}
|
|
94
|
+
tapp_session {action:"tap", id:"Sign In"}
|
|
95
|
+
tapp_session {action:"wait", text:"Home", timeoutMs:10000}
|
|
96
|
+
tapp_look
|
|
97
|
+
tapp_session {action:"end"}
|
|
82
98
|
```
|
|
83
99
|
|
|
84
100
|
Android sessions use `androidAppId`, optional `apkPath`, and the same action loop.
|
|
@@ -90,10 +106,10 @@ For autonomous exploration, pass test-only values when authorized:
|
|
|
90
106
|
- CLI: `--email`, `--password`, repeated `--launch-arg`, and JSON `--launch-env`.
|
|
91
107
|
- MCP: `testEmail`, `testPassword`, `inputOverrides`, `appLaunchArgs`, `appLaunchEnv`, or explicit
|
|
92
108
|
`loginSteps`.
|
|
93
|
-
- Reusable: `tapp actor set NAME --email-env ENV --password-env ENV` stores env-var **names**
|
|
94
|
-
(never values);
|
|
95
|
-
`
|
|
96
|
-
|
|
109
|
+
- Reusable: `tapp plan actor set NAME --email-env ENV --password-env ENV` stores env-var **names**
|
|
110
|
+
(never values); replay resolves them via `tapp run FILE --actor NAME` or
|
|
111
|
+
`tapp_run {actor:"NAME"}`. Re-running `actor set` on an existing actor requires `--replace` —
|
|
112
|
+
idempotent setup scripts must include it.
|
|
97
113
|
|
|
98
114
|
Do not persist secrets in `.tapp/`. If the result reports input fields and no values were supplied,
|
|
99
115
|
ask the user rather than pretending the explored surface was complete.
|
|
@@ -103,18 +119,18 @@ ask the user rather than pretending the explored surface was complete.
|
|
|
103
119
|
Flow YAML belongs under `.tapp/flows/` and can replay without a model or API key:
|
|
104
120
|
|
|
105
121
|
```bash
|
|
106
|
-
npx -y @aarwitz/tapp@latest
|
|
107
|
-
npx -y @aarwitz/tapp@latest
|
|
108
|
-
npx -y @aarwitz/tapp@latest
|
|
109
|
-
npx -y @aarwitz/tapp@latest ci
|
|
122
|
+
npx -y @aarwitz/tapp@latest validate --example # a complete starter Flow (step vocabulary: assert_screen = screen TITLE, assert_exists = text present; taps are label-only)
|
|
123
|
+
npx -y @aarwitz/tapp@latest validate .tapp/flows/smoke.yml
|
|
124
|
+
npx -y @aarwitz/tapp@latest run .tapp/flows/smoke.yml
|
|
125
|
+
npx -y @aarwitz/tapp@latest ci # the gate · ci install writes the workflow · ci baseline saves a target-scoped baseline
|
|
110
126
|
```
|
|
111
127
|
|
|
112
|
-
Web commands (`
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
Web commands (`look`, `explore`, `run`) accept `--device "iPhone 13"` (any Playwright device
|
|
129
|
+
profile) or `--viewport 390x844` to render at mobile sizes, and `look` accepts `--full-page` for a
|
|
130
|
+
full-height screenshot — use these for "does it look right on a phone" checks. Web explores also
|
|
131
|
+
audit outbound links (DNS, HTTP status, unavailable-shell heuristic) and `mailto:` domains, report an
|
|
132
|
+
honest `stopReason` (`no-unexplored-in-scope-controls` when a small surface is swept before the
|
|
133
|
+
budget), and return a per-action `trace` in `--json`.
|
|
118
134
|
|
|
119
135
|
`tapp explore` observes. `tapp ci` applies versioned deterministic policy to evidence, selected
|
|
120
136
|
Flows/Scenarios/contracts, coverage, and any target-scoped baseline. Its outcomes are `pass`, `fail`,
|