yadflow 4.10.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +14 -3
  3. package/bin/commands.mjs +7 -1
  4. package/bin/yad.mjs +163 -16
  5. package/cli/agent-guard-worker.mjs +13 -0
  6. package/cli/agent-guard.mjs +1053 -57
  7. package/cli/agent-rules.mjs +59 -3
  8. package/cli/argv-flags.mjs +2 -2
  9. package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
  10. package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
  11. package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
  12. package/cli/brain/vendor/graphology-library.min.js +2 -0
  13. package/cli/brain/vendor/graphology.umd.min.js +2 -0
  14. package/cli/brain/vendor/sigma.min.js +1369 -0
  15. package/cli/brain/view/app.js +382 -0
  16. package/cli/brain/view/index.html +63 -0
  17. package/cli/brain/view/live.css +228 -0
  18. package/cli/brain/view/live.html +110 -0
  19. package/cli/brain/view/live.js +884 -0
  20. package/cli/brain/view/style.css +141 -0
  21. package/cli/brain-about.mjs +206 -0
  22. package/cli/brain-activity.mjs +285 -0
  23. package/cli/brain-skills.mjs +118 -0
  24. package/cli/brain-vendor.mjs +71 -0
  25. package/cli/brain-view.mjs +345 -0
  26. package/cli/brain.mjs +810 -0
  27. package/cli/brand-cmd.mjs +326 -0
  28. package/cli/brand.mjs +327 -0
  29. package/cli/ci-check.mjs +3 -3
  30. package/cli/doctor.mjs +145 -14
  31. package/cli/epic-state.mjs +93 -1
  32. package/cli/epic.mjs +15 -3
  33. package/cli/errors.mjs +2 -1
  34. package/cli/find-product.mjs +69 -15
  35. package/cli/foundation-publish.mjs +256 -0
  36. package/cli/gate.mjs +29 -3
  37. package/cli/git-read.mjs +38 -0
  38. package/cli/guard-stream.mjs +409 -0
  39. package/cli/guide.mjs +26 -3
  40. package/cli/hook.mjs +59 -9
  41. package/cli/issues-act.mjs +57 -13
  42. package/cli/issues-write.mjs +19 -6
  43. package/cli/issues.mjs +69 -24
  44. package/cli/lib.mjs +37 -2
  45. package/cli/local-page.mjs +138 -0
  46. package/cli/local-setup-record.mjs +71 -0
  47. package/cli/local-setup-steps.mjs +186 -0
  48. package/cli/local-setup.mjs +611 -0
  49. package/cli/machine.mjs +1 -1
  50. package/cli/manifest.mjs +55 -0
  51. package/cli/map/view/app.js +712 -0
  52. package/cli/map/view/index.html +50 -0
  53. package/cli/map/view/style.css +142 -0
  54. package/cli/map-view.mjs +190 -0
  55. package/cli/map.mjs +637 -0
  56. package/cli/members.mjs +9 -15
  57. package/cli/next.mjs +1 -1
  58. package/cli/openpr.mjs +2 -2
  59. package/cli/plain-text.mjs +22 -0
  60. package/cli/plan.mjs +310 -36
  61. package/cli/platform.mjs +5 -5
  62. package/cli/product-index.mjs +1 -1
  63. package/cli/protection.mjs +32 -0
  64. package/cli/reconcile.mjs +61 -13
  65. package/cli/report.mjs +9 -3
  66. package/cli/reports-dir.mjs +393 -0
  67. package/cli/reports.mjs +65 -0
  68. package/cli/run-checks.mjs +5 -2
  69. package/cli/scan.mjs +4 -6
  70. package/cli/secret-text.mjs +66 -0
  71. package/cli/setup.mjs +54 -8
  72. package/cli/standup.mjs +94 -72
  73. package/cli/status.mjs +6 -5
  74. package/cli/test-agents-file.mjs +614 -8
  75. package/cli/test-brain-activity.mjs +753 -0
  76. package/cli/test-brain-view.mjs +381 -0
  77. package/cli/test-brain.mjs +795 -0
  78. package/cli/test-brand.mjs +558 -0
  79. package/cli/test-guide.mjs +438 -0
  80. package/cli/test-local-setup.mjs +1188 -0
  81. package/cli/test-machine.mjs +59 -0
  82. package/cli/test-map.mjs +615 -0
  83. package/cli/test-reports.mjs +382 -0
  84. package/cli/test-run-checks.mjs +4 -0
  85. package/cli/test-worktree.mjs +24 -3
  86. package/cli/toolbox-connect.mjs +21 -6
  87. package/cli/toolbox.mjs +74 -5
  88. package/cli/update-commit.mjs +118 -9
  89. package/cli/usage.mjs +17 -7
  90. package/cli/workspace.mjs +11 -2
  91. package/package.json +8 -4
  92. package/skills/sdlc/module-help.csv +1 -0
  93. package/skills/yad-architecture/SKILL.md +22 -4
  94. package/skills/yad-brand/SKILL.md +69 -0
  95. package/skills/yad-change/SKILL.md +3 -1
  96. package/skills/yad-change/references/triage.md +2 -0
  97. package/skills/yad-checks/SKILL.md +2 -0
  98. package/skills/yad-checks/references/check-gates.md +8 -5
  99. package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
  100. package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
  101. package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
  102. package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
  103. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
  104. package/skills/yad-checks/templates/hooks/local-setup-notice.mjs +96 -0
  105. package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
  106. package/skills/yad-connect-repos/SKILL.md +14 -0
  107. package/skills/yad-discovery/SKILL.md +11 -0
  108. package/skills/yad-discovery/references/foundation-schema.md +11 -0
  109. package/skills/yad-docs/templates/app/package-lock.json +18 -10
  110. package/skills/yad-docs/templates/app/package.json +6 -1
  111. package/skills/yad-epic/SKILL.md +3 -0
  112. package/skills/yad-epic/references/state-schema.md +35 -1
  113. package/skills/yad-guide/SKILL.md +10 -7
  114. package/skills/yad-implement/SKILL.md +76 -15
  115. package/skills/yad-issues/SKILL.md +2 -1
  116. package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
  117. package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
  118. package/skills/yad-spec/SKILL.md +19 -0
  119. package/skills/yad-stories/SKILL.md +22 -4
  120. package/skills/yad-stories/references/story-schema.md +1 -1
