@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.
Files changed (106) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +90 -140
  3. package/adapters/core/cleanup.sh +0 -0
  4. package/adapters/core/inject.sh +0 -0
  5. package/adapters/extension/cleanup.mjs +0 -0
  6. package/adapters/extension/console-tail.mjs +51 -24
  7. package/adapters/extension/ensure-browser.sh +0 -0
  8. package/adapters/extension/inject.mjs +5 -9
  9. package/adapters/extension/launch-browser.cjs +0 -0
  10. package/adapters/extension/launch-webpack.cjs +83 -0
  11. package/adapters/extension/launch.sh +8 -11
  12. package/adapters/extension/live.sh +2 -0
  13. package/adapters/extension/readiness.mjs +0 -0
  14. package/adapters/extension/reattach.sh +1 -0
  15. package/adapters/extension/refresh-build.sh +0 -0
  16. package/adapters/extension/seed-fixture.sh +4 -12
  17. package/adapters/extension/sidepanel-toggle.sh +4 -1
  18. package/adapters/extension/snapshot-dist.sh +0 -0
  19. package/adapters/extension/stamp-runtime-title.cjs +49 -0
  20. package/adapters/extension/start-watch.sh +16 -4
  21. package/adapters/extension/stop-viewers.sh +1 -1
  22. package/adapters/extension/sync-webpack-dist.cjs +105 -0
  23. package/adapters/extension/verify.sh +1 -1
  24. package/adapters/extension/wallet-fixture-state.cjs +0 -0
  25. package/adapters/manifest.json +46 -38
  26. package/adapters/mobile/bridge-runtime/cdp-bridge.cjs +0 -0
  27. package/adapters/mobile/bridge-runtime/console-forwarder.cjs +1 -1
  28. package/adapters/mobile/bridge-runtime/lib/target-discovery.cjs +2 -3
  29. package/adapters/mobile/bridge-runtime/setup-wallet.sh +0 -0
  30. package/adapters/mobile/cleanup.sh +16 -176
  31. package/adapters/mobile/inject.sh +88 -671
  32. package/adapters/mobile/launch-console-forwarder.cjs +39 -0
  33. package/adapters/mobile/lib/metro-listener.sh +0 -0
  34. package/adapters/mobile/lib/tmux-viewer.sh +0 -0
  35. package/adapters/mobile/open-device.sh +0 -0
  36. package/adapters/mobile/prewarm-bundle.sh +0 -0
  37. package/adapters/mobile/start-console-forwarder.sh +70 -0
  38. package/adapters/mobile/start-metro.sh +0 -41
  39. package/adapters/mobile/stop-metro.sh +0 -0
  40. package/adapters/mobile/verify.sh +4 -61
  41. package/adapters/mobile/wait-for-bridge.sh +0 -0
  42. package/adapters/mobile/yarn-setup.sh +0 -0
  43. package/adapters/shared/activate-repo-node.sh +0 -0
  44. package/adapters/shared/activate-repo-ruby.sh +0 -0
  45. package/adapters/shared/cli-ux.sh +0 -0
  46. package/adapters/shared/ensure-runner-deps.sh +0 -0
  47. package/adapters/shared/harness-path.sh +0 -0
  48. package/adapters/shared/hash-helpers.sh +0 -0
  49. package/adapters/shared/install-repo-deps.sh +0 -0
  50. package/adapters/shared/json-field.sh +0 -0
  51. package/adapters/shared/open-debug.mjs +90 -36
  52. package/adapters/shared/open-log-window.sh +0 -0
  53. package/adapters/shared/reap-checkout-metros.sh +0 -0
  54. package/adapters/shared/resolve-slot-ports-core.mjs +0 -6
  55. package/adapters/shared/resolve-slot-ports.mjs +0 -0
  56. package/adapters/shared/resolve-slot-ports.sh +0 -5
  57. package/adapters/shared/sync-wallet-fixture.sh +0 -0
  58. package/adapters/shared/tmux-session.sh +0 -0
  59. package/adapters/shared/tmux-viewer.sh +0 -0
  60. package/adapters/shared/update-check-worker.mjs +37 -0
  61. package/dist/adapters/extension/console-capture.js +84 -0
  62. package/dist/adapters/extension/runtime-decision.js +14 -2
  63. package/dist/adapters/extension/surface.js +3 -2
  64. package/dist/adapters/mobile/prepare.js +22 -7
  65. package/dist/adapters/mobile/surface.js +1 -1
  66. package/dist/adapters/resolve-slot-ports.js +0 -2
  67. package/dist/adapters/slot-ports.js +8 -0
  68. package/dist/cli.js +3 -11
  69. package/dist/commands/call.js +9 -4
  70. package/dist/commands/debug.js +38 -31
  71. package/dist/commands/fixtures.js +18 -10
  72. package/dist/commands/launch/index.js +10 -0
  73. package/dist/commands/logs.js +8 -6
  74. package/dist/commands/manifest.js +5 -17
  75. package/dist/commands/run-engine.js +1 -32
  76. package/dist/commands/run-report.js +1 -1
  77. package/dist/commands/run.js +50 -3
  78. package/dist/commands/status-probe.js +1 -1
  79. package/dist/commands/update.js +15 -28
  80. package/dist/doctor.js +1 -4
  81. package/dist/harness.js +5 -123
  82. package/dist/live-adapter-contract.js +6 -20
  83. package/dist/mm-harness-cli.js +6 -43
  84. package/dist/paths.js +2 -5
  85. package/dist/run-diagnostics.js +35 -40
  86. package/dist/runtime-context.js +26 -8
  87. package/docs/CHEATSHEET.md +39 -52
  88. package/docs/CLI-ERGONOMICS-HUMAN-QA.md +48 -104
  89. package/docs/CODE-MAP.md +1 -1
  90. package/docs/VIDEO-DEMO-VALIDATION.md +62 -0
  91. package/docs/architecture.md +65 -375
  92. package/docs/live-adapter-contract.md +3 -1
  93. package/library/actions/core/perps/_controller.mjs +10 -55
  94. package/library/manifests/mobile.action-manifest.json +1 -1
  95. package/package.json +2 -2
  96. package/scripts/completions.sh +0 -0
  97. package/scripts/install-completions.sh +0 -0
  98. package/adapters/mobile/overlay/app/dev-tools/AgenticService/AgentStepHud.tsx.patch +0 -185
  99. package/adapters/mobile/overlay/app/dev-tools/AgenticService/AgenticService.ts.patch +0 -1662
  100. package/adapters/mobile/overlay/compat/README.md +0 -28
  101. package/adapters/mobile/overlay/compat/rn81-message-event-source.patch +0 -42
  102. package/adapters/shared/resolve-farmslot-ports-core.mjs +0 -3
  103. package/adapters/shared/resolve-farmslot-ports.mjs +0 -5
  104. package/adapters/shared/resolve-farmslot-ports.sh +0 -7
  105. package/docs/CLI-SPEC.md +0 -1142
  106. package/docs/MENTAL-MODEL.md +0 -295
