@uselazuli/cli 1.0.1 → 1.0.2

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 (56) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +3 -3
  3. package/bin/lazuli.mjs +67 -19
  4. package/package.json +1 -1
  5. package/rules/content/HYPOTHESES.md +3 -2
  6. package/rules/content/review.yaml +33 -2
  7. package/rules/graphic/HYPOTHESES.md +1 -0
  8. package/rules/graphic/review.yaml +29 -0
  9. package/rules/motion/HYPOTHESES.md +3 -3
  10. package/rules/motion/review.yaml +4 -4
  11. package/rules/typography/HYPOTHESES.md +1 -1
  12. package/rules/typography/review.yaml +2 -2
  13. package/rules/ui/HYPOTHESES.md +1 -1
  14. package/rules/ui/compose.yaml +27 -0
  15. package/rules/ui/review.yaml +2 -1
  16. package/skills/lazuli/SKILL.md +8 -5
  17. package/skills/lazuli/procedures/review-design.md +1 -0
  18. package/skills/lazuli/procedures/show-options.md +2 -1
  19. package/skills/lazuli-content-voice/SKILL.md +1 -0
  20. package/skills/lazuli-graphic-identity/SKILL.md +3 -1
  21. package/skills/lazuli-ui-composition/SKILL.md +4 -4
  22. package/skills/lazuli-ui-layout-review/SKILL.md +2 -2
  23. package/src/browser.mjs +2 -1
  24. package/src/commands/catalog.mjs +1 -1
  25. package/src/commands/check-design.mjs +51 -16
  26. package/src/commands/compare-designs.mjs +65 -2
  27. package/src/commands/draft-memo.mjs +4 -3
  28. package/src/commands/hooks.mjs +7 -5
  29. package/src/commands/record-log.mjs +54 -25
  30. package/src/commands/render-options.mjs +78 -15
  31. package/src/measure/a11y.mjs +8 -0
  32. package/src/measure/cases.mjs +22 -5
  33. package/src/measure/color.mjs +7 -0
  34. package/src/measure/in-page/a11y.js +33 -0
  35. package/src/measure/in-page/color.js +3 -1
  36. package/src/measure/in-page/extreme.js +28 -6
  37. package/src/measure/in-page/motion-probe.js +2 -0
  38. package/src/measure/in-page/type.js +3 -0
  39. package/src/measure/layout.mjs +9 -0
  40. package/src/measure/motion.mjs +2 -1
  41. package/src/measure/registry.mjs +3 -2
  42. package/src/measure/timeline.mjs +5 -5
  43. package/src/project/gate.mjs +12 -3
  44. package/src/project/lazuli-md.mjs +27 -3
  45. package/src/project/log.mjs +16 -10
  46. package/src/project/match.mjs +93 -5
  47. package/src/report/evaluators/a11y.mjs +21 -0
  48. package/src/report/evaluators/color.mjs +48 -1
  49. package/src/report/evaluators/extreme.mjs +43 -9
  50. package/src/report/evaluators/layout.mjs +10 -1
  51. package/src/report/evaluators/motion.mjs +10 -3
  52. package/src/report/evaluators/type.mjs +6 -3
  53. package/src/report/format.mjs +4 -4
  54. package/src/rules/load.mjs +18 -0
  55. package/src/rules/schema.mjs +8 -0
  56. package/templates/LAZULI.md +2 -0
@@ -38,7 +38,7 @@
38
38
  status: hypothesis
39
39
  hypothesis: H3
40
40
  source: >-
