@blackbelt-technology/frontend-mockup-loop 0.11.0 → 0.12.1

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 (49) hide show
  1. package/.pi/skills/frontend-mockup-loop/SKILL.md +87 -8
  2. package/README.md +47 -2
  3. package/package.json +43 -4
  4. package/references/live-mock-site.md +332 -0
  5. package/site/Site.tsx +627 -0
  6. package/site/clock.ts +39 -0
  7. package/site/fixtures.ts +144 -0
  8. package/site/frame-env.ts +59 -0
  9. package/site/kit.tsx +175 -0
  10. package/site/main.tsx +11 -0
  11. package/site/pane-runtime.ts +230 -0
  12. package/site/pane-scroll-guard.ts +70 -0
  13. package/site/ring-line.ts +100 -0
  14. package/site/script.ts +201 -0
  15. package/site/site.css +179 -0
  16. package/site/step-gate.ts +138 -0
  17. package/site/tsconfig.json +16 -0
  18. package/site/virtual.d.ts +16 -0
  19. package/src/extension.ts +189 -58
  20. package/src/mock-site/base.d.mts +2 -0
  21. package/src/mock-site/base.mjs +28 -0
  22. package/src/mock-site/browser.d.mts +8 -0
  23. package/src/mock-site/browser.mjs +72 -0
  24. package/src/mock-site/capture.d.mts +8 -0
  25. package/src/mock-site/capture.mjs +221 -0
  26. package/src/mock-site/check.mjs +8 -0
  27. package/src/mock-site/cli.d.mts +3 -0
  28. package/src/mock-site/cli.mjs +96 -0
  29. package/src/mock-site/decisions.d.mts +6 -0
  30. package/src/mock-site/decisions.mjs +71 -0
  31. package/src/mock-site/discover.d.mts +7 -0
  32. package/src/mock-site/discover.mjs +137 -0
  33. package/src/mock-site/env.d.mts +15 -0
  34. package/src/mock-site/env.mjs +228 -0
  35. package/src/mock-site/frameworks.d.mts +5 -0
  36. package/src/mock-site/frameworks.mjs +27 -0
  37. package/src/mock-site/headless.d.mts +9 -0
  38. package/src/mock-site/headless.mjs +207 -0
  39. package/src/mock-site/locate.d.mts +3 -0
  40. package/src/mock-site/locate.mjs +30 -0
  41. package/src/mock-site/options.d.mts +19 -0
  42. package/src/mock-site/options.mjs +45 -0
  43. package/src/mock-site/plugin.d.mts +21 -0
  44. package/src/mock-site/plugin.mjs +191 -0
  45. package/src/mock-site/refs.d.mts +7 -0
  46. package/src/mock-site/refs.mjs +65 -0
  47. package/src/mock-site/serve-cli.mjs +43 -0
  48. package/src/mock-site/video.mjs +8 -0
  49. package/src/mock-site-serve.ts +186 -0
@@ -4,7 +4,7 @@ description: "Plan, build, and iterate UX-friendly frontend mockups via a ground
4
4
  license: MIT
5
5
  metadata:
6
6
  author: blackbelt-technology
7
- version: "0.2"
7
+ version: "0.3"
8
8
  ---
9
9
 
10
10
  # frontend-mockup-loop
@@ -134,11 +134,65 @@ references a design token — never a raw hex or px literal.** If a surface need
134
134
  a token that doesn't exist, add it to the theme layer first, then cite it in
135
135
  the contract. This file is what stops screens from drifting apart.
136
136
 
