@deeeed/metamask-harness 0.5.0 → 0.6.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +51 -20
  2. package/adapters/core/inject.sh +1 -0
  3. package/adapters/extension/cleanup.mjs +1 -1
  4. package/adapters/extension/inject.mjs +4 -1
  5. package/adapters/extension/launch-browser.cjs +18 -4
  6. package/adapters/extension/live.sh +14 -2
  7. package/adapters/extension/refresh-build.sh +2 -2
  8. package/adapters/extension/sidepanel-toggle.sh +33 -12
  9. package/adapters/extension/start-watch.sh +2 -2
  10. package/adapters/extension/wallet-fixture-state.cjs +38 -24
  11. package/adapters/manifest.json +32 -3
  12. package/adapters/mobile/inject.sh +1 -0
  13. package/adapters/mobile/start-metro.sh +1 -1
  14. package/adapters/mobile/stop-metro.sh +20 -0
  15. package/adapters/mobile/verify.sh +1 -1
  16. package/adapters/shared/activate-repo-node.sh +1 -1
  17. package/adapters/shared/cli-ux.sh +44 -25
  18. package/adapters/shared/ensure-runner-deps.sh +30 -0
  19. package/adapters/shared/log-tui.mjs +4 -4
  20. package/adapters/shared/open-debug.mjs +1 -1
  21. package/adapters/shared/reap-checkout-metros.sh +53 -0
  22. package/adapters/shared/recipe-harness-root.mjs +23 -0
  23. package/adapters/shared/resolve-farmslot-ports-core.mjs +205 -0
  24. package/adapters/shared/resolve-farmslot-ports.mjs +20 -0
  25. package/adapters/shared/resolve-farmslot-ports.sh +19 -126
  26. package/bin/mm-harness +45 -4
  27. package/dist/adapters/extension/runtime.js +3 -1
  28. package/dist/adapters/mobile/provision.js +34 -1
  29. package/dist/adapters/mobile/runtime-decision.js +3 -1
  30. package/dist/adapters/resolve-farmslot-ports.js +22 -0
  31. package/dist/adapters/slot-ports.js +18 -29
  32. package/dist/cli.js +32 -1463
  33. package/dist/commands/call.js +183 -0
  34. package/dist/commands/completion-candidates.js +58 -0
  35. package/dist/commands/doctor.js +101 -0
  36. package/dist/commands/ensure-ready.js +24 -0
  37. package/dist/commands/flows.js +62 -0
  38. package/dist/commands/launch/extension.js +40 -0
  39. package/dist/commands/{launch.js → launch/index.js} +15 -47
  40. package/dist/commands/launch/mobile.js +10 -0
  41. package/dist/commands/manifest.js +72 -0
  42. package/dist/commands/parse-args.js +189 -0
  43. package/dist/commands/provision.js +136 -0
  44. package/dist/commands/resolve-extension.js +23 -0
  45. package/dist/commands/run-engine.js +341 -0
  46. package/dist/commands/run.js +217 -0
  47. package/dist/commands/runtime-decision.js +58 -0
  48. package/dist/commands/runtime-health.js +25 -0
  49. package/dist/commands/runtime-launch.js +139 -0
  50. package/dist/commands/self-test.js +52 -0
  51. package/dist/commands/stop.js +52 -0
  52. package/dist/harness.js +8 -48
  53. package/dist/mm-harness-cli.js +13 -8
  54. package/docs/CLI-SPEC.md +1 -1
  55. package/docs/CODE-MAP.md +62 -0
  56. package/library/README.md +14 -0
  57. package/library/actions/core/perps/_controller.mjs +1 -1
  58. package/library/actions/extension/platform/cdp.mjs +2 -2
  59. package/library/actions/extension/wallet/ensure_unlocked.mjs +7 -1
  60. package/library/actions/harness-exports.mjs +27 -0
  61. package/library/actions/mobile/wallet/ensure_unlocked.mjs +14 -2
  62. package/library/actions/mobile/wallet/setup.mjs +1 -1
  63. package/package.json +6 -7
  64. package/src/adapters/core/surface.ts +0 -71
  65. package/src/adapters/extension/ensure-ready.ts +0 -185
  66. package/src/adapters/extension/extension-id.ts +0 -107
  67. package/src/adapters/extension/runtime-decision.ts +0 -445
  68. package/src/adapters/extension/runtime.ts +0 -407
  69. package/src/adapters/extension/surface.ts +0 -88
  70. package/src/adapters/mobile/deps-markers.ts +0 -21
  71. package/src/adapters/mobile/prepare.ts +0 -246
  72. package/src/adapters/mobile/provision.ts +0 -594
  73. package/src/adapters/mobile/runtime-decision.ts +0 -459
  74. package/src/adapters/mobile/surface.ts +0 -71
  75. package/src/adapters/slot-ports.ts +0 -165
  76. package/src/adapters/surface.ts +0 -117
  77. package/src/adapters.ts +0 -601
  78. package/src/cli-color.ts +0 -92
  79. package/src/cli-commands.ts +0 -250
  80. package/src/cli-version.ts +0 -141
  81. package/src/cli.ts +0 -2091
  82. package/src/commands/debug.ts +0 -65
  83. package/src/commands/fixtures.ts +0 -198
  84. package/src/commands/launch.ts +0 -470
  85. package/src/commands/logs.ts +0 -99
  86. package/src/commands/shared.ts +0 -235
  87. package/src/commands/update.ts +0 -316
  88. package/src/completions-cache.ts +0 -86
  89. package/src/doctor.ts +0 -215
  90. package/src/harness.ts +0 -797
  91. package/src/heal-bounds.ts +0 -198
  92. package/src/index.ts +0 -15
  93. package/src/leaf-invoke.ts +0 -28
  94. package/src/live-adapter-contract.ts +0 -274
  95. package/src/manifest.ts +0 -47
  96. package/src/mm-harness-cli.ts +0 -655
  97. package/src/paths.ts +0 -198
  98. package/src/progress.ts +0 -117
  99. package/src/recording-target.ts +0 -147
  100. package/src/run-recording.ts +0 -329
  101. package/src/runner.ts +0 -108
  102. package/src/types.ts +0 -57
