@deeeed/metamask-harness 0.17.3 → 0.17.5
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/CHANGELOG.md +6 -96
- package/README.md +136 -96
- package/adapters/extension/console-tail.mjs +24 -51
- package/adapters/extension/ensure-browser.sh +7 -1
- package/adapters/extension/inject.mjs +15 -5
- package/adapters/extension/launch-browser.cjs +4 -3
- package/adapters/extension/launch.sh +11 -8
- package/adapters/extension/lib/chrome-args.cjs +24 -0
- package/adapters/extension/live.sh +1 -2
- package/adapters/extension/reattach.sh +0 -1
- package/adapters/extension/seed-fixture.sh +12 -4
- package/adapters/extension/sidepanel-toggle.sh +1 -4
- package/adapters/extension/start-watch.sh +4 -17
- package/adapters/extension/stop-viewers.sh +1 -1
- package/adapters/extension/verify.sh +1 -1
- package/adapters/manifest.json +45 -53
- package/adapters/mobile/bridge-runtime/cdp-bridge.cjs +0 -16
- package/adapters/mobile/bridge-runtime/console-forwarder.cjs +1 -1
- package/adapters/mobile/bridge-runtime/lib/match-bridge-target.cjs +1 -3
- package/adapters/mobile/bridge-runtime/lib/target-discovery.cjs +3 -2
- package/adapters/mobile/cleanup.sh +176 -16
- package/adapters/mobile/inject.sh +671 -90
- package/adapters/mobile/overlay/app/dev-tools/AgenticService/AgentStepHud.tsx.patch +185 -0
- package/adapters/mobile/overlay/app/dev-tools/AgenticService/AgenticService.ts.patch +1662 -0
- package/adapters/mobile/overlay/compat/README.md +28 -0
- package/adapters/mobile/overlay/compat/rn81-message-event-source.patch +42 -0
- package/adapters/mobile/start-metro.sh +41 -0
- package/adapters/mobile/verify.sh +61 -4
- package/adapters/mobile/wait-for-bridge.sh +8 -22
- package/adapters/shared/harness-source-fingerprint.mjs +49 -0
- package/adapters/shared/install-repo-deps.sh +1 -5
- package/adapters/shared/open-debug.mjs +184 -103
- package/adapters/shared/resolve-farmslot-ports-core.mjs +3 -0
- package/adapters/shared/resolve-farmslot-ports.mjs +5 -0
- package/adapters/shared/resolve-farmslot-ports.sh +7 -0
- package/adapters/shared/resolve-slot-ports-core.mjs +6 -0
- package/adapters/shared/resolve-slot-ports.sh +7 -2
- package/bin/mm-harness +0 -7
- package/dist/adapters/extension/harness-freshness.js +39 -0
- package/dist/adapters/extension/runtime-decision.js +4 -73
- package/dist/adapters/extension/surface.js +2 -3
- package/dist/adapters/mobile/perps-env.js +3 -43
- package/dist/adapters/mobile/prepare.js +7 -22
- package/dist/adapters/mobile/source-freshness.js +26 -41
- package/dist/adapters/mobile/surface.js +1 -1
- package/dist/adapters/resolve-slot-ports.js +2 -0
- package/dist/adapters/slot-ports.js +0 -16
- package/dist/adapters.js +5 -12
- package/dist/cli-commands.js +1 -1
- package/dist/cli.js +12 -6
- package/dist/commands/call.js +22 -56
- package/dist/commands/check.js +3 -9
- package/dist/commands/checklist.js +4 -1
- package/dist/commands/debug.js +31 -38
- package/dist/commands/device-target.js +12 -27
- package/dist/commands/doctor.js +23 -77
- package/dist/commands/fixtures.js +17 -27
- package/dist/commands/launch/extension.js +2 -0
- package/dist/commands/launch/index.js +59 -167
- package/dist/commands/logs.js +6 -8
- package/dist/commands/manifest.js +25 -151
- package/dist/commands/parse-args.js +0 -2
- package/dist/commands/provision.js +3 -10
- package/dist/commands/run-engine.js +69 -71
- package/dist/commands/run-report.js +3 -12
- package/dist/commands/run.js +35 -245
- package/dist/commands/shared.js +3 -55
- package/dist/commands/status-probe.js +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/stop.js +2 -7
- package/dist/commands/update.js +28 -16
- package/dist/doctor.js +4 -1
- package/dist/harness.js +134 -43
- package/dist/heal-bounds.js +1 -1
- package/dist/live-adapter-contract.js +20 -6
- package/dist/mm-harness-cli.js +48 -123
- package/dist/paths.js +5 -2
- package/dist/runner.js +2 -37
- package/dist/runtime-context.js +8 -26
- package/docs/ADAPTER-SURFACE.md +112 -19
- package/docs/CHEATSHEET.md +52 -39
- package/docs/CLI-SPEC.md +1098 -0
- package/docs/CODE-MAP.md +1 -1
- package/docs/DEBUG-HANDOVER.md +36 -0
- package/docs/MENTAL-MODEL.md +295 -0
- package/docs/UX-PRINCIPLES.md +1 -3
- package/docs/architecture.md +375 -65
- package/docs/live-adapter-contract.md +2 -4
- package/docs/recipe-libraries.md +275 -45
- package/library/README.md +0 -4
- package/library/actions/core/perps/_controller.mjs +55 -10
- package/library/actions/mobile/platform/bridge.mjs +1 -5
- package/library/manifests/core.action-manifest.json +7 -7
- package/library/manifests/mobile.action-manifest.json +3 -28
- package/package.json +1 -4
- package/adapters/extension/launch-webpack.cjs +0 -83
- package/adapters/extension/stamp-runtime-title.cjs +0 -49
- package/adapters/extension/sync-webpack-dist.cjs +0 -105
- package/adapters/mobile/launch-console-forwarder.cjs +0 -39
- package/adapters/mobile/start-console-forwarder.sh +0 -70
- package/adapters/shared/update-check-worker.mjs +0 -35
- package/dist/adapters/extension/console-capture.js +0 -93
- package/dist/command-contract.js +0 -441
- package/dist/command-journal.js +0 -225
- package/dist/commands/last.js +0 -52
- package/dist/json-stream.js +0 -57
- package/dist/run-diagnostics.js +0 -261
- package/docs/CLI-ERGONOMICS-AUDIT.md +0 -32
- package/docs/CLI-ERGONOMICS-HUMAN-QA.md +0 -64
- package/docs/VIDEO-DEMO-VALIDATION.md +0 -74
- package/library/recipes/runner/smoke.core.recipe.json +0 -27
- package/library/recipes/wallet/smoke.extension.recipe.json +0 -42
- package/library/recipes/wallet/smoke.mobile.recipe.json +0 -42
- package/scripts/validate-human-outcomes.mjs +0 -169
|
@@ -1,36 +1,196 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# cleanup.sh — remove the mobile harness overlay from a checkout
|
|
3
|
+
#
|
|
4
|
+
# Purpose:
|
|
5
|
+
# Restores backed-up product files (full installs), removes exactly the
|
|
6
|
+
# .git/info/exclude entries the install recorded, then deletes the harness
|
|
7
|
+
# dir and backup store. Metadata-only installs remove metadata alone.
|
|
8
|
+
#
|
|
9
|
+
# Inputs (flags / env):
|
|
10
|
+
# --target <metamask-mobile> (default $PWD)
|
|
11
|
+
# --allow-managed-changes skip the managed-hash refusal
|
|
12
|
+
# env RECIPE_HARNESS_ROOT
|
|
13
|
+
#
|
|
14
|
+
# Outputs:
|
|
15
|
+
# Removes <harness>/ and backup dir; restores managed product paths.
|
|
16
|
+
# Exit 0 — cleaned; 1 — no backup state / changed managed paths refusal /
|
|
17
|
+
# missing backup; 2 — bad args.
|
|
18
|
+
#
|
|
19
|
+
# Never touches: product files other than the recorded managed paths;
|
|
20
|
+
# .git/info/exclude lines it did not record; product-local cache dirs.
|
|
3
21
|
set -euo pipefail
|
|
4
22
|
|
|
5
23
|
TARGET="$PWD"
|
|
24
|
+
ALLOW_MANAGED_CHANGES=false
|
|
6
25
|
while [ "$#" -gt 0 ]; do
|
|
7
26
|
case "$1" in
|
|
8
|
-
--target)
|
|
9
|
-
-
|
|
27
|
+
--target) TARGET="$2"; shift 2 ;;
|
|
28
|
+
--allow-managed-changes) ALLOW_MANAGED_CHANGES=true; shift ;;
|
|
29
|
+
-h|--help) echo "Usage: cleanup.sh [--target <metamask-mobile>] [--allow-managed-changes]"; exit 0 ;;
|
|
10
30
|
*) echo "Unknown arg: $1" >&2; exit 2 ;;
|
|
11
31
|
esac
|
|
12
32
|
done
|
|
13
33
|
|
|
14
34
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
-
|
|
16
|
-
|
|
35
|
+
TARGET="$(cd "$TARGET" && pwd)"
|
|
36
|
+
# shellcheck disable=SC1091
|
|
37
|
+
. "$SCRIPT_DIR/../shared/hash-helpers.sh"
|
|
38
|
+
# shellcheck disable=SC1091
|
|
39
|
+
for _hp in "$SCRIPT_DIR/../shared/harness-path.sh"; do
|
|
40
|
+
[ -f "$_hp" ] && { . "$_hp"; break; }
|
|
41
|
+
done
|
|
42
|
+
unset _hp
|
|
43
|
+
if ! command -v harness_root >/dev/null 2>&1; then
|
|
44
|
+
echo "mm-harness: shared lib adapters/shared/harness-path.sh not found; reinstall the runner." >&2
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
17
47
|
HARNESS_DIR="$(harness_dir "$TARGET" mobile)"
|
|
18
48
|
|
|
49
|
+
# A console-forwarder left running would keep polling for this checkout's Metro
|
|
50
|
+
# after cleanup orphans it; stop any forwarder scoped to this checkout first.
|
|
19
51
|
pkill -f "console-forwarder.cjs --port .* --out $TARGET/" 2>/dev/null || true
|
|
52
|
+
if GIT_BACKUP_PATH="$(git -C "$TARGET" rev-parse --git-path recipe-harness/mobile/backup 2>/dev/null)"; then
|
|
53
|
+
case "$GIT_BACKUP_PATH" in
|
|
54
|
+
/*) BACKUP_DIR="$GIT_BACKUP_PATH" ;;
|
|
55
|
+
*) BACKUP_DIR="$TARGET/$GIT_BACKUP_PATH" ;;
|
|
56
|
+
esac
|
|
57
|
+
else
|
|
58
|
+
BACKUP_DIR="$HARNESS_DIR/backup-store"
|
|
59
|
+
fi
|
|
60
|
+
if [ ! -f "$BACKUP_DIR/state.env" ] && [ -f "$HARNESS_DIR/backup/state.env" ]; then
|
|
61
|
+
BACKUP_DIR="$HARNESS_DIR/backup"
|
|
62
|
+
fi
|
|
63
|
+
STATE_FILE="$BACKUP_DIR/state.env"
|
|
64
|
+
|
|
65
|
+
remove_recorded_git_exclude_entries() {
|
|
66
|
+
local tracking_file="$1"
|
|
67
|
+
[ -s "$tracking_file" ] || return 0
|
|
68
|
+
local git_dir exclude_file tmp_file
|
|
69
|
+
if ! git_dir="$(git -C "$TARGET" rev-parse --git-dir 2>/dev/null)"; then
|
|
70
|
+
return 0
|
|
71
|
+
fi
|
|
72
|
+
case "$git_dir" in
|
|
73
|
+
/*) ;;
|
|
74
|
+
*) git_dir="$TARGET/$git_dir" ;;
|
|
75
|
+
esac
|
|
76
|
+
exclude_file="$git_dir/info/exclude"
|
|
77
|
+
[ -f "$exclude_file" ] || return 0
|
|
78
|
+
# Remove only the lines THIS install recorded, one occurrence per distinct
|
|
79
|
+
# ledger entry (the appended copy is the last match), so a pre-existing
|
|
80
|
+
# duplicate copy or a stale/duplicate ledger entry never drops a line we did
|
|
81
|
+
# not add this run.
|
|
82
|
+
tmp_file="$(mktemp)"
|
|
83
|
+
awk '
|
|
84
|
+
NR==FNR { if (length($0)) want[$0]=1; next }
|
|
85
|
+
{ lines[++n]=$0; if ($0 in want) last[$0]=n }
|
|
86
|
+
END { for (k in last) drop[last[k]]=1; for (i=1;i<=n;i++) if (!(i in drop)) print lines[i] }
|
|
87
|
+
' "$tracking_file" "$exclude_file" > "$tmp_file"
|
|
88
|
+
mv "$tmp_file" "$exclude_file"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if [ -f "$HARNESS_DIR/manifest.json" ] && node -e '
|
|
92
|
+
const fs = require("fs");
|
|
93
|
+
const manifest = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
|
94
|
+
process.exit(manifest.installMode === "product-owned" ? 0 : 1);
|
|
95
|
+
' "$HARNESS_DIR/manifest.json" 2>/dev/null; then
|
|
96
|
+
remove_recorded_git_exclude_entries "$HARNESS_DIR/added-git-exclude"
|
|
97
|
+
rm -rf "$HARNESS_DIR"
|
|
98
|
+
echo "Cleaned mobile recipe harness metadata from $TARGET (product-owned in-app bridge files left untouched)"
|
|
99
|
+
exit 0
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
if [ ! -f "$STATE_FILE" ]; then
|
|
103
|
+
if [ -f "$HARNESS_DIR/manifest.json" ] && node -e '
|
|
104
|
+
const fs = require("fs");
|
|
105
|
+
const manifest = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
|
106
|
+
process.exit(manifest.installMode === "product-owned" ? 0 : 1);
|
|
107
|
+
' "$HARNESS_DIR/manifest.json" 2>/dev/null; then
|
|
108
|
+
remove_recorded_git_exclude_entries "$HARNESS_DIR/added-git-exclude"
|
|
109
|
+
rm -rf "$HARNESS_DIR"
|
|
110
|
+
echo "Cleaned mobile recipe harness metadata from $TARGET (product-owned in-app bridge files left untouched)"
|
|
111
|
+
exit 0
|
|
112
|
+
fi
|
|
113
|
+
echo "No mobile harness backup found at $STATE_FILE" >&2
|
|
114
|
+
exit 1
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
while IFS= read -r _line || [ -n "$_line" ]; do
|
|
118
|
+
[[ "$_line" =~ ^[[:space:]]*(#|$) ]] && continue
|
|
119
|
+
_key="${_line%%=*}"
|
|
120
|
+
_val="${_line#*=}"
|
|
121
|
+
case "$_key" in
|
|
122
|
+
AGENTIC_SERVICE_EXISTED|PACKAGE_JSON_EXISTED|NAVIGATION_SERVICE_EXISTED|APP_TSX_EXISTED) ;;
|
|
123
|
+
*) continue ;;
|
|
124
|
+
esac
|
|
125
|
+
export "$_key=$_val"
|
|
126
|
+
done < "$STATE_FILE"
|
|
127
|
+
unset _line _key _val
|
|
128
|
+
|
|
129
|
+
HASH_FILE="$BACKUP_DIR/managed-hashes.tsv"
|
|
130
|
+
|
|
131
|
+
verify_managed_paths_unchanged() {
|
|
132
|
+
if [ ! -f "$HASH_FILE" ]; then
|
|
133
|
+
cat >&2 <<EOF
|
|
134
|
+
Refusing cleanup: no managed hash file found at $HASH_FILE.
|
|
135
|
+
Re-run mobile harness install from the current runner to refresh safety metadata, or restore manually.
|
|
136
|
+
EOF
|
|
137
|
+
exit 1
|
|
138
|
+
fi
|
|
139
|
+
local rel expected actual conflicts=0
|
|
140
|
+
while IFS=$'\t' read -r rel expected; do
|
|
141
|
+
[ -n "$rel" ] || continue
|
|
142
|
+
actual="$(hash_path "$rel")"
|
|
143
|
+
if [ "$actual" != "$expected" ]; then
|
|
144
|
+
echo "Refusing cleanup: managed harness path changed after install: $rel" >&2
|
|
145
|
+
echo " expected: $expected" >&2
|
|
146
|
+
echo " actual: $actual" >&2
|
|
147
|
+
conflicts=1
|
|
148
|
+
fi
|
|
149
|
+
done < "$HASH_FILE"
|
|
150
|
+
if [ "$conflicts" != "0" ]; then
|
|
151
|
+
cat >&2 <<EOF
|
|
152
|
+
Cleanup would restore backups over files that changed after harness install.
|
|
153
|
+
Save/stash those changes, rerun harness install to refresh managed hashes, or restore manually.
|
|
154
|
+
EOF
|
|
155
|
+
exit 1
|
|
156
|
+
fi
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if [ "$ALLOW_MANAGED_CHANGES" != "true" ]; then
|
|
160
|
+
verify_managed_paths_unchanged
|
|
161
|
+
else
|
|
162
|
+
echo "Allowing cleanup over changed managed harness paths."
|
|
163
|
+
fi
|
|
20
164
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if [ -
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mv "$tmp_file" "$exclude_file"
|
|
165
|
+
restore_path() {
|
|
166
|
+
local rel="$1"
|
|
167
|
+
local existed="$2"
|
|
168
|
+
local target_path="$TARGET/$rel"
|
|
169
|
+
local backup_path="$BACKUP_DIR/$rel"
|
|
170
|
+
if [ "$existed" = "1" ]; then
|
|
171
|
+
if [ ! -e "$backup_path" ]; then
|
|
172
|
+
echo "Missing backup for $rel at $backup_path" >&2
|
|
173
|
+
exit 1
|
|
31
174
|
fi
|
|
175
|
+
rm -rf "$target_path"
|
|
176
|
+
mkdir -p "$(dirname "$target_path")"
|
|
177
|
+
cp -a "$backup_path" "$target_path"
|
|
178
|
+
else
|
|
179
|
+
rm -rf "$target_path"
|
|
32
180
|
fi
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
restore_path "app/dev-tools/AgenticService" "${AGENTIC_SERVICE_EXISTED:-0}"
|
|
184
|
+
if [ "${PACKAGE_JSON_EXISTED+x}" = "x" ]; then
|
|
185
|
+
restore_path "package.json" "$PACKAGE_JSON_EXISTED"
|
|
33
186
|
fi
|
|
187
|
+
restore_path "app/core/NavigationService/NavigationService.ts" "${NAVIGATION_SERVICE_EXISTED:-0}"
|
|
188
|
+
restore_path "app/components/Nav/App/App.tsx" "${APP_TSX_EXISTED:-0}"
|
|
189
|
+
|
|
190
|
+
remove_recorded_git_exclude_entries "$BACKUP_DIR/added-git-exclude"
|
|
34
191
|
|
|
192
|
+
# Leave any product-local cache dirs alone: they are owned by the product
|
|
193
|
+
# checkout, not the harness.
|
|
35
194
|
rm -rf "$HARNESS_DIR"
|
|
36
|
-
|
|
195
|
+
rm -rf "$BACKUP_DIR"
|
|
196
|
+
echo "Cleaned mobile recipe harness from $TARGET"
|