@aarwitz/tapp 0.35.5 → 0.35.7
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 +13 -1
- package/Harness/OCQAHarnessUITests/ExplorerTests.swift +129 -3
- package/bin/tapp.js +119 -2
- package/browser/app.css +77 -0
- package/browser/app.js +221 -1
- package/browser/index.html +19 -0
- package/browser/product-contract.js +11 -0
- package/browser/view-model.js +185 -0
- package/docs/BROWSER-PRODUCT.md +20 -7
- package/mcp-server/src/android-driver.js +11 -0
- package/mcp-server/src/android-flow.js +46 -9
- package/mcp-server/src/capture-provenance.js +27 -1
- package/mcp-server/src/evidence-retention.js +215 -0
- package/mcp-server/src/flow-recording.js +106 -0
- package/mcp-server/src/flow-runtime.js +47 -3
- package/mcp-server/src/index.js +22 -4
- package/mcp-server/src/macos-flow.js +20 -4
- package/mcp-server/src/sim-recorder.js +273 -0
- package/mcp-server/src/web-explorer.js +13 -1
- package/mcp-server/src/web-flow.js +123 -6
- package/package.json +2 -2
- package/scripts/flow_lib.py +4 -1
- package/skills/tapp/SKILL.md +6 -2
|
@@ -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.35.
|
|
4
|
+
"version": "0.35.7",
|
|
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.35.
|
|
27
|
+
"@aarwitz/tapp@0.35.7",
|
|
28
28
|
"mcp"
|
|
29
29
|
],
|
|
30
30
|
"cwd": "${CLAUDE_PROJECT_DIR}"
|
package/AGENTS.md
CHANGED
|
@@ -58,7 +58,19 @@ Tapp's current action and pointer; the overlay is omitted from evidence screensh
|
|
|
58
58
|
drive the person's existing/default browser profile.
|
|
59
59
|
|
|
60
60
|
The interactive session/record loop is MCP-only (it needs a long-lived process). Flow replay is
|
|
61
|
-
also available in the CLI.
|
|
61
|
+
also available in the CLI.
|
|
62
|
+
|
|
63
|
+
To film an iOS Flow, `tapp run <flow.yml> --record take.mp4 [--hold 3s]` records the simulator and
|
|
64
|
+
writes `take.steps.json` beside it: every step in the video's own seconds, so a cut can be made by
|
|
65
|
+
step name instead of off a contact sheet. `--hold` keeps the last screen on screen for that long —
|
|
66
|
+
it has to be added to the file afterwards, because the simulator records changes rather than
|
|
67
|
+
frames and a motionless screen records nothing. Needs ffmpeg on the machine.
|
|
68
|
+
|
|
69
|
+
A one-time system alert ("Allow notifications", "You have changed the icon") belongs to iOS rather
|
|
70
|
+
than to the app, so a Flow's own `tap:` reaches it only by its exact button label. `alerts: allow`
|
|
71
|
+
or `alerts: dismiss` at the top of an iOS Flow clears whichever one appears and records which
|
|
72
|
+
button was pressed, which is what keeps a journey replayable when the alert shows up on some runs
|
|
73
|
+
and not others. The rest of this playbook assumes the `tapp_*` MCP tools are connected. With
|
|
62
74
|
MCP, the no-bundle-id path is: `tapp_build {projectDir}` (auto-detects + builds +
|
|
63
75
|
installs, returns the bundle id) → `tapp_explore {appBundleId}`.
|
|
64
76
|
|
|
@@ -487,6 +487,74 @@ class ExplorerTests: XCTestCase {
|
|
|
487
487
|
|
|
488
488
|
private var backTitleHistory: [String] = []
|
|
489
489
|
|
|
490
|
+
/// A system alert belongs to SpringBoard, not to the app, so a Flow's `tap: OK` cannot reach it
|
|
491
|
+
/// and the step fails on a button the author can plainly see. A field case: changing an app's
|
|
492
|
+
/// theme switched its icon, iOS asked "You have changed the icon for <app>", and the flow for
|
|
493
|
+
/// that screen stopped after one choice.
|
|
494
|
+
private func systemAlertButton(labelled label: String) -> XCUIElement? {
|
|
495
|
+
let alert = XCUIApplication(bundleIdentifier: "com.apple.springboard").alerts.firstMatch
|
|
496
|
+
guard alert.exists else { return nil }
|
|
497
|
+
// By label, not by subscript: `alert.buttons["Allow"]` matched "Allow Once" on an alert
|
|
498
|
+
// that has no "Allow" at all, so a flow asking for a button that is not there pressed a
|
|
499
|
+
// different one and passed.
|
|
500
|
+
let wanted = alertLabelKey(label)
|
|
501
|
+
return alert.buttons.allElementsBoundByIndex
|
|
502
|
+
.first { alertLabelKey($0.label) == wanted && $0.exists && $0.isHittable }
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/// The labels an `alerts:` setting will press, and nothing else.
|
|
506
|
+
///
|
|
507
|
+
/// Matched through `alertLabelKey`, because iOS writes "Don\u{2019}t Allow" with a typographic
|
|
508
|
+
/// apostrophe: a list spelled with the ASCII one matched nothing at all, the dismiss mode
|
|
509
|
+
/// silently did nothing, and the run still reported a pass (found by running it against Maps).
|
|
510
|
+
private static let alertAllowLabels = ["Allow While Using App", "Allow Once", "Allow", "OK", "Continue"]
|
|
511
|
+
private static let alertDismissLabels = ["Don't Allow", "Not Now", "Cancel", "Dismiss", "Later"]
|
|
512
|
+
|
|
513
|
+
/// Compare alert labels the way a person reads them: either apostrophe, any case.
|
|
514
|
+
private func alertLabelKey(_ label: String) -> String {
|
|
515
|
+
label.replacingOccurrences(of: "\u{2019}", with: "'")
|
|
516
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
517
|
+
.lowercased()
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/// Clear a one-time system alert standing between the flow and the app (TM-497).
|
|
521
|
+
///
|
|
522
|
+
/// Three of the eight takes on 11/7 were re-recorded because of these. Returns the button it
|
|
523
|
+
/// pressed, so the run records that it diverged from the script rather than quietly doing it.
|
|
524
|
+
///
|
|
525
|
+
/// Only a recognised label, or a single-button alert. An unrecognised alert with a choice in it
|
|
526
|
+
/// is left alone and the step fails naming its buttons: guessing on a dialog about permissions,
|
|
527
|
+
/// money or deletion is worse than stopping.
|
|
528
|
+
private func handleSystemAlert(mode: String) -> String? {
|
|
529
|
+
let alert = XCUIApplication(bundleIdentifier: "com.apple.springboard").alerts.firstMatch
|
|
530
|
+
guard alert.exists else { return nil }
|
|
531
|
+
let wanted = (mode == "dismiss" ? Self.alertDismissLabels : Self.alertAllowLabels).map(alertLabelKey)
|
|
532
|
+
let present = alert.buttons.allElementsBoundByIndex
|
|
533
|
+
for key in wanted {
|
|
534
|
+
if let button = present.first(where: { alertLabelKey($0.label) == key && $0.exists && $0.isHittable }) {
|
|
535
|
+
let label = button.label
|
|
536
|
+
button.tap()
|
|
537
|
+
waitForUIStability(timeout: 1.5)
|
|
538
|
+
return label
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if alert.buttons.count == 1 {
|
|
542
|
+
let button = alert.buttons.element(boundBy: 0)
|
|
543
|
+
let label = button.label
|
|
544
|
+
button.tap()
|
|
545
|
+
waitForUIStability(timeout: 1.5)
|
|
546
|
+
return label
|
|
547
|
+
}
|
|
548
|
+
return nil
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/// What a system alert offers, for a failure message that names the way out.
|
|
552
|
+
private func systemAlertButtonLabels() -> [String] {
|
|
553
|
+
let alert = XCUIApplication(bundleIdentifier: "com.apple.springboard").alerts.firstMatch
|
|
554
|
+
guard alert.exists else { return [] }
|
|
555
|
+
return alert.buttons.allElementsBoundByIndex.map { $0.label }.filter { !$0.isEmpty }
|
|
556
|
+
}
|
|
557
|
+
|
|
490
558
|
private func sessionTapById(_ identifier: String) -> String {
|
|
491
559
|
var existedButNotHittable = false
|
|
492
560
|
var existedButDisabled = false
|
|
@@ -773,10 +841,32 @@ class ExplorerTests: XCTestCase {
|
|
|
773
841
|
passF.typeText("\n")
|
|
774
842
|
if formGone(within: 4) { return ("ok", "") }
|
|
775
843
|
|
|
844
|
+
// TM-618: this used to match any button whose name contained one of the keywords, with
|
|
845
|
+
// nothing ruled out. "Continue with Google" contains "continue", so a sign-in step could
|
|
846
|
+
// press it — handing a third-party identity provider a session, which a machine must never
|
|
847
|
+
// do on someone's behalf. Worse, the hand-off makes the app's own form disappear, so the
|
|
848
|
+
// formGone() check above read it as a successful sign-in.
|
|
849
|
+
//
|
|
850
|
+
// MIRROR: these two lists are the Swift copy of NOT_SIGN_IN and SIGN_IN_NAME in
|
|
851
|
+
// mcp-server/src/sign-in.js. tests/sign-in.test.js fails if they drift apart — change both
|
|
852
|
+
// together or the test will tell you.
|
|
853
|
+
let neverSignIn = [
|
|
854
|
+
"forgot", "reset", "recover", "remember", "show password", "hide password", "cancel",
|
|
855
|
+
"go back", "back to", "sign up", "signup", "create account", "create an account",
|
|
856
|
+
"create your account", "register", "get started free", "privacy", "terms", "need help",
|
|
857
|
+
"help?", "continue with", "with google", "with apple", "with facebook", "with github",
|
|
858
|
+
"with microsoft", "single sign", "sso", "close", "dismiss", "skip",
|
|
859
|
+
]
|
|
860
|
+
func isNeverSignIn(_ name: String) -> Bool {
|
|
861
|
+
neverSignIn.contains { name.contains($0) }
|
|
862
|
+
}
|
|
776
863
|
func submitButton() -> XCUIElement? {
|
|
777
864
|
let keywords = ["log in", "login", "sign in", "signin", "continue", "submit", "next", "get started"]
|
|
778
865
|
let buttons = app.buttons.allElementsBoundByIndex.filter { $0.exists }
|
|
779
|
-
|
|
866
|
+
// Rule out the dangerous ones first, then prefer a sign-in name — the same order as
|
|
867
|
+
// the shared rule. A product-named button is handled by the Return key above.
|
|
868
|
+
let usable = buttons.filter { !isNeverSignIn(($0.label + " " + $0.identifier).lowercased()) }
|
|
869
|
+
return usable.first { b in
|
|
780
870
|
let t = (b.label + " " + b.identifier).lowercased()
|
|
781
871
|
return keywords.contains { t.contains($0) }
|
|
782
872
|
}
|
|
@@ -1024,6 +1114,10 @@ class ExplorerTests: XCTestCase {
|
|
|
1024
1114
|
// Per-flow wait default (field issue #20): a splash that prefetches for ~8s makes the
|
|
1025
1115
|
// fixed 6s wait_for fail on a healthy app. Steps may still override individually.
|
|
1026
1116
|
let flowDefaultTimeoutMs = (flow["timeoutMs"] as? Int) ?? (flow["timeout"] as? Int) ?? 6000
|
|
1117
|
+
// `alerts: allow|dismiss` (TM-497). One-time system alerts — "Allow notifications", "You
|
|
1118
|
+
// have changed the icon" — appear on some runs and not others and belong to SpringBoard,
|
|
1119
|
+
// not the app, so without this they stop the flow dead on a screen nobody scripted.
|
|
1120
|
+
let alertMode = ((flow["alerts"] as? String) ?? "").lowercased()
|
|
1027
1121
|
// XCTest runs teardown blocks even when a step aborts unexpectedly. Keep the final
|
|
1028
1122
|
// visible frame inspectable for both successful and failing replays (public issue #26).
|
|
1029
1123
|
addTeardownBlock { [self] in recordFlowScreenshot(name: "flow-final") }
|
|
@@ -1066,6 +1160,16 @@ class ExplorerTests: XCTestCase {
|
|
|
1066
1160
|
var failed = 0
|
|
1067
1161
|
var executed = 0
|
|
1068
1162
|
var aiIndex = 0
|
|
1163
|
+
// TM-497: every step says when it happened, in milliseconds from the flow's start, so a
|
|
1164
|
+
// recording can be cut by step name. The JavaScript runners have carried this since the
|
|
1165
|
+
// first half of the story; iOS has its own loop and did not, which meant the one platform
|
|
1166
|
+
// the demo videos are made on was the one platform whose steps had no times.
|
|
1167
|
+
//
|
|
1168
|
+
// Contiguous by construction: a step starts where the previous one ended, so its window
|
|
1169
|
+
// carries its own settling and waiting — the seconds an editor is looking for.
|
|
1170
|
+
let flowStartedAt = Date()
|
|
1171
|
+
print("OCQA_FLOW_CLOCK:{\"startedAtEpochMs\":\(Int(flowStartedAt.timeIntervalSince1970 * 1000))}")
|
|
1172
|
+
var stepStartMs = 0
|
|
1069
1173
|
for (i, raw) in steps.enumerated() {
|
|
1070
1174
|
let idx = i + 1
|
|
1071
1175
|
executed = idx
|
|
@@ -1078,10 +1182,22 @@ class ExplorerTests: XCTestCase {
|
|
|
1078
1182
|
let timeoutMs = (step["timeoutMs"] as? Int) ?? (step["timeout"] as? Int) ?? flowDefaultTimeoutMs
|
|
1079
1183
|
var status = "pass"
|
|
1080
1184
|
var detail = ""
|
|
1185
|
+
// Before the step, not after: an alert on screen is what makes the step fail.
|
|
1186
|
+
var alertNote = ""
|
|
1187
|
+
if alertMode == "allow" || alertMode == "dismiss", let pressed = handleSystemAlert(mode: alertMode) {
|
|
1188
|
+
alertNote = "a system alert was \(alertMode == "dismiss" ? "dismissed" : "allowed") first: pressed ‘\(escapeJSON(pressed))’"
|
|
1189
|
+
}
|
|
1081
1190
|
|
|
1082
1191
|
switch action {
|
|
1083
1192
|
case "tap":
|
|
1084
|
-
|
|
1193
|
+
var tapStatus = sessionTapById(target)
|
|
1194
|
+
// TM-686: the button really is on screen, it just belongs to SpringBoard.
|
|
1195
|
+
if tapStatus != "ok", let alertButton = systemAlertButton(labelled: target) {
|
|
1196
|
+
alertButton.tap()
|
|
1197
|
+
waitForUIStability(timeout: 1.5)
|
|
1198
|
+
tapStatus = "ok"
|
|
1199
|
+
detail = "‘\(escapeJSON(target))’ is a system alert's button, not the app's"
|
|
1200
|
+
}
|
|
1085
1201
|
status = tapStatus == "ok" ? "pass" : "fail"
|
|
1086
1202
|
if status == "fail" {
|
|
1087
1203
|
// Name which of the three it was. "Disabled" in particular sends the
|
|
@@ -1093,6 +1209,10 @@ class ExplorerTests: XCTestCase {
|
|
|
1093
1209
|
case "not_hittable": detail = "‘\(target)’ exists but could not be reached, even after dismissing the keyboard and scrolling"
|
|
1094
1210
|
default: detail = "could not find ‘\(target)’ on this screen"
|
|
1095
1211
|
}
|
|
1212
|
+
let alertButtons = systemAlertButtonLabels()
|
|
1213
|
+
if !alertButtons.isEmpty {
|
|
1214
|
+
detail += " — a system alert is in the way, offering \(escapeJSON(alertButtons.joined(separator: ", "))); add `alerts: allow` or `alerts: dismiss` to the flow, or tap one of them"
|
|
1215
|
+
}
|
|
1096
1216
|
}
|
|
1097
1217
|
case "type":
|
|
1098
1218
|
status = sessionType(value, id: target.isEmpty ? nil : target) ? "pass" : "fail"
|
|
@@ -1159,7 +1279,13 @@ class ExplorerTests: XCTestCase {
|
|
|
1159
1279
|
let isAssert = action.hasPrefix("assert_")
|
|
1160
1280
|
let taskEvidence = taskName.isEmpty ? "" : ",\"task\":\"\(escapeJSON(taskName))\""
|
|
1161
1281
|
let contractEvidence = contractName.isEmpty ? "" : ",\"contract\":\"\(escapeJSON(contractName))\""
|
|
1162
|
-
|
|
1282
|
+
// Kept whatever the step then did: the first version wrote it into `detail` and the
|
|
1283
|
+
// tap-failure branch overwrote it, so a run that handled an alert and then failed said
|
|
1284
|
+
// nothing about the alert at all.
|
|
1285
|
+
if !alertNote.isEmpty { detail = detail.isEmpty ? alertNote : "\(alertNote); \(detail)" }
|
|
1286
|
+
let stepEndMs = Int(Date().timeIntervalSince(flowStartedAt) * 1000)
|
|
1287
|
+
print("OCQA_FLOW_STEP:{\"index\":\(idx),\"action\":\"\(escapeJSON(action))\",\"target\":\"\(escapeJSON(target.isEmpty ? value : target))\",\"assert\":\(isAssert),\"status\":\"\(status)\",\"detail\":\"\(escapeJSON(detail))\",\"startMs\":\(stepStartMs),\"endMs\":\(stepEndMs)\(taskEvidence)\(contractEvidence)}")
|
|
1288
|
+
stepStartMs = stepEndMs
|
|
1163
1289
|
if status == "fail" {
|
|
1164
1290
|
failed += 1
|
|
1165
1291
|
// Web and Android flows write flow-failure-N.png next to the log; iOS buried the
|
package/bin/tapp.js
CHANGED
|
@@ -26,6 +26,33 @@ import { existingProjectArtifactPath, isProjectArtifactDirectory } from "../mcp-
|
|
|
26
26
|
|
|
27
27
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
28
28
|
const packageRoot = path.resolve(__dirname, "..");
|
|
29
|
+
|
|
30
|
+
// After a run has written its own evidence, remove evidence that is past the retention window
|
|
31
|
+
// (TM-630). Doing it in teardown needs no new command, and a tidy-up problem must never turn a
|
|
32
|
+
// good run bad — hence the swallow.
|
|
33
|
+
// Saving a report means the author is relying on that run, so it is marked to survive the
|
|
34
|
+
// retention window (TM-630). Honouring the mark was useless while nothing wrote it.
|
|
35
|
+
async function keepThisRun(structured, reason) {
|
|
36
|
+
try {
|
|
37
|
+
const { keepRunFor } = await import(path.join(packageRoot, "mcp-server", "src", "evidence-retention.js"));
|
|
38
|
+
const kept = keepRunFor(structured, reason);
|
|
39
|
+
if (kept.kept) console.log(` This run is marked to keep, so clearing out old evidence will not remove it.`);
|
|
40
|
+
} catch { /* marking is a courtesy, never a reason to fail a run */ }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function pruneEvidenceQuietly() {
|
|
44
|
+
try {
|
|
45
|
+
const { pruneEvidence } = await import(path.join(packageRoot, "mcp-server", "src", "evidence-retention.js"));
|
|
46
|
+
const pruned = pruneEvidence();
|
|
47
|
+
if (pruned.removed.length) {
|
|
48
|
+
const { formatStorage } = await import(path.join(packageRoot, "mcp-server", "src", "environment-preflight.js"));
|
|
49
|
+
console.log(`Tidied up: removed ${pruned.removed.length} run${pruned.removed.length === 1 ? "" : "s"} older than ${pruned.keepDays} days, freeing ${formatStorage(pruned.freedBytes)}.`);
|
|
50
|
+
// Tapp cannot know that a path was quoted in a note somewhere else, so say how to keep one.
|
|
51
|
+
console.log(` Keep a run for ever by putting a .tapp-keep file in it; saved reports are marked already.`);
|
|
52
|
+
}
|
|
53
|
+
} catch { /* never fail a run over housekeeping */ }
|
|
54
|
+
}
|
|
55
|
+
|
|
29
56
|
const pkg = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
30
57
|
|
|
31
58
|
// Redirect all writable output away from the (possibly read-only) package dir. TAPP_HOME and
|
|
@@ -1021,6 +1048,7 @@ switch (command) {
|
|
|
1021
1048
|
if (flags.json && typeof flags.json === "string") {
|
|
1022
1049
|
fs.writeFileSync(flags.json, JSON.stringify(r.structured, null, 2));
|
|
1023
1050
|
console.log(`\n📄 Full report JSON: ${flags.json} (pass as --baseline next run to diff regressions)`);
|
|
1051
|
+
await keepThisRun(r.structured, `saved as ${flags.json}`);
|
|
1024
1052
|
}
|
|
1025
1053
|
break;
|
|
1026
1054
|
}
|
|
@@ -1133,6 +1161,7 @@ switch (command) {
|
|
|
1133
1161
|
if (flags.json && typeof flags.json === "string") {
|
|
1134
1162
|
fs.writeFileSync(flags.json, JSON.stringify(r.structured, null, 2));
|
|
1135
1163
|
console.log(`\n📄 Full report JSON: ${flags.json} (pass as --baseline next run to diff regressions)`);
|
|
1164
|
+
await keepThisRun(r.structured, `saved as ${flags.json}`);
|
|
1136
1165
|
}
|
|
1137
1166
|
break;
|
|
1138
1167
|
}
|
|
@@ -1459,7 +1488,7 @@ switch (command) {
|
|
|
1459
1488
|
break;
|
|
1460
1489
|
}
|
|
1461
1490
|
if (!["run", "validate"].includes(verb) || !flowPath) {
|
|
1462
|
-
console.error("usage: tapp validate --example\n tapp flow steps [--json]\n tapp run <flow.yml|glob> [...more] [--var NAME=VALUE ...] [--platform ios|android|web] [--actor NAME] [--email VALUE] [--password VALUE] [--url URL] [--app-id ID] [--apk FILE] [--serial ID]\n tapp validate <flow.yml|glob> [...more]\n Several Flows (or a glob) run in sequence and print one line per Flow; exit 1 if any failed.");
|
|
1491
|
+
console.error("usage: tapp validate --example\n tapp flow steps [--json]\n tapp run <flow.yml|glob> [...more] [--var NAME=VALUE ...] [--platform ios|android|web] [--actor NAME] [--email VALUE] [--password VALUE] [--url URL] [--app-id ID] [--apk FILE] [--serial ID] [--record out.mp4 [--hold 3s]]\n tapp validate <flow.yml|glob> [...more]\n Several Flows (or a glob) run in sequence and print one line per Flow; exit 1 if any failed.");
|
|
1463
1492
|
process.exit(2);
|
|
1464
1493
|
}
|
|
1465
1494
|
// Several Flows in one command (field issue #9): the shell usually expands the glob, but a
|
|
@@ -1619,10 +1648,81 @@ switch (command) {
|
|
|
1619
1648
|
requireMacFor("iOS Flow replay");
|
|
1620
1649
|
invocation = ["bash", [path.join(packageRoot, "scripts", "run-flow.sh"), absolute, typeof flags["bundle-id"] === "string" ? flags["bundle-id"] : flow.app || ""]];
|
|
1621
1650
|
}
|
|
1651
|
+
// --record / --hold (TM-497). tapp owns the recorder so the video and the step times come out
|
|
1652
|
+
// of the same run; before this the wrapper started simctl by hand and the two clocks drifted.
|
|
1653
|
+
const recordTo = typeof flags.record === "string" && flags.record ? path.resolve(flags.record) : "";
|
|
1654
|
+
let holdMs = 0;
|
|
1655
|
+
let recorder = null;
|
|
1656
|
+
if (recordTo || flags.hold !== undefined) {
|
|
1657
|
+
const { parseHold } = await import(path.join(packageRoot, "mcp-server", "src", "flow-recording.js"));
|
|
1658
|
+
try { holdMs = parseHold(flags.hold === true ? "" : flags.hold); }
|
|
1659
|
+
catch (error) { console.error(`❌ ${error.message}`); process.exit(2); }
|
|
1660
|
+
}
|
|
1661
|
+
if (recordTo) {
|
|
1662
|
+
if (platform !== "ios") { console.error(`❌ --record records an iOS simulator (this Flow is ${platform})`); process.exit(2); }
|
|
1663
|
+
const { prepareRecorder, recorderToolingError, startRecording } = await import(path.join(packageRoot, "mcp-server", "src", "sim-recorder.js"));
|
|
1664
|
+
const missing = recorderToolingError();
|
|
1665
|
+
if (missing) { console.error(`❌ ${missing}`); process.exit(2); }
|
|
1666
|
+
const ready = prepareRecorder(env.TAPP_UDID);
|
|
1667
|
+
if (!ready.ok) { console.error(`❌ ${ready.error}`); process.exit(2); }
|
|
1668
|
+
// One line, because a repair nobody is told about costs the same three re-records next time.
|
|
1669
|
+
for (const note of ready.repaired) console.log(` recorder: ${note}`);
|
|
1670
|
+
recorder = startRecording({ udid: env.TAPP_UDID, out: recordTo, holdMs });
|
|
1671
|
+
// The recorder marks itself on a still screen; the flow must not start before that mark, or
|
|
1672
|
+
// the first change in the file is the app moving and the whole clock is wrong.
|
|
1673
|
+
await recorder.ready();
|
|
1674
|
+
}
|
|
1675
|
+
const flowStartedAtMs = Date.now();
|
|
1622
1676
|
const result = spawnSync(invocation[0], invocation[1], { stdio: "inherit", env });
|
|
1677
|
+
if (recorder) {
|
|
1678
|
+
const stopped = await recorder.stop();
|
|
1679
|
+
if (!stopped.ok) {
|
|
1680
|
+
console.error(`\n⚠️ ${stopped.error}`);
|
|
1681
|
+
} else {
|
|
1682
|
+
const { flowStartedAtEpochMs, parseFlowSteps, writeStepsSidecar } = await import(path.join(packageRoot, "mcp-server", "src", "flow-recording.js"));
|
|
1683
|
+
const logText = fs.existsSync(flowLog) ? fs.readFileSync(flowLog, "utf8") : "";
|
|
1684
|
+
const steps = parseFlowSteps(logText);
|
|
1685
|
+
// The runner's own start, not this process's: on iOS most of a minute passes building and
|
|
1686
|
+
// launching the harness while the recorder is already rolling, and using the CLI's clock
|
|
1687
|
+
// puts every step that far too early in the video.
|
|
1688
|
+
const startedAt = flowStartedAtEpochMs(logText) ?? flowStartedAtMs;
|
|
1689
|
+
// The recorder writes a frame when the screen CHANGES, so a flow that ends on a still
|
|
1690
|
+
// screen leaves the file ending before the flow does and the last steps land past its end.
|
|
1691
|
+
// Cloning the final frame covers that gap; the hold comes on top of it. This happens
|
|
1692
|
+
// before the sidecar is written so the sidecar can be told the file's real length.
|
|
1693
|
+
const { padTail, tailMsFor } = await import(path.join(packageRoot, "mcp-server", "src", "sim-recorder.js"));
|
|
1694
|
+
const { stepsInVideoTime } = await import(path.join(packageRoot, "mcp-server", "src", "flow-recording.js"));
|
|
1695
|
+
const placed = stepsInVideoTime(steps, { flowStartedAtMs: startedAt, recordingStartedAtMs: stopped.startedAtMs });
|
|
1696
|
+
const lastStepEndMs = placed.length ? placed[placed.length - 1].end * 1000 : 0;
|
|
1697
|
+
// TAPP_RECORD_DEBUG keeps the capture exactly as simctl wrote it, before any tail is added,
|
|
1698
|
+
// and prints the two clocks. This is what a report of "the step times are wrong" needs:
|
|
1699
|
+
// every timing bug found while building this was invisible in the finished file.
|
|
1700
|
+
if (process.env.TAPP_RECORD_DEBUG === "1") {
|
|
1701
|
+
fs.copyFileSync(recordTo, `${recordTo}.raw.mp4`);
|
|
1702
|
+
console.error(`[record] capture ${(stopped.durationMs / 1000).toFixed(3)}s, ${stopped.frames} frames, first frame at ${stopped.startedAtMs}, flow started at ${startedAt} (+${((startedAt - stopped.startedAtMs) / 1000).toFixed(3)}s), last step ends ${(lastStepEndMs / 1000).toFixed(3)}s`);
|
|
1703
|
+
console.error(`[record] capture kept unpadded at ${recordTo}.raw.mp4`);
|
|
1704
|
+
}
|
|
1705
|
+
const held = padTail(recordTo, tailMsFor({ durationMs: stopped.durationMs, lastStepEndMs, holdMs }));
|
|
1706
|
+
if (held.error) console.error(`⚠️ ${held.error}`);
|
|
1707
|
+
const finalMs = held.durationMs ?? stopped.durationMs;
|
|
1708
|
+
// Say how much of the finished file is a held frame rather than captured picture. The
|
|
1709
|
+
// recorder stops writing when the screen stops changing, so the tail is always partly a
|
|
1710
|
+
// clone — a few seconds on a normal run. One take ended its capture 26 seconds before the
|
|
1711
|
+
// flow did and the rest was a single frozen frame, and the finished file gave no sign of
|
|
1712
|
+
// it; anyone editing that would have found out the hard way.
|
|
1713
|
+
const heldMs = Math.max(0, finalMs - stopped.durationMs);
|
|
1714
|
+
const sidecar = writeStepsSidecar(recordTo, steps, {
|
|
1715
|
+
flowStartedAtMs: startedAt, recordingStartedAtMs: stopped.startedAtMs, holdMs,
|
|
1716
|
+
name: flow.name || "", videoDurationMs: finalMs,
|
|
1717
|
+
});
|
|
1718
|
+
console.log(`\nRecording: ${recordTo} (${(finalMs / 1000).toFixed(1)}s — ${(stopped.durationMs / 1000).toFixed(1)}s captured${heldMs > 500 ? `, ${(heldMs / 1000).toFixed(1)}s holding the last screen` : ""})`);
|
|
1719
|
+
console.log(`Step times: ${sidecar.path} (${sidecar.steps.length} step${sidecar.steps.length === 1 ? "" : "s"} in the video's own seconds)`);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1623
1722
|
const evidenceWritten = fs.existsSync(evidenceDir) && fs.readdirSync(evidenceDir).length > 0;
|
|
1624
1723
|
if (evidenceWritten) console.log(`\nEvidence: ${evidenceDir}`);
|
|
1625
1724
|
else console.error("\n⚠️ Evidence unavailable — the platform runner did not write any artifacts for this Flow run.");
|
|
1725
|
+
await pruneEvidenceQuietly();
|
|
1626
1726
|
process.exit(result.status ?? 1);
|
|
1627
1727
|
}
|
|
1628
1728
|
|
|
@@ -1794,6 +1894,7 @@ switch (command) {
|
|
|
1794
1894
|
const result = spawnSync(process.execPath, [path.join(packageRoot, "scripts", "run-web-scenario.js"), absolute, url], { stdio: "inherit", env });
|
|
1795
1895
|
if (fs.existsSync(flowLog)) spawnSync("python3", [path.join(packageRoot, "scripts", "flow_lib.py"), "report", flowLog], { stdio: "inherit" });
|
|
1796
1896
|
console.log(`\nEvidence: ${evidenceDir}`);
|
|
1897
|
+
await pruneEvidenceQuietly();
|
|
1797
1898
|
process.exit(result.status ?? 1);
|
|
1798
1899
|
}
|
|
1799
1900
|
|
|
@@ -1956,7 +2057,7 @@ switch (command) {
|
|
|
1956
2057
|
pyyaml.code === 0 ? sayOk("PyYAML", "importable (YAML Flow replay)") : sayBad("PyYAML", "missing — `python3 -m pip install pyyaml` (YAML Flow replay needs it; JSON Flows work without)");
|
|
1957
2058
|
}
|
|
1958
2059
|
|
|
1959
|
-
const { storagePreflight } = await import(path.join(packageRoot, "mcp-server", "src", "environment-preflight.js"));
|
|
2060
|
+
const { storagePreflight, formatStorage } = await import(path.join(packageRoot, "mcp-server", "src", "environment-preflight.js"));
|
|
1960
2061
|
const storage = storagePreflight(tappHome);
|
|
1961
2062
|
report.disk = { level: storage.level, message: storage.message || null };
|
|
1962
2063
|
if (storage.level === "blocked") { sayBad("Disk space", storage.message); healthy = false; }
|
|
@@ -1964,6 +2065,22 @@ switch (command) {
|
|
|
1964
2065
|
else if (storage.level === "ok") sayOk("Disk space", storage.message);
|
|
1965
2066
|
else say(` ⬜ Disk space — ${storage.message || "could not be checked"}`);
|
|
1966
2067
|
|
|
2068
|
+
// What Tapp itself is holding, next to the machine's free space (TM-630): the disk line alone
|
|
2069
|
+
// let 3.4 GB of our own run evidence go unmentioned for three months.
|
|
2070
|
+
const { evidenceUsage, keepDays, DEFAULT_KEEP_DAYS, formatAge } =
|
|
2071
|
+
await import(path.join(packageRoot, "mcp-server", "src", "evidence-retention.js"));
|
|
2072
|
+
const usage = evidenceUsage();
|
|
2073
|
+
const days = keepDays();
|
|
2074
|
+
report.evidence = { runs: usage.runs, bytes: usage.bytes, keepDays: days };
|
|
2075
|
+
if (!usage.runs) sayOk("Evidence", `none kept yet (${days ? `removed after ${days} days` : "kept for ever"})`);
|
|
2076
|
+
else {
|
|
2077
|
+
const window = days
|
|
2078
|
+
? `removed after ${days} days`
|
|
2079
|
+
: "kept for ever — TAPP_KEEP_EVIDENCE_DAYS is off";
|
|
2080
|
+
say(` ${days ? "✅" : "⚠️ "} Evidence — ${formatStorage(usage.bytes)} in ${usage.runs} run${usage.runs === 1 ? "" : "s"}`
|
|
2081
|
+
+ `${usage.oldestMs ? `, oldest ${formatAge(Date.now() - usage.oldestMs)}` : ""} · ${window}`);
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1967
2084
|
say("\n Platforms:");
|
|
1968
2085
|
if (process.platform === "darwin") {
|
|
1969
2086
|
const xcode = run("xcode-select", ["-p"]);
|
package/browser/app.css
CHANGED
|
@@ -631,3 +631,80 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
|
|
|
631
631
|
|
|
632
632
|
/* A suggestion this Studio cannot start is dimmed, not deleted: pressing it still answers. */
|
|
633
633
|
.prompt-suggestions [data-kind].elsewhere { opacity:.62; }
|
|
634
|
+
|
|
635
|
+
/* ---- Findings and Coverage (TM-794) -------------------------------------------------------
|
|
636
|
+
Findings reads as a short list of kinds a person can scan, each opening onto the individual
|
|
637
|
+
places. Coverage reads left to right, one column per step away from the screen the run
|
|
638
|
+
started on, the way the run actually went. */
|
|
639
|
+
|
|
640
|
+
.run-picker { min-width:240px; max-width:340px; padding:7px 10px; border:1px solid var(--line); border-radius:var(--radius); background:var(--control); color:var(--ink); font-size:11px; }
|
|
641
|
+
|
|
642
|
+
.findings-tally { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:14px; }
|
|
643
|
+
.findings-tally .button-link { margin-top:0; margin-left:auto; }
|
|
644
|
+
.sev-tally { border:1px solid var(--line); border-radius:999px; padding:4px 11px; font-size:11px; font-weight:600; color:var(--muted); background:var(--control); }
|
|
645
|
+
.sev-tally.critical,.sev-tally.high { color:var(--tapp-red); border-color:rgba(248,81,73,.45); background:var(--tapp-red-bg); }
|
|
646
|
+
.sev-tally.medium { color:var(--tapp-amber-soft); border-color:rgba(210,153,34,.45); background:var(--tapp-amber-bg); }
|
|
647
|
+
|
|
648
|
+
.finding-group { border:1px solid var(--line); border-radius:var(--radius); background:var(--paper); margin-bottom:8px; }
|
|
649
|
+
.finding-group>summary { display:flex; align-items:center; gap:10px; padding:12px 14px; cursor:pointer; list-style:none; }
|
|
650
|
+
.finding-group>summary::-webkit-details-marker { display:none; }
|
|
651
|
+
.finding-group>summary::after { content:"▾"; width:14px; text-align:center; color:var(--muted); font-size:11px; line-height:1; transition:transform .12s ease; }
|
|
652
|
+
.finding-group.single { display:flex; align-items:center; gap:10px; padding:12px 14px; }
|
|
653
|
+
.finding-group.single .group-count { color:var(--faint); }
|
|
654
|
+
.finding-group[open]>summary::after { transform:rotate(180deg); }
|
|
655
|
+
.finding-group>summary:hover { background:var(--wash); border-radius:var(--radius); }
|
|
656
|
+
.group-label { flex:1; font-weight:600; font-size:13px; }
|
|
657
|
+
.group-count { color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; }
|
|
658
|
+
.sev-dot { width:8px; height:8px; border-radius:50%; background:var(--faint); flex:none; }
|
|
659
|
+
.sev-dot.critical,.sev-dot.high { background:var(--tapp-red); }
|
|
660
|
+
.sev-dot.medium { background:var(--tapp-amber); }
|
|
661
|
+
.sev-dot.low { background:var(--tapp-text-faint); }
|
|
662
|
+
.finding-group .detail-list { padding:0 18px 14px 34px; }
|
|
663
|
+
.finding-group .detail-list li { margin-bottom:5px; }
|
|
664
|
+
.finding-group .detail-list b { text-transform:uppercase; font-size:9px; letter-spacing:.06em; }
|
|
665
|
+
.detail-list b.sev-critical,.detail-list b.sev-high { color:var(--tapp-red); }
|
|
666
|
+
.detail-list b.sev-medium { color:var(--tapp-amber-soft); }
|
|
667
|
+
|
|
668
|
+
.coverage-counts { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:16px; }
|
|
669
|
+
.coverage-counts span { border:1px solid var(--line); border-radius:999px; padding:5px 12px; font-size:11px; color:var(--muted); background:var(--control); }
|
|
670
|
+
.coverage-counts span b { color:var(--ink); font-size:13px; margin-right:4px; font-variant-numeric:tabular-nums; }
|
|
671
|
+
.coverage-counts .button-link { margin-top:0; margin-left:auto; }
|
|
672
|
+
|
|
673
|
+
.coverage-map { display:flex; gap:22px; align-items:flex-start; overflow-x:auto; padding-bottom:10px; }
|
|
674
|
+
.coverage-column { display:flex; flex-direction:column; gap:14px; flex:none; width:210px; }
|
|
675
|
+
.coverage-column-head { margin:0 0 2px; color:var(--faint); font-size:10px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; }
|
|
676
|
+
|
|
677
|
+
.screen-card { border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--paper); padding:10px; }
|
|
678
|
+
.screen-card.orphan { border-style:dashed; }
|
|
679
|
+
.screen-card strong { display:block; margin-top:9px; font-size:12px; line-height:1.3; }
|
|
680
|
+
.screen-card>small { display:block; margin-top:3px; color:var(--faint); font-size:10px; }
|
|
681
|
+
/* The card is the shape of the thing it is a picture of. A web still forced into a phone's
|
|
682
|
+
portrait box loses its left edge to `cover`, taking the screen's own name with it. */
|
|
683
|
+
.screen-shot { position:relative; aspect-ratio:3/4; border-radius:var(--radius); overflow:hidden; background:var(--wash); display:flex; align-items:center; justify-content:center; }
|
|
684
|
+
.coverage-map[data-platform="web"] .screen-shot,
|
|
685
|
+
.coverage-map[data-platform="macos"] .screen-shot { aspect-ratio:16/10; }
|
|
686
|
+
.coverage-map[data-platform="web"] .coverage-column,
|
|
687
|
+
.coverage-map[data-platform="macos"] .coverage-column { width:260px; }
|
|
688
|
+
.screen-shot img { width:100%; height:100%; object-fit:cover; object-position:top center; }
|
|
689
|
+
.screen-shot-none { color:var(--faint); font-size:10px; }
|
|
690
|
+
.screen-note { position:absolute; left:6px; right:6px; bottom:6px; padding:3px 6px; border-radius:4px; background:rgba(9,12,17,.82); color:var(--tapp-amber-soft); font-size:9px; text-align:center; }
|
|
691
|
+
.screen-exits { margin:9px 0 0; padding:0; list-style:none; display:flex; flex-direction:column; gap:4px; }
|
|
692
|
+
.screen-exits li { color:var(--muted); font-size:10px; line-height:1.35; }
|
|
693
|
+
.screen-exits li span { color:var(--faint); }
|
|
694
|
+
.screen-exits-none { margin:9px 0 0; color:var(--faint); font-size:10px; }
|
|
695
|
+
.coverage-note { margin-top:14px; font-size:11px; }
|
|
696
|
+
|
|
697
|
+
@media (max-width:860px) {
|
|
698
|
+
.coverage-column { width:168px; }
|
|
699
|
+
.run-picker { min-width:0; width:100%; max-width:none; }
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.findings-section { margin-bottom:26px; }
|
|
703
|
+
.findings-section h2 { font-size:14px; margin-bottom:4px; }
|
|
704
|
+
.findings-section h2 i { color:var(--muted); font-style:normal; font-size:12px; font-variant-numeric:tabular-nums; }
|
|
705
|
+
.findings-section>.muted { font-size:11px; margin-bottom:10px; }
|
|
706
|
+
|
|
707
|
+
/* A run with no recorded transitions has no path to lay out, so its screens are a plain grid. */
|
|
708
|
+
.coverage-map.flat { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:16px; overflow-x:visible; }
|
|
709
|
+
.coverage-map.flat[data-platform="web"] { grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); }
|
|
710
|
+
.coverage-map.flat .screen-card { width:auto; }
|