@venizia/vulcan 0.4.5 → 0.4.7
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/LICENSE.md +1 -1
- package/README.md +13 -0
- package/base/checks/wiki-anchors.ts +8 -0
- package/base/checks/wiki-source-links.ts +8 -0
- package/base/hooks/guard-git.ts +9 -2
- package/base/hooks/guard-writes.ts +4 -0
- package/base/hooks/session-start.ts +14 -4
- package/base/make/vulcan.mk +12 -1
- package/base/references/delegation-brief.md +5 -4
- package/base/rules.md +2 -2
- package/base/skills/docs-writing/SKILL.md +1 -1
- package/base/skills/docs-writing/references/agent-documents.md +1 -1
- package/base/skills/knowledge-sync/SKILL.md +1 -1
- package/base/skills/plan-a-change/SKILL.md +2 -2
- package/base/skills/plan-a-change/evals/evals.json +6 -0
- package/base/skills/plan-a-change/references/spec-card.md +1 -0
- package/base/skills/report-back/SKILL.md +1 -1
- package/base/skills/retro/SKILL.md +1 -1
- package/base/skills/review-a-change/SKILL.md +1 -1
- package/base/skills/ship/SKILL.md +1 -1
- package/base/skills/visualize-work/SKILL.md +33 -11
- package/base/skills/visualize-work/references/spec.md +77 -12
- package/package.json +4 -4
- package/src/config/schema.ts +58 -4
- package/src/doctor/checks.ts +29 -1
- package/src/doctor/runner.ts +2 -0
- package/src/hooks/command-view.ts +24 -0
- package/src/hooks/common/constants.ts +10 -0
- package/src/hooks/guard-git.ts +78 -2
- package/src/hooks/guard-outside.ts +20 -3
- package/src/hooks/guard-writes.ts +17 -6
- package/src/hooks/index.ts +2 -0
- package/src/hooks/project-guards.ts +123 -0
- package/src/hooks/project-tmp.ts +36 -0
- package/src/hooks/session-digest.ts +5 -0
- package/src/manifest/render.ts +38 -0
- package/src/sync/claude-launch.ts +48 -0
- package/src/sync/index.ts +1 -0
- package/src/sync/local-choice.ts +2 -0
- package/src/visualize/assets.ts +195 -54
- package/src/visualize/charts.ts +235 -0
- package/src/visualize/constants.ts +106 -1
- package/src/visualize/diagrams.ts +224 -0
- package/src/visualize/icons.ts +28 -0
- package/src/visualize/layout.ts +58 -8
- package/src/visualize/page.ts +152 -146
- package/src/visualize/schema.ts +246 -0
- package/src/visualize/sections.ts +370 -0
- package/src/visualize/validate.ts +100 -7
- package/src/wiki/anchors.ts +118 -0
- package/src/wiki/command.ts +110 -0
- package/src/wiki/constants.ts +30 -0
- package/src/wiki/index.ts +4 -0
- package/src/wiki/source-links.ts +186 -0
package/src/visualize/layout.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NodeStates } from './constants.ts';
|
|
2
|
+
import { iconSvg } from './icons.ts';
|
|
1
3
|
import type { TVisualizeSpec } from './schema.ts';
|
|
2
4
|
|
|
3
5
|
/** Escapes text for HTML and for an attribute value: everything the spec says is data, never markup. */
|
|
@@ -9,11 +11,21 @@ export const escapeText = (opts: { value: string }): string =>
|
|
|
9
11
|
.replaceAll('"', '"')
|
|
10
12
|
.replaceAll("'", ''');
|
|
11
13
|
|
|
12
|
-
const CELL_WIDTH =
|
|
13
|
-
const CELL_HEIGHT =
|
|
14
|
-
const BOX_WIDTH =
|
|
15
|
-
const BOX_HEIGHT =
|
|
16
|
-
const MARGIN =
|
|
14
|
+
const CELL_WIDTH = 290;
|
|
15
|
+
const CELL_HEIGHT = 112;
|
|
16
|
+
const BOX_WIDTH = 176;
|
|
17
|
+
const BOX_HEIGHT = 60;
|
|
18
|
+
const MARGIN = 24;
|
|
19
|
+
|
|
20
|
+
/** Below this share of its natural width the figure is replaced by a list, so no text drops under 12 px. */
|
|
21
|
+
export const FIGURE_FIT = 0.92;
|
|
22
|
+
|
|
23
|
+
/** The natural width of a figure of `cols` columns, in pixels. */
|
|
24
|
+
export const figureWidth = (opts: { cols: number }): number => MARGIN * 2 + opts.cols * CELL_WIDTH;
|
|
25
|
+
|
|
26
|
+
/** How many columns a flow spans. */
|
|
27
|
+
export const columnsOf = (opts: { flow: NonNullable<TVisualizeSpec['flow']> }): number =>
|
|
28
|
+
Math.max(...opts.flow.nodes.map((node) => node.col)) + 1;
|
|
17
29
|
|
|
18
30
|
interface IPoint {
|
|
19
31
|
x: number;
|
|
@@ -77,7 +89,7 @@ const routeOf = (opts: { from: IPoint; to: IPoint }): { path: string; label: IPo
|
|
|
77
89
|
export const renderFigure = (opts: { flow: NonNullable<TVisualizeSpec['flow']> }): string => {
|
|
78
90
|
const { flow } = opts;
|
|
79
91
|
const byId = new Map(flow.nodes.map((node) => [node.id, node]));
|
|
80
|
-
const width =
|
|
92
|
+
const width = figureWidth({ cols: columnsOf({ flow }) });
|
|
81
93
|
const height = MARGIN * 2 + (Math.max(...flow.nodes.map((node) => node.row)) + 1) * CELL_HEIGHT;
|
|
82
94
|
const edges = flow.edges
|
|
83
95
|
.map((edge) => {
|
|
@@ -98,10 +110,48 @@ export const renderFigure = (opts: { flow: NonNullable<TVisualizeSpec['flow']> }
|
|
|
98
110
|
.map((node) => {
|
|
99
111
|
const centre = centreOf(node);
|
|
100
112
|
const lines = node.sublabel === undefined ? 1 : 2;
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
const tone = node.state === undefined ? '' : ` c-${NodeStates.toneOf(node.state)}`;
|
|
114
|
+
const left = centre.x - BOX_WIDTH / 2;
|
|
115
|
+
const anchor = node.state === undefined ? 'middle' : 'start';
|
|
116
|
+
const textX = node.state === undefined ? centre.x : left + 40;
|
|
117
|
+
const mark =
|
|
118
|
+
node.state === undefined
|
|
119
|
+
? ''
|
|
120
|
+
: `<g class="st" transform="translate(${left + 12} ${centre.y - 10})">${iconSvg({ name: NodeStates.iconOf(node.state), size: 20 }).replace('<svg', '<svg x="0" y="0"')}</g>`;
|
|
121
|
+
|
|
122
|
+
return `<g class="node ${escaped(node.kind ?? 'step')}${tone}" tabindex="0" role="img" aria-label="${escaped(node.label)}${node.sublabel === undefined ? '' : `, ${escaped(node.sublabel)}`}" data-node="${escaped(node.id)}" data-detail="${escaped(node.detail ?? node.sublabel ?? node.label)}"><title>${escaped(node.label)}</title><rect x="${left}" y="${centre.y - BOX_HEIGHT / 2}" width="${BOX_WIDTH}" height="${BOX_HEIGHT}" rx="4"/>${mark}<text x="${textX}" y="${centre.y + (lines === 1 ? 5 : -4)}" text-anchor="${anchor}" class="t">${escaped(node.label)}</text>${node.sublabel === undefined ? '' : `<text x="${textX}" y="${centre.y + 17}" text-anchor="${anchor}" class="s">${escaped(node.sublabel)}</text>`}</g>`;
|
|
103
123
|
})
|
|
104
124
|
.join('');
|
|
105
125
|
|
|
106
126
|
return `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="group" aria-label="flow"><defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0L10 5L0 10z" fill="currentColor"/></marker><marker id="e" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path class="bad" d="M0 0L10 5L0 10z"/></marker></defs>${edges}${nodes}</svg>`;
|
|
107
127
|
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The same flow as a list, for a phone where the figure cannot be read: one row per arrow, then one per box that
|
|
131
|
+
* has a detail. Page CSS shows it only on a narrow screen.
|
|
132
|
+
*/
|
|
133
|
+
export const renderPathList = (opts: { flow: NonNullable<TVisualizeSpec['flow']> }): string => {
|
|
134
|
+
const { flow } = opts;
|
|
135
|
+
const byId = new Map(flow.nodes.map((node) => [node.id, node]));
|
|
136
|
+
const nameOf = (id: string): string => {
|
|
137
|
+
const node = byId.get(id);
|
|
138
|
+
const mark =
|
|
139
|
+
node?.state === undefined
|
|
140
|
+
? ''
|
|
141
|
+
: `<span class="inl c-${NodeStates.toneOf(node.state)}">${iconSvg({ name: NodeStates.iconOf(node.state), size: 16 })}</span>`;
|
|
142
|
+
|
|
143
|
+
return `${mark}${escaped(node?.label ?? id)}`;
|
|
144
|
+
};
|
|
145
|
+
const arrows = flow.edges
|
|
146
|
+
.map(
|
|
147
|
+
(edge) =>
|
|
148
|
+
`<li><b>${nameOf(edge.from)}</b><span class="verb ${escaped(edge.variant ?? 'main')}">${escaped(edge.label)}</span><b>${nameOf(edge.to)}</b></li>`,
|
|
149
|
+
)
|
|
150
|
+
.join('');
|
|
151
|
+
const details = flow.nodes
|
|
152
|
+
.filter((node) => node.detail !== undefined)
|
|
153
|
+
.map((node) => `<li><b>${escaped(node.label)}</b> ${escaped(node.detail ?? '')}</li>`)
|
|
154
|
+
.join('');
|
|
155
|
+
|
|
156
|
+
return `<ol class="path">${arrows}</ol>${details === '' ? '' : `<ul class="path-detail">${details}</ul>`}`;
|
|
157
|
+
};
|
package/src/visualize/page.ts
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { PAGE_CSS, PAGE_JS } from './assets.ts';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
3
|
+
import { DEFAULT_CHROME, NodeStates } from './constants.ts';
|
|
4
|
+
import type { TChrome } from './constants.ts';
|
|
5
|
+
import { iconSvg } from './icons.ts';
|
|
6
|
+
import { stateIcon } from './charts.ts';
|
|
7
|
+
import { escapeText, FIGURE_FIT } from './layout.ts';
|
|
6
8
|
import type { TVisualizeSpec } from './schema.ts';
|
|
9
|
+
import {
|
|
10
|
+
architectureSection,
|
|
11
|
+
beforeAfterSection,
|
|
12
|
+
chip,
|
|
13
|
+
comparisonSection,
|
|
14
|
+
decisionRecordSection,
|
|
15
|
+
decisionsSection,
|
|
16
|
+
evidenceSection,
|
|
17
|
+
explainerSection,
|
|
18
|
+
findingsSection,
|
|
19
|
+
flowSection,
|
|
20
|
+
ideaMapSection,
|
|
21
|
+
linksSection,
|
|
22
|
+
logSection,
|
|
23
|
+
risksSection,
|
|
24
|
+
stateWord,
|
|
25
|
+
tilesHtml,
|
|
26
|
+
timelineSection,
|
|
27
|
+
} from './sections.ts';
|
|
28
|
+
import type { ISectionContext } from './sections.ts';
|
|
7
29
|
|
|
8
30
|
const escaped = (value: string): string => escapeText({ value });
|
|
9
31
|
|
|
10
|
-
/** A page word by its key; a key the page does not know shows as itself. */
|
|
11
|
-
const wordOf = (opts: { words: Record<string, string>; key: string }): string =>
|
|
12
|
-
opts.words[opts.key] ?? opts.key;
|
|
13
|
-
|
|
14
32
|
const definedOnly = (opts: {
|
|
15
33
|
value: Record<string, string | undefined> | undefined;
|
|
16
34
|
}): Record<string, string> =>
|
|
@@ -35,6 +53,10 @@ export const chromeOf = (opts: { spec: TVisualizeSpec }): TChrome => {
|
|
|
35
53
|
...DEFAULT_CHROME,
|
|
36
54
|
...Object.fromEntries(Object.entries(merged).filter(([, value]) => typeof value === 'string')),
|
|
37
55
|
statusStates: { ...DEFAULT_CHROME.statusStates, ...definedOnly({ value: given.statusStates }) },
|
|
56
|
+
minimapStates: {
|
|
57
|
+
...DEFAULT_CHROME.minimapStates,
|
|
58
|
+
...definedOnly({ value: given.minimapStates }),
|
|
59
|
+
},
|
|
38
60
|
evidenceLabels: {
|
|
39
61
|
...DEFAULT_CHROME.evidenceLabels,
|
|
40
62
|
...definedOnly({ value: given.evidenceLabels }),
|
|
@@ -42,170 +64,154 @@ export const chromeOf = (opts: { spec: TVisualizeSpec }): TChrome => {
|
|
|
42
64
|
};
|
|
43
65
|
};
|
|
44
66
|
|
|
45
|
-
/** JSON for a `<script type="application/json">`: nothing in it can close the tag or start a comment. */
|
|
46
|
-
const jsonForScript = (opts: { value: unknown }): string =>
|
|
47
|
-
JSON.stringify(opts.value)
|
|
48
|
-
.replaceAll('<', '\\u003c')
|
|
49
|
-
.replaceAll('>', '\\u003e')
|
|
50
|
-
.replaceAll('&', '\\u0026')
|
|
51
|
-
.replaceAll('
', '\\u2028')
|
|
52
|
-
.replaceAll('
', '\\u2029');
|
|
53
|
-
|
|
54
67
|
const sha256 = (opts: { text: string }): string =>
|
|
55
68
|
`'sha256-${createHash('sha256').update(opts.text).digest('base64')}'`;
|
|
56
69
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
/** The state each status of the spec reads as: a shape, a colour and a word. */
|
|
71
|
+
const BANNER_STATE: Record<string, string> = {
|
|
72
|
+
ok: 'done',
|
|
73
|
+
warn: 'waiting',
|
|
74
|
+
blocked: 'blocked',
|
|
75
|
+
info: 'info',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* For each figure width, the rule that swaps the figure for its list: below the viewport width at which the figure would
|
|
80
|
+
* shrink under FIGURE_FIT of its natural size (text under 12 px). The 66 is the page and frame padding.
|
|
81
|
+
*/
|
|
82
|
+
export const figureFitCss = (opts: { widths: Set<number> }): string =>
|
|
83
|
+
[...opts.widths]
|
|
84
|
+
.sort((a, b) => a - b)
|
|
85
|
+
.map((width) => {
|
|
86
|
+
const at = Math.ceil(width * FIGURE_FIT) + 66;
|
|
87
|
+
|
|
88
|
+
return `@media (max-width:${at}px){.fig.f${width}{display:none}.fig.f${width}~.path,.fig.f${width}~.path-detail{display:block}.fig.f${width}~.bar,.fig.f${width}~#detail,.fig.f${width}~.legend{display:none}}`;
|
|
89
|
+
})
|
|
90
|
+
.join('\n');
|
|
91
|
+
|
|
92
|
+
/** Counts of each minimap state, as tiles: how many tasks are done, in progress, waiting and blocked. */
|
|
93
|
+
const countTiles = (opts: {
|
|
94
|
+
spec: TVisualizeSpec;
|
|
95
|
+
chrome: TChrome;
|
|
96
|
+
}): { value: string; label: string; state: string }[] => {
|
|
97
|
+
const rows = opts.spec.minimap ?? [];
|
|
98
|
+
const count = (state: string): number => rows.filter((row) => row.status === state).length;
|
|
99
|
+
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
value: `${count('done')} / ${rows.length}`,
|
|
103
|
+
label: stateWord({ chrome: opts.chrome, state: 'done' }),
|
|
104
|
+
state: 'done',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
value: String(count('in progress')),
|
|
108
|
+
label: stateWord({ chrome: opts.chrome, state: 'in progress' }),
|
|
109
|
+
state: 'in progress',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
value: String(count('waiting')),
|
|
113
|
+
label: stateWord({ chrome: opts.chrome, state: 'waiting' }),
|
|
114
|
+
state: 'waiting',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
value: String(count('blocked')),
|
|
118
|
+
label: stateWord({ chrome: opts.chrome, state: 'blocked' }),
|
|
119
|
+
state: 'blocked',
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
};
|
|
61
123
|
|
|
62
|
-
const
|
|
63
|
-
|
|
124
|
+
const bannerHtml = (opts: { spec: TVisualizeSpec; chrome: TChrome }): string => {
|
|
125
|
+
const { spec, chrome } = opts;
|
|
126
|
+
const state = BANNER_STATE[spec.status.state] ?? 'info';
|
|
127
|
+
const word =
|
|
128
|
+
spec.status.label ??
|
|
129
|
+
chrome.statusStates[spec.status.state as keyof TChrome['statusStates']] ??
|
|
130
|
+
spec.status.state;
|
|
131
|
+
const meta = [
|
|
132
|
+
spec.asOf === undefined ? '' : `<span>${escaped(chrome.asOf)}: ${escaped(spec.asOf)}</span>`,
|
|
133
|
+
spec.scope === undefined ? '' : `<span>${escaped(chrome.scope)}: ${escaped(spec.scope)}</span>`,
|
|
134
|
+
].join('');
|
|
64
135
|
|
|
65
|
-
|
|
66
|
-
|
|
136
|
+
return `<header class="banner c-${NodeStates.toneOf(state)}" data-slide data-hero><div class="b-ic">${stateIcon({ state, size: 52 })}</div><div class="b-tx"><p class="meta">${meta}</p><p class="word">${escaped(word)}</p><h1>${escaped(spec.title)}</h1><p class="verdict">${escaped(spec.verdict)}</p>${spec.caption === undefined ? '' : `<p class="cap">${escaped(spec.caption)}</p>`}</div></header>`;
|
|
137
|
+
};
|
|
67
138
|
|
|
68
|
-
const
|
|
69
|
-
const {
|
|
139
|
+
const stepperHtml = (opts: { spec: TVisualizeSpec; chrome: TChrome }): string => {
|
|
140
|
+
const { minimap } = opts.spec;
|
|
70
141
|
|
|
71
|
-
if (
|
|
142
|
+
if (minimap === undefined) {
|
|
72
143
|
return '';
|
|
73
144
|
}
|
|
74
145
|
|
|
75
146
|
const { chrome } = opts;
|
|
76
|
-
const kinds = [...new Set(flow.nodes.map((node) => node.kind ?? 'step'))];
|
|
77
|
-
const variants = [...new Set(flow.edges.map((edge) => edge.variant ?? 'main'))];
|
|
78
|
-
const steps = flow.steps;
|
|
79
|
-
const controls = [
|
|
80
|
-
flow.edges.length > 0
|
|
81
|
-
? `<button id="play" type="button" aria-pressed="false" data-play="${escaped(chrome.play)}" data-pause="${escaped(chrome.pause)}">${escaped(chrome.play)}</button>`
|
|
82
|
-
: '',
|
|
83
|
-
steps.length > 0
|
|
84
|
-
? `<button id="prev" type="button">${escaped(chrome.previous)}</button><button id="next" type="button">${escaped(chrome.following)}</button><button id="all" type="button">${escaped(chrome.allSteps)}</button>`
|
|
85
|
-
: '',
|
|
86
|
-
].join('');
|
|
87
147
|
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
? `<ol class="steps">${steps.map((step) => `<li><b>${escaped(step.title)}</b> - ${escaped(step.note)}</li>`).join('')}</ol><script type="application/json" id="steps">${jsonForScript({ value: steps })}</script>`
|
|
95
|
-
: ''
|
|
96
|
-
}`,
|
|
97
|
-
});
|
|
148
|
+
return `<section class="sec" id="minimap" data-slide><h2 class="lab">${escaped(chrome.minimap)}</h2><ol class="strip">${minimap
|
|
149
|
+
.map(
|
|
150
|
+
(row) =>
|
|
151
|
+
`<li class="seg c-${NodeStates.toneOf(row.status)}"><span class="bar"></span><span class="nm">${chip({ chrome, state: row.status })}<span class="tn">${escaped(row.task)}</span></span>${row.note === undefined ? '' : `<span class="nt">${escaped(row.note)}</span>`}</li>`,
|
|
152
|
+
)
|
|
153
|
+
.join('')}</ol></section>`;
|
|
98
154
|
};
|
|
99
155
|
|
|
100
|
-
|
|
101
|
-
|
|
156
|
+
/** What the owner has to do and what blocks it: the first thing after the verdict. */
|
|
157
|
+
const ownerHtml = (opts: { spec: TVisualizeSpec; chrome: TChrome }): string => {
|
|
158
|
+
const { spec, chrome } = opts;
|
|
102
159
|
|
|
103
|
-
if (
|
|
160
|
+
if (spec.strip === undefined) {
|
|
104
161
|
return '';
|
|
105
162
|
}
|
|
106
163
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return `<section><h3>${escaped(title)}</h3><ul>${items
|
|
116
|
-
.map((item) =>
|
|
117
|
-
item.change === kind
|
|
118
|
-
? `<li class="${kind}">${escaped(item.text)} <small>(${escaped(kind === ChangeKinds.ADDED ? chrome.added : chrome.removed)})</small></li>`
|
|
119
|
-
: `<li>${escaped(item.text)}</li>`,
|
|
120
|
-
)
|
|
121
|
-
.join('')}</ul></section>`;
|
|
122
|
-
};
|
|
164
|
+
const jump =
|
|
165
|
+
spec.decisions === undefined
|
|
166
|
+
? ''
|
|
167
|
+
: `<a class="jump" href="#decisions">${escaped(chrome.decisions)} (${spec.decisions.length})</a>`;
|
|
168
|
+
const actions =
|
|
169
|
+
spec.actions === undefined
|
|
170
|
+
? ''
|
|
171
|
+
: `<ol class="check">${spec.actions.map((action) => `<li>${escaped(action)}</li>`).join('')}</ol>`;
|
|
123
172
|
|
|
124
|
-
return
|
|
125
|
-
title: `${chrome.before} / ${chrome.after}`,
|
|
126
|
-
body: `<div class="ba">${side({ ...beforeAfter.before, kind: ChangeKinds.REMOVED })}${side({ ...beforeAfter.after, kind: ChangeKinds.ADDED })}</div>`,
|
|
127
|
-
});
|
|
173
|
+
return `<section class="two" data-slide><div class="card action"><p class="lab">${escaped(chrome.next)}</p><h2>${escaped(spec.strip.next)}</h2>${actions}${jump}</div><div class="card blocked"><p class="lab">${escaped(chrome.blockedBy)}</p><p class="bb">${iconSvg({ name: 'waiting', size: 20 })}<span>${escaped(spec.strip.blockedBy)}</span></p><p class="ok-line">${iconSvg({ name: 'done', size: 16 })}<span><b>${escaped(chrome.healthy)}</b> ${escaped(spec.strip.healthy)}</span></p><p class="ok-line">${iconSvg({ name: 'info', size: 16 })}<span><b>${escaped(chrome.changed)}</b> ${escaped(spec.strip.changed)}</span></p></div></section>`;
|
|
128
174
|
};
|
|
129
175
|
|
|
130
176
|
/** The whole page: one file, no network, a content-security policy that allows only the page's own style and script by hash. */
|
|
131
177
|
export const renderPage = (opts: { spec: TVisualizeSpec }): string => {
|
|
132
178
|
const { spec } = opts;
|
|
133
179
|
const chrome = chromeOf({ spec });
|
|
134
|
-
const {
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
spec.
|
|
138
|
-
spec.
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
spec.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
spec.decisions === undefined
|
|
146
|
-
? ''
|
|
147
|
-
: sectionOf({
|
|
148
|
-
title: chrome.decisions,
|
|
149
|
-
body: `<ol class="d">${spec.decisions
|
|
150
|
-
.map(
|
|
151
|
-
(item) =>
|
|
152
|
-
`<li>${escaped(item.question)}<br><b>${escaped(chrome.recommended)}:</b> ${escaped(item.recommended)}<br><small>${escaped(chrome.changesClaim)}: ${escaped(item.changes)}</small></li>`,
|
|
153
|
-
)
|
|
154
|
-
.join('')}</ol>`,
|
|
155
|
-
});
|
|
156
|
-
const evidence =
|
|
157
|
-
spec.evidence === undefined
|
|
180
|
+
const ctx: ISectionContext = { spec, chrome, fits: new Set<number>() };
|
|
181
|
+
const state = BANNER_STATE[spec.status.state] ?? 'info';
|
|
182
|
+
const word =
|
|
183
|
+
spec.status.label ??
|
|
184
|
+
chrome.statusStates[spec.status.state as keyof TChrome['statusStates']] ??
|
|
185
|
+
spec.status.state;
|
|
186
|
+
const tiles =
|
|
187
|
+
spec.tiles ?? (spec.minimap === undefined ? undefined : countTiles({ spec, chrome }));
|
|
188
|
+
const body = [
|
|
189
|
+
bannerHtml({ spec, chrome }),
|
|
190
|
+
tiles === undefined
|
|
158
191
|
? ''
|
|
159
|
-
:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
cell({ value: row.risk }),
|
|
183
|
-
cell({ value: row.impact }),
|
|
184
|
-
cell({ value: row.fallback }),
|
|
185
|
-
]),
|
|
186
|
-
}),
|
|
187
|
-
});
|
|
188
|
-
const log =
|
|
189
|
-
spec.log === undefined
|
|
190
|
-
? ''
|
|
191
|
-
: sectionOf({
|
|
192
|
-
title: chrome.log,
|
|
193
|
-
body: table({
|
|
194
|
-
head: ['', ''],
|
|
195
|
-
rows: spec.log.map((row) => [
|
|
196
|
-
cell({ value: row.date, tag: true }),
|
|
197
|
-
cell({ value: row.text }),
|
|
198
|
-
]),
|
|
199
|
-
}),
|
|
200
|
-
});
|
|
201
|
-
const links =
|
|
202
|
-
spec.links === undefined
|
|
203
|
-
? ''
|
|
204
|
-
: sectionOf({
|
|
205
|
-
title: chrome.links,
|
|
206
|
-
body: `<ul>${spec.links.map((link) => `<li><a href="${escaped(link.href)}" rel="noopener noreferrer">${escaped(link.label)}</a></li>`).join('')}</ul>`,
|
|
207
|
-
});
|
|
208
|
-
const policy = `default-src 'none'; style-src ${sha256({ text: PAGE_CSS })}; script-src ${sha256({ text: PAGE_JS })}; base-uri 'none'; form-action 'none'`;
|
|
192
|
+
: `<div data-slide class="slide-tiles">${tilesHtml({ tiles, chrome })}</div>`,
|
|
193
|
+
stepperHtml({ spec, chrome }),
|
|
194
|
+
ownerHtml({ spec, chrome }),
|
|
195
|
+
flowSection({ ctx }),
|
|
196
|
+
architectureSection({ ctx }),
|
|
197
|
+
comparisonSection({ ctx }),
|
|
198
|
+
ideaMapSection({ ctx }),
|
|
199
|
+
explainerSection({ ctx }),
|
|
200
|
+
timelineSection({ ctx }),
|
|
201
|
+
findingsSection({ ctx }),
|
|
202
|
+
beforeAfterSection({ ctx }),
|
|
203
|
+
decisionRecordSection({ ctx }),
|
|
204
|
+
decisionsSection({ ctx }),
|
|
205
|
+
evidenceSection({ ctx }),
|
|
206
|
+
risksSection({ ctx }),
|
|
207
|
+
logSection({ ctx }),
|
|
208
|
+
linksSection({ ctx }),
|
|
209
|
+
].join('');
|
|
210
|
+
const css = `${PAGE_CSS}\n${figureFitCss({ widths: ctx.fits })}`;
|
|
211
|
+
const policy = `default-src 'none'; style-src ${sha256({ text: css })}; script-src ${sha256({ text: PAGE_JS })}; base-uri 'none'; form-action 'none'`;
|
|
212
|
+
const mini = `<div class="mini c-${NodeStates.toneOf(state)}" role="banner">${chip({ chrome, state, size: 18, label: word })}<b>${escaped(spec.title)}</b></div>`;
|
|
213
|
+
const tools = `<div class="tools"><button id="present" type="button" data-on="${escaped(chrome.present)}" data-off="${escaped(chrome.exitPresent)}">${escaped(chrome.present)}</button><button id="theme" type="button">${escaped(chrome.theme)}</button></div>`;
|
|
214
|
+
const deck = `<nav class="deck" aria-label="${escaped(chrome.slide)}"><button id="slide-prev" type="button">${escaped(chrome.previous)}</button><span id="slide-count" aria-live="polite"></span><button id="slide-next" type="button">${escaped(chrome.following)}</button></nav>`;
|
|
209
215
|
|
|
210
|
-
return `<!doctype html><html lang="${escaped(spec.language)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="${escaped(policy)}"><meta name="generator" content="vulcan visualize"><title>${escaped(spec.title)}</title><style>${
|
|
216
|
+
return `<!doctype html><html lang="${escaped(spec.language)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="${escaped(policy)}"><meta name="generator" content="vulcan visualize"><title>${escaped(spec.title)}</title><style>${css}</style></head><body>${mini}<main class="wrap">${tools}${body}<footer>${escaped(chrome.footer)}</footer></main>${deck}<script>${PAGE_JS}</script></body></html>`;
|
|
211
217
|
};
|