@aarwitz/tapp 0.18.1 → 0.18.2

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.
@@ -12,19 +12,8 @@ import { fileURLToPath } from "node:url";
12
12
  import { customerProductContract } from "../../browser/product-contract.js";
13
13
  import { BrowserWorkspaceRegistry } from "./browser-workspaces.js";
14
14
  import { selectApplicationTarget } from "./ci-setup.js";
15
- import {
16
- createProductBaseline,
17
- generateProductPlan,
18
- initializeProductProject,
19
- installProductCi,
20
- prepareProductCi,
21
- prepareProductTarget,
22
- promoteProductPlan,
23
- readProductProject,
24
- reviewProductPlan,
25
- runProductGate,
26
- validateProductPlan,
27
- } from "./product-operations.js";
15
+ import { initializeProductProject, prepareProductTarget, readProductProject, runProductGate } from "./product-operations.js";
16
+ import { readCaptureProvenance } from "./capture-provenance.js";
28
17
 
29
18
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
30
19
  const assetRoot = path.join(packageRoot, "browser");
@@ -119,6 +108,29 @@ function capturePath(captureId, relative = "report.html") {
119
108
  return candidate === root || candidate.startsWith(root + path.sep) ? candidate : null;
120
109
  }
121
110
 
111
+ // Read-only website audits live in the captures directory like every other run; the Studio
112
+ // lists the ones with a summary file. Newest first, bounded.
113
+ function listAudits(limit = 50) {
114
+ const root = captureRoot();
115
+ let names;
116
+ try { names = fs.readdirSync(root); } catch { return []; }
117
+ const audits = [];
118
+ for (const name of names) {
119
+ if (!name.startsWith("web-audit-")) continue;
120
+ const summaryPath = path.join(root, name, "audit.json");
121
+ let summary;
122
+ try { summary = JSON.parse(fs.readFileSync(summaryPath, "utf8")); } catch { continue; }
123
+ const provenance = readCaptureProvenance(path.join(root, name));
124
+ audits.push({
125
+ id: name, createdAt: provenance?.createdAt || fs.statSync(summaryPath).mtime.toISOString(),
126
+ url: summary.url, pagesAudited: summary.pagesAudited || 0, pagesWithUnverifiableWiring: summary.pagesWithUnverifiableWiring || 0,
127
+ findingCounts: summary.findingCounts || {}, issueCount: summary.issueCount ?? (summary.issues || []).length,
128
+ issues: (summary.issues || []).slice(0, 60), checkedFor: summary.checkedFor || [], notChecked: summary.notChecked || [],
129
+ });
130
+ }
131
+ return audits.sort((a, b) => b.createdAt.localeCompare(a.createdAt)).slice(0, limit);
132
+ }
133
+
122
134
  function openBrowser(url) {
123
135
  const invocation = process.platform === "darwin" ? ["open", [url]]
124
136
  : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]]
@@ -418,7 +430,7 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
418
430
  return;
419
431
  }
420
432
  if (request.method === "GET" && url.pathname === "/api/repositories") { json(response, 200, hosted ? { current:hostedRepository(registry.current()), repositories:registry.list().map(hostedRepository) } : { current: registry.current(), repositories: registry.list() }); return; }
421
- if (request.method === "GET" && url.pathname === "/api/repositories/github") { json(response, 200, { repositories: await registry.listGithub() }); return; }
433
+ if (request.method === "GET" && url.pathname === "/api/audits") { json(response, 200, { audits: hosted ? hostedPayload(listAudits()) : listAudits() }); return; }
422
434
  if (request.method === "GET" && url.pathname === "/api/project") { json(response, 200, hosted ? hostedPayload(projectSnapshot(registry)) : projectSnapshot(registry)); return; }
423
435
  if (request.method === "GET" && url.pathname === "/api/live-session") { json(response, 200, liveSession || { active:false }); return; }
