diff --git a/.agent/skills/basalt-html/SKILL.md b/.agent/skills/basalt-html/SKILL.md index 813edaf1..b77fc4e7 100644 --- a/.agent/skills/basalt-html/SKILL.md +++ b/.agent/skills/basalt-html/SKILL.md @@ -62,6 +62,7 @@ Markup built only at run time (a `.row` your script writes) won't be seen: add ` - **period** `.period`: two ghost icon buttons round `.period-label`; at an end `aria-disabled`, never `disabled`. - **terminal** `.terminal`: with `.code`; lines are `span[data-kind]`; the script draws the gutter. - **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`. - **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. diff --git a/.agent/skills/basalt-html/compose.mjs b/.agent/skills/basalt-html/compose.mjs index 272b537a..f3d8550c 100644 --- a/.agent/skills/basalt-html/compose.mjs +++ b/.agent/skills/basalt-html/compose.mjs @@ -28,6 +28,7 @@ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import vm from "node:vm"; const here = path.dirname(fileURLToPath(import.meta.url)); @@ -303,7 +304,7 @@ export function readBody(body, stats = {}) { const placeholder = new RegExp(`${mark}(\\d+)${mark}(\\s*)`, "g"); const blank = (item) => { let text = item.text; for (const [a, b] of [...item.comments].reverse()) text = text.slice(0, a) + " " + text.slice(b); return text; }; return { - text: out, saved, scripts, placeholder, whole, h1: h1 && !h1.open ? h1.text.trim() : null, + text: out, saved, scripts, placeholder, mark, whole, h1: h1 && !h1.open ? h1.text.trim() : null, // The text put back; with `bare`, as detection reads it: no comment (an HTML one, or one in a nested element, or in a script). restore: (s, bare = false) => s.replace(placeholder, (_, k, ws) => { const item = saved[Number(k)]; @@ -539,7 +540,8 @@ export function compose(body, { fonts = true, lang = "en", all = false, parts = }); for (const name of use) if (!(name in manifest.modules)) throw new Error(`basalt:use names "${name}", which is not a module (modules: ${Object.keys(manifest.modules).join(", ")})`); - const content = held.restore(markup).replace(/^\s+/, ""); + const diagramNotes = []; + const content = held.restore(writeDiagrams(markup, held, parts, diagramNotes)).replace(/^\s+/, ""); title ||= held.h1 || "Untitled page"; // an empty