@venizia/vulcan 0.4.9-0 → 0.4.9-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/base/extensions/vulcan-guards.ts +48 -41
- package/base/hooks/antigravity-guards.ts +2 -2
- package/base/hooks/codex-guards.ts +15 -5
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +4 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +5 -6
- package/base/hooks/guard-remote-hosts.ts +6 -7
- package/base/hooks/guard-scripting.ts +5 -6
- package/base/hooks/guard-writes.ts +8 -9
- package/base/hooks/post-tool.ts +2 -2
- package/base/hooks/prompt-submit.ts +2 -2
- package/base/hooks/session-start.ts +3 -3
- package/base/hooks/stop.ts +2 -2
- package/base/hooks/subagent-start.ts +2 -2
- package/base/skills/docs-update/SKILL.md +4 -2
- package/base/skills/visualize-work/SKILL.md +9 -0
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +45 -43
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +96 -97
- package/src/agents/hooks-json.ts +38 -36
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +201 -195
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- package/src/commands/add.command.ts +2 -2
- package/src/commands/agents.command.ts +11 -17
- package/src/commands/clean.command.ts +6 -6
- package/src/commands/doctor.command.ts +4 -4
- package/src/commands/init.command.ts +12 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +42 -49
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +80 -75
- package/src/commands/visualize.command.ts +7 -13
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +94 -91
- package/src/common/paths.ts +14 -12
- package/src/config/loader.ts +52 -49
- package/src/config/packages.ts +14 -11
- package/src/config/schema.ts +3 -3
- package/src/create/add-app.ts +519 -509
- package/src/create/add-lib.ts +237 -240
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- package/src/create/diff.ts +21 -23
- package/src/create/dockerignore.ts +26 -24
- package/src/create/files.ts +7 -5
- package/src/create/init-monorepo.ts +75 -80
- package/src/create/lib-preset.ts +59 -63
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +26 -23
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +301 -303
- package/src/create/preset-menu.ts +38 -32
- package/src/create/preset.ts +202 -197
- package/src/create/process.ts +79 -72
- package/src/create/scratch.ts +48 -49
- package/src/create/workspace.ts +404 -396
- package/src/doctor/checks.ts +1027 -1014
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -118
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +42 -37
- package/src/hooks/codex-patch.ts +25 -22
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/decision.ts +37 -37
- package/src/hooks/guard-git.ts +51 -49
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +93 -91
- package/src/hooks/guard-package.ts +82 -79
- package/src/hooks/guard-scripting.ts +19 -14
- package/src/hooks/guard-writes.ts +154 -149
- package/src/hooks/owner-reply.ts +127 -127
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +65 -62
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +153 -130
- package/src/hooks/session-digest.ts +98 -101
- package/src/hooks/shell.ts +509 -499
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +106 -104
- package/src/init/scaffold.ts +135 -132
- package/src/local/clean.ts +38 -36
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +144 -138
- package/src/manifest/render.ts +110 -104
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +99 -93
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +71 -69
- package/src/owner/survey.ts +173 -171
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/rules/base.ts +15 -11
- package/src/rules/parser.ts +39 -32
- package/src/rules/slots.ts +8 -6
- package/src/signals/claims.ts +30 -28
- package/src/signals/classify.ts +38 -33
- package/src/signals/loop.ts +39 -37
- package/src/signals/state.ts +79 -81
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +56 -59
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +36 -34
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +59 -61
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +166 -167
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +38 -38
- package/src/ui/prompt.ts +79 -77
- package/src/visualize/assets.ts +33 -24
- package/src/visualize/charts.ts +179 -176
- package/src/visualize/compare-css.ts +3 -2
- package/src/visualize/compare-render.ts +9 -7
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +7 -5
- package/src/visualize/kinds-render.ts +50 -45
- package/src/visualize/kinds-validate.ts +12 -10
- package/src/visualize/labels.ts +21 -17
- package/src/visualize/layout.ts +112 -97
- package/src/visualize/page.ts +92 -104
- package/src/visualize/render.ts +143 -140
- package/src/visualize/sections.ts +395 -384
- package/src/visualize/sources.ts +2 -2
- package/src/visualize/theme.ts +12 -10
- package/src/visualize/validate.ts +13 -9
- package/src/wiki/anchors.ts +38 -36
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +46 -44
package/src/visualize/labels.ts
CHANGED
|
@@ -27,23 +27,27 @@ const bundledOf = (opts: { language?: string }): TChrome => {
|
|
|
27
27
|
: DEFAULT_CHROME;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
export class Labels {
|
|
31
|
+
/** The strings of the page: the bundled words of the page's language, with whatever the spec replaces. */
|
|
32
|
+
static chromeOf(opts: { spec: TVisualizeSpec; language?: string }): TChrome {
|
|
33
|
+
const given = opts.spec.chrome ?? {};
|
|
34
|
+
const base = bundledOf({ language: opts.language });
|
|
35
|
+
const merged: Record<string, unknown> = { ...base };
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
for (const [key, value] of Object.entries(given)) {
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
merged[key] = value;
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
|
-
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
43
|
+
return {
|
|
44
|
+
...base,
|
|
45
|
+
...Object.fromEntries(
|
|
46
|
+
Object.entries(merged).filter(([, value]) => typeof value === 'string'),
|
|
47
|
+
),
|
|
48
|
+
statusStates: { ...base.statusStates, ...definedOnly({ value: given.statusStates }) },
|
|
49
|
+
minimapStates: { ...base.minimapStates, ...definedOnly({ value: given.minimapStates }) },
|
|
50
|
+
evidenceLabels: { ...base.evidenceLabels, ...definedOnly({ value: given.evidenceLabels }) },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/visualize/layout.ts
CHANGED
|
@@ -1,44 +1,22 @@
|
|
|
1
1
|
import { NodeStates } from './constants.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { IconSet } from './icons.ts';
|
|
3
3
|
import type { TVisualizeSpec } from './schema.ts';
|
|
4
4
|
|
|
5
|
-
/** Escapes text for HTML and for an attribute value: everything the spec says is data, never markup. */
|
|
6
|
-
export const escapeText = (opts: { value: string }): string =>
|
|
7
|
-
opts.value
|
|
8
|
-
.replaceAll('&', '&')
|
|
9
|
-
.replaceAll('<', '<')
|
|
10
|
-
.replaceAll('>', '>')
|
|
11
|
-
.replaceAll('"', '"')
|
|
12
|
-
.replaceAll("'", ''');
|
|
13
|
-
|
|
14
5
|
const CELL_WIDTH = 290;
|
|
15
|
-
const CELL_HEIGHT = 112;
|
|
16
|
-
const BOX_WIDTH = 176;
|
|
17
|
-
const BOX_HEIGHT = 60;
|
|
18
|
-
const MARGIN = 24;
|
|
19
6
|
|
|
20
|
-
|
|
21
|
-
export const FIGURE_FIT = 0.92;
|
|
7
|
+
const CELL_HEIGHT = 112;
|
|
22
8
|
|
|
23
|
-
|
|
24
|
-
export const figureWidth = (opts: { cols: number }): number => MARGIN * 2 + opts.cols * CELL_WIDTH;
|
|
9
|
+
const BOX_WIDTH = 176;
|
|
25
10
|
|
|
26
|
-
|
|
27
|
-
export const columnsOf = (opts: { flow: NonNullable<TVisualizeSpec['flow']> }): number =>
|
|
28
|
-
Math.max(...opts.flow.nodes.map((node) => node.col)) + 1;
|
|
11
|
+
const BOX_HEIGHT = 60;
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
}
|
|
13
|
+
const MARGIN = 24;
|
|
34
14
|
|
|
35
15
|
const centreOf = (opts: { row: number; col: number }): IPoint => ({
|
|
36
16
|
x: MARGIN + opts.col * CELL_WIDTH + CELL_WIDTH / 2,
|
|
37
17
|
y: MARGIN + opts.row * CELL_HEIGHT + CELL_HEIGHT / 2,
|
|
38
18
|
});
|
|
39
19
|
|
|
40
|
-
const escaped = (value: string): string => escapeText({ value });
|
|
41
|
-
|
|
42
20
|
/**
|
|
43
21
|
* The route of an edge between two box centres: straight when they share a row or a column, else an
|
|
44
22
|
* elbow - along the source's row, then along the target's column. The label sits on the longest run.
|
|
@@ -85,78 +63,115 @@ const routeOf = (opts: { from: IPoint; to: IPoint }): { path: string; label: IPo
|
|
|
85
63
|
};
|
|
86
64
|
};
|
|
87
65
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
66
|
+
export class FigureLayout {
|
|
67
|
+
private static escaped(value: string): string {
|
|
68
|
+
return FigureLayout.escapeText({ value });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Escapes text for HTML and for an attribute value: everything the spec says is data, never markup. */
|
|
72
|
+
static escapeText(opts: { value: string }): string {
|
|
73
|
+
return opts.value
|
|
74
|
+
.replaceAll('&', '&')
|
|
75
|
+
.replaceAll('<', '<')
|
|
76
|
+
.replaceAll('>', '>')
|
|
77
|
+
.replaceAll('"', '"')
|
|
78
|
+
.replaceAll("'", ''');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The natural width of a figure of `cols` columns, in pixels. */
|
|
82
|
+
static figureWidth(opts: { cols: number }): number {
|
|
83
|
+
return MARGIN * 2 + opts.cols * CELL_WIDTH;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** How many columns a flow spans. */
|
|
87
|
+
static columnsOf(opts: { flow: NonNullable<TVisualizeSpec['flow']> }): number {
|
|
88
|
+
return Math.max(...opts.flow.nodes.map((node) => node.col)) + 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The figure: boxes on a grid, arrows between them. Every part carries a `data-` id the page script highlights. */
|
|
92
|
+
static render(opts: { flow: NonNullable<TVisualizeSpec['flow']> }): string {
|
|
93
|
+
const { flow } = opts;
|
|
94
|
+
const byId = new Map(flow.nodes.map((node) => [node.id, node]));
|
|
95
|
+
const width = FigureLayout.figureWidth({ cols: FigureLayout.columnsOf({ flow }) });
|
|
96
|
+
const height = MARGIN * 2 + (Math.max(...flow.nodes.map((node) => node.row)) + 1) * CELL_HEIGHT;
|
|
97
|
+
const edges = flow.edges
|
|
98
|
+
.map((edge) => {
|
|
99
|
+
const from = byId.get(edge.from);
|
|
100
|
+
const to = byId.get(edge.to);
|
|
101
|
+
|
|
102
|
+
if (from === undefined || to === undefined) {
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const route = routeOf({ from: centreOf(from), to: centreOf(to) });
|
|
107
|
+
const name = `${edge.from}>${edge.to}`;
|
|
108
|
+
// What the owner starts is drawn in the hot colour; a failure keeps its own red.
|
|
109
|
+
const hot = from.state === 'waiting' && edge.variant !== 'error';
|
|
110
|
+
const head = edge.variant === 'error' ? 'e' : hot ? 'h' : 'a';
|
|
111
|
+
|
|
112
|
+
return `<g class="edge ${FigureLayout.escaped(edge.variant ?? 'main')}${hot ? ' hot' : ''}" data-edge="${FigureLayout.escaped(name)}"><title>${FigureLayout.escaped(edge.label)}</title><path d="${route.path}" marker-end="url(#${head})"/><text x="${route.label.x}" y="${route.label.y}" text-anchor="middle">${FigureLayout.escaped(edge.label)}</text></g>`;
|
|
113
|
+
})
|
|
114
|
+
.join('');
|
|
115
|
+
const nodes = flow.nodes
|
|
116
|
+
.map((node) => {
|
|
117
|
+
const centre = centreOf(node);
|
|
118
|
+
const lines = node.sublabel === undefined ? 1 : 2;
|
|
119
|
+
const tone = node.state === undefined ? '' : ` c-${NodeStates.toneOf(node.state)}`;
|
|
120
|
+
const gate = node.state === 'waiting';
|
|
121
|
+
const left = centre.x - BOX_WIDTH / 2;
|
|
122
|
+
const anchor = node.state === undefined ? 'middle' : 'start';
|
|
123
|
+
const textX =
|
|
124
|
+
node.state === undefined ? centre.x : left + (node.state === 'waiting' ? 48 : 40);
|
|
125
|
+
const mark =
|
|
126
|
+
node.state === undefined
|
|
127
|
+
? ''
|
|
128
|
+
: `${gate ? `<circle class="halo" cx="${left + 22}" cy="${centre.y}" r="20"/><circle class="core" cx="${left + 22}" cy="${centre.y}" r="13"/>` : ''}<g class="st" transform="translate(${left + 12} ${centre.y - 10})">${IconSet.iconSvg({ name: NodeStates.iconOf(node.state), size: 20 }).replace('<svg', '<svg x="0" y="0"')}</g>`;
|
|
129
|
+
|
|
130
|
+
return `<g class="node ${FigureLayout.escaped(node.kind ?? 'step')}${tone}${gate ? ' gate' : ''}" tabindex="0" role="img" aria-label="${FigureLayout.escaped(node.label)}${node.sublabel === undefined ? '' : `, ${FigureLayout.escaped(node.sublabel)}`}" data-node="${FigureLayout.escaped(node.id)}" data-detail="${FigureLayout.escaped(node.detail ?? node.sublabel ?? node.label)}"><title>${FigureLayout.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">${FigureLayout.escaped(node.label)}</text>${node.sublabel === undefined ? '' : `<text x="${textX}" y="${centre.y + 17}" text-anchor="${anchor}" class="s">${FigureLayout.escaped(node.sublabel)}</text>`}</g>`;
|
|
131
|
+
})
|
|
132
|
+
.join('');
|
|
133
|
+
|
|
134
|
+
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="13" markerHeight="13" markerUnits="userSpaceOnUse" orient="auto"><path class="ah" d="M0 0L10 5L0 10z"/></marker><marker id="e" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="13" markerHeight="13" markerUnits="userSpaceOnUse" orient="auto"><path class="bad" d="M0 0L10 5L0 10z"/></marker><marker id="h" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="15" markerHeight="15" markerUnits="userSpaceOnUse" orient="auto"><path class="hot" d="M0 0L10 5L0 10z"/></marker></defs>${edges}${nodes}</svg>`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The same flow as a list, for a phone where the figure cannot be read: one row per arrow, then one per box that
|
|
139
|
+
* has a detail. Page CSS shows it only on a narrow screen.
|
|
140
|
+
*/
|
|
141
|
+
static renderPathList(opts: { flow: NonNullable<TVisualizeSpec['flow']> }): string {
|
|
142
|
+
const { flow } = opts;
|
|
143
|
+
const byId = new Map(flow.nodes.map((node) => [node.id, node]));
|
|
144
|
+
const nameOf = (id: string): string => {
|
|
145
|
+
const node = byId.get(id);
|
|
122
146
|
const mark =
|
|
123
|
-
node
|
|
147
|
+
node?.state === undefined
|
|
124
148
|
? ''
|
|
125
|
-
:
|
|
149
|
+
: `<span class="inl c-${NodeStates.toneOf(node.state)}">${IconSet.iconSvg({ name: NodeStates.iconOf(node.state), size: 16 })}</span>`;
|
|
126
150
|
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
.
|
|
151
|
+
return `${mark}${FigureLayout.escaped(node?.label ?? id)}`;
|
|
152
|
+
};
|
|
153
|
+
const arrows = flow.edges
|
|
154
|
+
.map(
|
|
155
|
+
(edge) =>
|
|
156
|
+
`<li><b>${nameOf(edge.from)}</b><span class="verb ${FigureLayout.escaped(edge.variant ?? 'main')}">${FigureLayout.escaped(edge.label)}</span><b>${nameOf(edge.to)}</b></li>`,
|
|
157
|
+
)
|
|
158
|
+
.join('');
|
|
159
|
+
const details = flow.nodes
|
|
160
|
+
.filter((node) => node.detail !== undefined)
|
|
161
|
+
.map(
|
|
162
|
+
(node) =>
|
|
163
|
+
`<li><b>${FigureLayout.escaped(node.label)}</b> ${FigureLayout.escaped(node.detail ?? '')}</li>`,
|
|
164
|
+
)
|
|
165
|
+
.join('');
|
|
166
|
+
|
|
167
|
+
return `<ol class="path">${arrows}</ol>${details === '' ? '' : `<ul class="path-detail">${details}</ul>`}`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
130
170
|
|
|
131
|
-
|
|
132
|
-
|
|
171
|
+
/** Below this share of its natural width the figure is replaced by a list, so no text drops under 12 px. */
|
|
172
|
+
export const FIGURE_FIT = 0.92;
|
|
133
173
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
export const renderPathList = (opts: { flow: NonNullable<TVisualizeSpec['flow']> }): string => {
|
|
139
|
-
const { flow } = opts;
|
|
140
|
-
const byId = new Map(flow.nodes.map((node) => [node.id, node]));
|
|
141
|
-
const nameOf = (id: string): string => {
|
|
142
|
-
const node = byId.get(id);
|
|
143
|
-
const mark =
|
|
144
|
-
node?.state === undefined
|
|
145
|
-
? ''
|
|
146
|
-
: `<span class="inl c-${NodeStates.toneOf(node.state)}">${iconSvg({ name: NodeStates.iconOf(node.state), size: 16 })}</span>`;
|
|
147
|
-
|
|
148
|
-
return `${mark}${escaped(node?.label ?? id)}`;
|
|
149
|
-
};
|
|
150
|
-
const arrows = flow.edges
|
|
151
|
-
.map(
|
|
152
|
-
(edge) =>
|
|
153
|
-
`<li><b>${nameOf(edge.from)}</b><span class="verb ${escaped(edge.variant ?? 'main')}">${escaped(edge.label)}</span><b>${nameOf(edge.to)}</b></li>`,
|
|
154
|
-
)
|
|
155
|
-
.join('');
|
|
156
|
-
const details = flow.nodes
|
|
157
|
-
.filter((node) => node.detail !== undefined)
|
|
158
|
-
.map((node) => `<li><b>${escaped(node.label)}</b> ${escaped(node.detail ?? '')}</li>`)
|
|
159
|
-
.join('');
|
|
160
|
-
|
|
161
|
-
return `<ol class="path">${arrows}</ol>${details === '' ? '' : `<ul class="path-detail">${details}</ul>`}`;
|
|
162
|
-
};
|
|
174
|
+
interface IPoint {
|
|
175
|
+
x: number;
|
|
176
|
+
y: number;
|
|
177
|
+
}
|
package/src/visualize/page.ts
CHANGED
|
@@ -1,43 +1,24 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { HEAD_JS, PAGE_JS
|
|
2
|
+
import { Assets, HEAD_JS, PAGE_JS } from './assets.ts';
|
|
3
3
|
import { NodeStates } from './constants.ts';
|
|
4
4
|
import type { TChrome } from './constants.ts';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { IconSet } from './icons.ts';
|
|
6
|
+
import { SpecCharts } from './charts.ts';
|
|
7
7
|
import { COMPARE_CSS } from './compare-css.ts';
|
|
8
8
|
import { CompareView } from './compare-render.ts';
|
|
9
9
|
import { NEW_KINDS_CSS } from './kinds-css.ts';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { KindsRender } from './kinds-render.ts';
|
|
11
|
+
import { GridSpans } from './grid-span.ts';
|
|
12
|
+
import { Labels } from './labels.ts';
|
|
13
|
+
import { FIGURE_FIT, FigureLayout } from './layout.ts';
|
|
13
14
|
import type { TVisualizeSpec } from './schema.ts';
|
|
14
15
|
import { PageTerms, SourceRefs } from './sources.ts';
|
|
15
16
|
import { ProjectTheme } from './theme.ts';
|
|
16
17
|
import type { IResolvedTheme } from './theme.ts';
|
|
17
|
-
import {
|
|
18
|
-
architectureSection,
|
|
19
|
-
beforeAfterSection,
|
|
20
|
-
chip,
|
|
21
|
-
comparisonSection,
|
|
22
|
-
decisionRecordSection,
|
|
23
|
-
decisionsSection,
|
|
24
|
-
evidenceSection,
|
|
25
|
-
explainerSection,
|
|
26
|
-
findingsSection,
|
|
27
|
-
flowSection,
|
|
28
|
-
ideaMapSection,
|
|
29
|
-
linksSection,
|
|
30
|
-
logSection,
|
|
31
|
-
risksSection,
|
|
32
|
-
section,
|
|
33
|
-
sectionLinks,
|
|
34
|
-
stateWord,
|
|
35
|
-
tilesHtml,
|
|
36
|
-
timelineSection,
|
|
37
|
-
} from './sections.ts';
|
|
18
|
+
import { SpecSections } from './sections.ts';
|
|
38
19
|
import type { ISectionContext } from './sections.ts';
|
|
39
20
|
|
|
40
|
-
const escaped = (value: string): string => escapeText({ value });
|
|
21
|
+
const escaped = (value: string): string => FigureLayout.escapeText({ value });
|
|
41
22
|
|
|
42
23
|
/** The mark of the top bar: a diamond in the hot colour. */
|
|
43
24
|
const MARK =
|
|
@@ -85,22 +66,22 @@ const countTiles = (opts: {
|
|
|
85
66
|
return [
|
|
86
67
|
{
|
|
87
68
|
value: `${count('done')} / ${rows.length}`,
|
|
88
|
-
label: stateWord({ chrome: opts.chrome, state: 'done' }),
|
|
69
|
+
label: SpecSections.stateWord({ chrome: opts.chrome, state: 'done' }),
|
|
89
70
|
state: 'done',
|
|
90
71
|
},
|
|
91
72
|
{
|
|
92
73
|
value: String(count('in progress')),
|
|
93
|
-
label: stateWord({ chrome: opts.chrome, state: 'in progress' }),
|
|
74
|
+
label: SpecSections.stateWord({ chrome: opts.chrome, state: 'in progress' }),
|
|
94
75
|
state: 'in progress',
|
|
95
76
|
},
|
|
96
77
|
{
|
|
97
78
|
value: String(count('waiting')),
|
|
98
|
-
label: stateWord({ chrome: opts.chrome, state: 'waiting' }),
|
|
79
|
+
label: SpecSections.stateWord({ chrome: opts.chrome, state: 'waiting' }),
|
|
99
80
|
state: 'waiting',
|
|
100
81
|
},
|
|
101
82
|
{
|
|
102
83
|
value: String(count('blocked')),
|
|
103
|
-
label: stateWord({ chrome: opts.chrome, state: 'blocked' }),
|
|
84
|
+
label: SpecSections.stateWord({ chrome: opts.chrome, state: 'blocked' }),
|
|
104
85
|
state: 'blocked',
|
|
105
86
|
},
|
|
106
87
|
];
|
|
@@ -130,7 +111,7 @@ const heroHtml = (opts: { ctx: ISectionContext }): string => {
|
|
|
130
111
|
spec.scope === undefined ? '' : `<span>${escaped(chrome.scope)}: ${escaped(spec.scope)}</span>`,
|
|
131
112
|
].join('');
|
|
132
113
|
|
|
133
|
-
return `<div class="banner slab c-${tone}" data-slide data-hero><div class="wrap hero"><p class="state">${stateIcon({ state, size: 22 })}<span class="word">${escaped(word)}</span></p><h1>${escaped(spec.title)}</h1><p class="lede">${escaped(spec.verdict)}</p>${spec.caption === undefined ? '' : `<p class="cap">${escaped(spec.caption)}</p>`}${meta === '' ? '' : `<p class="meta">${meta}</p>`}${
|
|
114
|
+
return `<div class="banner slab c-${tone}" data-slide data-hero><div class="wrap hero"><p class="state">${SpecCharts.stateIcon({ state, size: 22 })}<span class="word">${escaped(word)}</span></p><h1>${escaped(spec.title)}</h1><p class="lede">${escaped(spec.verdict)}</p>${spec.caption === undefined ? '' : `<p class="cap">${escaped(spec.caption)}</p>`}${meta === '' ? '' : `<p class="meta">${meta}</p>`}${SpecSections.flow({ ctx: opts.ctx })}</div></div>`;
|
|
134
115
|
};
|
|
135
116
|
|
|
136
117
|
/** The minimap as a track: a stripe, a shape and a word for every task. */
|
|
@@ -146,7 +127,7 @@ const stepperHtml = (opts: { spec: TVisualizeSpec; chrome: TChrome }): string =>
|
|
|
146
127
|
return `<section class="part" id="minimap" data-slide><div class="wrap"><h2 class="sh">${escaped(chrome.minimap)}</h2><ol class="strip">${minimap
|
|
147
128
|
.map(
|
|
148
129
|
(row) =>
|
|
149
|
-
`<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>`,
|
|
130
|
+
`<li class="seg c-${NodeStates.toneOf(row.status)}"><span class="bar"></span><span class="nm">${SpecSections.chip({ chrome, state: row.status })}<span class="tn">${escaped(row.task)}</span></span>${row.note === undefined ? '' : `<span class="nt">${escaped(row.note)}</span>`}</li>`,
|
|
150
131
|
)
|
|
151
132
|
.join('')}</ol></div></section>`;
|
|
152
133
|
};
|
|
@@ -168,7 +149,7 @@ const ownerHtml = (opts: { spec: TVisualizeSpec; chrome: TChrome }): string => {
|
|
|
168
149
|
? ''
|
|
169
150
|
: `<ol class="check">${spec.actions.map((action) => `<li>${escaped(action)}</li>`).join('')}</ol>`;
|
|
170
151
|
|
|
171
|
-
return `<section class="two" id="next" data-slide><div class="wrap"><div class="own"><div class="nx"><p class="lab">${escaped(chrome.next)}</p><h2>${escaped(spec.strip.next)}</h2>${actions}${jump}</div><div class="stop"><p class="lab">${escaped(chrome.blockedBy)}</p><p>${escaped(spec.strip.blockedBy)}</p></div></div><div class="facts"><p class="fact">${iconSvg({ name: 'done', size: 18 })}<span><b>${escaped(chrome.healthy)}</b> ${escaped(spec.strip.healthy)}</span></p><p class="fact">${iconSvg({ name: 'info', size: 18 })}<span><b>${escaped(chrome.changed)}</b> ${escaped(spec.strip.changed)}</span></p></div></div></section>`;
|
|
152
|
+
return `<section class="two" id="next" data-slide><div class="wrap"><div class="own"><div class="nx"><p class="lab">${escaped(chrome.next)}</p><h2>${escaped(spec.strip.next)}</h2>${actions}${jump}</div><div class="stop"><p class="lab">${escaped(chrome.blockedBy)}</p><p>${escaped(spec.strip.blockedBy)}</p></div></div><div class="facts"><p class="fact">${IconSet.iconSvg({ name: 'done', size: 18 })}<span><b>${escaped(chrome.healthy)}</b> ${escaped(spec.strip.healthy)}</span></p><p class="fact">${IconSet.iconSvg({ name: 'info', size: 18 })}<span><b>${escaped(chrome.changed)}</b> ${escaped(spec.strip.changed)}</span></p></div></div></section>`;
|
|
172
153
|
};
|
|
173
154
|
|
|
174
155
|
/** The neutral theme of a page that is given none. */
|
|
@@ -184,72 +165,79 @@ const NEUTRAL = ((): IResolvedTheme => {
|
|
|
184
165
|
return resolved.theme;
|
|
185
166
|
})();
|
|
186
167
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
168
|
+
export class PageShell {
|
|
169
|
+
/** The whole page: one file, no network, a content-security policy that allows only the page's own style and scripts by hash. */
|
|
170
|
+
static render(opts: {
|
|
171
|
+
spec: TVisualizeSpec;
|
|
172
|
+
/** The page's language: the spec's, else the owner's profile, else English. */
|
|
173
|
+
language?: string;
|
|
174
|
+
/** The checked colours of the page; the stylesheet takes its tokens from them. */
|
|
175
|
+
theme?: IResolvedTheme;
|
|
176
|
+
}): string {
|
|
177
|
+
const { spec } = opts;
|
|
178
|
+
const language = opts.language ?? spec.language ?? 'en';
|
|
179
|
+
const chrome = Labels.chromeOf({ spec, language });
|
|
180
|
+
const ctx: ISectionContext = {
|
|
181
|
+
spec,
|
|
182
|
+
chrome,
|
|
183
|
+
fits: new Set<number>(),
|
|
184
|
+
spans: new Set<number>(),
|
|
185
|
+
};
|
|
186
|
+
const { state, tone, word } = stateOf({ spec, chrome });
|
|
187
|
+
const sources = SourceRefs.entries({ spec, chrome });
|
|
188
|
+
const tiles =
|
|
189
|
+
spec.tiles ?? (spec.minimap === undefined ? undefined : countTiles({ spec, chrome }));
|
|
190
|
+
const body = [
|
|
191
|
+
heroHtml({ ctx }),
|
|
192
|
+
tiles === undefined
|
|
193
|
+
? ''
|
|
194
|
+
: `<div data-slide class="slide-tiles"><div class="wrap">${SpecSections.tilesHtml({ tiles, chrome })}</div></div>`,
|
|
195
|
+
stepperHtml({ spec, chrome }),
|
|
196
|
+
ownerHtml({ spec, chrome }),
|
|
197
|
+
SpecSections.architecture({ ctx }),
|
|
198
|
+
CompareView.section({ ctx }),
|
|
199
|
+
KindsRender.sequenceSection({ ctx }),
|
|
200
|
+
KindsRender.lifecycleSection({ ctx }),
|
|
201
|
+
KindsRender.treeSection({ ctx }),
|
|
202
|
+
SpecSections.comparison({ ctx }),
|
|
203
|
+
SpecSections.ideaMap({ ctx }),
|
|
204
|
+
SpecSections.explainer({ ctx }),
|
|
205
|
+
SpecSections.timeline({ ctx }),
|
|
206
|
+
SpecSections.findings({ ctx }),
|
|
207
|
+
SpecSections.beforeAfter({ ctx }),
|
|
208
|
+
SpecSections.decisionRecord({ ctx }),
|
|
209
|
+
SpecSections.decisions({ ctx }),
|
|
210
|
+
SpecSections.evidence({ ctx }),
|
|
211
|
+
SpecSections.risks({ ctx }),
|
|
212
|
+
SpecSections.log({ ctx }),
|
|
213
|
+
spec.terms === undefined
|
|
214
|
+
? ''
|
|
215
|
+
: SpecSections.section({
|
|
216
|
+
id: 'terms',
|
|
217
|
+
title: chrome.terms,
|
|
218
|
+
body: PageTerms.listHtml({ terms: spec.terms }),
|
|
219
|
+
}),
|
|
220
|
+
sources.length === 0
|
|
221
|
+
? ''
|
|
222
|
+
: SpecSections.section({
|
|
223
|
+
id: 'sources',
|
|
224
|
+
title: chrome.sources,
|
|
225
|
+
body: SourceRefs.listHtml({ entries: sources }),
|
|
226
|
+
}),
|
|
227
|
+
SpecSections.links({ ctx }),
|
|
228
|
+
].join('');
|
|
229
|
+
const css = `${Assets.pageCss({ tokens: ProjectTheme.tokensCss({ theme: opts.theme ?? NEUTRAL }) })}\n${NEW_KINDS_CSS}\n${COMPARE_CSS}\n${GridSpans.css({ spans: ctx.spans })}\n${figureFitCss({ widths: ctx.fits })}`;
|
|
230
|
+
const policy = `default-src 'none'; style-src ${sha256({ text: css })}; script-src ${sha256({ text: HEAD_JS })} ${sha256({ text: PAGE_JS })}; base-uri 'none'; form-action 'none'`;
|
|
231
|
+
const links = SpecSections.sectionLinks({ spec, chrome })
|
|
232
|
+
.map((link) => `<a href="#${link.id}">${escaped(link.title)}</a>`)
|
|
233
|
+
.join('');
|
|
234
|
+
const stamp =
|
|
235
|
+
spec.asOf === undefined
|
|
236
|
+
? ''
|
|
237
|
+
: `<span class="sep" aria-hidden="true"></span><span class="stamp">${escaped(spec.asOf)}</span>`;
|
|
238
|
+
const bar = `<header class="top slab c-${tone}"><div class="wrap">${MARK}<b class="ttl">${escaped(spec.title)}</b>${SpecSections.chip({ chrome, state, size: 18, label: word })}<nav aria-label="${escaped(chrome.navLabel)}"><span class="links">${links}</span>${stamp}<span class="sep" aria-hidden="true"></span><button class="btn js-only" id="present" type="button" data-on="${escaped(chrome.present)}" data-off="${escaped(chrome.exitPresent)}">${escaped(chrome.present)}</button><button class="theme" id="theme" type="button" aria-label="${escaped(chrome.themeToDark)}" data-to-light="${escaped(chrome.themeToLight)}" data-to-dark="${escaped(chrome.themeToDark)}">${IconSet.iconSvg({ name: 'sun', size: 20, className: 'sun' })}${IconSet.iconSvg({ name: 'moon', size: 20, className: 'moon' })}<span class="tip" aria-hidden="true"></span></button></nav></div></header>`;
|
|
239
|
+
const deck = `<nav class="deck" aria-label="${escaped(chrome.slide)}"><button class="btn" id="slide-prev" type="button">${escaped(chrome.previous)}</button><span id="slide-count" aria-live="polite"></span><button class="btn" id="slide-next" type="button">${escaped(chrome.following)}</button></nav>`;
|
|
240
|
+
|
|
241
|
+
return `<!doctype html><html lang="${escaped(language)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta http-equiv="Content-Security-Policy" content="${escaped(policy)}"><meta name="generator" content="vulcan visualize"><title>${escaped(spec.title)}</title><script>${HEAD_JS}</script><style>${css}</style></head><body>${bar}<main>${body}</main><footer class="slab foot"><div class="wrap"><p>${escaped(chrome.footer)}</p></div></footer>${deck}<script>${PAGE_JS}</script></body></html>`;
|
|
242
|
+
}
|
|
243
|
+
}
|