137
- ### 3. MOCKUP — diverge in HTML, serve it live
138
- Build standalone HTML/Tailwind mockups grounded in steps 1–2. Serve them with
139
- `serve_mockup` and hand back the clickable **local + LAN URL** (the LAN URL
140
- opens on a phone) — **not a screenshot** — so the human reacts to a real page.
141
- Render dark AND light.
137
+ ### 3. MOCKUP — live components, mandatory default
138
+ **Any mock, mockup, UI-option, variant or redesign request in a project the mock
139
+ site can build is a live-component mock — no exceptions by habit.** One page per
140
+ `mockups/<yyyy-mm-dd-slug>/mock.tsx` renders the app's REAL components in
141
+ Current | Proposed frames, with numbered rings (`Issue` red / `Fix` green) around
142
+ the parts that change and a `#ref` link for every page / frame / side / ring /
143
+ step. The site inherits the app's own build config (package.json `mockSite`
144
+ `{ launcher, config }`, else detected), so no aliases or plugins are copied.
145
+ Full guide: `references/live-mock-site.md`.
146
+
147
+ **Static HTML is a named exception, never a default.** Only (a) a pure geometry
148
+ repro, or (b) a project with no buildable components. "No components yet" does
149
+ NOT apply when the surface is composed of existing app components. Say which
150
+ exception applies whenever you build one; a static board lives in its own
151
+ directory with a `STATIC.md` naming the exception, served with `serve_mockup`.
152
+
153
+ **Every mock starts with a Locate frame.** A close-up of a part never shows where it
154
+ lives. Every live mock you create or edit declares `locate` before it is shown: the
155
+ whole app page built from the REAL app shell, opened at the landing view, with a
156
+ `script` of only the steps a user takes to reach the part, ending with
157
+ `act: "spot"` on the reviewed part (dims the rest, labels it `You are here: <say>`).
158
+ For a part that does not exist yet, the path clicks its proposed entry point (the
159
+ new button) and spots the new part. A mock with a `phone: true` frame also declares
160
+ `locate.phone` (the phone walk in a real 375px pane). The site shows Locate first
161
+ (`#<id>/locate`, `#<id>/locate-phone`); a mock without it shows `NO LOCATE`. An
162
+ existing mock you only show (not edit) needs no Locate. Static boards (the exception
163
+ above) and the package's example mocks are exempt.
164
+
165
+ **Fidelity rules — confirm all four before showing a mock:**
166
+ - **R1 same surroundings** — both panes render the same shell (frame
167
+ `surroundings`, or bare in both).
168
+ - **R2 Current is today** — Current renders the SHIPPED components with today's
169
+ props; never a redraw or copied markup.
170
+ - **R3 only ringed parts differ** — anything that differs between panes is ringed.
171
+ - **R4 real data** — fixtures follow real record shapes (`mock-capture` records
172
+ them); real product nouns, never placeholder names.
173
+
174
+ **Behaviour is shown, not described.** When the reviewer must judge an
175
+ interaction, give the frame a `script` (click / type / clear / hover / press /
176
+ wait on the real DOM, `unless` / `expect` per step) over a fixture factory
177
+ (`fixtures`, fresh per pane and loop). Check it with `mock-check <ref> --loops 10`
178
+ before showing it. A paused scripted frame steps with ◀ / ▶ (back replays on
179
+ fresh fixtures), so the reviewer can walk the interaction one step at a time.
180
+
181
+ **Show it with the package tools.** Serve with `serve_mock_site{}` first (the check
182
+ runs against the running site; pass `--url` for a non-default port). Before showing
183
+ a mock you created or edited, run `mock-check <mock-id>` and get a zero exit: it
184
+ reports Locate problems and runs the Locate frame(s) and every scripted frame. Show
185
+ the returned URL to the user (LAN URL only for a phone check) — **not a
186
+ screenshot**. The first reference you give is `#<id>/locate`; for an untouched mock
187
+ without Locate, its first frame `#<id>/1`.
188
+ Every question to the user about a mock carries the full clickable `#ref` URL of
189
+ each page, frame, side, ring or step it concerns (e.g. both rings when asking
190
+ the user to pick between two variants). Render dark AND light.
191
+
192
+ **Decisions are recorded by you, with the CLI.** The site shows decisions
193
+ read-only. After the user's verdict in conversation (or your own scored review),
194
+ run `mock-decide accept <ref> ["note"]` or `mock-decide reject <ref> "why"` (a
195
+ reject always carries a reason) and report what was recorded.
142
196
 
143
197
  ### 4. TEST — run the expert-UX evaluation protocol
144
198
  Run `score_mockup` to capture full-page screenshots at mobile/tablet/desktop
@@ -175,10 +229,27 @@ the change's notes.
175
229
 
176
230
  - `serve_mockup{dir, port?, stop?}` — Node static server on 0.0.0.0; returns
177
231
  local + LAN URLs. Zero external deps.
232
+ - `serve_mock_site{dir?, port?, lan?, base?, stop?}` — start the project's
233
+ live-component mock site through the project's own launcher with the
234
+ inherited build config, plus the optional `mockups/mock-site.config.ts`
235
+ options (default port 5299; reserved ports refused; localhost-only unless
236
+ `lan`, and LAN clients are view-only). The result names the launcher and app
237
+ config used. `base` serves the site under a URL path prefix (`/some/prefix/`:
238
+ letters, digits, `. _ ~ -` segments, starts and ends with `/`; `/` = none). Without
239
+ it the tool may be handed a base by its host; when it is, show the URL the tool
240
+ returns exactly as printed (it already contains the base).
241
+ - CLIs: `mock-decide list|accept|reject|reopen|adoptable|move` (the only writer
242
+ of `decision.json`, `by: "agent"`), `mock-capture <url> <mockDir>` (HTTP →
243
+ redacted `fixtures.har.json`; refuses on a surviving secret),
244
+ `mock-check <mock-id | ref> [--loops N]` (headless script loops, default 3, non-zero on
245
+ a failed loop; a mock id first reports Locate problems, then runs the Locate
246
+ frame(s) and every scripted frame, one line per pane with its mean loop time), `mock-video <ref> [--out f.webm]` (one loop; default under the
247
+ project's build cache).
178
248
  - `score_mockup{url, widths?, outDir?, system?}` — Playwright breakpoint screenshots +
179
249
  scoring rubric. Chromium is declared in this package's `pi.tools` (optional
180
- `pw-browser` probe); absent → install guidance via the registry's Install
181
- dropdown or `pi-dashboard-ensure` (`npx playwright@1.62.1 install chromium`).
250
+ `pw-browser` probe). When Playwright's pinned build is missing it tries the
251
+ cached builds, newest first; none launches → install guidance
252
+ (`npx playwright install chromium`).
182
253
  - `init_ui_contract{path?, force?, system?, refresh?}` — scaffold the
