@deeeed/metamask-harness 0.17.0 → 0.17.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.
- package/CHANGELOG.md +34 -0
- package/README.md +90 -140
- package/adapters/core/cleanup.sh +0 -0
- package/adapters/core/inject.sh +0 -0
- package/adapters/extension/cleanup.mjs +0 -0
- package/adapters/extension/console-tail.mjs +51 -24
- package/adapters/extension/ensure-browser.sh +0 -0
- package/adapters/extension/inject.mjs +5 -9
- package/adapters/extension/launch-browser.cjs +0 -0
- package/adapters/extension/launch-webpack.cjs +83 -0
- package/adapters/extension/launch.sh +8 -11
- package/adapters/extension/live.sh +2 -0
- package/adapters/extension/readiness.mjs +0 -0
- package/adapters/extension/reattach.sh +1 -0
- package/adapters/extension/refresh-build.sh +0 -0
- package/adapters/extension/seed-fixture.sh +4 -12
- package/adapters/extension/sidepanel-toggle.sh +4 -1
- package/adapters/extension/snapshot-dist.sh +0 -0
- package/adapters/extension/stamp-runtime-title.cjs +49 -0
- package/adapters/extension/start-watch.sh +16 -4
- package/adapters/extension/stop-viewers.sh +1 -1
- package/adapters/extension/sync-webpack-dist.cjs +105 -0
- package/adapters/extension/verify.sh +1 -1
- package/adapters/extension/wallet-fixture-state.cjs +0 -0
- package/adapters/manifest.json +46 -38
- package/adapters/mobile/bridge-runtime/cdp-bridge.cjs +0 -0
- package/adapters/mobile/bridge-runtime/console-forwarder.cjs +1 -1
- package/adapters/mobile/bridge-runtime/lib/target-discovery.cjs +2 -3
- package/adapters/mobile/bridge-runtime/setup-wallet.sh +0 -0
- package/adapters/mobile/cleanup.sh +16 -176
- package/adapters/mobile/inject.sh +88 -671
- package/adapters/mobile/launch-console-forwarder.cjs +39 -0
- package/adapters/mobile/lib/metro-listener.sh +0 -0
- package/adapters/mobile/lib/tmux-viewer.sh +0 -0
- package/adapters/mobile/open-device.sh +0 -0
- package/adapters/mobile/prewarm-bundle.sh +0 -0
- package/adapters/mobile/start-console-forwarder.sh +70 -0
- package/adapters/mobile/start-metro.sh +0 -41
- package/adapters/mobile/stop-metro.sh +0 -0
- package/adapters/mobile/verify.sh +4 -61
- package/adapters/mobile/wait-for-bridge.sh +0 -0
- package/adapters/mobile/yarn-setup.sh +0 -0
- package/adapters/shared/activate-repo-node.sh +0 -0
- package/adapters/shared/activate-repo-ruby.sh +0 -0
- package/adapters/shared/cli-ux.sh +0 -0
- package/adapters/shared/ensure-runner-deps.sh +0 -0
- package/adapters/shared/harness-path.sh +0 -0
- package/adapters/shared/hash-helpers.sh +0 -0
- package/adapters/shared/install-repo-deps.sh +0 -0
- package/adapters/shared/json-field.sh +0 -0
- package/adapters/shared/open-debug.mjs +90 -36
- package/adapters/shared/open-log-window.sh +0 -0
- package/adapters/shared/reap-checkout-metros.sh +0 -0
- package/adapters/shared/resolve-slot-ports-core.mjs +0 -6
- package/adapters/shared/resolve-slot-ports.mjs +0 -0
- package/adapters/shared/resolve-slot-ports.sh +0 -5
- package/adapters/shared/sync-wallet-fixture.sh +0 -0
- package/adapters/shared/tmux-session.sh +0 -0
- package/adapters/shared/tmux-viewer.sh +0 -0
- package/adapters/shared/update-check-worker.mjs +37 -0
- package/dist/adapters/extension/console-capture.js +84 -0
- package/dist/adapters/extension/runtime-decision.js +14 -2
- package/dist/adapters/extension/surface.js +3 -2
- package/dist/adapters/mobile/prepare.js +22 -7
- package/dist/adapters/mobile/surface.js +1 -1
- package/dist/adapters/resolve-slot-ports.js +0 -2
- package/dist/adapters/slot-ports.js +8 -0
- package/dist/cli.js +3 -11
- package/dist/commands/call.js +9 -4
- package/dist/commands/debug.js +38 -31
- package/dist/commands/fixtures.js +18 -10
- package/dist/commands/launch/index.js +10 -0
- package/dist/commands/logs.js +8 -6
- package/dist/commands/manifest.js +5 -17
- package/dist/commands/run-engine.js +1 -32
- package/dist/commands/run-report.js +1 -1
- package/dist/commands/run.js +50 -3
- package/dist/commands/status-probe.js +1 -1
- package/dist/commands/update.js +15 -28
- package/dist/doctor.js +1 -4
- package/dist/harness.js +5 -123
- package/dist/live-adapter-contract.js +6 -20
- package/dist/mm-harness-cli.js +6 -43
- package/dist/paths.js +2 -5
- package/dist/run-diagnostics.js +35 -40
- package/dist/runtime-context.js +26 -8
- package/docs/CHEATSHEET.md +39 -52
- package/docs/CLI-ERGONOMICS-HUMAN-QA.md +48 -104
- package/docs/CODE-MAP.md +1 -1
- package/docs/VIDEO-DEMO-VALIDATION.md +62 -0
- package/docs/architecture.md +65 -375
- package/docs/live-adapter-contract.md +3 -1
- package/library/actions/core/perps/_controller.mjs +10 -55
- package/library/manifests/mobile.action-manifest.json +1 -1
- package/package.json +2 -2
- package/scripts/completions.sh +0 -0
- package/scripts/install-completions.sh +0 -0
- package/adapters/mobile/overlay/app/dev-tools/AgenticService/AgentStepHud.tsx.patch +0 -185
- package/adapters/mobile/overlay/app/dev-tools/AgenticService/AgenticService.ts.patch +0 -1662
- package/adapters/mobile/overlay/compat/README.md +0 -28
- package/adapters/mobile/overlay/compat/rn81-message-event-source.patch +0 -42
- package/adapters/shared/resolve-farmslot-ports-core.mjs +0 -3
- package/adapters/shared/resolve-farmslot-ports.mjs +0 -5
- package/adapters/shared/resolve-farmslot-ports.sh +0 -7
- package/docs/CLI-SPEC.md +0 -1142
- package/docs/MENTAL-MODEL.md +0 -295
|
@@ -1,196 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
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.
|
|
2
|
+
# Remove checkout-local Mobile harness metadata without touching product source.
|
|
21
3
|
set -euo pipefail
|
|
22
4
|
|
|
23
5
|
TARGET="$PWD"
|
|
24
|
-
ALLOW_MANAGED_CHANGES=false
|
|
25
6
|
while [ "$#" -gt 0 ]; do
|
|
26
7
|
case "$1" in
|
|
27
|
-
--target) TARGET="$2"; shift 2 ;;
|
|
28
|
-
|
|
29
|
-
-h|--help) echo "Usage: cleanup.sh [--target <metamask-mobile>] [--allow-managed-changes]"; exit 0 ;;
|
|
8
|
+
--target) [ "$#" -ge 2 ] || { echo "Missing value for --target" >&2; exit 2; }; TARGET="$2"; shift 2 ;;
|
|
9
|
+
-h|--help) echo "Usage: cleanup.sh [--target <metamask-mobile>]"; exit 0 ;;
|
|
30
10
|
*) echo "Unknown arg: $1" >&2; exit 2 ;;
|
|
31
11
|
esac
|
|
32
12
|
done
|
|
33
13
|
|
|
34
14
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
15
|
+
. "$SCRIPT_DIR/../shared/harness-path.sh"
|
|
16
|
+
TARGET="$(cd "$TARGET" && pwd -P)"
|
|
47
17
|
HARNESS_DIR="$(harness_dir "$TARGET" mobile)"
|
|
48
18
|
|
|
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.
|
|
51
19
|
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
|
|
164
20
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if [
|
|
172
|
-
|
|
173
|
-
|
|
21
|
+
tracking_file="$HARNESS_DIR/added-git-exclude"
|
|
22
|
+
if [ -s "$tracking_file" ]; then
|
|
23
|
+
git_dir="$(git -C "$TARGET" rev-parse --git-dir 2>/dev/null || true)"
|
|
24
|
+
if [ -n "$git_dir" ]; then
|
|
25
|
+
case "$git_dir" in /*) ;; *) git_dir="$TARGET/$git_dir" ;; esac
|
|
26
|
+
exclude_file="$git_dir/info/exclude"
|
|
27
|
+
if [ -f "$exclude_file" ]; then
|
|
28
|
+
tmp_file="$(mktemp)"
|
|
29
|
+
awk 'NR==FNR { if (length($0)) drop[$0]=1; next } !($0 in drop)' "$tracking_file" "$exclude_file" > "$tmp_file"
|
|
30
|
+
mv "$tmp_file" "$exclude_file"
|
|
174
31
|
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"
|
|
180
32
|
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"
|
|
186
33
|
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"
|
|
191
34
|
|
|
192
|
-
# Leave any product-local cache dirs alone: they are owned by the product
|
|
193
|
-
# checkout, not the harness.
|
|
194
35
|
rm -rf "$HARNESS_DIR"
|
|
195
|
-
|
|
196
|
-
echo "Cleaned mobile recipe harness from $TARGET"
|
|
36
|
+
echo "Cleaned mobile harness metadata from $TARGET; product files were not touched"
|