package/cli/brand.mjs ADDED
@@ -0,0 +1,327 @@
1
+ // The Product's brand on every page yadflow makes (E184).
2
+ //
3
+ // A Product may hold its design system — its logo, its colours, its fonts — in many shapes: a DESIGN.md with
4
+ // YAML front matter, one with a CSS `:root` block, prose tables, or a design tool. Pages never parse those.
5
+ // They read ONE small committed file, `.sdlc/brand.json`, which `yad brand init` (or the yad-brand skill)
6
+ // fills from the Product's design system:
7
+ //
8
+ // { "version": 1, "name": "…", "source": "DESIGN.md", "sourceHash": "sha256:…",
9
+ // "logo": "design/logo.svg", "mark": "design/mark.svg",
10
+ // "colors": { "light": { bg, surface, text, muted, border, primary, accent }, "dark": { … } | null },
11
+ // "fonts": { "heading": { "family": "Cairo", "files": ["design/fonts/Cairo.woff2"] } | null, "body": …, "mono": … },
12
+ // "status": { live, merged, active, planned, idle } | null }
13
+ //
14
+ // With no file — or a file that cannot be used — every page wears yadflow's own look (its logo's purple and
15
+ // pink) and says why in `yad brand`. A brand never breaks a page: each value is checked before it reaches one.
16
+ //
17
+ // SAFETY. A colour must match a narrow pattern (hex, or rgb/hsl/oklch/oklab of numbers), so no value can end
18
+ // the CSS it is written into. A file must sit inside the Product (no `..`, no link out), be of an allowed type
19
+ // and under its size cap; it is embedded as a data: URI, and an SVG is only ever shown through <img>, where
20
+ // its scripts never run. A font family is letters, digits, spaces, `-` and `_`.
21
+ import fs from 'node:fs';
22
+ import path from 'node:path';
23
+ import { createHash } from 'node:crypto';
24
+ import { fileURLToPath } from 'node:url';
25
+ import { readJSONStrict } from './lib.mjs';
26
+ import { PROJECT_FILES } from './manifest.mjs';
27
+
28
+ export const BRAND_FILE = PROJECT_FILES.brandConfig;
29
+ export const BRAND_VERSION = 1;
30
+ export const ROLES = Object.freeze(['bg', 'surface', 'text', 'muted', 'border', 'primary', 'accent']);
31
+ export const STATUS_KEYS = Object.freeze(['live', 'merged', 'active', 'planned', 'idle']);
32
+ export const FONT_SLOTS = Object.freeze(['heading', 'body', 'mono']);
33
+ export const IMAGE_CAP = 512 * 1024;
34
+ export const FONT_CAP = 600 * 1024;
35
+ const IMAGE_TYPES = Object.freeze({ '.svg': 'image/svg+xml', '.png': 'image/png', '.webp': 'image/webp', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg' });
36
+ const FONT_TYPES = Object.freeze({ '.woff2': ['font/woff2', 'woff2'], '.woff': ['font/woff', 'woff'], '.ttf': ['font/ttf', 'truetype'], '.otf': ['font/otf', 'opentype'] });
37
+
38
+ // A colour value: hex, or a CSS colour function holding only numbers, units, `%`, `.`, `/`, `,` and spaces.
39
+ export const COLOR_RE = /^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?|oklch|oklab)\(\s*(?:[-+0-9.%\s/,]|deg|turn|none)+\))$/i;
40
+ export const FAMILY_RE = /^[A-Za-z0-9][A-Za-z0-9 _-]{0,63}$/;
41
+ // A colour yadflow can write: checked for length first, so a huge value never reaches the pattern (review 1).
42
+ export const COLOR_MAX = 64;
43
+ export const isColor = (v) => typeof v === 'string' && v.trim().length <= COLOR_MAX && COLOR_RE.test(v.trim());
44
+ const SYSTEM_SANS = 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
45
+ const SYSTEM_MONO = 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';
46
+
47
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
48
+ export const YADFLOW_MARK_FILE = path.join(HERE, '..', 'skills', 'yad-docs', 'templates', 'app', 'public', 'favicon.svg');
49
+
50
+ // yadflow's own look, from its logo: purple #6316DB and pink #FB2576 (until yadflow defines its brand).
51
+ export const YADFLOW_BRAND = Object.freeze({
52
+ version: BRAND_VERSION, name: 'yadflow', source: null, sourceHash: null, logo: null, mark: null,
53
+ colors: {
54
+ light: { bg: '#ffffff', surface: '#f7f5fb', text: '#1b1530', muted: '#5f5873', border: '#e4dff0', primary: '#6316db', accent: '#fb2576' },
55
+ dark: { bg: '#120e1c', surface: '#1c1729', text: '#f1edfa', muted: '#a59cba', border: '#2f2842', primary: '#9466f8', accent: '#ff6490' },
56
+ },
57
+ fonts: { heading: null, body: null, mono: null },
58
+ status: null,
59
+ });
60
+
61
+ const isObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
62
+
63
+ // A path in brand.json: relative, inside the Product, never through a link that leaves it. → absolute | null
64
+ export function brandPath(root, rel) {
65
+ if (typeof rel !== 'string' || !rel.trim() || path.isAbsolute(rel) || rel.split(/[\\/]/).includes('..')) return null;
66
+ const full = path.resolve(root, rel);
67
+ let realRoot, realFull;
68
+ try { realRoot = fs.realpathSync(root); realFull = fs.realpathSync(full); } catch { return null; }
69
+ return realFull.startsWith(realRoot + path.sep) ? realFull : null;
70
+ }
71
+
72
+ // Check a parsed brand.json. → { brand (normalised), problems: [text], warnings: [text] }
73
+ export function checkBrand(root, rec) {
74
+ const problems = [], warnings = [];
75
+ if (!isObj(rec)) return { brand: null, problems: [`${BRAND_FILE} is not a JSON object`], warnings };
76
+ if (rec.version !== BRAND_VERSION) problems.push(`${BRAND_FILE} is version ${JSON.stringify(rec.version ?? null)}, and this yadflow reads version ${BRAND_VERSION}`);
77
+ const name = typeof rec.name === 'string' && rec.name.trim() ? rec.name.trim().slice(0, 80) : null;
78
+ if (!name) problems.push('"name" must be the product\'s name');
79
+ const colors = { light: null, dark: null };
80
+ for (const scheme of ['light', 'dark']) {
81
+ const c = rec.colors?.[scheme];
82
+ if (c === null || c === undefined) { if (scheme === 'light') problems.push('"colors.light" is needed'); continue; }
83
+ if (!isObj(c)) { problems.push(`"colors.${scheme}" must be an object of colour roles`); continue; }
84
+ const out = {};
85
+ for (const role of ROLES) {
86
+ const v = c[role];
87
+ if (v === undefined || v === null) { warnings.push(`colors.${scheme}.${role} is not set — yadflow's is used`); continue; }
88
+ if (!isColor(v)) { problems.push(`colors.${scheme}.${role} is not a colour yadflow can use (hex, rgb(), hsl(), oklch() or oklab())`); continue; }
89
+ out[role] = v.trim();
90
+ }
91
+ for (const k of Object.keys(c)) if (!ROLES.includes(k)) warnings.push(`colors.${scheme}.${k} is not a role yadflow uses (${ROLES.join(', ')})`);
92
+ colors[scheme] = out;
93
+ }
94
+ const files = (rel, kind, types, cap) => {
95
+ if (rel === null || rel === undefined) return null;
96
+ const full = brandPath(root, rel);
97
+ if (!full) { problems.push(`${kind} "${String(rel)}" is not a file inside the Product`); return null; }
98
+ const ext = path.extname(full).toLowerCase();
99
+ if (!Object.hasOwn(types, ext)) { problems.push(`${kind} "${rel}" is not one of ${Object.keys(types).join(', ')}`); return null; }
100
+ let size;
101
+ try { const st = fs.statSync(full); if (!st.isFile()) throw new Error('not a file'); size = st.size; } catch { problems.push(`${kind} "${rel}" cannot be read`); return null; }
102
+ if (cap && size > cap) { problems.push(`${kind} "${rel}" is ${Math.ceil(size / 1024)} KB — at most ${cap / 1024} KB`); return null; }
103
+ return rel;
104
+ };
105
+ const logo = files(rec.logo, 'logo', IMAGE_TYPES, IMAGE_CAP);
106
+ const mark = files(rec.mark, 'mark', IMAGE_TYPES, IMAGE_CAP);
107
+ const fonts = {};
108
+ let fontBytes = 0;
109
+ for (const slot of FONT_SLOTS) {
110
+ const f = rec.fonts?.[slot];
111
+ if (f === null || f === undefined) { fonts[slot] = null; continue; }
112
+ if (!isObj(f) || typeof f.family !== 'string' || !FAMILY_RE.test(f.family.trim())) { problems.push(`fonts.${slot}.family must be a font name (letters, digits, spaces, - and _)`); fonts[slot] = null; continue; }
113
+ const list = [];
114
+ for (const rel of Array.isArray(f.files) ? f.files : []) {
115
+ const ok = files(rel, `fonts.${slot} file`, FONT_TYPES, 0);
116
+ if (!ok) continue;
117
+ fontBytes += fs.statSync(brandPath(root, ok)).size;
118
+ list.push(ok);
119
+ }
120
+ fonts[slot] = { family: f.family.trim(), files: list };
121
+ }
122
+ if (fontBytes > FONT_CAP) { warnings.push(`the font files add up to ${Math.ceil(fontBytes / 1024)} KB — over ${FONT_CAP / 1024} KB they are not embedded in self-contained pages; the font names are still used`); }
123
+ let status = null;
124
+ if (rec.status !== null && rec.status !== undefined) {
125
+ if (!isObj(rec.status)) problems.push('"status" must be an object of status colours, or null');
126
+ else {
127
+ status = {};
128
+ for (const k of STATUS_KEYS) {
129
+ const v = rec.status[k];
130
+ if (v === undefined) continue;
131
+ if (!isColor(v)) problems.push(`status.${k} is not a colour yadflow can use`);
132
+ else status[k] = v.trim();
133
+ }
134
+ }
135
+ }
136
+ const brand = { version: BRAND_VERSION, name, source: typeof rec.source === 'string' ? rec.source : null, sourceHash: typeof rec.sourceHash === 'string' ? rec.sourceHash : null,
137
+ logo, mark, colors, fonts, status, fontBytes };
138
+ return { brand, problems, warnings };
139
+ }
140
+
141
+ // The brand every page wears. → { brand (complete: every role set), origin: 'product' | 'yadflow', problems, warnings, file }
142
+ export function readBrand(root) {
143
+ const file = path.join(root, BRAND_FILE);
144
+ const fallback = (problems = [], warnings = []) => ({ brand: completeBrand(YADFLOW_BRAND), origin: 'yadflow', problems, warnings, file });
145
+ let rec;
146
+ try { rec = readJSONStrict(file, null); } catch (e) { return fallback([`${BRAND_FILE} cannot be read (${String(e.message).split('\n')[0]})`]); }
147
+ if (rec === null) return fallback();
148
+ const c = checkBrand(root, rec);
149
+ if (c.problems.length) return fallback(c.problems, c.warnings);
150
+ return { brand: completeBrand(c.brand), origin: 'product', problems: [], warnings: c.warnings, file };
151
+ }
152
+
153
+ // Every role set: a missing light role is yadflow's. A dark primary or accent the brand does not give (no dark
154
+ // scheme, or one without them) is its light one made lighter, or yadflow's when it cannot be made lighter, so
155
+ // it reads on a dark background; every other missing dark role is yadflow's neutral dark.
156
+ function completeBrand(b) {
157
+ const light = { ...YADFLOW_BRAND.colors.light, ...(b.colors?.light || {}) };
158
+ const ownDark = b.colors?.dark;
159
+ const derive = (role) => (b.colors?.light?.[role] && lighter(light[role])) || YADFLOW_BRAND.colors.dark[role];
160
+ const dark = { ...YADFLOW_BRAND.colors.dark, primary: derive('primary'), accent: derive('accent'), ...(ownDark || {}) };
161
+ // `derivedDark`: the brand gave no dark colours of its own, so its dark look is made from the light one.
162
+ return { ...b, colors: { light, dark, derivedDark: !ownDark || !Object.keys(ownDark).length }, fonts: b.fonts || { heading: null, body: null, mono: null } };
163
+ }
164
+
165
+ // ---- colour maths (for contrast, and the derived dark scheme) --------------------------------------
166
+
167
+ const clamp01 = (x) => Math.min(1, Math.max(0, x));
168
+ const toLinear = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
169
+ // A colour → linear sRGB [r, g, b] (0–1), or null when yadflow cannot read it (hsl, oklab: no contrast check).
170
+ export function linearRgb(value) {
171
+ const v = String(value).trim().toLowerCase();
172
+ let m = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(v);
173
+ if (m) {
174
+ let h = m[1];
175
+ if (h.length <= 4) h = [...h].map((ch) => ch + ch).join('');
176
+ return [0, 2, 4].map((i) => toLinear(parseInt(h.slice(i, i + 2), 16) / 255));
177
+ }
178
+ // Each channel read with its own unit; an alpha after `/` or a fourth value is left out. Anything else is
179
+ // not read (null), never guessed (review 1).
180
+ m = /^rgba?\(\s*([\d.]+)(%?)(?:\s*,\s*|\s+)([\d.]+)(%?)(?:\s*,\s*|\s+)([\d.]+)(%?)\s*(?:[,/]\s*[\d.]+%?\s*)?\)$/.exec(v);
181
+ if (m) return [[m[1], m[2]], [m[3], m[4]], [m[5], m[6]]].map(([x, pc]) => toLinear(clamp01(Number(x) / (pc ? 100 : 255))));
182
+ m = /^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)(%?)\s+([-\d.]+)(deg)?\s*(?:\/\s*[\d.]+%?\s*)?\)$/.exec(v);
183
+ if (m) {
184
+ // CSS: L 100% is 1; C 100% is 0.4.
185
+ const L = Number(m[1]) / (m[2] ? 100 : 1), C = m[4] ? (Number(m[3]) / 100) * 0.4 : Number(m[3]), h = (Number(m[5]) * Math.PI) / 180;
186
+ const a = C * Math.cos(h), b = C * Math.sin(h);
187
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
188
+ const mm = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
189
+ const s = (L - 0.0894841775 * a - 1.2914855480 * b) ** 3;
190
+ return [4.0767416621 * l - 3.3077115913 * mm + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * mm - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * mm + 1.7076147010 * s].map(clamp01);
191
+ }
192
+ return null;
193
+ }
194
+ const luminance = (rgb) => 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2];
195
+ export function contrast(a, b) {
196
+ const x = linearRgb(a), y = linearRgb(b);
197
+ if (!x || !y) return null;
198
+ const [hi, lo] = [luminance(x), luminance(y)].sort((p, q) => q - p);
199
+ return (hi + 0.05) / (lo + 0.05);
200
+ }
201
+ // A colour made lighter for a dark background: oklch() with its lightness raised; any other colour yadflow can
202
+ // read (hex, rgb()) → a lighter hex; one it cannot read → null, and yadflow's dark colour is used (reviews 1, 2).
203
+ export function lighter(value) {
204
+ const ok = /^oklch\(\s*([\d.]+)(%?)(\s+[\d.]+%?\s+[-\d.]+(?:deg)?\s*(?:\/\s*[\d.]+%?\s*)?)\)$/i.exec(String(value).trim());
205
+ if (ok) {
206
+ const L = Number(ok[1]) / (ok[2] ? 100 : 1);
207
+ return `oklch(${(L + (1 - L) * 0.5).toFixed(3)}${ok[3]})`;
208
+ }
209
+ const rgb = linearRgb(value);
210
+ if (!rgb) return null;
211
+ const toS = (c) => { const s = c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055; return Math.round(clamp01(s) * 255); };
212
+ const mixed = rgb.map((c) => c + (1 - c) * 0.35);
213
+ return `#${mixed.map((c) => toS(c).toString(16).padStart(2, '0')).join('')}`;
214
+ }
215
+
216
+ // Text that is hard to read. → [text]; a colour yadflow cannot read is skipped, never guessed. `links`: also
217
+ // `primary`, which the pages use as link text, so it needs 4.5:1 like text (review 2). `yad brand check` asks
218
+ // for it; `yad doctor` does not, so a brand colour chosen for buttons never warns on every run.
219
+ export function contrastProblems(brand, { links = false } = {}) {
220
+ const out = [];
221
+ const pairs = [['text', 4.5, 'text'], ['muted', 3, 'muted'], ...(links ? [['primary', 4.5, 'primary (links)']] : [])];
222
+ for (const scheme of ['light', 'dark']) {
223
+ const c = brand.colors[scheme];
224
+ for (const [role, min, label] of pairs) {
225
+ const r = contrast(c[role], c.bg);
226
+ if (r !== null && r < min) out.push(`${scheme}: ${label} on bg is ${r.toFixed(1)}:1 — under ${min}:1, hard to read`);
227
+ }
228
+ }
229
+ return out;
230
+ }
231
+
232
+ // ---- what a page needs ----------------------------------------------------------------------------
233
+
234
+ const dataUri = (mime, buf) => `data:${mime};base64,${buf.toString('base64')}`;
235
+ // The logo, the mark and the fonts as data: URIs (the files were checked by checkBrand).
236
+ export function brandAssets(root, brand, origin) {
237
+ const image = (rel) => {
238
+ const full = rel ? brandPath(root, rel) : null;
239
+ if (!full) return null;
240
+ const mime = IMAGE_TYPES[path.extname(full).toLowerCase()];
241
+ if (!mime) return null;
242
+ try { return dataUri(mime, fs.readFileSync(full)); } catch { return null; }
243
+ };
244
+ let mark = image(brand.mark) || image(brand.logo);
245
+ if (!mark && origin === 'yadflow') { try { mark = dataUri('image/svg+xml', fs.readFileSync(YADFLOW_MARK_FILE)); } catch { mark = null; } }
246
+ const fonts = [];
247
+ if ((brand.fontBytes || 0) <= FONT_CAP) {
248
+ for (const slot of FONT_SLOTS) {
249
+ const f = brand.fonts?.[slot];
250
+ for (const rel of f?.files || []) {
251
+ const full = brandPath(root, rel);
252
+ if (!full) continue;
253
+ const type = FONT_TYPES[path.extname(full).toLowerCase()];
254
+ if (!type) continue; // a brand never breaks a page
255
+ const [mime, format] = type;
256
+ try { fonts.push({ family: f.family, src: dataUri(mime, fs.readFileSync(full)), format }); } catch { /* left out */ }
257
+ }
258
+ }
259
+ }
260
+ return { mark, fonts };
261
+ }
262
+
263
+ const familyStack = (f, system) => (f ? `"${f.family}", ${system}` : system);
264
+ // The brand as CSS: @font-face for embedded fonts, then every role as a variable, light and dark both named
265
+ // (`--brand-bg`, `--brand-dark-bg`) so a page that is always dark (the map) can take the dark ones directly.
266
+ export function brandCss(brand, assets) {
267
+ const lines = [];
268
+ for (const f of assets.fonts) lines.push(`@font-face{font-family:"${f.family}";src:url(${f.src}) format("${f.format}");font-display:swap}`);
269
+ const vars = [];
270
+ for (const role of ROLES) vars.push(`--brand-${role}:${brand.colors.light[role]}`, `--brand-dark-${role}:${brand.colors.dark[role]}`);
271
+ vars.push(`--brand-font-heading:${familyStack(brand.fonts?.heading || brand.fonts?.body, SYSTEM_SANS)}`);
272
+ vars.push(`--brand-font-body:${familyStack(brand.fonts?.body || brand.fonts?.heading, SYSTEM_SANS)}`);
273
+ vars.push(`--brand-font-mono:${familyStack(brand.fonts?.mono, SYSTEM_MONO)}`);
274
+ for (const k of STATUS_KEYS) if (brand.status?.[k]) vars.push(`--brand-status-${k}:${brand.status[k]}`);
275
+ if (assets.mark && DATA_IMAGE_RE.test(assets.mark)) vars.push(`--brand-mark:url("${assets.mark}")`);
276
+ lines.push(`:root{${vars.join(';')}}`);
277
+ return lines.join('\n');
278
+ }
279
+
280
+ // A data: image URI of the kinds brandAssets makes — nothing else is ever written into CSS.
281
+ export const DATA_IMAGE_RE = /^data:image\/(?:svg\+xml|png|webp|jpeg);base64,[A-Za-z0-9+/=]+$/;
282
+
283
+ // Where each page shows its brand mark: before its title, drawn from `--brand-mark` (CSS only — no page script
284
+ // changes, and the strict pages already allow `img-src data:`).
285
+ export const PAGE_TITLES = Object.freeze({ map: '.brand h1', brain: '.brand h1', live: 'header.bar .mark', catalog: 'body > main > h1', usage: 'body h1', standup: 'body h1', issues: 'body h1' });
286
+ const markRule = (sel) => `${sel}::before{content:"";display:inline-block;width:1.15em;height:1.15em;margin-right:.4em;vertical-align:-0.18em;background:var(--brand-mark) center/contain no-repeat}`;
287
+
288
+ // How each page's own variables take the brand. Status, layer and priority colours keep their meaning: only
289
+ // the page around them changes (the user's decision). A page with a light and a dark look maps both.
290
+ const both = (light, dark) => `:root{${light}}\n@media (prefers-color-scheme: dark){:root{${dark}}}`;
291
+ const map = (pairs, scheme) => pairs.map(([v, role]) => `${v}:var(--brand-${scheme === 'dark' ? 'dark-' : ''}${role})`).join(';');
292
+ export const PAGE_MAPS = Object.freeze({
293
+ // The progress map is always dark: the dark roles, a glass of the surface, the status colours only if set.
294
+ map: `:root{${map([['--bg', 'bg'], ['--ink', 'text'], ['--muted', 'muted']], 'dark')};--ink-2:color-mix(in srgb, var(--brand-dark-text) 60%, var(--brand-dark-muted));--hair:color-mix(in srgb, var(--brand-dark-border) 70%, transparent);--glass:color-mix(in srgb, var(--brand-dark-surface) 80%, transparent)}
295
+ :root{--live:var(--brand-status-live, #3987e5);--merged:var(--brand-status-merged, #d55181);--active:var(--brand-status-active, #c98500);--planned:var(--brand-status-planned, #93a0bf);--idle:var(--brand-status-idle, #5b6680)}
296
+ html,body{font-family:var(--brand-font-body)}.brand h1{font-family:var(--brand-font-heading)}.linkish,#panel a{color:var(--brand-dark-primary)}`,
297
+ brain: both(map([['--bg', 'bg'], ['--panel', 'surface'], ['--text', 'text'], ['--muted', 'muted'], ['--line', 'border'], ['--accent', 'primary']], 'light'),
298
+ map([['--bg', 'bg'], ['--panel', 'surface'], ['--text', 'text'], ['--muted', 'muted'], ['--line', 'border'], ['--accent', 'primary']], 'dark'))
299
+ + '\nbody{font-family:var(--brand-font-body)}h1,h2,h3{font-family:var(--brand-font-heading)}',
300
+ live: `:root{--sky-0:var(--brand-dark-bg);--sky-1:var(--brand-dark-surface);--ink:var(--brand-dark-text);--ink-2:color-mix(in srgb, var(--brand-dark-text) 60%, var(--brand-dark-muted));--ink-3:var(--brand-dark-muted);--rule:color-mix(in srgb, var(--brand-dark-border) 60%, transparent);--glass:color-mix(in srgb, var(--brand-dark-surface) 66%, transparent);--sans:var(--brand-font-body);--mono:var(--brand-font-mono)}`,
301
+ catalog: both(map([['--bg', 'bg'], ['--ink', 'text'], ['--muted', 'muted'], ['--line', 'border'], ['--tag', 'surface'], ['--link', 'primary']], 'light'),
302
+ map([['--bg', 'bg'], ['--ink', 'text'], ['--muted', 'muted'], ['--line', 'border'], ['--tag', 'surface'], ['--link', 'primary']], 'dark'))
303
+ + '\nbody{font-family:var(--brand-font-body)}h1,h2{font-family:var(--brand-font-heading)}',
304
+ // usage was dark only; it now follows the brand's light and dark looks like the other reports.
305
+ usage: both(map([['--bg', 'bg'], ['--fg', 'text'], ['--dim', 'muted'], ['--card', 'surface'], ['--line', 'border'], ['--accent', 'primary']], 'light'),
306
+ map([['--bg', 'bg'], ['--fg', 'text'], ['--dim', 'muted'], ['--card', 'surface'], ['--line', 'border'], ['--accent', 'primary']], 'dark'))
307
+ + '\nbody{font-family:var(--brand-font-body)}h1,h2{font-family:var(--brand-font-heading)}',
308
+ standup: both(map([['--bg', 'bg'], ['--fg', 'text'], ['--dim', 'muted'], ['--card', 'surface'], ['--line', 'border']], 'light'),
309
+ map([['--bg', 'bg'], ['--fg', 'text'], ['--dim', 'muted'], ['--card', 'surface'], ['--line', 'border']], 'dark'))
310
+ + '\nbody{font-family:var(--brand-font-body)}h1,h2{font-family:var(--brand-font-heading)}',
311
+ issues: both(map([['--bg', 'bg'], ['--fg', 'text'], ['--dim', 'muted'], ['--card', 'surface'], ['--line', 'border'], ['--link', 'primary']], 'light'),
312
+ map([['--bg', 'bg'], ['--fg', 'text'], ['--dim', 'muted'], ['--card', 'surface'], ['--line', 'border'], ['--link', 'primary']], 'dark'))
313
+ + '\nbody{font-family:var(--brand-font-body)}h1,h2{font-family:var(--brand-font-heading)}',
314
+ });
315
+
316
+ // Everything one page needs. → { css, name, origin, problems }
317
+ // css the brand block, the page's own mapping and its mark rule — added AFTER the page's CSS, so it wins.
318
+ export function brandForPage(root, page) {
319
+ const r = readBrand(root);
320
+ const assets = brandAssets(root, r.brand, r.origin);
321
+ const mark = assets.mark && DATA_IMAGE_RE.test(assets.mark) && PAGE_TITLES[page] ? `\n${markRule(PAGE_TITLES[page])}` : '';
322
+ const css = `${brandCss(r.brand, assets)}\n${PAGE_MAPS[page] || ''}${mark}`;
323
+ return { css, name: r.brand.name, origin: r.origin, problems: r.problems };
324
+ }
325
+
326
+ // The fingerprint of the design system brand.json was made from, for `yad brand check`.
327
+ export const sourceFingerprint = (text) => `sha256:${createHash('sha256').update(text, 'utf8').digest('hex')}`;
package/cli/ci-check.mjs CHANGED
@@ -22,7 +22,7 @@ import fs from 'node:fs';
22
22
  import path from 'node:path';