183
254
  token-referencing contract. With `system`, write that preset's DTCG contract
184
255
  (offline snapshot; `refresh` re-fetches upstream first). No `system` →
@@ -190,6 +261,14 @@ the change's notes.
190
261
 
191
262
  ## Pitfalls
192
263
 
264
+ - Live mock site: decisions are per PAGE (never per frame), recorded only with
265
+ `mock-decide`; a reject needs a reason. Unfixtured requests show under
266
+ "Missing fixtures": add a fixture, never a live backend. A ring adds one wrapper element — use `block` for grid/flex children,
267
+ and know that `>` / `first:` / `space-x-*` selectors can shift. App overlays
268
+ portaled to `document.body` escape pane containment: render dialogs inline. A
269
+ rejected mock is revised and reopened, or deleted together with its
270
+ `mockups/AGENTS.md` row.
271
+
193
272
  - Do NOT verify against a live/production server — isolate the env so mockup
194
273
  edits actually load.
195
274
  - Do NOT put raw hex/px in the contract or mockups; reference tokens, else
package/README.md CHANGED
@@ -28,12 +28,56 @@ This registers:
28
28
  - **Tools** the agent can call:
29
29
  | Tool | Purpose |
30
30
  |------|---------|
31
- | `serve_mockup` | Serve a mockup dir over HTTP on `0.0.0.0`; returns clickable **local + LAN** URLs (LAN works on a phone). Zero deps. |
31
+ | `serve_mockup` | Serve a mockup dir (inside the session cwd) over HTTP, **loopback-only by default**; pass `lan:true` to also listen on the LAN (phone check). Returns token URLs (`http://localhost:<port>/<token>/`). Zero deps. **Breaking:** root-relative links like `/style.css` no longer resolve under the token prefix — use relative links (`style.css`). |
32
32
  | `score_mockup` | Capture full-page screenshots at mobile/tablet/desktop widths via Playwright; returns paths + a scoring rubric. With `system`, uses that preset's boolean rubric. |
33
33
  | `init_ui_contract` | Scaffold a token-referencing `ui-contract.md` consistency control plane. With `system`, write that preset's DTCG token contract. |
34
34
  | `list_design_systems` | Enumerate the selectable design-system presets. |
35
35
  | `validate_mockup` | Run the layered validation pipeline for a system (L1+L2 gates, L3+L4 advisory); returns `{ gates, advisory, pass }`. |
36
+ | `serve_mock_site` | Start the project's **live-component mock site** through the project's own launcher with its inherited build config (port 5299, localhost only unless `lan`). Show the URL to the user. |
36
37
  - **Command** `/mockup-loop` — print the loop and point at the skill.
38
+ - **Bins** `mock-decide` (records a page decision; the only writer), `mock-capture`
39
+ (HTTP traffic → redacted fixtures), `mock-check` (headless script loops),
40
+ `mock-video` (one loop to `.webm`).
41
+
42
+ ## Live-component mock site
43
+
44
+ For React projects, mocks render the app's **real components** instead of
45
+ hand-built HTML. One directory per mock page, `mockups/<yyyy-mm-dd-slug>/mock.tsx`:
46
+
47
+ ```tsx
48
+ import { Fix, Issue, type Mock } from "mock-site/kit";
49
+ const mock: Mock = { title: "Settings - save bar", category: "Settings", frames: [
50
+ { title: "Settings - desktop",
51
+ current: <Issue n={1} tip="Save hidden below the fold"><Settings {...today} /></Issue>,
52
+ proposed: <Fix n={1} tip="Sticky save bar"><Settings {...next} /></Fix> },
53
+ ] };
54
+ export default mock;
55
+ ```
56
+
57
+ - **Exact environment**: the site inherits the app's own build config (aliases,
58
+ plugins, css, define) through the project's launcher — declared in
59
+ `package.json` `"mockSite": { "launcher", "config" }` or detected. No mirrored
60
+ config; `mockups/mock-site.config.ts` is an optional options object.
61
+ - Current | Proposed (or New) panes; `phone: true` renders a real 375px iframe;
62
+ `surroundings` wraps both panes in the same real app shell.
63
+ - Numbered rings (`Issue` red, `Fix` green) circle the elements that change.
64
+ - **Fixtures**: a per-pane factory answers the app's HTTP / WebSocket traffic
65
+ in-page; unanswered requests are listed as missing fixtures.
66
+ `mock-capture` records real traffic, redacted, refusing on secrets.
67
+ - **Scripts**: real click / type / hover steps on the real components with a
68
+ visible pointer, looped; `mock-check` proves them, `mock-video` records them.
69
+ - Decisions are read-only in the site; the agent records them with
70
+ `mock-decide accept|reject <ref> "why"` into `mockups/<id>/decision.json`.
71
+ - Every page, frame, side, ring and step has a link: `#<id>/<frame>/<side>/<ring|step-k>`.
72
+ - Themes come from the options (first = default; `system` follows the OS).
73
+
74
+ Setup and the full authoring rules:
75
+ [`references/live-mock-site.md`](references/live-mock-site.md). Install it in
76
+ the project too (`npm i -D @blackbelt-technology/frontend-mockup-loop`) so the
77
+ site can load it; `pi install` only gives pi the tools. Needs `vite` and
78
+ `react` / `react-dom` in the project (optional peers); fixtures need
79
+ `@mswjs/interceptors`, scripts `@testing-library/user-event` (optional peers,
80
+ loaded only by those panes).
37
81
 
