@venizia/vulcan 0.4.10-2 → 0.4.10-3
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 +19 -14
- package/base/hooks/guard-outside.ts +6 -17
- package/base/hooks/guard-writes.ts +3 -24
- package/base/rules.md +3 -3
- package/base/skills/visualize-work/SKILL.md +1 -1
- package/base/skills/visualize-work/references/spec.md +1 -1
- package/package.json +3 -3
- package/src/agents/resolve.ts +1 -0
- package/src/board/common/types.ts +2 -2
- package/src/board/schema.ts +4 -1
- package/src/board/settings.ts +1 -1
- package/src/commands/help.command.ts +2 -63
- package/src/commands/table.ts +315 -0
- package/src/commit/check.ts +1 -0
- package/src/commit/common/constants.ts +2 -0
- package/src/commit/hook.ts +44 -4
- package/src/common/constants.ts +6 -3
- package/src/common/env-variables.ts +37 -0
- package/src/common/index.ts +1 -0
- package/src/config/loader.ts +22 -0
- package/src/config/schema.ts +121 -4
- package/src/create/add-app.ts +5 -0
- package/src/create/common/constants.ts +5 -3
- package/src/create/preset.ts +1 -0
- package/src/doctor/checks.ts +10 -0
- package/src/doctor/common/constants.ts +26 -0
- package/src/doctor/runner.ts +1 -0
- package/src/doctor/schema.ts +4 -0
- package/src/hooks/owner-reply.ts +5 -0
- package/src/hooks/project-guards.ts +25 -4
- package/src/hooks/session-digest.ts +9 -0
- package/src/init/scaffold.ts +1 -0
- package/src/local/auto-clean.ts +2 -1
- package/src/local/clean.ts +1 -0
- package/src/manifest/render.ts +48 -6
- package/src/owner/constants.ts +3 -1
- package/src/owner/profile.ts +1 -0
- package/src/owner/schema.ts +37 -6
- package/src/router.ts +4 -130
- package/src/rules/base.ts +1 -0
- package/src/signals/loop.ts +1 -0
- package/src/skills/frontmatter.ts +1 -0
- package/src/sync/planner.ts +1 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/tokens.ts +305 -0
- package/src/ui/prompt.ts +1 -0
- package/src/visualize/page.ts +4 -4
- package/src/visualize/render.ts +2 -1
- package/src/visualize/theme.ts +27 -10
- package/src/wiki/anchors.ts +1 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { ProjectTheme, Theme } from '../visualize/theme.ts';
|
|
2
|
+
import type { IThemeInput } from '../visualize/theme.ts';
|
|
3
|
+
|
|
4
|
+
/** One mode of the token set: token name to colour (`#rrggbb`, or `#rrggbbaa` for a line or a muted text). */
|
|
5
|
+
export type TTokenMode = Record<string, string>;
|
|
6
|
+
|
|
7
|
+
/** What the project writes under `theme`: a preset, an accent, per-token overrides and the type and corner settings. */
|
|
8
|
+
export interface IThemeConfig extends Partial<IThemeInput> {
|
|
9
|
+
preset?: string;
|
|
10
|
+
/** A colour for both modes, or one per mode. */
|
|
11
|
+
tokens?: Record<string, string | { light?: string; dark?: string }>;
|
|
12
|
+
font?: string;
|
|
13
|
+
mono?: string;
|
|
14
|
+
radius?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The resolved set every consumer reads: both modes and the three settings, with the preset it started from. */
|
|
18
|
+
export interface IThemeTokens {
|
|
19
|
+
preset: string;
|
|
20
|
+
light: TTokenMode;
|
|
21
|
+
dark: TTokenMode;
|
|
22
|
+
font: string;
|
|
23
|
+
mono: string;
|
|
24
|
+
radius: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type TTokensResult = { ok: true; tokens: IThemeTokens } | { ok: false; problems: string[] };
|
|
28
|
+
|
|
29
|
+
interface IPreset {
|
|
30
|
+
/** The accent the preset is known by; a project that gives the same seed gets the preset as written. */
|
|
31
|
+
seed: IThemeInput;
|
|
32
|
+
light: TTokenMode;
|
|
33
|
+
dark: TTokenMode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The neutral part shared by the presets: grounds, text, lines and the states. Board and wiki agree on these values. */
|
|
37
|
+
const NEUTRAL_LIGHT: TTokenMode = {
|
|
38
|
+
ground: '#f5f5f5',
|
|
39
|
+
bg: '#ffffff',
|
|
40
|
+
line: '#0000001a',
|
|
41
|
+
'line-strong': '#101010',
|
|
42
|
+
ink: '#000000',
|
|
43
|
+
body: '#4b4b4b',
|
|
44
|
+
muted: '#6b6b6b',
|
|
45
|
+
ok: '#067647',
|
|
46
|
+
'ok-soft': '#e7f5ee',
|
|
47
|
+
wait: '#8a4b00',
|
|
48
|
+
'wait-soft': '#fdf1dc',
|
|
49
|
+
fail: '#b42318',
|
|
50
|
+
'fail-soft': '#fdecea',
|
|
51
|
+
info: '#175cd3',
|
|
52
|
+
'info-soft': '#eff8ff',
|
|
53
|
+
};
|
|
54
|
+
const NEUTRAL_DARK: TTokenMode = {
|
|
55
|
+
ground: '#121214',
|
|
56
|
+
bg: '#1b1b1b',
|
|
57
|
+
line: '#ffffff1a',
|
|
58
|
+
'line-strong': '#ffffff4d',
|
|
59
|
+
ink: '#ffffff',
|
|
60
|
+
body: '#ffffffb3',
|
|
61
|
+
muted: '#ffffff8c',
|
|
62
|
+
ok: '#47cd89',
|
|
63
|
+
'ok-soft': '#14291f',
|
|
64
|
+
wait: '#fdb022',
|
|
65
|
+
'wait-soft': '#33270f',
|
|
66
|
+
fail: '#f97066',
|
|
67
|
+
'fail-soft': '#3a1d1a',
|
|
68
|
+
info: '#84caff',
|
|
69
|
+
'info-soft': '#102a43',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** The text pairs checked at 4.5:1 and the marks at 3:1, per mode; `on` names the token the first sits on. */
|
|
73
|
+
const TEXT_PAIRS: [string, string][] = [
|
|
74
|
+
['ink', 'bg'],
|
|
75
|
+
['body', 'bg'],
|
|
76
|
+
['muted', 'bg'],
|
|
77
|
+
['ink', 'ground'],
|
|
78
|
+
['body', 'ground'],
|
|
79
|
+
['muted', 'ground'],
|
|
80
|
+
['accent-text', 'bg'],
|
|
81
|
+
['accent-text', 'ground'],
|
|
82
|
+
['accent-text', 'accent-soft'],
|
|
83
|
+
['accent-ink', 'accent'],
|
|
84
|
+
['ok', 'ok-soft'],
|
|
85
|
+
['wait', 'wait-soft'],
|
|
86
|
+
['fail', 'fail-soft'],
|
|
87
|
+
['info', 'info-soft'],
|
|
88
|
+
];
|
|
89
|
+
const MARK_PAIRS: [string, string][] = [
|
|
90
|
+
['accent', 'bg'],
|
|
91
|
+
['accent', 'ground'],
|
|
92
|
+
['ok', 'bg'],
|
|
93
|
+
['wait', 'bg'],
|
|
94
|
+
['fail', 'bg'],
|
|
95
|
+
['info', 'bg'],
|
|
96
|
+
];
|
|
97
|
+
const TEXT_RATIO = 4.5;
|
|
98
|
+
const MARK_RATIO = 3;
|
|
99
|
+
|
|
100
|
+
/** The design tokens: fixed semantic names, values from a preset and the project, checked against WCAG AA. */
|
|
101
|
+
export class ThemeTokens {
|
|
102
|
+
static readonly DEFAULT_PRESET = 'venizia';
|
|
103
|
+
|
|
104
|
+
/** A colour of a token: six hex digits, or eight with an alpha channel (a line, a soft text). */
|
|
105
|
+
static readonly COLOUR = /^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/;
|
|
106
|
+
|
|
107
|
+
static readonly PRESETS: Record<string, IPreset> = {
|
|
108
|
+
venizia: {
|
|
109
|
+
seed: ProjectTheme.DEFAULT,
|
|
110
|
+
light: {
|
|
111
|
+
...NEUTRAL_LIGHT,
|
|
112
|
+
accent: '#8a5a20',
|
|
113
|
+
'accent-ink': '#ffffff',
|
|
114
|
+
'accent-soft': '#f5ecdf',
|
|
115
|
+
'accent-text': '#8a5a20',
|
|
116
|
+
},
|
|
117
|
+
dark: {
|
|
118
|
+
...NEUTRAL_DARK,
|
|
119
|
+
accent: '#dead6a',
|
|
120
|
+
'accent-ink': '#1a1200',
|
|
121
|
+
'accent-soft': '#33281a',
|
|
122
|
+
'accent-text': '#dead6a',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
slate: {
|
|
126
|
+
seed: { accent: '#3f5266', accentDark: '#9fb4cc' },
|
|
127
|
+
light: NEUTRAL_LIGHT,
|
|
128
|
+
dark: NEUTRAL_DARK,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
static readonly FONT = "'Inter Display', system-ui, -apple-system, 'Segoe UI', sans-serif";
|
|
133
|
+
static readonly MONO =
|
|
134
|
+
"'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace";
|
|
135
|
+
static readonly RADIUS = '4px';
|
|
136
|
+
|
|
137
|
+
/** The names a project may override: the keys of a preset. */
|
|
138
|
+
static names(): string[] {
|
|
139
|
+
return Object.keys(ThemeTokens.PRESETS.venizia.light);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** A colour with an alpha channel laid over `ground`, as the six-digit colour the eye sees. */
|
|
143
|
+
private static opaque(opts: { color: string; ground: string }): string {
|
|
144
|
+
if (opts.color.length !== 9) {
|
|
145
|
+
return opts.color;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const alpha = Number.parseInt(opts.color.slice(7), 16) / 255;
|
|
149
|
+
const channel = (from: number): number =>
|
|
150
|
+
Math.round(
|
|
151
|
+
Number.parseInt(opts.color.slice(from, from + 2), 16) * alpha +
|
|
152
|
+
Number.parseInt(opts.ground.slice(from, from + 2), 16) * (1 - alpha),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
return `#${[1, 3, 5].map((from) => channel(from).toString(16).padStart(2, '0')).join('')}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private static ratio(opts: { mode: TTokenMode; text: string; on: string }): number {
|
|
159
|
+
const ground = ThemeTokens.opaque({ color: opts.mode[opts.on], ground: opts.mode.bg });
|
|
160
|
+
|
|
161
|
+
return Theme.contrastOf({
|
|
162
|
+
foreground: ThemeTokens.opaque({ color: opts.mode[opts.text], ground }),
|
|
163
|
+
background: ground,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Every pair of a mode below AA, each as a sentence that names the pair, the colours and the ratio. */
|
|
168
|
+
private static contrastProblems(opts: { name: string; mode: TTokenMode }): string[] {
|
|
169
|
+
const problems: string[] = [];
|
|
170
|
+
|
|
171
|
+
for (const [pairs, needed, role] of [
|
|
172
|
+
[TEXT_PAIRS, TEXT_RATIO, 'text'],
|
|
173
|
+
[MARK_PAIRS, MARK_RATIO, 'a mark'],
|
|
174
|
+
] as const) {
|
|
175
|
+
for (const [text, on] of pairs) {
|
|
176
|
+
const ratio = ThemeTokens.ratio({ mode: opts.mode, text, on });
|
|
177
|
+
|
|
178
|
+
if (ratio < needed) {
|
|
179
|
+
problems.push(
|
|
180
|
+
`${opts.name}: ${text} ${opts.mode[text]} as ${role} on ${on} ${opts.mode[on]} is ${ratio.toFixed(2)}:1; it needs ${needed}:1`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return problems;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The token set of a project's `theme` (or of the default preset when it has none): the preset as written, the
|
|
191
|
+
* accent family derived when the project gives its own accent, then its per-token overrides. Every pair is checked
|
|
192
|
+
* for each mode and a pair below AA refuses the whole theme; nothing is swapped for another colour.
|
|
193
|
+
*/
|
|
194
|
+
static resolve(opts: { theme?: IThemeConfig }): TTokensResult {
|
|
195
|
+
const theme = opts.theme ?? {};
|
|
196
|
+
const presetName = theme.preset ?? ThemeTokens.DEFAULT_PRESET;
|
|
197
|
+
const preset = Object.hasOwn(ThemeTokens.PRESETS, presetName)
|
|
198
|
+
? ThemeTokens.PRESETS[presetName]
|
|
199
|
+
: undefined;
|
|
200
|
+
|
|
201
|
+
if (preset === undefined) {
|
|
202
|
+
return {
|
|
203
|
+
ok: false,
|
|
204
|
+
problems: [
|
|
205
|
+
`theme preset '${presetName}' is unknown; use one of ${Object.keys(ThemeTokens.PRESETS).join(', ')}`,
|
|
206
|
+
],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (
|
|
211
|
+
theme.accent === undefined &&
|
|
212
|
+
(theme.accentDark !== undefined || theme.accentText !== undefined)
|
|
213
|
+
) {
|
|
214
|
+
return {
|
|
215
|
+
ok: false,
|
|
216
|
+
problems: ['theme accentDark and accentText belong to an accent: give accent too'],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const light: TTokenMode = { ...preset.light };
|
|
221
|
+
const dark: TTokenMode = { ...preset.dark };
|
|
222
|
+
const seed: IThemeInput =
|
|
223
|
+
theme.accent === undefined
|
|
224
|
+
? preset.seed
|
|
225
|
+
: { accent: theme.accent, accentDark: theme.accentDark, accentText: theme.accentText };
|
|
226
|
+
const own =
|
|
227
|
+
seed.accent === preset.seed.accent &&
|
|
228
|
+
seed.accentDark === preset.seed.accentDark &&
|
|
229
|
+
seed.accentText === undefined;
|
|
230
|
+
|
|
231
|
+
// Venizia carries its accent family as written; any other seed is derived by the page resolver, which refuses a bad one.
|
|
232
|
+
if (!own || presetName !== 'venizia') {
|
|
233
|
+
const derived = ProjectTheme.resolve({ project: seed });
|
|
234
|
+
|
|
235
|
+
if (!derived.ok) {
|
|
236
|
+
return { ok: false, problems: derived.problems };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (const [mode, palette] of [
|
|
240
|
+
[light, derived.theme.light],
|
|
241
|
+
[dark, derived.theme.dark],
|
|
242
|
+
] as const) {
|
|
243
|
+
mode.accent = palette.accent;
|
|
244
|
+
mode['accent-ink'] = palette.accentInk;
|
|
245
|
+
mode['accent-soft'] = palette.accentSoft;
|
|
246
|
+
mode['accent-text'] = palette.accent;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// On the light ground the page resolver's accent is the text colour; the mark and the fill are the seed itself.
|
|
250
|
+
light.accent = seed.accent;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const problems: string[] = [];
|
|
254
|
+
|
|
255
|
+
for (const [name, value] of Object.entries(theme.tokens ?? {})) {
|
|
256
|
+
if (!Object.hasOwn(light, name)) {
|
|
257
|
+
problems.push(
|
|
258
|
+
`theme token '${name}' is unknown; use one of ${ThemeTokens.names().join(', ')}`,
|
|
259
|
+
);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const given = typeof value === 'string' ? { light: value, dark: value } : value;
|
|
264
|
+
|
|
265
|
+
for (const [mode, key] of [
|
|
266
|
+
[light, 'light'],
|
|
267
|
+
[dark, 'dark'],
|
|
268
|
+
] as const) {
|
|
269
|
+
const color = given[key];
|
|
270
|
+
|
|
271
|
+
if (color === undefined) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (!ThemeTokens.COLOUR.test(color)) {
|
|
276
|
+
problems.push(`theme token '${name}' ${key} '${color}' is not a hex colour like #8a5a20`);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
mode[name] = color.toLowerCase();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
problems.push(
|
|
285
|
+
...ThemeTokens.contrastProblems({ name: 'light', mode: light }),
|
|
286
|
+
...ThemeTokens.contrastProblems({ name: 'dark', mode: dark }),
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
if (problems.length > 0) {
|
|
290
|
+
return { ok: false, problems };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return {
|
|
294
|
+
ok: true,
|
|
295
|
+
tokens: {
|
|
296
|
+
preset: presetName,
|
|
297
|
+
light,
|
|
298
|
+
dark,
|
|
299
|
+
font: theme.font ?? ThemeTokens.FONT,
|
|
300
|
+
mono: theme.mono ?? ThemeTokens.MONO,
|
|
301
|
+
radius: theme.radius ?? ThemeTokens.RADIUS,
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
package/src/ui/prompt.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface IChoice {
|
|
|
8
8
|
hint?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/** Terminal prompts (text, select, multiselect, confirm, plan) for the interactive commands such as `vulcan init`, `vulcan add` and `vulcan profile`. */
|
|
11
12
|
export class TerminalPrompt {
|
|
12
13
|
/**
|
|
13
14
|
* Free text, only where there is nothing to pick from (a new name). A default, when there is one, is
|
package/src/visualize/page.ts
CHANGED
|
@@ -152,13 +152,13 @@ const ownerHtml = (opts: { spec: TVisualizeSpec; chrome: TChrome }): string => {
|
|
|
152
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>`;
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
-
/** The
|
|
156
|
-
const
|
|
155
|
+
/** The theme of a page that is given none: the default preset. */
|
|
156
|
+
const DEFAULT_THEME = ((): IResolvedTheme => {
|
|
157
157
|
const resolved = ProjectTheme.resolve({});
|
|
158
158
|
|
|
159
159
|
if (!resolved.ok) {
|
|
160
160
|
throw new Error(
|
|
161
|
-
`the
|
|
161
|
+
`the default theme does not pass its own checks: ${resolved.problems.join('; ')}`,
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -226,7 +226,7 @@ export class PageShell {
|
|
|
226
226
|
}),
|
|
227
227
|
SpecSections.links({ ctx }),
|
|
228
228
|
].join('');
|
|
229
|
-
const css = `${Assets.pageCss({ tokens: ProjectTheme.tokensCss({ theme: opts.theme ??
|
|
229
|
+
const css = `${Assets.pageCss({ tokens: ProjectTheme.tokensCss({ theme: opts.theme ?? DEFAULT_THEME }) })}\n${NEW_KINDS_CSS}\n${COMPARE_CSS}\n${GridSpans.css({ spans: ctx.spans })}\n${figureFitCss({ widths: ctx.fits })}`;
|
|
230
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
231
|
const links = SpecSections.sectionLinks({ spec, chrome })
|
|
232
232
|
.map((link) => `<a href="#${link.id}">${escaped(link.title)}</a>`)
|
package/src/visualize/render.ts
CHANGED
|
@@ -39,6 +39,7 @@ const CHECKS = [
|
|
|
39
39
|
"no network, no font, no image, a policy that allows only the page's own style and script",
|
|
40
40
|
];
|
|
41
41
|
|
|
42
|
+
/** Validates a JSON spec and renders it as one static HTML page; used by `vulcan visualize`. */
|
|
42
43
|
export class SpecPage {
|
|
43
44
|
/** Spec text to a page: parse, validate, cross-check, render, size gate. Nothing is written here. */
|
|
44
45
|
static renderText(opts: { text: string; context?: IRenderContext }): TRenderResult {
|
|
@@ -115,7 +116,7 @@ export class SpecPage {
|
|
|
115
116
|
checks: [
|
|
116
117
|
...CHECKS,
|
|
117
118
|
PageGate.CHECK,
|
|
118
|
-
`colour from the ${themed.theme.source === 'spec' ? "spec's accent" : themed.theme.source === 'project' ? "project's theme" : '
|
|
119
|
+
`colour from the ${themed.theme.source === 'spec' ? "spec's accent" : themed.theme.source === 'project' ? "project's theme" : 'default preset'}: every text, mark and fill pair checked`,
|
|
119
120
|
...themed.theme.notes,
|
|
120
121
|
`size ${(bytes / 1024).toFixed(1)} KB, within ${VisualizeLimits.FAIL_BYTES / 1024} KB`,
|
|
121
122
|
],
|
package/src/visualize/theme.ts
CHANGED
|
@@ -159,20 +159,23 @@ const GROUNDS = {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
export class ProjectTheme {
|
|
162
|
-
/** The colour of a page whose project says nothing:
|
|
163
|
-
static readonly DEFAULT: IThemeInput = { accent: '#
|
|
162
|
+
/** The colour of a page whose project says nothing: the venizia bronze, the seeds of the default preset. */
|
|
163
|
+
static readonly DEFAULT: IThemeInput = { accent: '#8a5a20', accentDark: '#dead6a' };
|
|
164
164
|
|
|
165
165
|
/** The manifest is read only up to this size: a real one is a few KB. */
|
|
166
166
|
static readonly MAX_MANIFEST_BYTES = 1024 * 1024;
|
|
167
167
|
|
|
168
|
+
/** The six-digit hex colour pattern, the one the config and the tokens check with. */
|
|
169
|
+
static readonly HEX = HEX;
|
|
170
|
+
|
|
168
171
|
/** Whether `value` is a six-digit hex colour. */
|
|
169
172
|
static isHex(value: unknown): value is string {
|
|
170
173
|
return typeof value === 'string' && HEX.test(value);
|
|
171
174
|
}
|
|
172
175
|
|
|
173
176
|
/**
|
|
174
|
-
* The theme of a page: the spec's own accent, else the project's `theme` from the manifest, else the
|
|
175
|
-
*
|
|
177
|
+
* The theme of a page: the spec's own accent, else the project's `theme` from the manifest, else the default
|
|
178
|
+
* preset. Every text, mark and fill pair is checked; a failure writes nothing and says the colour, the ground
|
|
176
179
|
* and the ratio. A colour is never swapped for another.
|
|
177
180
|
*/
|
|
178
181
|
static resolve(opts: { spec?: IThemeInput; project?: IThemeInput }): TThemeResult {
|
|
@@ -405,7 +408,7 @@ export class ProjectTheme {
|
|
|
405
408
|
|
|
406
409
|
/**
|
|
407
410
|
* The project's `theme` from the manifest of the folder the command runs in. No config file is loaded and nothing
|
|
408
|
-
* is requested: a missing file, or a manifest with no `theme`, is the
|
|
411
|
+
* is requested: a missing file, or a manifest with no `theme`, is the default preset.
|
|
409
412
|
*/
|
|
410
413
|
static readManifestTheme(opts: { root: string }): { theme?: IThemeInput; warning?: string } {
|
|
411
414
|
let text: string;
|
|
@@ -436,7 +439,7 @@ export class ProjectTheme {
|
|
|
436
439
|
manifest = JSON.parse(text);
|
|
437
440
|
} catch {
|
|
438
441
|
return {
|
|
439
|
-
warning: '.agents/vulcan.manifest.json is not valid JSON, so the
|
|
442
|
+
warning: '.agents/vulcan.manifest.json is not valid JSON, so the default colour is used',
|
|
440
443
|
};
|
|
441
444
|
}
|
|
442
445
|
|
|
@@ -450,16 +453,30 @@ export class ProjectTheme {
|
|
|
450
453
|
}
|
|
451
454
|
|
|
452
455
|
if (typeof theme !== 'object' || theme === null) {
|
|
453
|
-
return { warning: 'the manifest theme is not an object, so the
|
|
456
|
+
return { warning: 'the manifest theme is not an object, so the default colour is used' };
|
|
454
457
|
}
|
|
455
458
|
|
|
456
|
-
|
|
457
|
-
const
|
|
459
|
+
// A manifest that holds only the resolved tokens (a project that set no accent) gives the accent of its preset.
|
|
460
|
+
const tokens: unknown = Reflect.get(theme, 'tokens');
|
|
461
|
+
const modeOf = (mode: string): unknown =>
|
|
462
|
+
typeof tokens === 'object' && tokens !== null ? Reflect.get(tokens, mode) : undefined;
|
|
463
|
+
const resolvedAccent = (mode: string): unknown => {
|
|
464
|
+
const palette = modeOf(mode);
|
|
465
|
+
|
|
466
|
+
return typeof palette === 'object' && palette !== null
|
|
467
|
+
? Reflect.get(palette, 'accent')
|
|
468
|
+
: undefined;
|
|
469
|
+
};
|
|
470
|
+
const given: unknown = Reflect.get(theme, 'accent');
|
|
471
|
+
const accent: unknown = given ?? resolvedAccent('light');
|
|
472
|
+
const accentDark: unknown =
|
|
473
|
+
Reflect.get(theme, 'accentDark') ??
|
|
474
|
+
(given === undefined ? resolvedAccent('dark') : undefined);
|
|
458
475
|
const accentText: unknown = Reflect.get(theme, 'accentText');
|
|
459
476
|
|
|
460
477
|
if (!ProjectTheme.isHex(accent)) {
|
|
461
478
|
return {
|
|
462
|
-
warning: 'the manifest theme has no six-digit hex accent, so the
|
|
479
|
+
warning: 'the manifest theme has no six-digit hex accent, so the default colour is used',
|
|
463
480
|
};
|
|
464
481
|
}
|
|
465
482
|
|
package/src/wiki/anchors.ts
CHANGED
|
@@ -76,6 +76,7 @@ const readAnchors = (opts: { dist: string }): Map<string, Set<string>> => {
|
|
|
76
76
|
return anchorsByRoute;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
/** Checks that the heading links in wiki content resolve to a built page anchor; run by `make wiki-anchors-check`. */
|
|
79
80
|
export class AnchorCheck {
|
|
80
81
|
/** Checks every `](page#fragment)` link of the markdown under `content` against the ids built in `dist`. */
|
|
81
82
|
static check(opts: { content: string; dist: string }): {
|