23
23
  import { c, log, ok, warn, fail, info, hand, run, exists, readJSON, isPlainObject, forTerminal, asArg } from './lib.mjs';
24
24
  import { REQUIRED_CHECKS, REPO_WIRING, PRODUCT_WIRING, PROJECT_FILES, PRODUCT_LINK, productConfigPath, isVerifiedLedger } from './manifest.mjs';
25
- import { readCiSettings, protectionLine } from './protection.mjs';
25
+ import { readCiSettings, protectionLine, configuredGitUrl } from './protection.mjs';
26
26
  import { repoActions, productActions } from './plan.mjs';
27
27
  import { judgeRepo, runnable } from './workspace.mjs';
28
28
  import { isSolo } from './gate.mjs';
@@ -474,7 +474,7 @@ export function ciTargets(root, { repo = null } = {}) {
474
474
  const onDisk = typeof entry.path === 'string' && entry.path && runnable(judgeRepo(root, entry));
475
475
  return {
476
476
  name: entry.name, kind: 'code', entry, ciRuns: true,
477
- target: { platform: entry.platform || null, gitUrl: (typeof entry.git_url === 'string' && entry.git_url) || (onDisk ? origin(path.resolve(root, entry.path)) : null), branch: branchOf(entry) },
477
+ target: { platform: entry.platform || null, gitUrl: configuredGitUrl(entry.git_url, () => (onDisk ? origin(path.resolve(root, entry.path)) : null)) || null, branch: branchOf(entry) },
478
478
  };
479
479
  };
480
480
  if (repo !== null) {
@@ -486,7 +486,7 @@ export function ciTargets(root, { repo = null } = {}) {
486
486
  name: 'Product', kind: 'product', wired, ciRuns: wired,
487
487
  // The verified ledger asked for, by its name or its older spellings, whether or not a platform is set.
488
488
  wantsVerified: config.ledger === 'verified' || (typeof config.ledger !== 'string' && (config.bridge_enabled === true || config.bridge === true)),
489
- target: { platform: config.platform || null, gitUrl: config.git_url || origin(root), branch: branchOf(config) },
489
+ target: { platform: config.platform || null, gitUrl: configuredGitUrl(config.git_url, () => origin(root)) || null, branch: branchOf(config) },
490
490
  };
491
491
  return { targets: [product, ...entries.map(code)] };
492
492
  }