38
82
  ## Selectable design systems
39
83
 
@@ -64,7 +108,8 @@ tools' `system` param) to target a specific system. v1 presets:
64
108
  `hig-doctor`, `material3-mcp`, MUI/Fluent eslint plugins, `lumo`.
65
109
  - `score_mockup` uses Playwright if present — enable breakpoint capture with
66
110
  `npm i -D playwright && npx playwright install chromium`; without it,
67
- `score_mockup` returns the rubric plus manual-capture guidance.
111
+ `score_mockup` returns the rubric plus manual-capture guidance. A missing
112
+ pinned browser build falls back to the cached builds, newest first.
68
113
 
69
114
  ### Refreshing snapshots
70
115
 
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/frontend-mockup-loop",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Pi extension + skill for a ground→contract→mockup→test→fix→learn frontend design loop. Ships a live mockup server tool, a Playwright breakpoint-screenshot tool, and a design-contract scaffolder. Works in any React/Tailwind/shadcn project.",
5
5
  "type": "module",
6
+ "bin": {
7
+ "mock-decide": "src/mock-site/cli.mjs",
8
+ "mock-capture": "src/mock-site/capture.mjs",
9
+ "mock-check": "src/mock-site/check.mjs",
10
+ "mock-video": "src/mock-site/video.mjs"
11
+ },
6
12
  "repository": {
7
13
  "type": "git",
8
14
  "url": "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
@@ -41,7 +47,9 @@
41
47
  },
42
48
  "files": [
43
49
  "src/",
50
+ "site/",
44
51
  "!src/__tests__",
52
+ "!site/__tests__",
45
53
  "presets-data/",
46
54
  ".pi/skills/",
47
55
  "references/",
@@ -54,16 +62,47 @@
54
62
  "eslint-plugin-tailwindcss": "^3.17.0"
55
63
  },
56
64
  "peerDependencies": {
57
- "@earendil-works/pi-coding-agent": ">=1.3.0",
58
- "typebox": ">=1.3.6"
65
+ "@earendil-works/pi-coding-agent": ">=1.7.0",
66
+ "@mswjs/interceptors": ">=0.37.0",
67
+ "@testing-library/dom": ">=10.0.0",
68
+ "@testing-library/user-event": ">=14.5.0",
69
+ "@vitejs/plugin-react": ">=4.0.0 <6.0.0",
70
+ "react": ">=18.0.0",
71
+ "react-dom": ">=18.0.0",
72
+ "typebox": ">=1.3.6",
73
+ "vite": ">=5.4.21 <6.0.0 || >=6.4.1 <6.4.4 || >=6.4.5 <7.0.0 || >=7.0.8 <7.1.0 || >=7.1.11"
59
74
  },
60
75
  "peerDependenciesMeta": {
61
76
  "@earendil-works/pi-coding-agent": {
62
77
  "optional": true
78
+ },
79
+ "vite": {
80
+ "optional": true
81
+ },
82
+ "@vitejs/plugin-react": {
83
+ "optional": true
84
+ },
85
+ "react": {
86
+ "optional": true
87
+ },
88
+ "react-dom": {
89
+ "optional": true
90
+ },
91
+ "@mswjs/interceptors": {
92
+ "optional": true
93
+ },
94
+ "@testing-library/user-event": {
95
+ "optional": true
96
+ },
97
+ "@testing-library/dom": {
98
+ "optional": true
63
99
  }
64
100
  },
65
101
  "devDependencies": {
66
- "@earendil-works/pi-coding-agent": "^1.3.0",
102
+ "@earendil-works/pi-coding-agent": "^1.7.0",
103
+ "@mswjs/interceptors": "^0.45.11",
104
+ "@testing-library/dom": "^10.4.2",
105
+ "@testing-library/user-event": "^14.6.8",
67
106
  "typebox": ">=1.3.6"
68
107
  }
69
108
  }
