mockpit 1.2.0 → 2.0.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 (59) hide show
  1. package/README.md +69 -48
  2. package/bin/demoData.js +3 -3
  3. package/bin/mockpit.js +426 -51
  4. package/dist/mcp/server.js +45 -7
  5. package/dist/server/apiViews.d.ts +407 -21
  6. package/dist/server/apiViews.js +110 -11
  7. package/dist/server/app.d.ts +5 -1
  8. package/dist/server/app.js +1454 -192
  9. package/dist/server/codeWorker.js +2 -1
  10. package/dist/server/decisions.d.ts +23 -0
  11. package/dist/server/decisions.js +100 -0
  12. package/dist/server/designGuide.d.ts +6 -2
  13. package/dist/server/designGuide.js +96 -27
  14. package/dist/server/embeds.d.ts +26 -0
  15. package/dist/server/embeds.js +144 -0
  16. package/dist/server/eventLog.js +2 -1
  17. package/dist/server/feedbackBatch.d.ts +15 -4
  18. package/dist/server/feedbackBatch.js +31 -7
  19. package/dist/server/fills.d.ts +41 -0
  20. package/dist/server/fills.js +328 -0
  21. package/dist/server/guidance.d.ts +23 -0
  22. package/dist/server/guidance.js +71 -0
  23. package/dist/server/index.js +25 -2
  24. package/dist/server/knobs.d.ts +6 -2
  25. package/dist/server/knobs.js +11 -1
  26. package/dist/server/mcpHttp.d.ts +6 -0
  27. package/dist/server/mcpHttp.js +35 -0
  28. package/dist/server/mcpSpec.d.ts +14 -13
  29. package/dist/server/mcpSpec.js +133 -18
  30. package/dist/server/postSurfaces.js +6 -12
  31. package/dist/server/richRender.js +3 -1
  32. package/dist/server/run.js +10 -1
  33. package/dist/server/runApi.d.ts +3 -3
  34. package/dist/server/runApi.js +18 -13
  35. package/dist/server/sqlStore.d.ts +97 -5
  36. package/dist/server/sqlStore.js +367 -27
  37. package/dist/server/surfacePage.d.ts +6 -2
  38. package/dist/server/surfacePage.js +142 -10
  39. package/dist/server/themes.d.ts +2 -0
  40. package/dist/server/themes.js +23 -3
  41. package/dist/server/types.d.ts +107 -16
  42. package/dist/server/types.js +73 -10
  43. package/dist/server/viewerRequest.d.ts +2 -0
  44. package/dist/server/viewerRequest.js +14 -0
  45. package/extensions/mockpit.js +179 -16
  46. package/guide/packs/design-craft.md +35 -0
  47. package/guide/topics/asks.md +82 -31
  48. package/guide/topics/feedback.md +151 -43
  49. package/guide/topics/html.md +8 -10
  50. package/guide/topics/http.md +8 -4
  51. package/guide/topics/knobs.md +4 -3
  52. package/guide/topics/scripts.md +2 -2
  53. package/guide/topics/surfaces.md +45 -11
  54. package/package.json +3 -15
  55. package/skills/launch-video/SKILL.md +2 -2
  56. package/skills/mockpit/SKILL.md +23 -7
  57. package/viewer/dist/index.html +9 -8
  58. package/dist/server/slots.d.ts +0 -14
  59. package/dist/server/slots.js +0 -71
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  **A design-decision loop for terminal coding agents.**
4
4
 
5
5
  Your agent publishes a mock (a page or a component) in each of its UI states and
6
- in a few parallel looks. It shows up live in your browser with the agent's
7
- questions beside it: pick a look from pictures, tune the knobs it exposed, leave
8
- comments on the parts it marked, then press **Send**, at your own pace. Nothing
6
+ in a few parallel variants. It shows up live in your browser with the agent's
7
+ questions beside it: pick a variant from pictures, tune the knobs it exposed, leave
8
+ comments on the parts it declared, then press **Send**, at your own pace. Nothing
9
9
  the agent calls waits for you: it gets the whole batch once and revises.
