chamba 0.6.1 → 0.7.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 (35) hide show
  1. package/README.md +13 -6
  2. package/dist/lib/agent-context.js +33 -7
  3. package/dist/lib/dockerfile-builder.js +2 -1
  4. package/dist/lib/safe-rm.js +13 -3
  5. package/package.json +3 -3
  6. package/templates/Dockerfile +20 -1
  7. package/templates/pane-apps/client/assets/specs-B1970L17.css +1 -0
  8. package/templates/pane-apps/client/assets/specs-cEee_SPn.js +23 -0
  9. package/templates/pane-apps/client/specs/index.html +13 -0
  10. package/templates/pane-apps/server/specs.mjs +1588 -0
  11. package/templates/skills/dx-spec/SKILL.md +365 -0
  12. package/templates/skills/dx-spec/references/imagination-guide.md +140 -0
  13. package/templates/skills/dx-spec/references/review-guide.md +173 -0
  14. package/templates/skills/dx-spec/references/spec-guide.md +125 -0
  15. package/templates/skills/dx-spec/references/stages.md +399 -0
  16. package/templates/skills/dx-spec-config/SKILL.md +313 -0
  17. package/templates/skills/dx-spec-config/references/principles-template.md +12 -0
  18. package/templates/skills/dx-spec-execute/SKILL.md +324 -0
  19. package/templates/specs.sh +106 -0
  20. package/templates/webterm/README.md +42 -6
  21. package/templates/webterm/config.js +43 -0
  22. package/templates/webterm/public/app/composer.js +4 -1
  23. package/templates/webterm/public/app/dom.js +13 -5
  24. package/templates/webterm/public/app/frames.js +7 -0
  25. package/templates/webterm/public/app/main.js +7 -1
  26. package/templates/webterm/public/app/pane-shell.js +315 -0
  27. package/templates/webterm/public/app/pane.js +58 -183
  28. package/templates/webterm/public/app/specs-host.js +222 -0
  29. package/templates/webterm/public/app/terminal.js +8 -0
  30. package/templates/webterm/public/index.html +51 -27
  31. package/templates/webterm/public/styles.css +144 -30
  32. package/templates/webterm/server.js +273 -0
  33. package/templates/webterm/specs.js +358 -0
  34. package/templates/webterm/tool-document.js +67 -0
  35. package/templates/webterm/typed-line.js +85 -0
