@phnx-labs/artifacts-cli 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +75 -14
- package/dist/cli.js +25 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/new.js +2 -0
- package/dist/commands/new.js.map +1 -1
- package/dist/lib/agent-assets.d.ts +1 -0
- package/dist/lib/agent-assets.js +15 -0
- package/dist/lib/agent-assets.js.map +1 -0
- package/dist/lib/collab.d.ts +61 -0
- package/dist/lib/collab.js +714 -0
- package/dist/lib/collab.js.map +1 -0
- package/dist/lib/creator-cover.d.ts +7 -0
- package/dist/lib/creator-cover.js +68 -0
- package/dist/lib/creator-cover.js.map +1 -0
- package/dist/lib/fonts.d.ts +3 -0
- package/dist/lib/fonts.js +68 -12
- package/dist/lib/fonts.js.map +1 -1
- package/dist/lib/freshness.d.ts +6 -0
- package/dist/lib/freshness.js +52 -0
- package/dist/lib/freshness.js.map +1 -0
- package/dist/lib/highlights.d.ts +11 -1
- package/dist/lib/highlights.js +38 -71
- package/dist/lib/highlights.js.map +1 -1
- package/dist/lib/icons.js +2 -1
- package/dist/lib/icons.js.map +1 -1
- package/dist/lib/reader-anchors.d.ts +16 -0
- package/dist/lib/reader-anchors.js +146 -0
- package/dist/lib/reader-anchors.js.map +1 -0
- package/dist/lib/render.js +337 -38
- package/dist/lib/render.js.map +1 -1
- package/dist/lib/section-collapse.d.ts +17 -0
- package/dist/lib/section-collapse.js +113 -0
- package/dist/lib/section-collapse.js.map +1 -0
- package/dist/lib/templates.d.ts +5 -3
- package/dist/lib/templates.js +19 -4
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/tokens.d.ts +2 -0
- package/dist/lib/tokens.js +5 -1
- package/dist/lib/tokens.js.map +1 -1
- package/dist/lib/validate.js +28 -1
- package/dist/lib/validate.js.map +1 -1
- package/fonts/Inter-OFL.txt +92 -0
- package/fonts/InterVariable.woff2 +0 -0
- package/fonts/JetBrainsMono-OFL.txt +93 -0
- package/fonts/JetBrainsMono-wght.woff2 +0 -0
- package/fonts/README.md +16 -0
- package/package.json +4 -1
package/dist/lib/render.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { execFile } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
3
4
|
import { basename, dirname, extname, resolve } from 'node:path';
|
|
4
5
|
import { promisify } from 'node:util';
|
|
5
6
|
import { Marked } from 'marked';
|
|
@@ -10,13 +11,29 @@ import { loadDesign } from './design.js';
|
|
|
10
11
|
import { EMBEDDED_ARTIFACT_CLASSES, EMBEDDED_BLOCK_PATTERN, isSupportedSvgAnimationTarget, readEmbeddedBlock, } from './embedded-html.js';
|
|
11
12
|
import { resolveFonts } from './fonts.js';
|
|
12
13
|
import { escapeHtml, unescapeHtml } from './html.js';
|
|
14
|
+
import { BODY_REVISION_META, COLLAB_SCRIPT, bodyRevision } from './collab.js';
|
|
13
15
|
import { HIGHLIGHTS_SCRIPT } from './highlights.js';
|
|
16
|
+
import { READER_ANCHORS_SCRIPT } from './reader-anchors.js';
|
|
17
|
+
import { SECTION_COLLAPSE_SCRIPT } from './section-collapse.js';
|
|
14
18
|
import { linkIconHtml } from './icons.js';
|
|
19
|
+
import { COVER_CSS, coverArtwork, coverClass, creatorFavicon, creatorId, creatorMark } from './creator-cover.js';
|
|
20
|
+
import { artifactTimestamp, FRESHNESS_SCRIPT } from './freshness.js';
|
|
21
|
+
import { knownProjects } from './templates.js';
|
|
15
22
|
import { collectReferences, parseArtifactLinks, referencesHtml, transformLinkPills } from './links.js';
|
|
16
23
|
import { validateMarkdown } from './validate.js';
|
|
17
24
|
import { parseWorksheet, renderFieldCard, renderRowsGroup } from './worksheet.js';
|
|
18
25
|
const execFileAsync = promisify(execFile);
|
|
19
26
|
const ARTIFACT_SOURCE_ID = 'artifacts-source';
|
|
27
|
+
// The single canonical live-reload marker: a SHA-256 over the WHOLE finished
|
|
28
|
+
// document (body plus every metadata surface), so any re-render change — content
|
|
29
|
+
// or metadata-only — flips it. Computed by hashing the document with this fixed
|
|
30
|
+
// placeholder standing in for the value, then substituting the real digest, so
|
|
31
|
+
// the hash never has to include itself. The loopback reload poll (reloadScript)
|
|
32
|
+
// and the collab body-revision (collab.ts) are deliberately separate concerns:
|
|
33
|
+
// body-revision is body-only so a comment stays anchored across a metadata edit,
|
|
34
|
+
// while this marker must notice exactly those metadata edits.
|
|
35
|
+
const CONTENT_HASH_META = 'artifacts-content-hash';
|
|
36
|
+
const CONTENT_HASH_PLACEHOLDER = '__ARTIFACTS_CONTENT_HASH__';
|
|
20
37
|
// Marks a heading that came from Markdown, so it can be told apart from an <h2>
|
|
21
38
|
// an author wrote inside an embedded block. A private-use character rather than
|
|
22
39
|
// an attribute: an attribute would have to be allowlisted through the sanitizer,
|
|
@@ -110,6 +127,12 @@ const HARNESS_PRODUCT_NAMES = {
|
|
|
110
127
|
droid: 'Droid',
|
|
111
128
|
antigravity: 'Antigravity',
|
|
112
129
|
kimi: 'Kimi',
|
|
130
|
+
opencode: 'OpenCode',
|
|
131
|
+
openclaw: 'OpenClaw',
|
|
132
|
+
hermes: 'Hermes',
|
|
133
|
+
muse: 'Muse',
|
|
134
|
+
warp: 'Warp',
|
|
135
|
+
pi: 'Pi',
|
|
113
136
|
};
|
|
114
137
|
/**
|
|
115
138
|
* Single human-facing agent string: product + model (e.g. "Grok 4.5"),
|
|
@@ -122,7 +145,7 @@ export function agentDisplayName(harness, agent) {
|
|
|
122
145
|
return '';
|
|
123
146
|
if (!h)
|
|
124
147
|
return a;
|
|
125
|
-
const product = HARNESS_PRODUCT_NAMES[h.toLowerCase()]
|
|
148
|
+
const product = (Object.hasOwn(HARNESS_PRODUCT_NAMES, h.toLowerCase()) ? HARNESS_PRODUCT_NAMES[h.toLowerCase()] : undefined)
|
|
126
149
|
?? (h.charAt(0).toUpperCase() + h.slice(1));
|
|
127
150
|
if (!a)
|
|
128
151
|
return product;
|
|
@@ -133,6 +156,14 @@ export function agentDisplayName(harness, agent) {
|
|
|
133
156
|
return `${product} ${stripped}`;
|
|
134
157
|
return `${product} ${a}`;
|
|
135
158
|
}
|
|
159
|
+
/** Cap the project prefix used in the browser <title> so a long/dotted/dashed
|
|
160
|
+
* project name can never push the artifact's own topic out of the tab. The hero
|
|
161
|
+
* still shows the project verbatim; only the tab prefix is bounded. */
|
|
162
|
+
function boundedTitlePrefix(project, max = 24) {
|
|
163
|
+
const trimmed = project.trim();
|
|
164
|
+
const points = [...trimmed];
|
|
165
|
+
return points.length > max ? `${points.slice(0, max - 1).join('').trimEnd()}…` : trimmed;
|
|
166
|
+
}
|
|
136
167
|
function metadataValue(value) {
|
|
137
168
|
if (value instanceof Date)
|
|
138
169
|
return value.toISOString().slice(0, 10);
|
|
@@ -145,6 +176,24 @@ function repositoryHref(repository) {
|
|
|
145
176
|
? `https://github.com/${repository}`
|
|
146
177
|
: undefined;
|
|
147
178
|
}
|
|
179
|
+
/** The bare project name from an `owner/repo` (or plain) repository string. */
|
|
180
|
+
function repositoryBasename(repository) {
|
|
181
|
+
return repository.split('/').filter(Boolean).at(-1) || '';
|
|
182
|
+
}
|
|
183
|
+
/** Explicit author dates, otherwise the source mtime; never the render time. */
|
|
184
|
+
function buildTimestamps(data, sourceMtimeIso) {
|
|
185
|
+
const stamp = (label, value) => ({ label, ...value, display: value.iso.slice(0, 10) });
|
|
186
|
+
const created = artifactTimestamp(data.created);
|
|
187
|
+
const updated = artifactTimestamp(data.updated);
|
|
188
|
+
const stamps = [];
|
|
189
|
+
if (created)
|
|
190
|
+
stamps.push(stamp('Created', created));
|
|
191
|
+
if (updated)
|
|
192
|
+
stamps.push(stamp('Updated', updated));
|
|
193
|
+
else if (sourceMtimeIso)
|
|
194
|
+
stamps.push(stamp('Source updated', { iso: sourceMtimeIso, relative: true }));
|
|
195
|
+
return stamps;
|
|
196
|
+
}
|
|
148
197
|
/**
|
|
149
198
|
* A deep link that resumes this session. Clicking it hands the URL to the OS,
|
|
150
199
|
* which routes it to the registered `agents open` handler (agents-cli) — the CLI
|
|
@@ -156,36 +205,48 @@ function sessionDeepLink(id) {
|
|
|
156
205
|
const trimmed = id.trim();
|
|
157
206
|
return trimmed ? `agents://session/${encodeURIComponent(trimmed)}` : undefined;
|
|
158
207
|
}
|
|
159
|
-
function artifactMetadata(data) {
|
|
208
|
+
function artifactMetadata(data, sourceMtimeIso = '') {
|
|
160
209
|
const field = (name) => metadataValue(data[name]);
|
|
161
210
|
const facts = Array.isArray(data.facts)
|
|
162
211
|
? data.facts.map(metadataValue).filter(Boolean)
|
|
163
212
|
: [];
|
|
164
213
|
const repository = field('repository');
|
|
165
214
|
const branch = field('branch');
|
|
166
|
-
const harness = field('harness');
|
|
215
|
+
const harness = creatorId(field('harness'));
|
|
167
216
|
const agent = field('agent');
|
|
168
217
|
const agentLabel = agentDisplayName(harness, agent);
|
|
169
218
|
const { links } = parseArtifactLinks(data.links);
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
219
|
+
// The project the artifact is *about* — prominent, and linked when we can point
|
|
220
|
+
// somewhere honest. An explicit project wins; otherwise fall back to the
|
|
221
|
+
// repository's bare name (the render-layer fallback; project detection itself
|
|
222
|
+
// lives in templates.ts and is out of scope here). The link is an explicit
|
|
223
|
+
// `projectUrl` when it is HTTP(S), else the repository's own GitHub page.
|
|
224
|
+
const projectId = field('project');
|
|
225
|
+
const registered = projectId ? knownProjects().filter((project) => project.name === projectId) : [];
|
|
226
|
+
const known = registered.length === 1 ? registered[0] : undefined;
|
|
227
|
+
const projectValue = known?.displayName || projectId || repositoryBasename(repository);
|
|
228
|
+
const projectUrl = field('projectUrl');
|
|
229
|
+
const projectHref = (/^https?:\/\//i.test(projectUrl) ? projectUrl : undefined)
|
|
230
|
+
?? known?.url ?? repositoryHref(repository || known?.repo || '');
|
|
231
|
+
const project = projectValue ? { value: projectValue, href: projectHref } : null;
|
|
174
232
|
return {
|
|
175
|
-
|
|
233
|
+
project,
|
|
234
|
+
kind: field('kind') || field('context'),
|
|
176
235
|
status: field('status'),
|
|
236
|
+
creator: { agent: agentLabel, harness, human: field('human') },
|
|
237
|
+
timestamps: buildTimestamps(data, sourceMtimeIso),
|
|
177
238
|
facts,
|
|
178
239
|
links: links.map((link) => ({
|
|
179
240
|
value: link.label,
|
|
180
241
|
href: link.url,
|
|
181
242
|
icon: linkIconHtml(link.url),
|
|
182
243
|
})),
|
|
244
|
+
// The long tail — everything a reader rarely needs at a glance. Folded behind
|
|
245
|
+
// a <details> in the hero. Creator and freshness moved up to their own lines.
|
|
183
246
|
provenance: [
|
|
184
247
|
repository ? { value: repository, href: repositoryHref(repository) } : undefined,
|
|
185
248
|
branch ? { value: branch } : undefined,
|
|
186
249
|
field('tracking') ? { value: field('tracking') } : undefined,
|
|
187
|
-
agentLabel ? { value: agentLabel } : undefined,
|
|
188
|
-
field('human') ? { value: field('human') } : undefined,
|
|
189
250
|
field('host') ? { value: field('host') } : undefined,
|
|
190
251
|
field('session') ? { value: field('session'), href: sessionDeepLink(field('sessionId') || field('session')) } : undefined,
|
|
191
252
|
field('date') ? { value: field('date') } : undefined,
|
|
@@ -204,11 +265,44 @@ function statusBadge(status) {
|
|
|
204
265
|
const slug = slugify(status) || 'unknown';
|
|
205
266
|
return `<span class="status-badge status-${escapeHtml(slug)}">${escapeHtml(status)}</span>`;
|
|
206
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* The eyebrow above the title. The project comes first and prominent — linked
|
|
270
|
+
* when a URL is known — followed by the kind, then the status badge. An artifact
|
|
271
|
+
* with no project or kind still shows a stable "Artifact" label.
|
|
272
|
+
*/
|
|
207
273
|
function kickerHtml(metadata) {
|
|
208
|
-
const parts =
|
|
209
|
-
|
|
210
|
-
.
|
|
211
|
-
|
|
274
|
+
const parts = [];
|
|
275
|
+
if (metadata.kind)
|
|
276
|
+
parts.push(`<span class="kicker-part">${escapeHtml(metadata.kind)}</span>`);
|
|
277
|
+
if (!parts.length)
|
|
278
|
+
parts.push(`<span class="kicker-part">Artifact</span>`);
|
|
279
|
+
return `<div class="kicker">${parts.join('<span class="kicker-separator" aria-hidden="true">·</span>')}${statusBadge(metadata.status)}</div>`;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The compact "who made this, and how fresh is it" line under the title: the
|
|
283
|
+
* agent's brand mark + product name, the human, then the truthful freshness
|
|
284
|
+
* stamps. Date-only values stay absolute; precise instants gain relative text.
|
|
285
|
+
*/
|
|
286
|
+
function creatorLine(metadata) {
|
|
287
|
+
const parts = [];
|
|
288
|
+
const { human } = metadata.creator;
|
|
289
|
+
if (human)
|
|
290
|
+
parts.push(`<span class="creator-human">${escapeHtml(human)}</span>`);
|
|
291
|
+
for (const time of metadata.timestamps) {
|
|
292
|
+
parts.push(`<time class="creator-time" datetime="${escapeHtml(time.iso)}" title="${escapeHtml(time.label + ' ' + time.iso)}" data-label="${escapeHtml(time.label)}" data-relative="${time.relative}">${escapeHtml(time.label)} ${escapeHtml(time.display)}</time>`);
|
|
293
|
+
}
|
|
294
|
+
if (!parts.length)
|
|
295
|
+
return '';
|
|
296
|
+
return `<p class="creator-line" aria-label="Creator and freshness">${parts.join('<span class="meta-sep" aria-hidden="true">·</span>')}</p>`;
|
|
297
|
+
}
|
|
298
|
+
function coverTop(metadata) {
|
|
299
|
+
const { agent, harness } = metadata.creator;
|
|
300
|
+
const producer = `<div class="cover-creator creator-agent">${creatorMark(harness)}<span>${escapeHtml(agent || 'Artifact')}</span></div>`;
|
|
301
|
+
const project = metadata.project;
|
|
302
|
+
const home = !project ? '' : project.href
|
|
303
|
+
? `<a class="cover-project kicker-project" href="${escapeHtml(project.href)}" title="${escapeHtml(project.value)}" target="_blank" rel="noopener">${escapeHtml(project.value)}<span aria-hidden="true">↗</span></a>`
|
|
304
|
+
: `<span class="cover-project kicker-project">${escapeHtml(project.value)}</span>`;
|
|
305
|
+
return `<div class="cover-top">${producer}${home}</div>`;
|
|
212
306
|
}
|
|
213
307
|
function factsLine(facts) {
|
|
214
308
|
if (!facts.length)
|
|
@@ -235,11 +329,21 @@ function provenanceLine(parts) {
|
|
|
235
329
|
});
|
|
236
330
|
return `<p class="provenance-line" aria-label="Provenance">${items.join('<span class="meta-sep" aria-hidden="true">·</span>')}</p>`;
|
|
237
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* The long provenance tail — repository, branch, tracking, host, session, date —
|
|
334
|
+
* folded behind a disclosure so the hero stays scannable. Print events open it
|
|
335
|
+
* and restore the reader's state afterward, so a PDF never drops provenance.
|
|
336
|
+
*/
|
|
337
|
+
function provenanceDetails(parts) {
|
|
338
|
+
if (!parts.length)
|
|
339
|
+
return '';
|
|
340
|
+
return `<details class="provenance-details"><summary>Details</summary>${provenanceLine(parts)}</details>`;
|
|
341
|
+
}
|
|
238
342
|
function metadataBlock(metadata) {
|
|
239
343
|
const body = [
|
|
240
344
|
factsLine(metadata.facts),
|
|
241
345
|
linksBlock(metadata.links),
|
|
242
|
-
|
|
346
|
+
provenanceDetails(metadata.provenance),
|
|
243
347
|
].filter(Boolean).join('');
|
|
244
348
|
return body ? `<div class="meta" aria-label="Artifact metadata">${body}</div>` : '';
|
|
245
349
|
}
|
|
@@ -270,6 +374,16 @@ function inlineLocalAssets(html, baseDir, diagnostics) {
|
|
|
270
374
|
return ` src="data:${mimeFor(path)};base64,${data}"`;
|
|
271
375
|
});
|
|
272
376
|
}
|
|
377
|
+
/** The source file's last-modified instant as ISO 8601, or '' when it cannot be
|
|
378
|
+
* stat'd. The honest fallback for freshness when no explicit `updated:` exists. */
|
|
379
|
+
function fileMtimeIso(path) {
|
|
380
|
+
try {
|
|
381
|
+
return statSync(path).mtime.toISOString();
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
return '';
|
|
385
|
+
}
|
|
386
|
+
}
|
|
273
387
|
export function slugify(text) {
|
|
274
388
|
return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
275
389
|
}
|
|
@@ -355,6 +469,128 @@ function addHeadingIds(html) {
|
|
|
355
469
|
}
|
|
356
470
|
return { html: out + html.slice(cursor), entries };
|
|
357
471
|
}
|
|
472
|
+
const ID_ATTRIBUTE = /\sid="([^"]*)"/g;
|
|
473
|
+
/** Every id already present in the document, so a generated one never collides with an authored one. */
|
|
474
|
+
function collectExistingIds(html) {
|
|
475
|
+
const ids = new Set();
|
|
476
|
+
let match;
|
|
477
|
+
ID_ATTRIBUTE.lastIndex = 0;
|
|
478
|
+
while ((match = ID_ATTRIBUTE.exec(html)) !== null)
|
|
479
|
+
ids.add(match[1]);
|
|
480
|
+
return ids;
|
|
481
|
+
}
|
|
482
|
+
/** The section-body id for a heading, numbered past any collision with an existing id (authored or generated). */
|
|
483
|
+
function uniqueBodyId(headingId, taken) {
|
|
484
|
+
const base = `section-body-${headingId}`;
|
|
485
|
+
let id = base;
|
|
486
|
+
let suffix = 2;
|
|
487
|
+
while (taken.has(id)) {
|
|
488
|
+
id = `${base}-${suffix}`;
|
|
489
|
+
suffix += 1;
|
|
490
|
+
}
|
|
491
|
+
taken.add(id);
|
|
492
|
+
return id;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Locates each top-level section heading's exact tag span (from `<h2`/`<h3` to
|
|
496
|
+
* its closing tag) in the final HTML, in document order. Matched by id and
|
|
497
|
+
* searched forward from the previous match, so a heading elsewhere in the
|
|
498
|
+
* document that happens to reuse the same id — an author's own raw `<h2 id=…>`,
|
|
499
|
+
* or an embedded panel caption — can never shadow the real section. Each span
|
|
500
|
+
* also carries a section-body id guaranteed not to collide with any id already
|
|
501
|
+
* in the document, authored or generated.
|
|
502
|
+
*/
|
|
503
|
+
function findHeadingSpans(html, entries) {
|
|
504
|
+
const spans = [];
|
|
505
|
+
const takenIds = collectExistingIds(html);
|
|
506
|
+
let cursor = 0;
|
|
507
|
+
for (const entry of entries) {
|
|
508
|
+
const markerIndex = html.indexOf(`id="${entry.id}"`, cursor);
|
|
509
|
+
if (markerIndex === -1)
|
|
510
|
+
continue;
|
|
511
|
+
const tagStart = html.lastIndexOf('<', markerIndex);
|
|
512
|
+
const tagOpenEnd = html.indexOf('>', markerIndex);
|
|
513
|
+
if (tagStart === -1 || tagOpenEnd === -1)
|
|
514
|
+
continue;
|
|
515
|
+
const closeTag = `</h${entry.level}>`;
|
|
516
|
+
const innerEnd = html.indexOf(closeTag, tagOpenEnd);
|
|
517
|
+
if (innerEnd === -1)
|
|
518
|
+
continue;
|
|
519
|
+
const closeEnd = innerEnd + closeTag.length;
|
|
520
|
+
spans.push({ entry, tagStart, closeEnd, bodyId: uniqueBodyId(entry.id, takenIds) });
|
|
521
|
+
cursor = closeEnd;
|
|
522
|
+
}
|
|
523
|
+
return spans;
|
|
524
|
+
}
|
|
525
|
+
/** Inserts the collapse toggle as the heading's last child, right before its closing tag. */
|
|
526
|
+
function injectSectionToggle(headingTag, span) {
|
|
527
|
+
const closeTag = `</h${span.entry.level}>`;
|
|
528
|
+
const label = escapeHtml(span.entry.text) || 'section';
|
|
529
|
+
const button = `<button type="button" class="section-toggle" aria-expanded="true" aria-controls="${escapeHtml(span.bodyId)}" aria-label="Collapse ${label} section" data-section-label="${label}" data-section-id="${escapeHtml(span.entry.id)}"></button>`;
|
|
530
|
+
return headingTag.slice(0, headingTag.length - closeTag.length) + button + closeTag;
|
|
531
|
+
}
|
|
532
|
+
// A lone `<a id="…"></a>` (optionally the sole content of its own `<p>`) sitting
|
|
533
|
+
// right before a heading, with nothing but whitespace after it — the canonical
|
|
534
|
+
// "permalink placed ahead of its heading" convention. It carries no visible
|
|
535
|
+
// content of its own, so it is treated as an alias of the heading it precedes:
|
|
536
|
+
// pulled out of the PRECEDING section's content and carried into the content of
|
|
537
|
+
// the section it actually names, so collapsing/revealing that section collapses
|
|
538
|
+
// or reveals the alias with it. An anchor that wraps real text, or one that
|
|
539
|
+
// merely follows a heading, is left exactly where it is.
|
|
540
|
+
const TRAILING_ALIAS_ANCHORS = /(?:\s*(?:<p>\s*<a id="[^"]*"><\/a>\s*<\/p>|<a id="[^"]*"><\/a>))+\s*$/;
|
|
541
|
+
/**
|
|
542
|
+
* Groups the flat sequence of top-level h2/h3 headings into a nested tree so
|
|
543
|
+
* each heading's own content — and, for an h2, its subsections — collapses as
|
|
544
|
+
* one unit. An h2 section runs to the next h2; an h3 subsection runs to the
|
|
545
|
+
* next h3 or h2, whichever comes first. Every wrapper starts expanded: a
|
|
546
|
+
* reader with JS disabled always sees the complete, unhidden document.
|
|
547
|
+
*/
|
|
548
|
+
function wrapCollapsibleSections(html, entries) {
|
|
549
|
+
const spans = findHeadingSpans(html, entries);
|
|
550
|
+
if (!spans.length)
|
|
551
|
+
return html;
|
|
552
|
+
const contents = spans.map((span, index) => {
|
|
553
|
+
const end = spans[index + 1] ? spans[index + 1].tagStart : html.length;
|
|
554
|
+
return html.slice(span.closeEnd, end);
|
|
555
|
+
});
|
|
556
|
+
let prefix = html.slice(0, spans[0].tagStart);
|
|
557
|
+
const aliases = spans.map(() => '');
|
|
558
|
+
// Extract from each original preceding slice once. Keep moved aliases apart
|
|
559
|
+
// so an empty parent cannot pass its own alias on to its first subsection.
|
|
560
|
+
for (let index = 0; index < spans.length; index += 1) {
|
|
561
|
+
const preceding = index === 0 ? prefix : contents[index - 1];
|
|
562
|
+
const match = preceding.match(TRAILING_ALIAS_ANCHORS);
|
|
563
|
+
if (!match)
|
|
564
|
+
continue;
|
|
565
|
+
aliases[index] = match[0].replace(/^\s+/, '');
|
|
566
|
+
if (index === 0)
|
|
567
|
+
prefix = preceding.slice(0, match.index);
|
|
568
|
+
else
|
|
569
|
+
contents[index - 1] = preceding.slice(0, match.index);
|
|
570
|
+
}
|
|
571
|
+
const nodes = [];
|
|
572
|
+
const stack = [];
|
|
573
|
+
for (let index = 0; index < spans.length; index += 1) {
|
|
574
|
+
const span = spans[index];
|
|
575
|
+
const node = {
|
|
576
|
+
span,
|
|
577
|
+
headingHtml: injectSectionToggle(html.slice(span.tagStart, span.closeEnd), span),
|
|
578
|
+
directContent: aliases[index] + contents[index],
|
|
579
|
+
children: [],
|
|
580
|
+
};
|
|
581
|
+
// An h3 closes any open h3 sibling; either level closes an open h3 beneath
|
|
582
|
+
// an h2. Only a strictly shallower heading stays open as the new parent.
|
|
583
|
+
while (stack.length && stack[stack.length - 1].span.entry.level >= span.entry.level)
|
|
584
|
+
stack.pop();
|
|
585
|
+
(stack.length ? stack[stack.length - 1].children : nodes).push(node);
|
|
586
|
+
stack.push(node);
|
|
587
|
+
}
|
|
588
|
+
const render = (node) => {
|
|
589
|
+
const inner = node.directContent + node.children.map(render).join('');
|
|
590
|
+
return `<div class="artifact-section" data-section="${escapeHtml(node.span.entry.id)}">${node.headingHtml}<div class="artifact-section-body" id="${escapeHtml(node.span.bodyId)}">${inner}</div></div>`;
|
|
591
|
+
};
|
|
592
|
+
return prefix + nodes.map(render).join('');
|
|
593
|
+
}
|
|
358
594
|
// Render a fenced ```diff block as a GitHub-style diff: added lines green,
|
|
359
595
|
// removed lines red, with a sign gutter. Called from the Marked code renderer,
|
|
360
596
|
// so `code` is the raw (unescaped) block text — escape each line here. The output
|
|
@@ -533,7 +769,7 @@ function sanitizeBody(html, worksheet = false) {
|
|
|
533
769
|
},
|
|
534
770
|
});
|
|
535
771
|
}
|
|
536
|
-
function shell(title, summary, header, footer, metadata, body, source, styles, defaultTheme, worksheet = null) {
|
|
772
|
+
function shell(title, summary, header, footer, metadata, body, source, styles, defaultTheme, revision, worksheet = null) {
|
|
537
773
|
const sourceJson = source
|
|
538
774
|
? `<script type="application/json" id="${ARTIFACT_SOURCE_ID}">${JSON.stringify({ encoding: 'base64', markdown: Buffer.from(source).toString('base64') })}</script>`
|
|
539
775
|
: '';
|
|
@@ -562,6 +798,16 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
562
798
|
</script>`;
|
|
563
799
|
const readerScript = `<script>
|
|
564
800
|
(() => {
|
|
801
|
+
const disclosures = [...document.querySelectorAll('.provenance-details')];
|
|
802
|
+
const printState = new Map();
|
|
803
|
+
addEventListener('beforeprint', () => disclosures.forEach((details) => {
|
|
804
|
+
if (!printState.has(details)) printState.set(details, details.open);
|
|
805
|
+
details.open = true;
|
|
806
|
+
}));
|
|
807
|
+
addEventListener('afterprint', () => {
|
|
808
|
+
printState.forEach((open, details) => { details.open = open; });
|
|
809
|
+
printState.clear();
|
|
810
|
+
});
|
|
565
811
|
// Scroll-spy: mark the section the reader is currently in. The active heading
|
|
566
812
|
// is the last one whose top has passed the reading line, so a heading is
|
|
567
813
|
// "current" from the moment it reaches the top, not when it leaves.
|
|
@@ -574,14 +820,20 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
574
820
|
let queued = false;
|
|
575
821
|
const sync = () => {
|
|
576
822
|
queued = false;
|
|
823
|
+
// A heading inside a collapsed section renders nowhere (offsetParent is
|
|
824
|
+
// null), so its rect is the zero-box the browser reports for anything
|
|
825
|
+
// not laid out — that zero top would otherwise look like "at the reading
|
|
826
|
+
// line" and win the section below it. Drop it from contention entirely.
|
|
827
|
+
const visible = targets.filter((entry) => entry.heading.offsetParent !== null);
|
|
828
|
+
if (!visible.length) return;
|
|
577
829
|
const line = 120;
|
|
578
|
-
let current =
|
|
579
|
-
for (const entry of
|
|
830
|
+
let current = visible[0];
|
|
831
|
+
for (const entry of visible) {
|
|
580
832
|
if (entry.heading.getBoundingClientRect().top <= line) current = entry;
|
|
581
833
|
else break;
|
|
582
834
|
}
|
|
583
|
-
// Past the end of the document the last section is
|
|
584
|
-
if (window.innerHeight + window.scrollY >= document.body.scrollHeight - 4) current =
|
|
835
|
+
// Past the end of the document the last visible section is being read.
|
|
836
|
+
if (window.innerHeight + window.scrollY >= document.body.scrollHeight - 4) current = visible[visible.length - 1];
|
|
585
837
|
if (!current || current.link === active) return;
|
|
586
838
|
if (active) active.classList.remove('is-active');
|
|
587
839
|
active = current.link;
|
|
@@ -595,6 +847,9 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
595
847
|
const onScroll = () => { if (!queued) { queued = true; requestAnimationFrame(sync); } };
|
|
596
848
|
addEventListener('scroll', onScroll, { passive: true });
|
|
597
849
|
addEventListener('resize', onScroll, { passive: true });
|
|
850
|
+
// A collapse/expand toggle changes which headings are laid out without
|
|
851
|
+
// necessarily firing a scroll event — resync explicitly when that happens.
|
|
852
|
+
document.addEventListener('artifacts:section-toggle', onScroll);
|
|
598
853
|
sync();
|
|
599
854
|
}
|
|
600
855
|
|
|
@@ -612,19 +867,40 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
612
867
|
} catch {}
|
|
613
868
|
})();
|
|
614
869
|
</script>`;
|
|
870
|
+
// Live-reload detection, keyed to the single canonical marker the renderer
|
|
871
|
+
// emits: <meta name="artifacts-content-hash">, hashed over the whole document,
|
|
872
|
+
// so a metadata-only re-render (a new `updated:` stamp, a changed project) is
|
|
873
|
+
// detected too. Manual by default — a new version reveals the chip rather than
|
|
874
|
+
// reloading under the reader, so an unsaved worksheet field or scroll position
|
|
875
|
+
// survives until they choose to reload.
|
|
876
|
+
//
|
|
877
|
+
// Only http(s) can be watched: a loopback dev server (`artifacts render --open`)
|
|
878
|
+
// re-renders the file on save, and a same-origin poll of this page sees the new
|
|
879
|
+
// hash. A file:// page has no server to re-serve it, so disk changes are
|
|
880
|
+
// invisible to the page; the chip stays hidden there by design.
|
|
615
881
|
const reloadScript = `<script>
|
|
616
882
|
(() => {
|
|
617
|
-
const
|
|
883
|
+
const marker = (html) => html.match(/<meta name="artifacts-content-hash" content="([^"]+)">/)?.[1] || '';
|
|
884
|
+
const current = document.querySelector('meta[name="artifacts-content-hash"]')?.content || '';
|
|
618
885
|
const chip = document.querySelector('.reload-chip');
|
|
619
|
-
if (!current || !chip
|
|
886
|
+
if (!current || !chip) return;
|
|
887
|
+
// file:// (and any non-web scheme) cannot be re-fetched for a fresh render.
|
|
888
|
+
if (location.protocol !== 'http:' && location.protocol !== 'https:') return;
|
|
620
889
|
chip.addEventListener('click', () => location.reload());
|
|
890
|
+
let inFlight = false;
|
|
621
891
|
const check = async () => {
|
|
892
|
+
// Pause while the tab is hidden and never overlap a slow fetch with the next.
|
|
893
|
+
if (inFlight || document.hidden) return;
|
|
894
|
+
inFlight = true;
|
|
622
895
|
try {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
896
|
+
// Same-origin by construction (this page's own URL); only a successful
|
|
897
|
+
// response is trusted — a transient 5xx or a dropped dev server never
|
|
898
|
+
// flips the chip.
|
|
899
|
+
const response = await fetch(location.href, { cache: 'no-store', redirect: 'error', signal: AbortSignal.timeout(8000) });
|
|
900
|
+
if (!response.ok) return;
|
|
901
|
+
const next = marker(await response.text());
|
|
626
902
|
if (next && next !== current) chip.hidden = false;
|
|
627
|
-
} catch {}
|
|
903
|
+
} catch {} finally { inFlight = false; }
|
|
628
904
|
};
|
|
629
905
|
setInterval(check, 1500);
|
|
630
906
|
})();
|
|
@@ -722,20 +998,32 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
722
998
|
})();
|
|
723
999
|
</script>` : '';
|
|
724
1000
|
const worksheetToolbar = worksheet ? `<div class="wq-toolbar" role="toolbar" aria-label="Worksheet actions"><button type="button" data-wq-action="save">Save</button><button type="button" data-wq-action="export">Export answers</button><button type="button" data-wq-action="copy-markdown">Copy answers as Markdown</button><button type="button" data-wq-action="print">Print / PDF</button><button type="button" data-wq-action="reset">Reset drafts</button><span class="wq-status" aria-live="polite">loading</span></div>` : '';
|
|
725
|
-
|
|
1001
|
+
// Prefix the browser tab with the project, so a wall of open plan tabs is
|
|
1002
|
+
// scannable by project rather than by identical leading words. The prefix is
|
|
1003
|
+
// length-bounded (the hero shows the project verbatim); a very long project
|
|
1004
|
+
// name is truncated with an ellipsis so the artifact's own topic always
|
|
1005
|
+
// survives in the tab title.
|
|
1006
|
+
const documentTitle = metadata.project
|
|
1007
|
+
? `${boundedTitlePrefix(metadata.project.value)} — ${title}`
|
|
1008
|
+
: title;
|
|
1009
|
+
const document = `<!doctype html>
|
|
726
1010
|
<html lang="en"${themeAttribute}>
|
|
727
1011
|
<head>
|
|
728
1012
|
<meta charset="utf-8">
|
|
729
1013
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
730
1014
|
<meta name="robots" content="noindex">
|
|
731
|
-
<
|
|
1015
|
+
<meta name="${CONTENT_HASH_META}" content="${CONTENT_HASH_PLACEHOLDER}">
|
|
1016
|
+
<meta name="${BODY_REVISION_META}" content="${escapeHtml(revision)}">
|
|
1017
|
+
<title>${escapeHtml(documentTitle)}</title>
|
|
1018
|
+
${creatorFavicon(metadata.creator.harness)}
|
|
732
1019
|
<style>
|
|
733
1020
|
${styles}
|
|
734
1021
|
.reader-highlight{background:color-mix(in srgb,var(--warn) 38%,var(--bg));color:inherit;border-radius:2px;box-decoration-break:clone;-webkit-box-decoration-break:clone;cursor:pointer}.reader-highlight:hover{background:color-mix(in srgb,var(--warn) 55%,var(--bg))}.reload-chip{display:inline-flex;align-items:center;height:30px;margin-right:8px;padding:0 12px;border:1px solid color-mix(in srgb,var(--accent) 40%,var(--line));border-radius:999px;background:color-mix(in srgb,var(--accent) 12%,var(--surface));color:var(--accent);font:500 12px/1 var(--font-mono);cursor:pointer}.reload-chip[hidden]{display:none}
|
|
735
|
-
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-body);line-height:1.6;-webkit-font-smoothing:antialiased;transition:background-color .15s ease,color .15s ease}main{width:100%;max-width:var(--content-width);min-width:0;margin:0 auto;padding:24px var(--page-padding) 80px}.document-header{display:flex;align-items:center;justify-content:flex-end;min-height:42px;border-bottom:1px solid var(--line);color:var(--muted);font-family:var(--font-mono);font-size:12px}.header-label{min-width:0;margin-right:auto;padding-right:12px;overflow-wrap:anywhere;color:var(--text);font-weight:650}.theme-toggle{display:inline-flex;flex:0 0 auto;align-items:center;gap:6px;height:30px;padding:0 12px;border:1px solid var(--line);border-radius:999px;background:var(--surface);color:var(--muted);font:500 12px/1 var(--font-mono);cursor:pointer}.theme-toggle:hover{color:var(--accent);border-color:var(--accent)}.theme-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.hero{padding:var(--hero-top) 0 var(--hero-bottom);border-bottom:1px solid var(--line)}.kicker{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;font-family:var(--font-mono);font-size:12px;text-transform:uppercase;letter-spacing:.14em;color:var(--accent);font-weight:500}.kicker-part{color:var(--accent)}.kicker-separator{color:var(--muted);padding:0 2px}.status-badge{display:inline-flex;align-items:center;height:22px;padding:0 9px;border-radius:999px;border:1px solid color-mix(in srgb,var(--warn) 40%,var(--line));background:color-mix(in srgb,var(--warn) 14%,transparent);color:var(--warn);font-family:var(--font-mono);font-size:10.5px;font-weight:650;letter-spacing:.1em;text-transform:uppercase;line-height:1}.status-badge.status-implementing,.status-badge.status-in-progress,.status-badge.status-review,.status-badge.status-done,.status-badge.status-complete{border-color:color-mix(in srgb,var(--accent) 40%,var(--line));background:color-mix(in srgb,var(--accent) 12%,transparent);color:var(--accent)}.hero h1{font-family:var(--font-display);font-size:clamp(30px,4vw,44px);line-height:1.1;margin:12px 0 14px;letter-spacing:-.01em}.summary{max-width:760px;color:var(--muted);font-size:17px;margin:0}.meta{display:grid;gap:14px;margin-top:20px}.facts-line{margin:0;color:var(--muted);font-family:var(--font-mono);font-size:12.5px;line-height:1.7}.meta-block{display:grid;gap:8px}.meta-label{font-family:var(--font-mono);font-size:10.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);font-weight:500}.meta-row{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:0}.chip{display:inline-flex;align-items:center;gap:4px;max-width:100%;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:4px 11px;color:var(--muted);font-family:var(--font-mono);font-size:11.5px;line-height:1.5}.chip-value{color:var(--text);overflow-wrap:anywhere}.chip-icon{display:inline-block;width:12px;height:12px;margin-right:5px;vertical-align:-1.5px;fill:currentColor;flex:0 0 auto}.chip-favicon{display:inline-block;width:12px;height:12px;margin-right:5px;vertical-align:-1.5px;border-radius:2px;object-fit:contain;flex:0 0 auto}.chip-value a{color:inherit;text-decoration:none}.chip-value a:hover{text-decoration:underline}.provenance-line{margin:0;color:var(--muted);font-family:var(--font-mono);font-size:12.5px;line-height:1.7}.provenance-line a{color:var(--accent-alt);text-decoration:none}.provenance-line a:hover{text-decoration:underline}.provenance-part{color:var(--muted)}.meta-sep{margin:0 7px;opacity:.45}.toc{display:grid;gap:4px;margin:24px 0 8px;font-family:var(--font-mono);font-size:13px}.toc-item{display:block;padding:2px 0 2px 10px;border-left:2px solid transparent;color:var(--muted);text-decoration:none;overflow-wrap:anywhere}.toc-item.toc-sub{padding-left:24px;font-size:.92em;opacity:.85}.toc-item:hover{color:var(--accent)}.toc-item.is-active{color:var(--accent);border-left-color:var(--accent)}.toc-item.is-active .toc-index{opacity:1}@media (min-width:1380px){.toc{position:fixed;top:88px;left:max(20px,calc(50% - var(--content-width)/2 - 236px));width:212px;max-height:calc(100vh - 132px);overflow-y:auto;margin:0;z-index:5;scrollbar-width:thin}.toc::-webkit-scrollbar{width:6px}.toc::-webkit-scrollbar-thumb{background:var(--line);border-radius:3px}}@media (max-width:1379px){.toc-item.toc-sub{display:none}}.code-diff{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--code)}.code-diff-pre{margin:0;padding:10px 0;background:none;border:none;border-radius:0;overflow-x:auto;font-family:var(--font-mono);font-size:12.5px;line-height:1.55;color:var(--code-text)}.cd-line{display:block;white-space:pre;padding:0 14px}.cd-sign{display:inline-block;width:1.4ch;color:var(--muted);user-select:none}.cd-add{background:color-mix(in srgb,var(--accent) 15%,transparent)}.cd-add .cd-sign{color:var(--accent)}.cd-del{background:color-mix(in srgb,var(--danger) 15%,transparent)}.cd-del .cd-sign{color:var(--danger)}.cd-hunk,.cd-meta{color:var(--muted);opacity:.8}.code-diff>summary{list-style:none;cursor:pointer;padding:8px 14px;font-family:var(--font-mono);font-size:12px;color:var(--code-text);background:color-mix(in srgb,var(--code-text) 8%,var(--code));border-bottom:1px solid transparent;user-select:none}.code-diff[open]>summary{border-bottom-color:color-mix(in srgb,var(--code-text) 15%,transparent)}.code-diff>summary::-webkit-details-marker{display:none}.code-diff>summary::before{content:"\\25B8";display:inline-block;margin-right:7px;color:color-mix(in srgb,var(--code-text) 55%,transparent);font-size:10px;transition:transform .12s ease}.code-diff[open]>summary::before{transform:rotate(90deg)}.checklist{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:var(--panel-padding)}.checklist-head{font-family:var(--font-mono);font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted);margin-bottom:10px}.checklist-items{list-style:none;margin:0;padding:0;display:grid;gap:7px}.cl-item{display:flex;align-items:baseline;gap:9px}.cl-box{flex:0 0 auto;font-family:var(--font-mono);font-size:.95em}.cl-done .cl-box{color:var(--accent)}.cl-todo .cl-box{color:var(--muted)}.cl-doing .cl-box{color:var(--warn)}.cl-done .cl-text{color:var(--muted);text-decoration:line-through;text-decoration-color:var(--line)}.toc a{color:var(--muted);text-decoration:none}.toc a:hover{color:var(--accent)}.toc a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.toc-index{color:var(--accent);font-family:var(--font-mono);font-size:.9em}.artifact-body{min-width:0;padding-top:18px;counter-reset:section}h2{font-size:24px;margin:var(--section-spacing) 0 12px;line-height:1.2;letter-spacing:-.01em}.artifact-body>h2{counter-increment:section}.artifact-body>h2::before{content:counter(section,decimal-leading-zero);font-family:var(--font-mono);font-size:.62em;color:var(--accent);margin-right:10px;opacity:.85}h3{font-size:17px;margin:calc(var(--section-spacing) * .78) 0 10px}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.link-pill{display:inline-flex;align-items:center;gap:4px;max-width:100%;padding:0 6px;border:1px solid var(--line);border-radius:6px;background:var(--surface-alt);color:var(--text);font-size:.92em;line-height:1.35;text-decoration:none;vertical-align:baseline;transition:border-color .12s ease,color .12s ease,background-color .12s ease}.link-pill:hover{border-color:var(--accent);color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,var(--surface-alt));text-decoration:none}.link-pill:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.link-pill-icon{width:12px;height:12px;flex:0 0 auto;fill:currentColor;opacity:.9}.link-pill-favicon{display:inline-block;width:12px;height:12px;flex:0 0 auto;border-radius:3px;object-fit:contain}.link-pill-text{min-width:0;overflow-wrap:anywhere}.link-pill code{background:none;border:none;padding:0;color:inherit}td .link-pill,li .link-pill{vertical-align:-1px}p,li,dd,figcaption{overflow-wrap:anywhere}pre{background:var(--code);color:var(--code-text);padding:var(--panel-padding);border-radius:12px;overflow:auto;border:1px solid var(--line)}code{font-family:var(--font-mono);font-size:.88em;background:var(--surface-alt);border:1px solid var(--line);border-radius:5px;padding:1.5px 6px;color:var(--accent-alt)}pre code{background:none;border:none;padding:0;color:inherit}table{width:100%;border-collapse:collapse;margin:18px 0}th,td{border-bottom:1px solid var(--line);padding:10px;text-align:left;vertical-align:top}th{font-family:var(--font-mono);font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}blockquote{border-left:3px solid var(--accent);padding-left:var(--panel-padding);color:var(--muted);margin-left:0}img{display:block;max-width:100%;height:auto}svg{max-width:100%;height:auto}.artifact-body>p>img{margin:var(--figure-spacing) auto}.artifact-grid{display:grid;gap:var(--panel-padding);margin:var(--figure-spacing) 0}.artifact-grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}.artifact-grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}.artifact-panel,.artifact-stat{min-width:0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:var(--panel-padding)}.artifact-panel h3{margin:10px 0 8px;font-size:16px}.artifact-stat-value,.artifact-stat-label{display:block}.artifact-stat-value{color:var(--text);font-family:var(--font-display);font-size:24px;line-height:1.15}.artifact-stat-label{margin-top:6px;color:var(--muted);font-size:13px}.artifact-tag{display:inline-block;--tag-color:var(--muted);background:color-mix(in srgb,var(--tag-color) 12%,transparent);border:1px solid color-mix(in srgb,var(--tag-color) 30%,transparent);border-radius:6px;padding:2px 8px;color:var(--tag-color);font-family:var(--font-mono);font-size:11px;font-weight:600;text-transform:uppercase}.artifact-tag-accent{--tag-color:var(--accent)}.artifact-callout{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:0 var(--radius) var(--radius) 0;background:var(--surface-alt);padding:var(--panel-padding)}.artifact-callout-warn{border-left-color:var(--warn)}.artifact-callout-danger{border-left-color:var(--danger)}.artifact-callout strong{color:var(--text)}.artifact-figure{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:var(--panel-padding);overflow-x:auto}.artifact-figure>img,.artifact-image{width:auto;max-width:100%;height:auto;margin:0 auto}.artifact-figure-diagram{background:#0e120f;border-color:#26302a}.artifact-diagram{display:block;width:100%;height:auto;margin:0 auto}.artifact-figure-tall{width:100%;max-width:394px;margin-left:auto;margin-right:auto}.artifact-figure figcaption{margin-top:12px;color:var(--muted);font-family:var(--font-mono);font-size:12px;text-align:center}.artifact-figure.artifact-figure-diagram figcaption{color:#8b938c}.artifact-legend{display:flex;flex-wrap:wrap;gap:8px 16px;margin:12px 0;color:var(--muted);font-family:var(--font-mono);font-size:11.5px}.artifact-behavior{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;display:grid;grid-template-columns:1fr 1fr}.artifact-behavior-panel{padding:var(--panel-padding);background:var(--surface)}.artifact-behavior-panel+.artifact-behavior-panel{border-left:1px solid var(--line)}.artifact-behavior-panel::before{display:block;font-family:var(--font-mono);font-size:10.5px;text-transform:uppercase;letter-spacing:.12em;color:var(--muted);font-weight:500;margin-bottom:8px;content:""}.artifact-behavior-panel[data-state="current"]::before{content:"Current"}.artifact-behavior-panel[data-state="proposed"]{background:color-mix(in srgb,var(--accent) 6%,var(--surface))}.artifact-behavior-panel[data-state="proposed"]::before{content:"Proposed";color:var(--accent)}.document-footer{margin-top:var(--footer-spacing);padding-top:18px;border-top:1px solid var(--line);color:var(--muted);font-family:var(--font-mono);font-size:12px}.references-list{margin:0;padding-left:1.6em;display:grid;gap:7px}.reference-item{color:var(--muted)}.reference-item::marker{font-family:var(--font-mono);font-size:.86em;color:var(--muted)}.reference-link{display:inline-flex;align-items:center;gap:7px;max-width:100%;color:var(--text);text-decoration:none;overflow-wrap:anywhere}.reference-link:hover{color:var(--accent);text-decoration:none}.reference-link:hover .reference-text{text-decoration:underline}.reference-host{color:var(--muted);font-family:var(--font-mono);font-size:.82em}.view-count{color:var(--muted);font-family:var(--font-mono);font-size:11.5px;margin-right:12px;white-space:nowrap}
|
|
1022
|
+
.kicker-project{color:var(--accent);font-weight:700;letter-spacing:.1em;text-decoration:none}.kicker-project:hover{text-decoration:underline}.creator-line{display:flex;flex-wrap:wrap;align-items:center;margin:14px 0 0;color:var(--muted);font-family:var(--font-mono);font-size:12px;line-height:1.6}.creator-agent{display:inline-flex;align-items:center;color:var(--text)}.creator-agent .chip-icon{width:13px;height:13px;margin-right:6px;vertical-align:-2px;fill:currentColor;flex:0 0 auto}.creator-human{color:var(--muted)}.creator-time{color:var(--muted)}.provenance-details{color:var(--muted);font-family:var(--font-mono);font-size:12px}.provenance-details>summary{cursor:pointer;color:var(--muted);text-transform:uppercase;letter-spacing:.1em;font-size:10.5px;list-style:none;width:fit-content}.provenance-details>summary::-webkit-details-marker{display:none}.provenance-details>summary::before{content:"\\25B8";display:inline-block;margin-right:6px;font-size:9px;transition:transform .12s ease}.provenance-details[open]>summary::before{transform:rotate(90deg)}.provenance-details>summary:hover{color:var(--accent)}.provenance-details .provenance-line{margin-top:8px}
|
|
1023
|
+
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-body);line-height:1.6;-webkit-font-smoothing:antialiased;transition:background-color .15s ease,color .15s ease}main{width:100%;max-width:var(--content-width);min-width:0;margin:0 auto;padding:24px var(--page-padding) 80px}.document-header{display:flex;align-items:center;justify-content:flex-end;min-height:42px;border-bottom:1px solid var(--line);color:var(--muted);font-family:var(--font-mono);font-size:12px}.header-label{min-width:0;margin-right:auto;padding-right:12px;overflow-wrap:anywhere;color:var(--text);font-weight:650}.theme-toggle{display:inline-flex;flex:0 0 auto;align-items:center;gap:6px;height:30px;padding:0 12px;border:1px solid var(--line);border-radius:999px;background:var(--surface);color:var(--muted);font:500 12px/1 var(--font-mono);cursor:pointer}.theme-toggle:hover{color:var(--accent);border-color:var(--accent)}.theme-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.hero{padding:var(--hero-top) 0 var(--hero-bottom);border-bottom:1px solid var(--line)}.kicker{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;font-family:var(--font-mono);font-size:12px;text-transform:uppercase;letter-spacing:.14em;color:var(--accent);font-weight:500}.kicker-part{color:var(--accent)}.kicker-separator{color:var(--muted);padding:0 2px}.status-badge{display:inline-flex;align-items:center;height:22px;padding:0 9px;border-radius:999px;border:1px solid color-mix(in srgb,var(--warn) 40%,var(--line));background:color-mix(in srgb,var(--warn) 14%,transparent);color:var(--warn);font-family:var(--font-mono);font-size:10.5px;font-weight:650;letter-spacing:.1em;text-transform:uppercase;line-height:1}.status-badge.status-implementing,.status-badge.status-in-progress,.status-badge.status-review,.status-badge.status-done,.status-badge.status-complete{border-color:color-mix(in srgb,var(--accent) 40%,var(--line));background:color-mix(in srgb,var(--accent) 12%,transparent);color:var(--accent)}.hero h1{font-family:var(--font-display);font-size:clamp(30px,4vw,44px);line-height:1.1;margin:12px 0 14px;letter-spacing:-.01em}.summary{max-width:760px;color:var(--muted);font-size:17px;margin:0}.meta{display:grid;gap:14px;margin-top:20px}.facts-line{margin:0;color:var(--muted);font-family:var(--font-mono);font-size:12.5px;line-height:1.7}.meta-block{display:grid;gap:8px}.meta-label{font-family:var(--font-mono);font-size:10.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);font-weight:500}.meta-row{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:0}.chip{display:inline-flex;align-items:center;gap:4px;max-width:100%;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:4px 11px;color:var(--muted);font-family:var(--font-mono);font-size:11.5px;line-height:1.5}.chip-value{color:var(--text);overflow-wrap:anywhere}.chip-icon{display:inline-block;width:12px;height:12px;margin-right:5px;vertical-align:-1.5px;fill:currentColor;flex:0 0 auto}.chip-favicon{display:inline-block;width:12px;height:12px;margin-right:5px;vertical-align:-1.5px;border-radius:2px;object-fit:contain;flex:0 0 auto}.chip-value a{color:inherit;text-decoration:none}.chip-value a:hover{text-decoration:underline}.provenance-line{margin:0;color:var(--muted);font-family:var(--font-mono);font-size:12.5px;line-height:1.7}.provenance-line a{color:var(--accent-alt);text-decoration:none}.provenance-line a:hover{text-decoration:underline}.provenance-part{color:var(--muted)}.meta-sep{margin:0 7px;opacity:.45}.toc{display:grid;gap:4px;margin:24px 0 8px;font-family:var(--font-mono);font-size:13px}.toc-item{display:block;padding:2px 0 2px 10px;border-left:2px solid transparent;color:var(--muted);text-decoration:none;overflow-wrap:anywhere}.toc-item.toc-sub{padding-left:24px;font-size:.92em;opacity:.85}.toc-item:hover{color:var(--accent)}.toc-item.is-active{color:var(--accent);border-left-color:var(--accent)}.toc-item.is-active .toc-index{opacity:1}@media (min-width:1380px){.toc{position:fixed;top:88px;left:max(20px,calc(50% - var(--content-width)/2 - 236px));width:212px;max-height:calc(100vh - 132px);overflow-y:auto;margin:0;z-index:5;scrollbar-width:thin}.toc::-webkit-scrollbar{width:6px}.toc::-webkit-scrollbar-thumb{background:var(--line);border-radius:3px}}@media (max-width:1379px){.toc-item.toc-sub{display:none}}.code-diff{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--code)}.code-diff-pre{margin:0;padding:10px 0;background:none;border:none;border-radius:0;overflow-x:auto;font-family:var(--font-mono);font-size:12.5px;line-height:1.55;color:var(--code-text)}.cd-line{display:block;white-space:pre;padding:0 14px}.cd-sign{display:inline-block;width:1.4ch;color:var(--muted);user-select:none}.cd-add{background:color-mix(in srgb,var(--accent) 15%,transparent)}.cd-add .cd-sign{color:var(--accent)}.cd-del{background:color-mix(in srgb,var(--danger) 15%,transparent)}.cd-del .cd-sign{color:var(--danger)}.cd-hunk,.cd-meta{color:var(--muted);opacity:.8}.code-diff>summary{list-style:none;cursor:pointer;padding:8px 14px;font-family:var(--font-mono);font-size:12px;color:var(--code-text);background:color-mix(in srgb,var(--code-text) 8%,var(--code));border-bottom:1px solid transparent;user-select:none}.code-diff[open]>summary{border-bottom-color:color-mix(in srgb,var(--code-text) 15%,transparent)}.code-diff>summary::-webkit-details-marker{display:none}.code-diff>summary::before{content:"\\25B8";display:inline-block;margin-right:7px;color:color-mix(in srgb,var(--code-text) 55%,transparent);font-size:10px;transition:transform .12s ease}.code-diff[open]>summary::before{transform:rotate(90deg)}.checklist{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:var(--panel-padding)}.checklist-head{font-family:var(--font-mono);font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted);margin-bottom:10px}.checklist-items{list-style:none;margin:0;padding:0;display:grid;gap:7px}.cl-item{display:flex;align-items:baseline;gap:9px}.cl-box{flex:0 0 auto;font-family:var(--font-mono);font-size:.95em}.cl-done .cl-box{color:var(--accent)}.cl-todo .cl-box{color:var(--muted)}.cl-doing .cl-box{color:var(--warn)}.cl-done .cl-text{color:var(--muted);text-decoration:line-through;text-decoration-color:var(--line)}.toc a{color:var(--muted);text-decoration:none}.toc a:hover{color:var(--accent)}.toc a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.toc-index{color:var(--accent);font-family:var(--font-mono);font-size:.9em}.artifact-body{min-width:0;padding-top:18px;counter-reset:section}h2{font-size:24px;margin:var(--section-spacing) 0 12px;line-height:1.2;letter-spacing:-.01em}.artifact-section>h2{counter-increment:section}.artifact-section>h2::before{content:counter(section,decimal-leading-zero);font-family:var(--font-mono);font-size:.62em;color:var(--accent);margin-right:10px;opacity:.85}h3{font-size:17px;margin:calc(var(--section-spacing) * .78) 0 10px}.artifact-section-body[hidden]{display:none}.section-toggle{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-left:8px;padding:0;border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--muted);cursor:pointer;vertical-align:middle;flex:0 0 auto}.section-toggle:hover{color:var(--accent);border-color:var(--accent)}.section-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.section-toggle::before{content:"\\25BE";display:block;font-size:10px;line-height:1;transition:transform .12s ease}.section-toggle[aria-expanded="false"]::before{transform:rotate(-90deg)}.toc-collapse-actions{display:flex;gap:10px;margin:0 0 8px 10px}.toc-collapse-actions button{border:none;background:none;padding:0;color:var(--muted);font-family:var(--font-mono);font-size:11px;text-transform:uppercase;letter-spacing:.06em;cursor:pointer}.toc-collapse-actions button:hover{color:var(--accent)}.toc-collapse-actions button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.link-pill{display:inline-flex;align-items:center;gap:4px;max-width:100%;padding:0 6px;border:1px solid var(--line);border-radius:6px;background:var(--surface-alt);color:var(--text);font-size:.92em;line-height:1.35;text-decoration:none;vertical-align:baseline;transition:border-color .12s ease,color .12s ease,background-color .12s ease}.link-pill:hover{border-color:var(--accent);color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,var(--surface-alt));text-decoration:none}.link-pill:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.link-pill-icon{width:12px;height:12px;flex:0 0 auto;fill:currentColor;opacity:.9}.link-pill-favicon{display:inline-block;width:12px;height:12px;flex:0 0 auto;border-radius:3px;object-fit:contain}.link-pill-text{min-width:0;overflow-wrap:anywhere}.link-pill code{background:none;border:none;padding:0;color:inherit}td .link-pill,li .link-pill{vertical-align:-1px}p,li,dd,figcaption{overflow-wrap:anywhere}pre{background:var(--code);color:var(--code-text);padding:var(--panel-padding);border-radius:12px;overflow:auto;border:1px solid var(--line)}code{font-family:var(--font-mono);font-size:.88em;background:var(--surface-alt);border:1px solid var(--line);border-radius:5px;padding:1.5px 6px;color:var(--accent-alt)}pre code{background:none;border:none;padding:0;color:inherit}table{width:100%;border-collapse:collapse;margin:18px 0}th,td{border-bottom:1px solid var(--line);padding:10px;text-align:left;vertical-align:top}th{font-family:var(--font-mono);font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}blockquote{border-left:3px solid var(--accent);padding-left:var(--panel-padding);color:var(--muted);margin-left:0}img{display:block;max-width:100%;height:auto}svg{max-width:100%;height:auto}.artifact-body>p>img{margin:var(--figure-spacing) auto}.artifact-grid{display:grid;gap:var(--panel-padding);margin:var(--figure-spacing) 0}.artifact-grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}.artifact-grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}.artifact-panel,.artifact-stat{min-width:0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:var(--panel-padding)}.artifact-panel h3{margin:10px 0 8px;font-size:16px}.artifact-stat-value,.artifact-stat-label{display:block}.artifact-stat-value{color:var(--text);font-family:var(--font-display);font-size:24px;line-height:1.15}.artifact-stat-label{margin-top:6px;color:var(--muted);font-size:13px}.artifact-tag{display:inline-block;--tag-color:var(--muted);background:color-mix(in srgb,var(--tag-color) 12%,transparent);border:1px solid color-mix(in srgb,var(--tag-color) 30%,transparent);border-radius:6px;padding:2px 8px;color:var(--tag-color);font-family:var(--font-mono);font-size:11px;font-weight:600;text-transform:uppercase}.artifact-tag-accent{--tag-color:var(--accent)}.artifact-callout{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:0 var(--radius) var(--radius) 0;background:var(--surface-alt);padding:var(--panel-padding)}.artifact-callout-warn{border-left-color:var(--warn)}.artifact-callout-danger{border-left-color:var(--danger)}.artifact-callout strong{color:var(--text)}.artifact-figure{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:var(--panel-padding);overflow-x:auto}.artifact-figure>img,.artifact-image{width:auto;max-width:100%;height:auto;margin:0 auto}.artifact-figure-diagram{background:#0e120f;border-color:#26302a}.artifact-diagram{display:block;width:100%;height:auto;margin:0 auto}.artifact-figure-tall{width:100%;max-width:394px;margin-left:auto;margin-right:auto}.artifact-figure figcaption{margin-top:12px;color:var(--muted);font-family:var(--font-mono);font-size:12px;text-align:center}.artifact-figure.artifact-figure-diagram figcaption{color:#8b938c}.artifact-legend{display:flex;flex-wrap:wrap;gap:8px 16px;margin:12px 0;color:var(--muted);font-family:var(--font-mono);font-size:11.5px}.artifact-behavior{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;display:grid;grid-template-columns:1fr 1fr}.artifact-behavior-panel{padding:var(--panel-padding);background:var(--surface)}.artifact-behavior-panel+.artifact-behavior-panel{border-left:1px solid var(--line)}.artifact-behavior-panel::before{display:block;font-family:var(--font-mono);font-size:10.5px;text-transform:uppercase;letter-spacing:.12em;color:var(--muted);font-weight:500;margin-bottom:8px;content:""}.artifact-behavior-panel[data-state="current"]::before{content:"Current"}.artifact-behavior-panel[data-state="proposed"]{background:color-mix(in srgb,var(--accent) 6%,var(--surface))}.artifact-behavior-panel[data-state="proposed"]::before{content:"Proposed";color:var(--accent)}.document-footer{margin-top:var(--footer-spacing);padding-top:18px;border-top:1px solid var(--line);color:var(--muted);font-family:var(--font-mono);font-size:12px}.references-list{margin:0;padding-left:1.6em;display:grid;gap:7px}.reference-item{color:var(--muted)}.reference-item::marker{font-family:var(--font-mono);font-size:.86em;color:var(--muted)}.reference-link{display:inline-flex;align-items:center;gap:7px;max-width:100%;color:var(--text);text-decoration:none;overflow-wrap:anywhere}.reference-link:hover{color:var(--accent);text-decoration:none}.reference-link:hover .reference-text{text-decoration:underline}.reference-host{color:var(--muted);font-family:var(--font-mono);font-size:.82em}.view-count{color:var(--muted);font-family:var(--font-mono);font-size:11.5px;margin-right:12px;white-space:nowrap}
|
|
736
1024
|
.artifact-figure-diagram{--artifact-fg:#e7ece8;--artifact-muted:#b7c0b8;--artifact-accent:#a3e635}.artifact-figure.artifact-figure-diagram figcaption{color:var(--artifact-muted)}
|
|
737
1025
|
@media(max-width:720px){main{padding:32px var(--mobile-page-padding) 64px}.artifact-grid-2,.artifact-grid-3{grid-template-columns:1fr}.artifact-figure{padding:min(12px,var(--panel-padding))}.artifact-figure-wide .artifact-diagram{min-width:640px}.artifact-behavior{grid-template-columns:1fr}.artifact-behavior-panel+.artifact-behavior-panel{border-left:none;border-top:1px solid var(--line)}table{display:block;max-width:100%;overflow-x:auto}th,td{min-width:140px;overflow-wrap:anywhere}pre{white-space:pre-wrap;overflow-wrap:anywhere}}
|
|
738
|
-
@media print{body{transition:none;-webkit-print-color-adjust:exact;print-color-adjust:exact}.toc,.theme-toggle,.view-count{display:none}.document-header-empty{display:none}main{max-width:none;padding:0}:root[data-pdf-layout="poster"] main{max-width:var(--content-width);margin:0 auto;padding:var(--print-margin)}.chip{background:var(--surface)}.chip-value{color:var(--text)}.provenance-line,.provenance-line a,.facts-line{color:var(--text)}.status-badge{color:var(--text);border-color:var(--line)}h2,h3{break-after:avoid-page}.artifact-figure,.artifact-grid,.artifact-panel,.artifact-stat,.artifact-callout,.artifact-behavior,pre,table,blockquote,.meta{break-inside:avoid}.artifact-figure-wide .artifact-diagram{min-width:0}.artifact-figure-tall{max-width:330px}pre{white-space:pre-wrap;overflow-wrap:anywhere}a{color:var(--text);text-decoration:underline}.link-pill{color:var(--text);text-decoration:none;background:var(--surface);border-color:var(--line);break-inside:avoid}}
|
|
1026
|
+
@media print{body{transition:none;-webkit-print-color-adjust:exact;print-color-adjust:exact}.toc,.theme-toggle,.view-count{display:none}.section-toggle{display:none}.artifact-section-body[hidden]{display:block!important}.document-header-empty{display:none}main{max-width:none;padding:0}:root[data-pdf-layout="poster"] main{max-width:var(--content-width);margin:0 auto;padding:var(--print-margin)}.chip{background:var(--surface)}.chip-value{color:var(--text)}.provenance-line,.provenance-line a,.facts-line{color:var(--text)}.creator-line,.creator-agent,.creator-human,.creator-time{color:var(--text)}.provenance-details>summary{display:none}.provenance-details>.provenance-line{display:block!important}.status-badge{color:var(--text);border-color:var(--line)}h2,h3{break-after:avoid-page}.artifact-figure,.artifact-grid,.artifact-panel,.artifact-stat,.artifact-callout,.artifact-behavior,pre,table,blockquote,.meta{break-inside:avoid}.artifact-figure-wide .artifact-diagram{min-width:0}.artifact-figure-tall{max-width:330px}pre{white-space:pre-wrap;overflow-wrap:anywhere}a{color:var(--text);text-decoration:underline}.link-pill{color:var(--text);text-decoration:none;background:var(--surface);border-color:var(--line);break-inside:avoid}}
|
|
739
1027
|
</style>
|
|
740
1028
|
${worksheet ? `<style>
|
|
741
1029
|
.wq-toolbar{position:sticky;top:0;z-index:10;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px 0;border-bottom:1px solid var(--line);background:var(--bg)}
|
|
@@ -755,21 +1043,26 @@ ${worksheet ? `<style>
|
|
|
755
1043
|
</head>
|
|
756
1044
|
<body>
|
|
757
1045
|
<main>
|
|
758
|
-
<header class="document-header${header ? '' : ' document-header-empty'}">${header ? `<div class="header-label">${escapeHtml(header)}</div>` : ''}<span class="view-count" hidden></span><button class="reload-chip" type="button" hidden>
|
|
1046
|
+
<header class="document-header${header ? '' : ' document-header-empty'}">${header ? `<div class="header-label">${escapeHtml(header)}</div>` : ''}<span class="view-count" hidden></span><button class="reload-chip" type="button" hidden>New version available · Reload</button><button class="theme-toggle" type="button" aria-label="Toggle color theme" aria-pressed="false" title="Toggle color theme"><span aria-hidden="true">◐</span> theme</button></header>
|
|
759
1047
|
${worksheetToolbar}
|
|
760
|
-
<
|
|
1048
|
+
<style>${COVER_CSS}</style>
|
|
1049
|
+
<section class="hero creator-cover cover-${coverClass(metadata.creator.harness)}">
|
|
1050
|
+
${coverArtwork(metadata.creator.harness)}
|
|
1051
|
+
${coverTop(metadata)}
|
|
761
1052
|
${kickerHtml(metadata)}
|
|
762
1053
|
<h1>${escapeHtml(title)}</h1>
|
|
763
1054
|
${summary ? `<p class="summary">${summary}</p>` : ''}
|
|
764
|
-
${
|
|
1055
|
+
${creatorLine(metadata)}
|
|
765
1056
|
</section>
|
|
1057
|
+
<div class="hero-metadata">${metadataBlock(metadata)}</div>
|
|
766
1058
|
${body}
|
|
767
1059
|
${footer ? `<footer class="document-footer">${escapeHtml(footer)}</footer>` : ''}
|
|
768
1060
|
</main>
|
|
769
1061
|
${sourceJson}
|
|
770
|
-
${themeScript}${readerScript}${reloadScript}${worksheetScript}${HIGHLIGHTS_SCRIPT}
|
|
1062
|
+
${themeScript}${FRESHNESS_SCRIPT}${readerScript}${reloadScript}${worksheetScript}${SECTION_COLLAPSE_SCRIPT}${READER_ANCHORS_SCRIPT}${HIGHLIGHTS_SCRIPT}${COLLAB_SCRIPT}
|
|
771
1063
|
</body>
|
|
772
1064
|
</html>`;
|
|
1065
|
+
return document.replace(CONTENT_HASH_PLACEHOLDER, createHash('sha256').update(document).digest('hex').slice(0, 16));
|
|
773
1066
|
}
|
|
774
1067
|
function paletteVariables(palette) {
|
|
775
1068
|
return `--bg:${palette.background};--surface:${palette.surface};--surface-alt:${palette.surfaceAlt};--line:${palette.line};--text:${palette.text};--muted:${palette.muted};--accent:${palette.accent};--accent-alt:${palette.accentAlt};--warn:${palette.warn};--danger:${palette.danger};--artifact-fg:${palette.text};--artifact-muted:${palette.muted};--artifact-accent:${palette.accent};`;
|
|
@@ -821,7 +1114,7 @@ export async function renderMarkdown(filePath, options = {}) {
|
|
|
821
1114
|
const summary = renderInlineMarkdown(String(data.summary || ''));
|
|
822
1115
|
const header = metadataValue(data.header);
|
|
823
1116
|
const footer = metadataValue(data.footer);
|
|
824
|
-
const metadata = artifactMetadata(data);
|
|
1117
|
+
const metadata = artifactMetadata(data, fileMtimeIso(abs));
|
|
825
1118
|
let body = String(await markdownRenderer.parse(markInProgressTasks(content), { gfm: true, breaks: false }));
|
|
826
1119
|
body = transformChecklists(body);
|
|
827
1120
|
// Pills are applied after the sanitizer so the brand marks, favicons, and pill
|
|
@@ -842,11 +1135,16 @@ export async function renderMarkdown(filePath, options = {}) {
|
|
|
842
1135
|
body += referencesHtml(references, id);
|
|
843
1136
|
entries.push({ level: 2, text: 'References', id });
|
|
844
1137
|
}
|
|
1138
|
+
body = wrapCollapsibleSections(body, entries);
|
|
845
1139
|
const toc = tocHtml(entries);
|
|
846
1140
|
const design = cssFromDesign(dirname(abs));
|
|
847
1141
|
diagnostics.push(...design.diagnostics);
|
|
848
1142
|
return {
|
|
849
|
-
html: shell(title, summary, header, footer, metadata, toc + `<article class="artifact-body">${body}</article>`, options.embedSource === false ? null : raw, design.css, design.defaultTheme,
|
|
1143
|
+
html: shell(title, summary, header, footer, metadata, toc + `<article class="artifact-body">${body}</article>`, options.embedSource === false ? null : raw, design.css, design.defaultTheme,
|
|
1144
|
+
// Hashed over the body alone: a re-render that only moves the `updated`
|
|
1145
|
+
// date or the session id keeps the revision, and every comment anchored
|
|
1146
|
+
// to it stays anchored.
|
|
1147
|
+
bodyRevision(body), worksheet ? { id: String(data.worksheet_id), basename: basename(abs, extname(abs)) } : null),
|
|
850
1148
|
diagnostics,
|
|
851
1149
|
};
|
|
852
1150
|
}
|
|
@@ -857,8 +1155,9 @@ export function normalizeHtml(filePath) {
|
|
|
857
1155
|
return { html: raw, diagnostics: [] };
|
|
858
1156
|
}
|
|
859
1157
|
const design = cssFromDesign(dirname(abs));
|
|
1158
|
+
const body = sanitizeBody(raw);
|
|
860
1159
|
return {
|
|
861
|
-
html: shell(basename(abs, extname(abs)), '', '', '', {
|
|
1160
|
+
html: shell(basename(abs, extname(abs)), '', '', '', { project: null, kind: '', status: '', creator: { agent: '', harness: '', human: '' }, timestamps: [], facts: [], links: [], provenance: [] }, `<article class="artifact-body">${body}</article>`, null, design.css, design.defaultTheme, bodyRevision(body)),
|
|
862
1161
|
diagnostics: design.diagnostics,
|
|
863
1162
|
};
|
|
864
1163
|
}
|