@@ -1,117 +0,0 @@
1
- // The per-platform surface: one interface every command resolves platform
2
- // behavior through, so no command hand-rolls `if (adapter === …)` for behavior a
3
- // platform owns. A command NEVER branches on adapter for behavior this interface
4
- // owns; a new platform behavior extends the surface (a new member here + its
5
- // three implementations), not the command. This is the enforcement mechanism for
6
- // UX-PRINCIPLES.md principle 1 (context-aware by default). See
7
- // docs/ADAPTER-SURFACE.md.
8
-
9
- import type { MetaMaskRecipeAdapter } from '../types.ts';
10
- import { coreSurface } from './core/surface.ts';
11
- import { extensionSurface } from './extension/surface.ts';
12
- import { mobileSurface } from './mobile/surface.ts';
13
-
14
- // Read-only runtime readiness, normalized across platforms so `doctor` renders
15
- // one line the same way regardless of adapter. Device platforms fill deps +
16
- // devServer; core (headless) reports deps presence only (no devServer).
17
- export interface AdapterRuntimeStatus {
18
- decision: string;
19
- reasonCode?: string;
20
- reasons: string[];
21
- deps?: string;
22
- // The platform's dev server (Metro for mobile, webpack watcher for extension),
23
- // labelled so the render names the right thing. Absent for headless core.
24
- devServer?: { label: string; status: string };
25
- }
26
-
27
- // One log file a platform writes, most-relevant first. `logs` tails the first
28
- // candidate that exists.
29
- export interface AdapterLogSource {
30
- label: string;
31
- path: string;
32
- }
33
-
34
- // Result of stopping the platform's dev server. `headless` is the core case —
35
- // there is nothing to stop, so `stop` teaches instead. `stopped` carries the
36
- // exit status plus, when the platform counts them, how many processes were
37
- // signalled and the raw leaf output for the --json envelope.
38
- export type AdapterDevServerStop =
39
- | { kind: 'headless'; message: string; userAction: string }
40
- | { kind: 'stopped'; status: number; summary: string; signalled?: number; output?: string };
41
-
42
- export interface AdapterDevServer {
43
- // One noun for the dev server this platform runs ("Metro", "webpack watcher").
44
- describe(): string;
45
- // Stop the dev server this checkout owns, port/pid-scoped. Idempotent:
46
- // nothing-to-stop is success, never an error.
47
- stop(target: string): AdapterDevServerStop;
48
- }
49
-
50
- // Platform-phrased Next: hints so no command prints another platform's vocabulary.
51
- // `launch` (re)starts the app + dev server; `relaunch` rebuilds first (the
52
- // fixtures-set retry). core has no app, so its hints teach the headless path.
53
- export interface AdapterHints {
54
- launch: string;
55
- relaunch: string;
56
- }
57
-
58
- export interface AdapterRunwayProvisionOptions {
59
- json?: boolean;
60
- platform?: string;
61
- branch?: string;
62
- defaultBranch?: string;
63
- run?: string;
64
- cacheRoot?: string;
65
- simulator?: string;
66
- runtime?: string;
67
- deviceType?: string;
68
- slot?: string;
69
- watcherPort?: string;
70
- runtimeDir?: string;
71
- force?: boolean;
72
- resolveOnly?: boolean;
73
- rerunCommand: string;
74
- }
75
-
76
- export interface AdapterRunwayProvisionResult {
77
- schemaVersion: 1;
78
- command: 'provision';
79
- adapter: MetaMaskRecipeAdapter;
80
- target: string;
81
- platform?: string;
82
- status: 'pass' | 'fail';
83
- exitCode: number;
84
- error?: { code: string; message: string; userAction: string };
85
- [key: string]: unknown;
86
- }
87
-
88
- export interface AdapterRunwayProvision {
89
- run(target: string, options: AdapterRunwayProvisionOptions): Promise<AdapterRunwayProvisionResult>;
90
- }
91
-
92
- export interface AdapterSurface {
93
- readonly adapter: MetaMaskRecipeAdapter;
94
- // core runs no app/dev server; device adapters (mobile/extension) do. Commands
95
- // ask this instead of testing `adapter === 'core'`.
96
- readonly headless: boolean;
97
- // Resolve slot ports/device into the environment (checkout context > pool >
98
- // formula). No-op for core.
99
- resolveSlotPorts(target: string): void;
100
- // Read-only readiness for `doctor`. Never launches or mutates.
101
- runtimeStatus(target: string): Promise<AdapterRuntimeStatus>;
102
- devServer: AdapterDevServer;
103
- runwayProvision: AdapterRunwayProvision;
104
- // Ordered candidate log files for `logs`. Empty for core.
105
- logSources(target: string): AdapterLogSource[];
106
- hints: AdapterHints;
107
- }
108
-
109
- const SURFACES: Record<MetaMaskRecipeAdapter, AdapterSurface> = {
110
- mobile: mobileSurface,
111
- extension: extensionSurface,
112
- core: coreSurface,
113
- };
114
-
115
- export function getAdapterSurface(adapter: MetaMaskRecipeAdapter): AdapterSurface {
116
- return SURFACES[adapter];
117
- }