424
436
  if (request.method === "GET" && url.pathname === "/api/live-session/frame") {
@@ -456,35 +468,6 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
456
468
  return;
457
469
  }
458
470
 
459
- const uploadFileMatch = url.pathname.match(/^\/api\/repositories\/uploads\/(upload_[a-f0-9]{20})\/files$/);
460
- if (request.method === "PUT" && uploadFileMatch) {
461
- requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
462
- let relativePath;
463
- try { relativePath = decodeURIComponent(String(request.headers["x-tapp-relative-path"] || "")); }
464
- catch { throw Object.assign(new Error("Repository file path header is invalid"), { statusCode: 400 }); }
465
- const result = await registry.writeUploadFile(uploadFileMatch[1], relativePath, request, request.headers["content-length"]);
466
- json(response, 200, result);
467
- return;
468
- }
469
- if (request.method === "POST" && url.pathname === "/api/repositories/uploads") {
470
- requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
471
- json(response, 201, registry.createUpload(await readJsonBody(request)));
472
- return;
473
- }
474
- const uploadCompleteMatch = url.pathname.match(/^\/api\/repositories\/uploads\/(upload_[a-f0-9]{20})\/complete$/);
475
- if (request.method === "POST" && uploadCompleteMatch) {
476
- requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
477
- if (liveSession?.active) throw Object.assign(new Error("End the active live session before changing repositories"), { statusCode:409 });
478
- const repository = registry.finishUpload(uploadCompleteMatch[1]);
479
- json(response, 200, { repository: hosted ? hostedRepository(repository) : repository });
480
- return;
481
- }
482
- const uploadAbortMatch = url.pathname.match(/^\/api\/repositories\/uploads\/(upload_[a-f0-9]{20})$/);
483
- if (request.method === "DELETE" && uploadAbortMatch) {
484
- requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
485
- json(response, 200, { aborted: registry.abortUpload(uploadAbortMatch[1]) });
486
- return;
487
- }
488
471
  if (request.method === "POST" && url.pathname === "/api/repositories/select") {
489
472
  requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
490
473
  if (activeMutation) throw Object.assign(new Error(`Operation '${activeMutation.operation}' is still running`), { statusCode: 409 });
@@ -499,14 +482,26 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
499
482
  requireMutationAuth(request, hosted ? publicOrigins : origin, csrfToken);
500
483
  const body = await readJsonBody(request);
501
484
  const operation = url.pathname.slice("/api/operations/".length);
502
- if (operation === "connect-github") {
503
- if (liveSession?.active) throw Object.assign(new Error("End the active live session before changing repositories"), { statusCode:409 });
504
- const job = startJob(operation, (progress) => registry.cloneGithub(body.repository, progress), null);
485
+ // A website audit needs no repository: it is read-only against a URL and writes a capture.
486
+ if (operation === "audit") {
487
+ let target;
488
+ try { target = new URL(String(body.url || "")); } catch { throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 }); }
489
+ if (!/^https?:$/.test(target.protocol)) throw Object.assign(new Error("Audit needs a valid http(s) URL"), { statusCode: 400 });
490
+ const pages = Math.max(1, Math.min(20, Number(body.pages) || 6));
491
+ const job = startJob(operation, async (progress) => {
492
+ const { auditWebSite } = await import("./web-audit.js");
493
+ progress({ phase: "runtime", text: `Opening ${target.href} read-only (up to ${pages} pages, nothing will be clicked)` });
494
+ const summary = await auditWebSite({
495
+ url: target.href, pages, delayMs: 750, capturesDir: captureRoot(),
496
+ onPage: (page, n) => progress({ phase: "explore", text: `Audited ${page.url} — ${page.findings.length} finding(s)`, current: n, total: pages }),
497
+ });
498
+ return hosted ? hostedPayload(summary) : summary;
499
+ }, null);
505
500
  json(response, 202, { job: publicJob(job, { hosted }) });
506
501
  return;
507
502
  }
