@phnx-labs/artifacts-cli 0.4.1 → 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 +21 -0
- package/README.md +35 -3
- package/dist/cli.js +5 -4
- 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/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/freshness.d.ts +6 -0
- package/dist/lib/freshness.js +52 -0
- package/dist/lib/freshness.js.map +1 -0
- package/dist/lib/icons.js +2 -1
- package/dist/lib/icons.js.map +1 -1
- package/dist/lib/render.js +189 -31
- package/dist/lib/render.js.map +1 -1
- 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/validate.js +28 -1
- package/dist/lib/validate.js.map +1 -1
- package/package.json +3 -1
package/dist/lib/icons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/lib/icons.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,oCAAoC;AAEpC,MAAM,kBAAkB,GAA2B;IACjD,MAAM,EACJ,qxDAAqxD;IACvxD,KAAK,EACH,s7CAAs7C;IACx7C,MAAM,EACJ,8RAA8R;IAChS,MAAM,EACJ,0VAA0V;IAC5V,OAAO,EACL,4lDAA4lD;CAC/lD,CAAC;AAEF,MAAM,aAAa,GACjB,uOAAuO,CAAC;AAE1O,MAAM,UAAU,GACd,wKAAwK,CAAC;AAE3K,MAAM,UAAU,YAAY;IAC1B,OAAO,iEAAiE,UAAU,QAAQ,CAAC;AAC7F,CAAC;AAED,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MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAS;QAChC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,IAAI;YAAE,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,2EAA2E;IAC3E,OAAO,eAAe,OAAO,CAAC,OAAO,oDAAoD,kBAAkB,CAAC,IAAI,CAAC,sGAAsG,CAAC;AAC1N,CAAC"}
|
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';
|
|
@@ -15,11 +16,24 @@ import { HIGHLIGHTS_SCRIPT } from './highlights.js';
|
|
|
15
16
|
import { READER_ANCHORS_SCRIPT } from './reader-anchors.js';
|
|
16
17
|
import { SECTION_COLLAPSE_SCRIPT } from './section-collapse.js';
|
|
17
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';
|
|
18
22
|
import { collectReferences, parseArtifactLinks, referencesHtml, transformLinkPills } from './links.js';
|
|
19
23
|
import { validateMarkdown } from './validate.js';
|
|
20
24
|
import { parseWorksheet, renderFieldCard, renderRowsGroup } from './worksheet.js';
|
|
21
25
|
const execFileAsync = promisify(execFile);
|
|
22
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__';
|
|
23
37
|
// Marks a heading that came from Markdown, so it can be told apart from an <h2>
|
|
24
38
|
// an author wrote inside an embedded block. A private-use character rather than
|
|
25
39
|
// an attribute: an attribute would have to be allowlisted through the sanitizer,
|
|
@@ -113,6 +127,12 @@ const HARNESS_PRODUCT_NAMES = {
|
|
|
113
127
|
droid: 'Droid',
|
|
114
128
|
antigravity: 'Antigravity',
|
|
115
129
|
kimi: 'Kimi',
|
|
130
|
+
opencode: 'OpenCode',
|
|
131
|
+
openclaw: 'OpenClaw',
|
|
132
|
+
hermes: 'Hermes',
|
|
133
|
+
muse: 'Muse',
|
|
134
|
+
warp: 'Warp',
|
|
135
|
+
pi: 'Pi',
|
|
116
136
|
};
|
|
117
137
|
/**
|
|
118
138
|
* Single human-facing agent string: product + model (e.g. "Grok 4.5"),
|
|
@@ -125,7 +145,7 @@ export function agentDisplayName(harness, agent) {
|
|
|
125
145
|
return '';
|
|
126
146
|
if (!h)
|
|
127
147
|
return a;
|
|
128
|
-
const product = HARNESS_PRODUCT_NAMES[h.toLowerCase()]
|
|
148
|
+
const product = (Object.hasOwn(HARNESS_PRODUCT_NAMES, h.toLowerCase()) ? HARNESS_PRODUCT_NAMES[h.toLowerCase()] : undefined)
|
|
129
149
|
?? (h.charAt(0).toUpperCase() + h.slice(1));
|
|
130
150
|
if (!a)
|
|
131
151
|
return product;
|
|
@@ -136,6 +156,14 @@ export function agentDisplayName(harness, agent) {
|
|
|
136
156
|
return `${product} ${stripped}`;
|
|
137
157
|
return `${product} ${a}`;
|
|
138
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
|
+
}
|
|
139
167
|
function metadataValue(value) {
|
|
140
168
|
if (value instanceof Date)
|
|
141
169
|
return value.toISOString().slice(0, 10);
|
|
@@ -148,6 +176,24 @@ function repositoryHref(repository) {
|
|
|
148
176
|
? `https://github.com/${repository}`
|
|
149
177
|
: undefined;
|
|
150
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
|
+
}
|
|
151
197
|
/**
|
|
152
198
|
* A deep link that resumes this session. Clicking it hands the URL to the OS,
|
|
153
199
|
* which routes it to the registered `agents open` handler (agents-cli) — the CLI
|
|
@@ -159,36 +205,48 @@ function sessionDeepLink(id) {
|
|
|
159
205
|
const trimmed = id.trim();
|
|
160
206
|
return trimmed ? `agents://session/${encodeURIComponent(trimmed)}` : undefined;
|
|
161
207
|
}
|
|
162
|
-
function artifactMetadata(data) {
|
|
208
|
+
function artifactMetadata(data, sourceMtimeIso = '') {
|
|
163
209
|
const field = (name) => metadataValue(data[name]);
|
|
164
210
|
const facts = Array.isArray(data.facts)
|
|
165
211
|
? data.facts.map(metadataValue).filter(Boolean)
|
|
166
212
|
: [];
|
|
167
213
|
const repository = field('repository');
|
|
168
214
|
const branch = field('branch');
|
|
169
|
-
const harness = field('harness');
|
|
215
|
+
const harness = creatorId(field('harness'));
|
|
170
216
|
const agent = field('agent');
|
|
171
217
|
const agentLabel = agentDisplayName(harness, agent);
|
|
172
218
|
const { links } = parseArtifactLinks(data.links);
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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;
|
|
177
232
|
return {
|
|
178
|
-
|
|
233
|
+
project,
|
|
234
|
+
kind: field('kind') || field('context'),
|
|
179
235
|
status: field('status'),
|
|
236
|
+
creator: { agent: agentLabel, harness, human: field('human') },
|
|
237
|
+
timestamps: buildTimestamps(data, sourceMtimeIso),
|
|
180
238
|
facts,
|
|
181
239
|
links: links.map((link) => ({
|
|
182
240
|
value: link.label,
|
|
183
241
|
href: link.url,
|
|
184
242
|
icon: linkIconHtml(link.url),
|
|
185
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.
|
|
186
246
|
provenance: [
|
|
187
247
|
repository ? { value: repository, href: repositoryHref(repository) } : undefined,
|
|
188
248
|
branch ? { value: branch } : undefined,
|
|
189
249
|
field('tracking') ? { value: field('tracking') } : undefined,
|
|
190
|
-
agentLabel ? { value: agentLabel } : undefined,
|
|
191
|
-
field('human') ? { value: field('human') } : undefined,
|
|
192
250
|
field('host') ? { value: field('host') } : undefined,
|
|
193
251
|
field('session') ? { value: field('session'), href: sessionDeepLink(field('sessionId') || field('session')) } : undefined,
|
|
194
252
|
field('date') ? { value: field('date') } : undefined,
|
|
@@ -207,11 +265,44 @@ function statusBadge(status) {
|
|
|
207
265
|
const slug = slugify(status) || 'unknown';
|
|
208
266
|
return `<span class="status-badge status-${escapeHtml(slug)}">${escapeHtml(status)}</span>`;
|
|
209
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
|
+
*/
|
|
210
273
|
function kickerHtml(metadata) {
|
|
211
|
-
const parts =
|
|
212
|
-
|
|
213
|
-
.
|
|
214
|
-
|
|
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>`;
|
|
215
306
|
}
|
|
216
307
|
function factsLine(facts) {
|
|
217
308
|
if (!facts.length)
|
|
@@ -238,11 +329,21 @@ function provenanceLine(parts) {
|
|
|
238
329
|
});
|
|
239
330
|
return `<p class="provenance-line" aria-label="Provenance">${items.join('<span class="meta-sep" aria-hidden="true">·</span>')}</p>`;
|
|
240
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
|
+
}
|
|
241
342
|
function metadataBlock(metadata) {
|
|
242
343
|
const body = [
|
|
243
344
|
factsLine(metadata.facts),
|
|
244
345
|
linksBlock(metadata.links),
|
|
245
|
-
|
|
346
|
+
provenanceDetails(metadata.provenance),
|
|
246
347
|
].filter(Boolean).join('');
|
|
247
348
|
return body ? `<div class="meta" aria-label="Artifact metadata">${body}</div>` : '';
|
|
248
349
|
}
|
|
@@ -273,6 +374,16 @@ function inlineLocalAssets(html, baseDir, diagnostics) {
|
|
|
273
374
|
return ` src="data:${mimeFor(path)};base64,${data}"`;
|
|
274
375
|
});
|
|
275
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
|
+
}
|
|
276
387
|
export function slugify(text) {
|
|
277
388
|
return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
278
389
|
}
|
|
@@ -687,6 +798,16 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
687
798
|
</script>`;
|
|
688
799
|
const readerScript = `<script>
|
|
689
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
|
+
});
|
|
690
811
|
// Scroll-spy: mark the section the reader is currently in. The active heading
|
|
691
812
|
// is the last one whose top has passed the reading line, so a heading is
|
|
692
813
|
// "current" from the moment it reaches the top, not when it leaves.
|
|
@@ -746,19 +867,40 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
746
867
|
} catch {}
|
|
747
868
|
})();
|
|
748
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.
|
|
749
881
|
const reloadScript = `<script>
|
|
750
882
|
(() => {
|
|
751
|
-
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 || '';
|
|
752
885
|
const chip = document.querySelector('.reload-chip');
|
|
753
|
-
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;
|
|
754
889
|
chip.addEventListener('click', () => location.reload());
|
|
890
|
+
let inFlight = false;
|
|
755
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;
|
|
756
895
|
try {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
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());
|
|
760
902
|
if (next && next !== current) chip.hidden = false;
|
|
761
|
-
} catch {}
|
|
903
|
+
} catch {} finally { inFlight = false; }
|
|
762
904
|
};
|
|
763
905
|
setInterval(check, 1500);
|
|
764
906
|
})();
|
|
@@ -856,21 +998,32 @@ function shell(title, summary, header, footer, metadata, body, source, styles, d
|
|
|
856
998
|
})();
|
|
857
999
|
</script>` : '';
|
|
858
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>` : '';
|
|
859
|
-
|
|
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>
|
|
860
1010
|
<html lang="en"${themeAttribute}>
|
|
861
1011
|
<head>
|
|
862
1012
|
<meta charset="utf-8">
|
|
863
1013
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
864
1014
|
<meta name="robots" content="noindex">
|
|
1015
|
+
<meta name="${CONTENT_HASH_META}" content="${CONTENT_HASH_PLACEHOLDER}">
|
|
865
1016
|
<meta name="${BODY_REVISION_META}" content="${escapeHtml(revision)}">
|
|
866
|
-
<title>${escapeHtml(
|
|
1017
|
+
<title>${escapeHtml(documentTitle)}</title>
|
|
1018
|
+
${creatorFavicon(metadata.creator.harness)}
|
|
867
1019
|
<style>
|
|
868
1020
|
${styles}
|
|
869
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}
|
|
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}
|
|
870
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}
|
|
871
1024
|
.artifact-figure-diagram{--artifact-fg:#e7ece8;--artifact-muted:#b7c0b8;--artifact-accent:#a3e635}.artifact-figure.artifact-figure-diagram figcaption{color:var(--artifact-muted)}
|
|
872
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}}
|
|
873
|
-
@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)}.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}}
|
|
874
1027
|
</style>
|
|
875
1028
|
${worksheet ? `<style>
|
|
876
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)}
|
|
@@ -890,21 +1043,26 @@ ${worksheet ? `<style>
|
|
|
890
1043
|
</head>
|
|
891
1044
|
<body>
|
|
892
1045
|
<main>
|
|
893
|
-
<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>
|
|
894
1047
|
${worksheetToolbar}
|
|
895
|
-
<
|
|
1048
|
+
<style>${COVER_CSS}</style>
|
|
1049
|
+
<section class="hero creator-cover cover-${coverClass(metadata.creator.harness)}">
|
|
1050
|
+
${coverArtwork(metadata.creator.harness)}
|
|
1051
|
+
${coverTop(metadata)}
|
|
896
1052
|
${kickerHtml(metadata)}
|
|
897
1053
|
<h1>${escapeHtml(title)}</h1>
|
|
898
1054
|
${summary ? `<p class="summary">${summary}</p>` : ''}
|
|
899
|
-
${
|
|
1055
|
+
${creatorLine(metadata)}
|
|
900
1056
|
</section>
|
|
1057
|
+
<div class="hero-metadata">${metadataBlock(metadata)}</div>
|
|
901
1058
|
${body}
|
|
902
1059
|
${footer ? `<footer class="document-footer">${escapeHtml(footer)}</footer>` : ''}
|
|
903
1060
|
</main>
|
|
904
1061
|
${sourceJson}
|
|
905
|
-
${themeScript}${readerScript}${reloadScript}${worksheetScript}${SECTION_COLLAPSE_SCRIPT}${READER_ANCHORS_SCRIPT}${HIGHLIGHTS_SCRIPT}${COLLAB_SCRIPT}
|
|
1062
|
+
${themeScript}${FRESHNESS_SCRIPT}${readerScript}${reloadScript}${worksheetScript}${SECTION_COLLAPSE_SCRIPT}${READER_ANCHORS_SCRIPT}${HIGHLIGHTS_SCRIPT}${COLLAB_SCRIPT}
|
|
906
1063
|
</body>
|
|
907
1064
|
</html>`;
|
|
1065
|
+
return document.replace(CONTENT_HASH_PLACEHOLDER, createHash('sha256').update(document).digest('hex').slice(0, 16));
|
|
908
1066
|
}
|
|
909
1067
|
function paletteVariables(palette) {
|
|
910
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};`;
|
|
@@ -956,7 +1114,7 @@ export async function renderMarkdown(filePath, options = {}) {
|
|
|
956
1114
|
const summary = renderInlineMarkdown(String(data.summary || ''));
|
|
957
1115
|
const header = metadataValue(data.header);
|
|
958
1116
|
const footer = metadataValue(data.footer);
|
|
959
|
-
const metadata = artifactMetadata(data);
|
|
1117
|
+
const metadata = artifactMetadata(data, fileMtimeIso(abs));
|
|
960
1118
|
let body = String(await markdownRenderer.parse(markInProgressTasks(content), { gfm: true, breaks: false }));
|
|
961
1119
|
body = transformChecklists(body);
|
|
962
1120
|
// Pills are applied after the sanitizer so the brand marks, favicons, and pill
|
|
@@ -999,7 +1157,7 @@ export function normalizeHtml(filePath) {
|
|
|
999
1157
|
const design = cssFromDesign(dirname(abs));
|
|
1000
1158
|
const body = sanitizeBody(raw);
|
|
1001
1159
|
return {
|
|
1002
|
-
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)),
|
|
1003
1161
|
diagnostics: design.diagnostics,
|
|
1004
1162
|
};
|
|
1005
1163
|
}
|