bigpowers 2.4.1 → 2.5.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.
- package/.pi/package.json +2 -2
- package/.pi/prompts/align-grid.md +102 -0
- package/.pi/skills/align-grid/SKILL.md +104 -0
- package/CHANGELOG.md +7 -0
- package/align-grid/SKILL.md +108 -0
- package/align-grid/scripts/grid_tokens.py +201 -0
- package/align-grid/scripts/verify_grid.js +140 -0
- package/package.json +1 -1
- package/countable-story-format.md +0 -293
package/.pi/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bigpowers",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "62 skills — 61 agent skills for spec-driven, test-first software development by solo developers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
7
7
|
],
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Build editorial/magazine/report webpages on a GENUINE Müller-Brockmann modular grid (International Typographic Style) — not a decorative one. Encodes the discipline (columns + modules + baseline, grotesque type, flush-left, restrained black/white/red palette) AND the hard-won front-end engineering to make the grid real, visible, and verified: one CSS-variable source of truth, an interactive grid-toggle overlay that lives in the SAME content box as the content, subgrid \"bands\" so every element snaps to a column line, an 8px baseline lock, and runtime OPTICAL ALIGNMENT that puts display type's ink (not its box) on the line. Ships with a scaffold generator and a Puppeteer verification harness that proves 0px adherence."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Müller-Brockmann Grid Systems — built real, visible, and verified
|
|
7
|
+
|
|
8
|
+
Josef Müller-Brockmann (1914–1996), Zurich; *Grid Systems in Graphic Design* (1981) is the corpus. The grid is treated as an ethic, not decoration: **"The grid system is an aid, not a guarantee. It permits a number of possible uses and each designer can look for a solution appropriate to his personal style. But one must learn how to use the grid; it is an art that requires practice."** This skill encodes that discipline AND — the part most attempts get wrong — the front-end engineering to make the grid genuinely load-bearing on the web, plus a harness that PROVES it.
|
|
9
|
+
|
|
10
|
+
> Two real review notes this skill exists to prevent:
|
|
11
|
+
> 1. *"the grid is just slapped on top and misaligned"* → the overlay wasn't in the same content box as the content (see §2.2).
|
|
12
|
+
> 2. *"the H in the headline is off the grid"* → the headline's BOX was on the grid but its INK wasn't; large glyphs carry a side-bearing (see §2.6). **Box-on-grid ≠ ink-on-grid.**
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## PART 1 — THE DISCIPLINE (decide before drawing)
|
|
16
|
+
- **Objective order.** The grid brings "constructive thought," legibility, and "objective and functional" design. Restraint is the point; the system, not the ego, organizes the page.
|
|
17
|
+
- **Modular grid.** Divide the type area into a field of **modules** — columns AND rows — separated by consistent **gutters**, inside defined **margins**. Text and images occupy whole modules. Müller-Brockmann specimens common field counts (8 / 20 / 32 fields). For the web, a **12-column grid + 8px baseline** is a robust general default; a **6×6 or 4×8 modular field grid** when you want visible rows too.
|
|
18
|
+
- **Baseline grid.** Vertical rhythm is sacred: **leading = a whole multiple of the baseline unit**, and every element snaps to it. This is what makes facing columns and images line up across the page.
|
|
19
|
+
- **Typography.** A **grotesque sans** (Akzidenz-Grotesk / Helvetica; on the web Inter, Helvetica Now, Archivo). **Flush-left, ragged-right.** Few sizes, large jumps in **scale** for hierarchy; objective, not expressive. Big **numerals/data set large** is a signature move.
|
|
20
|
+
- **Palette.** Pure white paper, near-black ink, **one accent — red is canonical**. Avoid the warm-cream "Claude look"; **never blue/purple gradients** (hard house rule).
|
|
21
|
+
- **White space + asymmetry.** Generous margins; asymmetric compositions held in tension by the grid.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## PART 2 — MAKE THE GRID REAL ON THE WEB (the load-bearing engineering)
|
|
25
|
+
`grid_tokens.py` emits this whole scaffold correctly; the rules below are why it's built the way it is.
|
|
26
|
+
|
|
27
|
+
### 2.1 One source of truth
|
|
28
|
+
Put every grid parameter in `:root` CSS variables — `--cols, --gutter, --margin, --bl (baseline), --lh (leading=3×bl), --maxw`. **Content and the overlay both read these same variables.** Never hand-author the overlay separately or it will drift.
|
|
29
|
+
|
|
30
|
+
### 2.2 The overlay MUST live in the SAME content box as the content ← #1 bug
|
|
31
|
+
Failure mode: content sits in a centered `max-width` container while the overlay is a **full-width sibling** of the section. On any viewport wider than `--maxw`, the centered content and the full-width overlay no longer share column positions → "slapped on top / misaligned."
|
|
32
|
+
**Fix:** put `.guides` *inside* the same `.wrap`, and draw the column guides with `left/right = var(--margin)` and the **same** `repeat(var(--cols),1fr)` + `column-gap:var(--gutter)`. Then the overlay columns **are** the content columns at every width. Add left/right margin lines at `var(--margin)`.
|
|
33
|
+
|
|
34
|
+
### 2.3 Place every element by column LINE via subgrid bands
|
|
35
|
+
Don't eyeball spans. Each horizontal **band** spans all columns and re-exposes them:
|
|
36
|
+
```css
|
|
37
|
+
.band{grid-column:1 / -1; display:grid; grid-template-columns:subgrid; column-gap:var(--gutter); align-items:start;}
|
|
38
|
+
@supports not (grid-template-columns:subgrid){ .band{grid-template-columns:repeat(var(--cols),1fr);} }
|
|
39
|
+
```
|
|
40
|
+
Children place with `grid-column: <startline> / <endline>` (e.g. `1 / 6`, `6 / 13`). Every headline, paragraph, photo, caption now snaps to identical lines.
|
|
41
|
+
|
|
42
|
+
### 2.4 Lock vertical rhythm to the baseline
|
|
43
|
+
- Leading = `--lh` (e.g. 24px = 3×8). **Every line-height a multiple of the baseline, in px (not unitless) for display type** — unitless line-heights on large type push the box off the grid.
|
|
44
|
+
- Every margin/padding a multiple of the baseline. Spread top/bottom padding a multiple too, so content starts on a line.
|
|
45
|
+
- **Media heights = multiples of the leading** (e.g. 240/360/432/480px) so a photo's top AND bottom both land on lines.
|
|
46
|
+
- Hairline rules sit inside a baseline-height band, not free-floating.
|
|
47
|
+
|
|
48
|
+
### 2.5 The toggle (sizzle within the sizzle)
|
|
49
|
+
A control (button **+ `G` key**) toggles `body.grid-on`; overlay fades 0→1. Overlay draws: translucent **numbered column fields**, the **baseline** (major line every `--lh`, faint minor every `--bl`), and **margin lines**. Showing the real grid the page is built on IS the demo.
|
|
50
|
+
|
|
51
|
+
### 2.6 OPTICAL ALIGNMENT — display ink, not its box ← the subtle bug
|
|
52
|
+
A 180px headline whose layout box is exactly on line 1 still looks misaligned against body text, because the letterform's **ink** is inset by its **left side-bearing**. Cure at runtime:
|
|
53
|
+
```js
|
|
54
|
+
// after document.fonts.ready and on resize:
|
|
55
|
+
var cvs=document.createElement('canvas'),ctx=cvs.getContext('2d');
|
|
56
|
+
document.querySelectorAll('.masthead,.numeral,.shead h2,.h2b').forEach(function(el){
|
|
57
|
+
el.style.marginLeft='0px';
|
|
58
|
+
var cs=getComputedStyle(el),ch=(el.textContent||'').trim()[0]; if(!ch) return;
|
|
59
|
+
if(cs.textTransform==='uppercase') ch=ch.toUpperCase();
|
|
60
|
+
ctx.font=cs.fontStyle+' '+cs.fontWeight+' '+cs.fontSize+' '+cs.fontFamily; ctx.textAlign='left';
|
|
61
|
+
var abl=ctx.measureText(ch).actualBoundingBoxLeft; // +ve = ink overhangs left of box
|
|
62
|
+
if(isFinite(abl)) el.style.marginLeft=abl.toFixed(2)+'px'; // shift box so INK lands on the line
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
Apply to the masthead, big numerals, and section headlines. It scales with fluid type (re-runs on resize) and uses the **actually-loaded** font, so it's correct in the user's browser.
|
|
66
|
+
**CRITICAL measurement caveat:** side-bearing is **font-specific**. If you measure with the wrong font you get the wrong nudge. Headless/sandbox Chrome usually lacks the webfont, so canvas falls back to a different grotesque (measured **−16px on the fallback vs −7px on real Inter** for the same `H`). To verify optics offline you must **embed the real webfont** via `@font-face` (local TTF). In production the runtime JS measures the loaded font and is correct.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## PART 3 — VERIFY (don't trust, measure) → `verify_grid.js`
|
|
70
|
+
Render with headless Chrome (Puppeteer) and assert, at **several widths including > and < `--maxw`** (to catch centered-container drift, e.g. 1440 / 1180 / 900):
|
|
71
|
+
1. **Column adherence** — every placed `.band > *` left snaps to a column START and right to a column END (~0px). **Exclude the optically-aligned display elements** from this box check (their box is intentionally side-bearing-offset; they're validated in step 4). **Gotcha:** build BOTH the column-start set and the column-end set — a grid item spanning "to line N" ends at the *far* side of the gutter, so single-edge math falsely reports a one-gutter error.
|
|
72
|
+
2. **Overlay match** — each `.guides .col` rect equals the computed column rect (~0px).
|
|
73
|
+
3. **Baseline** — text tops modulo the baseline ≈ 0 (tolerance ≈ half a baseline; the box-top is a proxy — the leading does the real work).
|
|
74
|
+
4. **Optical ink** — each display element's ink-left (box − `actualBoundingBoxLeft`, real font) equals **its own** column line (nearest column-start to its box), not always line 1.
|
|
75
|
+
|
|
76
|
+
Sandbox Chrome flags that work: `--headless=new --no-sandbox --disable-gpu --disable-dbus --use-gl=angle --use-angle=swiftshader`. `file://` works for non-ES-module pages; the CLI `--screenshot` can hang on tall pages — drive via Puppeteer and screenshot per viewport. Read PNGs back with the image-capable Read tool to eyeball a **zoom crop of the top-left corner** (masthead vs body vs column line) — the fastest human check.
|
|
77
|
+
|
|
78
|
+
A clean run looks like: `col=0px overlay=0px baseline≤4px ink=0px` → `GRID VERIFY: PASS`.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## PART 4 — CRAFT DEFAULTS (so it looks excellent, not just aligned)
|
|
82
|
+
- **Palette:** white `#fff`, ink `#111`, one accent (Swiss red `#e4002b`). No warm-cream Claude look; no blue/purple gradients.
|
|
83
|
+
- **Type:** a real grotesque webfont (Inter / Helvetica Now / Archivo) for display + body; a **mono** (Space Mono / IBM Plex Mono) for folios, captions, grid annotations — reinforces the technical register. Non-Latin via Noto Sans JP etc.
|
|
84
|
+
- **Hierarchy** through scale + weight + white space, not color. Treat key data as **large numerals**. Kicker labels in mono caps. Per-spread folios.
|
|
85
|
+
- **Real photography.** Ground real subjects in real photos (`SearchImages`). **Host each image via `PublishFilePublicly` and embed the `pub.hyperagent.com` URL** — a `PublishWebpage` artifact runs in a sandboxed iframe that can't authenticate thread-scoped `/api/files/...` URLs (broken-image trap).
|
|
86
|
+
- **Type fidelity if you ever rasterize art** (cairosvg / headless screenshots / image-gen reference): a `Helvetica`/`Arial` CSS stack silently falls back to **Noto Sans** (reads like Calibri). Render in **Liberation Sans** or an embedded Helvetica/Arimo TTF before trusting it. (Same trap as the optical-measurement caveat: wrong font in → wrong result out.)
|
|
87
|
+
- **Spread model:** full-width sections, each its own per-spread `.grid` + `.guides`, consistent margins/folios.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## PART 5 — WORKFLOW
|
|
91
|
+
1. Pick the subject; gather real photos; host them publicly.
|
|
92
|
+
2. Generate the scaffold: `python3 grid_tokens.py` (or `--scaffold` for a full page; `--cols/--baseline/--gutter/--margin/--maxw/--accent` to taste; it warns if gutter/margin aren't baseline multiples).
|
|
93
|
+
3. Build spreads as **subgrid bands**; place everything by **column line**; lock spacing/line-heights/media heights to the **baseline**.
|
|
94
|
+
4. Add the overlay (same content box) + toggle + optical-alignment JS (already in the scaffold; point its selector list at your display elements).
|
|
95
|
+
5. Publish, then **verify**: `CHROME=… PUP=… node verify_grid.js <file-or-url> --widths=1440,1180,900`. Eyeball a top-left zoom crop. Fix, republish.
|
|
96
|
+
|
|
97
|
+
## SCRIPTS
|
|
98
|
+
- **`grid_tokens.py`** — deterministic scaffold generator. Emits the `:root` tokens, `.grid`/`.band` (subgrid) scaffold, `.guides` overlay CSS, toggle JS, and the optical-alignment JS — all wired to one source of truth. `--scaffold` emits a full minimal HTML page. No network/credentials.
|
|
99
|
+
- **`verify_grid.js`** — Puppeteer harness implementing all four checks above with the corrected both-edges column math, the optical-exclusion, per-element column-line ink targeting, and PASS/FAIL output at multiple widths. Env: `CHROME` (chrome binary), `PUP` (puppeteer-core module path).
|
|
100
|
+
|
|
101
|
+
## CREED
|
|
102
|
+
A grid you can't toggle on and measure is a mood board, not a system. Build it from one source of truth, prove it at 0px, and align the **ink**.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: align-grid
|
|
3
|
+
description: "\"Build editorial/magazine/report webpages on a GENUINE Müller-Brockmann modular grid (International Typographic Style) — not a decorative one. Encodes the discipline (columns + modules + baseline, grotesque type, flush-left, restrained black/white/red palette) AND the hard-won front-end engineering to make the grid real, visible, and verified: one CSS-variable source of truth, an interactive grid-toggle overlay that lives in the SAME content box as the content, subgrid \\\"bands\\\" so every element snaps to a column line, an 8px baseline lock, and runtime OPTICAL ALIGNMENT that puts display type's ink (not its box) on the line. Ships with a scaffold generator and a Puppeteer verification harness that proves 0px adherence.\""
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Müller-Brockmann Grid Systems — built real, visible, and verified
|
|
9
|
+
|
|
10
|
+
Josef Müller-Brockmann (1914–1996), Zurich; *Grid Systems in Graphic Design* (1981) is the corpus. The grid is treated as an ethic, not decoration: **"The grid system is an aid, not a guarantee. It permits a number of possible uses and each designer can look for a solution appropriate to his personal style. But one must learn how to use the grid; it is an art that requires practice."** This skill encodes that discipline AND — the part most attempts get wrong — the front-end engineering to make the grid genuinely load-bearing on the web, plus a harness that PROVES it.
|
|
11
|
+
|
|
12
|
+
> Two real review notes this skill exists to prevent:
|
|
13
|
+
> 1. *"the grid is just slapped on top and misaligned"* → the overlay wasn't in the same content box as the content (see §2.2).
|
|
14
|
+
> 2. *"the H in the headline is off the grid"* → the headline's BOX was on the grid but its INK wasn't; large glyphs carry a side-bearing (see §2.6). **Box-on-grid ≠ ink-on-grid.**
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## PART 1 — THE DISCIPLINE (decide before drawing)
|
|
18
|
+
- **Objective order.** The grid brings "constructive thought," legibility, and "objective and functional" design. Restraint is the point; the system, not the ego, organizes the page.
|
|
19
|
+
- **Modular grid.** Divide the type area into a field of **modules** — columns AND rows — separated by consistent **gutters**, inside defined **margins**. Text and images occupy whole modules. Müller-Brockmann specimens common field counts (8 / 20 / 32 fields). For the web, a **12-column grid + 8px baseline** is a robust general default; a **6×6 or 4×8 modular field grid** when you want visible rows too.
|
|
20
|
+
- **Baseline grid.** Vertical rhythm is sacred: **leading = a whole multiple of the baseline unit**, and every element snaps to it. This is what makes facing columns and images line up across the page.
|
|
21
|
+
- **Typography.** A **grotesque sans** (Akzidenz-Grotesk / Helvetica; on the web Inter, Helvetica Now, Archivo). **Flush-left, ragged-right.** Few sizes, large jumps in **scale** for hierarchy; objective, not expressive. Big **numerals/data set large** is a signature move.
|
|
22
|
+
- **Palette.** Pure white paper, near-black ink, **one accent — red is canonical**. Avoid the warm-cream "Claude look"; **never blue/purple gradients** (hard house rule).
|
|
23
|
+
- **White space + asymmetry.** Generous margins; asymmetric compositions held in tension by the grid.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## PART 2 — MAKE THE GRID REAL ON THE WEB (the load-bearing engineering)
|
|
27
|
+
`grid_tokens.py` emits this whole scaffold correctly; the rules below are why it's built the way it is.
|
|
28
|
+
|
|
29
|
+
### 2.1 One source of truth
|
|
30
|
+
Put every grid parameter in `:root` CSS variables — `--cols, --gutter, --margin, --bl (baseline), --lh (leading=3×bl), --maxw`. **Content and the overlay both read these same variables.** Never hand-author the overlay separately or it will drift.
|
|
31
|
+
|
|
32
|
+
### 2.2 The overlay MUST live in the SAME content box as the content ← #1 bug
|
|
33
|
+
Failure mode: content sits in a centered `max-width` container while the overlay is a **full-width sibling** of the section. On any viewport wider than `--maxw`, the centered content and the full-width overlay no longer share column positions → "slapped on top / misaligned."
|
|
34
|
+
**Fix:** put `.guides` *inside* the same `.wrap`, and draw the column guides with `left/right = var(--margin)` and the **same** `repeat(var(--cols),1fr)` + `column-gap:var(--gutter)`. Then the overlay columns **are** the content columns at every width. Add left/right margin lines at `var(--margin)`.
|
|
35
|
+
|
|
36
|
+
### 2.3 Place every element by column LINE via subgrid bands
|
|
37
|
+
Don't eyeball spans. Each horizontal **band** spans all columns and re-exposes them:
|
|
38
|
+
```css
|
|
39
|
+
.band{grid-column:1 / -1; display:grid; grid-template-columns:subgrid; column-gap:var(--gutter); align-items:start;}
|
|
40
|
+
@supports not (grid-template-columns:subgrid){ .band{grid-template-columns:repeat(var(--cols),1fr);} }
|
|
41
|
+
```
|
|
42
|
+
Children place with `grid-column: <startline> / <endline>` (e.g. `1 / 6`, `6 / 13`). Every headline, paragraph, photo, caption now snaps to identical lines.
|
|
43
|
+
|
|
44
|
+
### 2.4 Lock vertical rhythm to the baseline
|
|
45
|
+
- Leading = `--lh` (e.g. 24px = 3×8). **Every line-height a multiple of the baseline, in px (not unitless) for display type** — unitless line-heights on large type push the box off the grid.
|
|
46
|
+
- Every margin/padding a multiple of the baseline. Spread top/bottom padding a multiple too, so content starts on a line.
|
|
47
|
+
- **Media heights = multiples of the leading** (e.g. 240/360/432/480px) so a photo's top AND bottom both land on lines.
|
|
48
|
+
- Hairline rules sit inside a baseline-height band, not free-floating.
|
|
49
|
+
|
|
50
|
+
### 2.5 The toggle (sizzle within the sizzle)
|
|
51
|
+
A control (button **+ `G` key**) toggles `body.grid-on`; overlay fades 0→1. Overlay draws: translucent **numbered column fields**, the **baseline** (major line every `--lh`, faint minor every `--bl`), and **margin lines**. Showing the real grid the page is built on IS the demo.
|
|
52
|
+
|
|
53
|
+
### 2.6 OPTICAL ALIGNMENT — display ink, not its box ← the subtle bug
|
|
54
|
+
A 180px headline whose layout box is exactly on line 1 still looks misaligned against body text, because the letterform's **ink** is inset by its **left side-bearing**. Cure at runtime:
|
|
55
|
+
```js
|
|
56
|
+
// after document.fonts.ready and on resize:
|
|
57
|
+
var cvs=document.createElement('canvas'),ctx=cvs.getContext('2d');
|
|
58
|
+
document.querySelectorAll('.masthead,.numeral,.shead h2,.h2b').forEach(function(el){
|
|
59
|
+
el.style.marginLeft='0px';
|
|
60
|
+
var cs=getComputedStyle(el),ch=(el.textContent||'').trim()[0]; if(!ch) return;
|
|
61
|
+
if(cs.textTransform==='uppercase') ch=ch.toUpperCase();
|
|
62
|
+
ctx.font=cs.fontStyle+' '+cs.fontWeight+' '+cs.fontSize+' '+cs.fontFamily; ctx.textAlign='left';
|
|
63
|
+
var abl=ctx.measureText(ch).actualBoundingBoxLeft; // +ve = ink overhangs left of box
|
|
64
|
+
if(isFinite(abl)) el.style.marginLeft=abl.toFixed(2)+'px'; // shift box so INK lands on the line
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
Apply to the masthead, big numerals, and section headlines. It scales with fluid type (re-runs on resize) and uses the **actually-loaded** font, so it's correct in the user's browser.
|
|
68
|
+
**CRITICAL measurement caveat:** side-bearing is **font-specific**. If you measure with the wrong font you get the wrong nudge. Headless/sandbox Chrome usually lacks the webfont, so canvas falls back to a different grotesque (measured **−16px on the fallback vs −7px on real Inter** for the same `H`). To verify optics offline you must **embed the real webfont** via `@font-face` (local TTF). In production the runtime JS measures the loaded font and is correct.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## PART 3 — VERIFY (don't trust, measure) → `verify_grid.js`
|
|
72
|
+
Render with headless Chrome (Puppeteer) and assert, at **several widths including > and < `--maxw`** (to catch centered-container drift, e.g. 1440 / 1180 / 900):
|
|
73
|
+
1. **Column adherence** — every placed `.band > *` left snaps to a column START and right to a column END (~0px). **Exclude the optically-aligned display elements** from this box check (their box is intentionally side-bearing-offset; they're validated in step 4). **Gotcha:** build BOTH the column-start set and the column-end set — a grid item spanning "to line N" ends at the *far* side of the gutter, so single-edge math falsely reports a one-gutter error.
|
|
74
|
+
2. **Overlay match** — each `.guides .col` rect equals the computed column rect (~0px).
|
|
75
|
+
3. **Baseline** — text tops modulo the baseline ≈ 0 (tolerance ≈ half a baseline; the box-top is a proxy — the leading does the real work).
|
|
76
|
+
4. **Optical ink** — each display element's ink-left (box − `actualBoundingBoxLeft`, real font) equals **its own** column line (nearest column-start to its box), not always line 1.
|
|
77
|
+
|
|
78
|
+
Sandbox Chrome flags that work: `--headless=new --no-sandbox --disable-gpu --disable-dbus --use-gl=angle --use-angle=swiftshader`. `file://` works for non-ES-module pages; the CLI `--screenshot` can hang on tall pages — drive via Puppeteer and screenshot per viewport. Read PNGs back with the image-capable Read tool to eyeball a **zoom crop of the top-left corner** (masthead vs body vs column line) — the fastest human check.
|
|
79
|
+
|
|
80
|
+
A clean run looks like: `col=0px overlay=0px baseline≤4px ink=0px` → `GRID VERIFY: PASS`.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## PART 4 — CRAFT DEFAULTS (so it looks excellent, not just aligned)
|
|
84
|
+
- **Palette:** white `#fff`, ink `#111`, one accent (Swiss red `#e4002b`). No warm-cream Claude look; no blue/purple gradients.
|
|
85
|
+
- **Type:** a real grotesque webfont (Inter / Helvetica Now / Archivo) for display + body; a **mono** (Space Mono / IBM Plex Mono) for folios, captions, grid annotations — reinforces the technical register. Non-Latin via Noto Sans JP etc.
|
|
86
|
+
- **Hierarchy** through scale + weight + white space, not color. Treat key data as **large numerals**. Kicker labels in mono caps. Per-spread folios.
|
|
87
|
+
- **Real photography.** Ground real subjects in real photos (`SearchImages`). **Host each image via `PublishFilePublicly` and embed the `pub.hyperagent.com` URL** — a `PublishWebpage` artifact runs in a sandboxed iframe that can't authenticate thread-scoped `/api/files/...` URLs (broken-image trap).
|
|
88
|
+
- **Type fidelity if you ever rasterize art** (cairosvg / headless screenshots / image-gen reference): a `Helvetica`/`Arial` CSS stack silently falls back to **Noto Sans** (reads like Calibri). Render in **Liberation Sans** or an embedded Helvetica/Arimo TTF before trusting it. (Same trap as the optical-measurement caveat: wrong font in → wrong result out.)
|
|
89
|
+
- **Spread model:** full-width sections, each its own per-spread `.grid` + `.guides`, consistent margins/folios.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## PART 5 — WORKFLOW
|
|
93
|
+
1. Pick the subject; gather real photos; host them publicly.
|
|
94
|
+
2. Generate the scaffold: `python3 grid_tokens.py` (or `--scaffold` for a full page; `--cols/--baseline/--gutter/--margin/--maxw/--accent` to taste; it warns if gutter/margin aren't baseline multiples).
|
|
95
|
+
3. Build spreads as **subgrid bands**; place everything by **column line**; lock spacing/line-heights/media heights to the **baseline**.
|
|
96
|
+
4. Add the overlay (same content box) + toggle + optical-alignment JS (already in the scaffold; point its selector list at your display elements).
|
|
97
|
+
5. Publish, then **verify**: `CHROME=… PUP=… node verify_grid.js <file-or-url> --widths=1440,1180,900`. Eyeball a top-left zoom crop. Fix, republish.
|
|
98
|
+
|
|
99
|
+
## SCRIPTS
|
|
100
|
+
- **`grid_tokens.py`** — deterministic scaffold generator. Emits the `:root` tokens, `.grid`/`.band` (subgrid) scaffold, `.guides` overlay CSS, toggle JS, and the optical-alignment JS — all wired to one source of truth. `--scaffold` emits a full minimal HTML page. No network/credentials.
|
|
101
|
+
- **`verify_grid.js`** — Puppeteer harness implementing all four checks above with the corrected both-edges column math, the optical-exclusion, per-element column-line ink targeting, and PASS/FAIL output at multiple widths. Env: `CHROME` (chrome binary), `PUP` (puppeteer-core module path).
|
|
102
|
+
|
|
103
|
+
## CREED
|
|
104
|
+
A grid you can't toggle on and measure is a mood board, not a system. Build it from one source of truth, prove it at 0px, and align the **ink**.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [2.5.0](https://github.com/danielvm-git/bigpowers/compare/v2.4.1...v2.5.0) (2026-06-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add align-grid skill and orchestration reference docs ([359c823](https://github.com/danielvm-git/bigpowers/commit/359c82381d0d124ef849ca15bd1d3ee91d218766))
|
|
7
|
+
|
|
1
8
|
## [2.4.1](https://github.com/danielvm-git/bigpowers/compare/v2.4.0...v2.4.1) (2026-06-18)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: align-grid
|
|
3
|
+
description: "Build editorial/magazine/report webpages on a GENUINE Müller-Brockmann modular grid (International Typographic Style) — not a decorative one. Encodes the discipline (columns + modules + baseline, grotesque type, flush-left, restrained black/white/red palette) AND the hard-won front-end engineering to make the grid real, visible, and verified: one CSS-variable source of truth, an interactive grid-toggle overlay that lives in the SAME content box as the content, subgrid \"bands\" so every element snaps to a column line, an 8px baseline lock, and runtime OPTICAL ALIGNMENT that puts display type's ink (not its box) on the line. Ships with a scaffold generator and a Puppeteer verification harness that proves 0px adherence."
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Müller-Brockmann Grid Systems — built real, visible, and verified
|
|
8
|
+
|
|
9
|
+
Josef Müller-Brockmann (1914–1996), Zurich; *Grid Systems in Graphic Design* (1981) is the corpus. The grid is treated as an ethic, not decoration: **"The grid system is an aid, not a guarantee. It permits a number of possible uses and each designer can look for a solution appropriate to his personal style. But one must learn how to use the grid; it is an art that requires practice."** This skill encodes that discipline AND — the part most attempts get wrong — the front-end engineering to make the grid genuinely load-bearing on the web, plus a harness that PROVES it.
|
|
10
|
+
|
|
11
|
+
> Two real review notes this skill exists to prevent:
|
|
12
|
+
> 1. *"the grid is just slapped on top and misaligned"* → the overlay wasn't in the same content box as the content (see §2.2).
|
|
13
|
+
> 2. *"the H in the headline is off the grid"* → the headline's BOX was on the grid but its INK wasn't; large glyphs carry a side-bearing (see §2.6). **Box-on-grid ≠ ink-on-grid.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## PART 1 — THE DISCIPLINE (decide before drawing)
|
|
18
|
+
- **Objective order.** The grid brings "constructive thought," legibility, and "objective and functional" design. Restraint is the point; the system, not the ego, organizes the page.
|
|
19
|
+
- **Modular grid.** Divide the type area into a field of **modules** — columns AND rows — separated by consistent **gutters**, inside defined **margins**. Text and images occupy whole modules. Müller-Brockmann specimens common field counts (8 / 20 / 32 fields). For the web, a **12-column grid + 8px baseline** is a robust general default; a **6×6 or 4×8 modular field grid** when you want visible rows too.
|
|
20
|
+
- **Baseline grid.** Vertical rhythm is sacred: **leading = a whole multiple of the baseline unit**, and every element snaps to it. This is what makes facing columns and images line up across the page.
|
|
21
|
+
- **Typography.** A **grotesque sans** (Akzidenz-Grotesk / Helvetica; on the web Inter, Helvetica Now, Archivo). **Flush-left, ragged-right.** Few sizes, large jumps in **scale** for hierarchy; objective, not expressive. Big **numerals/data set large** is a signature move.
|
|
22
|
+
- **Palette.** Pure white paper, near-black ink, **one accent — red is canonical**. Avoid the warm-cream "Claude look"; **never blue/purple gradients** (hard house rule).
|
|
23
|
+
- **White space + asymmetry.** Generous margins; asymmetric compositions held in tension by the grid.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## PART 2 — MAKE THE GRID REAL ON THE WEB (the load-bearing engineering)
|
|
28
|
+
`grid_tokens.py` emits this whole scaffold correctly; the rules below are why it's built the way it is.
|
|
29
|
+
|
|
30
|
+
### 2.1 One source of truth
|
|
31
|
+
Put every grid parameter in `:root` CSS variables — `--cols, --gutter, --margin, --bl (baseline), --lh (leading=3×bl), --maxw`. **Content and the overlay both read these same variables.** Never hand-author the overlay separately or it will drift.
|
|
32
|
+
|
|
33
|
+
### 2.2 The overlay MUST live in the SAME content box as the content ← #1 bug
|
|
34
|
+
Failure mode: content sits in a centered `max-width` container while the overlay is a **full-width sibling** of the section. On any viewport wider than `--maxw`, the centered content and the full-width overlay no longer share column positions → "slapped on top / misaligned."
|
|
35
|
+
**Fix:** put `.guides` *inside* the same `.wrap`, and draw the column guides with `left/right = var(--margin)` and the **same** `repeat(var(--cols),1fr)` + `column-gap:var(--gutter)`. Then the overlay columns **are** the content columns at every width. Add left/right margin lines at `var(--margin)`.
|
|
36
|
+
|
|
37
|
+
### 2.3 Place every element by column LINE via subgrid bands
|
|
38
|
+
Don't eyeball spans. Each horizontal **band** spans all columns and re-exposes them:
|
|
39
|
+
```css
|
|
40
|
+
.band{grid-column:1 / -1; display:grid; grid-template-columns:subgrid; column-gap:var(--gutter); align-items:start;}
|
|
41
|
+
@supports not (grid-template-columns:subgrid){ .band{grid-template-columns:repeat(var(--cols),1fr);} }
|
|
42
|
+
```
|
|
43
|
+
Children place with `grid-column: <startline> / <endline>` (e.g. `1 / 6`, `6 / 13`). Every headline, paragraph, photo, caption now snaps to identical lines.
|
|
44
|
+
|
|
45
|
+
### 2.4 Lock vertical rhythm to the baseline
|
|
46
|
+
- Leading = `--lh` (e.g. 24px = 3×8). **Every line-height a multiple of the baseline, in px (not unitless) for display type** — unitless line-heights on large type push the box off the grid.
|
|
47
|
+
- Every margin/padding a multiple of the baseline. Spread top/bottom padding a multiple too, so content starts on a line.
|
|
48
|
+
- **Media heights = multiples of the leading** (e.g. 240/360/432/480px) so a photo's top AND bottom both land on lines.
|
|
49
|
+
- Hairline rules sit inside a baseline-height band, not free-floating.
|
|
50
|
+
|
|
51
|
+
### 2.5 The toggle (sizzle within the sizzle)
|
|
52
|
+
A control (button **+ `G` key**) toggles `body.grid-on`; overlay fades 0→1. Overlay draws: translucent **numbered column fields**, the **baseline** (major line every `--lh`, faint minor every `--bl`), and **margin lines**. Showing the real grid the page is built on IS the demo.
|
|
53
|
+
|
|
54
|
+
### 2.6 OPTICAL ALIGNMENT — display ink, not its box ← the subtle bug
|
|
55
|
+
A 180px headline whose layout box is exactly on line 1 still looks misaligned against body text, because the letterform's **ink** is inset by its **left side-bearing**. Cure at runtime:
|
|
56
|
+
```js
|
|
57
|
+
// after document.fonts.ready and on resize:
|
|
58
|
+
var cvs=document.createElement('canvas'),ctx=cvs.getContext('2d');
|
|
59
|
+
document.querySelectorAll('.masthead,.numeral,.shead h2,.h2b').forEach(function(el){
|
|
60
|
+
el.style.marginLeft='0px';
|
|
61
|
+
var cs=getComputedStyle(el),ch=(el.textContent||'').trim()[0]; if(!ch) return;
|
|
62
|
+
if(cs.textTransform==='uppercase') ch=ch.toUpperCase();
|
|
63
|
+
ctx.font=cs.fontStyle+' '+cs.fontWeight+' '+cs.fontSize+' '+cs.fontFamily; ctx.textAlign='left';
|
|
64
|
+
var abl=ctx.measureText(ch).actualBoundingBoxLeft; // +ve = ink overhangs left of box
|
|
65
|
+
if(isFinite(abl)) el.style.marginLeft=abl.toFixed(2)+'px'; // shift box so INK lands on the line
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
Apply to the masthead, big numerals, and section headlines. It scales with fluid type (re-runs on resize) and uses the **actually-loaded** font, so it's correct in the user's browser.
|
|
69
|
+
**CRITICAL measurement caveat:** side-bearing is **font-specific**. If you measure with the wrong font you get the wrong nudge. Headless/sandbox Chrome usually lacks the webfont, so canvas falls back to a different grotesque (measured **−16px on the fallback vs −7px on real Inter** for the same `H`). To verify optics offline you must **embed the real webfont** via `@font-face` (local TTF). In production the runtime JS measures the loaded font and is correct.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## PART 3 — VERIFY (don't trust, measure) → `verify_grid.js`
|
|
74
|
+
Render with headless Chrome (Puppeteer) and assert, at **several widths including > and < `--maxw`** (to catch centered-container drift, e.g. 1440 / 1180 / 900):
|
|
75
|
+
1. **Column adherence** — every placed `.band > *` left snaps to a column START and right to a column END (~0px). **Exclude the optically-aligned display elements** from this box check (their box is intentionally side-bearing-offset; they're validated in step 4). **Gotcha:** build BOTH the column-start set and the column-end set — a grid item spanning "to line N" ends at the *far* side of the gutter, so single-edge math falsely reports a one-gutter error.
|
|
76
|
+
2. **Overlay match** — each `.guides .col` rect equals the computed column rect (~0px).
|
|
77
|
+
3. **Baseline** — text tops modulo the baseline ≈ 0 (tolerance ≈ half a baseline; the box-top is a proxy — the leading does the real work).
|
|
78
|
+
4. **Optical ink** — each display element's ink-left (box − `actualBoundingBoxLeft`, real font) equals **its own** column line (nearest column-start to its box), not always line 1.
|
|
79
|
+
|
|
80
|
+
Sandbox Chrome flags that work: `--headless=new --no-sandbox --disable-gpu --disable-dbus --use-gl=angle --use-angle=swiftshader`. `file://` works for non-ES-module pages; the CLI `--screenshot` can hang on tall pages — drive via Puppeteer and screenshot per viewport. Read PNGs back with the image-capable Read tool to eyeball a **zoom crop of the top-left corner** (masthead vs body vs column line) — the fastest human check.
|
|
81
|
+
|
|
82
|
+
A clean run looks like: `col=0px overlay=0px baseline≤4px ink=0px` → `GRID VERIFY: PASS`.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## PART 4 — CRAFT DEFAULTS (so it looks excellent, not just aligned)
|
|
87
|
+
- **Palette:** white `#fff`, ink `#111`, one accent (Swiss red `#e4002b`). No warm-cream Claude look; no blue/purple gradients.
|
|
88
|
+
- **Type:** a real grotesque webfont (Inter / Helvetica Now / Archivo) for display + body; a **mono** (Space Mono / IBM Plex Mono) for folios, captions, grid annotations — reinforces the technical register. Non-Latin via Noto Sans JP etc.
|
|
89
|
+
- **Hierarchy** through scale + weight + white space, not color. Treat key data as **large numerals**. Kicker labels in mono caps. Per-spread folios.
|
|
90
|
+
- **Real photography.** Ground real subjects in real photos (`SearchImages`). **Host each image via `PublishFilePublicly` and embed the `pub.hyperagent.com` URL** — a `PublishWebpage` artifact runs in a sandboxed iframe that can't authenticate thread-scoped `/api/files/...` URLs (broken-image trap).
|
|
91
|
+
- **Type fidelity if you ever rasterize art** (cairosvg / headless screenshots / image-gen reference): a `Helvetica`/`Arial` CSS stack silently falls back to **Noto Sans** (reads like Calibri). Render in **Liberation Sans** or an embedded Helvetica/Arimo TTF before trusting it. (Same trap as the optical-measurement caveat: wrong font in → wrong result out.)
|
|
92
|
+
- **Spread model:** full-width sections, each its own per-spread `.grid` + `.guides`, consistent margins/folios.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## PART 5 — WORKFLOW
|
|
97
|
+
1. Pick the subject; gather real photos; host them publicly.
|
|
98
|
+
2. Generate the scaffold: `python3 grid_tokens.py` (or `--scaffold` for a full page; `--cols/--baseline/--gutter/--margin/--maxw/--accent` to taste; it warns if gutter/margin aren't baseline multiples).
|
|
99
|
+
3. Build spreads as **subgrid bands**; place everything by **column line**; lock spacing/line-heights/media heights to the **baseline**.
|
|
100
|
+
4. Add the overlay (same content box) + toggle + optical-alignment JS (already in the scaffold; point its selector list at your display elements).
|
|
101
|
+
5. Publish, then **verify**: `CHROME=… PUP=… node verify_grid.js <file-or-url> --widths=1440,1180,900`. Eyeball a top-left zoom crop. Fix, republish.
|
|
102
|
+
|
|
103
|
+
## SCRIPTS
|
|
104
|
+
- **`grid_tokens.py`** — deterministic scaffold generator. Emits the `:root` tokens, `.grid`/`.band` (subgrid) scaffold, `.guides` overlay CSS, toggle JS, and the optical-alignment JS — all wired to one source of truth. `--scaffold` emits a full minimal HTML page. No network/credentials.
|
|
105
|
+
- **`verify_grid.js`** — Puppeteer harness implementing all four checks above with the corrected both-edges column math, the optical-exclusion, per-element column-line ink targeting, and PASS/FAIL output at multiple widths. Env: `CHROME` (chrome binary), `PUP` (puppeteer-core module path).
|
|
106
|
+
|
|
107
|
+
## CREED
|
|
108
|
+
A grid you can't toggle on and measure is a mood board, not a system. Build it from one source of truth, prove it at 0px, and align the **ink**.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
grid_tokens.py — Müller-Brockmann editorial grid scaffold generator.
|
|
4
|
+
|
|
5
|
+
Emits a battle-tested, self-contained CSS + JS scaffold for building an
|
|
6
|
+
editorial/magazine webpage on a REAL, VISIBLE, VERIFIED modular grid:
|
|
7
|
+
|
|
8
|
+
• ONE source of truth: all grid params live in :root CSS variables.
|
|
9
|
+
• The grid-toggle OVERLAY reads the SAME variables and lives in the SAME
|
|
10
|
+
content box as the content, so its columns ARE the content columns
|
|
11
|
+
(this is the fix for the "grid is just slapped on top / misaligned" bug
|
|
12
|
+
that happens when the overlay is a full-width sibling of a centered
|
|
13
|
+
max-width container).
|
|
14
|
+
• Subgrid "bands" so every element is placed by column LINE, not eyeballed.
|
|
15
|
+
• Vertical rhythm locked to an 8px baseline (24px leading).
|
|
16
|
+
• Runtime OPTICAL ALIGNMENT: display type is nudged so its INK (not its box)
|
|
17
|
+
lands on the column line — large letterforms carry a left side-bearing, so
|
|
18
|
+
a headline whose box is on the grid still looks misaligned vs body text.
|
|
19
|
+
|
|
20
|
+
No network, no credentials. Deterministic.
|
|
21
|
+
|
|
22
|
+
Usage:
|
|
23
|
+
python3 grid_tokens.py # print CSS + JS block
|
|
24
|
+
python3 grid_tokens.py --scaffold # print a full minimal HTML page
|
|
25
|
+
python3 grid_tokens.py --cols 12 --baseline 8 --gutter 24 --margin 72 \
|
|
26
|
+
--maxw 1296 --accent "#e4002b"
|
|
27
|
+
"""
|
|
28
|
+
import argparse, sys
|
|
29
|
+
|
|
30
|
+
def build(cfg):
|
|
31
|
+
c = cfg
|
|
32
|
+
lh = c.baseline * 3 # leading = 3 baselines
|
|
33
|
+
css = f""":root{{
|
|
34
|
+
--cols:{c.cols};
|
|
35
|
+
--bl:{c.baseline}px; /* baseline unit */
|
|
36
|
+
--lh:{lh}px; /* leading = 3 x baseline */
|
|
37
|
+
--gutter:{c.gutter}px;
|
|
38
|
+
--margin:{c.margin}px;
|
|
39
|
+
--pad:{c.baseline*12}px; /* spread top/bottom pad (x baseline) */
|
|
40
|
+
--maxw:{c.maxw}px;
|
|
41
|
+
|
|
42
|
+
--paper:#ffffff;
|
|
43
|
+
--ink:#111315;
|
|
44
|
+
--ink-soft:#5b6066;
|
|
45
|
+
--accent:{c.accent};
|
|
46
|
+
|
|
47
|
+
--g-col:rgba(228,0,43,.075); /* column field fill (re-tint to taste) */
|
|
48
|
+
--g-edge:rgba(228,0,43,.40); /* column edge / margin line */
|
|
49
|
+
--g-base:rgba(0,150,140,.34); /* major baseline line ({lh}px) */
|
|
50
|
+
--g-base-min:rgba(0,150,140,.12);/* minor baseline line ({c.baseline}px) */
|
|
51
|
+
}}
|
|
52
|
+
*{{box-sizing:border-box;}}
|
|
53
|
+
body{{margin:0;background:var(--paper);color:var(--ink);
|
|
54
|
+
font-family:"Inter",system-ui,sans-serif;font-size:16px;line-height:var(--lh);
|
|
55
|
+
-webkit-font-smoothing:antialiased;}}
|
|
56
|
+
img{{display:block;width:100%;height:100%;object-fit:cover;}}
|
|
57
|
+
|
|
58
|
+
/* ---- spread + grid scaffold (ONE source of truth) ---- */
|
|
59
|
+
.spread{{position:relative;width:100%;}}
|
|
60
|
+
.wrap{{position:relative;max-width:var(--maxw);margin:0 auto;padding:var(--pad) var(--margin);}}
|
|
61
|
+
.grid{{display:grid;grid-template-columns:repeat(var(--cols),1fr);
|
|
62
|
+
column-gap:var(--gutter);row-gap:var(--lh);}}
|
|
63
|
+
/* a band spans all columns and re-exposes them as a subgrid so children
|
|
64
|
+
align to the SAME lines as everything else on the page */
|
|
65
|
+
.band{{grid-column:1 / -1;display:grid;grid-template-columns:subgrid;
|
|
66
|
+
column-gap:var(--gutter);row-gap:var(--lh);align-items:start;}}
|
|
67
|
+
@supports not (grid-template-columns:subgrid){{
|
|
68
|
+
.band{{grid-template-columns:repeat(var(--cols),1fr);}}
|
|
69
|
+
}}
|
|
70
|
+
/* place children with: style="grid-column: <startline> / <endline>" */
|
|
71
|
+
|
|
72
|
+
/* ---- the grid OVERLAY (same content box -> columns match exactly) ---- */
|
|
73
|
+
.guides{{position:absolute;inset:0;pointer-events:none;z-index:60;opacity:0;
|
|
74
|
+
transition:opacity .26s ease;}}
|
|
75
|
+
body.grid-on .guides{{opacity:1;}}
|
|
76
|
+
.guides .cols{{position:absolute;top:0;bottom:0;left:var(--margin);right:var(--margin);
|
|
77
|
+
display:grid;grid-template-columns:repeat(var(--cols),1fr);column-gap:var(--gutter);}}
|
|
78
|
+
.guides .col{{background:var(--g-col);
|
|
79
|
+
box-shadow:inset 1px 0 0 var(--g-edge),inset -1px 0 0 var(--g-edge);position:relative;}}
|
|
80
|
+
.guides .col span{{position:absolute;top:{c.baseline*4}px;left:0;right:0;text-align:center;
|
|
81
|
+
font-family:"Space Mono",monospace;font-size:10px;line-height:1;color:var(--accent);}}
|
|
82
|
+
.guides .rows{{position:absolute;left:var(--margin);right:var(--margin);top:var(--pad);bottom:0;
|
|
83
|
+
background-image:
|
|
84
|
+
repeating-linear-gradient(to bottom,var(--g-base) 0 1px,transparent 1px var(--lh)),
|
|
85
|
+
repeating-linear-gradient(to bottom,var(--g-base-min) 0 1px,transparent 1px var(--bl));}}
|
|
86
|
+
.guides .mline{{position:absolute;top:0;bottom:0;width:1px;background:var(--g-edge);}}
|
|
87
|
+
.guides .mline.l{{left:var(--margin);}} .guides .mline.r{{right:var(--margin);}}
|
|
88
|
+
|
|
89
|
+
/* ---- vertical rhythm helpers (keep ALL spacing a multiple of --bl) ----
|
|
90
|
+
line-heights for display type MUST be px multiples of --bl, never unitless,
|
|
91
|
+
or the box height drifts off the baseline. Media heights = multiples of --lh
|
|
92
|
+
so photo top AND bottom land on lines. */
|
|
93
|
+
.toggle{{position:fixed;top:18px;right:18px;z-index:200;display:flex;align-items:center;gap:10px;
|
|
94
|
+
background:var(--ink);color:#fff;border:none;cursor:pointer;font-family:"Space Mono",monospace;
|
|
95
|
+
font-size:12px;letter-spacing:.14em;text-transform:uppercase;padding:11px 14px;}}
|
|
96
|
+
.toggle .dot{{width:9px;height:9px;border-radius:50%;background:#555;}}
|
|
97
|
+
body.grid-on .toggle{{background:var(--accent);}} body.grid-on .toggle .dot{{background:#fff;}}"""
|
|
98
|
+
|
|
99
|
+
js = """/* toggle: button + 'G' key */
|
|
100
|
+
var btn=document.getElementById('gridToggle');
|
|
101
|
+
function setGrid(on){document.body.classList.toggle('grid-on',on);
|
|
102
|
+
if(btn){btn.setAttribute('aria-pressed',on?'true':'false');
|
|
103
|
+
var l=btn.querySelector('.lbl'); if(l) l.textContent=on?'Hide grid':'Show grid';}}
|
|
104
|
+
if(btn) btn.addEventListener('click',function(){setGrid(!document.body.classList.contains('grid-on'));});
|
|
105
|
+
document.addEventListener('keydown',function(e){
|
|
106
|
+
if((e.key==='g'||e.key==='G')&&!e.metaKey&&!e.ctrlKey&&!e.altKey){
|
|
107
|
+
setGrid(!document.body.classList.contains('grid-on'));}});
|
|
108
|
+
|
|
109
|
+
/* populate every overlay's column guides (numbered) */
|
|
110
|
+
document.querySelectorAll('.guides .cols').forEach(function(h){
|
|
111
|
+
var n=getComputedStyle(document.documentElement).getPropertyValue('--cols').trim()||'12';
|
|
112
|
+
for(var i=1;i<=parseInt(n,10);i++){var c=document.createElement('div');c.className='col';
|
|
113
|
+
var s=document.createElement('span');s.textContent=i;c.appendChild(s);h.appendChild(c);}});
|
|
114
|
+
|
|
115
|
+
/* ---- OPTICAL ALIGNMENT --------------------------------------------------
|
|
116
|
+
Large display glyphs carry a left side-bearing: the ink sits inside the
|
|
117
|
+
layout box, so a headline whose BOX is on the column line still LOOKS
|
|
118
|
+
indented (or overhangs) vs body text. Measure each display glyph's actual
|
|
119
|
+
ink offset and nudge the element so its visible ink lands on the line.
|
|
120
|
+
Scales with fluid type; re-runs after the webfont loads and on resize.
|
|
121
|
+
Add the selector list to match your display elements. */
|
|
122
|
+
(function(){
|
|
123
|
+
var cvs=document.createElement('canvas'),ctx=cvs.getContext('2d');
|
|
124
|
+
var sel='.masthead, .numeral, .shead h2, .h2b'; /* <-- your display selectors */
|
|
125
|
+
function align(){
|
|
126
|
+
document.querySelectorAll(sel).forEach(function(el){
|
|
127
|
+
el.style.marginLeft='0px';
|
|
128
|
+
var cs=getComputedStyle(el),ch=(el.textContent||'').trim().charAt(0); if(!ch) return;
|
|
129
|
+
if(cs.textTransform==='uppercase') ch=ch.toUpperCase();
|
|
130
|
+
ctx.font=cs.fontStyle+' '+cs.fontWeight+' '+cs.fontSize+' '+cs.fontFamily;
|
|
131
|
+
ctx.textAlign='left';
|
|
132
|
+
var abl=ctx.measureText(ch).actualBoundingBoxLeft; /* +ve = ink overhangs left */
|
|
133
|
+
if(isFinite(abl)) el.style.marginLeft=abl.toFixed(2)+'px'; /* ink -> on the line */
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if(document.fonts&&document.fonts.ready){document.fonts.ready.then(align);}
|
|
137
|
+
align();
|
|
138
|
+
var t;window.addEventListener('resize',function(){clearTimeout(t);t=setTimeout(align,120);});
|
|
139
|
+
})();"""
|
|
140
|
+
|
|
141
|
+
band = """ <!-- a band: children placed by column LINE -->
|
|
142
|
+
<div class="band">
|
|
143
|
+
<div style="grid-column:1 / 6;"><!-- text col --></div>
|
|
144
|
+
<figure style="grid-column:6 / 13;"><!-- image col (height = x --lh) --></figure>
|
|
145
|
+
</div>"""
|
|
146
|
+
|
|
147
|
+
overlay = """ <div class="guides" aria-hidden="true">
|
|
148
|
+
<div class="cols"></div><div class="rows"></div>
|
|
149
|
+
<div class="mline l"></div><div class="mline r"></div>
|
|
150
|
+
</div>"""
|
|
151
|
+
|
|
152
|
+
if cfg.scaffold:
|
|
153
|
+
return f"""<!DOCTYPE html>
|
|
154
|
+
<html lang="en"><head><meta charset="UTF-8">
|
|
155
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
156
|
+
<title>Editorial — modular grid</title>
|
|
157
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
158
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
|
|
159
|
+
<style>
|
|
160
|
+
{css}
|
|
161
|
+
</style></head>
|
|
162
|
+
<body>
|
|
163
|
+
<button class="toggle" id="gridToggle" aria-pressed="false"><span class="dot"></span><span class="lbl">Show grid</span></button>
|
|
164
|
+
|
|
165
|
+
<section class="spread">
|
|
166
|
+
<div class="wrap">
|
|
167
|
+
<div class="grid">
|
|
168
|
+
{band}
|
|
169
|
+
</div>
|
|
170
|
+
{overlay}
|
|
171
|
+
</div>
|
|
172
|
+
</section>
|
|
173
|
+
|
|
174
|
+
<script>
|
|
175
|
+
{js}
|
|
176
|
+
</script>
|
|
177
|
+
</body></html>"""
|
|
178
|
+
else:
|
|
179
|
+
return ("/* ===== CSS (paste in <style>) ===== */\n" + css +
|
|
180
|
+
"\n\n/* ===== JS (paste in <script>, after the DOM) ===== */\n" + js +
|
|
181
|
+
"\n\n/* ===== band markup pattern ===== */\n" + band +
|
|
182
|
+
"\n\n/* ===== per-spread overlay markup ===== */\n" + overlay + "\n")
|
|
183
|
+
|
|
184
|
+
def main():
|
|
185
|
+
ap = argparse.ArgumentParser(description="Müller-Brockmann editorial grid scaffold generator")
|
|
186
|
+
ap.add_argument("--cols", type=int, default=12)
|
|
187
|
+
ap.add_argument("--baseline", type=int, default=8, help="baseline unit in px (leading = 3x)")
|
|
188
|
+
ap.add_argument("--gutter", type=int, default=24)
|
|
189
|
+
ap.add_argument("--margin", type=int, default=72)
|
|
190
|
+
ap.add_argument("--maxw", type=int, default=1296)
|
|
191
|
+
ap.add_argument("--accent", default="#e4002b")
|
|
192
|
+
ap.add_argument("--scaffold", action="store_true", help="emit a full minimal HTML page")
|
|
193
|
+
cfg = ap.parse_args()
|
|
194
|
+
for name, v in (("gutter", cfg.gutter), ("margin", cfg.margin)):
|
|
195
|
+
if v % cfg.baseline != 0:
|
|
196
|
+
print(f"# WARNING: --{name} ({v}) is not a multiple of --baseline ({cfg.baseline}); "
|
|
197
|
+
f"vertical/spacing rhythm will drift off the grid.", file=sys.stderr)
|
|
198
|
+
sys.stdout.write(build(cfg) + "\n")
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
main()
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* verify_grid.js — prove an editorial page actually sits on its grid.
|
|
4
|
+
*
|
|
5
|
+
* Renders the page with headless Chrome (Puppeteer) and asserts, at several
|
|
6
|
+
* viewport widths (including > and < the content max-width, to catch the
|
|
7
|
+
* centered-container drift):
|
|
8
|
+
*
|
|
9
|
+
* 1. COLUMN ADHERENCE — every placed `.band > *` element's left edge snaps
|
|
10
|
+
* to a column START line and its right edge to a column END line (~0px).
|
|
11
|
+
* NB: build BOTH the start-set and end-set of x-coords. A grid item that
|
|
12
|
+
* spans "to line N" ends at the FAR side of the gutter, so naive single
|
|
13
|
+
* edge math falsely reports a one-gutter (gutter-px) error.
|
|
14
|
+
* 2. OVERLAY MATCH — each `.guides .col` rect equals the computed column
|
|
15
|
+
* rect (~0px), i.e. the overlay really is the content grid.
|
|
16
|
+
* 3. BASELINE — text element tops, modulo the baseline unit, ~0.
|
|
17
|
+
* 4. OPTICAL INK — display elements' visible INK-left equals the column
|
|
18
|
+
* line (measure canvas actualBoundingBoxLeft with the LOADED font).
|
|
19
|
+
* CAVEAT: side-bearing is font-specific. In a sandbox the webfont is often
|
|
20
|
+
* absent and canvas falls back to a different grotesque (we measured -16px
|
|
21
|
+
* fallback vs -7px real Inter). To verify optics offline, EMBED the real
|
|
22
|
+
* webfont via @font-face(local TTF). In production the page's runtime JS
|
|
23
|
+
* measures the actually-loaded font, so it is correct for the user.
|
|
24
|
+
*
|
|
25
|
+
* Env / args:
|
|
26
|
+
* CHROME = path to chrome binary (required)
|
|
27
|
+
* PUP = path to puppeteer-core module (required)
|
|
28
|
+
* arg1 = file:// URL or http URL of the page (default: file://$PWD/index.html)
|
|
29
|
+
* --widths=1440,1180,900 --baseline=8
|
|
30
|
+
*
|
|
31
|
+
* Sandbox chrome flags that work here:
|
|
32
|
+
* --no-sandbox --disable-gpu --disable-dbus --use-gl=angle --use-angle=swiftshader
|
|
33
|
+
* (file:// works for non-ES-module pages; CLI --screenshot can hang on tall
|
|
34
|
+
* pages, so we drive via Puppeteer and screenshot per-viewport.)
|
|
35
|
+
*/
|
|
36
|
+
const puppeteer = require(process.env.PUP || 'puppeteer-core');
|
|
37
|
+
const path = require('path');
|
|
38
|
+
|
|
39
|
+
const args = process.argv.slice(2);
|
|
40
|
+
const url = (args.find(a => !a.startsWith('--'))) ||
|
|
41
|
+
('file://' + path.join(process.cwd(), 'index.html'));
|
|
42
|
+
const opt = k => { const a = args.find(x => x.startsWith('--' + k + '=')); return a ? a.split('=')[1] : null; };
|
|
43
|
+
const widths = (opt('widths') || '1440,1180,900').split(',').map(Number);
|
|
44
|
+
const BL = Number(opt('baseline') || 8);
|
|
45
|
+
|
|
46
|
+
(async () => {
|
|
47
|
+
const browser = await puppeteer.launch({
|
|
48
|
+
executablePath: process.env.CHROME, headless: 'new',
|
|
49
|
+
args: ['--no-sandbox','--disable-gpu','--disable-dbus','--use-gl=angle','--use-angle=swiftshader','--hide-scrollbars']
|
|
50
|
+
});
|
|
51
|
+
const page = await browser.newPage();
|
|
52
|
+
let failed = false;
|
|
53
|
+
|
|
54
|
+
for (const W of widths) {
|
|
55
|
+
await page.setViewport({ width: W, height: 1000, deviceScaleFactor: 1 });
|
|
56
|
+
await page.goto(url, { waitUntil: 'load', timeout: 25000 });
|
|
57
|
+
try { await page.evaluate(() => document.fonts && document.fonts.ready); } catch (e) {}
|
|
58
|
+
await new Promise(r => setTimeout(r, 500));
|
|
59
|
+
|
|
60
|
+
const res = await page.evaluate((BL) => {
|
|
61
|
+
const OPT = '.opt-align'; // display elements: optically aligned by INK, not box
|
|
62
|
+
const grid = document.querySelector('.grid');
|
|
63
|
+
const cs = getComputedStyle(grid);
|
|
64
|
+
const tracks = cs.gridTemplateColumns.split(' ').map(parseFloat);
|
|
65
|
+
const gap = parseFloat(cs.columnGap);
|
|
66
|
+
const gr = grid.getBoundingClientRect();
|
|
67
|
+
// build column START (L) and END (R) coordinate sets
|
|
68
|
+
const L = [], R = []; let x = gr.left;
|
|
69
|
+
for (let i = 0; i < tracks.length; i++) { L.push(x); x += tracks[i]; R.push(x); if (i < tracks.length - 1) x += gap; }
|
|
70
|
+
const nr = (v, arr) => arr.reduce((m, e) => Math.min(m, Math.abs(e - v)), 1e9);
|
|
71
|
+
const nearest = (v, arr) => arr.reduce((b, e) => Math.abs(e - v) < Math.abs(b - v) ? e : b, arr[0]);
|
|
72
|
+
|
|
73
|
+
// 1. column adherence — exclude optical display elements (their box is
|
|
74
|
+
// deliberately offset by the glyph side-bearing so the INK lands on
|
|
75
|
+
// the line; they are validated by check 4 instead).
|
|
76
|
+
let colErr = 0, worst = null;
|
|
77
|
+
document.querySelectorAll('.band > *').forEach(el => {
|
|
78
|
+
if (el.matches(OPT)) return;
|
|
79
|
+
const r = el.getBoundingClientRect(); if (r.width < 2) return;
|
|
80
|
+
const e = Math.max(nr(r.left, L), nr(r.right, R));
|
|
81
|
+
if (e > colErr) { colErr = e; worst = (el.className || el.tagName).toString().slice(0, 28); }
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// 2. overlay match
|
|
85
|
+
let ovErr = 0;
|
|
86
|
+
document.querySelectorAll('.guides .cols .col').forEach((c, i) => {
|
|
87
|
+
const r = c.getBoundingClientRect();
|
|
88
|
+
if (L[i] != null) ovErr = Math.max(ovErr, Math.abs(r.left - L[i]));
|
|
89
|
+
if (R[i] != null) ovErr = Math.max(ovErr, Math.abs(r.right - R[i]));
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// 3. baseline (tops modulo BL, per spread relative to its rows-top)
|
|
93
|
+
let baseErr = 0;
|
|
94
|
+
document.querySelectorAll('.spread').forEach(sp => {
|
|
95
|
+
const rowsEl = sp.querySelector('.guides .rows'); if (!rowsEl) return;
|
|
96
|
+
const top = rowsEl.getBoundingClientRect().top;
|
|
97
|
+
sp.querySelectorAll('.body,.lede,.cap,.toc li,.dishes li,.kicker').forEach(el => {
|
|
98
|
+
const t = el.getBoundingClientRect().top - top; const m = ((t % BL) + BL) % BL;
|
|
99
|
+
baseErr = Math.max(baseErr, Math.min(m, BL - m));
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// 4. optical ink offset — each display element's visible INK-left must
|
|
104
|
+
// sit on ITS OWN column line (the nearest column-start to its box),
|
|
105
|
+
// not always line 1 (headlines can start on any column).
|
|
106
|
+
const cvs = document.createElement('canvas'), ctx = cvs.getContext('2d');
|
|
107
|
+
let inkErr = 0, inkWorst = null;
|
|
108
|
+
document.querySelectorAll(OPT).forEach(el => {
|
|
109
|
+
const c = getComputedStyle(el); let ch = (el.textContent || '').trim().charAt(0); if (!ch) return;
|
|
110
|
+
if (c.textTransform === 'uppercase') ch = ch.toUpperCase();
|
|
111
|
+
ctx.font = c.fontStyle + ' ' + c.fontWeight + ' ' + c.fontSize + ' ' + c.fontFamily; ctx.textAlign = 'left';
|
|
112
|
+
const abl = ctx.measureText(ch).actualBoundingBoxLeft;
|
|
113
|
+
const box = el.getBoundingClientRect().left;
|
|
114
|
+
const target = nearest(box, L); // the column line this element sits on
|
|
115
|
+
const ink = box - abl; // visible ink-left
|
|
116
|
+
const e = Math.abs(ink - target);
|
|
117
|
+
if (e > inkErr) { inkErr = e; inkWorst = (el.className || '').toString().slice(0, 20) + ' "' + ch + '"'; }
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
track: +tracks[0].toFixed(1),
|
|
122
|
+
maxColErrPx: +colErr.toFixed(2), worstCol: worst,
|
|
123
|
+
overlayErrPx: +ovErr.toFixed(2),
|
|
124
|
+
maxBaselineOffPx: +baseErr.toFixed(2),
|
|
125
|
+
maxInkOffPx: +inkErr.toFixed(2), worstInk: inkWorst,
|
|
126
|
+
fontFamily: getComputedStyle(document.querySelector('.masthead') || document.body).fontFamily.split(',')[0]
|
|
127
|
+
};
|
|
128
|
+
}, BL);
|
|
129
|
+
|
|
130
|
+
// baseline tolerance = half a baseline unit (element border-box top vs line is a proxy; leading does the real work)
|
|
131
|
+
const pass = res.maxColErrPx <= 0.5 && res.overlayErrPx <= 0.5 && res.maxBaselineOffPx <= (BL / 2) && res.maxInkOffPx <= 1.0;
|
|
132
|
+
if (!pass) failed = true;
|
|
133
|
+
console.log(`[${pass ? 'PASS' : 'FAIL'}] vw=${W} col=${res.maxColErrPx}px overlay=${res.overlayErrPx}px ` +
|
|
134
|
+
`baseline=${res.maxBaselineOffPx}px ink=${res.maxInkOffPx}px ` +
|
|
135
|
+
`(worstCol=${res.worstCol}, worstInk=${res.worstInk}, font=${res.fontFamily})`);
|
|
136
|
+
}
|
|
137
|
+
await browser.close();
|
|
138
|
+
if (failed) { console.error('GRID VERIFY: FAIL'); process.exit(1); }
|
|
139
|
+
console.log('GRID VERIFY: PASS');
|
|
140
|
+
})().catch(e => { console.error('ERR', e.message); process.exit(2); });
|
package/package.json
CHANGED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
# Countable Story Format
|
|
2
|
-
|
|
3
|
-
The canonical format for stories and bug-fix specs that need to be **countable** — i.e., readable by automated counters that score scope, sizing, and non-functional coverage. Every spec-producing skill in bigpowers writes output in this format.
|
|
4
|
-
|
|
5
|
-
This is a structural contract. Counters key off the exact section names and order. Section omissions are not equivalent to "no content here" — they make the spec uncountable. Use `Not applicable` instead.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Hard rules
|
|
10
|
-
|
|
11
|
-
1. **Every section must be present.** Empty sections are written as `Not applicable` with a one-line reason. Deleting a section caps maturity at 3.
|
|
12
|
-
2. **Section names and order are fixed.** Do not rename, merge, or reorder. Counters do not infer location.
|
|
13
|
-
3. **Sections 14, 15, 16 are tagged `*NFR*`** in their heading. The NFR ratio = (§14 + §15 + §16 content) / total content. The tag must be present even when the section is `Not applicable`.
|
|
14
|
-
4. **Sizing uses Fibonacci only.** XS=1, S=2, M=3, L=5, XL=8. Any other value is invalid.
|
|
15
|
-
5. **Acceptance criteria are Gherkin only** (`Scenario / Given / When / Then`) and live in §17.
|
|
16
|
-
6. **Acceptance criteria must cover the main flow (§5) plus every alternative/exception listed in §6.** One scenario per branch, minimum.
|
|
17
|
-
7. **Multiple occurrences of the same dimension are listed separately**, each with its own one-line rationale. Do not collapse.
|
|
18
|
-
|
|
19
|
-
## Maturity rubric (self-score in the header)
|
|
20
|
-
|
|
21
|
-
| Score | Label | Definition |
|
|
22
|
-
|------|-------|------------|
|
|
23
|
-
| 1 | Napkin | Only §1, §2, §17 populated. |
|
|
24
|
-
| 2 | Sketch | §1–§6 populated; data model implicit. |
|
|
25
|
-
| **3** | **Countable** | **§1–§16 populated. Counter runs cleanly. Wording may still be loose.** |
|
|
26
|
-
| 4 | Refined | §1–§20 populated. Gherkin covers every business rule. Open questions tracked but non-blocking. |
|
|
27
|
-
| 5 | Implementation-ready | All sections final. Data model precise enough for codegen. No open questions. References complete. |
|
|
28
|
-
|
|
29
|
-
**Sprint commitment gate:** maturity ≥ 4 recommended. Anything below 3 is blocked from sprint commit unless risk is explicitly accepted.
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Header block (mandatory)
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
STORY KEY: <PROJECT-NNN>
|
|
37
|
-
TITLE: <short imperative title>
|
|
38
|
-
TYPE: Story | Spike | Bug | Enabler
|
|
39
|
-
PARENT: <epic key or N/A>
|
|
40
|
-
STATUS: Draft | Ready for refinement | Refined | Counted | In sprint
|
|
41
|
-
AUTHOR: <name> DATE: <YYYY-MM-DD>
|
|
42
|
-
MATURITY: <self-score 1-5>
|
|
43
|
-
SIZE: XS | S | M | L | XL (Fibonacci 1/2/3/5/8)
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
`SIZE` is optional at maturity 3; required at maturity 4+.
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## The 20 sections
|
|
51
|
-
|
|
52
|
-
Headings appear verbatim, including the numbers.
|
|
53
|
-
|
|
54
|
-
### 1. Business narrative
|
|
55
|
-
|
|
56
|
-
Two to four paragraphs of plain business prose. No solution language. No `As a / I want` phrasing — that belongs in §2. Describe the situation, the friction, and the desired outcome from the business point of view.
|
|
57
|
-
|
|
58
|
-
### 2. Value statement
|
|
59
|
-
|
|
60
|
-
A single line:
|
|
61
|
-
```
|
|
62
|
-
As a <actor>, I want <capability>, so that <outcome>.
|
|
63
|
-
```
|
|
64
|
-
Retained for portfolio-level skim. One line, no expansion.
|
|
65
|
-
|
|
66
|
-
### 3. Actors and permissions
|
|
67
|
-
|
|
68
|
-
List of actors and what they are allowed to do. Mark each as `internal | external | system`.
|
|
69
|
-
|
|
70
|
-
### 4. Trigger and preconditions
|
|
71
|
-
|
|
72
|
-
What event starts this flow. What must be true before it can run.
|
|
73
|
-
|
|
74
|
-
### 5. Main flow and business logic
|
|
75
|
-
|
|
76
|
-
Numbered steps describing the happy path. Decision points are explicit. Include the line `Interruption point: <where the flow can be paused/resumed or N/A>`.
|
|
77
|
-
|
|
78
|
-
### 6. Alternative flows and exceptions
|
|
79
|
-
|
|
80
|
-
Numbered list of every branch and every error path. Each entry must be referenced by a Gherkin scenario in §17.
|
|
81
|
-
|
|
82
|
-
### 7. Interface elements
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
Context: new | existing
|
|
86
|
-
Static elements: <list>
|
|
87
|
-
Dynamic elements: <list>
|
|
88
|
-
```
|
|
89
|
-
Max five elements per cluster. If more, split into clusters.
|
|
90
|
-
|
|
91
|
-
### 8. Domain model
|
|
92
|
-
|
|
93
|
-
Entities touched, entities created, relationships changed. Reference `specs/CONTEXT.md` and `specs/UBIQUITOUS_LANGUAGE.md` where applicable.
|
|
94
|
-
|
|
95
|
-
### 9. Integrations and boundaries
|
|
96
|
-
|
|
97
|
-
Each integration tagged `perennial | ethereal` and `direction: in | out | both`.
|
|
98
|
-
|
|
99
|
-
### 10. Background processes
|
|
100
|
-
|
|
101
|
-
Each tagged `event | scheduled | manual+scheduled | external`.
|
|
102
|
-
|
|
103
|
-
### 11. Notifications
|
|
104
|
-
|
|
105
|
-
One entry per notification: channel, recipient, trigger event.
|
|
106
|
-
|
|
107
|
-
### 12. Audit and logging
|
|
108
|
-
|
|
109
|
-
Audited entities and the audit fields captured.
|
|
110
|
-
|
|
111
|
-
### 13. Solution variabilities
|
|
112
|
-
|
|
113
|
-
For each parameter: source (`config | tenant | feature flag | role`) and behaviour per value.
|
|
114
|
-
|
|
115
|
-
### 14. Quality attributes *NFR*
|
|
116
|
-
|
|
117
|
-
Concrete service-level targets: p95 latency, uptime, scale ceiling, reliability. Numbers only — no adjectives.
|
|
118
|
-
|
|
119
|
-
### 15. Security and compliance *NFR*
|
|
120
|
-
|
|
121
|
-
AuthN method, AuthZ model, data classification, applicable regulations, controls in place.
|
|
122
|
-
|
|
123
|
-
### 16. UX and accessibility *NFR*
|
|
124
|
-
|
|
125
|
-
WCAG level, i18n scope, supported modalities, branding constraints.
|
|
126
|
-
|
|
127
|
-
### 17. Acceptance criteria
|
|
128
|
-
|
|
129
|
-
Gherkin scenarios:
|
|
130
|
-
```
|
|
131
|
-
Scenario: <name>
|
|
132
|
-
Given <precondition>
|
|
133
|
-
When <action>
|
|
134
|
-
Then <outcome>
|
|
135
|
-
```
|
|
136
|
-
At least one scenario for the main flow (§5) and one per branch in §6.
|
|
137
|
-
|
|
138
|
-
### 18. Out of scope
|
|
139
|
-
|
|
140
|
-
Explicit non-goals. Phrased as full sentences, not single words.
|
|
141
|
-
|
|
142
|
-
### 19. Open questions
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
- <question> — owner: <name>, needed by: <YYYY-MM-DD>
|
|
146
|
-
```
|
|
147
|
-
A non-empty §19 caps maturity at 3.
|
|
148
|
-
|
|
149
|
-
### 20. References
|
|
150
|
-
|
|
151
|
-
Links to design docs, RFCs, ADRs, prior stories, datasets, prototypes.
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## Bug-fix specs (bugs/BUG-*.md)
|
|
156
|
-
|
|
157
|
-
Bug fixes use the same header block and the same 20 sections. The minimum required for "Countable" on a bug fix:
|
|
158
|
-
|
|
159
|
-
- §1 — describe actual vs. expected behavior and reproduction.
|
|
160
|
-
- §5 — the verified root-cause flow (output of the 4-phase RCA).
|
|
161
|
-
- §6 — alternative hypotheses ruled out.
|
|
162
|
-
- §17 — Gherkin: at least one regression scenario that fails before the fix and passes after.
|
|
163
|
-
- §18 — what this fix deliberately does not change.
|
|
164
|
-
- §19 — anything still unverified.
|
|
165
|
-
|
|
166
|
-
Sections 2–4, 7–16, 20 are marked `Not applicable — <reason>` if the fix is purely behavioral.
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
## Refactors and spikes
|
|
171
|
-
|
|
172
|
-
Refactors and spikes are not user stories and do **not** use this format. They keep their existing lightweight templates (`specs/REFACTOR.md`, `specs/SPIKE-<name>.md`). They are not counted.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Worked example (minimal countable story)
|
|
177
|
-
|
|
178
|
-
```
|
|
179
|
-
STORY KEY: ACME-101
|
|
180
|
-
TITLE: Self-serve password reset
|
|
181
|
-
TYPE: Story
|
|
182
|
-
PARENT: ACME-EPIC-7
|
|
183
|
-
STATUS: Draft
|
|
184
|
-
AUTHOR: dvm DATE: 2026-05-23
|
|
185
|
-
MATURITY: 3
|
|
186
|
-
SIZE: M
|
|
187
|
-
|
|
188
|
-
### 1. Business narrative
|
|
189
|
-
Customer-support handles ~120 password reset tickets per week. Each ticket
|
|
190
|
-
costs an average of 8 minutes of agent time. Customers wait 4 hours on
|
|
191
|
-
average for a reply. Both numbers are unacceptable for our SLA tier.
|
|
192
|
-
|
|
193
|
-
### 2. Value statement
|
|
194
|
-
As a signed-out customer, I want to reset my own password, so that I can
|
|
195
|
-
get back into my account without contacting support.
|
|
196
|
-
|
|
197
|
-
### 3. Actors and permissions
|
|
198
|
-
- Customer (external) — initiate reset, set new password.
|
|
199
|
-
- Auth service (system) — issue and verify reset tokens.
|
|
200
|
-
|
|
201
|
-
### 4. Trigger and preconditions
|
|
202
|
-
Trigger: customer clicks "Forgot password" on the sign-in screen.
|
|
203
|
-
Precondition: an account with the supplied email exists and is not locked.
|
|
204
|
-
|
|
205
|
-
### 5. Main flow and business logic
|
|
206
|
-
1. Customer submits email.
|
|
207
|
-
2. System creates single-use reset token (TTL 30 min).
|
|
208
|
-
3. System emails token link to the registered address.
|
|
209
|
-
4. Customer opens link and submits new password.
|
|
210
|
-
5. System verifies token, updates password hash, invalidates token.
|
|
211
|
-
6. System redirects to sign-in.
|
|
212
|
-
Interruption point: between steps 3 and 4 (link sent, not yet clicked).
|
|
213
|
-
|
|
214
|
-
### 6. Alternative flows and exceptions
|
|
215
|
-
6a. Email not registered — respond identically to success path (do not leak).
|
|
216
|
-
6b. Token expired — display generic "request a new link" message.
|
|
217
|
-
6c. Account locked — redirect to support contact page; do not issue token.
|
|
218
|
-
|
|
219
|
-
### 7. Interface elements
|
|
220
|
-
Context: existing.
|
|
221
|
-
Static elements: page title, email input, submit button.
|
|
222
|
-
Dynamic elements: validation message, throttle banner.
|
|
223
|
-
|
|
224
|
-
### 8. Domain model
|
|
225
|
-
Entities touched: User, AuthCredential. New entity: PasswordResetToken
|
|
226
|
-
(user_id, token_hash, expires_at, used_at).
|
|
227
|
-
|
|
228
|
-
### 9. Integrations and boundaries
|
|
229
|
-
- Email provider (perennial, direction: out).
|
|
230
|
-
|
|
231
|
-
### 10. Background processes
|
|
232
|
-
- Token sweeper (scheduled, hourly) — purges expired tokens.
|
|
233
|
-
|
|
234
|
-
### 11. Notifications
|
|
235
|
-
- Email — recipient: registered user — trigger: token issued.
|
|
236
|
-
|
|
237
|
-
### 12. Audit and logging
|
|
238
|
-
Audited entity: PasswordResetToken. Fields: issued_at, used_at, ip.
|
|
239
|
-
|
|
240
|
-
### 13. Solution variabilities
|
|
241
|
-
- TTL (config) — default 30 min, override per tenant.
|
|
242
|
-
|
|
243
|
-
### 14. Quality attributes *NFR*
|
|
244
|
-
- p95 reset-flow end-to-end < 60 s including email delivery.
|
|
245
|
-
- 99.9% monthly uptime on the reset endpoint.
|
|
246
|
-
|
|
247
|
-
### 15. Security and compliance *NFR*
|
|
248
|
-
- AuthN: anonymous on request, token-based on completion.
|
|
249
|
-
- AuthZ: token bound to user_id; single use.
|
|
250
|
-
- Data class: PII (email).
|
|
251
|
-
- Controls: rate-limit 5/hour/IP; token-hash at rest.
|
|
252
|
-
|
|
253
|
-
### 16. UX and accessibility *NFR*
|
|
254
|
-
- WCAG 2.1 AA.
|
|
255
|
-
- i18n: en, pt-BR at launch.
|
|
256
|
-
|
|
257
|
-
### 17. Acceptance criteria
|
|
258
|
-
Scenario: Happy path
|
|
259
|
-
Given a registered customer at the sign-in screen
|
|
260
|
-
When the customer requests a password reset for their email
|
|
261
|
-
Then an email with a single-use link is sent within 60 seconds
|
|
262
|
-
|
|
263
|
-
Scenario: Unknown email (6a)
|
|
264
|
-
Given an email that is not registered
|
|
265
|
-
When the customer requests a password reset
|
|
266
|
-
Then the UI shows the same confirmation as the happy path
|
|
267
|
-
And no email is sent
|
|
268
|
-
|
|
269
|
-
Scenario: Expired token (6b)
|
|
270
|
-
Given a reset token older than 30 minutes
|
|
271
|
-
When the customer opens the link
|
|
272
|
-
Then the UI shows "request a new link"
|
|
273
|
-
|
|
274
|
-
Scenario: Locked account (6c)
|
|
275
|
-
Given an account marked locked
|
|
276
|
-
When the customer requests a password reset
|
|
277
|
-
Then no token is issued
|
|
278
|
-
And the UI redirects to the support contact page
|
|
279
|
-
|
|
280
|
-
### 18. Out of scope
|
|
281
|
-
- Passwordless / magic-link sign-in.
|
|
282
|
-
- Forced password rotation policy.
|
|
283
|
-
- Admin-initiated resets.
|
|
284
|
-
|
|
285
|
-
### 19. Open questions
|
|
286
|
-
- Confirm rate-limit threshold with SecOps — owner: dvm, needed by: 2026-05-30.
|
|
287
|
-
|
|
288
|
-
### 20. References
|
|
289
|
-
- ADR-0014 (token strategy).
|
|
290
|
-
- specs/CONTEXT.md (User aggregate).
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
This example scores 3 (Countable). To reach 4, resolve §19 and add NFR coverage for §16 i18n test plan.
|