@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NodeStates } from './constants.ts';
|
|
2
2
|
import type { TChrome } from './constants.ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { SpecCharts } from './charts.ts';
|
|
4
|
+
import { GridSpans } from './grid-span.ts';
|
|
5
|
+
import { IconSet } from './icons.ts';
|
|
6
|
+
import { FigureLayout } from './layout.ts';
|
|
6
7
|
import type { TVisualizeSpec } from './schema.ts';
|
|
7
8
|
|
|
8
9
|
type TDiagram = NonNullable<NonNullable<TVisualizeSpec['explainer']>['steps'][number]['diagram']>;
|
|
@@ -15,7 +16,7 @@ export interface IDrawing {
|
|
|
15
16
|
fallback: string;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
const escaped = (value: string): string => escapeText({ value });
|
|
19
|
+
const escaped = (value: string): string => FigureLayout.escapeText({ value });
|
|
19
20
|
|
|
20
21
|
const box = (opts: {
|
|
21
22
|
x: number;
|
|
@@ -36,189 +37,203 @@ const box = (opts: {
|
|
|
36
37
|
const arrowHead = (opts: { x: number; y: number }): string =>
|
|
37
38
|
`<path d="M${opts.x - 7} ${opts.y - 5}L${opts.x} ${opts.y}L${opts.x - 7} ${opts.y + 5}" fill="none" class="dline"/>`;
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
export class SpecDiagrams {
|
|
41
|
+
/** An explainer step's diagram: a row of boxes joined by labelled arrows, or stacked layers. */
|
|
42
|
+
static render(opts: { diagram: TDiagram }): IDrawing {
|
|
43
|
+
const { diagram } = opts;
|
|
44
|
+
|
|
45
|
+
if (diagram.type === 'row') {
|
|
46
|
+
const longest = Math.max(
|
|
47
|
+
...diagram.nodes.flatMap((node) => [
|
|
48
|
+
node.label.length * 8.2,
|
|
49
|
+
(node.sub?.length ?? 0) * 7.6,
|
|
50
|
+
]),
|
|
51
|
+
);
|
|
52
|
+
const bw = Math.max(124, Math.ceil(longest) + 24);
|
|
53
|
+
const gap = 78;
|
|
54
|
+
const width = diagram.nodes.length * bw + (diagram.nodes.length - 1) * gap + 16;
|
|
55
|
+
const parts = diagram.nodes
|
|
56
|
+
.map((node, index) => {
|
|
57
|
+
const x = 8 + index * (bw + gap);
|
|
58
|
+
const label = diagram.arrows?.[index];
|
|
59
|
+
const arrow =
|
|
60
|
+
index < diagram.nodes.length - 1
|
|
61
|
+
? `<path d="M${x + bw + 4} 40H${x + bw + gap - 4}" class="dline"/>${arrowHead({ x: x + bw + gap - 4, y: 40 })}${label === undefined ? '' : `<text class="dl" x="${x + bw + gap / 2}" y="30" text-anchor="middle">${escaped(label)}</text>`}`
|
|
62
|
+
: '';
|
|
63
|
+
|
|
64
|
+
return `${box({ x, y: 12, width: bw, height: 56, label: node.label, sub: node.sub })}${arrow}`;
|
|
65
|
+
})
|
|
66
|
+
.join('');
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
svg: `<svg width="${width}" viewBox="0 0 ${width} 80" role="group" aria-label="diagram">${parts}</svg>`,
|
|
70
|
+
width,
|
|
71
|
+
fallback: `<ol class="path">${diagram.nodes
|
|
72
|
+
.map(
|
|
73
|
+
(node, index) =>
|
|
74
|
+
`<li><b>${escaped(node.label)}</b>${node.sub === undefined ? '' : ` <span class="mut">${escaped(node.sub)}</span>`}${index < diagram.nodes.length - 1 && diagram.arrows?.[index] !== undefined ? `<span class="verb">${escaped(diagram.arrows[index] ?? '')}</span>` : ''}</li>`,
|
|
75
|
+
)
|
|
76
|
+
.join('')}</ol>`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
42
79
|
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
80
|
+
const most = Math.max(...diagram.layers.map((layer) => layer.items.length));
|
|
81
|
+
const label = Math.max(
|
|
82
|
+
112,
|
|
83
|
+
Math.ceil(Math.max(...diagram.layers.map((layer) => layer.label.length)) * 8.8) + 30,
|
|
84
|
+
);
|
|
85
|
+
const iw = Math.max(
|
|
86
|
+
112,
|
|
87
|
+
Math.ceil(
|
|
88
|
+
Math.max(...diagram.layers.flatMap((layer) => layer.items.map((item) => item.length))) * 8,
|
|
89
|
+
) + 24,
|
|
46
90
|
);
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const label = diagram.arrows?.[index];
|
|
54
|
-
const arrow =
|
|
55
|
-
index < diagram.nodes.length - 1
|
|
56
|
-
? `<path d="M${x + bw + 4} 40H${x + bw + gap - 4}" class="dline"/>${arrowHead({ x: x + bw + gap - 4, y: 40 })}${label === undefined ? '' : `<text class="dl" x="${x + bw + gap / 2}" y="30" text-anchor="middle">${escaped(label)}</text>`}`
|
|
57
|
-
: '';
|
|
58
|
-
|
|
59
|
-
return `${box({ x, y: 12, width: bw, height: 56, label: node.label, sub: node.sub })}${arrow}`;
|
|
91
|
+
const width = label + most * (iw + 10) + 14;
|
|
92
|
+
const parts = diagram.layers
|
|
93
|
+
.map((layer, row) => {
|
|
94
|
+
const y = 8 + row * 62;
|
|
95
|
+
|
|
96
|
+
return `<g><rect x="4" y="${y}" width="${width - 8}" height="54" rx="4" class="dband"/><text class="dlab" x="14" y="${y + 31}">${escaped(layer.label)}</text>${layer.items.map((item, col) => box({ x: label + col * (iw + 10), y: y + 8, width: iw, height: 38, label: item })).join('')}</g>`;
|
|
60
97
|
})
|
|
61
98
|
.join('');
|
|
62
99
|
|
|
63
100
|
return {
|
|
64
|
-
svg: `<svg width="${width}" viewBox="0 0 ${width}
|
|
101
|
+
svg: `<svg width="${width}" viewBox="0 0 ${width} ${diagram.layers.length * 62 + 12}" role="group" aria-label="layers">${parts}</svg>`,
|
|
65
102
|
width,
|
|
66
|
-
fallback: `<
|
|
67
|
-
.map(
|
|
68
|
-
(node, index) =>
|
|
69
|
-
`<li><b>${escaped(node.label)}</b>${node.sub === undefined ? '' : ` <span class="mut">${escaped(node.sub)}</span>`}${index < diagram.nodes.length - 1 && diagram.arrows?.[index] !== undefined ? `<span class="verb">${escaped(diagram.arrows[index] ?? '')}</span>` : ''}</li>`,
|
|
70
|
-
)
|
|
71
|
-
.join('')}</ol>`,
|
|
103
|
+
fallback: `<ul class="path">${diagram.layers.map((layer) => `<li><b>${escaped(layer.label)}</b>: ${layer.items.map(escaped).join(', ')}</li>`).join('')}</ul>`,
|
|
72
104
|
};
|
|
73
105
|
}
|
|
74
106
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Math.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
) +
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const bw = 176;
|
|
111
|
-
const bh = 68;
|
|
112
|
-
const gap = 64;
|
|
113
|
-
const rowHeight = 190;
|
|
114
|
-
const width = label + most * (bw + gap) + 4;
|
|
115
|
-
const height = architecture.layers.length * rowHeight + 8;
|
|
116
|
-
const positions = new Map<string, { x: number; y: number; row: number }>();
|
|
117
|
-
|
|
118
|
-
architecture.layers.forEach((layer, row) => {
|
|
119
|
-
const total = layer.boxes.length * (bw + gap) - gap;
|
|
120
|
-
const start = label + (most * (bw + gap) - gap - total) / 2;
|
|
121
|
-
|
|
122
|
-
layer.boxes.forEach((boxSpec, col) =>
|
|
123
|
-
positions.set(boxSpec.id, { x: start + col * (bw + gap), y: 4 + row * rowHeight + 34, row }),
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
const bands = architecture.layers
|
|
128
|
-
.map(
|
|
129
|
-
(layer, row) =>
|
|
130
|
-
`<rect x="2" y="${4 + row * rowHeight}" width="${width - 4}" height="${rowHeight - 14}" rx="4" class="dband"/><text class="dlab" x="14" y="${4 + row * rowHeight + 24}">${escaped(layer.label)}</text>`,
|
|
131
|
-
)
|
|
132
|
-
.join('');
|
|
133
|
-
// Links that cross the same gap between two layers get their own horizontal run, so no two lines share one.
|
|
134
|
-
const lanes = new Map<number, number>();
|
|
135
|
-
const across = new Map<number, number>();
|
|
136
|
-
|
|
137
|
-
for (const link of architecture.links) {
|
|
138
|
-
const from = positions.get(link.from);
|
|
139
|
-
const to = positions.get(link.to);
|
|
140
|
-
|
|
141
|
-
if (from !== undefined && to !== undefined && from.row !== to.row) {
|
|
142
|
-
across.set(Math.min(from.row, to.row), (across.get(Math.min(from.row, to.row)) ?? 0) + 1);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const links = architecture.links
|
|
147
|
-
.map((link) => {
|
|
148
|
-
const a = positions.get(link.from);
|
|
149
|
-
const b = positions.get(link.to);
|
|
150
|
-
|
|
151
|
-
if (a === undefined || b === undefined) {
|
|
152
|
-
return '';
|
|
153
|
-
}
|
|
107
|
+
/** The layered view: bands from top to bottom, boxes in each, and an elbow line for every link. */
|
|
108
|
+
static renderArchitecture(opts: { architecture: TArchitecture; chrome: TChrome }): IDrawing {
|
|
109
|
+
const { architecture } = opts;
|
|
110
|
+
const most = Math.max(...architecture.layers.map((layer) => layer.boxes.length));
|
|
111
|
+
const label = 120;
|
|
112
|
+
const bw = 176;
|
|
113
|
+
const bh = 68;
|
|
114
|
+
const gap = 64;
|
|
115
|
+
const rowHeight = 190;
|
|
116
|
+
const width = label + most * (bw + gap) + 4;
|
|
117
|
+
const height = architecture.layers.length * rowHeight + 8;
|
|
118
|
+
const positions = new Map<string, { x: number; y: number; row: number }>();
|
|
119
|
+
|
|
120
|
+
architecture.layers.forEach((layer, row) => {
|
|
121
|
+
const total = layer.boxes.length * (bw + gap) - gap;
|
|
122
|
+
const start = label + (most * (bw + gap) - gap - total) / 2;
|
|
123
|
+
|
|
124
|
+
layer.boxes.forEach((boxSpec, col) =>
|
|
125
|
+
positions.set(boxSpec.id, {
|
|
126
|
+
x: start + col * (bw + gap),
|
|
127
|
+
y: 4 + row * rowHeight + 34,
|
|
128
|
+
row,
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const bands = architecture.layers
|
|
134
|
+
.map(
|
|
135
|
+
(layer, row) =>
|
|
136
|
+
`<rect x="2" y="${4 + row * rowHeight}" width="${width - 4}" height="${rowHeight - 14}" rx="4" class="dband"/><text class="dlab" x="14" y="${4 + row * rowHeight + 24}">${escaped(layer.label)}</text>`,
|
|
137
|
+
)
|
|
138
|
+
.join('');
|
|
139
|
+
// Links that cross the same gap between two layers get their own horizontal run, so no two lines share one.
|
|
140
|
+
const lanes = new Map<number, number>();
|
|
141
|
+
const across = new Map<number, number>();
|
|
154
142
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const x2 = sign === 1 ? b.x : b.x + bw;
|
|
159
|
-
const y = a.y + bh / 2;
|
|
143
|
+
for (const link of architecture.links) {
|
|
144
|
+
const from = positions.get(link.from);
|
|
145
|
+
const to = positions.get(link.to);
|
|
160
146
|
|
|
161
|
-
|
|
147
|
+
if (from !== undefined && to !== undefined && from.row !== to.row) {
|
|
148
|
+
across.set(Math.min(from.row, to.row), (across.get(Math.min(from.row, to.row)) ?? 0) + 1);
|
|
162
149
|
}
|
|
150
|
+
}
|
|
163
151
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
152
|
+
const links = architecture.links
|
|
153
|
+
.map((link) => {
|
|
154
|
+
const a = positions.get(link.from);
|
|
155
|
+
const b = positions.get(link.to);
|
|
156
|
+
|
|
157
|
+
if (a === undefined || b === undefined) {
|
|
158
|
+
return '';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (a.row === b.row) {
|
|
162
|
+
const sign = a.x < b.x ? 1 : -1;
|
|
163
|
+
const x1 = sign === 1 ? a.x + bw : a.x;
|
|
164
|
+
const x2 = sign === 1 ? b.x : b.x + bw;
|
|
165
|
+
const y = a.y + bh / 2;
|
|
166
|
+
|
|
167
|
+
return `<g class="dlink"><path d="M${x1} ${y}H${x2}" class="dline"/><path d="M${x2 - sign * 7} ${y - 5}L${x2} ${y}L${x2 - sign * 7} ${y + 5}" fill="none" class="dline"/>${link.label === undefined ? '' : `<text class="dl" x="${(x1 + x2) / 2}" y="${y - 8}" text-anchor="middle">${escaped(link.label)}</text>`}</g>`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const down = a.row < b.row;
|
|
171
|
+
const gapIndex = Math.min(a.row, b.row);
|
|
172
|
+
const lane = lanes.get(gapIndex) ?? 0;
|
|
173
|
+
|
|
174
|
+
lanes.set(gapIndex, lane + 1);
|
|
175
|
+
|
|
176
|
+
const top = 4 + gapIndex * rowHeight + 34 + bh;
|
|
177
|
+
const bottom = 4 + (gapIndex + 1) * rowHeight + 34;
|
|
178
|
+
const ym =
|
|
179
|
+
top + 14 + ((bottom - top - 28) * (lane + 1)) / ((across.get(gapIndex) ?? 1) + 1);
|
|
180
|
+
const shift = lane % 3 === 1 ? 10 : lane % 3 === 2 ? -10 : 0;
|
|
181
|
+
const x1 = a.x + bw / 2 + shift;
|
|
182
|
+
const x2 = b.x + bw / 2 + shift;
|
|
183
|
+
const y1 = down ? a.y + bh : a.y;
|
|
184
|
+
const y2 = down ? b.y : b.y + bh;
|
|
185
|
+
const tip = down ? -7 : 7;
|
|
186
|
+
|
|
187
|
+
return `<g class="dlink"><path d="M${x1} ${y1}V${ym}H${x2}V${y2}" class="dline"/><path d="M${x2 - 5} ${y2 + tip}L${x2} ${y2}L${x2 + 5} ${y2 + tip}" fill="none" class="dline"/>${link.label === undefined ? '' : `<text class="dl" x="${(x1 + x2) / 2}" y="${ym - 5}" text-anchor="middle">${escaped(link.label)}</text>`}</g>`;
|
|
188
|
+
})
|
|
189
|
+
.join('');
|
|
190
|
+
const boxes = architecture.layers
|
|
191
|
+
.flatMap((layer) => layer.boxes)
|
|
192
|
+
.map((spec) => {
|
|
193
|
+
const p = positions.get(spec.id);
|
|
194
|
+
|
|
195
|
+
return p === undefined
|
|
196
|
+
? ''
|
|
197
|
+
: box({
|
|
198
|
+
x: p.x,
|
|
199
|
+
y: p.y,
|
|
200
|
+
width: bw,
|
|
201
|
+
height: bh,
|
|
202
|
+
label: spec.label,
|
|
203
|
+
sub: spec.sub,
|
|
204
|
+
tone: spec.state === undefined ? undefined : NodeStates.toneOf(spec.state),
|
|
205
|
+
icon:
|
|
206
|
+
spec.state === undefined
|
|
207
|
+
? undefined
|
|
208
|
+
: SpecCharts.stateIcon({ state: spec.state, size: 20 }),
|
|
209
|
+
});
|
|
210
|
+
})
|
|
211
|
+
.join('');
|
|
212
|
+
const names = new Map(
|
|
213
|
+
architecture.layers.flatMap((layer) =>
|
|
214
|
+
layer.boxes.map((spec) => [spec.id, spec.label] as const),
|
|
215
|
+
),
|
|
216
|
+
);
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const right = map.branches.filter((_, index) => index % 2 === 1);
|
|
218
|
+
return {
|
|
219
|
+
svg: `<svg width="${width}" viewBox="0 0 ${width} ${height}" role="group" aria-label="${escaped(opts.chrome.architecture)}">${bands}${links}${boxes}</svg>`,
|
|
220
|
+
width,
|
|
221
|
+
fallback: `<ul class="path">${architecture.layers.map((layer) => `<li><b>${escaped(layer.label)}</b>: ${layer.boxes.map((spec) => `${spec.state === undefined ? '' : `<span class="c-${NodeStates.toneOf(spec.state)} inl">${SpecCharts.stateIcon({ state: spec.state, size: 16 })}</span>`}${escaped(spec.label)}`).join(', ')}</li>`).join('')}${architecture.links.map((link) => `<li>${escaped(names.get(link.from) ?? link.from)} <span class="verb">${escaped(link.label ?? opts.chrome.uses)}</span> ${escaped(names.get(link.to) ?? link.to)}</li>`).join('')}</ul>`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
222
224
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
/** The idea map: the centre between two columns of branches, each branch a cluster of ideas. */
|
|
226
|
+
static renderIdeaMap(opts: {
|
|
227
|
+
map: NonNullable<TVisualizeSpec['ideaMap']>;
|
|
228
|
+
spans: Set<number>;
|
|
229
|
+
}): string {
|
|
230
|
+
const { map, spans } = opts;
|
|
231
|
+
// Branches alternate left and right, a pair to a row; each takes three rows of the grid (title, chips, note) from it,
|
|
232
|
+
// so the title and the chips of two branches in one row sit at the same height, and the centre spans every row.
|
|
233
|
+
const rows = Math.ceil(map.branches.length / 2) * 3;
|
|
234
|
+
const cluster = (branch: (typeof map.branches)[number], index: number): string =>
|
|
235
|
+
`<li class="branch" data-s="${(index % 5) + 1}"><h3><i class="sw" data-s="${(index % 5) + 1}"></i>${escaped(branch.label)}</h3><ul class="chips">${branch.items.map((item) => `<li>${escaped(item)}</li>`).join('')}</ul>${branch.note === undefined ? '' : `<p class="mut">${escaped(branch.note)}</p>`}</li>`;
|
|
236
|
+
|
|
237
|
+
return `<div class="idea"><div class="centre win ${GridSpans.classOf({ count: rows, spans })}">${IconSet.iconSvg({ name: 'star', size: 22 })}<b>${escaped(map.center)}</b></div><ul class="bs" role="list">${map.branches.map((branch, index) => cluster(branch, index)).join('')}</ul></div>`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cards in a row share their rows: each card spans as many rows of its grid as it has parts, and takes those rows over
|
|
3
|
+
* from the grid (`grid-template-rows: subgrid`), so the score, the title, each criterion and each pro of one card sit
|
|
4
|
+
* at the same height as the same part of its neighbours, whatever wraps. The number of rows is only known when the page
|
|
5
|
+
* is made, and an inline `style` is blocked by the page's policy, so a class names the span (`sp4`) and the page carries
|
|
6
|
+
* the rules for exactly the spans it uses.
|
|
7
|
+
*/
|
|
8
|
+
export class GridSpans {
|
|
9
|
+
/** The most rows a card can span: a tag, a total, a title, a line, 8 criteria, 6 pros and 6 cons, and room to spare. */
|
|
10
|
+
static readonly MAX = 40;
|
|
11
|
+
|
|
12
|
+
/** The class that makes an element span `count` rows; remembers the span so the page carries its rule. */
|
|
13
|
+
static classOf(opts: { count: number; spans: Set<number> }): string {
|
|
14
|
+
const count = Math.max(1, Math.min(GridSpans.MAX, Math.round(opts.count)));
|
|
15
|
+
|
|
16
|
+
opts.spans.add(count);
|
|
17
|
+
|
|
18
|
+
return `sp${count}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The rules of the spans a page uses; with no subgrid in the browser, or in one column (a phone), a card is a plain block. */
|
|
22
|
+
static css(opts: { spans: Set<number> }): string {
|
|
23
|
+
if (opts.spans.size === 0) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const rules = [...opts.spans]
|
|
28
|
+
.sort((a, b) => a - b)
|
|
29
|
+
.map((count) => `.sp${count}{grid-row-end:span ${count}}`)
|
|
30
|
+
.join('');
|
|
31
|
+
|
|
32
|
+
return `@media (min-width:621px){@supports (grid-template-rows:subgrid){${rules}}}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/visualize/icons.ts
CHANGED
|
@@ -23,9 +23,11 @@ const PATHS: Record<string, string> = {
|
|
|
23
23
|
moon: '<path d="M20.2 14.6A8.4 8.4 0 0 1 9.4 3.8 8.4 8.4 0 1 0 20.2 14.6Z"/>',
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export class IconSet {
|
|
27
|
+
/** An icon; `className` is added after `ic` for a page rule that targets one icon (the theme switch's sun and moon). */
|
|
28
|
+
static iconSvg(opts: { name: string; size?: number; className?: string }): string {
|
|
29
|
+
const size = opts.size ?? 20;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
}
|
|
31
|
+
return `<svg class="ic${opts.className === undefined ? '' : ` ${opts.className}`}" viewBox="0 0 24 24" width="${size}" height="${size}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${PATHS[opts.name] ?? ''}</svg>`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SpecCharts } from './charts.ts';
|
|
2
2
|
import type { TChrome } from './constants.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { FigureLayout } from './layout.ts';
|
|
4
4
|
import { LifecycleKinds, MessageKinds } from './kinds-schema.ts';
|
|
5
5
|
import type { ITreeNode, TLifecycle, TSequence, TTree } from './kinds-schema.ts';
|
|
6
6
|
import type { INewKindsSpec } from './kinds-validate.ts';
|
|
7
|
-
import {
|
|
7
|
+
import { SpecSections } from './sections.ts';
|
|
8
8
|
|
|
9
9
|
/** What a section of the new kinds needs: its slice of the spec, the page's words, and the figure widths to register. */
|
|
10
10
|
export interface INewKindsContext {
|
|
@@ -35,7 +35,7 @@ const KIND_WORDS = {
|
|
|
35
35
|
countItems: 'items',
|
|
36
36
|
} as const;
|
|
37
37
|
|
|
38
|
-
const escaped = (value: string): string => escapeText({ value });
|
|
38
|
+
const escaped = (value: string): string => FigureLayout.escapeText({ value });
|
|
39
39
|
|
|
40
40
|
const wordOf = (opts: { chrome: TChrome; key: keyof typeof KIND_WORDS }): string => {
|
|
41
41
|
const given: Record<string, unknown> = opts.chrome;
|
|
@@ -568,7 +568,9 @@ const renderTree = (opts: { tree: TTree; chrome: TChrome }): IKindDrawing => {
|
|
|
568
568
|
|
|
569
569
|
const sized = rows.map((row) => {
|
|
570
570
|
const word =
|
|
571
|
-
row.node.state === undefined
|
|
571
|
+
row.node.state === undefined
|
|
572
|
+
? undefined
|
|
573
|
+
: SpecSections.stateWord({ chrome, state: row.node.state });
|
|
572
574
|
const hasSub = row.node.sublabel !== undefined;
|
|
573
575
|
const icon = row.node.state === undefined ? 0 : 26;
|
|
574
576
|
const wordWidth = word === undefined ? 0 : Math.ceil(word.length * 7.4) + 20;
|
|
@@ -613,11 +615,12 @@ const renderTree = (opts: { tree: TTree; chrome: TChrome }): IKindDrawing => {
|
|
|
613
615
|
const textX = row.x + 14 + row.icon;
|
|
614
616
|
const state = row.node.state;
|
|
615
617
|
|
|
616
|
-
return `<g class="knode${state === undefined ? '' : ` kn-${state.replaceAll(' ', '-')}`}"><rect class="kbox" x="${row.x}" y="${row.y}" width="${row.boxWidth}" height="${row.boxHeight}" rx="4"/>${state === undefined ? '' : `<g class="kic" transform="translate(${row.x + 12} ${centre - 8})">${stateIcon({ state, size: 16 }).replace('<svg', '<svg x="0" y="0"')}</g>`}<text class="kt" x="${textX}" y="${row.hasSub ? row.y + 21 : centre + 5}">${escaped(row.node.label)}</text>${row.word === undefined ? '' : `<text class="kw" x="${row.x + row.boxWidth - 12}" y="${row.hasSub ? row.y + 21 : centre + 4}" text-anchor="end">${escaped(row.word)}</text>`}${row.node.sublabel === undefined ? '' : `<text class="ks" x="${textX}" y="${row.y + 39}">${escaped(row.node.sublabel)}</text>`}</g>`;
|
|
618
|
+
return `<g class="knode${state === undefined ? '' : ` kn-${state.replaceAll(' ', '-')}`}"><rect class="kbox" x="${row.x}" y="${row.y}" width="${row.boxWidth}" height="${row.boxHeight}" rx="4"/>${state === undefined ? '' : `<g class="kic" transform="translate(${row.x + 12} ${centre - 8})">${SpecCharts.stateIcon({ state, size: 16 }).replace('<svg', '<svg x="0" y="0"')}</g>`}<text class="kt" x="${textX}" y="${row.hasSub ? row.y + 21 : centre + 5}">${escaped(row.node.label)}</text>${row.word === undefined ? '' : `<text class="kw" x="${row.x + row.boxWidth - 12}" y="${row.hasSub ? row.y + 21 : centre + 4}" text-anchor="end">${escaped(row.word)}</text>`}${row.node.sublabel === undefined ? '' : `<text class="ks" x="${textX}" y="${row.y + 39}">${escaped(row.node.sublabel)}</text>`}</g>`;
|
|
617
619
|
})
|
|
618
620
|
.join('');
|
|
619
621
|
const outline = (node: ITreeNode): string => {
|
|
620
|
-
const state =
|
|
622
|
+
const state =
|
|
623
|
+
node.state === undefined ? '' : ` ${SpecSections.chip({ chrome, state: node.state })}`;
|
|
621
624
|
const inner =
|
|
622
625
|
node.children === undefined || node.children.length === 0
|
|
623
626
|
? ''
|
|
@@ -650,44 +653,46 @@ const frame = (opts: { ctx: INewKindsContext; drawing: IKindDrawing }): string =
|
|
|
650
653
|
return `<figure class="kfig"><div class="fig f${width}">${opts.drawing.svg}</div>${opts.drawing.list}<figcaption>${escaped(opts.drawing.caption)}</figcaption></figure>`;
|
|
651
654
|
};
|
|
652
655
|
|
|
653
|
-
export
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
};
|
|
656
|
+
export class KindsRender {
|
|
657
|
+
static sequenceSection(opts: { ctx: INewKindsContext }): string {
|
|
658
|
+
const { sequence } = opts.ctx.spec;
|
|
659
|
+
|
|
660
|
+
return sequence === undefined
|
|
661
|
+
? ''
|
|
662
|
+
: SpecSections.section({
|
|
663
|
+
id: 'sequence',
|
|
664
|
+
title: opts.ctx.chrome.sequence,
|
|
665
|
+
body: frame({
|
|
666
|
+
ctx: opts.ctx,
|
|
667
|
+
drawing: renderSequence({ sequence, chrome: opts.ctx.chrome }),
|
|
668
|
+
}),
|
|
669
|
+
});
|
|
670
|
+
}
|
|
667
671
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
672
|
+
static lifecycleSection(opts: { ctx: INewKindsContext }): string {
|
|
673
|
+
const { lifecycle } = opts.ctx.spec;
|
|
674
|
+
|
|
675
|
+
return lifecycle === undefined
|
|
676
|
+
? ''
|
|
677
|
+
: SpecSections.section({
|
|
678
|
+
id: 'lifecycle',
|
|
679
|
+
title: opts.ctx.chrome.lifecycle,
|
|
680
|
+
body: frame({
|
|
681
|
+
ctx: opts.ctx,
|
|
682
|
+
drawing: renderLifecycle({ lifecycle, chrome: opts.ctx.chrome }),
|
|
683
|
+
}),
|
|
684
|
+
});
|
|
685
|
+
}
|
|
682
686
|
|
|
683
|
-
|
|
684
|
-
|
|
687
|
+
static treeSection(opts: { ctx: INewKindsContext }): string {
|
|
688
|
+
const { tree } = opts.ctx.spec;
|
|
685
689
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
690
|
+
return tree === undefined
|
|
691
|
+
? ''
|
|
692
|
+
: SpecSections.section({
|
|
693
|
+
id: 'tree',
|
|
694
|
+
title: opts.ctx.chrome.tree,
|
|
695
|
+
body: frame({ ctx: opts.ctx, drawing: renderTree({ tree, chrome: opts.ctx.chrome }) }),
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}
|
|
@@ -172,13 +172,15 @@ const checkTree = (opts: { tree: TTree }): string[] => {
|
|
|
172
172
|
return problems;
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
175
|
+
export class KindsValidate {
|
|
176
|
+
/** What a schema cannot say about the sequence, the lifecycle and the tree: ids, ends of arrows, reach, limits. */
|
|
177
|
+
static checkNew(opts: { spec: INewKindsSpec }): string[] {
|
|
178
|
+
const { sequence, lifecycle, tree } = opts.spec;
|
|
179
|
+
|
|
180
|
+
return [
|
|
181
|
+
...(sequence === undefined ? [] : checkSequence({ sequence })),
|
|
182
|
+
...(lifecycle === undefined ? [] : checkLifecycle({ lifecycle })),
|
|
183
|
+
...(tree === undefined ? [] : checkTree({ tree })),
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
}
|