10
10
 
11
11
  <table>
@@ -13,11 +13,11 @@ the agent calls waits for you: it gets the whole batch once and revises.
13
13
  <td width="50%" valign="top">
14
14
  <picture>
15
15
  <source media="(prefers-color-scheme: dark)" srcset="docs/mockpit-dark.png">
16
- <img width="100%" alt="The Writer mock on its first question, Look: the Writing state on the stage with a numbered question pin, the strip of four UI states below it, and the panel offering three looks (Quiet, Dark, Editorial) as picture options" src="docs/mockpit-light.png">
16
+ <img width="100%" alt="The Writer mock on its first question, Which variant?: the Writing state on the stage with a numbered question pin, the row of four UI states below it, and the panel offering three variants (Quiet, Dark, Editorial) as picture options" src="docs/mockpit-light.png">
17
17
  </picture>
18
18
  </td>
19
19
  <td width="50%" valign="top">
20
- <img width="100%" alt="Animated demo: the agent publishes the Writer mock; the user previews the three looks on the stage, picks Quiet, answers where the trim goes, keeps a part from another look and presses Send; the top bar reads Sent, Not seen yet, then Delivered once the agent reads the feedback; the agent replies and publishes v2" src="docs/mockpit-demo.gif">
20
+ <img width="100%" alt="Animated demo: the agent publishes the Writer mock; the user previews the three variants on the stage, picks Quiet, answers where the trim goes, borrows a part from another variant and presses Send; the top bar reads Sent, Not seen yet, then Delivered once the agent reads the feedback; the agent replies and publishes its next version" src="docs/mockpit-demo.gif">
21
21
  </td>
22
22
  </tr>
23
23
  </table>
@@ -34,46 +34,52 @@ mockpit turns that into a design-decision loop:
34
34
 
35
35
  | | sideshow | mockpit |
36
36
  | ------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
37
- | Structure | A stream of posts per session | **project › mock › state › variant › version**: a repo, a page or component by slug, its UI states, parallel looks, history |
37
+ | Structure | A stream of posts per session | **project › mock › state › variant › version**: a repo, a page or component by slug, its UI states, parallel variants, history |
38
38
  | Questions | Free-text comments | The agent asks; you answer in place, picking from pictures of each option |