508
503
  const root = registry.currentRoot();
509
- if (!root) throw Object.assign(new Error("Connect a local folder or GitHub repository first"), { statusCode: 409 });
504
+ if (!root) throw Object.assign(new Error("Open a repository first: tapp app /path/to/repo"), { statusCode: 409 });
510
505
  const repositoryId = registry.current().id;
511
506
  const job = startJob(operation, async (progress) => {
512
507
  const engine = await import("./index.js");
@@ -608,21 +603,6 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
608
603
  onStatus: (text) => progress({ phase: "runtime", text }),
609
604
  });
610
605
  }
611
- if (operation === "review") return reviewProductPlan({ projectDir: root, approve: body.approve || [], reject: body.reject || [], defer: body.defer || [] });
612
- if (operation === "generate") return generateProductPlan({ projectDir: root });
613
- if (operation === "validate") {
614
- const selected = selectedTarget(root, body);
615
- const prepared = await prepareProductTarget({ projectDir: root, platform: selected.platform, target: selected.id, buildIos: engine.buildAppForSim, installIos: engine.installAppOnBootedSim, buildAndroid: engine.buildAndroidApp, onProgress: progress });
616
- return validateProductPlan({
617
- projectDir: root, items: body.items || [], platform: selected.platform, target: selected.id,
618
- url: prepared.runtime.url || "", bundleId: prepared.runtime.bundleId || "", appId: prepared.runtime.appId || "", apkPath: prepared.runtime.apkPath || "", serial: runtime.serial,
619
- timeout: runtime.timeout, testEmail: runtime.testEmail, testPassword: runtime.testPassword,
620
- startWebTarget: engine.startManagedWebTarget, stopWebTarget: engine.stopManagedWebTarget, onProgress: progress,
621
- });
622
- }
623
- if (operation === "promote") return promoteProductPlan({ projectDir: root, items: body.items || [] });
624
- if (operation === "ci-preview") return prepareProductCi({ projectDir: root, actionRef: body.actionRef, defaultBranch: body.defaultBranch || "main" });
625
- if (operation === "ci-install") return installProductCi({ projectDir: root, actionRef: body.actionRef, defaultBranch: body.defaultBranch || "main", replace: body.replace === true, allowUnresolved: body.allowUnresolved === true });
626
606
  if (operation === "gate") {
627
607
  const selected = selectedTarget(root, body);
628
608
  const prepared = await prepareProductTarget({ projectDir: root, platform: selected.platform, target: selected.id, buildIos: engine.buildAppForSim, buildAndroid: engine.buildAndroidApp, onProgress: progress });
@@ -632,14 +612,6 @@ export async function startBrowserProduct({ projectDir, port = 0, launch = false
632
612
  actions: runtime.maxActions, timeout: runtime.timeout, baseline: body.baseline || "", testEmail: runtime.testEmail, testPassword: runtime.testPassword, onProgress: progress,
633
613
  });
634
614
  }
635
- if (operation === "baseline") {
636
- const project = readProductProject({ projectDir: root });
637
- const run = project.evidence.find((item) => item.id === body.runId);
638
- if (!run?.reportPath) throw new Error("Select a completed local gate run before creating a baseline");
639
- const platform = run.report?.platform || String(body.platform || "").toLowerCase();
640
- const target = run.report?.targetKey || body.target || "";
641
- return createProductBaseline({ projectDir: root, reportPath: run.reportPath, platform, target, replace: body.replace === true });
642
- }
643
615
  throw new Error(`Unsupported product operation '${operation}'`);
644
616
  }, repositoryId);
645
617
  json(response, 202, { job: publicJob(job, { hosted }) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
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",
@@ -96,7 +96,7 @@
96
96
  "mobile"
97
97
  ],
98
98
  "scripts": {
99
- "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/cloud-runner.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
99
+ "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
100
100
  "test:browser-journey": "node --test tests/browser-journey.test.js",
101
101
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
102
102
  }