@@ -1,61 +1,48 @@
1
- # mm-harness — user cheatsheet
1
+ # mm-harness cheatsheet
2
2
 
3
- `mm-harness <command> [target] [flags]` · Run from inside any MetaMask checkout · Platform auto-detected
3
+ Run inside a MetaMask checkout. Product, slot, ports, and runtime paths are
4
+ auto-detected.
4
5
 
5
- ---
6
+ ## Operate
6
7
 
7
- ## Daily loop
8
-
9
- | Situation | Command |
8
+ | Need | Command |
10
9
  |---|---|
11
- | Start / relaunch iOS | `mm-harness launch ios` |
12
- | Start / relaunch Android | `mm-harness launch android` |
13
- | Launch extension (fullscreen) | `mm-harness launch` |
14
- | Launch extension in sidepanel | `mm-harness launch --sidepanel` |
15
- | Native code changed — rebuild first | `mm-harness launch ios --build` |
16
- | Tail Metro / webpack logs | `mm-harness logs` |
17
- | Open DevTools / RN inspector | `mm-harness debug` |
18
- | Seed wallet from fixture — no typing | `mm-harness fixtures set` |
19
- | Refresh wallet fixture files on slot | `mm-harness fixtures sync` |
20
-
21
- `launch` auto-installs the overlay on first use.
22
- `fixtures set` reads the password **from** the fixture — never typed.
23
-
24
- ---
25
-
26
- ## Proof loop
27
-
28
- ```
29
- actions → call <action> → flows → run recipe.json --plan → run recipe.json
10
+ | Extension | `mm-harness launch` |
11
+ | Extension sidepanel | `mm-harness launch --sidepanel` |
12
+ | iOS / Android | `mm-harness launch ios` / `mm-harness launch android` |
13
+ | Clean rebuild | `mm-harness launch --build` |
14
+ | Runtime status | `mm-harness status` |
15
+ | Logs | `mm-harness logs` |
16
+ | Debugger | `mm-harness debug` |
17
+ | Apply wallet fixture | `mm-harness fixtures set` |
18
+
19
+ Extension log sources: `extension`, `dapp`, `webpack`, `watcher`, `rebuild`.
20
+ Mobile log sources: `app`, `metro`.
21
+
22
+ ## Discover and prove
23
+
24
+ ```bash
25
+ mm-harness actions positions
26
+ mm-harness actions --action metamask.wallet.ensure_unlocked
27
+ mm-harness call metamask.wallet.ensure_unlocked
28
+ mm-harness flows
29
+ mm-harness run recipe.json --plan
30
+ mm-harness run recipe.json --artifacts-dir temp/recipe-proof
30
31
  ```
31
32
 
32
- | Command | What it does |
33
- |---|---|
34
- | `mm-harness actions` | Action vocabulary for this adapter |
35
- | `mm-harness call unlock` | One action through the real engine (fuzzy name ok) |
36
- | `mm-harness flows` | Reusable flows (personal > team > canonical) |
37
- | `mm-harness run recipe.json --plan` | Validate + print plan, no device touched; exit 5 if invalid |
38
- | `mm-harness run recipe.json` | Execute + write evidence (summary / trace / artifacts) |
39
-
40
- ---
33
+ The run result prints diagnostics plus absolute evidence paths. Resume safely with
34
+ `mm-harness last --json`.
41
35
 
42
- ## Health
36
+ ## Recover
43
37
 
44
- | Command | What it does |
45
- |---|---|
46
- | `mm-harness doctor` | Full readiness check — fixture, runtime context, overlay. No launch. |
47
- | `mm-harness doctor --fix` | Repair overlay + runtime context without launching the app. |
48
- | `mm-harness verify` | Check overlay/runtime is present and healthy. No launch. |
49
- | `mm-harness cleanup` | Remove the overlay and restore the checkout. |
50
-
51
- ---
52
-
53
- ## For agents and scripts
54
-
55
- **`--json`** — machine-readable output on every command; includes `recovered[]`, `mutations[]`, `schemaVersion`.
56
-
57
- **`--heal`** — `off` (fail fast, repro-preserving) · `infra-only` (heal transport, never wallet; `run`/`call` default) · `auto` (auto-ensure overlay + heal; `launch` default).
58
-
59
- **Exit codes** — `0` success · `1` recipe/action failed · `2` bad args / missing target · `5` validation failure (fix recipe).
38
+ ```bash
39
+ mm-harness doctor
40
+ mm-harness doctor --fix
41
+ mm-harness verify
42
+ mm-harness cleanup
43
+ mm-harness update
44
+ ```
60
45
 
61
- **Tab completion** `mm-harness completions install` prints the lines to add to `~/.zshrc` / `~/.bashrc`.
46
+ For automation, add `--json`. Use `--json-stream` for line-delimited run progress.
47
+ Bad input exits `2`; recipe/action failure exits `1`; recipe validation failure
48
+ exits `5`.
@@ -1,104 +1,48 @@
1
- # CLI ergonomics human QA
2
-
3
- Use this short pass after installing a release candidate. Automated contracts remain the release gate; this checklist confirms the experience in a real shell and checkout.
4
-
5
- ## Setup
6
-
7
- ```bash
8
- export TARGET=/absolute/path/to/a/metamask-checkout
9
- export ADAPTER=extension # extension, mobile, or core
10
- mm-harness --version
11
- mm-harness doctor --adapter "$ADAPTER" --target "$TARGET" --json | jq .status
12
- ```
13
-
14
- Expected: the intended version is printed and `doctor` returns parseable JSON. Resolve required doctor failures before continuing.
15
-
16
- ## 1. Teaching errors
17
-
18
- ```bash
19
- out="$(mm-harness actions --categoriez --adapter "$ADAPTER" --json 2>/dev/null || true)"
20
- jq '.error | {code, message, userAction}' <<<"$out"
21
- ```
22
-
23
- Expected: `code` is stable, the message names the bad flag and valid options, and `userAction` suggests the closest valid invocation.
24
-
25
- ## 2. In-tool discovery
26
-
27
- ```bash
28
- mm-harness actions --adapter "$ADAPTER" --categories
29
- mm-harness actions status --adapter "$ADAPTER"
30
- mm-harness actions --action app.status --adapter "$ADAPTER" --json | jq '{actions, relatedActions}'
31
- ```
32
-
33
- Expected: category output is compact, fuzzy search is bounded, and action detail includes related actions when available. A missing example action should produce a teaching error, not silent output.
34
-
35
- ## 3. Machine-output cleanliness and recovery
36
-
37
- ```bash
38
- out="$(mm-harness call definitely.not.an.action --adapter "$ADAPTER" --target "$TARGET" --json 2>/dev/null || true)"
39
- jq '{status, error}' <<<"$out"
40
- ```
41
-
42
- Expected: stdout is one parseable JSON document with `error.code`, `error.message`, and `error.userAction`; it contains no spinner, banner, or human-only glyph.
43
-
44
- ## 4. Immediate human feedback
45
-
46
- Run the platform-appropriate launch in an interactive terminal:
47
-
48
- ```bash
49
- # Extension
50
- mm-harness launch --adapter extension --target "$TARGET"
51
-
52
- # Mobile: choose the intended platform
53
- mm-harness launch ios --target "$TARGET"
54
- # mm-harness launch android --target "$TARGET"
55
- ```
56
-
57
- Expected: intent/progress appears immediately, long work continues to report progress, and the app becomes ready. Redirected or `--json` stdout stays decoration-free.
58
-
59
- ## 5. Lifecycle next step
60
-
61
- For Extension:
62
-
63
- ```bash
64
- mm-harness stop --adapter extension --target "$TARGET" --json | jq '{status, next}'
65
- ```
66
-
67
- Expected: `next` is a target-scoped launch command. Mobile `stop` intentionally omits `next` because Metro does not identify whether iOS or Android should be relaunched.
68
-
69
- ## 6. Resume after interruption
70
-
71
- ```bash
72
- mm-harness last --target "$TARGET" --json | jq '.last | {command, args, verdict, evidencePaths, startedAt, finishedAt}'
73
- ```
74
-
75
- Expected: the last operation can be reconstructed without rerunning it, including its arguments, verdict, evidence paths, and timestamps.
76
-
77
- ## 7. Recipe proof smoke
78
-
79
- ```bash
80
- mm-harness run --list --adapter "$ADAPTER" --json | jq '{actions: .actions[0:5], flows: .flows[0:5]}'
81
- export RECIPE=replace-with-a-safe-recipe-name-or-path
82
- export ARTIFACTS_DIR="$(mktemp -d)"
83
- mm-harness run "$RECIPE" --plan --adapter "$ADAPTER" --target "$TARGET" --json | jq '{status, plan}'
84
- mm-harness run "$RECIPE" --adapter "$ADAPTER" --target "$TARGET" --artifacts-dir "$ARTIFACTS_DIR"
85
- ```
86
-
87
- Expected: the plan validates before execution; the final result identifies evidence paths and `mm-harness last --json` records the run.
88
-
89
- Optional JSONL check:
90
-
91
- ```bash
92
- mm-harness run "$RECIPE" --adapter "$ADAPTER" --target "$TARGET" --artifacts-dir "$ARTIFACTS_DIR-stream" --json-stream | jq -c .
93
- ```
94
-
95
- Expected: complete JSON objects arrive line by line while the run is active.
96
-
97
- ## Cleanup
98
-
99
- ```bash
100
- [ "$ADAPTER" = core ] || mm-harness stop --adapter "$ADAPTER" --target "$TARGET"
101
- mm-harness status --target "$TARGET" --json | jq .
102
- ```
103
-
104
- Record the harness version, checkout SHA, adapter/platform, failed command, exit code, and JSON envelope for any discrepancy.
1
+ # Human QA
2
+
3
+ Run this from each product checkout before a release. Verify the visible outcome,
4
+ not only the exit code.
5
+
6
+ ## Common
7
+
8
+ - [ ] `mm-harness --version` prints the candidate version.
9
+ - [ ] `mm-harness doctor` detects the correct product and reports only current
10
+ configuration.
11
+ - [ ] A misspelled flag explains the error and gives a runnable next command.
12
+ - [ ] `mm-harness actions` and `mm-harness flows` return useful, bounded discovery.
13
+ - [ ] `mm-harness fixtures set` either applies the fixture or names the missing
14
+ file and exact recovery action.
15
+ - [ ] `mm-harness run <safe-recipe> --artifacts-dir temp/qa-proof` prints findings,
16
+ diagnostics, and absolute evidence paths.
17
+ - [ ] `mm-harness last --json` identifies that run without rerunning it.
18
+ - [ ] `mm-harness doctor --json` is one parseable document with no human decoration.
19
+
20
+ ## Extension
21
+
22
+ - [ ] `mm-harness launch` opens/reuses the checkout's named Chrome profile.
23
+ - [ ] `mm-harness launch --sidepanel` opens the MetaMask sidepanel without extra
24
+ Extension tabs.
25
+ - [ ] `mm-harness debug` opens connected DevTools for the active MetaMask target.
26
+ - [ ] `mm-harness logs --source extension` shows Extension console events.
27
+ - [ ] `mm-harness logs --source dapp` shows dapp console events separately.
28
+ - [ ] Edit a visible source string twice, waiting for successful incremental
29
+ compilation after each edit; refresh the browser and confirm both changes.
30
+ - [ ] Revert the edit, confirm a third incremental compilation, and verify the
31
+ same watcher and Chrome process were reused.
32
+
33
+ ## Mobile
34
+
35
+ - [ ] `mm-harness launch ios` boots/reuses the intended simulator and opens the app.
36
+ - [ ] `mm-harness launch android` targets the intended emulator/device.
37
+ - [ ] `mm-harness logs --source metro` and `--source app` show distinct streams.
38
+ - [ ] `mm-harness debug` opens the usable React Native developer surface.
39
+ - [ ] Change a visible JS string, confirm Metro rebuilds, reload the app, and see
40
+ the change without a native rebuild.
41
+
42
+ ## Core
43
+
44
+ - [ ] `mm-harness status`, `doctor`, `actions`, `flows`, and a safe recipe run work
45
+ without browser/device assumptions.
46
+
47
+ Record the command, version, checkout SHA, visible mismatch, exit code, and JSON
48
+ error envelope for any failure.
package/docs/CODE-MAP.md CHANGED
@@ -11,7 +11,7 @@ bin/mm-harness bash front door: MM_HARNESS_BIN dev/prod switch,
11
11
  │ stale-dist warning), deps ensure
12
12
 
13
13
  src/mm-harness-cli.ts commander surface: grouped colored help, per-command
14
- │ --help, retired-name teaching; delegates in-process
14
+ │ --help and usage errors; delegates in-process
15
15
 
16
16
  src/cli.ts parse + dispatch ONLY — no verb logic lives here
17
17
 
@@ -0,0 +1,62 @@
1
+ # Video demo validation
2
+
3
+ Candidate: local packed `@deeeed/metamask-harness` 0.17.1 installed globally.
4
+ Run commands from the named checkout; product/ports are auto-detected.
5
+
6
+ ## Common
7
+
8
+ - [x] `mm-harness --version` prints `0.17.1` from the global npm install.
9
+ - [x] `yarn check` passes.
10
+ - [x] No `package-lock.json`; Yarn state is valid.
11
+ - [x] Current source/docs contain no compatibility or removed-command paths.
12
+ - [x] `doctor` reports current runtime fields only.
13
+ - [x] Recipe results print diagnostics and absolute artifact paths inline.
14
+
15
+ ## Extension (`mme-2`)
16
+
17
+ - [x] `mm-harness doctor` reports healthy CDP and active webpack watcher.
18
+ - [x] `mm-harness run runner.smoke --artifacts-dir temp/final-demo-smoke` passes.
19
+ - [x] Smoke prints six absolute evidence paths and `diagnostics: CLEAN`.
20
+ - [x] `mm-harness debug` connects native DevTools to the active slot target.
21
+ - [x] Fullscreen and sidepanel targets are selectable.
22
+ - [x] Two source edits plus revert compiled incrementally with the same watcher;
23
+ browser refresh showed each change without relaunch.
24
+
25
+ ## Mobile (`mm-1`, iOS)
26
+
27
+ - [x] `mm-harness install` writes metadata only; product checkout remains clean.
28
+ - [x] `mm-harness fixtures set` reads the canonical fixture and unlocks `dev1`.
29
+ - [x] `mm-harness call metamask.wallet.ensure_unlocked` passes from the global package.
30
+ - [x] `mm-harness verify` passes after fixture setup.
31
+ - [x] `mm-harness status` reports `WalletView`, unlocked wallet, selected account,
32
+ and fixture `READY`.
33
+ - [ ] During the recording, visually confirm the expected simulator is foregrounded.
34
+
35
+ ## Core (`core-1`)
36
+
37
+ - [x] `mm-harness doctor` reports the headless controller ready.
38
+ - [x] Canonical wallet fixture is present.
39
+ - [x] `mm-harness run perps.smoke --artifacts-dir temp/final-demo-smoke` passes.
40
+ - [x] Positions, orders, and account state are read through the controller.
41
+ - [x] Evidence prints absolute paths; diagnostics correctly reports `N/A` for headless Core.
42
+
43
+ ## Recording sequence
44
+
45
+ ```bash
46
+ # Extension
47
+ cd /Users/deeeed/farmslot/repos/mme-2
48
+ mm-harness doctor
49
+ mm-harness actions positions
50
+ mm-harness flows
51
+ mm-harness run runner.smoke --artifacts-dir temp/demo
52
+
53
+ # Mobile
54
+ cd /Users/deeeed/farmslot/repos/mm-1
55
+ mm-harness launch ios
56
+ mm-harness fixtures set
57
+ mm-harness call metamask.wallet.ensure_unlocked
58
+
59
+ # Core
60
+ cd /Users/deeeed/farmslot/repos/core-1
61
+ mm-harness run perps.smoke --artifacts-dir temp/demo
62
+ ```