41
- Candidate range from Butterick, Practical Typography, "Line spacing" (opened 2026-11-25: 120% to 145% of the point size). The upper end is raised to 1.5 so the hint never argues against WCAG 2.2 Success Criterion 1.4.8 Visual Presentation (Level AAA, https://www.w3.org/TR/WCAG22/#visual-presentation, opened 2026-11-25), which asks that line spacing can be at least space-and-a-half within paragraphs. Treated as a hypothesis until the A/B.
41
+ Candidate range from Butterick, Practical Typography, "Line spacing" (opened 2026-11-25: 120% to 145% of the point size). The upper end is raised to 1.5 so the hint never argues against WCAG 2.2 Success Criterion 1.4.8 Visual Presentation (Level AAA, https://www.w3.org/TR/WCAG22/#visual-presentation, opened 2026-11-25), which asks that line spacing can be at least space-and-a-half within paragraphs. The same page says nothing about headings or display type, so the lower bound being skipped for display type (24 px and up, or 18.66 px and up at weight 700 or more, the WCAG 2.2 large scale that RV2 reads) is our claim, not the source's. Treated as a hypothesis until the A/B.
42
42
  measure: type.line-height
43
43
  threshold: { minRatio: 1.2, maxRatio: 1.5 }
44
44
  when_to_break: >-
@@ -46,7 +46,7 @@
46
46
  break_effect: >-
47
47
  A tight huge headline reads as one block with force, like a poster. An airy quote reads as slow and contemplative.
48
48
  test: >-
49
- The measurer reports the line height ratio of each multi-line block. Hint for blocks outside the candidate range.
49
+ The measurer reports the line height ratio of each multi-line block. Hint for blocks outside the candidate range; a block at WCAG large scale is display type and is hinted only above the upper bound.
50
50
  example: >-
51
51
  Body at 1.4, a display headline at 1.05 on purpose.
52
52
  counterexample: >-
@@ -9,7 +9,7 @@ Where a row or a rule cites the kit author's internal product plan, that plan is
9
9
  | H1 | Distance from default (compare-designs) | The structural signature distance between a page and a no-kit baseline for the same brief, components weighted equally (our claim) | Ask reviewers which of several pairs "looks different" and check the distance ranks the pairs the same way |
10
10
  | H2 | UR1 (scale contrast of the first view, layout.scale-contrast) | Cutoff: minTextRatio 2, minAreaRatio 2. The first view has contrast when the largest text is at least 2 times the body size or the largest block is at least 2 times the median block; the hint fires only when both fall below. How it was picked: a round starting value, our claim, set before any real page was measured (the stub used the same). Observed so far, not evidence: layout-flat 1 and 1, layout-tension 12.5 and 16.32; test site A 2.81 and 9.59 at 1440 px, 1.94 and 7.33 at 390 px; test site B 2.56 and 5.31 at 1440 px, 1.92 and 14.77 at 390 px. The text cutoff sits within 0.08 of two site readings at 390 px (1.94 and 1.92) | Needs pages outside the test sites: a set of award-listed pages against default-template pages for the same brief, judged by reviewers ("has a clear top?") before the cutoff is applied; then compare text ratios of 1, 2 and 4 |
11
11
  | H3 | UR2 (empty space has a shape, layout.empty-space) | Cutoff: minSpread 0.5. The first view is read as a shape when the emptiest and the fullest of its 9 areas differ by at least 0.5 (50 percentage points of empty share); below that the space is spread evenly. How it was picked: a midpoint between the two fixtures (layout-flat 0.11, layout-tension 1), our claim, set before any real page was measured. It was briefly lowered to 0.3 and restored, because a cutoff tuned to the sites it runs on cannot be tested by them. Observed so far, not evidence: test site A 0.54 at 1440 px and 0.25 at 390 px; test site B 0.42 at 1440 px and 0.75 at 390 px. The cutoff sits within 0.04 of test site A at 1440 px | Needs pages outside the test sites: award-listed pages against default templates, judged by reviewers ("looks placed or looks left over?") before the cutoff is applied; then compare spreads of 0.1, 0.3, 0.5 and 0.7 |
12
- | H4 | UR3 (one focal point, layout.focal-point) | Cutoff: minDominance 2. One block leads the first view when its area is at least 2 times the next largest block. How it was picked: a round starting value, our claim, set before any real page was measured (the stub used the same). It was briefly lowered to 1.5 after the site readings were known and restored, because a cutoff tuned to the sites it runs on cannot be tested by them. Observed so far, not evidence: layout-flat 1, layout-tension 16.32; test site A 1.52 at 1440 px and 2.48 at 390 px; test site B 1.06 at 1440 px and 3.76 at 390 px. At this cutoff both sites get the hint at 1440 px (test site A sits at 1.52) and neither does at 390 px | Needs pages outside the test sites: a five second test ("where did you look first?") on award-listed pages and default-template pages before the cutoff is applied; then compare dominance 1, 1.5, 2 and 3 on how often reviewers agree on one element |
12
+ | H4 | UR3 (one focal point, layout.focal-point) | Cutoff: minDominance 2. One block leads the first view when its area is at least 2 times the next largest block. The pair of the two largest blocks (UC9) leads when the second is at least 2 times the third, the same cutoff applied to the pair. How it was picked: a round starting value, our claim, set before any real page was measured (the stub used the same). It was briefly lowered to 1.5 after the site readings were known and restored, because a cutoff tuned to the sites it runs on cannot be tested by them. Observed so far, not evidence: layout-flat 1, layout-tension 16.32; test site A 1.52 at 1440 px and 2.48 at 390 px; test site B 1.06 at 1440 px and 3.76 at 390 px. At this cutoff both sites get the hint at 1440 px (test site A sits at 1.52) and neither does at 390 px | Needs pages outside the test sites: a five second test ("where did you look first?") on award-listed pages and default-template pages before the cutoff is applied; then compare dominance 1, 1.5, 2 and 3 on how often reviewers agree on one element |
13
13
  | H5 | UR4 (the page changes pace, rhythm.pace) | Cutoff: minSections 3, minHeightRatio 1.5, minDensityRatio 1.5. A page of at least 3 sections changes pace when its tallest section is at least 1.5 times its shortest, or its densest at least 1.5 times its sparsest; the hint fires only when both ratios stay below. How it was picked: round starting values, our claim, set before any real page was measured. Observed so far, not evidence: height ratios rhythm-flat 1, rhythm-sequence 3, test site A 23.38 at 1440 px and 33.5 at 390 px, test site B 15 at 1440 px and 16.55 at 390 px; density ratios rhythm-flat 1, test site A 9.02 at 1440 px and 4.56 at 390 px, test site B has a section of density 0 so the ratio has no bound | Needs pages outside the test sites: scroll recordings of award-listed pages and default-template pages, judged by reviewers ("does the page have a beat or does it repeat?") before the cutoff is applied; then compare height ratios of 1, 1.5 and 3 |
14
14
  | H6 | UR6 (the climax sits where it was declared, rhythm.climax) | Cutoff: maxShift 0.2. The measured climax (the section with the largest type, centered on its position in the page) may sit up to 0.2 of the page height from the climax beat of the declared map. How it was picked: a round starting value, our claim, set before any real page was measured. Observed so far, not evidence: on rhythm-sequence the climax is 0.01 from a map with the climax third and 0.39 from a map with the climax first; the two real sites declare no map, so no real page has tested it | Needs pages outside the test sites: pages whose climax was placed on purpose and mapped by their authors, judged "on the beat" or not by reviewers before the cutoff is applied |
15
15
  | H7 | UR5 (the sequence follows the declared map, rhythm.map) | A section marked "breathe" should not be denser than the median section of the page and one marked "accelerate" should not be sparser; the beat count must equal the section count. Our claim, a hint only; no number is used as a cutoff. A section is flagged only when its density differs from the median by more than densityStep, the share of one row of the coverage grid in that section (8 px over the measured section height): that is the measuring resolution, not a cutoff, so a difference smaller than one row is not read as a difference. Observed so far: no real page declares a map | Needs pages outside the test sites: pages whose authors say they followed their map against pages built without one, before the hint is applied |
@@ -217,3 +217,30 @@
217
217
  A long technical page that, after the specifications, gives one open view to a single sentence from a customer.
218
218
  counterexample: >-
219
219
  Specifications, pricing, questions and contact packed one after another with the same tight spacing.
220
+
221
+ - id: UC9
222
+ name: Two blocks in deliberate tension
223
+ area: ui
224
+ moment: create
225
+ skill: lazuli-ui-composition
226
+ rule: >-
227
+ Give the first view two protagonists of near-equal weight, set so they press on each other (they touch, overlap or face each other across a narrow gap), with everything else clearly smaller.
228
+ why: >-
229
+ Two masses that neither wins keep the eye moving between them, so the view reads as a contest or a dialogue instead of a single statement.
230
+ works_when: >-
231
+ The two blocks carry two halves of one message (a claim and its proof, a product and its price, a before and an after), and together they clearly outweigh the rest of the view.
232
+ excess_when: >-
233
+ A third block of similar weight joins them, so the view has no pair and no lead, or the two blocks say the same thing, so the tension has no meaning.
234
+ origin: hypothesis
235
+ source: >-
236
+ Our claim, grown from the when_to_break of UR3 (a deliberate standoff between two equal halves); the effect is our claim.
237
+ when_to_break: >-
238
+ Let the two blocks collide so hard that one partly hides the other, for a single statement moment such as an opening, declared with break-a-rule first.
239
+ break_effect: >-
240
+ The viewer feels a clash rather than a dialogue, so the view reads as loud and physical, at the cost of reading one of the two in full.
241
+ test: >-
242
+ UR3 reads the pair: the layout report names the two largest blocks of the first view, gives the second as a multiple of the third (the pair leads when it reaches the UR3 cutoff) and says whether their boxes overlap or how far apart they are. The move is declared with record-decision --rule "UC9 followed"; then a UR3 hint where the pair leads reads as the declared move, and one where it does not stays a hint that says the move reads as its excess.
243
+ example: >-
244
+ A giant headline and a giant product photo that overlap at the center of the view, with one small line of text in a corner.
245
+ counterexample: >-
246
+ Four cards of the same size across the first view, with the headline as large as each of them.
@@ -72,12 +72,13 @@
72
72
  Our claim, not verified yet. Weight here is the visible area of a block; the cutoff is a starting value set before any real page was measured; the H4 row says how and lists what was observed afterwards, which is not evidence.
73
73
  measure: layout.focal-point
74
74
  threshold: { minDominance: 2 }
75
+ declared_by: [UC9]
75
76
  when_to_break: >-
76
77
  A deliberate standoff between two equal halves (a split view, a before and after), declared with break-a-rule first.
77
78
  break_effect: >-
78
79
  The viewer feels tension between two claims and has to choose, so the view reads as a comparison.
79
80
  test: >-
80
- The layout report names the largest block of the first view and gives its area as a multiple of the next largest. Hint when the multiple is below the cutoff.
81
+ The layout report names the largest block of the first view and gives its area as a multiple of the next largest. Hint when the multiple is below the cutoff. When the hint comes from two blocks in deliberate tension, declared as move UC9 (record-decision --rule "UC9 followed" or a live break on UC9), the hint becomes declared only where the pair leads the rest at the same cutoff; elsewhere it stays a hint and says the move reads as its excess.
81
82
  example: >-
82
83
  A full-height photo that is twice the area of any other block in the view.
83
84
  counterexample: >-
@@ -38,8 +38,8 @@ The procedures below call these through the CLI (see "Running the CLI"). They ar
38
38
  | `record-review` | Stores a reviewer verdict for a capture after checking it judges every goal of the page. |
39
39
  | `check-goals` | Reports each goal's recorded check (met, partly, missed, stale or not checked) and whether the gate passes. |
40
40
  | `draft-memo` | Gathers decisions, breaks, first looks and verdicts per goal into a draft for explain-decisions, and lists the gaps. |
41
- | `render-options` | Renders 6 to 9 option HTML files, measures each and writes one contact sheet per width, with no ranking. |
42
- | `compare-designs` | Reports the structural distance of a page from a baseline made without the kit, per width, with no verdict (hypothesis H1). |
41
+ | `render-options` | Renders 6 to 9 option HTML files, measures each and writes one contact sheet per width, with no ranking. `--height <px>` sets the viewport height and `--screens <n>` shows the first n screens in each thumbnail, and `--baseline <page>` adds each option's distance from that page to its label. |
42
+ | `compare-designs` | Reports the structural distance of a page from a baseline made without the kit, per width, with no verdict (hypothesis H1). `--options <folder>` places each option file of a folder from near to far against the baseline. |
43
43
  | `map-page` | Maps one step of a simulated task, read only: screenshots and a numbered list of what can be used, stopping at forms and checkout off local targets. |
44
44
  | `record-task` | Stores the tester's answer for the last mapped step of a simulated task and prints the next step, or closes the task with counts. |
45
45
 
@@ -82,6 +82,8 @@ A goal is one entry per piece. The optional `Target:` line names the page it app
82
82
 
83
83
  A derived piece (a social post, an Open Graph image, a favicon set, a presentation cover) is a goal with a `Size:` line: the canvas in pixels, `1200x630`, or square sizes `16, 32, 180, 512`. A goal with a `Size:` or a symbol or image `Target:` is not a screen, so `--site` and the post-edit hook leave it out.
84
84
 
85
+ For the options stage, one goal can cover the folder of option files: a `*` in its `Target:` (`Target: ./.lazuli/options/home/*.html`) matches any file name in that one folder. It is never a screen and never gated, because an option review never counts for the page: the chosen page gets its own goal.
86
+
85
87
  `## Brand` holds the Brand tokens, one bullet each, anywhere in the section. Every color, font and symbol of a derived piece is read from these lines; prose around them is ignored, and a token line that cannot be read is named as a problem:
86
88
 
87
89
  ```
@@ -97,9 +99,10 @@ A color is an optional name and a hex. One Symbol line is the main symbol; a sim
97
99
  1. Read `LAZULI.md`. List the screens or pieces in play.
98
100
  2. For each one, get three short statements: what people must understand, feel and do (write `Do` as a task a person can try on that page, for example `book a first visit`), and the page it lives on if there is one (`Target:`). For a page that scrolls, ask for the rhythm map too: one `Rhythm:` line under the piece, one beat per section from top to bottom, each `breathe`, `steady`, `accelerate` or `climax`, separated by commas, with exactly one `climax` (for example `- Rhythm: breathe, steady, accelerate, climax, breathe`). Ask all questions in one batch.
99
101
  3. Write them under `## Goals`, one entry per piece, in the format above. In delegate mode, propose them from the brief, state the assumptions, and write them.
102
+ 4. When a goal line changes later (`Understand`, `Feel`, `Do`, `Target`, `Rhythm`), log it with `lazuli record-decision --rule none --decision "<Field> changed: was <old>; now <new>. <reason>"`, so `explain-decisions` can say why the goal moved.
100
103
 
101
104
  ## check-design
102
- Run `node "<KIT_PATH>/bin/lazuli.mjs" check-design <url-or-html-path>` (see "Running the CLI"). Options: `--width 1440,390`, `--area color` (a comma list; an unknown name exits 2 and lists the known areas), `--json`, `--out <file>` (also writes the report there; `.lazuli/report.json` is still written). More screens of the same product follow the first target (`check-design ./index.html ./about.html`); `--site` adds the `Target` line of every page goal in `LAZULI.md` (not the pieces and symbols), since those are the screens of one product. Page findings stay for the first target; findings that compare screens are marked "across N screens". With `--site` and fewer than two distinct screens it exits 2. `LAZULI_RULES_DIR` points the CLI at another rules folder; it is a debugging switch, so leave it unset in normal work.
105
+ Run `node "<KIT_PATH>/bin/lazuli.mjs" check-design <url-or-html-path>` (see "Running the CLI"). Options: `--width 1440,390`, `--height <px>` (the viewport height, 100 to 10000, 900 by default; `--height 844` reads a phone's first view; not with `--asset`), `--area color` (a comma list; an unknown name exits 2 and lists the known areas), `--json`, `--out <file>` (also writes the report there; `.lazuli/report.json` is still written). More screens of the same product follow the first target (`check-design ./index.html ./about.html`); `--site` adds the `Target` line of every page goal in `LAZULI.md` (not the pieces and symbols), since those are the screens of one product. Page findings stay for the first target; findings that compare screens are marked "across N screens". With `--site` and fewer than two distinct screens it exits 2. `LAZULI_RULES_DIR` points the CLI at another rules folder; it is a debugging switch, so leave it unset in normal work.
103
106
 
104
107
  `check-design --asset <file-or-url>` checks one symbol or derived piece instead of a page: an SVG, PNG or ICO is a symbol; an HTML file, or a PNG, JPG or WebP with a size, is a piece. A piece takes its sizes from the `Size:` line of its goal or from `--size 1200x630`. Only the areas with a rule the asset measurers read are reported (unless `--area` names others); the report reads `Asset:` and `Sizes:` and lists the `Files written:`, and a finding's width is a size label such as `1200x630`. It takes no page target, `--site` or `--width`; a piece with no size exits 2 naming the line to write. A piece or a symbol is delivered like a page: `capture` it and have it reviewed (review-design) before check-goals counts its goal; `--asset` measures it but is not that review.
105
108
 
@@ -128,7 +131,7 @@ Full procedure: procedures/create.md
128
131
  ## show-options
129
132
  1. Needs an idea in `LAZULI.md`; without one, write it first (create step 2).
130
133
  2. Write 6 to 9 option files from the template of `lazuli-ui-composition`, each a different composition (moves or grid, not colors), naming its moves by UC id.
131
- 3. `render-options <folder> --width 1440`, then open the sheet (the option canvas is one first view, 1440 px wide; 390 px with `--width 390` when `## Audience` names a phone). It measures scale, empty space and focal point and never ranks; name the tension in words.
134
+ 3. `render-options <folder> --width 1440`, then open the sheet (the option canvas is one first view, 1440 px wide; 390 px with `--width 390 --height 844` when `## Audience` names a phone). It measures scale, empty space and focal point and never ranks; name the tension in words.
132
135
  4. Director waits for the choice. Delegate chooses and says why. Log it with `record-decision`, one call per rule id, each with its own decision text (the same text replaces the earlier entry); a pushed move or a broken grid goes through `break-a-rule` first.
133
136
  Full procedure: procedures/show-options.md
134
137
 
@@ -165,7 +168,7 @@ Each rule has `when_to_break` and `break_effect`. To break one:
165
168
  4. Director mode: ask the person before applying. Delegate mode: apply the break only if the check passes.
166
169
  5. Record it with `record-break`, then run the check after applying:
167
170
  `node "<KIT_PATH>/bin/lazuli.mjs" record-break --rule PA2 --piece "checkout page" --effect "the black block makes the payment button feel heavy and final" --check "check-design on ./checkout.html, plus a short test with people from the audience" --status trying`
168
- 6. Entries under `## Breaks` are written and changed only with `record-break`, never by hand. `--rule` takes one id or a comma list (`--rule PA11,RV9`), one entry per id; when a rule shares its measure with others, the command names them, because the same finding is reported under each id. `--status` is `trying`, `kept` or `reverted`; call it again for the same rule and piece to change the status. The entry it writes looks like this:
171
+ 6. Entries under `## Breaks` are written and changed only with `record-break`, never by hand. `--rule` takes one id or a comma list (`--rule PA11,RV9`), one entry per id; when a rule shares its measure with others, the command names them, because the same finding is reported under each id. `--status` is `trying`, `kept` or `reverted`; call it again for the same rule and piece to change the status. `--target <file>` limits the entry to one file the piece covers (one option of a folder goal), written relative to the project folder; a file outside the piece or a glob is refused; `record-decision` takes it too. The entry it writes looks like this:
169
172
  ```
170
173
  - Rule: PA2
171
174
  - Piece: checkout page
@@ -9,6 +9,7 @@ In this file `lazuli <command>` means `node "<KIT_PATH>/bin/lazuli.mjs" <command
9
9
  When a goal's `Target` is a symbol (an SVG, PNG or ICO) or the goal has a `Size`, it is not a screen: run `lazuli check-design --asset <Target>` in place of the three-width check and put its report, with the `Files written:`, in the review. `--asset` measures but is not the review. For a piece with text and a canvas width of 200 px or more, run the page check `lazuli check-design <Target> --width <canvas width> --area color,typography` first and quote its findings in the review: text contrast (RV2) is a WCAG norm, and a norm fail there blocks delivery like any page norm. Run `--asset` last: it keeps that page report beside its own, and the capture puts both in the reviewer packet. For a symbol, also have the blind look at small sizes done by a plain fresh agent given only the path printed as `Blind look sheet:` (see `lazuli-graphic-identity`), and report its answer in words.
10
10
  When the motion area ran (`check-design <target> --area motion`), open the filmstrip path that the motion report prints (`Frames for review: <path>`) and attach that file to the review (the capture does not carry it), so the reviewer judges MR11 from `filmstrip.png` in words.
11
11
  When the content area ran (`check-design <target> --area content`), run the swap test of CR12 as a reviewer: a fresh agent that did not write the copy replaces the product name with a competitor's in the main heading, the first paragraph and the main button, and says in words which lines still hold (see `lazuli-content-voice`); quote its answer in the review. Have the reviewer also judge CW6 in words, heading by heading and label by label: it is the WCAG 2.2 2.4.6 norm (headings and labels describe topic or purpose), no measure reads it, and a declared break never waives it.
12
+ When CR14 names large images shown recolored, ask the reviewer whether each treated image is proof (a customer, a result, the product as received); quote the answer in the review.
12
13
  On a page with sales copy (prices, discounts, a deadline or a stock line, numbers, or health, income or result claims), have the reviewer also walk CR13 as a checklist: one line per claim with where its source is shown on the page, or "no source on the page"; quote the list in the review. In regulated sectors (food supplements, health, finance) a person who knows the local regulation reviews the claims; the kit does not.
13
14
  When the data area ran and the page has charts, open each chart sheet path that the report prints (`Charts for review: <path>`, a `charts-<width>.png` per width) and attach that file to the review (the capture does not carry it), so the reviewer says in words what each simulated view still shows; it goes to the reviewer only, never to the first look.
14
15
  2. **Task test.** When a goal of the page has a `Do` and a `Target`, and `LAZULI.md` has an `## Audience`, run the `lazuli-ux-task-test` skill before the capture, so the reviewer packet lists the recorded task. Take the audience's device width for `--width` from the Audience. With no Audience, ask for it in director mode, or write a one-line assumption in delegate mode (see the skill). If neither is possible, say the task test was not run, and why. A recorded task never satisfies the effect gate by itself: the reviewer's verdict does that.
@@ -7,6 +7,7 @@ In this file `lazuli <command>` means `node "<KIT_PATH>/bin/lazuli.mjs" <command
7
7
  ## Needs
8
8
  - An idea. `## Idea` in `LAZULI.md` must hold one sentence. If it is empty, do step 2 of `procedures/create.md` first: every option serves that sentence, so there is nothing to compare without it.
9
9
  - A goal for the piece with its `Target:` and, for a page that scrolls, its `Rhythm:` line (`set-goals`).
10
+ - For a break on the options, one goal for the folder, `Target: ./.lazuli/options/<piece>/*.html`, not one goal per option file. It is never gated and never a screen. A break that applies to one option names it: `lazuli record-break --piece "<options goal>" --target <option file> ...`. `render-options` applies the breaks to each option through the goals that cover it, and the sheet lists them as breaks.
10
11
 
11
12
  ## Mode
12
13
  Read `## Mode` in `LAZULI.md`.
@@ -16,7 +17,7 @@ Read `## Mode` in `LAZULI.md`.
16
17
  ## Steps
17
18
  1. **Read the moves and the grid.** `lazuli list-rules --moment create --area ui`. The moves are UC ids, the grid rules are UG ids. Read each move's `works_when` and `excess_when`.
18
19
  2. **Write 6 to 9 option files** in `.lazuli/options/<piece>/` (or another folder you name), one HTML file each, starting from `../../lazuli-ui-composition/references/option-template.html` (that path is from this file's folder). Each option is a different composition: different moves or a different grid, not a different palette or font on the same layout. In an HTML comment at the top of each file, name the moves it uses by UC id and the grid it follows by UG id. Fewer than 6 or more than 9 files is refused.
19
- 3. **Render and measure.** `lazuli render-options .lazuli/options/<piece> --width 1440`. The option canvas is one first view, 900 px tall and 1440 px wide by default, so render it at its own width only: a narrower width shows a crop of it, and the sheet says so. When `## Audience` in `LAZULI.md` names a phone as the main device, set `body` to `390px` wide in each option and render with `--width 390` instead. A later run at another width keeps the earlier measures in `options.json` while the option file names stay the same; if you rename, add or remove a file, the earlier widths are dropped and the output says so. It writes one contact sheet, with the measures under each thumbnail. Open the sheet and look at it.
20
+ 3. **Render and measure.** `lazuli render-options .lazuli/options/<piece> --width 1440`. The option canvas is one first view, 900 px tall and 1440 px wide by default, so render it at its own width only: a narrower width shows a crop of it, and the sheet says so. When `## Audience` in `LAZULI.md` names a phone as the main device, set `body` to `390px` wide in each option and render with `--width 390 --height 844` instead (a 390 by 844 phone, the kit's phone width); add `--screens 3` when the brief asks to see proof or offer, so each thumbnail shows the first three screens (the measures still read the first view). A later run at another width keeps the earlier measures in `options.json` while the option file names and the height stay the same; if you rename, add or remove a file, or render at another height, the earlier widths are dropped and the output says so. It writes one contact sheet, with the measures under each thumbnail. With `--baseline <page>` (a page made without the kit for the same brief) each label also gives the option's distance from it, a measurement under hypothesis H1 and not a verdict. `lazuli compare-designs --options <folder> --baseline <page>` lists the options from near to far on the same distance; give it the same `--width` and `--height` as `render-options`, so each option is read at its own canvas (1440 wide by default). Open the sheet and look at it.
20
21
  4. **Read the measures and name the tension.** The sheet prints scale contrast, empty space and focal point for each option. Tension (what pulls against what) is not computed: judge it from the sheet, where the focal offset and the empty cells help, and say it in words for each option. The sheet never ranks options and never picks a best one, and neither do you: the choice is a judgment about the idea. A hint id on a thumbnail is a hint from a hypothesis, not a failure.
21
22
  5. **Choose.** Director mode: show the sheet with the measures and your words on each, then wait. Delegate mode: choose one, and justify it from the idea and the measures in plain language.
22
23
  6. **Log the choice.**
@@ -29,6 +29,7 @@ Do not use when:
29
29
  3. Without subagents, ask the person or a separate session that has not seen the work. If neither is possible, say the swap test was not run.
30
30
  4. Hold the copy against `## Voice` in words: which trait each line shows, which it ignores, which avoided word appears.
31
31
  5. On a page with sales copy, walk CR13 while writing and have the reviewer walk it again: one line per claim (a number, a discount, a scarcity or deadline line, a health, income or result claim) with where its source is shown on the page, or "no source on the page". A discount is checked against the page's own prices, and a countdown or "few left" line must be true for every visitor, never generated. In regulated sectors (food supplements, health, finance) a person who knows the local regulation reviews the claims; the kit does not.
32
+ 6. When CR14 names large images shown recolored (a filter or a blend mode), ask for each whether it is proof: a customer, a result, the product as received. Proof stays close to the original, or the treatment is declared with `break-a-rule` and kept only after `review-design`.
32
33
 
33
34
  ## Closing checklist
34
35
  - Three "this, not that" traits in `## Voice`, chosen by the person in director mode, with a reason in delegate mode.
@@ -27,7 +27,8 @@ Each rule id gets its own decision text, because the same text replaces the earl
27
27
  2. Look at `symbol-sheet.png` yourself. The measures are hints with hypothesis ids, not a verdict.
28
28
  3. The blind look (GR5): start a plain fresh agent that did not draw the symbol (not `lazuli-first-look`, whose prompt is for pages) and give it only the path printed as `Blind look sheet:`. That is `sheet.png`, a copy of the sheet in a `lz-<token>` folder outside the project, each tile labeled with its size only. Give it nothing else: not the Brand or the goals, not the name, not the symbol's file name or its `.lazuli/assets/` path. The host may give every subagent the project's instructions (such as CLAUDE.md), its memory and recent commit messages, which Lazuli does not control; keep the brand, the idea and the goals out of those, or the look is not blind. Ask what it sees at 16 and 32 px and whether those are the same mark as the large one. With no subagent, ask the person, or a session that has not seen the work. Report the answer in the agent's words, never as a measure. It is not recorded as data and the effect gate does not count it.
29
29
  4. A hint judged false is noted with evidence, never silenced. To keep a failing rule on purpose, declare it with `break-a-rule` and keep it only after `review-design`. WCAG A and AA norms are fixed, never broken.
30
- 5. A symbol goal is delivered like a page: `capture` it and run `review-design` (its step runs `check-design --asset` for you); `--asset` measures but is not that review.
30
+ 5. On a page run, GR10 reads the first view against the Brand Color lines: a hint names the nearest color of the view for each Brand color. Bring a Brand color into the first view, or declare the move away from the brand with `break-a-rule`. With no Brand Color line it says nothing, and the report notes it.
31
+ 6. A symbol goal is delivered like a page: `capture` it and run `review-design` (its step runs `check-design --asset` for you); `--asset` measures but is not that review.
31
32
 
32
33
  ## Rule index
33
34
  | Ids | Theme |
@@ -38,6 +39,7 @@ Each rule id gets its own decision text, because the same text replaces the earl
38
39
  | GS1 to GS6 | smallest size first, small version, strokes, flat color, light and dark, no live text |
39
40
  | GR1 to GR4 | measured: silhouette, parts, strokes, edge on light and dark |
40
41
  | GR5 | the blind look at small sizes |
42
+ | GR10 | measured on a page: the first view shows a Brand color |
41
43
 
42
44
  ## What never to say
43
45
  Never say the symbol is recognizable, memorable or distinctive, or that an effect was achieved. The CLI measures pixels and geometry; the blind answer is one agent's reading.
@@ -5,7 +5,7 @@ description: Use when composing a page or landing as one composition instead of
5
5
 
6
6
  # Composing a page as a whole
7
7
 
8
- A page is one composition from the idea, not a column of blocks that were filled in. This skill is for the moment before code. The moves are UC1 to UC8 (`../lazuli/rules/ui/compose.yaml`), the grid rules are UG1 to UG3 (`../lazuli/rules/ui/grid.yaml`) and the numbers behind the checks are hypotheses (`../lazuli/rules/ui/HYPOTHESES.md`), after install (in a kit checkout: `rules/ui/`). Read the rule text there; this file gives the order of work.
8
+ A page is one composition from the idea, not a column of blocks that were filled in. This skill is for the moment before code. The moves are UC1 to UC9 (`../lazuli/rules/ui/compose.yaml`), the grid rules are UG1 to UG3 (`../lazuli/rules/ui/grid.yaml`) and the numbers behind the checks are hypotheses (`../lazuli/rules/ui/HYPOTHESES.md`), after install (in a kit checkout: `rules/ui/`). Read the rule text there; this file gives the order of work.
9
9
 
10
10
  Do not use when:
11
11
  - a page already renders and needs judging: use `lazuli-ui-layout-review`;
@@ -14,14 +14,14 @@ Do not use when:
14
14
  ## Procedure
15
15
  1. Say the idea of the piece in one sentence, from the goal in `LAZULI.md` (`set-goals` first if there is none). Every choice below serves that sentence.
16
16
  2. The grid is chosen in the options step (5), because the options may vary it: modular, asymmetric or broken on purpose (UG1). Do not log it yet. `show-options` logs it once, after the choice, under its own decision text with the UG id it follows, naming the idea and the rejected alternatives. A framework's default container counts only when logged with its reason (UG2).
17
- 3. Pick moves from `compose.yaml` by their `works_when` (UC1 to UC8). Read each move's `excess_when` and stop before it. Take the few the idea needs; a page that uses every move tends to be the same page again.
17
+ 3. Pick moves from `compose.yaml` by their `works_when` (UC1 to UC9). Read each move's `excess_when` and stop before it. Take the few the idea needs; a page that uses every move tends to be the same page again. Two protagonists on purpose is UC9: log it with `record-decision --rule "UC9 followed"`, and the UR3 hint then reads as `declared` where the two largest blocks lead the rest, and stays a hint where they do not.
18
18
  4. Write the rhythm map before building: one `Rhythm:` line in the goal, one beat per section from top to bottom (`breathe`, `steady`, `accelerate`, `climax`), exactly one `climax`. Change it through `set-goals`, never by hand-editing `LAZULI.md`. The check later reads it (UR5, UR6).
19
19
  5. Explore before code with `show-options` (`../lazuli/procedures/show-options.md`): 6 to 9 compositions from `references/option-template.html`, rendered into one contact sheet with `render-options <folder> --width 1440` (the template canvas is one first view, 1440 px wide; `--width 390` with a 390 px body when `## Audience` names a phone). Show them; the person or the delegate choice picks.
20
20
  6. Build the chosen one, then run `check-design <target> --area ui --width 1440,768,390` and hand over to `lazuli-ui-layout-review`.
21
21
 
22
22
  ## Breaking on purpose
23
23
  Choosing a grid or a move follows a rule: log it with `record-decision` as followed. Two cases are breaks and go through `break-a-rule` first:
24
- - a move pushed past its `excess_when` (any of UC1 to UC8);
24
+ - a move pushed past its `excess_when` (any of UC1 to UC9);
25
25
  - an element that leaves the grid on purpose (UG3): name the line or field it breaks and the effect.
26
26
  Declare the break with its effect, build, run `review-design`, and log the decision with `--rule "<id> broken"` only after the break is kept (`record-break --status kept`). A break logged before the review has no check behind it.
27
27
 
@@ -30,7 +30,7 @@ Each thumbnail carries two lines under its file name (three on a crop). The firs
30
30
  - `scale`: the size contrast of the biggest text against the body text (`x text`), and of the biggest block against the typical block (`x area`);
31
31
  - `empty`: the share of the first view left empty; `spread`: how unevenly that empty space is spread across it (low means even, so it reads as leftovers);
32
32
  - `focal`: the strongest block, how many times larger it is than the next, and where its center sits in the first view.
33
- The second line is `no hints`, or names the rules whose check did not pass on that option, like `hints UR2, UR3` (and `fails LR3; hints UR2` when a project rule failed: a failure is never hidden). When the option canvas is wider than the width it was rendered at, a third line says the view is a crop and its bleeds are not meaningful. Look an id up with `list-rules --area ui` to read the rule and its hypothesis id (the cutoff behind the hint lives in `HYPOTHESES.md`). In a `check-design` report the same hint reads `(hypothesis H3, ui)`: the ui area, cutoff hypothesis H3, a starting value not yet tested with people. Say it is a hint, never a failure.
33
+ The second line is `no hints`, or names the rules whose check did not pass on that option, like `hints UR2, UR3` (and `fails LR3; hints UR2` when a project rule failed: a failure is never hidden; `declared UR3` when a declared move explains the hint and the measure shows the move). When the option canvas is wider than the width it was rendered at, a third line says the view is a crop and its bleeds are not meaningful. Look an id up with `list-rules --area ui` to read the rule and its hypothesis id (the cutoff behind the hint lives in `HYPOTHESES.md`). In a `check-design` report the same hint reads `(hypothesis H3, ui)`: the ui area, cutoff hypothesis H3, a starting value not yet tested with people. Say it is a hint, never a failure.
34
34
  The sheet never ranks options and never picks a best one. Tension between options (what pulls against what) is named in words by whoever looks, not computed. The measures describe; the choice is a judgment about the idea.
35
35
 
36
36
  ## Common errors
@@ -5,7 +5,7 @@ description: Use when a rendered page needs its layout judged as a composition (
5
5
 
6
6
  # Reviewing the composition of a rendered page
7
7
 
8
- A page can pass every check and still look like what any tool would make for the same brief. This skill reads the render as a composition: the first view, the sequence down the scroll and the distance from the default. The rules are UR1 to UR8 (`../lazuli/rules/ui/review.yaml`), with UC1 to UC8 and UG1 to UG3 as the choices they review (`compose.yaml`, `grid.yaml` in the same folder), after install (in a kit checkout: `rules/ui/`). Every cutoff is a hypothesis in `HYPOTHESES.md`: the report gives hints, never verdicts.
8
+ A page can pass every check and still look like what any tool would make for the same brief. This skill reads the render as a composition: the first view, the sequence down the scroll and the distance from the default. The rules are UR1 to UR8 (`../lazuli/rules/ui/review.yaml`), with UC1 to UC9 and UG1 to UG3 as the choices they review (`compose.yaml`, `grid.yaml` in the same folder), after install (in a kit checkout: `rules/ui/`). Every cutoff is a hypothesis in `HYPOTHESES.md`: the report gives hints, never verdicts.
9
9
 
10
10
  Do not use when:
11
11
  - no page exists yet: use `lazuli-ui-composition`;
@@ -26,7 +26,7 @@ Do not use when:
26
26
  |---|---|---|
27
27
  | layout.scale-contrast | UR1 | neither the biggest text nor the biggest block stands out in the first view |
28
28
  | layout.empty-space | UR2 | empty space is spread evenly, so it reads as leftovers |
29
- | layout.focal-point | UR3 | no block leads the first view |
29
+ | layout.focal-point | UR3 | no block leads the first view; `declared` when move UC9 is declared and the two largest blocks lead the rest at the same cutoff |
30
30
  | layout.grid | UG2 | every section sits between the same centered edges (judged at 768 px and wider) |
31
31
  | rhythm.pace | UR4 | sections do not change pace |
32
32
  | rhythm.map | UR5 | sections do not follow the declared map, or there is none |
package/src/browser.mjs CHANGED
@@ -113,9 +113,10 @@ export function cdpSession(page) {
113
113
  }
114
114
 
115
115
  // Callers close the returned page's context via page.context().close().
116
+ // opts.height: the viewport height in px, VIEWPORT_HEIGHT when not given.
116
117
  export async function openTarget(browser, target, width, opts = {}) {
117
118
  const context = await browser.newContext({
118
- viewport: { width, height: VIEWPORT_HEIGHT },
119
+ viewport: { width, height: opts.height ?? VIEWPORT_HEIGHT },
119
120
  // The measurers load the screenshot back into the page as a data: image; a strict CSP would block it.
120
121
  bypassCSP: true,
121
122
  ...(opts.still === true ? { reducedMotion: "reduce" } : {}),
@@ -31,7 +31,7 @@ export const HELPERS = [
31
31
  { name: "check-goals", summary: "Reports each goal's recorded check (met, partly, missed, stale or not checked) and whether the gate passes." },
32
32
  { name: "draft-memo", summary: "Gathers decisions, breaks, first looks and verdicts per goal into a draft for explain-decisions, and lists the gaps." },
33
33
  { name: "render-options", summary: "Renders 6 to 9 option HTML files, measures each and writes one contact sheet per width, with no ranking." },
34
- { name: "compare-designs", summary: "Reports the structural distance of a page from a baseline made without the kit, per width, with no verdict (hypothesis H1)." },
34
+ { name: "compare-designs", summary: "Reports the structural distance of a page from a baseline made without the kit, per width, with no verdict (hypothesis H1). `--options <folder>` places each option file of a folder from near to far against the baseline." },
35
35
  { name: "map-page", summary: "Maps one step of a simulated task, read only: screenshots and a numbered list of what can be used, stopping at forms and checkout off local targets." },
36
36
  { name: "record-task", summary: "Stores the tester's answer for the last mapped step of a simulated task and prints the next step, or closes the task with counts." },
37
37
  ];
@@ -1,16 +1,36 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { openBrowser, openTarget, resolveTarget } from "../browser.mjs";
3
+ import { VIEWPORT_HEIGHT, openBrowser, openTarget, resolveTarget } from "../browser.mjs";
4
+ import { FULL_PAGE_CAP_PX } from "./capture.mjs";
4
5
  import { MEASURERS, measurersFor } from "../measure/registry.mjs";
5
6
  import { KIT_RULES_DIR, loadKit } from "../rules/load.mjs";
6
7
  import { evaluate } from "../report/evaluate.mjs";
7
8
  import { noteGuessChanges } from "../report/evaluators/weight.mjs";
8
- import { emptyBrand, isAssetGoal, readLazuliMd } from "../project/lazuli-md.mjs";
9
+ import { emptyBrand, isAssetGoal, isOptionsGoal, readLazuliMd } from "../project/lazuli-md.mjs";
9
10
  import { AssetInputError, assetDir, assetOfType, loadAssetBytes, resolveAsset } from "../measure/asset.mjs";
10
- import { applyBreaks, matchGoals, sameTarget } from "../project/match.mjs";
11
+ import { applyBreaks, applyDeclarations, matchGoals, sameTarget } from "../project/match.mjs";
11
12
  import { gateStatus } from "../project/gate.mjs";
12
13
  import { makeBlindFolder, removeBlindFolder } from "../project/blind.mjs";
13
14
 
15
+ // Technical limits of the viewport height in px, not rules: below 100 px no page lays out as a screen, and
16
+ // above the full-page capture cap (FULL_PAGE_CAP_PX) a first view would be taller than anything the kit captures.
17
+ // capture.mjs imports this file, so the cap is read when called, never while this module loads.
18
+ export const MIN_HEIGHT_PX = 100;
19
+ export const maxHeightPx = () => FULL_PAGE_CAP_PX;
20
+
21
+ export class HeightInputError extends Error {
22
+ constructor() {
23
+ super(`--height needs a whole number of px from ${MIN_HEIGHT_PX} to ${maxHeightPx()}.`);
24
+ this.name = "HeightInputError";
25
+ this.code = "HEIGHT_INPUT";
26
+ }
27
+ }
28
+
29
+ // A height is a whole number from MIN_HEIGHT_PX to maxHeightPx(); anything else is refused, never turned into the default.
30
+ export function checkHeight(height) {
31
+ if (height !== undefined && !(Number.isInteger(height) && height >= MIN_HEIGHT_PX && height <= maxHeightPx())) throw new HeightInputError();
32
+ }
33
+
14
34
  export class UnknownAreaError extends Error {
15
35
  constructor(name, known) {
16
36
  super(`Unknown area ${name}. Known areas: ${known.join(", ")}.`);
@@ -60,14 +80,14 @@ export function areaCoverage(areas, rules, measurers, { failed = new Set(), site
60
80
 
61
81
  // Opens every screen at one width and runs the site measurers on them. A screen that cannot be opened
62
82
  // stops the site measurers at that width with an error naming it. Every context closes in finally.
63
- async function measureSite({ browser, screens, width, cwd, siteMeasurers, rules, goals }) {
64
- const m = { width, errors: {} };
83
+ async function measureSite({ browser, screens, width, height, cwd, siteMeasurers, rules, goals }) {
84
+ const m = { width, height, errors: {} };
65
85
  const pages = [];
66
86
  try {
67
87
  let failure = null;
68
88
  for (const target of screens) {
69
89
  try {
70
- pages.push({ target, page: await openTarget(browser, target, width, { cwd }) });
90
+ pages.push({ target, page: await openTarget(browser, target, width, { cwd, height }) });
71
91
  } catch (err) {
72
92
  failure = `Screen ${target} could not be opened: ${String(err?.message ?? err).split("\n")[0]}`;
73
93
  break;
@@ -246,6 +266,8 @@ export async function checkDesign({
246
266
  screens: more = [],
247
267
  site = false,
248
268
  widths = [1440, 768, 390],
269
+ // The viewport height of every page this run opens, in px.
270
+ height = VIEWPORT_HEIGHT,
249
271
  out = ".lazuli/report.json",
250
272
  // A second file the report is also written to (CLI --out); the report at `out` is always written.
251
273
  copyTo,
@@ -259,6 +281,7 @@ export async function checkDesign({
259
281
  // Review sheets (the chart sheet) are written unless the post-edit hook turned them off (LAZULI_SHEETS=off).
260
282
  sheets = process.env.LAZULI_SHEETS !== "off",
261
283
  }) {
284
+ checkHeight(height);
262
285
  if (asset !== undefined) {
263
286
  return checkAsset({ asset, sizes, target, more, out, copyTo, cwd, givenBrowser, registered, allMeasurers, wanted });
264
287
  }
@@ -282,8 +305,8 @@ export async function checkDesign({
282
305
  const md = await readLazuliMd(cwd);
283
306
  const goals = matchGoals(md, target, cwd);
284
307
  // The distinct screens, in order: the target, the other targets given, then with --site the Target of
285
- // every goal that is a page (a derived piece or a symbol is not a screen). The same page written two ways counts once.
286
- const fromGoals = site ? (md?.goals ?? []).filter((g) => g.target && !isAssetGoal(g)) : [];
308
+ // every goal that is a page (a derived piece, a symbol or a folder of options is not a screen). The same page written two ways counts once.
309
+ const fromGoals = site ? (md?.goals ?? []).filter((g) => g.target && !isAssetGoal(g) && !isOptionsGoal(g)) : [];
287
310
  const candidates = [...more, ...fromGoals.map((g) => g.target)];
288
311
  const screens = [target];
289
312
  for (const s of candidates) if (!screens.some((x) => sameTarget(x, s, cwd))) screens.push(s);
@@ -317,6 +340,7 @@ export async function checkDesign({
317
340
  width,
318
341
  target,
319
342
  goals,
343
+ brand: md?.brand ?? emptyBrand(),
320
344
  once,
321
345
  cwd,
322
346
  sheets,
@@ -324,14 +348,14 @@ export async function checkDesign({
324
348
  // bare and prepare: a raw open with an init script and a route (the motion recorder); noScript and
325
349
  // navigate: a script-free open whose document the caller serves (the extreme case pages).
326
350
  openPage: async (opts = {}) => {
327
- const p = await openTarget(browser, target, opts.width ?? width, { still: opts.still, bare: opts.bare, prepare: opts.prepare, noScript: opts.noScript, navigate: opts.navigate, cwd });
351
+ const p = await openTarget(browser, target, opts.width ?? width, { still: opts.still, bare: opts.bare, prepare: opts.prepare, noScript: opts.noScript, navigate: opts.navigate, cwd, height });
328
352
  opened.push(p.context());
329
353
  return p;
330
354
  },
331
355
  };
332
- const page = await openTarget(browser, target, width, { cwd });
356
+ const page = await openTarget(browser, target, width, { cwd, height });
333
357
  try {
334
- const m = { width, errors: {} };
358
+ const m = { width, height, errors: {} };
335
359
  for (const measurer of pageMeasurers) {
336
360
  try {
337
361
  // ctx.rules: the selected rules whose measure is one of this measurer's ids.
@@ -350,19 +374,19 @@ export async function checkDesign({
350
374
  // Site measurers compare the screens after the page phase, once per width.
351
375
  if (siteMeasurers.length > 0 && screens.length >= 2) {
352
376
  for (const width of widths) {
353
- siteMeasures.push(await measureSite({ browser, screens, width, cwd, siteMeasurers, rules, goals }));
377
+ siteMeasures.push(await measureSite({ browser, screens, width, height, cwd, siteMeasurers, rules, goals }));
354
378
  }
355
379
  }
356
380
  } finally {
357
381
  for (const c of opened) await c.close().catch(() => {});
358
382
  if (!givenBrowser) await browser.close();
359
383
  }
360
- return summarize({ kit, chosen, rules, measurers, registered, measures, siteMeasures, siteMeasurers, screens, siteShort, siteSkipped, md, goals, target, cwd, out, copyTo });
384
+ return summarize({ kit, chosen, rules, measurers, registered, measures, siteMeasures, siteMeasurers, screens, siteShort, siteSkipped, md, goals, target, cwd, out, copyTo, viewportHeight: height });
361
385
  }
362
386
 
363
387
  // Coverage, findings, breaks and recorded effects of a run, written to the report file. kind and asset are set
364
388
  // on an asset run.
365
- async function summarize({ kit, chosen, rules, measurers, registered, measures, siteMeasures, siteMeasurers, screens, siteShort, siteSkipped, md, goals, target, cwd, out, copyTo, kind = null, asset }) {
389
+ async function summarize({ kit, chosen, rules, measurers, registered, measures, siteMeasures, siteMeasurers, screens, siteShort, siteSkipped, md, goals, target, cwd, out, copyTo, kind = null, asset, viewportHeight }) {
366
390
  const failedNames = new Set([...measures, ...siteMeasures].flatMap((m) => Object.keys(m.errors)));
367
391
  const areas = areaCoverage(chosen, rules, measurers, { failed: failedNames, siteSkipped: siteShort, kind, all: registered });
368
392
  // The site measurers that did not run for want of a second screen, named in the report: every one when more
@@ -380,10 +404,19 @@ async function summarize({ kit, chosen, rules, measurers, registered, measures,
380
404
  // Every kit and project rule id counts as known, not only the selected areas, so --area never makes a break look misspelled.
381
405
  // Site findings carry the screens they compare. A guessed main action that differs between widths says so.
382
406
  const siteFindings = evaluate(rules, siteMeasures, siteMeasurers).map((f) => ({ ...f, screens: [...screens] }));
383
- const { findings, applied, unapplied: allUnapplied } = applyBreaks([...noteGuessChanges(evaluate(rules, measures, measurers), measures), ...siteFindings], md?.breaks ?? [], goals, kit.rules, new Set(kit.rules.map((r) => r.id)));
407
+ const broken = applyBreaks([...noteGuessChanges(evaluate(rules, measures, measurers), measures), ...siteFindings], md?.breaks ?? [], goals, kit.rules, new Set(kit.rules.map((r) => r.id)), target, cwd);
408
+ const { applied, unapplied: allUnapplied } = broken;
409
+ // A declared move (UC9 for UR3) changes a hint only where the finding measured the move.
410
+ const { findings, applied: declarations } = applyDeclarations(broken.findings, md, goals, kit.rules, target, cwd);
384
411
  // With --area, a break on a rule of an area that was not selected has no findings here, which is not a fault of the break.
385
412
  const selected = new Set(rules.map((r) => r.id.toLowerCase()));
386
- const unapplied = allUnapplied.filter((u) => !(u.reason.startsWith("no fail or hint") || u.reason === "not measured by check-design") || selected.has(String(u.rule).trim().toLowerCase()));
413
+ // A break on a move that declared a finding did its work, so it is not listed as unapplied.
414
+ const declaredBy = (u) => declarations.some((d) => d.by === "break" && d.move.toLowerCase() === String(u.rule).trim().toLowerCase() && d.piece === u.piece);
415
+ // A break on a move that a finding read here, where the move did not hold, was measured: it says so.
416
+ const readNotHeld = (u) => findings.some((f) => Object.entries(f.moves ?? {}).some(([move, read]) => move.toLowerCase() === String(u.rule).trim().toLowerCase() && read?.holds === false));
417
+ const unapplied = allUnapplied
418
+ .filter((u) => (!(u.reason.startsWith("no fail or hint") || u.reason === "not measured by check-design") || selected.has(String(u.rule).trim().toLowerCase())) && !declaredBy(u))
419
+ .map((u) => (u.reason === "not measured by check-design" && readNotHeld(u) ? { ...u, reason: "the move was read and did not hold on this page" } : u));
387
420
  // A records file that cannot be read never stops the measuring: the goals just show no recorded check.
388
421
  let effects = [];
389
422
  const problems = [...(md?.problems ?? [])];
@@ -397,6 +430,7 @@ async function summarize({ kit, chosen, rules, measurers, registered, measures,
397
430
  const result = {
398
431
  target,
399
432
  ...(asset ? { asset } : {}),
433
+ ...(viewportHeight ? { viewportHeight } : {}),
400
434
  screens,
401
435
  areas,
402
436
  findings,
@@ -411,6 +445,7 @@ async function summarize({ kit, chosen, rules, measurers, registered, measures,
411
445
  effects,
412
446
  unmatchedGoals: (md?.goals.length ?? 0) - goals.length,
413
447
  breaks: applied,
448
+ declarations,
414
449
  unappliedBreaks: unapplied,
415
450
  problems,
416
451
  projectProblems: kit.projectProblems,
@@ -1,6 +1,8 @@
1
1
  import fs from "node:fs/promises";
2
+ import { existsSync, statSync } from "node:fs";
2
3
  import path from "node:path";
3
4
  import { openBrowser, openTarget, resolveTarget } from "../browser.mjs";
5
+ import { checkHeight } from "./check-design.mjs";
4
6
  import { measureLayout } from "../measure/layout.mjs";
5
7
  import { measureRhythm } from "../measure/rhythm.mjs";
6
8
  import { distance, signatureOf } from "../measure/signature.mjs";
@@ -23,8 +25,8 @@ export class CompareInputError extends Error {
23
25
 
24
26
  const round = (n) => Math.round(n * 100) / 100;
25
27
 
26
- async function signatureAt(browser, target, width, cwd) {
27
- const page = await openTarget(browser, target, width, { cwd });
28
+ export async function signatureAt(browser, target, width, cwd, height) {
29
+ const page = await openTarget(browser, target, width, { cwd, ...(height === undefined ? {} : { height }) });
28
30
  try {
29
31
  const layout = await measureLayout(page);
30
32
  const rhythm = await measureRhythm(page, {});
@@ -95,3 +97,64 @@ export function formatCompare(r) {
95
97
  lines.push(`Measures: ${r.path}`);
96
98
  return lines.join("\n");
97
99
  }
100
+
101
+ // The name a baseline goes by in a label: its file name, or the URL as given.
102
+ export const baselineName = (baseline) => (/^https?:\/\//i.test(baseline.trim()) ? baseline.trim() : path.basename(baseline.trim()));
103
+
104
+ // A folder of options placed from near to far against one baseline, per width (1440 by default, like render-options: an option is one canvas).
105
+ // Give it the same widths and height render-options used, so each option is read at its own canvas.
106
+ // The baseline is read once per width; ties keep file order. Like compareDesigns, it measures and gives no verdict (H1).
107
+ export async function compareOptions({ folder: given, baseline, widths = [1440], height, cwd = process.cwd(), out = path.join(".lazuli", "compare.json"), browser: givenBrowser }) {
108
+ if (typeof baseline !== "string" || baseline.trim() === "") {
109
+ throw new CompareInputError("compare-designs needs a baseline: a page made without the kit for the same brief.");
110
+ }
111
+ checkHeight(height);
112
+ const folder = path.resolve(cwd, given);
113
+ if (!existsSync(folder) || !statSync(folder).isDirectory()) throw new CompareInputError(`Options folder not found: ${folder}`);
114
+ resolveTarget(baseline, cwd);
115
+ const entries = await fs.readdir(folder, { withFileTypes: true });
116
+ const files = entries
117
+ .filter((e) => e.isFile() && /\.html$/i.test(e.name))
118
+ .map((e) => e.name)
119
+ .sort()
120
+ .filter((name) => !sameTarget(path.join(folder, name), baseline, cwd));
121
+ if (files.length === 0) throw new CompareInputError(`No .html option file in ${folder}.`);
122
+
123
+ const options = files.map((file) => ({ file, value: 0, widths: [] }));
124
+ const browser = givenBrowser ?? (await openBrowser());
125
+ try {
126
+ for (const width of widths) {
127
+ const b = await signatureAt(browser, baseline, width, cwd, height);
128
+ for (const option of options) {
129
+ const a = await signatureAt(browser, path.join(folder, option.file), width, cwd, height);
130
+ const d = distance(a, b);
131
+ option.widths.push({ width, value: d.value, components: d.components });
132
+ }
133
+ }
134
+ } finally {
135
+ if (!givenBrowser) await browser.close();
136
+ }
137
+ for (const option of options) option.value = round(option.widths.reduce((s, w) => s + w.value, 0) / option.widths.length);
138
+ const order = options
139
+ .map((o, i) => ({ o, i }))
140
+ .sort((x, y) => x.o.value - y.o.value || x.i - y.i)
141
+ .map(({ o }) => o.file);
142
+
143
+ const file = path.resolve(cwd, out);
144
+ const result = { baseline, options, order, widths, ...(height === undefined ? {} : { height }), path: file, note: COMPARE_NOTE };
145
+ await fs.mkdir(path.dirname(file), { recursive: true });
146
+ await fs.writeFile(file, JSON.stringify(result, null, 2));
147
+ return result;
148
+ }
149
+
150
+ // Each option in file order with its value, then the near-to-far line, the H1 caveat and the measures path.
151
+ export function formatCompareOptions(r) {
152
+ const value = (file) => r.options.find((o) => o.file === file).value;
153
+ const lines = [`Baseline: ${r.baseline}`];
154
+ for (const o of r.options) lines.push(`${o.file}: ${o.value}`);
155
+ lines.push(`Near to far: ${r.order.map((f) => `${f} ${value(f)}`).join(", ")}`);
156
+ lines.push(`Distance from the baseline: 0 is the same structure, 1 shares nothing. ${H1_LINE}`);
157
+ lines.push(r.note ?? COMPARE_NOTE);
158
+ lines.push(`Measures: ${r.path}`);
159
+ return lines.join("\n");
160
+ }
@@ -1,6 +1,6 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { readLazuliMd } from "../project/lazuli-md.mjs";
3
+ import { isOptionsGoal, readLazuliMd } from "../project/lazuli-md.mjs";
4
4
  import { gateStatus } from "../project/gate.mjs";
5
5
  import { matchGoals, sameTarget } from "../project/match.mjs";
6
6
  import { readRecords } from "../project/records.mjs";
@@ -118,7 +118,8 @@ export async function draftMemo({ cwd = process.cwd(), target } = {}) {
118
118
  check += `, review ${checked.verdict} by ${checked.reviewer ?? "unknown reviewer"} on ${checked.reviewedAt.slice(0, 10)}`;
119
119
  }
120
120
  out.push(check);
121
- if (goal.target) {
121
+ // An options goal is a glob, not a page with records of its own.
122
+ if (goal.target && !isOptionsGoal(goal)) {
122
123
  const look = await firstLookOf(root, goal.target);
123
124
  out.push(...look.lines);
124
125
  if (look.gap) {
@@ -150,7 +151,7 @@ export async function draftMemo({ cwd = process.cwd(), target } = {}) {
150
151
  gaps.push(`${goal.piece}: no decision is logged.`);
151
152
  }
152
153
  }
153
- if (checked && checked.status !== "met") {
154
+ if (checked && checked.status !== "met" && checked.status !== "options") {
154
155
  gaps.push(`${goal.piece}: the effect is ${checked.status}, not met.`);
155
156
  }
156
157
  }