@bytesbybrandon/living-docs 0.1.1 → 0.2.0
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/README.md +1 -0
- package/package.json +2 -2
- package/samples/end-of-harness-engineering.json +2 -0
- package/samples/harness-engineering.json +3 -0
- package/src/model/schema.js +1 -0
- package/src/render/blocks.js +36 -2
- package/src/render/svg.js +15 -12
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Ships an AXI CLI and a stdio MCP server over the same core.
|
|
|
12
12
|
|
|
13
13
|
* **Three themes:** `paper-light` for papers and reports, `paper-dark` for reading notes and essays, `hud` for repo audits and system snapshots.
|
|
14
14
|
* **Generated visuals:** diagrams and charts render as inline SVG from a compact spec, and the console hero uses a seeded graph layout.
|
|
15
|
+
* **Figure motion:** `draw`, `reveal`, and `steps` animate a generated figure with scoped CSS, then freeze for print and reduced motion. See [Document model](docs/guide/document-model.md).
|
|
15
16
|
* **Per-source style tokens:** palette, seed color, type pairing, density, and figure treatment adapt a theme without arbitrary CSS. See [Style tokens](docs/guide/style-tokens.md).
|
|
16
17
|
* **One self-contained file:** inline CSS, inline SVG, no network assets, and print rules. See [Guarantees](docs/guide/guarantees.md).
|
|
17
18
|
* **Engine and interfaces:** the same core powers the CLI and the MCP server.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytesbybrandon/living-docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Turn a source document into a designed, self-contained living doc: academic paper, dark reading notes, or telemetry console. Ships an AXI CLI and an MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"test": "node --test tests/cli.test.js tests/ingest.test.js tests/mcp.test.js tests/render.test.js tests/style.test.js tests/validate.test.js",
|
|
50
|
+
"test": "node --test tests/cli.test.js tests/ingest.test.js tests/mcp.test.js tests/motion.test.js tests/render.test.js tests/style.test.js tests/validate.test.js",
|
|
51
51
|
"samples": "node scripts/build-samples.js"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"type": "figure",
|
|
43
43
|
"caption": "Two ways to write a harness. The hand-written path is a single guess; the loop-written path reads failures, proposes edits, and keeps only what survives held-out scoring.",
|
|
44
44
|
"spec": "diagram",
|
|
45
|
+
"motion": "draw",
|
|
45
46
|
"span": "page",
|
|
46
47
|
"diagram": {
|
|
47
48
|
"width": 1000,
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
"type": "figure",
|
|
112
113
|
"caption": "Held-out score by round. Each round the editor proposes eight edits; the seven rejected are grey, the kept one is orange. The harness changes only when an edit wins.",
|
|
113
114
|
"spec": "chart",
|
|
115
|
+
"motion": "steps",
|
|
114
116
|
"chart": {
|
|
115
117
|
"kind": "scatter",
|
|
116
118
|
"height": 380,
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"type": "figure",
|
|
42
42
|
"caption": "An agent is a model plus a harness of seven subsystems. The harness owns everything outside the weights.",
|
|
43
43
|
"spec": "diagram",
|
|
44
|
+
"motion": "draw",
|
|
44
45
|
"diagram": {
|
|
45
46
|
"width": 1000,
|
|
46
47
|
"height": 440,
|
|
@@ -118,6 +119,7 @@
|
|
|
118
119
|
"type": "figure",
|
|
119
120
|
"caption": "Extensibility standards across eleven coding harnesses. Counts include partial support, greyed in the paper's original figure.",
|
|
120
121
|
"spec": "chart",
|
|
122
|
+
"motion": "steps",
|
|
121
123
|
"chart": {
|
|
122
124
|
"kind": "bar",
|
|
123
125
|
"height": 340,
|
|
@@ -163,6 +165,7 @@
|
|
|
163
165
|
"type": "figure",
|
|
164
166
|
"caption": "Convergence becomes imitation: Codex reads Claude Code's hook vocabulary while OpenHands reads its plugin format.",
|
|
165
167
|
"spec": "diagram",
|
|
168
|
+
"motion": "draw",
|
|
166
169
|
"diagram": {
|
|
167
170
|
"width": 1000,
|
|
168
171
|
"height": 300,
|
package/src/model/schema.js
CHANGED
|
@@ -157,6 +157,7 @@ export const BLOCKS = {
|
|
|
157
157
|
spec: oneOf(['diagram', 'chart'], 'which generator to use'),
|
|
158
158
|
diagram: { ...diagramSpec, optional: true },
|
|
159
159
|
chart: { ...chartSpec, optional: true },
|
|
160
|
+
motion: oneOf(['none', 'draw', 'reveal', 'steps'], 'static CSS animation for the figure; print and reduced motion stay static', { optional: true }),
|
|
160
161
|
span: oneOf(['column', 'page'], 'column width or full page', { optional: true })
|
|
161
162
|
},
|
|
162
163
|
check(value, path, err) {
|
package/src/render/blocks.js
CHANGED
|
@@ -17,19 +17,53 @@ export function createContext({ theme, palette, baseDir, model }) {
|
|
|
17
17
|
|
|
18
18
|
const spanClass = block => (block.span === 'page' ? ' span-page' : '');
|
|
19
19
|
|
|
20
|
+
function motionCss(id, motion) {
|
|
21
|
+
if (!motion || motion === 'none') return '';
|
|
22
|
+
const scope = `#${id}`;
|
|
23
|
+
const reset = `
|
|
24
|
+
@media (prefers-reduced-motion: reduce){
|
|
25
|
+
${scope} *{animation:none !important;opacity:1 !important;transform:none !important;stroke-dashoffset:0 !important}
|
|
26
|
+
}
|
|
27
|
+
@media print{
|
|
28
|
+
${scope} *{animation:none !important;opacity:1 !important;transform:none !important;stroke-dashoffset:0 !important}
|
|
29
|
+
}`;
|
|
30
|
+
const keyframes = `@keyframes ld-draw{to{stroke-dashoffset:0}}@keyframes ld-fade{to{opacity:1}}@keyframes ld-grow{to{transform:scaleY(1)}}`;
|
|
31
|
+
if (motion === 'draw') {
|
|
32
|
+
return `<style>${keyframes}
|
|
33
|
+
${scope} .ld-line{stroke-dasharray:1;stroke-dashoffset:1;animation:ld-draw 1000ms ease-out forwards}
|
|
34
|
+
${scope} .d-node,${scope} .ch-point,${scope} .ch-bar,${scope} .ch-legend,${scope} .d-edge-labels{opacity:0.15;animation:ld-fade 420ms ease-out forwards;animation-delay:calc(var(--i,0)*70ms + 420ms)}
|
|
35
|
+
${scope} .ch-bar{transform-box:fill-box;transform-origin:bottom;transform:scaleY(0);animation-name:ld-grow,ld-fade;animation-duration:500ms,300ms;animation-delay:calc(var(--i,0)*50ms + 300ms)}
|
|
36
|
+
${reset}</style>`;
|
|
37
|
+
}
|
|
38
|
+
if (motion === 'steps') {
|
|
39
|
+
return `<style>${keyframes}
|
|
40
|
+
${scope} .ld-line{stroke-dasharray:1;stroke-dashoffset:1;animation:ld-draw 700ms ease-out forwards;animation-delay:calc(var(--i,0)*140ms)}
|
|
41
|
+
${scope} .d-node,${scope} .ch-point,${scope} .ch-legend,${scope} .d-edge-labels{opacity:0.15;animation:ld-fade 360ms ease-out forwards;animation-delay:calc(var(--i,0)*140ms + 120ms)}
|
|
42
|
+
${scope} .ch-bar{transform-box:fill-box;transform-origin:bottom;transform:scaleY(0);opacity:0.15;animation:ld-grow 420ms ease-out forwards,ld-fade 200ms ease-out forwards;animation-delay:calc(var(--i,0)*120ms),calc(var(--i,0)*120ms)}
|
|
43
|
+
${reset}</style>`;
|
|
44
|
+
}
|
|
45
|
+
return `<style>${keyframes}
|
|
46
|
+
${scope} .d-node,${scope} .ch-point,${scope} .ch-bar,${scope} .ch-legend,${scope} .d-edge-labels{opacity:0.15;animation:ld-fade 420ms ease-out forwards;animation-delay:calc(var(--i,0)*70ms)}
|
|
47
|
+
${scope} .ld-line{stroke-dasharray:1;stroke-dashoffset:1;animation:ld-draw 800ms ease-out forwards}
|
|
48
|
+
${reset}</style>`;
|
|
49
|
+
}
|
|
50
|
+
|
|
20
51
|
function renderFigure(block, ctx) {
|
|
21
52
|
const number = ++ctx.counters.figure;
|
|
22
53
|
const span = block.span || (ctx.theme === 'hud' ? 'column' : 'page');
|
|
54
|
+
const motion = block.motion || 'none';
|
|
23
55
|
let svg = '';
|
|
24
56
|
try {
|
|
25
57
|
svg = block.spec === 'diagram'
|
|
26
|
-
? diagramSvg(block.diagram, ctx.palette, { figure: ctx.style?.figure })
|
|
27
|
-
: chartSvg(block.chart, ctx.palette, { figure: ctx.style?.figure });
|
|
58
|
+
? diagramSvg(block.diagram, ctx.palette, { figure: ctx.style?.figure, motion })
|
|
59
|
+
: chartSvg(block.chart, ctx.palette, { figure: ctx.style?.figure, motion });
|
|
28
60
|
} catch (error) {
|
|
29
61
|
ctx.warnings.push(`figure ${number}: ${error.message}`);
|
|
30
62
|
svg = `<div class="fig-error">Figure unavailable: ${escapeHtml(error.message)}</div>`;
|
|
31
63
|
}
|
|
64
|
+
const motionStyle = motionCss(`fig-${number}`, motion);
|
|
32
65
|
return `<figure class="fig${span === 'page' ? ' span-page' : ''}" id="fig-${number}">
|
|
66
|
+
${motionStyle}
|
|
33
67
|
<div class="fig-frame">${svg}</div>
|
|
34
68
|
<figcaption><span class="fig-num">Fig. ${number}.</span> ${renderInline(block.caption)}</figcaption>
|
|
35
69
|
</figure>`;
|
package/src/render/svg.js
CHANGED
|
@@ -60,7 +60,7 @@ function iconMarkup(node, palette) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export function diagramSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
63
|
+
export function diagramSvg(spec, palette, { figure = 'outline', motion = 'none' } = {}) {
|
|
64
64
|
const W = spec.width || 1000;
|
|
65
65
|
const H = spec.height || 520;
|
|
66
66
|
const nodes = (spec.nodes || []).map(node => ({ w: 150, h: 56, kind: 'box', icon: 'none', ...node }));
|
|
@@ -126,7 +126,8 @@ export function diagramSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
const markerEnd = edge.style === 'line' ? '' : ` marker-end="url(#${marker})"`;
|
|
129
|
-
|
|
129
|
+
const animLine = motion !== 'none' && edge.style !== 'dashed' ? ' class="ld-line" pathLength="1"' : '';
|
|
130
|
+
edges.push(`<path${animLine} d="${d}" fill="none" stroke="${stroke}" stroke-width="1.1"${dash}${markerEnd}/>`);
|
|
130
131
|
if (edge.label) {
|
|
131
132
|
edgeLabels.push(`<text x="${round(labelPoint.x)}" y="${round(labelPoint.y)}" text-anchor="${labelPoint.anchor}" font-size="10.5" fill="${palette.ink}" stroke="${palette.bg}" stroke-width="4" paint-order="stroke" stroke-linejoin="round">${escapeHtml(edge.label)}</text>`);
|
|
132
133
|
}
|
|
@@ -135,6 +136,7 @@ export function diagramSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
|
135
136
|
|
|
136
137
|
// Nodes.
|
|
137
138
|
const nodeMarkup = [];
|
|
139
|
+
let nodeIndex = 0;
|
|
138
140
|
for (const node of nodes) {
|
|
139
141
|
const minimal = figure === 'minimal';
|
|
140
142
|
const solid = figure === 'solid';
|
|
@@ -154,7 +156,7 @@ export function diagramSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
|
154
156
|
const blockHeight = lines.length * lineHeight + (node.sub ? 13 : 0) + iconSpace;
|
|
155
157
|
let textY = node.y + (node.h - blockHeight) / 2 + lineHeight - 4 + iconSpace;
|
|
156
158
|
|
|
157
|
-
nodeMarkup.push(`<g class="d-node d-node-${node.kind}">`);
|
|
159
|
+
nodeMarkup.push(`<g class="d-node d-node-${node.kind}" style="--i:${nodeIndex++}">`);
|
|
158
160
|
if (node.kind === 'stack') {
|
|
159
161
|
nodeMarkup.push(`<rect x="${node.x + 5}" y="${node.y + 5}" width="${node.w}" height="${node.h}" rx="2" fill="${palette.surface}" stroke="${palette.muted}" stroke-opacity="0.5"/>`);
|
|
160
162
|
}
|
|
@@ -170,7 +172,7 @@ export function diagramSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
|
170
172
|
nodeMarkup.push('</g>');
|
|
171
173
|
}
|
|
172
174
|
parts.push(`<g class="d-nodes">${nodeMarkup.join('')}</g>`);
|
|
173
|
-
if (edgeLabels.length) parts.push(`<g class="d-edge-labels">${edgeLabels.join('')}</g>`);
|
|
175
|
+
if (edgeLabels.length) parts.push(`<g class="d-edge-labels" style="--i:${nodes.length}">${edgeLabels.join('')}</g>`);
|
|
174
176
|
|
|
175
177
|
if (spec.notes?.length) {
|
|
176
178
|
const notes = spec.notes.map((note, i) =>
|
|
@@ -201,7 +203,7 @@ function seriesPoints(series) {
|
|
|
201
203
|
return (series.values || []).map((value, i) => ({ x: i + 1, y: value, label: series.labels?.[i] }));
|
|
202
204
|
}
|
|
203
205
|
|
|
204
|
-
export function chartSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
206
|
+
export function chartSvg(spec, palette, { figure = 'outline', motion = 'none' } = {}) {
|
|
205
207
|
const W = spec.width || 1000;
|
|
206
208
|
const H = spec.height || 420;
|
|
207
209
|
const showGrid = figure !== 'minimal';
|
|
@@ -257,6 +259,7 @@ export function chartSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
|
257
259
|
const barWidth = Math.max(4, Math.min(64, (slot * 0.55) / series.length));
|
|
258
260
|
|
|
259
261
|
const legend = [];
|
|
262
|
+
let markIndex = 0;
|
|
260
263
|
series.forEach((item, seriesIndex) => {
|
|
261
264
|
const tone = palette[item.tone] || palette.accent;
|
|
262
265
|
const points = seriesPoints(item).sort((a, b) => a.x - b.x);
|
|
@@ -267,24 +270,24 @@ export function chartSvg(spec, palette, { figure = 'outline' } = {}) {
|
|
|
267
270
|
const x = sx(point.x) - (series.length * barWidth) / 2 + seriesIndex * barWidth;
|
|
268
271
|
const y = sy(Math.max(yMin, point.y));
|
|
269
272
|
const height = Math.max(1, margin.t + plotH - y);
|
|
270
|
-
parts.push(`<rect x="${round(x)}" y="${round(y)}" width="${round(barWidth - 1.5)}" height="${round(height)}" fill="${tone}" fill-opacity="0.9"/>`);
|
|
273
|
+
parts.push(`<rect class="ch-bar" style="--i:${markIndex++}" x="${round(x)}" y="${round(y)}" width="${round(barWidth - 1.5)}" height="${round(height)}" fill="${tone}" fill-opacity="0.9"/>`);
|
|
271
274
|
});
|
|
272
275
|
} else if (item.kind === 'step' || spec.kind === 'steps') {
|
|
273
276
|
let d = `M ${round(sx(points[0].x))} ${round(sy(points[0].y))}`;
|
|
274
277
|
for (let i = 1; i < points.length; i++) {
|
|
275
278
|
d += ` H ${round(sx(points[i].x))} V ${round(sy(points[i].y))}`;
|
|
276
279
|
}
|
|
277
|
-
parts.push(`<path d="${d}" fill="none" stroke="${tone}" stroke-width="1.6"/>`);
|
|
278
|
-
points.forEach(point => parts.push(`<circle cx="${round(sx(point.x))}" cy="${round(sy(point.y))}" r="2.6" fill="${tone}"/>`));
|
|
280
|
+
parts.push(`<path${motion !== 'none' ? ' class="ld-line" pathLength="1"' : ''} d="${d}" fill="none" stroke="${tone}" stroke-width="1.6"/>`);
|
|
281
|
+
points.forEach(point => parts.push(`<circle class="ch-point" style="--i:${markIndex++}" cx="${round(sx(point.x))}" cy="${round(sy(point.y))}" r="2.6" fill="${tone}"/>`));
|
|
279
282
|
} else if (item.kind === 'dot' || spec.kind === 'scatter') {
|
|
280
|
-
points.forEach(point => parts.push(`<circle cx="${round(sx(point.x))}" cy="${round(sy(point.y))}" r="3.2" fill="${tone}"/>`));
|
|
283
|
+
points.forEach(point => parts.push(`<circle class="ch-point" style="--i:${markIndex++}" cx="${round(sx(point.x))}" cy="${round(sy(point.y))}" r="3.2" fill="${tone}"/>`));
|
|
281
284
|
} else {
|
|
282
285
|
const path = points.map((point, i) => `${i ? 'L' : 'M'} ${round(sx(point.x))} ${round(sy(point.y))}`).join(' ');
|
|
283
|
-
parts.push(`<path d="${path}" fill="none" stroke="${tone}" stroke-width="1.5"/>`);
|
|
284
|
-
points.forEach(point => parts.push(`<circle cx="${round(sx(point.x))}" cy="${round(sy(point.y))}" r="3.4" fill="${tone}" stroke="${palette.bg}" stroke-width="0.8"/>`));
|
|
286
|
+
parts.push(`<path${motion !== 'none' ? ' class="ld-line" pathLength="1"' : ''} d="${path}" fill="none" stroke="${tone}" stroke-width="1.5"/>`);
|
|
287
|
+
points.forEach(point => parts.push(`<circle class="ch-point" style="--i:${markIndex++}" cx="${round(sx(point.x))}" cy="${round(sy(point.y))}" r="3.4" fill="${tone}" stroke="${palette.bg}" stroke-width="0.8"/>`));
|
|
285
288
|
}
|
|
286
289
|
|
|
287
|
-
legend.push(`<g><rect x="0" y="-6" width="10" height="7" fill="${tone}"/><text x="15" y="0" font-size="10.5" fill="${palette.ink}">${escapeHtml(item.name)}</text></g>`);
|
|
290
|
+
legend.push(`<g class="ch-legend" style="--i:${markIndex++}"><rect x="0" y="-6" width="10" height="7" fill="${tone}"/><text x="15" y="0" font-size="10.5" fill="${palette.ink}">${escapeHtml(item.name)}</text></g>`);
|
|
288
291
|
});
|
|
289
292
|
|
|
290
293
|
for (const note of spec.annotations || []) {
|