Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
aa06df6
The diagram viewer (DECISIONS 310): Expand, the dialog, zoom and pan,…
bmjcoding Nov 23, 2026
50e0332
The diagram viewer in the HTML skill (DECISIONS 310): the diagram-zoo…
bmjcoding Nov 23, 2026
a66e86f
The viewer on a native dialog, Expand in words, and its layout in the…
bmjcoding Nov 23, 2026
d92cc92
The viewer's tests (diagram-viewer.test.mjs), and what they found
bmjcoding Nov 23, 2026
e7e6de4
The skill's index line for diagram-zoom, and its claimed classes
bmjcoding Nov 23, 2026
6b72639
Spatial arrow keys on tracks (DECISIONS 306, 1.5)
bmjcoding Nov 23, 2026
c7b0a66
Two diagram lengths and the print theme (DECISIONS 306, 1.0 and 1.7)
bmjcoding Nov 23, 2026
b62c3bc
A figure prints untraced (DECISIONS 306, 1.7)
bmjcoding Nov 23, 2026
dcfea55
Two-line edge labels (DECISIONS 306, 1.4)
bmjcoding Nov 23, 2026
52d5b41
Nested groups (DECISIONS 306, 1.3)
bmjcoding Nov 23, 2026
05870c4
Link cards (DECISIONS 306, 1.4)
bmjcoding Nov 23, 2026
71a2db3
Sequence activations and frames (DECISIONS 306, 1.2)
bmjcoding Nov 23, 2026
b913dda
Tests for batch B's built parts, and review round 66
bmjcoding Nov 23, 2026
3d757aa
Core-glyph masks for the review page's source stylesheet, and round 6…
bmjcoding Nov 23, 2026
010e37d
Flow on a dashed line (DECISIONS 306, 1.5)
bmjcoding Nov 23, 2026
b29dd14
Marks on a data flow's steps and a sequence's participants (DECISIONS…
bmjcoding Nov 23, 2026
6860c46
An entrance only on a first visit (DECISIONS 306, 1.5)
bmjcoding Nov 23, 2026
2334135
A trace on touch (DECISIONS 306, 1.5)
bmjcoding Nov 23, 2026
d58e50b
Right to left (DECISIONS 306, 1.7)
bmjcoding Nov 23, 2026
a643c62
Export to SVG and PNG (DECISIONS 306, 1.7), and the sequence's heads …
bmjcoding Nov 23, 2026
80f33ae
Automatic layout with elkjs (DECISIONS 306, 1.8)
bmjcoding Nov 23, 2026
14d1ad1
A sequence as text art (DECISIONS 306, 1.2)
bmjcoding Nov 23, 2026
2d0cd9f
Record the five diagrams' sizes after batch B (DECISIONS 318: the own…
bmjcoding Nov 23, 2026
c880624
The skill's caps after batch B (DECISIONS 318: the owner approved the…
bmjcoding Nov 23, 2026
0bdf9bd
elkjs in the package's third-party notices (DECISIONS 306, 1.8)
bmjcoding Nov 23, 2026
cf2fcd6
Round 66: automatic layout, text art, right to left and export
bmjcoding Nov 23, 2026
26dd3a7
Fixes from the full run: elkjs out of the shared chunk, the viewer's …
bmjcoding Nov 23, 2026
53064b3
Export: an edge on some sides only is drawn as lines; round 66 export…
bmjcoding Nov 23, 2026
2b15c9e
Two merged tests follow the decision: a tap traces on touch, and a da…
bmjcoding Nov 23, 2026
116c922
Re-record the five diagrams' sizes at the batch's head (+22 bytes each)
bmjcoding Nov 23, 2026
a7cb435
The quiet run, layout="auto" in the types, and the viewer's automatic…
bmjcoding Nov 23, 2026
9f725c1
Section 4's calls 2 and 3: a one-column schema's turn-back lanes, and…
bmjcoding Nov 23, 2026
b2f473e
End lanes past two, and several entries into one card (DECISIONS 306,…
bmjcoding Nov 23, 2026
4930420
Section 6's text for what is built: AGENTS.md, docs/motion.md, and fo…
bmjcoding Nov 23, 2026
f4250f6
Tests follow 1.3 and call 2, and the sizes and caps at the batch's head
bmjcoding Nov 23, 2026
88618e0
Cardinality and far keys in a schema (DECISIONS 306, 1.1, revised by …
bmjcoding Nov 23, 2026
b05ed38
Tests for cardinality and far keys: diagram-schema.test.mjs (section 8)
bmjcoding Nov 23, 2026
7648977
The rest of section 6 in foundations (6.2 to 6.12, 6.16), and cardina…
bmjcoding Nov 23, 2026
3832370
Automatic layout by the decider's ruling (DECISIONS 322): a main line…
bmjcoding Nov 23, 2026
e0cf7b8
Sizes and caps after cardinality, far keys and the ruling (DECISIONS …
bmjcoding Nov 23, 2026
65fa32b
Round 66: the schema's cardinality and far keys, and the automatic ar…
bmjcoding Nov 23, 2026
f47a065
elkjs's copy carries its licence, and no declaration names elkjs or t…
bmjcoding Nov 24, 2026
619ee9b
The viewer and the text sequence after both reviews (Fable B1 to B4, …
bmjcoding Nov 24, 2026
e459629
The engine, the stylesheet and export after both reviews and the swee…
bmjcoding Nov 24, 2026
ca505f6
The decider's text edits after the build, in foundations, and the ski…
bmjcoding Nov 24, 2026
78a9904
Round 66: the summary as built, the five parts with no picture, and t…
bmjcoding Nov 24, 2026
17c865a
A cycle of groups is handed to elk as groups of the root, so placing …
bmjcoding Nov 24, 2026
dcba515
Sizes and the skill's caps after the fix round (DECISIONS 318, 326)
bmjcoding Nov 24, 2026
d89c247
Tests for both reviews' findings and the sweep, and section 8's missi…
bmjcoding Nov 24, 2026
19d23b2
Round 66: the extended data flow is still, so its shot shows every line
bmjcoding Nov 24, 2026
3b2d116
Text art in the viewer: the glyph measured at 100%; the skill's rows …
bmjcoding Nov 24, 2026
e8b895d
The bare stack is written: a stack with no lines is dressed bare and …
bmjcoding Nov 24, 2026
dd7ca44
Ruling 1: 5.1's first list is an error, said once, and the figure dra…
bmjcoding Nov 24, 2026
c376b40
Ruling 2: elkjs is one copy, a build input at exactly 0.12.1
bmjcoding Nov 24, 2026
b073ff0
Ruling 3: a wrapped transcript route breaks before its arrow
bmjcoding Nov 24, 2026
c817305
Ruling 4: a stacked turn's label stays with its turn, inside the group
bmjcoding Nov 24, 2026
f72bc38
Opus P5: an automatic layout whose cards change while it runs lays ou…
bmjcoding Nov 24, 2026
bf32e54
Round 66: the text sequence and the automatic architecture in the vie…
bmjcoding Nov 24, 2026
e862657
Tests for the re-check (Opus B12): the frame side, the text viewer, t…
bmjcoding Nov 24, 2026
40608be
Sizes and caps: the built skill, the diagram module's cap to its meas…
bmjcoding Nov 24, 2026
dbbce9f
A text sequence has no Clear highlight on touch (React), as documente…
bmjcoding Nov 24, 2026
ca76f33
Review tooling: shoot one step alone (--only), and a state's own view…
bmjcoding Nov 24, 2026
0f74f0e
Merge origin/main (#127 stages and DECISIONS 328, #128 versioning) in…
bmjcoding Nov 24, 2026
2ae5f41
Merge origin/main (#129: oxlint, the repo review's fixes, the safe-si…
bmjcoding Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions .agent/skills/basalt-html/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: basalt-html
description: Generate any standalone HTML page in this project, such as a report, document, mockup, dashboard or small interactive tool, so it looks and behaves like Basalt in both themes and works offline. Use whenever asked to write, draft or mock up an .html file.
description: Generate any standalone HTML page in this project (a report, document, mockup, dashboard or small tool) so it looks and behaves like Basalt in both themes and works offline. Use whenever asked to write or mock up an .html file.
---

# Basalt HTML
Expand All @@ -9,9 +9,9 @@ Standalone HTML that looks and behaves like Basalt: one file, no network, dark a

## Use it

1. Pick modules from the index below and print their usage in one call, always with core: `node .agent/skills/basalt-html/compose.mjs --usage core table status callout`. Core is the layout, type, panel and button classes every page uses. Each usage also names the modules it needs and the classes, attributes and tags that add it. `--usage` alone prints the index.
2. Write the **body** to a file such as `report.body.html`: the HTML inside `<body>`, with the classes the usage names. It may also carry `<title>` (else the first `<h1>` is the title), your own `<style>`, and head tags: `<meta name="description">`, `og:`/`twitter:` meta, `<link rel="icon" href="data:…">` or `canonical` (any other meta or link is refused); the script adds `Basalt.init()` unless your own `<script>` calls it.
3. Run `node .agent/skills/basalt-html/compose.mjs report.body.html` (writes `report.html`; `--out <page.html>` names it). It wraps the body in the doctype, meta and theme bootstrap, inlines Geist and adds the core CSS and script, only the modules your classes, attributes and tags use, and the icons you name in quotes. It prints what it added, and one warning line for each module added. `--no-fonts` skips Geist (only for a file a tool reads, never a file a person opens), `--lang fr` sets the language, `--all` adds every module.
1. Pick modules from the index below and print their usage in one call, always with core: `node .agent/skills/basalt-html/compose.mjs --usage core table status callout`. Core is the classes every page uses. Each usage also names the modules it needs and the markup that adds it. `--usage` alone prints the index.
2. Write the **body** to a file such as `report.body.html`: the HTML inside `<body>`, with the classes the usage names. It may carry `<title>` (else the first `<h1>`), your own `<style>`, and head tags: `<meta name="description">`, `og:`/`twitter:` meta, `<link rel="icon" href="data:…">` or `canonical` (no other meta or link); the script adds `Basalt.init()` unless your `<script>` calls it.
3. Run `node .agent/skills/basalt-html/compose.mjs report.body.html` (writes `report.html`; `--out <page.html>` names it). It adds the doctype, meta and theme bootstrap, Geist inlined, the core, only the modules your markup uses, and the icons you name in quotes. It prints what it added, and one warning line for each module added. `--no-fonts` skips Geist (only for a file a tool reads, never a file a person opens), `--lang fr` sets the language, `--all` adds every module.
4. Open the page in both themes at 1440 and 390 wide before you hand it over. It follows the system theme; the toggle or `Basalt.toggleTheme()` switches it.

**Data you did not write** (a file, an API, a user) goes in as `textContent`; a link from it passes `Basalt.safeHref` (relative, http, https, mailto, tel); an option comes from a fixed list. Never into markup, a `<script>`, `style` or an `on…` attribute.
Expand All @@ -20,7 +20,7 @@ Standalone HTML that looks and behaves like Basalt: one file, no network, dark a

## Modules

Markup built only at run time (a `.row` your script writes) won't be seen: add `<!-- basalt:use rows -->` to the body.
Markup your script builds (a `.row`) isn't seen: add `<!-- basalt:use rows -->` to the body.

- **core** `.page`, `.stack`, `.panel`, `.card`, `.btn`: always in; print its usage too.
- **glyph** `data-glyph`: Basalt's own glyph by name, never drawn by hand; filled inside `aria-current`.
Expand Down Expand Up @@ -67,6 +67,9 @@ Markup built only at run time (a `.row` your script writes) won't be seen: add `
- **chart** `.chart`: JSON in `script[data-chart]`; `null` is a day not observed, never zero; needs a `summary`.
- **diagram** `.diagram`: JSON in `script[data-diagram]`; sides only to change the default; needs a `summary`.
- **diagram-motion** `"motion": "animated"`: added for you, with `loops`; a flow line needs a label; one mover a figure.
- **diagram-zoom** `.diagram`: added for you, with `dialog`; `"zoom": false` drops Expand.
- **diagram-export** `"export": true`: added for you; SVG and PNG downloads in the foot.
- **diagram-text** `"variant": "text"`: added for you; a sequence in box-drawing art, else its transcript.
- **sparkline** `.sparkline`: JSON in `script[data-sparkline]`; one line, no axes or series (that is a `chart`).
- **palette** `data-open-palette`, `Basalt.init({ palette })`: `keys` is an array, `['⌘', 'S']`: ⌘, ⌃ or ⌥ plus one key.
- **command-list** `.command-list`: the script builds it; items are the palette's; ⌘K goes to the palette when the page has one.
Expand All @@ -93,7 +96,7 @@ Markup built only at run time (a `.row` your script writes) won't be seen: add `
- **release** `.release`: only from `tools/changelog/skill-body.mjs`; never `hidden` on a fold.
- **tab-bar** `.tab-bar`: three to five links, glyph over label; with more, four and a More sheet.

Your own CSS goes in a `<style>` in the body (moved to the head, after Basalt's), using `--basalt-*` tokens only. Element selectors (`a`, `button`, `table`, `h1`) go in `@layer reset { }`, so they never beat a Basalt class; class rules can sit unlayered. Basalt's classes are in `@layer basalt`, so any unlayered rule of yours wins without `!important`. Never restyle a Basalt class from an element rule.
Your CSS goes in a body `<style>` (moved after Basalt's), with `--basalt-*` tokens only. Element selectors (`a`, `button`, `h1`) go in `@layer reset { }`, so they never beat a Basalt class; class rules can sit unlayered. Basalt's classes are in `@layer basalt`, so any unlayered rule of yours wins without `!important`. Never restyle a Basalt class from an element rule.

## Rules

Expand All @@ -102,10 +105,10 @@ Your own CSS goes in a `<style>` in the body (moved to the head, after Basalt's)
- **Levels, rim, nesting.** A panel (`.panel`, `.card`, `.callout`, `.code`, `.table-wrap`) is one level above what holds it, capped at 3, with a 1px rim and no shadow. Level is position, not importance: a hero is level 1. Group with space and dividers first; a panel is for a distinct object; at most one panel deep. Only things that leave the flow (menu, popover, dialog) take `.float` and a shadow.
- **Keys.** No single-character shortcuts on the page (WCAG 2.1.4): a shortcut needs ⌘, ⌃ or ⌥.
- **Selected** is a shape or weight, never a wash alone: a segment or tab label at 600 (400 at rest) on its pill or underline, a row's filled background, a checked box. No vertical bar; an outline never marks a state.
- **Both themes, always.** WCAG 2.2 AA: 4.5:1 text, 3:1 boundaries, focus and icons (the tokens pass; do not invent colours).
- **Motion** from the tokens only; entries ease out, nothing bounces or overshoots; under reduced motion, opacity only. A press is a colour step; only `.btn` scales (`--usage core`).
- **390px wide** must work: no sideways scroll, touch targets at least 44px (standalone links too: `--usage core`), inputs 16px (the CSS does it on coarse pointers). Don't hide a column to make a table fit.
- **No** CDN, framework, web font request, glow, gradient, dot grid, outer frame around the page, bounce, press scale beyond `.btn`'s .98, red fill, or decorative colour. Danger is red text with a red hairline.
- **Brand SVG file** (from `brand/`): paste it with `data-brand` on its `<svg>`; compose hides it and drops its title. The link round it needs `aria-label`.
- **Both themes, always.** WCAG 2.2 AA: 4.5:1 text, 3:1 boundaries, focus and icons (the tokens pass; add no colours).
- **Motion** from the tokens only; entries ease out, nothing overshoots; under reduced motion, opacity only. A press is a colour step; only `.btn` scales (`--usage core`).
- **390px wide** must work: no sideways scroll, touch targets at least 44px (standalone links too: `--usage core`), inputs 16px on touch (the CSS does it). Never hide a column to make a table fit.
- **No** CDN, framework, web font request, glow, gradient, dot grid, page frame, bounce, press scale beyond `.btn`'s .98, red fill, or decorative colour. Danger is red text with a red hairline.
- **Brand SVG file** (from `brand/`): paste it with `data-brand` on its `<svg>`; compose hides it and drops its title; its link needs `aria-label`.
- **A dot between words** is `.dot-sep`, never an `aria-hidden` dot with a hidden comma; a value and its unit need a space (`--usage core`).
- Icons: Phosphor Bold via `<i data-icon="Name"></i>`, 16px (`data-size="20"` beside 18 to 24px text). Available: Command, Option, Control, Sun, Moon, Info, Warning, ArrowRight, ArrowLeft, ArrowUp, ArrowDown, CaretUpDown, Trash, Download, ArrowClockwise, CheckCircle, XCircle, MinusCircle, Prohibit, GithubLogo, XLogo, LinkedinLogo, InstagramLogo, YoutubeLogo, EnvelopeSimple, TerminalWindow. Check, close, chevrons, copy, plus, minus, search: core glyphs (`data-glyph`), not icons. A script that names one writes it as a quoted string (`icon: 'Trash'`). Need another icon? Add its name to tools/html-skill/src/icons.json and rebuild. Never draw one, never use an emoji.
53 changes: 48 additions & 5 deletions .agent/skills/basalt-html/compose.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import vm from "node:vm";
import { MessageChannel, receiveMessageOnPort, Worker } from "node:worker_threads";

const here = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -581,7 +582,12 @@ export function compose(body, { fonts = true, lang = "en", all = false, parts =

// Detection reads markup and code, never comments: a word written about in a comment (an HTML one, or one inside a script or a style) brings nothing in.
const code = `${held.restore(markup, true)}\n${styles.map((style) => stripCssComments(style.css)).join("\n")}`;
const chosen = detect(code, manifest, Object.keys(iconFile.icons), { all, use, glyphNames: Object.keys(glyphFile) });
let chosen = detect(code, manifest, Object.keys(iconFile.icons), { all, use, glyphNames: Object.keys(glyphFile) });
// The diagram viewer (DECISIONS 310): a page with a figure has "Expand" and its dialog, unless every figure on it says "zoom": false. A figure drawn from
// script (Basalt.diagram) may want it, so it counts.
if (chosen.modules.includes("diagram") && !chosen.modules.includes("diagram-zoom") && "diagram-zoom" in manifest.modules && zoomWanted(held, code)) {
chosen = detect(code, manifest, Object.keys(iconFile.icons), { all, use: [...use, "diagram-zoom"], glyphNames: Object.keys(glyphFile) });
}
// A module the body never triggers, which is in only because another module's script builds its markup (the palette's rows and key chips).
const bare = { ...manifest, modules: Object.fromEntries(Object.entries(manifest.modules).map(([n, m]) => [n, { ...m, requires: [] }])) };
const direct = detect(code, bare, [], { all, use }).modules;
Expand Down Expand Up @@ -630,6 +636,30 @@ export function compose(body, { fonts = true, lang = "en", all = false, parts =
return { html, modules: chosen.modules, icons: chosen.icons, glyphs: chosen.glyphs, built, external: externalReferences(held, markup), diagrams: diagramNotes, bytes: Buffer.byteLength(html) };
}

/**
* An automatic diagram's placement for both directions (DECISIONS 306, 1.8), from parts/diagram-place.mjs run in a worker, waited for here: elk answers with
* a promise and compose is synchronous, so this thread sleeps on a shared flag until the worker has posted its answer and woken it.
*/
function placeNow(parts, spec) {
const signal = new SharedArrayBuffer(4);
const { port1, port2 } = new MessageChannel();
const worker = new Worker(path.join(parts, "diagram-place.mjs"), { workerData: { spec, port: port2, signal }, transferList: [port2] });
Atomics.wait(new Int32Array(signal), 0, 0, 60_000);
const got = receiveMessageOnPort(port1)?.message;
worker.terminate();
port1.close();
if (!got || got.error) throw new Error(got?.error ?? "the placer did not answer");
return got.placement;
}

/** Whether any figure on the page keeps its viewer: a `data-diagram` JSON without `"zoom": false`, or a figure drawn from script. */
function zoomWanted(held, code) {
if (/Basalt\s*\.\s*diagram\b/.test(code)) return true;
const specs = held.saved.filter((item) => item.kind === "script" && item.attrs.some(([k]) => k === "data-diagram"));
if (!specs.length) return true;
return specs.some((item) => { try { return JSON.parse(item.inner).zoom !== false; } catch { return true; } });
}

/**
* A diagram's words, written into the page (DECISIONS 281, 1.19): each `<figure class="diagram">` that holds only its JSON gets the markup the diagram module's
* script would write for it, from that same script (parts/diagram.js, run here without a page), so the page reads before any script runs. The figure's own
Expand Down Expand Up @@ -661,11 +691,24 @@ function writeDiagrams(markup, held, parts, notes, marks) {
try { spec = JSON.parse(item.inner); } catch (e) { notes.push(`a diagram's JSON does not parse (${e.message}); the page's script will say so`); continue; }
// Each card's mark: a bundled id is checked and its rule written once; the page's own mark is read into the page and named by an id, so the JSON
// the script reads carries the id and never a path.
if (spec && spec.type === "architecture" && Array.isArray(spec.nodes)) {
// An automatic figure (DECISIONS 306, 1.8) is placed here, at build time, for both directions; the page holds the placement and never elkjs.
if (spec && spec.layout === "auto" && !spec.placement && ["architecture", "flowchart", "schema"].includes(spec.type)) {
try {
spec.placement = placeNow(parts, spec);
const inner = `\n${JSON.stringify(spec).replace(/</g, "\\u003c")}\n`;
item.text = item.text.replace(item.inner, () => inner);
item.inner = inner;
} catch (e) { notes.push(`${spec.title ?? "a diagram"} could not be placed (${String(e.message).split("\n")[0]}); it is stacked`); }
}
// An architecture's cards, a data flow's steps and a sequence's participants may carry one (DECISIONS 306, 1.6).
const cards = spec && (spec.type === "architecture" || spec.type === "data-flow") ? spec.nodes : spec && spec.type === "sequence" ? spec.participants : null;
if (Array.isArray(cards)) {
let rewrote = false;
for (const n of spec.nodes) {
for (const n of cards) {
if (!n || n.mark === undefined || n.mark === null) continue;
if (typeof n.mark === "string") useMark(marks, n.mark, n, notes);
// A data flow's step counts its lane's label as its words, as React's check does (DECISIONS 306, 1.6; Neon's B10 of the code review).
const lane = spec.type === "data-flow" && Array.isArray(spec.lanes) ? spec.lanes.find((l) => l && l.id === n.lane) : null;
if (typeof n.mark === "string") useMark(marks, n.mark, lane ? { ...n, laneLabel: lane.label } : n, notes);
else { n.mark = ownMark(marks, n.mark); rewrote = true; }
}
if (rewrote) {
Expand Down Expand Up @@ -715,7 +758,7 @@ function useMark(marks, id, node, notes) {
}
function checkSays(file, id, node, notes) {
const says = (Object.hasOwn(file.says, id) ? file.says[id] : undefined) ?? [];
const words = [node.name, node.kind, node.detail].filter(Boolean).join(" ").toLowerCase();
const words = [node.name, node.kind, node.detail, node.laneLabel].filter(Boolean).join(" ").toLowerCase();
if (says.length && !says.some((w) => words.includes(w.toLowerCase()))) notes.push(`${node.id}'s mark (${id}) stands for ${says.join(" or ")}, and none of its words say so: a mark never carries a fact alone`);
}

Expand Down
Loading
Loading