@@ -0,0 +1,365 @@
1
+ ---
2
+ name: dx-spec
3
+ description: Build a work specification in the Specs tab of this session's web pane, or pick up one in progress. Every step the user answers is a form on that tab. User-invoked only.
4
+ disable-model-invocation: true
5
+ argument-hint: "[what the work is, or the name of a piece of work to pick up]"
6
+ ---
7
+
8
+ # dx-spec - build a work specification
9
+
10
+ This skill runs when the user types `/dx-spec`. It never starts on its own.
11
+
12
+ The skill turns work into a spec directory the Specs tab shows.
13
+ A fresh agent opens that directory later and builds the work from it, without asking the user anything, even though it never saw this conversation.
14
+ Everything is on disk, so the work stops at any point and continues in a later session, with any agent.
15
+
16
+ **This skill plans. It does not build.**
17
+ Do not edit application code while it runs, whatever the request asks for.
18
+ `/dx-spec-execute` builds the work after the spec is ready.
19
+
20
+ ## The web session
21
+
22
+ This family runs inside a chamba web session, where the Specs tab holds the work.
23
+ Check for one before anything else:
24
+
25
+ ```
26
+ specs stages
27
+ ```
28
+
29
+ The answer holds `root` - the directory the tab serves - and the stage catalog.
30
+ A refusal means there is no pane.
31
+ Say this and stop:
32
+
33
+ > This works in the chamba web session, where the Specs tab holds your work. Open the browser window this container printed at start, or run `webterm` in the terminal to get the address again. Then run `/dx-spec` there.
34
+
35
+ Start no flow, and offer no substitute.
36
+ There is one flow, and it needs the tab.
37
+
38
+ ## The one hard rule
39
+
40
+ **Everything you ask the user goes on the Specs tab.**
41
+ The tab draws the form, the user answers it there, and the answer comes back as a file.
42
+ `specs await` is how you ask.
43
+ Nothing you ask the user is a message in this terminal, and nothing is an `AskUserQuestion` call.
44
+
45
+ Three shapes, and one mechanism under all of them:
46
+
47
+ - A **gate** judges one artifact. The user approves it, or asks for changes with the words that say what to change.
48
+ - A **round** asks questions. Each question carries its options, whether one answer or several are allowed, and a box of its own for anything the options missed.
49
+ - A **decision card** carries a finding that needs the user's judgment: the evidence, the trade-off, and apply or dismiss.
50
+
51
+ Ask, then stop.
52
+ Declaring something is the end of your turn.
53
+ The pane types one line into this terminal when the user answers, and that line is what starts you again.
54
+ Do not poll, and do not carry on with the thing the question was there to settle.
55
+
56
+ You write to the user in plain messages in exactly four places:
57
+
58
+ - The **collect invitation** - one short line that asks what the work is.
59
+ - The **exploration stage** - thinking out loud is its whole point.
60
+ - A **line of fact** the user needs before a form makes sense, sent in the same turn as the form.
61
+ - The **closing line** that ends the run.
62
+
63
+ **Raise a doubt. Never guess at it.**
64
+ Do not settle a doubt on your own while a spec is being built, however small it looks.
65
+ A fresh agent builds from this spec without asking anything, so a doubt this session swallows becomes a wrong build later.
66
+
67
+ Raise a doubt in one of three ways, by where it comes up:
68
+
69
+ - Outside a stage that writes `SPEC.md`: ask it in the next round.
70
+ - Inside a stage that writes `SPEC.md`: queue it in place as a `[NEEDS CLARIFICATION: ...]` marker, and ask it at the next round or gate, once it clears the bar in `references/spec-guide.md`.
71
+ - Below that bar: write it to disk as a labeled assumption, naming the guess you made.
72
+
73
+ The same rule covers any other guess that has to stand: label it on disk, so no choice stays silent.
74
+
75
+ ## The tool owns the state
76
+
77
+ The Specs tool writes `state.json` and the `README.md` of each spec directory.
78
+ **Never edit either one.**
79
+ Never write a protocol list, a stage checkbox, a status line or a log line by hand.
80
+ You move the work with the verbs below, and the tool writes both files in the same act, so the board in the pane and the file in git cannot disagree.
81
+
82
+ Everything else in the spec directory is yours: `spec/SPEC.md`, the research, the mocks, the plan, the review, and the visuals beside them.
83
+
84
+ ## The verbs
85
+
86
+ `specs <verb> [<spec>]` takes JSON on stdin where a verb needs a payload, and answers JSON on stdout.
87
+ `<spec>` is the directory name the tab shows.
88
+
89
+ ```
90
+ specs stages where the specs live, and the stage catalog
91
+ specs state <spec> where the work stands, and what awaits the user
92
+ echo '<json>' | specs intake file a new piece of work
93
+ echo '<json>' | specs propose <spec> recommend a protocol, and put it to the user
94
+ echo '<json>' | specs await <spec> declare a gate, a round or a decision card
95
+ echo '<json>' | specs post <spec> say what is happening
96
+ echo '<json>' | specs review <spec> post one round of quality review
97
+ echo '{"id":"<id>"}' | specs answers <spec> read back what the user answered
98
+ ```
99
+
100
+ **Filing an intake:**
101
+
102
+ ```json
103
+ { "name": "Checkout discounts", "text": "everything the user said, in their words", "attachments": [] }
104
+ ```
105
+
106
+ The answer is `{ "entry": "checkout-discounts", "path": "checkout-discounts/intake.md" }`.
107
+ An attachment is `{ "name": "sketch.png", "type": "image/png", "data": "<base64>" }`.
108
+
109
+ **Recommending a protocol:**
110
+
111
+ ```json
112
+ { "stages": [{ "id": "interview", "recommended": true, "why": "the scope has open edges" }], "note": "" }
113
+ ```
114
+
115
+ Name every stage you have an opinion about.
116
+ The form shows the whole catalog either way, so the user sees what you did not recommend.
117
+
118
+ **Declaring a round:**
119
+
120
+ ```json
121
+ { "id": "interview-1", "kind": "round", "title": "A few things about the checkout", "file": "",
122
+ "payload": { "kind": "round", "questions": [
123
+ { "id": "scope", "ask": "Which orders can be partly cancelled?", "multi": false,
124
+ "invite": "Anything the options miss?",
125
+ "options": [
126
+ { "id": "any", "said": "Any order, at any time", "recommended": true },
127
+ { "id": "unshipped", "said": "Only an order nothing has shipped from" } ] } ] } }
128
+ ```
129
+
130
+ **Declaring a gate:**
131
+
132
+ ```json
133
+ { "id": "spec-gate", "kind": "gate", "title": "Does the spec look right?", "file": "spec/SPEC.md",
134
+ "payload": { "kind": "gate", "asks": "Approve it, or say what to change." } }
135
+ ```
136
+
137
+ `file` is the artifact the gate judges, relative to the spec directory.
138
+ The tab opens that artifact and puts the gate under it.
139
+
140
+ **Declaring a decision card:**
141
+
142
+ ```json
143
+ { "id": "rv-04", "kind": "gate", "title": "The plan leans on one mechanism", "file": "plan/PLAN.md",
144
+ "payload": { "kind": "decision",
145
+ "evidence": "what was found, and what it rests on",
146
+ "tradeoff": "what each way costs" } }
147
+ ```
148
+
149
+ **Posting progress:**
150
+
151
+ ```json
152
+ { "kind": "activity", "said": "Reading the checkout code" }
153
+ { "kind": "stage", "stage": "codebase-analysis", "status": "done", "artifacts": ["spec/SPEC.md"] }
154
+ { "kind": "status", "status": "ready" }
155
+ { "kind": "note", "said": "one dated line for the log" }
156
+ ```
157
+
158
+ Post an activity when you start something that takes a while, so the board says what is happening.
159
+ Post a stage as `running` when it starts, and as `done` with its artifacts when it ends.
160
+
161
+ **Reading an answer back:**
162
+
163
+ ```json
164
+ { "outcome": "approved", "said": "", "questions": [] }
165
+ ```
166
+
167
+ An outcome is `approved` or `changes` for a gate, `apply` or `dismiss` for a decision card, and `answered` for a round.
168
+ A round's answer carries one line per question, and a question the user left alone is there too, marked `"answered": false`.
169
+ Treat that as skipped. It is not a "no".
170
+ `{ "answer": null }` means the user has not answered yet.
171
+
172
+ ## Writing a question
173
+
174
+ The pane's form has no limit on questions or options, so ask the whole round at once rather than in a chain of small ones.
175
+ Every question still follows these rules:
176
+
177
+ - Write for someone who has never used these skills.
178
+ - Do not use internal terms - directory layout, phase files, stage names - unless the option explains them in the same breath.
179
+ - Put the option you would choose first, and mark it `"recommended": true`.
180
+ - Keep an option's `said` short. Put the reasoning and the trade-off in the question's `ask`.
181
+ - Where a real trade-off exists, lay it out and let the user decide. Never decide it silently.
182
+ - Give every question an `invite` when a typed answer would be worth more than a choice.
183
+
184
+ Give each round and each gate an id that says what it is: `interview-1`, `spec-gate`, `mocks-gate`.
185
+ An id is answered once. Ask again with a new id.
186
+
187
+ ## What a finished spec is
188
+
189
+ A complete spec lets a fresh agent open the directory with no other context and know what to build.
190
+ That agent learns where the edges are, how to tell the work is done, and roughly where the code goes.
191
+ No question for the user is left.
192
+ Aim for a production-grade spec every time.
193
+
194
+ ## What is on disk
195
+
196
+ The tab serves one root, and each piece of work is one directory under it.
197
+
198
+ ```
199
+ <root>/
200
+ principles.md the settings and principles, owned by /dx-spec-config
201
+ <slug>/
202
+ README.md written by the tool, from the state - never by you
203
+ intake.md what the work started as
204
+ spec/
205
+ SPEC.md the specification
206
+ *.md, *.svg what the user shared, and visuals written beside the spec
207
+ research/RESEARCH.md written by the research stage
208
+ mocks/<mock-id>.html one standalone page per screen
209
+ plan/PLAN.md the execution plan, plus one file per phase during the run
210
+ review/REVIEW.md the quality review report
211
+ archive/
212
+ YYYY-MM-DD-<slug>/ work that is finished and signed off
213
+ ```
214
+
215
+ A stage directory appears when its stage writes something. Nothing is created empty.
216
+
217
+ ## A page you make during this work
218
+
219
+ You may draw a page to explain something - a flow, a comparison, a diagram.
220
+ During spec work, that page belongs to the spec, so save it into the spec directory under a lowercase name.
221
+ The tab lists it beside the other artifacts and renders it, and the user comments on it there.
222
+ Do not publish it to the Pages tab: a page on Pages belongs to this conversation, and this one belongs to the work.
223
+
224
+ Outside spec work, `webpane` and the Pages tab are the right home for a page.
225
+
226
+ Keep a page standalone: no external stylesheet, no script that fetches anything, and images as data URLs.
227
+
228
+ ## Flow
229
+
230
+ Run the bootstrap in `../dx-spec-config/SKILL.md` before step 1.
231
+ It resolves the root, reads the principles file, offers the one-time setup when there is none, and gives you the settings for the rest of the run.
232
+
233
+ ### 1. Start
234
+
235
+ The user reaches this skill in one of three ways.
236
+
237
+ **A line arrived from the pane.** The user filed an intake on the tab, and the terminal carries one line naming the file. Read that file, and go to step 3.
238
+
239
+ **The user passed text.** Treat it as their opening input. When it names a piece of work that already exists, go to step 2.
240
+
241
+ **Nothing.** Read the root with `specs stages`.
242
+ With one piece of work or more there, declare a round that asks which one, with one option per directory and one for something new.
243
+ Declare it on the piece of work that changed last.
244
+ Every asking verb names a spec, and there is no spec for "which spec" - so the round sits on a real one, and the tab shows it wherever the user is.
245
+ Never name an empty spec or a spec that is not there: the verb refuses it, and the question is not asked at all.
246
+ With nothing there, go straight to the collect invitation in step 2.
247
+
248
+ ### 2. Collect
249
+
250
+ Let the user say everything they have before you ask anything.
251
+
252
+ Send this invitation as one short message, in these words:
253
+
254
+ > Tell me about the work. Paste everything you have - notes, links, screenshots, file paths, snippets, examples, prior art - in one go, and I'll take it from there.
255
+
256
+ Then end your turn and wait.
257
+ Skip the invitation when their opening input already covers it.
258
+
259
+ With their input in, file it:
260
+
261
+ ```
262
+ echo '{"name":"<a working name>","text":"<everything they said>","attachments":[]}' | specs intake
263
+ ```
264
+
265
+ The tool makes the directory, writes `intake.md`, and starts the state file.
266
+ The tab opens on it.
267
+
268
+ ### 3. Pick up work in progress
269
+
270
+ Read `specs state <spec>` and every artifact in the directory.
271
+ The state says which stages were confirmed, where each one stands, and what is waiting for the user.
272
+
273
+ `.specs/user-feedback.json` in the directory holds annotations the user sent that nobody has applied.
274
+ Apply them as `references/stages.md` defines, before anything else.
275
+
276
+ Then declare a round: what the work is, where it stands, and what happens next - continue, redo something, or change the steps.
277
+
278
+ ### 4. Choose the protocol
279
+
280
+ Read what the input points to in the codebase, enough to judge the shape and the size of the work.
281
+
282
+ Then recommend the stages this work needs:
283
+
284
+ ```
285
+ echo '{"stages":[...],"note":""}' | specs propose <spec>
286
+ ```
287
+
288
+ Give every stage you recommend a `why` of one sentence, in the user's terms.
289
+ The form shows the whole catalog, recommended or not, so the user sees the choice whole.
290
+ Confirming writes the protocol into the state, in catalog order.
291
+
292
+ Rough rules for what to recommend:
293
+
294
+ - A bug fix: codebase analysis and an execution plan.
295
+ - A small feature or a chore: interview, codebase analysis, execution plan.
296
+ - A new user-facing feature: exploration, interview, codebase analysis, technical specs, UI mocks, execution plan.
297
+ - Work in a subject you or the user do not know well: add research.
298
+ - Pure thinking, or one decision to make: exploration, maybe research, and no plan.
299
+ - Large or risky work: add the quality review. Many phases, several stages feeding one spec, or anything that touches security, data or money.
300
+
301
+ The pane offers imagination mode when the confirmed protocol holds exploration or UI mocks.
302
+ Read `references/imagination-guide.md` when the state comes back with `modes.imagination` true, when the user asks for the mode by name, and at no other time.
303
+
304
+ Save what the user shared into `spec/` under lowercase names of their own.
305
+
306
+ ### 5. Run the stages
307
+
308
+ Run the stages in the order the confirmed protocol lists.
309
+ `references/stages.md` defines each one.
310
+ Read a stage's section when the stage starts, and run the stage from that definition: it carries gates and rules the stage name alone does not state.
311
+
312
+ Every stage that writes into `SPEC.md` also uses `references/spec-guide.md`.
313
+
314
+ Post the stage as `running` when it starts.
315
+ Post it as `done` with its artifacts when its gate is approved.
316
+ Every stage ends at a gate, except codebase analysis, which feeds the next stage and has none.
317
+
318
+ Every gate also clears the open markers.
319
+ Before you declare a gate, read `SPEC.md` for open `[NEEDS CLARIFICATION: ...]` markers.
320
+ Put them in the same round as the gate, in the priority order in `references/spec-guide.md`.
321
+ Each answer replaces its marker in `SPEC.md` in the same round.
322
+ This is what makes every marker reach the user.
323
+ Codebase analysis has no gate, so what it opens is asked at the gate of the stage after it.
324
+ The interview asks its own markers in its own rounds.
325
+
326
+ ### 6. The coherence rewrite
327
+
328
+ Before the finalize gate, rewrite what the work changed after it was first written.
329
+ `references/spec-guide.md` defines this step: when it runs, what it produces, and the one round of review that follows it.
330
+
331
+ ### 7. Finalize
332
+
333
+ Read every file in the spec directory from start to end, and check:
334
+
335
+ - Every assumption and open question is labeled.
336
+ - No two files disagree.
337
+ - Each requirement carries its own acceptance criterion, where the spec carries requirement IDs.
338
+ - Every ID appears in some phase's `Covers` line, where the protocol includes the execution plan.
339
+
340
+ Skip `mocks/candidates/`: it holds directions nobody chose.
341
+
342
+ When `review/REVIEW.md` is there, this read covers less ground.
343
+ Read the parts no reviewer saw: the fixes the stage made, and the edits that came from the user's decisions at the review gate.
344
+ Treat the rest as covered, because the review stage ran the deeper version of this check over it.
345
+
346
+ Ask any marker still open in `SPEC.md` before the gate.
347
+ The gate does not pass while a marker stays open.
348
+
349
+ Then declare the finalize gate on `spec/SPEC.md`, saying what the spec covers in a sentence or two.
350
+ On changes: revise, and declare a new gate.
351
+ Loop until the user approves it.
352
+
353
+ After they approve:
354
+
355
+ ```
356
+ echo '{"kind":"status","status":"ready"}' | specs post <spec>
357
+ ```
358
+
359
+ Then declare one last gate: whether to commit the spec.
360
+ On approval, stage the spec directory by path and commit it with a one-line message.
361
+ Compose the message from the commit style in the principles file, with "spec ready" as its descriptive part.
362
+ Commit only. Never push.
363
+ Staging by path leaves every other change in the working tree alone.
364
+
365
+ Close with one short message: what the spec covers, where it is, whether it was committed, and, when a plan exists, that `/dx-spec-execute` runs it.
@@ -0,0 +1,140 @@
1
+ # Imagination mode
2
+
3
+ This file holds imagination mode for `/dx-spec` (`SKILL.md` in the directory above).
4
+ Read it when the mode is on, or when the user asks for it by name, and not before.
5
+
6
+ ## What the mode is
7
+
8
+ Imagination mode is a budget for divergence.
9
+ A normal run narrows the work from the first question.
10
+ A run in the mode holds the space open on purpose, spends real effort to look wide, and narrows late.
11
+
12
+ The mode adds no stage.
13
+ It changes three things:
14
+
15
+ - The early stages ask for the ideal first, and practicality waits its turn.
16
+ - The UI mocks stage starts with a fan-out: many deliberately different candidate screens, and the user chooses among them.
17
+ - The UI mocks stage runs before the technical specs stage, so the spec is written to the direction the user chose.
18
+
19
+ Token cost is not a concern here. Depth and range are the point.
20
+
21
+ **Raise a doubt, never guess** holds in full.
22
+ The mode widens the solution space.
23
+ It never lets you settle a doubt on your own.
24
+
25
+ ## The offer
26
+
27
+ The pane offers the mode on the protocol form, and only when the protocol holds high-level exploration or UI mocks.
28
+ You do not ask for it.
29
+ The state comes back with `modes.imagination` true when the user turned it on.
30
+
31
+ The user also turns it on by naming it, at any time before the technical specs stage writes the spec.
32
+
33
+ **Late activation.**
34
+ The mode applies to the stages still ahead.
35
+ Run every one of them in the mode.
36
+ For a stage that already finished, judge whether the mode would change its outcome.
37
+ When it would, ask in a round whether to run that stage again.
38
+ Say plainly that what exists stays until a new round replaces it.
39
+
40
+ ## The stage order
41
+
42
+ With the mode on, and both stages in the protocol, the UI mocks stage runs **before** the technical specs stage.
43
+ The reorder applies to those two stages alone.
44
+ Every other stage keeps its place.
45
+
46
+ ## High-level exploration in the mode
47
+
48
+ Run the first pass magic-first.
49
+ Name the ideal experience as if everything were possible: no cost, no platform limit, no legacy code.
50
+ **No talk of feasibility is allowed in that first pass.**
51
+ Let no answer of yours, and no answer of the user's, pull the conversation to what is practical.
52
+ When the user raises a constraint, write it down, and say it comes back once the ideal is clear.
53
+
54
+ Practicality enters after the first pass has a gate-confirmed conclusion.
55
+ The stage therefore gates twice.
56
+
57
+ Gate the ideal pass first: the ideal is clear, or there is more to imagine.
58
+ On "clear", write the ideal into the `North star` section of `spec/SPEC.md`, and run the second pass.
59
+ `references/spec-guide.md` defines that section. Create it here, and let the later stages fill in its other parts.
60
+ The second pass holds the ideal against the real code, the real cost and the real limits, and names what survives.
61
+ Gate that pass with the exploration gate in `stages.md`, which ends the stage.
62
+
63
+ ## The interview in the mode
64
+
65
+ Ask for the ideal experience first.
66
+ The constraint questions follow.
67
+ A constraint then applies to a vision, rather than standing in for one.
68
+ Every other rule of the interview stage holds.
69
+
70
+ ## The UI mocks stage in the mode
71
+
72
+ The stage keeps every rule in its `stages.md` section.
73
+ The mode puts a fan-out in front of the normal loop.
74
+
75
+ ### The creative research pass
76
+
77
+ Before the fan-out, study prior art and unusual patterns for work of this kind.
78
+ Look at how other products solved it, and at patterns the user has probably not seen.
79
+ Size the pass by your own judgment.
80
+
81
+ This pass belongs to the mode. It is not the research stage, and it leaves no document of its own.
82
+ Write what shaped the candidates as a short note in the north-star section of `SPEC.md`.
83
+
84
+ ### The fan-out round
85
+
86
+ Form your own feel for how many distinct directions this work holds.
87
+ Then ask one round, before you build anything: how many versions to make, and on which axes they differ.
88
+ Name the axes in the question, because the axes are what makes the candidates different.
89
+ Offer your own count, a smaller one, and one option that means "push for more than that".
90
+ Mark your count recommended.
91
+
92
+ On "push for more": go back to the axes, find directions outside the ones you named, and come back with a wider set.
93
+
94
+ ### The candidates
95
+
96
+ Build each candidate as a standalone page at `mocks/candidates/<NN>-<short name>.html`.
97
+ `<NN>` is the candidate's number, and it runs on across rounds, so no two candidates share one.
98
+ The candidate's id is its file name without the extension, such as `03-split-view`.
99
+
100
+ Every candidate differs from every other on a named axis.
101
+ Name that axis at the top of the candidate's page, in one line.
102
+ A candidate that differs in a color or a word alone is not a direction, and it does not earn a place in the set.
103
+
104
+ ### The choice
105
+
106
+ The tab renders every candidate page in the directory, so the user opens each one there.
107
+ Declare one round asking which candidates to keep: one question, multi-select, one option per candidate carrying its id, its title and its axis.
108
+ Give the round an `invite` for what the user thinks of the set as a whole.
109
+
110
+ Then apply the choice:
111
+
112
+ - Move every candidate the user keeps to `mocks/<mock-id>.html`, under a name that says what the screen is. These are the mocks now, and they enter the normal loop of the UI mocks stage.
113
+ - Leave every discarded candidate in `mocks/candidates/` as a record. A rejected direction can inspire a later feature, so delete none of them.
114
+
115
+ List the survivors in the `Mocks` section of `SPEC.md`.
116
+ List no candidate there: that section holds the screens to build.
117
+
118
+ ### When nothing is kept
119
+
120
+ A round can end with no candidate kept.
121
+ Ask what was wrong with them, in a round: they are all too close to each other, they all solve the wrong problem, or another reading the round suggests.
122
+ Mark the reading you find most likely, and leave the marker off when you have no view.
123
+
124
+ Then run another fan-out with fresh axes, informed by the answer.
125
+ Keep the discarded set on disk.
126
+ This loop has no fixed limit.
127
+ It ends when one direction survives at least, or when the user takes the work somewhere else.
128
+
129
+ ## The mocks checkpoint after the spec
130
+
131
+ With the mode on, the mocks are approved before the spec is written.
132
+ The spec can then settle something the approved mocks show.
133
+
134
+ After the technical specs gate passes, compare the approved mocks against the approved spec.
135
+ When the spec settled anything the mocks show - a flow, a state, a field, a name on the screen, a rule the screen obeys - ask in a round whether to bring the screens up to date.
136
+ Name what changed.
137
+
138
+ On yes: revise the mocks, and take a re-approval through the normal mocks gate.
139
+ On no: change nothing.
140
+ Offer no checkpoint when nothing the mocks show changed.
@@ -0,0 +1,173 @@
1
+ # The quality review
2
+
3
+ This file holds the reviewer briefs, the detection lenses, the severities, the report format, and the design-blockers loop.
4
+ The stage itself is defined in `stages.md`.
5
+ Read this file when the stage starts, and not before.
6
+
7
+ ## The reviewer brief
8
+
9
+ Every reviewer subagent gets this brief, with the angle-bracket parts filled in.
10
+ An agent that runs the review itself acts as both the reviewer and the assembler.
11
+
12
+ ```markdown
13
+ You are reviewing a written specification you did not help write.
14
+ Your focus is <the reviewer's one focus>, and the lenses that belong to it are <the lenses of that focus>.
15
+
16
+ Read every file in the spec directory at <path to the spec directory>, in this order, whichever of them exist: `README.md` first, since it tells you which stages this work ran, then `intake.md`, `spec/SPEC.md`, `research/RESEARCH.md`, `plan/PLAN.md` and the phase files beside it, and every page directly under `mocks/`.
17
+ Skip `mocks/candidates/`: it is a record of directions nobody chose, and it is not part of the work under review.
18
+ The screens to build are the mocks the `Mocks` section of `spec/SPEC.md` lists.
19
+ Read the principles file at <path to principles.md>.
20
+ Read the repo's own rule files, `CLAUDE.md` and `AGENTS.md`, wherever they exist.
21
+
22
+ Judge the artifacts as written.
23
+ Do not take the conclusions of the session that wrote them as settled: you were not in that session, and judging this work with fresh eyes is exactly your value.
24
+ You share no context with the other reviewers, you are not told what they found, and you must not ask another agent for context.
25
+ The deviations recorded in the plan's principles check are exceptions the user already approved, so raise one only when the reason written next to it does not hold.
26
+
27
+ Before you read anything, turn your lenses into a checklist: one check per lens, split further where a lens covers several things.
28
+ Then run every check, and return that checklist in your reply, with a pass or fail line per check.
29
+ Return every failed check as a finding, carrying its severity from the levels below, the artifact and the section it points at, a one-line title, and the reasoning behind it.
30
+ When a check fails on a decision that is the user's to make rather than a plain fix, say so, list the options, and name the one you would pick.
31
+ A check that passes can still leave you with something better to propose - a simpler shape, a design choice you would make differently, code the repo already ships that does part of the work.
32
+ Report that as a finding in the same form, and say in its reasoning that nothing failed and this is an improvement you are offering.
33
+ Give it the severity of what it would be worth.
34
+ Give your findings no id and no state, and write no header block: the agent running the review assembles the report and fills those in.
35
+ A finding you are unsure about is still reported, and you say in its reasoning that it is a judgment call.
36
+
37
+ Change no file and write nothing to disk.
38
+ Your reply is everything you produce.
39
+
40
+ <the severity levels of this file, copied into the brief>
41
+ ```
42
+
43
+ ## The detection lenses
44
+
45
+ Each lens has one line, so a brief names the lenses that belong to its focus.
46
+
47
+ - Inconsistency between artifacts - reads `spec/SPEC.md`, `research/RESEARCH.md`, `plan/PLAN.md` and the mocks against each other, for two statements that cannot both be true.
48
+ - Coverage of the requirements - see the block below.
49
+ - Missing detail and unhandled edge cases - reads the requirements and the flows for the empty, error and limit cases nobody wrote down.
50
+ - Ambiguity and untestable requirements - reads `spec/SPEC.md` for an open `[NEEDS CLARIFICATION: ...]` marker, a requirement with no acceptance criterion, and a requirement nobody could call pass or fail.
51
+ - Duplication and overlap - reads the artifacts for the same thing stated twice, in two places that can drift apart.
52
+ - Terminology drift - reads every artifact for one idea under several names, or one name over several ideas.
53
+ - Principles alignment - reads the artifacts against the principles file and the repo's own rule files.
54
+ - Better ways to do this - reads the design against the codebase for a simpler shape, and for code the repo already ships that does part of the work.
55
+ - Design blockers - reads the design for what would send the build wrong, and reports at HIGH and CRITICAL alone.
56
+
57
+ The consistency-and-completeness reviewer takes every lens except principles alignment, better ways to do this, and design blockers, which go to the reviewers of those names.
58
+ A focus outside this set takes the lenses that touch it.
59
+ Every lens goes to exactly one reviewer on the confirmed panel, so a panel that drops a focus hands that focus's lenses to the reviewer nearest to it.
60
+
61
+ ## The coverage lens
62
+
63
+ When the protocol includes the execution plan stage, the coverage lens runs two checks.
64
+ It checks that every requirement ID in `spec/SPEC.md` appears in some phase's `Covers` line in `plan/PLAN.md`.
65
+ It also checks that every ID named in a `Covers` line exists in `spec/SPEC.md`.
66
+ A requirement with no plan coverage is a CRITICAL finding.
67
+ The reviewer states which of two causes it looks like: a missing phase, or scope that belongs in the non-goals.
68
+ When the protocol has no execution plan stage, the lens checks instead that every requirement carries its own acceptance criterion, and reads as a pass or a fail.
69
+
70
+ ## The severity levels
71
+
72
+ - **CRITICAL** - a principles violation, a contradiction between artifacts, or a requirement with no plan coverage.
73
+ - **HIGH** - a conflicting or untestable requirement, an ambiguous security or performance attribute.
74
+ - **MEDIUM** - terminology drift, an edge case with missing detail.
75
+ - **LOW** - style and wording.
76
+
77
+ Fix a conflict with a principle by changing the work.
78
+ Never resolve it by softening the principle.
79
+
80
+ ## The design-blockers loop
81
+
82
+ One reviewer on every panel has the design-blockers focus.
83
+ Its brief is the brief above, with two additions:
84
+
85
+ - It reports HIGH and CRITICAL findings alone. Anything below that is not its business, and another reviewer has it.
86
+ - It reads for what would send the build wrong: a design that cannot hold, a contract two artifacts read differently, a requirement whose shape makes it unbuildable as written.
87
+
88
+ **The loop.**
89
+ Run the blockers reviewer.
90
+ Fix what it found.
91
+ Then run it again, with fresh context, over the fixed artifacts.
92
+ Repeat until a round returns nothing.
93
+ A fresh run each time is the point: a reviewer that saw the last round would grade its own fixes.
94
+
95
+ **The guardrail.**
96
+ A scoped reviewer has no natural zero.
97
+ Given fixed artifacts and a mandate to find HIGH findings, a reviewer finds HIGH findings, and the rounds degrade into ever smaller material dressed in a severity it does not carry.
98
+
99
+ So judge every returned finding before you loop again, against one criterion:
100
+
101
+ > A finding an executing agent would likely have resolved on its own is not a true design blocker, whatever severity the reviewer gave it.
102
+
103
+ An executing agent reads the code, runs the tests, and makes the small calls the spec left open.
104
+ That is its job.
105
+ A finding that names one of those calls is execution's work, and the plan's own review checkpoints cover it.
106
+
107
+ **The close.**
108
+ A round whose findings all fail that test closes the loop.
109
+ Record the judgment per finding in the report - what it was, and why it failed the test - and leave that material to execution.
110
+ Only a finding that passes the test justifies another round.
111
+
112
+ Convergence here is judged, never awaited.
113
+ Do not run a further round in the hope of a zero.
114
+
115
+ ## The report format
116
+
117
+ `review/REVIEW.md`:
118
+
119
+ ```markdown
120
+ # Quality review - <title of the work>
121
+
122
+ - Run: YYYY-MM-DD
123
+ - Mode: fresh-context subagents | inline - the session that wrote the spec
124
+ - Panel: <one focus per reviewer>
125
+ - Blockers loop: <n> rounds, closed by <a zero round | judgment>
126
+ - Findings: <total>, of which <n> applied, <n> dismissed, <n> waiting on you
127
+
128
+ ## <the first reviewer's focus>
129
+
130
+ - [x] <a check this reviewer ran and passed>
131
+ - [ ] <a check it ran and failed>
132
+
133
+ ### RV-01 - <the finding in one line>
134
+
135
+ - Severity: HIGH
136
+ - Points at: SPEC.md, the Requirements section, FR-04
137
+ - State: FOR YOUR DECISION
138
+ - Options: <first option> | <second option>
139
+ - Reasoning: <why the reviewer raised it>
140
+ - Note: <the fix applied, the reason it was dismissed, or what the reviewer recommends>
141
+
142
+ ### RV-02 - <the finding in one line>
143
+
144
+ - Severity: MEDIUM
145
+ - Points at: SPEC.md, the Data section
146
+ - State: APPLIED
147
+ - Reasoning: <why the reviewer raised it>
148
+ - Note: <the fix that was applied>
149
+
150
+ ## Design blockers
151
+
152
+ ### Round 1
153
+
154
+ <the findings of that round, in the form above>
155
+
156
+ ### Round 2 - closed by judgment
157
+
158
+ <each finding, with the judgment against the criterion and where the material was left>
159
+ ```
160
+
161
+ The running agent assembles this report from the reviewers' replies.
162
+ It writes the header block, and puts each reviewer's checklist and findings under that reviewer's focus.
163
+ It assigns the ids and the states.
164
+ Finding ids run `RV-01`, `RV-02`, and so on, in writing order across the whole report.
165
+ An id never changes, so a decision that names a finding still points at the same finding.
166
+
167
+ `State:` holds `APPLIED`, `DISMISSED` or `FOR YOUR DECISION`.
168
+ A finding that waits on the user carries an `Options:` line, recommended option first.
169
+ Every other finding leaves that line out.
170
+ The report keeps every finding, applied and dismissed included.
171
+ A finding the user decides on keeps its id and gains the outcome in its `Note:` line.
172
+ Applying that decision changes its `State:` line: `APPLIED` when the decision changed the artifacts, and `DISMISSED` when the user left them as they are.
173
+ Either way, drop the `Options:` line and update the counts in the header.