@deeeed/metamask-harness 0.2.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/CHANGELOG.md +161 -0
- package/README.md +140 -0
- package/bin/mm-harness +99 -0
- package/docs/CHEATSHEET.md +61 -0
- package/docs/CLI-SPEC.md +915 -0
- package/docs/MENTAL-MODEL.md +295 -0
- package/docs/architecture.md +367 -0
- package/docs/extension-runtime-commands.md +60 -0
- package/docs/harness-cli.md +43 -0
- package/docs/live-adapter-contract.md +188 -0
- package/docs/package-boundaries.md +47 -0
- package/docs/perps-flow-catalog.md +235 -0
- package/docs/recipe-libraries.md +95 -0
- package/docs/runtime-file-conventions.md +36 -0
- package/library/actions/core/perps/_controller.mjs +727 -0
- package/library/actions/core/perps/assert_orders.mjs +53 -0
- package/library/actions/core/perps/assert_positions.mjs +52 -0
- package/library/actions/core/perps/close_orders.mjs +97 -0
- package/library/actions/core/perps/close_positions.mjs +118 -0
- package/library/actions/core/perps/ensure_orders.mjs +40 -0
- package/library/actions/core/perps/ensure_positions.mjs +37 -0
- package/library/actions/core/perps/place_order.mjs +201 -0
- package/library/actions/core/perps/read_account.mjs +30 -0
- package/library/actions/core/perps/read_orders.mjs +27 -0
- package/library/actions/core/perps/read_positions.mjs +27 -0
- package/library/actions/core/perps/start_state.mjs +92 -0
- package/library/actions/core/perps/teardown_state.mjs +86 -0
- package/library/actions/extension/perps/assert_orders.mjs +11 -0
- package/library/actions/extension/perps/assert_positions.mjs +11 -0
- package/library/actions/extension/perps/close_orders.mjs +8 -0
- package/library/actions/extension/perps/close_positions.mjs +8 -0
- package/library/actions/extension/perps/ensure_orders.mjs +4 -0
- package/library/actions/extension/perps/ensure_positions.mjs +4 -0
- package/library/actions/extension/perps/perps.mjs +730 -0
- package/library/actions/extension/perps/place_order.mjs +7 -0
- package/library/actions/extension/perps/read_orders.mjs +4 -0
- package/library/actions/extension/perps/read_positions.mjs +3 -0
- package/library/actions/extension/platform/cdp.mjs +541 -0
- package/library/actions/extension/ui/navigate.mjs +44 -0
- package/library/actions/extension/wallet/ensure_unlocked.mjs +36 -0
- package/library/actions/extension/wallet/read_state.mjs +27 -0
- package/library/actions/extension/wallet/select_account.mjs +48 -0
- package/library/actions/extension/wallet/setup.mjs +35 -0
- package/library/actions/mobile/app-overlay/app/dev-tools/AgenticService/AgentStepHud.tsx.patch +185 -0
- package/library/actions/mobile/app-overlay/app/dev-tools/AgenticService/AgenticService.ts.patch +1662 -0
- package/library/actions/mobile/bridge-runtime/cdp-bridge.cjs +686 -0
- package/library/actions/mobile/bridge-runtime/lib/cdp-eval.cjs +110 -0
- package/library/actions/mobile/bridge-runtime/lib/config.cjs +39 -0
- package/library/actions/mobile/bridge-runtime/lib/issue-capture.cjs +446 -0
- package/library/actions/mobile/bridge-runtime/lib/target-discovery.cjs +204 -0
- package/library/actions/mobile/bridge-runtime/lib/ws-client.cjs +108 -0
- package/library/actions/mobile/bridge-runtime/setup-wallet.sh +442 -0
- package/library/actions/mobile/perps/assert_orders.mjs +11 -0
- package/library/actions/mobile/perps/assert_positions.mjs +11 -0
- package/library/actions/mobile/perps/close_orders.mjs +8 -0
- package/library/actions/mobile/perps/close_positions.mjs +8 -0
- package/library/actions/mobile/perps/ensure_orders.mjs +4 -0
- package/library/actions/mobile/perps/ensure_positions.mjs +4 -0
- package/library/actions/mobile/perps/perps.mjs +709 -0
- package/library/actions/mobile/perps/place_order.mjs +7 -0
- package/library/actions/mobile/perps/read_orders.mjs +4 -0
- package/library/actions/mobile/perps/read_positions.mjs +3 -0
- package/library/actions/mobile/platform/bridge.mjs +283 -0
- package/library/actions/mobile/ui/navigate.mjs +38 -0
- package/library/actions/mobile/wallet/ensure_unlocked.mjs +107 -0
- package/library/actions/mobile/wallet/home.mjs +35 -0
- package/library/actions/mobile/wallet/read_state.mjs +40 -0
- package/library/actions/mobile/wallet/select_account.mjs +48 -0
- package/library/actions/mobile/wallet/setup.mjs +220 -0
- package/library/flows/perps.flows.json +64 -0
- package/library/library.json +7 -0
- package/library/manifests/core.action-manifest.json +1282 -0
- package/library/manifests/extension.action-manifest.json +1749 -0
- package/library/manifests/mobile.action-manifest.json +1753 -0
- package/library/recipes/action-validation.extension.recipe.json +417 -0
- package/library/recipes/action-validation.mobile.recipe.json +422 -0
- package/library/recipes/order-lifecycle.core.recipe.json +78 -0
- package/library/recipes/perps-lifecycle.recipe.json +194 -0
- package/library/recipes/read-markets.core.recipe.json +38 -0
- package/library/recipes/smoke.extension.recipe.json +31 -0
- package/library/recipes/smoke.mobile.recipe.json +31 -0
- package/library/recipes/trading-lifecycle.core.recipe.json +76 -0
- package/orchestration/compat-overlays/README.md +19 -0
- package/orchestration/compat-overlays/mobile/README.md +13 -0
- package/orchestration/compat-overlays/mobile/rn81-message-event-source.patch +42 -0
- package/orchestration/core/cleanup.sh +37 -0
- package/orchestration/core/inject.sh +154 -0
- package/orchestration/doctor.mjs +72 -0
- package/orchestration/extension/cleanup.mjs +60 -0
- package/orchestration/extension/console-tail.mjs +228 -0
- package/orchestration/extension/ensure-browser.sh +416 -0
- package/orchestration/extension/ensure-ready.ts +185 -0
- package/orchestration/extension/extension-id.ts +107 -0
- package/orchestration/extension/inject.mjs +266 -0
- package/orchestration/extension/launch-browser.cjs +216 -0
- package/orchestration/extension/launch.sh +175 -0
- package/orchestration/extension/live.sh +320 -0
- package/orchestration/extension/pin-remote-flags.cjs +45 -0
- package/orchestration/extension/readiness.mjs +414 -0
- package/orchestration/extension/refresh-build.sh +190 -0
- package/orchestration/extension/runtime-decision.ts +445 -0
- package/orchestration/extension/runtime.ts +407 -0
- package/orchestration/extension/seed-fixture.sh +177 -0
- package/orchestration/extension/sidepanel-toggle.sh +291 -0
- package/orchestration/extension/snapshot-dist.sh +84 -0
- package/orchestration/extension/start-watch.sh +339 -0
- package/orchestration/extension/wallet-fixture-state.cjs +1086 -0
- package/orchestration/lib/activate-repo-node.sh +144 -0
- package/orchestration/lib/cli-color.mjs +84 -0
- package/orchestration/lib/cli-commands.mjs +243 -0
- package/orchestration/lib/cli-home.mjs +354 -0
- package/orchestration/lib/cli-ux.sh +252 -0
- package/orchestration/lib/cli-version.mjs +123 -0
- package/orchestration/lib/ensure-runner-deps.sh +56 -0
- package/orchestration/lib/harness-path.sh +55 -0
- package/orchestration/lib/hash-helpers.sh +44 -0
- package/orchestration/lib/json-field.sh +23 -0
- package/orchestration/lib/log-tui.mjs +304 -0
- package/orchestration/lib/open-debug.mjs +317 -0
- package/orchestration/lib/path-defaults.json +4 -0
- package/orchestration/lib/progress.mjs +107 -0
- package/orchestration/lib/recipe-paths.mjs +26 -0
- package/orchestration/lib/resolve-farmslot-ports.sh +144 -0
- package/orchestration/manifest.json +358 -0
- package/orchestration/mobile/cleanup.sh +192 -0
- package/orchestration/mobile/deps-markers.ts +21 -0
- package/orchestration/mobile/inject.sh +681 -0
- package/orchestration/mobile/launch.sh +137 -0
- package/orchestration/mobile/live.sh +125 -0
- package/orchestration/mobile/runtime-decision.ts +292 -0
- package/orchestration/porcelain/metamask-recipe +99 -0
- package/orchestration/porcelain/mm-recipe +1591 -0
- package/orchestration/porcelain/mme-recipe +1181 -0
- package/package.json +59 -0
- package/runner/extension/verify.sh +511 -0
- package/runner/mobile/verify.sh +501 -0
- package/runner/src/adapters.ts +601 -0
- package/runner/src/cli.ts +1820 -0
- package/runner/src/commands/debug.ts +44 -0
- package/runner/src/commands/fixtures.ts +99 -0
- package/runner/src/commands/launch.ts +397 -0
- package/runner/src/commands/logs.ts +60 -0
- package/runner/src/commands/shared.ts +138 -0
- package/runner/src/completions-cache.ts +86 -0
- package/runner/src/doctor.ts +203 -0
- package/runner/src/harness.ts +516 -0
- package/runner/src/heal-bounds.ts +179 -0
- package/runner/src/index.ts +6 -0
- package/runner/src/live-adapter-contract.ts +274 -0
- package/runner/src/manifest.ts +47 -0
- package/runner/src/mm-harness-cli.ts +488 -0
- package/runner/src/paths.ts +198 -0
- package/runner/src/recording-target.ts +147 -0
- package/runner/src/run-recording.ts +329 -0
- package/runner/src/runner.ts +108 -0
- package/runner/src/types.ts +57 -0
- package/scripts/completions.sh +125 -0
- package/scripts/install-completions.sh +62 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# completions.sh — bundled tab completion for `mm-harness` (bash + zsh).
|
|
3
|
+
#
|
|
4
|
+
# Static parts (commands, positional targets, per-command flags) mirror the
|
|
5
|
+
# mm-harness surface. Dynamic parts are sourced live from the hidden
|
|
6
|
+
# `mm-harness completion-candidates <actions|flows>` command (per-checkout cached):
|
|
7
|
+
# call <TAB> → action names from the adapter manifest
|
|
8
|
+
# run <TAB> → recipe files + flow refs from the recipe library
|
|
9
|
+
# so completion reflects the installed overlay's real vocabulary. A candidate read
|
|
10
|
+
# that fails is silently empty — completion never blocks the shell.
|
|
11
|
+
#
|
|
12
|
+
# Install: source this file from ~/.zshrc / ~/.bashrc
|
|
13
|
+
# (see: mm-harness completions install).
|
|
14
|
+
|
|
15
|
+
# Resolve the mm-harness bin: prefer one on PATH, else this checkout's bin.
|
|
16
|
+
_mmh_bin() {
|
|
17
|
+
if command -v mm-harness >/dev/null 2>&1; then
|
|
18
|
+
command -v mm-harness
|
|
19
|
+
return 0
|
|
20
|
+
fi
|
|
21
|
+
if [ -n "${BASH_SOURCE[0]:-}" ]; then
|
|
22
|
+
local here
|
|
23
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." 2>/dev/null && pwd)" || true
|
|
24
|
+
if [ -n "$here" ] && [ -x "$here/bin/mm-harness" ]; then
|
|
25
|
+
printf '%s\n' "$here/bin/mm-harness"
|
|
26
|
+
return 0
|
|
27
|
+
fi
|
|
28
|
+
fi
|
|
29
|
+
return 1
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_mmh_commands="launch logs debug fixtures actions call flows run doctor install verify cleanup completions"
|
|
33
|
+
|
|
34
|
+
# Per-command flags (static, from the mm-harness surface).
|
|
35
|
+
_mmh_flags_for() {
|
|
36
|
+
case "$1" in
|
|
37
|
+
launch) printf '%s' "--build --watch --verify --sidepanel --fullscreen --runway --device --cdp-port --watcher-port --heal --adapter --target --json" ;;
|
|
38
|
+
logs) printf '%s' "--full --events --source --adapter --target --json" ;;
|
|
39
|
+
debug) printf '%s' "--worker --dev-menu --adapter --target --json" ;;
|
|
40
|
+
fixtures) printf '%s' "--fixture --adapter --target --json" ;;
|
|
41
|
+
actions) printf '%s' "--adapter --action --kind --raw --action-manifest --target --json" ;;
|
|
42
|
+
call) printf '%s' "--arg --adapter --target --artifacts-dir --action-manifest --heal --json" ;;
|
|
43
|
+
flows) printf '%s' "--library --json" ;;
|
|
44
|
+
run) printf '%s' "--plan --adapter --artifacts-dir --target --library --cdp-port --heal --record-video --json" ;;
|
|
45
|
+
doctor) printf '%s' "--adapter --target --fix --json" ;;
|
|
46
|
+
install|verify|cleanup) printf '%s' "--adapter --target --json" ;;
|
|
47
|
+
*) printf '%s' "" ;;
|
|
48
|
+
esac
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Dynamic candidates from the DISCOVER layer (silent empty on any failure).
|
|
52
|
+
_mmh_actions() { local b; b="$(_mmh_bin)" || return 0; "$b" completion-candidates actions 2>/dev/null; }
|
|
53
|
+
_mmh_flows() { local b; b="$(_mmh_bin)" || return 0; "$b" completion-candidates flows 2>/dev/null; }
|
|
54
|
+
|
|
55
|
+
# ── Bash ────────────────────────────────────────────────────────────────
|
|
56
|
+
if [ -n "${BASH_VERSION:-}" ]; then
|
|
57
|
+
_mmh_complete_bash() {
|
|
58
|
+
local cur prev words cword
|
|
59
|
+
_get_comp_words_by_ref -n : cur prev words cword 2>/dev/null || {
|
|
60
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
61
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
62
|
+
words=("${COMP_WORDS[@]}")
|
|
63
|
+
cword=$COMP_CWORD
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if [ "$cword" -eq 1 ]; then
|
|
67
|
+
COMPREPLY=($(compgen -W "$_mmh_commands" -- "$cur"))
|
|
68
|
+
return
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
local cmd="${words[1]}"
|
|
72
|
+
case "$cur" in
|
|
73
|
+
-*) COMPREPLY=($(compgen -W "$(_mmh_flags_for "$cmd")" -- "$cur")); return ;;
|
|
74
|
+
esac
|
|
75
|
+
|
|
76
|
+
case "$cmd" in
|
|
77
|
+
launch) [ "$cword" -eq 2 ] && COMPREPLY=($(compgen -W "ios android" -- "$cur")) ;;
|
|
78
|
+
fixtures) [ "$cword" -eq 2 ] && COMPREPLY=($(compgen -W "sync set" -- "$cur")) ;;
|
|
79
|
+
completions) [ "$cword" -eq 2 ] && COMPREPLY=($(compgen -W "install bash zsh status" -- "$cur")) ;;
|
|
80
|
+
flows) [ "$cword" -eq 2 ] && COMPREPLY=($(compgen -W "list promote" -- "$cur")) ;;
|
|
81
|
+
call) [ "$cword" -eq 2 ] && COMPREPLY=($(compgen -W "$(_mmh_actions)" -- "$cur")) ;;
|
|
82
|
+
run) COMPREPLY=($(compgen -f -- "$cur"; compgen -W "$(_mmh_flows)" -- "$cur")) ;;
|
|
83
|
+
*) COMPREPLY=($(compgen -W "$(_mmh_flags_for "$cmd")" -- "$cur")) ;;
|
|
84
|
+
esac
|
|
85
|
+
}
|
|
86
|
+
complete -F _mmh_complete_bash mm-harness 2>/dev/null || true
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
# ── Zsh ─────────────────────────────────────────────────────────────────
|
|
90
|
+
if [ -n "${ZSH_VERSION:-}" ]; then
|
|
91
|
+
_mmh_complete_zsh() {
|
|
92
|
+
local -a candidates
|
|
93
|
+
local cmd="${words[2]:-}"
|
|
94
|
+
|
|
95
|
+
if (( CURRENT == 2 )); then
|
|
96
|
+
candidates=(${=_mmh_commands})
|
|
97
|
+
compadd -a candidates
|
|
98
|
+
return
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
local cur="${words[CURRENT]}"
|
|
102
|
+
if [[ "$cur" == -* ]]; then
|
|
103
|
+
candidates=(${=$(_mmh_flags_for "$cmd")})
|
|
104
|
+
compadd -a candidates
|
|
105
|
+
return
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
case "$cmd" in
|
|
109
|
+
launch) (( CURRENT == 3 )) && { candidates=(ios android); compadd -a candidates; } ;;
|
|
110
|
+
fixtures) (( CURRENT == 3 )) && { candidates=(sync set); compadd -a candidates; } ;;
|
|
111
|
+
completions) (( CURRENT == 3 )) && { candidates=(install bash zsh status); compadd -a candidates; } ;;
|
|
112
|
+
flows) (( CURRENT == 3 )) && { candidates=(list promote); compadd -a candidates; } ;;
|
|
113
|
+
call) (( CURRENT == 3 )) && { candidates=("${(@f)$(_mmh_actions)}"); compadd -a candidates; } ;;
|
|
114
|
+
run) candidates=("${(@f)$(_mmh_flows)}"); compadd -a candidates; _files ;;
|
|
115
|
+
*) candidates=(${=$(_mmh_flags_for "$cmd")}); compadd -a candidates ;;
|
|
116
|
+
esac
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (( $+functions[compdef] )); then
|
|
120
|
+
compdef _mmh_complete_zsh mm-harness
|
|
121
|
+
else
|
|
122
|
+
autoload -Uz compinit 2>/dev/null && compinit -u 2>/dev/null
|
|
123
|
+
(( $+functions[compdef] )) && compdef _mmh_complete_zsh mm-harness
|
|
124
|
+
fi
|
|
125
|
+
fi
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# install-completions.sh — install mm-harness shell completions (bash + zsh)
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
RUNNER_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
7
|
+
BASH_SNIPPET="source \"$RUNNER_ROOT/scripts/completions.sh\""
|
|
8
|
+
ZSH_SNIPPET=$'# mm-harness tab completion\nsource '"\"$RUNNER_ROOT/scripts/completions.sh\""
|
|
9
|
+
|
|
10
|
+
usage() {
|
|
11
|
+
cat <<EOF
|
|
12
|
+
Usage: install-completions.sh [install|bash|zsh|status]
|
|
13
|
+
|
|
14
|
+
install Print setup lines for bash and zsh (default)
|
|
15
|
+
bash Print bash one-liner to add to ~/.bashrc
|
|
16
|
+
zsh Print zsh lines to add to ~/.zshrc
|
|
17
|
+
status Show whether completions appear installed
|
|
18
|
+
|
|
19
|
+
Tab completion: type "mm-harness " (with a trailing space) then press TAB.
|
|
20
|
+
|
|
21
|
+
After install, restart your shell or run:
|
|
22
|
+
source $RUNNER_ROOT/scripts/completions.sh
|
|
23
|
+
EOF
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
cmd="${1:-install}"
|
|
27
|
+
case "$cmd" in
|
|
28
|
+
-h|--help) usage; exit 0 ;;
|
|
29
|
+
bash)
|
|
30
|
+
printf '%s\n' "$BASH_SNIPPET"
|
|
31
|
+
;;
|
|
32
|
+
zsh)
|
|
33
|
+
printf '%s\n' "$ZSH_SNIPPET"
|
|
34
|
+
;;
|
|
35
|
+
status)
|
|
36
|
+
if [ -f "$HOME/.bashrc" ] && grep -Fq "$RUNNER_ROOT/scripts/completions.sh" "$HOME/.bashrc" 2>/dev/null; then
|
|
37
|
+
echo "bash: sourced from ~/.bashrc"
|
|
38
|
+
else
|
|
39
|
+
echo "bash: not sourced (run: install-completions.sh bash)"
|
|
40
|
+
fi
|
|
41
|
+
if [ -f "$HOME/.zshrc" ] && grep -Fq "$RUNNER_ROOT/scripts/completions.sh" "$HOME/.zshrc" 2>/dev/null; then
|
|
42
|
+
echo "zsh: sourced from ~/.zshrc"
|
|
43
|
+
else
|
|
44
|
+
echo "zsh: not sourced (run: install-completions.sh zsh)"
|
|
45
|
+
fi
|
|
46
|
+
;;
|
|
47
|
+
install)
|
|
48
|
+
echo "Add to ~/.bashrc:"
|
|
49
|
+
echo " $BASH_SNIPPET"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "Add to ~/.zshrc:"
|
|
52
|
+
echo " $ZSH_SNIPPET"
|
|
53
|
+
echo ""
|
|
54
|
+
echo "Reload now:"
|
|
55
|
+
echo " source $RUNNER_ROOT/scripts/completions.sh"
|
|
56
|
+
;;
|
|
57
|
+
*)
|
|
58
|
+
echo "Unknown command: $cmd" >&2
|
|
59
|
+
usage >&2
|
|
60
|
+
exit 2
|
|
61
|
+
;;
|
|
62
|
+
esac
|