@deeeed/metamask-harness 0.28.0 → 0.29.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 (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +41 -0
  3. package/adapters/extension/build-lavamoat.sh +2 -1
  4. package/adapters/extension/ensure-browser.sh +82 -9
  5. package/adapters/extension/inject.mjs +1 -0
  6. package/adapters/extension/launch-browser.cjs +83 -1
  7. package/adapters/extension/lib/chrome-args.cjs +325 -1
  8. package/adapters/extension/lib/playwright-cdp.cjs +34 -0
  9. package/adapters/extension/lib/slot-title.cjs +2 -4
  10. package/adapters/extension/lib/validation-launch-supervisor.cjs +292 -0
  11. package/adapters/extension/lib/validation-process-ownership.cjs +69 -0
  12. package/adapters/extension/reattach.sh +2 -1
  13. package/adapters/extension/sidepanel-toggle.sh +14 -96
  14. package/adapters/extension/wallet-fixture-state.cjs +8 -31
  15. package/adapters/manifest.json +16 -0
  16. package/adapters/shared/private-atomic-write.cjs +47 -0
  17. package/adapters/shared/setup-base.sh +864 -0
  18. package/dist/adapters/extension/runtime.js +367 -24
  19. package/dist/adapters/extension/validation-process-ownership.js +10 -0
  20. package/dist/cli-commands.js +1 -0
  21. package/dist/command-contract.js +12 -0
  22. package/dist/commands/launch/extension.js +130 -19
  23. package/dist/commands/setup-base.js +24 -0
  24. package/dist/mm-harness-cli.js +28 -2
  25. package/library/actions/extension/analytics/consent.mjs +203 -0
  26. package/library/actions/extension/analytics/set_consent.mjs +19 -143
  27. package/library/actions/extension/perps/perps.mjs +2 -16
  28. package/library/actions/extension/perps/state.mjs +20 -0
  29. package/library/actions/extension/wallet/list_accounts.mjs +3 -25
  30. package/library/actions/extension/wallet/read_state.mjs +3 -23
  31. package/library/actions/extension/wallet/select_account.mjs +6 -33
  32. package/library/actions/extension/wallet/setup.mjs +2 -20
  33. package/library/actions/extension/wallet/state.mjs +111 -0
  34. package/library/recipes/runner/action-validation.extension.recipe.json +1 -1
  35. package/library/recipes/runner/action-validation.mobile.recipe.json +1 -1
  36. package/package.json +7 -4
  37. package/scripts/site-contrast.mjs +538 -0
  38. package/site/architecture.html +415 -0
  39. package/site/assets/progress.mjs +272 -0
  40. package/site/assets/style.css +808 -0
  41. package/site/cheatsheet.html +305 -0
  42. package/site/index.html +643 -0
  43. package/site/recipes.html +396 -0
  44. package/site/reviewers.html +374 -0
  45. package/site/tutorials/index.html +180 -0
  46. package/site/tutorials/v1.html +211 -0
  47. package/site/tutorials/v2.html +207 -0
  48. package/site/tutorials/v3.html +214 -0
  49. package/site/tutorials/v4.html +195 -0
  50. package/site/tutorials/v5.html +163 -0
  51. package/site/tutorials/v6.html +165 -0
  52. package/site/tutorials/v7.html +184 -0
@@ -0,0 +1,415 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Architecture — how the pieces fit</title>
7
+ <meta name="description" content="Skills, mm-harness, team recipe libraries, product repos: what lives where, the three workflows, and the mistakes newcomers make.">
8
+ <link rel="stylesheet" href="assets/style.css">
9
+ </head>
10
+ <body data-progress-page="architecture">
11
+ <a class="skip" href="#stack">Skip to the stack map</a>
12
+
13
+ <header class="topbar">
14
+ <div class="wrap topbar-inner">
15
+ <a class="brand" href="index.html">
16
+ <span class="brand-mark" aria-hidden="true"></span>
17
+ <span class="brand-name">mm-harness</span>
18
+ </a>
19
+ <nav class="nav" aria-label="Main">
20
+ <a href="index.html">Start Here</a>
21
+ <a href="recipes.html">Recipes</a>
22
+ <a href="cheatsheet.html">Cheatsheet</a>
23
+ <a href="architecture.html" aria-current="page">Architecture</a>
24
+ <a href="tutorials/index.html">Tutorials</a>
25
+ <a href="reviewers.html">For Reviewers</a>
26
+ </nav>
27
+ </div>
28
+ </header>
29
+
30
+ <main>
31
+ <section class="wrap hero" style="padding-bottom:1rem">
32
+ <span class="eyebrow">The stack</span>
33
+ <h1>How the pieces fit together</h1>
34
+ <p class="lede">
35
+ Four moving parts, two of which people routinely confuse. What each layer is, where it lives, which
36
+ workflow you are in, and the mistakes that cost newcomers their first afternoon.
37
+ </p>
38
+ </section>
39
+
40
+ <section class="wrap">
41
+ <h2 id="model">The one-paragraph model</h2>
42
+ <div class="doctrine">
43
+ <p>
44
+ <span class="k">A recipe proves a task with actions.</span> Recipes are JSON graphs of typed
45
+ actions; <code>mm-harness</code> executes them against a real app and produces an evidence bundle
46
+ a reviewer can trust. <strong>Skills</strong> teach an agent a workflow — author a recipe, review
47
+ a PR, validate a release. <strong>Recipe libraries</strong> hold each team's recipes and domain
48
+ actions. Compose in that order, against the product repo under test.
49
+ </p>
50
+ </div>
51
+ </section>
52
+
53
+ <section class="wrap">
54
+ <h2 id="stack">The layers</h2>
55
+ <p>Click a layer to see what it is responsible for and when you touch it.</p>
56
+
57
+ <div class="stack">
58
+ <button type="button" class="layer" aria-expanded="false" aria-controls="l-skills">
59
+ <span class="layer-n">1</span>
60
+ <span class="layer-name">Skills</span>
61
+ <span class="layer-sub">the workflow an agent follows</span>
62
+ </button>
63
+ <div class="layer-detail" id="l-skills" hidden>
64
+ <p>
65
+ A packaged workflow — author a recipe from a criterion, review a pull request, validate a
66
+ release — turning "figure it out" into a procedure with gates you can steer.
67
+ </p>
68
+ <p>
69
+ Skills live in the internal <code>Consensys/skills</code> repo, installed per checkout with that
70
+ repo's tooling. <strong>You do not need skills to run a recipe</strong>, only to have an agent
71
+ follow a proven workflow instead of improvising one.
72
+ <a href="tutorials/v3.html">V3 walks the install.</a>
73
+ </p>
74
+ </div>
75
+
76
+ <div class="arrow" aria-hidden="true">↓</div>
77
+
78
+ <button type="button" class="layer" aria-expanded="false" aria-controls="l-harness">
79
+ <span class="layer-n">2</span>
80
+ <span class="layer-name">mm-harness</span>
81
+ <span class="layer-sub">execution and evidence</span>
82
+ </button>
83
+ <div class="layer-detail" id="l-harness" hidden>
84
+ <p>
85
+ The CLI: launches the app, exposes the action vocabulary, executes recipe graphs against a real
86
+ build, writes the evidence. The only layer everyone needs, and the only one installed globally:
87
+ </p>
88
+ <div class="cmd"><pre><code><span class="p">$ </span>npm i -g @deeeed/metamask-harness@latest</code></pre></div>
89
+ <p style="margin-bottom:0">
90
+ It owns MetaMask runtime control and the domain capabilities; the generic graph engine and the
91
+ evidence schemas underneath it are separate packages it depends on.
92
+ </p>
93
+ </div>
94
+
95
+ <div class="arrow" aria-hidden="true">↓</div>
96
+
97
+ <button type="button" class="layer" aria-expanded="false" aria-controls="l-libs">
98
+ <span class="layer-n">3</span>
99
+ <span class="layer-name">Team recipe libraries</span>
100
+ <span class="layer-sub">your team's recipes and domain actions</span>
101
+ </button>
102
+ <div class="layer-detail" id="l-libs" hidden>
103
+ <p>
104
+ A team-owned repo of reusable recipes plus the domain actions they need. The harness ships a
105
+ bundled library so a fresh install can prove something immediately; your team's library is where
106
+ the recipes that matter to your work live.
107
+ </p>
108
+ <p>Libraries must be declared, or the harness only sees the bundled set:</p>
109
+ <div class="cmd"><pre><code><span class="p">$ </span>export RECIPE_LIBRARY_PATH="perps=$HOME/dev/my-recipe-library"
110
+ <span class="p">$ </span>mm-harness run &lt;recipe&gt; --library perps=$HOME/dev/my-recipe-library</code></pre></div>
111
+ <p style="margin-bottom:0">
112
+ Each library carries its own setup notes — read those before running anything domain-specific.
113
+ </p>
114
+ </div>
115
+
116
+ <div class="arrow" aria-hidden="true">↓</div>
117
+
118
+ <button type="button" class="layer" aria-expanded="false" aria-controls="l-product">
119
+ <span class="layer-n">4</span>
120
+ <span class="layer-name">Product repos</span>
121
+ <span class="layer-sub">the thing under test</span>
122
+ </button>
123
+ <div class="layer-detail" id="l-product" hidden>
124
+ <p>
125
+ <code>metamask-extension</code>, <code>metamask-mobile</code>, and <code>core</code>. Recipes
126
+ execute against a real build, never a mock. Run <code>mm-harness</code> from inside the checkout
127
+ and it detects the product, ports, and runtime paths.
128
+ </p>
129
+ <p style="margin-bottom:0">
130
+ They differ, and the harness says so rather than pretending otherwise: Core is headless with
131
+ nothing to launch and no UI actions; Mobile carries video capture; Extension is screenshots
132
+ only.
133
+ </p>
134
+ </div>
135
+ </div>
136
+ </section>
137
+
138
+ <section class="wrap">
139
+ <h2 id="loop">The improvement loop</h2>
140
+ <p>The stack is arranged so each run can leave the next one better informed.</p>
141
+
142
+ <div class="doctrine">
143
+ <p>
144
+ <span class="k">Learnings are written, not collected.</span> The checklist an agent follows carries
145
+ a step instructing it to write what it learned as human-readable markdown, bundled beside the
146
+ execution plan and the evidence. A run ends with prose — what was hard, what surprised it, what
147
+ the next run should know — sitting next to the proof. A deliverable, not telemetry: nobody mines
148
+ traces for insight; the agent is asked and answers.
149
+ </p>
150
+ </div>
151
+
152
+ <h3>The chain</h3>
153
+ <div class="stack">
154
+ <div class="layer layer-static">
155
+ <span class="layer-n">1</span>
156
+ <span class="layer-name">A checklist step asks for learnings</span>
157
+ <span class="layer-sub">part of the execution plan</span>
158
+ </div>
159
+ <div class="arrow" aria-hidden="true">↓</div>
160
+ <div class="layer layer-static">
161
+ <span class="layer-n">2</span>
162
+ <span class="layer-name">The run writes learnings.md beside its evidence</span>
163
+ <span class="layer-sub">prose, in the run artifacts</span>
164
+ </div>
165
+ <div class="arrow" aria-hidden="true">↓</div>
166
+ <div class="layer layer-static">
167
+ <span class="layer-n">3</span>
168
+ <span class="layer-name">Curation promotes the durable ones</span>
169
+ <span class="layer-sub">a human decides what generalises</span>
170
+ </div>
171
+ <div class="arrow" aria-hidden="true">↓</div>
172
+ <div class="layer layer-static">
173
+ <span class="layer-n">4</span>
174
+ <span class="layer-name">They become team knowledge</span>
175
+ <span class="layer-sub">in the library, beside the recipes</span>
176
+ </div>
177
+ <div class="arrow" aria-hidden="true">↓</div>
178
+ <div class="layer layer-static">
179
+ <span class="layer-n">5</span>
180
+ <span class="layer-name">The next run loads it before acting</span>
181
+ <span class="layer-sub">discovery, not recall</span>
182
+ </div>
183
+ </div>
184
+
185
+ <p>
186
+ Step 3 is a person on purpose: a run produces plenty of true-but-local detail, and promoting all of
187
+ it buries what matters — the same judgement as deciding what belongs in a code comment.
188
+ </p>
189
+
190
+ <div class="note blue">
191
+ <span class="note-title">Where learnings collect</span>
192
+ <p>
193
+ Scrubbed packages from approved runs land in
194
+ <code>MetaMask/experimental-distributed-learnings</code>, a private append-only inbox — the same
195
+ repository as <code>experimental-agentic-learnings</code>, which was its earlier name and still
196
+ redirects. Capture records the observation, review later decides whether it warrants a proposal,
197
+ and proposals go to whichever repo owns the affected layer. Sharing is opt-in: without a local
198
+ <code>learning.config.json</code> a run stages locally and publishes nothing. Packages are
199
+ date-partitioned and the indexes are scaffolded, but only one day of runs has landed so far —
200
+ collection is beginning, so treat it as the destination rather than a corpus to read today.
201
+ </p>
202
+ </div>
203
+
204
+ <h3>What works today</h3>
205
+
206
+ <div class="table-scroll">
207
+ <table>
208
+ <thead><tr><th>Mechanism</th><th>Its part in the loop</th></tr></thead>
209
+ <tbody>
210
+ <tr>
211
+ <td>The evidence bundle</td>
212
+ <td>Produces the raw material. <code>diagnostics.json</code> in particular is where side findings land — application warnings and errors captured during the run, kept out of the verdict precisely so they survive as observations rather than being flattened into pass or fail.</td>
213
+ </tr>
214
+ <tr>
215
+ <td>Team recipe libraries</td>
216
+ <td>The place shared understanding accumulates. A recipe that encodes "get to a clean market first" <em>is</em> a piece of team knowledge, already reusable by everyone who declares the library.</td>
217
+ </tr>
218
+ <tr>
219
+ <td><code>mm-harness recipe-quality</code></td>
220
+ <td>Turns a review's verdicts into a quality artifact, so an assessment of a proof is itself a durable record rather than a comment that scrolls away.</td>
221
+ </tr>
222
+ <tr>
223
+ <td><code>mm-harness execution-template</code></td>
224
+ <td>Discovers, validates, and materialises shared agent checklists — a curated procedure written once and picked up by everyone, which is the loop working at the level of process.</td>
225
+ </tr>
226
+ <tr>
227
+ <td>Skills</td>
228
+ <td>The same idea for workflows. A skill is a procedure someone got right, packaged so nobody has to rediscover it.</td>
229
+ </tr>
230
+ </tbody>
231
+ </table>
232
+ </div>
233
+
234
+ <h3>Where this is heading</h3>
235
+ <p>
236
+ The gap is the middle of the loop: recipes and actions have a home in a team library; the sharper
237
+ things a run teaches you do not yet. Worth capturing:
238
+ </p>
239
+
240
+ <ul>
241
+ <li><strong>Gotchas</strong> — the non-obvious precondition that cost someone an afternoon, written down once.</li>
242
+ <li><strong>Screen maps</strong> — how a surface is actually reached and identified in the current build, so the next author is not re-deriving it.</li>
243
+ <li><strong>Flakes</strong> — the step known to be intermittent, with what is known about when and why, so an author can distinguish a real failure from a familiar one.</li>
244
+ </ul>
245
+
246
+ <p>
247
+ The intended shape is the one proven everywhere else here: <strong>discovery rather than
248
+ recall</strong>. Just as you ask the checkout what actions exist, you would ask what is already
249
+ known about a surface before authoring against it — a <code>knowledge</code> surface alongside
250
+ <code>actions</code> and <code>run --list</code>, resolving the way libraries already do, layered
251
+ most-specific-wins: yours, your team's, the workflow's, then defaults shipping with the harness
252
+ release so tool facts cannot drift out of date in a document nobody re-reads.
253
+ </p>
254
+
255
+ <p>
256
+ Entries stay small and curated: a short index of what exists and when to load it, topic files under
257
+ a size cap, each entry carrying a stable id and the same symptom → cause → what to do shape the
258
+ error messages use. Promotion happens through an ordinary reviewed pull request, so a human is in
259
+ the loop by construction.
260
+ </p>
261
+
262
+ <div class="note">
263
+ <span class="note-title">Being straight about status</span>
264
+ <p style="margin-bottom:0">
265
+ <strong>Not shipping yet.</strong> There is no <code>knowledge</code> command today, which is why
266
+ you will not find one in a copyable block on this page. Meanwhile the useful part is unblocked:
267
+ keep what your runs teach you in the library repo beside the recipes. Tooling makes it
268
+ discoverable later; writing it down is what makes it exist.
269
+ </p>
270
+ </div>
271
+
272
+ <div class="doctrine">
273
+ <p>
274
+ <span class="k">The skills teach the workflow; the knowledge teaches the product.</span> Runs
275
+ produce learnings, curation promotes them, discovery serves them to every run after.
276
+ </p>
277
+ </div>
278
+ </section>
279
+
280
+ <section class="wrap">
281
+ <h2 id="libraries">Where everything lives</h2>
282
+ <div class="table-scroll">
283
+ <table>
284
+ <thead><tr><th>What</th><th>Is</th><th>You need it when</th></tr></thead>
285
+ <tbody>
286
+ <tr>
287
+ <td><code>@deeeed/metamask-harness</code><br><span style="color:var(--text-faint);font-size:.85rem">the <code>mm-harness</code> CLI, on npm</span></td>
288
+ <td>The execution engine and evidence producer: <code>doctor</code>, <code>launch</code>, <code>actions</code>, <code>call</code>, <code>run</code>, <code>last</code>.</td>
289
+ <td><strong>Always.</strong> Install and update with <code>npm i -g @deeeed/metamask-harness@latest</code>.</td>
290
+ </tr>
291
+ <tr>
292
+ <td><code>Consensys/skills</code><br><span style="color:var(--text-faint);font-size:.85rem">internal repo</span></td>
293
+ <td>Agentic skills — recipe authoring, PR QA review, release validation. Installed into a checkout via that repo's tooling.</td>
294
+ <td>When you want an agent to follow a proven workflow instead of improvising one.</td>
295
+ </tr>
296
+ <tr>
297
+ <td>Team recipe libraries<br><span style="color:var(--text-faint);font-size:.85rem">e.g. the perps and money-movement libraries</span></td>
298
+ <td>Team-owned recipes, domain actions, and domain knowledge. Declared with <code>RECIPE_LIBRARY_PATH</code> or <code>--library</code>.</td>
299
+ <td>When running or authoring anything domain-specific. <a href="tutorials/v3.html#steps">V3 walks the setup</a> with the perps library as the worked example.</td>
300
+ </tr>
301
+ <tr>
302
+ <td>Product repos<br><span style="color:var(--text-faint);font-size:.85rem">extension · mobile · core</span></td>
303
+ <td>The thing under test. The harness runs against a real checkout and a real build.</td>
304
+ <td><strong>Always</strong> — there is nothing to prove without one.</td>
305
+ </tr>
306
+ </tbody>
307
+ </table>
308
+ </div>
309
+ </section>
310
+
311
+ <section class="wrap">
312
+ <h2 id="workflows">The three workflows — pick one, do not blend them</h2>
313
+ <p>Most confusion here is someone doing two at once. They need different setup and fail differently.</p>
314
+
315
+ <div class="grid grid-3">
316
+ <div class="card">
317
+ <h3>1 · Run an existing recipe</h3>
318
+ <p style="color:var(--text-dim);font-size:.92rem">No skills needed. This is the majority of daily use.</p>
319
+ <div class="cmd"><pre><code><span class="p">$ </span>mm-harness update
320
+ <span class="p">$ </span>cd &lt;product checkout&gt;
321
+ <span class="p">$ </span>export RECIPE_LIBRARY_PATH=&lt;name=path&gt;
322
+ <span class="p">$ </span>mm-harness doctor
323
+ <span class="p">$ </span>mm-harness launch
324
+ <span class="p">$ </span>mm-harness run &lt;recipe&gt; \
325
+ --artifacts-dir ./out</code></pre></div>
326
+ <p style="margin-bottom:0;font-size:.92rem">Evidence lands in the artifacts dir. That is the whole workflow.</p>
327
+ </div>
328
+
329
+ <div class="card">
330
+ <h3>2 · Author a recipe</h3>
331
+ <p style="color:var(--text-dim);font-size:.92rem">For a specific acceptance criterion. Skills earn their keep here.</p>
332
+ <p style="font-size:.92rem">
333
+ Install the recipe-authoring skill. It discovers the vocabulary with
334
+ <code>mm-harness actions</code> — <strong>the discovered list is law, action names are never
335
+ invented</strong> — composes the graph, validates it with <code>run --plan</code>, then runs it
336
+ for real.
337
+ </p>
338
+ <p style="margin-bottom:0;font-size:.92rem">
339
+ Expect one honest failure-and-fix loop. That is the error messages doing their job.
340
+ </p>
341
+ </div>
342
+
343
+ <div class="card">
344
+ <h3>3 · Review a PR / validate a release</h3>
345
+ <p style="color:var(--text-dim);font-size:.92rem">Requires the QA skills.</p>
346
+ <p style="font-size:.92rem">
347
+ Give the skill one PR URL. It extracts the acceptance criteria verbatim — missing ones become a
348
+ hygiene finding, never an invented criterion — waits for you to confirm or edit the table, runs
349
+ the proof on a real device, and produces a per-criterion verdict with evidence paths.
350
+ </p>
351
+ <p style="margin-bottom:0;font-size:.92rem">
352
+ A criterion the surface genuinely cannot prove is reported as needing a human, not quietly
353
+ passed.
354
+ </p>
355
+ </div>
356
+ </div>
357
+
358
+ <div class="note blue">
359
+ <span class="note-title">Why "do not blend them" is a real instruction</span>
360
+ <p>
361
+ Running a recipe needs no skills; reviewing a PR does. Install everything and ask an agent to
362
+ "just handle it" and you get an agent choosing between procedures with no basis to pick. Name the
363
+ workflow you are in.
364
+ </p>
365
+ </div>
366
+ </section>
367
+
368
+ <section class="wrap">
369
+ <h2 id="mistakes">The five mistakes every newcomer makes</h2>
370
+
371
+ <ol style="padding-left:1.2rem">
372
+ <li style="margin-bottom:1rem">
373
+ <strong>Asking the agent to figure it all out from one sentence.</strong> The skills <em>are</em>
374
+ the figured-out part. Name the workflow you want; do not make the agent guess which of the three
375
+ you are in.
376
+ </li>
377
+ <li style="margin-bottom:1rem">
378
+ <strong>A stale harness.</strong> This one costs the most afternoons. The CLI ships often and
379
+ recipes assume current behaviour. Run <code>mm-harness update</code> before you debug anything
380
+ that "used to work".
381
+ </li>
382
+ <li style="margin-bottom:1rem">
383
+ <strong>Not declaring the library.</strong> Without <code>RECIPE_LIBRARY_PATH</code> (or
384
+ <code>--library</code>) the harness only sees bundled recipes — so your team's recipe appears not
385
+ to exist, and the error is telling the literal truth.
386
+ </li>
387
+ <li style="margin-bottom:1rem">
388
+ <strong>Skipping <code>doctor</code>.</strong> It tells you exactly what is missing and the exact
389
+ command that fixes it. Every error in this stack carries a <code>Next:</code> action. Read them —
390
+ that is the whole design.
391
+ </li>
392
+ <li>
393
+ <strong>Blending the workflows.</strong> See above. Mixing "run a recipe" with "review a PR"
394
+ confuses the agent and produces work you then have to check by hand.
395
+ </li>
396
+ </ol>
397
+
398
+ <hr class="sep">
399
+ <div class="btn-row">
400
+ <a class="btn btn-primary" href="index.html#steps">Do the walkthrough →</a>
401
+ <a class="btn btn-ghost" href="reviewers.html">Read an evidence bundle</a>
402
+ </div>
403
+ </section>
404
+ </main>
405
+
406
+ <footer class="footer">
407
+ <div class="wrap">
408
+ <p>Internal getting-started guide for the MetaMask agentic coding workflow. Not official MetaMask product documentation.</p>
409
+ <p>Verified against mm-harness 0.26+.</p>
410
+ </div>
411
+ </footer>
412
+
413
+ <script type="module" src="assets/progress.mjs"></script>
414
+ </body>
415
+ </html>