@deeeed/metamask-harness 0.17.4 → 0.18.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 +775 -0
- package/README.md +65 -71
- package/adapters/extension/ensure-browser.sh +12 -1
- package/adapters/extension/inject.mjs +7 -0
- package/adapters/extension/launch-browser.cjs +10 -3
- package/adapters/extension/lib/chrome-args.cjs +31 -0
- package/adapters/extension/lib/macos-focus.cjs +32 -0
- package/adapters/extension/live.sh +10 -20
- package/adapters/manifest.json +8 -0
- package/adapters/mobile/open-device.sh +45 -7
- package/adapters/mobile/verify.sh +15 -3
- 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-slot-ports-core.mjs +23 -6
- package/adapters/shared/resolve-slot-ports.sh +22 -5
- package/bin/mm-harness +15 -3
- package/dist/adapters/core/surface.js +4 -1
- package/dist/adapters/extension/console-capture.js +3 -1
- package/dist/adapters/extension/harness-freshness.js +39 -0
- package/dist/adapters/extension/product-config.js +110 -0
- package/dist/adapters/extension/runtime-decision.js +20 -71
- package/dist/adapters/extension/surface.js +19 -1
- package/dist/adapters/mobile/prepare.js +17 -0
- package/dist/adapters/mobile/source-freshness.js +26 -41
- package/dist/adapters/mobile/surface.js +4 -1
- package/dist/adapters/resolve-slot-ports.js +2 -0
- package/dist/adapters/slot-ports.js +13 -32
- package/dist/adapters.js +50 -17
- package/dist/checkout-lock.js +27 -2
- package/dist/cli-color.js +19 -0
- package/dist/cli-commands.js +1 -1
- package/dist/cli.js +2 -3
- package/dist/command-contract.js +13 -3
- package/dist/commands/call.js +115 -29
- package/dist/commands/checklist.js +4 -1
- package/dist/commands/completion-candidates.js +20 -13
- package/dist/commands/debug.js +31 -38
- package/dist/commands/doctor.js +33 -6
- package/dist/commands/fixtures.js +65 -17
- package/dist/commands/flows.js +39 -10
- package/dist/commands/launch/extension.js +40 -15
- package/dist/commands/launch/index.js +41 -5
- package/dist/commands/list-executables.js +151 -29
- package/dist/commands/manifest.js +127 -18
- package/dist/commands/parse-args.js +11 -1
- package/dist/commands/run-engine.js +384 -56
- package/dist/commands/run.js +112 -17
- package/dist/commands/shared.js +22 -2
- package/dist/commands/status-probe.js +3 -0
- package/dist/commands/status.js +1 -0
- package/dist/completions-cache.js +1 -1
- package/dist/doctor.js +56 -6
- package/dist/harness.js +6 -5
- package/dist/heal-bounds.js +1 -1
- package/dist/live-adapter-contract.js +132 -12
- package/dist/manifest.js +161 -1
- package/dist/mm-harness-cli.js +13 -7
- package/dist/recipe-security.js +178 -0
- package/dist/runner.js +87 -13
- package/dist/runtime-context.js +8 -26
- package/docs/CONTRIBUTING.md +137 -0
- package/docs/QA.md +185 -0
- package/docs/RECIPES.md +161 -0
- package/docs/SECURITY.md +88 -0
- package/library/actions/core/perps/read_account.mjs +2 -2
- package/library/actions/core/perps/read_orders.mjs +2 -1
- package/library/actions/core/perps/read_positions.mjs +2 -1
- package/library/actions/core/wallet/list_accounts.mjs +95 -0
- package/library/actions/extension/platform/cdp.mjs +1 -0
- package/library/actions/extension/wallet/list_accounts.mjs +41 -0
- package/library/actions/mobile/platform/bridge.mjs +1 -5
- package/library/actions/mobile/wallet/list_accounts.mjs +37 -0
- package/library/manifests/core.action-manifest.json +61 -0
- package/library/manifests/extension.action-manifest.json +53 -0
- package/library/manifests/mobile.action-manifest.json +53 -0
- package/library/recipes/runner/action-validation.extension.recipe.json +8 -1
- package/library/recipes/runner/action-validation.mobile.recipe.json +8 -1
- package/package.json +10 -6
- package/scripts/completions.sh +7 -7
- package/docs/ADAPTER-SURFACE.md +0 -26
- package/docs/CHEATSHEET.md +0 -48
- package/docs/CLI-ERGONOMICS-AUDIT.md +0 -32
- package/docs/CLI-ERGONOMICS-HUMAN-QA.md +0 -64
- package/docs/CODE-MAP.md +0 -62
- package/docs/UX-PRINCIPLES.md +0 -66
- package/docs/VIDEO-DEMO-VALIDATION.md +0 -74
- package/docs/architecture.md +0 -88
- package/docs/live-adapter-contract.md +0 -190
- package/docs/package-boundaries.md +0 -47
- package/docs/perps-flow-catalog.md +0 -235
- package/docs/recipe-libraries.md +0 -71
- package/docs/runtime-file-conventions.md +0 -36
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
# Perps Flow Catalog
|
|
2
|
-
|
|
3
|
-
MetaMask Perps recipes use a small set of parameterized primitives plus higher-level `ensure_*` wrappers. Do not add one action per scenario. A new Perps capability should first try to extend selector params or flow params.
|
|
4
|
-
|
|
5
|
-
## Layers
|
|
6
|
-
|
|
7
|
-
| Layer | Examples | Responsibility |
|
|
8
|
-
|---|---|---|
|
|
9
|
-
| Read primitives | `metamask.perps.read_positions`, `metamask.perps.read_orders` | Return redacted live state for a selected subset. |
|
|
10
|
-
| Bulk mutation primitives | `metamask.perps.close_positions`, `metamask.perps.close_orders`, `metamask.perps.place_order` | Perform one real product operation over a parameterized selection. |
|
|
11
|
-
| Assertion wrappers | `metamask.perps.assert_positions`, `metamask.perps.assert_orders` | Read live state and fail when selected state does not match expectation. |
|
|
12
|
-
| Ensure wrappers | `metamask.perps.ensure_positions`, `metamask.perps.ensure_orders` | Compose read/mutate/assert to create idempotent start states. |
|
|
13
|
-
| Domain setup/teardown | `metamask.perps.start_state`, `metamask.perps.teardown_state` | Compose wallet/provider/network/page/position/order setup before a proof window. |
|
|
14
|
-
|
|
15
|
-
## Selection contract
|
|
16
|
-
|
|
17
|
-
Position/order operations accept the same selector shape:
|
|
18
|
-
|
|
19
|
-
```json
|
|
20
|
-
{
|
|
21
|
-
"action": "metamask.perps.close_positions",
|
|
22
|
-
"mode": "matching",
|
|
23
|
-
"markets": ["BTC", "ETH"],
|
|
24
|
-
"side": "long",
|
|
25
|
-
"timeout_ms": 30000
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
- `mode: "matching"` selects `market`/`symbol` or `markets`/`symbols`.
|
|
30
|
-
- `mode: "all"` selects every live position/order returned by the product.
|
|
31
|
-
- `side` narrows selection when the product returns side information.
|
|
32
|
-
- `selector` can carry the same fields when a nested shape is easier for flow composition.
|
|
33
|
-
|
|
34
|
-
## Examples
|
|
35
|
-
|
|
36
|
-
Close every live Perps position before a proof window:
|
|
37
|
-
|
|
38
|
-
```json
|
|
39
|
-
{ "action": "metamask.perps.close_positions", "mode": "all" }
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Cancel only BTC open orders:
|
|
43
|
-
|
|
44
|
-
```json
|
|
45
|
-
{ "action": "metamask.perps.close_orders", "market": "BTC" }
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Higher-level clean start state:
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
{
|
|
52
|
-
"action": "metamask.perps.ensure_positions",
|
|
53
|
-
"state": "none",
|
|
54
|
-
"mode": "all"
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Provider/network setup belongs in a configurable start-state contract such as `metamask.perps.start_state`, not in duplicate primitive actions:
|
|
59
|
-
|
|
60
|
-
```json
|
|
61
|
-
{
|
|
62
|
-
"flow": "metamask.perps.start_state",
|
|
63
|
-
"params": {
|
|
64
|
-
"provider": "hyperliquid",
|
|
65
|
-
"network": "testnet",
|
|
66
|
-
"page": "market",
|
|
67
|
-
"market": "BTC",
|
|
68
|
-
"positions": { "state": "none", "mode": "all" },
|
|
69
|
-
"orders": { "state": "none", "mode": "all" }
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Position update operations
|
|
75
|
-
|
|
76
|
-
Perps needs more than open/close. When TP/SL, margin, or leverage update coverage is added, prefer one parameterized position-update primitive instead of one adapter file per feature. The primitive should accept a position selector, a small set of update operations, and explicit assertions over the resulting position/order state.
|
|
77
|
-
|
|
78
|
-
That future primitive should compose controller-backed product APIs when that is the supported app path. It must not mutate React/Redux/MobX/DOM/local storage directly.
|
|
79
|
-
|
|
80
|
-
## Direct controller usage
|
|
81
|
-
|
|
82
|
-
When a recipe genuinely needs direct controller access and there is no reusable UI-equivalent flow, the agent should call the product controller directly through the platform bridge/CDP capability documented for that project.
|
|
83
|
-
|
|
84
|
-
The runner should help by documenting discoverable controller capabilities, not by hiding them behind another action vocabulary. For each direct controller capability, document:
|
|
85
|
-
|
|
86
|
-
- controller/API path;
|
|
87
|
-
- supported params;
|
|
88
|
-
- whether it changes state;
|
|
89
|
-
- required preconditions;
|
|
90
|
-
- expected postcondition assertion;
|
|
91
|
-
- redaction rules for trace output.
|
|
92
|
-
|
|
93
|
-
Example documentation shape:
|
|
94
|
-
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"capability": "PerpsController.setTpSl",
|
|
98
|
-
"access": "direct-controller",
|
|
99
|
-
"params": {
|
|
100
|
-
"market": "BTC",
|
|
101
|
-
"takeProfit": { "price": "72000" },
|
|
102
|
-
"stopLoss": { "price": "65000" }
|
|
103
|
-
},
|
|
104
|
-
"postcondition": {
|
|
105
|
-
"action": "metamask.perps.assert_orders",
|
|
106
|
-
"market": "BTC",
|
|
107
|
-
"state": "present"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
State-changing direct controller calls must still be followed by a read/assert step or by an `ensure_*` wrapper that proves the final state.
|
|
113
|
-
|
|
114
|
-
## Limiting live-adapter file count
|
|
115
|
-
|
|
116
|
-
Perps should converge to one domain dispatcher per platform, not one new file for every controller operation. The runner can still expose many manifest actions, but implementation should route through a small domain module:
|
|
117
|
-
|
|
118
|
-
```text
|
|
119
|
-
library/actions/mobile/perps/perps.mjs # shared Mobile Perps operation catalog
|
|
120
|
-
library/actions/extension/perps/perps.mjs # shared Extension Perps operation catalog
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Runner resolution supports a domain dispatcher fallback such as `library/actions/<platform>/perps/perps.mjs` when an action-specific file is absent. That keeps discoverability in the manifest while avoiding a growing pile of tiny wrapper files.
|
|
124
|
-
|
|
125
|
-
## Rule of thumb for adding adapter files
|
|
126
|
-
|
|
127
|
-
Add a named adapter/flow when it represents a reusable product workflow that normally has a UI path and would otherwise waste proof-video time on repetitive setup. Examples: unlock wallet, navigate to Perps, ensure provider/network, open a market, create a baseline position, close selected positions, cancel selected orders, or prepare an order form.
|
|
128
|
-
|
|
129
|
-
Do not add a new adapter file only because a controller exposes another method. For direct controller operations, document the real controller capability and params so the agent can call the product API directly when appropriate.
|
|
130
|
-
|
|
131
|
-
| Need | Preferred shape | Why |
|
|
132
|
-
|---|---|---|
|
|
133
|
-
| Faster setup for a visual proof with a matching UI/user workflow | named flow or semantic adapter, e.g. `ensure_positions`, `close_positions` | Keeps proof videos focused while still using supported app/API paths. |
|
|
134
|
-
| Direct product capability with many variants | documented direct controller capability + required postcondition | Avoids one file per controller method and avoids a useless wrapper vocabulary. |
|
|
135
|
-
| Ticket-specific visual claim | task-local recipe assertion/evidence | Avoids polluting the domain API with one-off checks. |
|
|
136
|
-
| Repeated domain baseline across teams | catalog flow such as `start_state` | Creates a stable starting contract for many recipes. |
|
|
137
|
-
|
|
138
|
-
Direct controller capabilities must still be discoverable in docs/manifest metadata. The metadata should describe the real controller/API path, required params, examples, postconditions, and whether the operation is state-changing. The agent should be able to infer valid direct calls without reverse-engineering app internals first.
|
|
139
|
-
|
|
140
|
-
## Preconditions vs prestate
|
|
141
|
-
|
|
142
|
-
Existing Mobile recipes use pre-conditions such as `wallet.unlocked`, `perps.feature_enabled`, `perps.ready_to_trade`, `perps.sufficient_balance`, `perps.open_position`, `perps.open_position_tpsl`, `perps.open_limit_order`, `perps.not_in_watchlist`, and `perps.trading_flag`.
|
|
143
|
-
|
|
144
|
-
Recipe v1 should keep the same concept, but split it into two different responsibilities:
|
|
145
|
-
|
|
146
|
-
| Concept | Mutates state? | Purpose | Examples |
|
|
147
|
-
|---|---:|---|---|
|
|
148
|
-
| `preconditions` / `requires` | No | Fast fail with actionable reason when the target cannot support the recipe. | `wallet.unlocked`, `perps.feature_enabled`, `perps.trading_flag` |
|
|
149
|
-
| `prestate` / `startState` | Yes, when needed | Converge the app to a configurable baseline before the proof window. | unlock, select account, choose network/provider, close positions/orders, open market |
|
|
150
|
-
|
|
151
|
-
A precondition should not repair state. It answers “is this environment eligible?” A prestate answers “make the environment look like this before the proof starts.”
|
|
152
|
-
|
|
153
|
-
## Recommended Perps base prestate
|
|
154
|
-
|
|
155
|
-
Most Perps recipes should inherit from a configurable base prestate instead of repeating setup inline:
|
|
156
|
-
|
|
157
|
-
```json
|
|
158
|
-
{
|
|
159
|
-
"flow": "metamask.perps.start_state",
|
|
160
|
-
"params": {
|
|
161
|
-
"wallet": { "state": "unlocked", "account": "default" },
|
|
162
|
-
"featureFlags": { "perps": true, "trading": true },
|
|
163
|
-
"provider": "hyperliquid",
|
|
164
|
-
"network": "testnet",
|
|
165
|
-
"readyToTrade": true,
|
|
166
|
-
"balance": { "minWithdrawableUsd": "1" },
|
|
167
|
-
"page": "market",
|
|
168
|
-
"market": "BTC",
|
|
169
|
-
"positions": { "state": "none", "mode": "matching", "markets": ["BTC"] },
|
|
170
|
-
"orders": { "state": "none", "mode": "matching", "markets": ["BTC"] },
|
|
171
|
-
"hud": { "enabled": true, "proofSafe": true }
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
This flow should compose smaller actions/flows:
|
|
177
|
-
|
|
178
|
-
1. `metamask.wallet.ensure_unlocked`
|
|
179
|
-
2. `metamask.wallet.select_account` when requested
|
|
180
|
-
3. provider/network/testnet setup for Hyperliquid or another provider
|
|
181
|
-
4. read-only gates for feature/trading readiness
|
|
182
|
-
5. `metamask.perps.ensure_orders` for order baseline
|
|
183
|
-
6. `metamask.perps.ensure_positions` for position baseline
|
|
184
|
-
7. `ui.navigate` with a manifest-discoverable `page` alias, or raw route/hash fallback
|
|
185
|
-
8. `app.hud` when visual proof should show context and it will not obscure the claim
|
|
186
|
-
|
|
187
|
-
## Base prestate profiles
|
|
188
|
-
|
|
189
|
-
The runner should publish named profiles as examples, but keep them parameterized:
|
|
190
|
-
|
|
191
|
-
| Profile | Intended use | Default params |
|
|
192
|
-
|---|---|---|
|
|
193
|
-
| `perps.clean_market_testnet` | Most visual AC proofs from a clean market screen | Hyperliquid testnet, wallet unlocked, ready to trade, selected market, no selected positions/orders |
|
|
194
|
-
| `perps.open_position_testnet` | TP/SL, margin, close-position proofs | Hyperliquid testnet, selected market, one open position, optional side/notional/leverage |
|
|
195
|
-
| `perps.open_order_testnet` | Limit-order edit/cancel proofs | Hyperliquid testnet, selected market, one open order |
|
|
196
|
-
| `perps.provider_mainnet_readonly` | Read-only balance/provider proofs | Hyperliquid mainnet, no cleanup mutation unless explicitly requested |
|
|
197
|
-
|
|
198
|
-
Profiles are shortcuts, not separate hardcoded actions. A recipe should be able to override provider, network, market, account, positions, orders, balance, page, and HUD behavior.
|
|
199
|
-
|
|
200
|
-
## Recipe v1 shape
|
|
201
|
-
|
|
202
|
-
Recommended shape for a proof recipe:
|
|
203
|
-
|
|
204
|
-
```json
|
|
205
|
-
{
|
|
206
|
-
"preconditions": [
|
|
207
|
-
"wallet.unlocked",
|
|
208
|
-
"perps.feature_enabled",
|
|
209
|
-
"perps.trading_flag"
|
|
210
|
-
],
|
|
211
|
-
"startState": {
|
|
212
|
-
"action": "metamask.perps.start_state",
|
|
213
|
-
"intent": "Converge Perps to a clean BTC testnet baseline before proof",
|
|
214
|
-
"params": {
|
|
215
|
-
"profile": "perps.clean_market_testnet",
|
|
216
|
-
"market": "BTC",
|
|
217
|
-
"positions": { "state": "none", "market": "BTC" },
|
|
218
|
-
"orders": { "state": "none", "market": "BTC" }
|
|
219
|
-
},
|
|
220
|
-
"record": "trace_only"
|
|
221
|
-
},
|
|
222
|
-
"proof": {
|
|
223
|
-
"nodes": {
|
|
224
|
-
"ac-specific-step": {
|
|
225
|
-
"action": "ui.press",
|
|
226
|
-
"intent": "Perform the AC-specific Perps interaction through the UI",
|
|
227
|
-
"test_id": "example",
|
|
228
|
-
"record": "proof_window"
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
The prestate runs before the proof window and remains visible in `trace.json`/`summary.json`; the proof window only records the AC-specific behavior. This preserves review speed without hiding setup from the agent or reviewer.
|
package/docs/recipe-libraries.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Recipe libraries
|
|
2
|
-
|
|
3
|
-
A library shares reusable behavior without coupling it to one ticket:
|
|
4
|
-
|
|
5
|
-
- an **action** is one typed operation supplied by a platform adapter;
|
|
6
|
-
- a **flow** is a reusable parameterized action sequence;
|
|
7
|
-
- a **recipe** is a complete executable proof and owns task acceptance criteria.
|
|
8
|
-
|
|
9
|
-
Use a flow when several recipes repeat the same product journey. Keep ticket copy,
|
|
10
|
-
layout claims, and one-off assertions in the task recipe.
|
|
11
|
-
|
|
12
|
-
## Directory
|
|
13
|
-
|
|
14
|
-
```text
|
|
15
|
-
team-recipes/
|
|
16
|
-
library.json
|
|
17
|
-
flows/
|
|
18
|
-
wallet.flows.json
|
|
19
|
-
recipes/
|
|
20
|
-
onboarding/
|
|
21
|
-
smoke.extension.recipe.json
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
`library.json`:
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"kind": "recipe-library",
|
|
29
|
-
"schema_version": 1,
|
|
30
|
-
"name": "wallet-team",
|
|
31
|
-
"owner": "wallet-team"
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Enable a team library
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
export RECIPE_LIBRARY_PATH="wallet=$HOME/shared-library/wallet-team"
|
|
39
|
-
mm-harness flows
|
|
40
|
-
mm-harness run onboarding.smoke --plan
|
|
41
|
-
mm-harness run onboarding.smoke --artifacts-dir temp/onboarding-proof
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Use `--library wallet=/path/to/library` for a one-command override. Without an
|
|
45
|
-
explicit library, the personal library is read from
|
|
46
|
-
`$FARMSLOT_HOME/recipe-library` (default `~/.farmslot/recipe-library`).
|
|
47
|
-
|
|
48
|
-
Resolution order is recipe-local, explicit/personal/team, then bundled MetaMask.
|
|
49
|
-
The first matching flow wins. Runs print provenance and save resolved definitions
|
|
50
|
-
in `resolved-flows.json`, so shadowing is reviewable.
|
|
51
|
-
|
|
52
|
-
## Promote useful behavior
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
mm-harness flows promote --from recipe.json --flow wallet.ensure_ready --run artifacts
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Promotion requires a description. `ensure_*` flows require a machine-checkable
|
|
59
|
-
postcondition. A passing run stamps verification provenance.
|
|
60
|
-
|
|
61
|
-
## Keep libraries durable
|
|
62
|
-
|
|
63
|
-
- Parameterize before adding another name.
|
|
64
|
-
- Keep setup idempotent and prove postconditions.
|
|
65
|
-
- Keep secrets and wallet material out of libraries.
|
|
66
|
-
- Review shared libraries like code.
|
|
67
|
-
- Re-run their recipes when the product changes; stale provenance is surfaced.
|
|
68
|
-
- Keep generic graph or UI mechanics in Recipe Protocol, not a team library.
|
|
69
|
-
|
|
70
|
-
The bundled examples `runner.smoke`, `wallet.smoke`, and `perps.smoke` show the
|
|
71
|
-
same structure at increasing product specificity.
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Runtime File Conventions
|
|
2
|
-
|
|
3
|
-
This runner uses a small set of file extensions on purpose. The goal is to keep
|
|
4
|
-
MetaMask-specific logic easy to run from either a source checkout or a published
|
|
5
|
-
package without requiring target app builds to transpile runner code.
|
|
6
|
-
|
|
7
|
-
## Extension rules
|
|
8
|
-
|
|
9
|
-
- `src/**/*.ts` — typed runner core: CLI parsing, manifests, adapter binding,
|
|
10
|
-
runtime decisions, and shared helper logic.
|
|
11
|
-
- `library/actions/**/*.mjs`, `adapters/**/*.mjs`, and `scripts/**/*.mjs` —
|
|
12
|
-
standalone ESM modules that Node executes directly with no build step. Use
|
|
13
|
-
these for action adapters and small injected/runtime helpers.
|
|
14
|
-
- `*.cjs` — compatibility islands only. Keep these quarantined for helper code
|
|
15
|
-
that intentionally needs CommonJS semantics, such as portable `require()`
|
|
16
|
-
execution from shell scripts or bridge code shared with older runtime contexts.
|
|
17
|
-
- `*.sh` — thin OS/device orchestration wrappers for tools such as `simctl`,
|
|
18
|
-
`adb`, Chrome launch, tmux, and filesystem setup. Do not put recipe graph
|
|
19
|
-
execution or MetaMask domain semantics in shell.
|
|
20
|
-
- Plain source `*.js` is not allowed. With `"type": "module"`, `.js` would be
|
|
21
|
-
ESM, but it is visually ambiguous in this runner. Use `.mjs` for direct Node
|
|
22
|
-
scripts or `.ts` for typed core code.
|
|
23
|
-
|
|
24
|
-
## Design intent
|
|
25
|
-
|
|
26
|
-
The mix is intentional only when the boundary is clear:
|
|
27
|
-
|
|
28
|
-
1. TypeScript owns maintainable product/runner decisions.
|
|
29
|
-
2. ESM scripts own no-build runtime adapters and injected helpers.
|
|
30
|
-
3. CommonJS stays isolated where the runtime context makes ESM brittle.
|
|
31
|
-
4. Shell stays at the edge for host/device commands.
|
|
32
|
-
|
|
33
|
-
If a file crosses those boundaries, move the logic inward: shell should call a
|
|
34
|
-
Node module, standalone `.mjs` should become typed `src/**/*.ts` when it grows
|
|
35
|
-
shared domain logic, and new compatibility needs should be documented before
|
|
36
|
-
adding another `.cjs` file.
|