@@ -0,0 +1,332 @@
1
+ # Live-component mock site
2
+
3
+ Reference for `frontend-mockup-loop` step 3 (MOCKUP). The site renders a
4
+ project's **real components** in Current | Proposed frames, inside the app's own
5
+ build environment, circles the elements that change with numbered rings, drives
6
+ real interactions with scripts over network fixtures, and shows the page-level
7
+ decision the agent recorded with `mock-decide`. English only; nothing in it is
8
+ app-specific. See changes: add-live-component-mock-site, add-mock-site-exact-env,
9
+ add-mock-locate-frame.
10
+
11
+ ## Project setup (once per project)
12
+
13
+ Install the package **in the project** (the site loads it from the project's
14
+ `node_modules`; `pi install` alone only gives pi the tools):
15
+
16
+ ```bash
17
+ npm i -D @blackbelt-technology/frontend-mockup-loop
18
+ ```
19
+
20
+ **Environment = the app's own build config.** The site starts through the
21
+ project's launcher and inherits the app config's build shape (resolve / aliases,
22
+ plugins, css, define, optimizeDeps, the static asset dir served read-only). It
23
+ drops dev-server runtime (`server.*`: port, HMR, proxies), `build` and `root`
24
+ (root-relative settings are resolved first). Nothing is copied by hand.
25
+
26
+ - Declared (wins): `package.json` → `"mockSite": { "launcher": "scripts/dev.mjs", "config": "app/vite.config.ts" }`.
27
+ Use it when the app needs a loader (e.g. tsx) before Vite, or the config is
28
+ not at the root. Both paths are project-relative; a real path outside the
29
+ project (symlinks followed) is refused.
30
+ - Detected: a root `vite.config.*` (or `vite --config X` in `scripts.dev`) with
31
+ the project's Vite bin as launcher.
32
+ - Adapters: build tool **vite**, framework **react**. Others fail with the
33
+ reason, the supported adapters and the next step.
34
+ - The generated config is rewritten on every start at
35
+ `node_modules/.vite-mock-site/mock-site.config.<hash>.mjs`.
36
+
37
+ ```
38
+ package.json optional "mockSite": { launcher, config }
39
+ mockups/
40
+ mock-site.config.ts optional OPTIONS (never a build config)
41
+ mock-site.app.tsx setup() (import mock-site.css, map --mk-* tokens) + Providers
42
+ mock-site.css @import your app CSS + @source lines (app sources, mock roots)
43
+ tsconfig.json optional: paths for your aliases + "mock-site/kit"
44
+ 2026-11-03-<slug>/
45
+ mock.tsx one mock page (default export: Mock)
46
+ fixtures.har.json optional, written by mock-capture
47
+ decision.json written by mock-decide (absent = open)
48
+ ```
49
+
50
+ `mock-site.config.ts` (optional; without it: default themes, no setup module):
51
+
52
+ ```ts
53
+ import path from "node:path";
54
+ import { defineMockSite } from "@blackbelt-technology/frontend-mockup-loop/src/mock-site/options.mjs";
55
+
56
+ export default defineMockSite({
57
+ title: "My mocks",
58
+ app: "./mock-site.app.tsx",
59
+ // first = default; "system" follows prefers-color-scheme
60
+ themes: [
61
+ { id: "system", label: "System", system: { dark: "dark", light: "light" } },
62
+ { id: "dark", label: "Dark", attrs: { "data-theme": "dark" } },
63
+ { id: "light", label: "Light", attrs: { "data-theme": "light" } },
64
+ ],
65
+ aliases: { "@app": path.resolve(__dirname, "../src") }, // only aliases the app config lacks
66
+ redact: ["x-tenant"], // extra keys mock-capture redacts
67
+ });
68
+ ```
69
+
70
+ Keys: `title`, `themes`, `app`, `aliases`, `launcher`, `config`, `redact`. A
71
+ build key (`plugins`, `resolve`, `server`, …) is refused: "mock options are not
72
+ a build config". `package.json` `mockSite` wins over `launcher` / `config` here.
73
+
74
+ `mock-site.css` must be a real file: Tailwind resolves `@source` against the
75
+ file that holds it.
76
+
77
+ ```css
78
+ @import "../src/index.css";
79
+ @source "../src";
80
+ @source ".";
81
+ @source "../openspec/changes";
82
+ ```
83
+
84
+ `mock-site.app.tsx` maps the generic chrome tokens onto yours: `--mk-page`,
85
+ `--mk-panel`, `--mk-fg`, `--mk-muted`, `--mk-faint`, `--mk-line`, `--mk-line-2`,
86
+ `--mk-hover`, `--mk-accent`, `--mk-bad`, `--mk-ok`, `--mk-bad-text`, `--mk-ok-text`.
87
+
88
+ ## Writing a mock
89
+
90
+ ```tsx
91
+ import { Fix, Issue, Tap, type Mock } from "mock-site/kit";
92
+ import { SessionCard } from "@app/components/SessionCard";
93
+
94
+ const mock: Mock = {
95
+ title: "Sessions page - missing folder", // key word first
96
+ category: "Sessions",
97
+ change: "my-change", // optional
98
+ frames: [
99
+ { title: "Sessions page - desktop", width: 1040,
100
+ current: <Issue n={1} tip="Two pills compete"><SessionCard {...today} /></Issue>,
101
+ proposed: <Fix n={1} tip="One pill wins"><SessionCard {...next} /></Fix> },
102
+ { title: "Sessions page - phone", phone: true, current: <Page v="c" />, proposed: <Page v="p" /> },
103
+ ],
104
+ };
105
+ export default mock;
106
+ ```
107
+
108
+ - One mock = one PAGE or flow. Directory name = id = `yyyy-mm-dd-slug`.
109
+ - Import the kit as `mock-site/kit` and app code through aliases. Never use a
110
+ relative import that leaves the mock dir: the dir moves when it is adopted
111
+ into a change.
112
+ - `Issue` (red) on Current, `Fix` (green) on Proposed, same `n` on both sides.
113
+ `n` is `[A-Za-z0-9-]+`. A tip over 40 characters shows `TIP > 40`; a bad `n`
114
+ shows `BAD N`. Add `block` to keep a block / grid cell's layout.
115
+ - A frame without `current` shows one pane labelled `New`.
116
+ - `phone: true` renders each side in a real 375px iframe, so `@media` rules apply.
117
+ - Keep mocks prop-driven; wrap app context in `Providers` if a component needs it.
118
+ - `why`: one-line reason per frame (≤ 120 chars, else `WHY > 120`). Shown under
119
+ the frame title and in the page overview (one card per frame, top of page).
120
+ - **State changes are drawn, never clicked.** Use `steps` instead of
121
+ `current`/`proposed` for a flow: side by side by default (`3a`, `3b`, …, each
122
+ linkable as `#<id>/<n>/proposed/step-<k>`), `play: true` animates them in one
123
+ pane (reduced motion falls back to side by side). Wrap the element whose click
124
+ leads to the next step in `<Tap>`. Ring numbers stay unique across the steps.
125
+ `steps` with `current`/`proposed` is reported; steps win.
126
+
127
+ ```tsx
128
+ { title: "Re-link flow", why: "Each state is drawn.", steps: [
129
+ { label: "folder gone", proposed: <Banner action={<Tap><Btn>Re-link</Btn></Tap>} /> },
130
+ { label: "re-linked", proposed: <Row relinked /> },
131
+ ] }
132
+ ```
133
+ - `phone: true` with `steps`: each step renders in its own 375px iframe.
134
+ - Rings draw a 2px line 2px outside the part, above its children and neighbours,
135
+ under the top bar. It never changes layout; where a pane edge or a clipping box
136
+ would cut it, that side is drawn just inside. A keyboard-focused ring shows a
137
+ thicker accent line (also with Highlights off).
138
+ - Start from the example (in the package's source repo only, not in the npm package):
139
+ copy `packages/mockup-loop/examples/2026-11-03-session-pills/mock.tsx` to
140
+ `mockups/<yyyy-mm-dd-slug>/mock.tsx`. `examples/` is not a mock root, so the
141
+ example is never listed by default; a site with no mocks shows "No mocks yet".
142
+
143
+ ## Locate (where the part lives)
144
+
145
+ Every mock starts with a Locate frame: the whole app page and the user's path from
146
+ the landing view to the reviewed part. It renders first (`#<id>/locate`), is not
147
+ counted as a frame, and keeps every frame ref unchanged.
148
+
149
+ ```tsx
150
+ const mock: Mock = {
151
+ title: "Flow panel - question node", category: "Flows",
152
+ locate: {
153
+ page: <AppPage sessions={sessions} part={<FlowPanel />} />, // real app shell
154
+ script: [
155
+ { say: "Open the session", target: '[data-session-id="s1"]', act: "click", expect: "flow-panel" },
156
+ { say: "the question node", target: "question-node", act: "spot" },
157
+ ],
158
+ phone: { page: <AppPage phone sessions={sessions} part={<FlowPanel />} />, script: [ /* … ends with spot */ ] },
159
+ },
160
+ frames: [ /* … */ ],
161
+ };
162
+ ```
163
+
164
+ - `locate`: `page` (the whole page, real app shell), `script` (only the steps a user
165
+ takes, from the landing view), `width` (default 1100), `height` (default 640),
166
+ `fixtures`, `clockAt`; `phone` (`page`, `script`, `height` default 760,
167
+ `fixtures`, `clockAt`) is required when any frame is `phone: true`.
168
+ - The page lays out at its own size; a narrower review column scales the whole
169
+ pane down (never re-flows or clips it). The Locate pane runs like a scripted
170
+ frame (pointer, captions, Pause, ◀ / ▶, reduced motion = one paused pane per step).
171
+ - The walk ends with `act: "spot"` on the part. A new part: click its proposed
172
+ entry point, then spot the new part.
173
+ - Problems (problem list, sidebar entry, page title; `mock-check <mock-id>` exits 1):
174
+ `NO LOCATE` (no `locate`), `NO PHONE LOCATE` (a phone frame, no `locate.phone`),
175
+ `LOCATE WITHOUT SPOT` (the walk's last step is not `spot`), `SPOT WITH UNLESS`
176
+ (a `spot` with `unless` in the walk). Old mocks show `NO LOCATE` until edited.
177
+
178
+ ## Fixtures (network)
179
+
180
+ A mock (or one frame) may declare `fixtures`: a factory called once per pane and
181
+ per script loop, so state never leaks between panes or loops. Fixture-backed
182
+ panes run in their own same-origin document (mounted when scrolled near) whose
183
+ fetch / XHR / WebSocket are intercepted in-page (no service worker: works on the
184
+ plain-HTTP LAN URL too). Optional peers: `@mswjs/interceptors`.
185
+
186
+ ```tsx
187
+ const fixtures = (): Fixtures => {
188
+ let runs = [{ id: 1, status: "done" }];
189
+ return {
190
+ http: {
191
+ "GET /api/runs": () => runs, // JSON 200
192
+ "POST /api/runs": (r) => { runs = [...runs, r.json()]; return { ok: true }; },
193
+ "GET /api/runs/:id": (r) => runs.find((x) => String(x.id) === r.params.id),
194
+ },
195
+ ws: { "/ws/feed": (s) => { s.send({ type: "hello" }); s.onMessage((m) => s.send(m)); } },
196
+ har, // import har from "./fixtures.har.json" (mock-capture)
197
+ passthrough: ["cdn.example"],
198
+ };
199
+ };
200
+ ```
201
+
202
+ - Handlers return a `Response` or a JSON value. HAR entries answer after `http`.
203
+ - An unanswered request gets **501** and is listed per page under
204
+ **Missing fixtures** (`GET /api/roles` + the pane ref). Nothing reaches the
205
+ network unless `passthrough` allows it.
206
+ - `mock-capture <url> <mockDir> [--redact key]... [--out file]` records a
207
+ running app's HTTP traffic (Playwright HAR), redacts authorization / cookie /
208
+ password / secret / token / api-key / session keys (headers, cookies, query,
209
+ JSON bodies; plus `--redact` and the options' `redact`), then **refuses to
210
+ write** if a bearer token, JWT, `sk-`, `ghp_` / `gho_` / `github_pat_`,
211
+ `xox?-`, `AKIA` or `AIza` value survives, naming the entry and JSON path.
212
+ WebSocket traffic is never captured: write WS fixtures by hand.
213
+
214
+ ## Surroundings
215
+
216
+ `surroundings: (slot) => <AppShell route="/sessions">{slot}</AppShell>` renders
217
+ the same real shell around both panes; only the slot differs (fidelity R1).
218
+
219
+ ## Scripts (behaviour)
220
+
221
+ ```tsx
222
+ { title: "Edit cron", fixtures, clockAt: "2026-01-01T12:00:00Z",
223
+ proposed: <AutomationBoard />,
224
+ script: [
225
+ { say: "Open the editor", target: "edit-btn", act: "click" },
226
+ { say: "Raw mode", target: "raw-toggle", act: "click", unless: "raw-input" },
227
+ { say: "Type the cron", target: "raw-input", act: "type", text: "0 17 * * *",
228
+ expect: (d) => d.querySelector("input")?.value === "0 17 * * *" },
229
+ ] }
230
+ ```
231
+
232
+ - `act`: `click` | `type` | `clear` | `hover` | `press` (`key`) | `wait` | `spot`.
233
+ `spot` moves the pointer to the target, dims the pane outside it, rings it and
234
+ labels it `You are here: <say>` until the loop ends or the pane remounts (step
235
+ back removes it). It ignores pointer events, follows the target and stays
236
+ visible with Highlights off.
237
+ `target`: a test id (tried first) or a CSS selector; portals are found too.
238
+ - Each step waits up to `timeout` (default 4000 ms) for its target. `unless`
239
+ (selector or check) skips the step when it already holds; `expect` must hold
240
+ after the act. A failure stops the pane at that step and shows
241
+ `Step n/N "say" failed: …` with the selector.
242
+ - `side`: `proposed` (default) | `current` | `both`. `script` wins over `steps`
243
+ (both set = reported problem).
244
+ - Clock: starts at `clockAt` (default: page load) on every loop, then real time,
245
+ so "18m ago" reads the same each loop. Loops remount with fresh fixtures, hold,
246
+ repeat; **Pause** under the pane; `loop: false` stops at the end. The pane
247
+ label shows completed / failed loop counts.
248
+ - A pointer moves to each target before acting and a caption shows `n/N say`;
249
+ both live inside the pane and ignore pointer events.
250
+ - Fixed stage: on every page load a scripted pane first runs one silent fast
251
+ loop behind its "Loading pane…" line (15 s budget; not counted in health),
252
+ measuring after each step, then appears at its tallest height and keeps it,
253
+ so the site never moves while it loops. Content taller in the live loop grows
254
+ it once; it never shrinks while the page is open. First visit in a tab: the
255
+ 240 px placeholder is replaced once. An edited mock is re-measured on reload.
256
+ - Paused panes step: **◀** / **▶** beside **Pause** walk the script one step
257
+ at a time (disabled while a step or rewind runs; hidden after a failed loop).
258
+ The caption rests on `k/N say` of the last finished step, or `0/N start`.
259
+ Forward at the end starts the next loop (`loop: false`: nothing). Back
260
+ remounts with fresh fixtures and replays the earlier steps silently; the
261
+ pane clock restarts at `clockAt`.
262
+ - An embedded pane never scrolls the reviewer's page: `focus()` and
263
+ `scrollIntoView()` (runner and mocked components alike) scroll only the
264
+ pane's own scroll containers and window. A component relying on page-level
265
+ scrolling now scrolls inside its pane. Outside the guarantee: fragment
266
+ navigation in a pane, browser-native focus without a JS call (`autofocus`,
267
+ `<dialog>.showModal()` initial focus, label activation), and a `focus`
268
+ captured before the guard ran. Top-level `?pane=` pages (`mock-check`,
269
+ `mock-video`) keep native scrolling.
270
+ - Reduced motion: no animation; one live pane per step, paused after it, as
271
+ `#<id>/<frame>/<side>/step-<k>`.
272
+ - `mock-check <ref> [--loops N] [--url U]` runs a frame headlessly against a
273
+ running site (default 3 loops) and exits non-zero on any failed loop.
274
+ `mock-check <mock-id>` first reports the mock's Locate problems (exit 1, nothing
275
+ run; an id the site does not show: `unknown mock <id>`, exit 2), then runs the
276
+ Locate frame(s) and every scripted frame, one line per pane with its mean loop
277
+ time, exit 1 on any failed loop.
278
+ `mock-video <ref> [--out f.webm]` records one loop; default
279
+ `node_modules/.vite-mock-site/videos/` (never a mock dir), path printed.
280
+ - Playwright's pinned Chromium missing → the cached builds are tried newest
281
+ first; none launches → `npx playwright install chromium`.
282
+
283
+ ## References
284
+
285
+ | Ref | Points at |
286
+ |---|---|
287
+ | `#<id>` | the page |
288
+ | `#<id>/<frame>` | frame (1-based) |
289
+ | `#<id>/locate` / `#<id>/locate-phone` | the Locate frame / the phone Locate frame (side `proposed` only) |
290
+ | `#<id>/<frame>/current` / `proposed` | one side |
291
+ | `#<id>/<frame>/<side>/<n>` | one ring, phone frames included |
292
+ | `#<id>/<frame>/<side>/step-<k>` | step k (`steps` cards; a script step pane under reduced motion) |
293
+
294
+ A ring `n` never starts with `step-` (shown as `BAD N`).
295
+
296
+ Clicking a ref (page/frame `#ref`, side label, ring badge) copies its URL.
297
+ Opening one scrolls to the deepest existing part and flashes it. Quote refs when
298
+ discussing a mock: "reject `#2026-11-03-x/1/proposed/2`: label too long".
299
+
300
+ ## Deciding
301
+
302
+ - The site is read-only: it shows `open`, `accepted by <by>` or `rejected by <by>`
303
+ with the note, and offers no decision control.
304
+ - The agent records the user's verdict (or its own scored review):
305
+ `mock-decide list`, `mock-decide accept <ref> [note]`,
306
+ `mock-decide reject <ref> "why"` (a reason is required),
307
+ `mock-decide reopen <ref>`. `<ref>` may be an id, any `#ref`, or a full URL.
308
+ A note over 500 characters, an unknown id or a refused write (symlink) exits
309
+ non-zero with one line and writes nothing.
310
+ - `decision.json` = `{ status: "accepted"|"rejected", by: "agent", note?, at }`
311
+ (legacy `by: "user"` files are still read). Open tabs refresh live. Only open
312
+ mocks are listed unless "Show accepted / rejected".
313
+
314
+ ## Serving
315
+
316
+ `serve_mock_site{}` → `http://localhost:5299` (reserved ports are refused).
317
+ Show the URL to the user. `npm run`-style foreground start:
318
+ `node node_modules/@blackbelt-technology/frontend-mockup-loop/src/mock-site/serve-cli.mjs --port 5299`.
319
+ LAN mode relies on Vite's `server.fs.deny`; the package's optional `vite` peer
320
+ range (`>=5.4.21 <6 || >=6.4.1` minus 6.4.4, `7.0.8+`, `7.1.11+`) excludes the versions with
321
+ known deny bypasses, and LAN mode refuses to start on one (fail closed).
322
+ `serve_mock_site{lan:true}` adds a LAN URL for phones (view-only); project
323
+ sources are readable on the LAN while it runs.
324
+ `serve_mock_site{stop:true, port}` stops it.
325
+
326
+ ## Adoption into a change
327
+
328
+ A mock made before its change exists gets a `mockups/AGENTS.md` row ending
329
+ `Pending change: <intent>`. When the proposal is written, `mock-decide adoptable`
330
+ lists the offer: accepted mocks first `(accepted)`, open ones `(open)`, rejected
331
+ ones never. The whole directory (including an untracked `decision.json`) moves to
332
+ `openspec/changes/<name>/mockups/<id>/` and keeps working there.