39
39
  | Tuning | — | Knobs the agent declares (sliders, colours, springs…) on [tunekit](https://github.com/fabiogaliano/tunekit), live on the stage |
40
- | Comments | Text on a post | Anchored on a **part** the agent marked with `data-part`, in a given state |
41
- | Feedback | Each comment reaches the agent as it's written | Picks, tuned values, mix and comments stay drafts until you **Send**, then go out as one reply |
40
+ | Comments | Text on a post | Anchored on a **part** the agent declared with `data-part`, in a given state |
41
+ | Feedback | Each comment reaches the agent as it's written | Picks, tuned values, borrowed parts and comments stay drafts until you **Send**, then go out as one reply |
42
42
  | Design system | Built-in viewer themes | `mockpit init` detects the repo's tokens, fonts and kit so the agent's markup matches your codebase |
43
- | Agent verbs | Post-level: `publish`, `update`, `wait`, `comment` | Mock-level, never blocking: `publish`, `ask`, `read`, `feedback`, `say`, `export`, `upload`, `guide`, `run` |
43
+ | Agent verbs | Post-level: `publish`, `update`, `wait`, `comment` | Mock-level, never blocking: `publish`, `ask`, `read`, `feedback`, `say`, `edit`, `export`, `upload`, `guide`, `run` |
44
44
 
45
45
  ## The loop
46
46
 
47
47
  1. **Publish.** The agent publishes each state of the mock ("Writing", "Lab
48
- open") in one or more variants ("quiet", "dark"). One stage shows the mock;
49
- the strip under it switches states.
50
- 2. **Ask.** The agent asks what it can't decide alone: which look, where a
48
+ open") in one or more variants ("quiet", "dark"). One stage shows the mock,
49
+ one state at a time.
50
+ 2. **Ask.** The agent asks what it can't decide alone: which variant, where a
51
51
  panel goes, which of two layouts. The question lives in the mock, not in
52
52
  chat; the agent tells you where to look and ends its turn. Options bound to
53
53
  a variant or to knob values render as pictures; hovering one previews it on
54
- the stage, clicking picks it. After the look, **Mix** offers to borrow a part
55
- from another look. Variants the agent forgot to ask about get a built-in
56
- **Which one?**.
57
- 3. **Tune.** Parts the agent marked are selectable on the stage. Tune lists
58
- them with the knobs it declared for each, plus a comment field. Presets
54
+ the stage, clicking picks it, and the part it changed is outlined. A
55
+ region the agent drew several ways (a part with fills: one `data-part`, a
56
+ `data-fill` per alternative) is asked about once; a part inside a fill is
57
+ asked only while that fill is chosen. Variants the agent forgot to ask about
58
+ get a built-in **Which variant?**.
59
+ 3. **Tune.** Parts the agent declared are selectable on the stage. Tune lists
60
+ them with the knobs it declared for each, a **Borrow** line for a part
61
+ another variant draws differently, plus a comment field. Presets
59
62
  save a set of tuned values in your browser.
60
63
  4. **Send.** Everything above is a draft (it survives a reload) until one
61
- **Send**. A mock with a single variant and no questions gets **Accept /
62
- Revise / Drop** instead. The Send lands in the Thread as **Not seen yet**,
64
+ **Send**. A mock with a single variant and no questions gets **Use this /
65
+ Revise** instead. The Send lands in the Thread as **Not seen yet**,
63
66
  then **Delivered** once the agent has it. If it isn't picked up, tell your
64
67
  agent you've answered.
65
- 5. **Revise.** The agent gets one reply (answers, tuned values, mix, comments)
68
+ 5. **Revise.** The agent gets one reply (answers, tuned values, borrowed parts, comments)
66
69
  on its next write, its next `feedback` call, or from `mockpit watch` under a
67
- background monitor. It publishes the next version; the frame header's `v3 ▾` lists the history,
68
- and an older version opens under a banner with "restore as vN". Looks that
69
- lost are archived, not deleted.
70
+ background monitor. It publishes the next version. Versions are named by
71
+ their variant's own number ("Dark #2"); the version bar walks the history,
72
+ and **Use this** puts an older one back in use. Variants that lost are
73
+ archived, not deleted.
70
74
 
71
75
  **Home** lists the project's mocks with a thumbnail, their states and how many
72
76
  questions are open, with "Answer next ›" to jump to the first one. Dark and
73
- light themes, toggled from the top bar. On a phone or tablet the panel becomes a
74
- bottom sheet, the stage scrolls under your finger and renders the design at a
75
- chosen width (Phone 390, Tablet 744, Desktop 820, Wide 1280), and Inspect opens
76
- the stage full screen to pan and pinch-zoom it.
77
+ light themes, toggled from the top bar. On a phone or an iPad in portrait the
78
+ design is a canvas you pan and pinch, at each width the agent names (or one you
79
+ pick: Phone 390, Tablet 744, Desktop 820, Wide 1280) side by side, and the
80
+ questions float over it in a card you can snap to a corner, a side or the
81
+ bottom, or tuck against an edge. On a desktop, Inspect opens the stage full
82
+ screen to pan and pinch-zoom it.
77
83
 
78
84
  ## Quick start
79
85
 
@@ -94,7 +100,7 @@ curl -s http://localhost:8228/setup >> AGENTS.md
94
100
 
95
101
  Then run `mockpit init` once per repo and ask the agent to "mock this up on
96
102
  mockpit". No agent handy? `mockpit demo` seeds the Writer: one mock in four
97
- states and three looks, with questions, knobs and marked parts.
103
+ states and three variants, with questions, knobs and declared parts.
98
104
 
99
105
  MCP, the Pi extension and the Claude Code plugin are covered in
100
106
  **[docs/connecting-agents.md](docs/connecting-agents.md)**.
@@ -133,21 +139,22 @@ There are also `terminal` (ANSI output), `image` (uploaded assets), `json`
133
139
 
134
140
  ## Agent verbs
135
141
 
136
- Nine verbs, the same on every tier with the same fields: a zero-dependency CLI
142
+ Ten verbs, the same on every tier with the same fields: a zero-dependency CLI
137
143
  for agents with only a shell, MCP over stdio or streamable HTTP at `/mcp`, and
138
144
  plain HTTP. None of them waits for the user.
139
145
 
140
- | CLI | MCP | HTTP |
141
- | --------------------- | -------------------- | -------------------------------------- |
142
- | `mockpit publish` | `publish` | `POST /api/mocks` |
143
- | `mockpit ask` | `ask` | `POST /api/mocks/:id/asks` |
144
- | `mockpit read [slug]` | `read` | `GET /api/mocks`, `GET /api/mocks/:id` |
145
- | `mockpit feedback` | `feedback` | `GET /api/feedback?session=…` |
146
- | `mockpit say` | `say` | `POST /api/mocks/:id/say` |
147
- | `mockpit export` | `export` | `GET /api/mocks/:id/export` |
148
- | `mockpit upload` | `upload` | `POST /api/assets` |
149
- | `mockpit guide` | `guide` | `GET /agent-howto` |
150
- | `mockpit run` | `run` (`?mode=code`) | `POST /api/run` |
146
+ | CLI | MCP | HTTP |
147
+ | --------------------- | -------------------- | --------------------------------------------------- |
148
+ | `mockpit publish` | `publish` | `POST /api/mocks` |
149
+ | `mockpit ask` | `ask` | `POST /api/mocks/:id/asks` |
150
+ | `mockpit read [slug]` | `read` | `GET /api/mocks`, `GET /api/mocks/:id` |
151
+ | `mockpit feedback` | `feedback` | `GET /api/feedback?session=…` |
152
+ | `mockpit say` | `say` | `POST /api/mocks/:id/say` |
153
+ | `mockpit edit` | `edit` | `PATCH /api/mocks/:id`, `PATCH /api/projects/:name` |
154
+ | `mockpit export` | `export` | `GET /api/mocks/:id/export` |
155
+ | `mockpit upload` | `upload` | `POST /api/assets` |
156
+ | `mockpit guide` | `guide` | `GET /agent-howto` |
157
+ | `mockpit run` | `run` (`?mode=code`) | `POST /api/run` |
151
158
 
152
159
  The CLI adds `mockpit init` (detect the repo's design system, once per repo)
153
160
  and `mockpit watch` (one line per Send, for a background monitor).
@@ -155,32 +162,49 @@ and `mockpit watch` (one line per Send, for a background monitor).
155
162
  - **`publish` is the one write.** It creates the mock, state or variant, or the
156
163
  next version of an existing one. Send `html`, the full ordered `surfaces`
157
164
  list (an entry that is only `{id}` keeps that surface), or `parts` to replace
158
- just the marked elements.
165
+ just the declared elements.
159
166
  - **`feedback` returns at once** with what the user sent since the agent last
160
167
  heard, plus `pending`: whether each mock is open in the viewer and how far the user's
161
168
  draft has got (`2 of 3 answered`). Every write returns `feedback` too, and
162
169
  each Send is delivered exactly once across all of them.
163
- - **Asks are nudged.** A publish that leaves several variants with no ask
164
- binding them returns a nudge and a ready `suggestedAsk`.
170
+ - **Questions are nudged.** A publish that leaves several variants with no
171
+ question binding them returns a nudge and a ready `suggestedAsk`.
165
172
 
166
173
  A typical turn:
167
174
 
168
175
  ```sh
169
176
  mockpit publish --mock writer --state "Writing" --variant quiet --html quiet.html
170
177
  mockpit publish --mock writer --state "Writing" --variant dark --html dark.html
171
- mockpit ask --mock writer "Which look?" --option Quiet=quiet --option Dark=dark
178
+ mockpit ask --mock writer "Quiet or dark?" --option Quiet=quiet --option Dark=dark
172
179
  # the agent says where to look and ends its turn; once you've answered:
173
180
  mockpit feedback
174
181
  ```
175
182
 
176
183
  The running server serves the brief at `/agent-howto`: one short, project-aware
177
184
  document an agent reads before its first publish. Reference topics (`knobs`,
178
- `asks`, `surfaces`, `html`, `reply`, `http`, `scripts`) are at
185
+ `asks`, `surfaces`, `html`, `feedback`, `http`, `scripts`) are at
179
186
  `/agent-howto?topic=<id>`; `/guide` is the `html` topic. `run` executes one
180
187
  script against the same verbs on the server, so publishing variants and asking
181
188
  take one call; `/mcp?mode=code` serves it as the only tool, for connectors
182
189
  without a codemode of their own.
183
190
 
191
+ ## Guidance
192
+
193
+ Agents read one brief before their first publish, in layers. Higher wins:
194
+
195
+ | Layer | Where | Who gets it |
196
+ | ------------- | ------------------------------- | ------------------------------------- |
197
+ | Core | built in | everyone: how mockpit works, no taste |
198
+ | Packs | built in, off by default | whoever turns one on (`design-craft`) |
199
+ | Your rules | `~/.mockpit/rules.md` | you, in every project |
200
+ | Project rules | `.mockpit/rules.md` in the repo | anyone designing that repo |
201
+
202
+ A rules file has `## Rules` (always followed) and `## Suggestions` (aimed for),
203
+ and turns packs on with `packs: [design-craft]` in its frontmatter. `mockpit
204
+ rules` sends the project's file to the server; `mockpit init` does it too.
205
+ [`examples/rules.md`](examples/rules.md) is the maintainer's own, symlinked to
206
+ `~/.mockpit/rules.md`.
207
+
184
208
  ## Run it anywhere
185
209
 
186
210
  It runs locally as a small Node server (SQLite at `~/.mockpit/mockpit.db`), or on
@@ -227,12 +251,9 @@ The server app is importable from `mockpit/server` (`createApp`, `SqlStore`,
227
251
 
228
252
  ```sh
229
253
  npm run dev # server with watch + viewer watch build
230
- npm test # Node unit/API/store tests + viewer unit tests
231
- npm run test:worker # local workerd + Durable Object integration
232
254
  npm run typecheck # node + workers + viewer
233
255
  npm run lint # oxlint
234
256
  npm run format # oxfmt
235
- npm run test:e2e # Playwright, chromium + webkit (bridge, mock screen, decide flow)
236
257
  ```
237
258
 
238
259
  The architecture and contributor rules are in [AGENTS.md](AGENTS.md).
package/bin/demoData.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Seed content for `mockpit demo`: the Writer mock — four states of one
2
- // writing app, each drawn in three looks, with its parts marked so the viewer
2
+ // writing app, each drawn in three variants, with its parts marked so the viewer
3
3
  // can show questions, tuning and part comments. Dependency-free like the CLI.
4
4
 
5
5
  const LOOKS = {
@@ -101,8 +101,8 @@ export const DEMO = {
101
101
  },
102
102
  asks: [
103
103
  {
104
- id: "look",
105
- text: "Which look?",
104
+ id: "tone",
105
+ text: "Quiet, dark or editorial?",
106
106
  scope: "mock",
107
107
  options: [
108
108
  { label: "Quiet", variant: "quiet" },