Isometric line figures that answer the pointer. For React and for anything with a DOM.
Skill: the flow, the ten rules with what rejects a figure, how to find a concept, and the look
Lucas Marques686fe089d1c1
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 591bde4..eb35b20 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -15,6 +15,7 @@ pnpm buildpackages/hairline the package: src/core (maths, stage, styles), src/figures (six engines),src/mount.ts (the public lifecycle), src/index.ts and src/react.tsx (the two entries)apps/site hairline.lucasmarkes.com (Next.js)+skills/hairline-create the skill that draws a new figure: its kernel is generated from packages/hairline/src/coreregistry the shadcn item: its source, and the scripts that build and validate itfixtures two apps that install the packed tarball: Next.js and Vitescripts the release gate and what it calls@@ -29,6 +30,7 @@ scripts the release gate and what it calls| `pnpm test` | Unit and component tests (Vitest, jsdom). || `pnpm test:browser` | Browser tests in Chrome (Playwright): the figures, the theme, parity, the site. || `pnpm dev` | The site on `localhost:3000`, with the package rebuilding on change. |+| `pnpm kernel` | Regenerates `skills/hairline-create/kernel.js` from `packages/hairline/src/core`. Run it after any change there; a test fails until you do. || `pnpm release --static` | The release gate without the steps that need the network. CI runs this. || `pnpm release` | The whole gate. It never publishes. || `node scripts/consumers.mjs` | Packs the package and installs it in both fixtures. |diff --git a/docs/superpowers/specs/2026-10-01-hairline-create-skill-design.md b/docs/superpowers/specs/2026-10-01-hairline-create-skill-design.mdindex ed9b885..4e70c5f 100644--- a/docs/superpowers/specs/2026-10-01-hairline-create-skill-design.md+++ b/docs/superpowers/specs/2026-10-01-hairline-create-skill-design.md@@ -38,6 +38,7 @@ What reaches the person's machine on install is the skill folder and nothing els| `concepts.md` | How to turn an idea into a figure: the ways of answering the pointer already proven in the package, and what makes a concept weak (dead at rest, needs words to be understood, more than one idea, no reason for the pointer). || `kernel.js` | The engine as plain JavaScript, generated from `packages/hairline/src/core`. || `bench.html` | The page template, with two marked slots: kernel and figure. |+| `build.mjs` | Puts a figure on the bench: `node build.mjs <figure.js>` writes the page. No dependencies. || `examples/terrain.js`, `examples/riffle.js` | Two figures of the package in the skill's format: a continuous field (springs, falloff by distance) and discrete items (stagger, tweens, identity by geometry). || `validate.mjs` | The validator. No dependencies. || `look.md` | The checklist for the look, and how to do it by reading code when there is no browser. |@@ -62,6 +63,8 @@ Beside the mount function a figure declares:The bench owns everything else: it creates the host and the SVG, injects the kernel's stylesheet, maps the slider through `range` and calls `set`, switches the theme, and shows `means` and `rules`.+Figures are pointer-only. The bench's stage is an image, not a focusable group, so the Riffle example leaves out the package's keyboard handling.+## The validator`node validate.mjs <file.html>` exits non-zero and prints what to fix when:@@ -71,7 +74,9 @@ The bench owns everything else: it creates the host and the SVG, injects the ker- the figure sets its own `stroke-width`, or a colour, fill, filter or shadow outside the kernel's classes: rule 04, and the single stroke;- the page loads anything from outside (`<script src>`, `<link>`, `fetch`, `import`, remote `url()`);- the figure never writes the read-out, or does not return `set` and `destroy`;-- the figure runs its own clock (`setInterval`, `setTimeout` loops, `requestAnimationFrame`) instead of the kernel's loop: rule 07 and reduced motion;+- the figure runs its own clock (`setInterval`, `setTimeout`, `requestAnimationFrame`) or never joins the kernel's loop: rule 07 and reduced motion;+- the figure listens to the pointer itself, measures what is on screen, or never calls the kernel's `pointer`: rule 01;+- anything in the page other than the figure differs from the bench;- the figure does not declare `name`, `means`, `rules` and `range`;- the figure is over 200 lines, a sign the concept is too complicated.@@ -88,6 +93,8 @@ With a browser, the agent opens the file and takes four pictures: at rest and wi- bright outside, dim inside, no vertical corners drawn (rule 09);- the read-out names what is under the pointer and says `rest` when nothing is.+The bench takes two URL parameters for this: `?w=240` narrows the page, and `&at=x,y` holds the pointer at a viewBox point, for tools that cannot hover.+Without a browser the agent answers the same list from the code and says so at hand-off. Without Node it reads the validator's list and says so too.## Testsdiff --git a/packages/hairline/test/skill/shape.test.ts b/packages/hairline/test/skill/shape.test.tsnew file mode 100644index 0000000..a24bc1f--- /dev/null+++ b/packages/hairline/test/skill/shape.test.ts@@ -0,0 +1,44 @@+import { existsSync, readdirSync, readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";+import { expect, it } from "vitest";++/** The skill folder is what an agent installs: these hold its shape. */+const SKILL = fileURLToPath(new URL("../../../../skills/hairline-create/", import.meta.url));+const FILES = ["SKILL.md", "bench.html", "build.mjs", "concepts.md", "examples/riffle.js", "examples/terrain.js", "kernel.js", "look.md", "rules.md", "validate.mjs"];+const text = (p: string) => readFileSync(SKILL + p, "utf8");++it("holds exactly its ten files", () => {+ const found = (readdirSync(SKILL, { recursive: true, withFileTypes: true }) as import("node:fs").Dirent[])+ .filter((e) => e.isFile())+ .map((e) => (e.parentPath + "/" + e.name).slice(SKILL.length).replace(/^\//, ""));+ expect(found.sort()).toEqual(FILES);+});++it("SKILL.md opens with a name that is its folder's and a description that says when to use it", () => {+ const m = /^---\nname: (.+)\ndescription: (.+)\nargument-hint: (.+)\n---\n/.exec(text("SKILL.md"));+ expect(m).not.toBeNull();+ expect(m![1]).toBe("hairline-create");+ expect(m![2]).toMatch(/^Use when /);+ expect(m![2].length).toBeLessThanOrEqual(1024);+ expect(text("SKILL.md").split("\n").length).toBeLessThan(120);+});++it("SKILL.md points to every other file, and to none that is not there", () => {+ const skill = text("SKILL.md");+ for (const f of FILES.filter((f) => f !== "SKILL.md")) expect(skill, f).toContain(f);+ for (const [, f] of skill.matchAll(/`([\w./-]+\.(?:md|mjs|js|html))`/g)) expect(existsSync(SKILL + f), f).toBe(true);+});++it("rules.md has the ten rules, named as the bench names them", () => {+ const names = [...text("rules.md").matchAll(/^## (\d\d) · (\w+)/gm)].map((m) => `${m[1]} ${m[2]}`);+ const bench = /const RULES = (\[[^\]]+\]);/.exec(text("bench.html"))![1];+ expect(names).toEqual((JSON.parse(bench) as string[]).map((name, i) => `${String(i + 1).padStart(2, "0")} ${name}`));+});++it("look.md and SKILL.md name the validator's checks and the bench's parameters as they are", () => {+ expect(text("look.md")).toContain("?w=240");+ expect(text("look.md")).toContain("at=");+ for (const id of ["kernel", "bench", "text", "paint", "outside", "clock", "hit", "readout", "handle", "declare", "length"]) {+ expect(text("validate.mjs"), id).toMatch(new RegExp(`^ \\* {3}${id} `, "m"));+ }+});diff --git a/skills/hairline-create/SKILL.md b/skills/hairline-create/SKILL.mdnew file mode 100644index 0000000..5b15d9b--- /dev/null+++ b/skills/hairline-create/SKILL.md@@ -0,0 +1,67 @@+---+name: hairline-create+description: Use when someone asks for a new Hairline figure, or runs /hairline-create with an idea. Draws one isometric line figure that answers the pointer, in the style and on the engine of @lucasmarkes/hairline, and hands it over as a single self-contained HTML file.+argument-hint: "[idea]"+---++# Hairline: create a figure++You are making one figure in the Hairline style: an isometric line drawing, built from rounded solids in a single stroke, that answers the pointer. It ships as one HTML file with nothing to install. The six figures of `@lucasmarkes/hairline` are the bar; `examples/terrain.js` and `examples/riffle.js` are two of them, in the format you will write.++You write one thing: the figure. The engine (`kernel.js`) and the page (`bench.html`) are fixed. Never edit them, never paste a changed copy of them, and never write again what the kernel already gives you.++Every path below is in this skill's folder.++## 1. Concept++Read `concepts.md`. Then offer two or three concepts, one line each:++> **Name.** The object. What the pointer does to it. What the read-out says.++Wait for the person to pick. Skip this step only when they arrived with the object and the gesture already chosen. If there is nobody to ask, take the concept with the strongest rest pose and say which you took.++One figure, one idea. A concept that needs a label to be understood is not a concept yet.++## 2. Build++1. Read `rules.md`. The ten rules are not advice: a figure that breaks one is not finished.+2. Read the index at the top of `kernel.js`: the first comment, down to `var HL`. It lists everything you may call. Do not read the code under it.+3. Read the example nearer your concept: `examples/terrain.js` for a continuous field, `examples/riffle.js` for discrete items.+4. Write the figure as `<name>.js` in the person's working directory, in the shape of the examples: take what you need from `HL`, define `mount({ stage, svg, read }, value)` returning `{ set, destroy }`, and end the file with `hairline({ name, means, rules, range, mount })`.+ - `name`: lowercase, one word or hyphenated.+ - `means`: one sentence saying what the figure shows. It is the line under the stage.+ - `rules`: the numbers of the rules this figure leans on most.+ - `range`: the one number the slider drives, at intensity 0, 0.5 and 1. The middle one is the default, and the three move one way.+5. Assemble it: `node build.mjs <name>.js` writes `hairline-<name>.html`. Without Node, copy `bench.html` and put the contents of `kernel.js` where `/*KERNEL*/` is and your figure where `/*FIGURE*/` is, by file operation, changing nothing else.++## 3. Check++1. `node validate.mjs hairline-<name>.html`. Fix every line it prints, build again, run it again. Without Node, read the list of checks at the top of `validate.mjs` and answer each one from your code.+2. The look: follow `look.md`. Fix what fails, then go back to 1.++Do not hand over a page the validator rejects. Do not say the look is done if you did not look.++## 4. Hand over++Publish `hairline-<name>.html` as an artifact if you can. If you cannot, leave the file where the person can open it and say where it is. Then say, one line each:++- the metaphor: what the object is, and what the pointer does to it;+- the rules it leans on;+- anything you could not verify (no Node, no browser), plainly.++## 5. Adjust++When the person asks for a change, edit only `<name>.js`, then build, validate and look again. The tenth version is held to the same bar as the first.++## What goes wrong++| If you catch yourself | Do this instead |+| --- | --- |+| adding a label, a number or a letter to the drawing | say it with geometry (rule 10); names go to `read.textContent` |+| reaching for a colour, a fill or a glow | move one stroke from `sil` to `hi` (rule 04) |+| writing a timer, a `requestAnimationFrame` or a CSS animation | `register(stage, tick)`, with springs or tweens (rules 07 and 08) |+| testing the pointer against what is drawn right now | test it against the rest or target pose (rule 01) |+| drawing a box with twelve edges | `prism` of two rounded rings: a silhouette and one crease (rule 09) |+| leaving rest flat, empty, or symmetric because that was easy | compose it: rest is the thumbnail (rule 05) |+| editing the kernel or the bench to make something work | the figure is wrong; change the figure |+| letting in a second idea | cut it: one figure, one idea |diff --git a/skills/hairline-create/concepts.md b/skills/hairline-create/concepts.mdnew file mode 100644index 0000000..5e41d95--- /dev/null+++ b/skills/hairline-create/concepts.md@@ -0,0 +1,52 @@+# From an idea to a concept++A concept is three things: **an object**, **what the pointer does to it**, and **what the read-out says**. It fits on one line. If it does not, it is not ready to build.++## Finding it++1. **Find the object.** Something you could put on a desk: a tray, a belt, a platter, a stack, a board of pegs. Not a diagram. "A sales funnel" is not boxes and arrows; it might be a rack of sieves, each finer than the last.+2. **Find the variable.** Every idea has one number or one choice that matters: how far, which one, how fast, how long. That is what the pointer gets.+3. **Give the pointer that variable.** Where it is sets a position (continuous); what it is over sets a choice (discrete). The answer should be what a hand would expect from the object.+4. **Design the rest.** What does the object look like when nobody touches it? It must already be a composition, and already say what the figure is about.+5. **Choose the read-out's words.** A few characters naming what is under the pointer: `cell 4·2`, `08`, `sieve 3`. And `rest`.+6. **Choose the slider's number.** One number that makes the answer weaker or stronger: a radius, a stagger, a gap, a rate. Its three values go in `range`.++## Six answers already proven++The package's six figures each answer the pointer a different way. A new figure usually borrows one.++| Answer | In the package | The pointer | The clock | The slider |+| --- | --- | --- | --- | --- |+| **A field** | Terrain: pillars rise near the pointer | sets a position on the ground; height falls off with distance | a spring per part | the radius |+| **One of many** | Riffle: the card under the pointer stands up | picks an item; its neighbours part, staggered outwards | tweens | the stagger |+| **Scrub and pick** | Exploded: a window comes apart in layers | x scrubs the gap, y picks a layer, which gets the bright edge | a spring for the gap | the gap |+| **Paint and decay** | Phosphor: a dot matrix you can draw on | excites what it passes; the marks fade; an idle loop returns | a decay per dot | the afterglow |+| **Dilate time** | Slow: crates ride a belt through a gate | the world keeps moving, hovering slows it so it can be read | a spring on the rate | the rate |+| **Push the camera** | Turntable: a platter you flick round | pushes; friction bleeds the spin; detents catch it | friction, then a spring | the coast |++`examples/terrain.js` is the first and `examples/riffle.js` the second, in full.++## A weak concept++Drop it, or fix it before building, when:++- **It is dead at rest.** Nothing to look at until touched.+- **It needs words.** Without a label nobody would know what it is.+- **It holds more than one idea.** Two gestures, two variables, two objects.+- **The pointer has no reason.** The figure would be the same as a loop.+- **It is a diagram.** Boxes, arrows and lines between them are not an object.+- **It is an icon.** The literal symbol of the idea (a padlock for security) has nothing to answer with.+- **It depends on colour.** The palette is one stroke in four weights.+- **It will not read at 240px.** Too many parts, or parts too small.++## An example++For "a sales funnel":++> **Sieves.** Five trays stacked on a rack, each with a finer grid of holes. The pointer's height picks a tray, which slides out and takes the bright edge; the ones above it lift clear. The read-out names the stage: `sieve 3`.+>+> **Chute.** Beads ride a belt that narrows through four gates, fewer passing each. Hovering slows the belt; the gate nearest the pointer brightens as a bead passes. The read-out says how many reached it: `gate 2 · 31`.+>+> **Basin.** A field of pegs sloping to one drain. The pointer raises a ridge that splits the slope, and the pegs behind it stand taller the nearer they are. The read-out names the cell: `cell 6·2`.++Each has an object, a gesture and a read-out; each is one idea; each is something at rest.diff --git a/skills/hairline-create/look.md b/skills/hairline-create/look.mdnew file mode 100644index 0000000..4c06ccd--- /dev/null+++ b/skills/hairline-create/look.md@@ -0,0 +1,42 @@+# The look++The validator reads text. This is what only eyes can check. Do it every time the figure changes.++## Four pictures++Open `hairline-<name>.html` in a browser and take four pictures. Two parameters in the address help:++- `?w=240` narrows the page to 240px, the size of a thumbnail.+- `&at=x,y` holds the pointer at a point of the figure's 400 × 320 viewBox, for tools that cannot hover. Choose a point that is on your figure.++| Picture | Address |+| --- | --- |+| full size, at rest | `hairline-<name>.html` |+| full size, answering | `hairline-<name>.html?at=200,160` |+| 240px, at rest | `hairline-<name>.html?w=240` |+| 240px, answering | `hairline-<name>.html?w=240&at=200,160` |++Wait a second after loading before the answering pictures, so springs and tweens have landed.++## What to see++Answer each with yes or no. A no is fixed in the figure before anything is handed over.++1. **The silhouette reads at 240px.** You can say what the object is from the small picture alone.+2. **Rest is a composition** (rule 05). Not flat, not empty, not a regular grid; something is bright where the eye should start.+3. **The answer falls off with distance, or spreads out from the pointer** (rules 02 and 03). It is not everything at once, and not one part alone.+4. **Nothing flickers** (rule 01). Hold `at` on an edge that moves when touched and take two pictures a second apart: they are the same.+5. **Bright outside, dim inside** (rule 09). Every solid is a silhouette and one crease; no vertical corner is drawn; no corner is sharp.+6. **Nothing shows through** (rule 06). No far edge crosses a near solid; no guide crosses its own plate.+7. **One highlight** (rule 04). What is bright is what the pointer chose, and it is a stroke.+8. **The read-out names what is under the pointer**, in a few characters, and says `rest` at rest.+9. **Nothing leaves the frame.** With the slider at each end and the pointer at the figure's edges, every part stays inside the plate.+10. **Both themes.** Press the theme button: nothing vanishes and nothing is left the wrong colour.+11. **No words** (rule 10). Nothing in the drawing is a letter, a digit, an arrow or an icon.+12. **The page is clean.** No line under the stage reporting an error, and nothing on the console.++If you are unsure whether the figure's weight is right, build an example the same way and put the two side by side: `node build.mjs examples/terrain.js`.++## Without a browser++Answer the same twelve from the code, each with the line that makes it true: the rest values for 2, the falloff or stagger for 3, the hit test for 4, the paint order for 6. Then say at hand-over, in these words, that the figure was **not looked at in a browser**. Do not skip the list and do not guess a yes.diff --git a/skills/hairline-create/rules.md b/skills/hairline-create/rules.mdnew file mode 100644index 0000000..26f0bdf--- /dev/null+++ b/skills/hairline-create/rules.md@@ -0,0 +1,83 @@+# The ten rules++They come from the study behind the package (lucasmarkes.com/lab/hairline). Each has what it says, how to keep it with the kernel, and what gets a figure rejected.++## 01 · hit: hit areas don't move++Test the pointer against the rest pose, or the target pose, never the pose on screen. Otherwise the geometry lifts out from under the pointer, the hover drops, the geometry falls back, and the hover returns: a flicker loop.++- **Keep it:** `unproj(C, sx, sy, 0)` puts the pointer on the ground plane, which never moves; pick by world coordinates (Terrain). For items, test static bands along their resting edges (Riffle). When a choice depends on a moving value, read the spring's target (`.t`), not its position (`.x`).+- **Rejected when:** the pointer held still on a moving edge makes the figure oscillate; picking reads a spring's current value; the figure measures the DOM (`getBoundingClientRect`, `elementFromPoint`, `:hover`) or adds its own pointer listeners.++## 02 · order: stagger by distance++`delay = |i − a| × step`. The motion spreads out from the pointer instead of running down a list.++- **Keep it:** `tset(tween, target, now, Math.abs(i - a) * step)`, with a step of 30–60ms so it reads as one gesture.+- **Rejected when:** items move in index order whatever was touched; all move at once when the concept is a spread; a step so long the last item starts after the first has landed and the gesture reads as a queue.++## 03 · reach: clamp the reach++The answer has a far end, and the figure is still composed there.++- **Keep it:** a falloff that reaches a floor (Terrain's is 1 → .31 at 42% of the radius → .09 beyond); `clamp` every lift, gap and lean; fit the camera to the most extreme pose (`fit` with the lifted points), so nothing leaves the 400 × 320 frame at intensity 1.+- **Rejected when:** at the slider's far end the figure comes apart, overlaps itself or leaves the frame; an unclamped value follows the pointer without limit.++## 04 · accent: the stroke is the only highlight++No fills, glows or shadows. The active edge goes from the silhouette's stroke to the bright one and nothing else changes colour, so the colour reads as information.++- **Keep it:** `el.sil.classList.toggle("hi", active)`. Dots change between `dot`, `dot m` and `dot off`. That is the whole palette.+- **Rejected when:** the figure sets any colour, fill, opacity trick, gradient, filter, shadow or stroke width of its own; more than one thing is bright without each meaning something; highlight is used as decoration.++## 05 · rest: rest is designed, never flat++Leaving returns the figure to a composition: a dune, a lean, a slight explode. The still frame is the thumbnail, so it has to hold up alone.++- **Keep it:** give every part a rest value that is not zero and not uniform (Terrain's dune is two Gaussians; Riffle's cards lean back 12°). Put one bright mark at rest where the eye should start.+- **Rejected when:** at rest the figure is a flat grid, an empty tray, a perfectly regular row; at rest nothing says what the figure is about; rest and "nothing rendered yet" look alike.++## 06 · honesty: construction stays honest++Plates are opaque, filled with the ground colour. Guides and dashed lines are painted behind the plates they belong to, so the drawing never shows a line it should not.++- **Keep it:** append back to front (Terrain walks its grid diagonal by diagonal from the far corner); a shape that must hide what is behind it keeps its fill (no `nf`); guides use `dash` and are appended before their plate. When depth order changes, move the group (`a.after(b)`), do not redraw.+- **Rejected when:** a far edge shows through a near solid; paint order is the order the code happened to make things in; a dashed guide crosses the face of the plate it belongs to.++## 07 · cost: loops sleep offscreen++Only ambient motion runs without input, and only while visible.++- **Keep it:** all motion happens inside `register(stage, tick)`. Return `true` from `tick` only while something is still moving; call `wake()` after input. The loop stops when every figure has settled, sleeps offscreen, and lands springs and tweens at once under reduced motion.+- **Rejected when:** the figure has a timer, a `requestAnimationFrame` or a CSS animation of its own; `tick` always returns `true` in a figure that is not ambient; a path is rewritten on frames where its value did not change (keep the last drawn value and skip).++## 08 · clock: two clocks++A discrete change (which item) gets a long ease-out: 700ms on `(.32, .72, 0, 1)`. A continuous input (where the pointer is) gets a spring, `k 100 · c 18 · m 1`, because its target moves every frame and a timed ease would always be chasing it.++- **Keep it:** `tween` / `tset` / `tval` for which; `spring` / `stepS` for where. Use the defaults unless the figure has a reason you can state.+- **Rejected when:** a tween follows the pointer's position; a spring animates a choice between items; durations or spring constants are invented; anything is linear.++## 09 · radius: round every corner, then draw less++A solid is the hull of two rounded rings, its top and its base. The vertical corners are never drawn. The top edge becomes one dim crease a unit or two inside the silhouette. Bright outside, dim inside: that hierarchy is most of the polish.++- **Keep it:** `rings(x0, y0, x1, y1, r, b)` then `prism(P, front, ring, inner, z0, z1)` into `solid(parent)` with `put`. A thin plate gets a second line for its thickness, not a second solid. Round flat outlines with `fillet`.+- **Rejected when:** a box shows twelve edges or any vertical corner line; a corner is sharp; inner lines are as bright as the silhouette; a solid has more than its silhouette, one crease, and at most a few marks the object would really have.++## 10 · quiet: no words inside the figure++Geometry carries identity: a punch on a card's tab, a dot code on a crate's lid, a bright edge instead of a label. Names go to the corner read-out, outside the drawing. Anything decorative has to be something the object would really have.++- **Keep it:** `read.textContent = …` names what is under the pointer, in a few characters (`cell 4·2`, `08`), and says `rest` when nothing is. Number things with dots.+- **Rejected when:** the svg holds text, letters or digits drawn as paths, icons, arrows or logos; the figure cannot be understood without its read-out; the read-out is a sentence.++## The frame++Not a rule of the study, but every figure shares it.++- The viewBox is 400 × 320. Centre the figure near (200, 166) with `fit`.+- The camera is `Cam(45, 0.5, S)`: the 2:1 view. Change `S` to fit; leave the angle alone unless the camera is the concept.+- The silhouette must read at 240px wide. Past a hundred or so solids, or with parts under ten viewBox units, it will not.+- `mount` keeps no state outside itself, and `destroy` leaves the svg empty and nothing running: collect tear-down in `disposer()` and return `bag.dispose`.+- At most 200 lines. A longer figure is usually two ideas.