create-pmos 0.680.0 → 0.681.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.
- package/package.json +9 -3
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +8 -2
- package/workspace/guide/cli.md +9 -5
- package/workspace/lib/design-cli.js +75 -23
- package/workspace/lib/design-drift.js +274 -13
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/test-lists/design-drift-guard.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.681.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-22T07:
|
|
37
|
+
"v": "0.681.0",
|
|
38
|
+
"at": "2026-11-22T07:52:20.147Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
41
|
{
|
|
@@ -43,6 +43,12 @@
|
|
|
43
43
|
"t": "Read a document as a CFO, an engineer and a sceptic (A110)",
|
|
44
44
|
"s": "Read a document as a CFO, an engineer and a sceptic (A110)",
|
|
45
45
|
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1487,
|
|
49
|
+
"t": "Design drift guard counts token bypasses, with a ratchet",
|
|
50
|
+
"s": "Design drift guard counts token bypasses, with a ratchet",
|
|
51
|
+
"k": "new"
|
|
46
52
|
}
|
|
47
53
|
]
|
|
48
54
|
},
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T07:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T07:52:17Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T07:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T07:52:17Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T07:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T07:52:17Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-22T07:
|
|
3
|
+
"v": "0.681.0",
|
|
4
|
+
"at": "2026-11-22T07:52:20.147Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
7
|
{
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"t": "Read a document as a CFO, an engineer and a sceptic (A110)",
|
|
10
10
|
"s": "Read a document as a CFO, an engineer and a sceptic (A110)",
|
|
11
11
|
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1487,
|
|
15
|
+
"t": "Design drift guard counts token bypasses, with a ratchet",
|
|
16
|
+
"s": "Design drift guard counts token bypasses, with a ratchet",
|
|
17
|
+
"k": "new"
|
|
12
18
|
}
|
|
13
19
|
]
|
|
14
20
|
},
|
package/workspace/guide/cli.md
CHANGED
|
@@ -320,12 +320,16 @@ Only PMOS's impact run uses these. The server pins each run to your ledger. Outs
|
|
|
320
320
|
- `pmos drift replay`: the replay of the last four weeks of this repository.
|
|
321
321
|
- `pmos drift status`: the last weekly result and the replays on record.
|
|
322
322
|
|
|
323
|
-
### pmos design drift:
|
|
323
|
+
### pmos design drift: places that do not read a design token
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
-
|
|
328
|
-
-
|
|
325
|
+
The aim: change one token and every page follows. Each place this command counts is a place a token change does not reach.
|
|
326
|
+
|
|
327
|
+
- `pmos design drift`: counts every literal colour, text size, corner, spacing and shadow outside the system sheets, every token defined outside the system, every inline style value, and every class the system does not define. It says how many have a token with the same value. It reads git only.
|
|
328
|
+
- `--base <ref>` compares with an earlier commit. For each file whose count of a kind rose, it lists the added lines and the token each one should read. `--base week` uses the last commit a week earlier.
|
|
329
|
+
- `--gate` exits 1 when a count rose against `--base`. `--github` prints each new place as a GitHub warning on its line. CI runs it on every pull request, as a warning only.
|
|
330
|
+
- `--weeks <n>` adds the total at the end of each of the last n weeks. `--write` writes the report to `planning/reports/`.
|
|
331
|
+
- `--pages` shows the older measure instead: for each page, the share of its classes that the system defines and its own CSS rules.
|
|
332
|
+
- A product sets the files to count and its system sheets in `design-drift.json` in its design-system folder, for example `{ "scan": ["web/**/*.css"], "systemSheets": ["ds.css"] }`.
|
|
329
333
|
|
|
330
334
|
## Initiatives and the Board
|
|
331
335
|
|
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* design-cli.js — `pmos design drift`:
|
|
3
|
-
* design-drift-guard
|
|
2
|
+
/* design-cli.js — `pmos design drift`: every place this product's styles and scripts do not read a design token, and a ratchet so a pull
|
|
3
|
+
* request may lower that count but never raise it (initiative design-token-ratchet, the rescope of design-drift-guard). lib/design-drift.js
|
|
4
|
+
* does the counting. Wawan, 2026-11-22: a design system is reusable templates; changing one token must change every page, with no page rewritten.
|
|
4
5
|
*
|
|
5
|
-
* pmos design drift [--ref <ref>] [--base <ref>|week] [--weeks <n>] [--json] [--write] [--gate]
|
|
6
|
-
* --ref the commit to
|
|
7
|
-
* --base compare with this commit
|
|
8
|
-
*
|
|
9
|
-
* --
|
|
10
|
-
* --
|
|
11
|
-
* --
|
|
6
|
+
* pmos design drift [--ref <ref>] [--base <ref>|week] [--weeks <n>] [--json] [--write] [--gate] [--github] [--pages]
|
|
7
|
+
* --ref the commit to count (default HEAD). WORKTREE counts the files on disk, saved or not.
|
|
8
|
+
* --base compare with this commit: each file whose count of a kind rose, with the added lines and the token each should read.
|
|
9
|
+
* `week` is the last commit a week before --ref.
|
|
10
|
+
* --weeks add the total at the end of each of the last n weeks (1 to 12)
|
|
11
|
+
* --json print the result as JSON
|
|
12
|
+
* --write write the report to planning/reports/ (the only write this command makes)
|
|
13
|
+
* --gate exit 1 when a count rose against --base
|
|
14
|
+
* --github print each new bypass as a GitHub warning on its file and line (the CI step uses it)
|
|
15
|
+
* --pages the older view instead: each page's share of system classes and its own CSS (a measure only)
|
|
12
16
|
*
|
|
13
|
-
* Run it in the product's repository. It reads git only and changes nothing else. Exit codes: 0 done, 1 a
|
|
14
|
-
*
|
|
17
|
+
* Run it in the product's repository. It reads git only and changes nothing else. Exit codes: 0 done, 1 a count rose (only with --gate) or
|
|
18
|
+
* the refs cannot be read, 2 usage. */
|
|
15
19
|
const fs = require('fs');
|
|
16
20
|
const path = require('path');
|
|
17
21
|
const D = require('./design-drift.js');
|
|
18
22
|
|
|
19
23
|
const COMMANDS = { design: ['drift'] };
|
|
20
24
|
const USAGE = [
|
|
21
|
-
'usage: pmos design drift —
|
|
22
|
-
' pmos design drift [--ref <ref>] [--base <ref>|week] [--weeks <n>] [--json] [--write] [--gate]',
|
|
23
|
-
' --ref <ref> the commit to
|
|
24
|
-
' --base <ref> compare with this commit; "week" is the last commit a week earlier',
|
|
25
|
-
' --weeks <n> the
|
|
26
|
-
' --write write the report to planning/reports/
|
|
27
|
-
' --gate exit 1 when a
|
|
28
|
-
'
|
|
25
|
+
'usage: pmos design drift — every place your styles and scripts do not read a design token, and which ones a change adds',
|
|
26
|
+
' pmos design drift [--ref <ref>] [--base <ref>|week] [--weeks <n>] [--json] [--write] [--gate] [--github] [--pages]',
|
|
27
|
+
' --ref <ref> the commit to count (default HEAD; WORKTREE reads the files on disk)',
|
|
28
|
+
' --base <ref> compare with this commit and name each added line that bypasses a token; "week" is the last commit a week earlier',
|
|
29
|
+
' --weeks <n> the total at the end of each of the last n weeks (1 to 12)',
|
|
30
|
+
' --write write the report to planning/reports/',
|
|
31
|
+
' --gate exit 1 when a count rose against --base',
|
|
32
|
+
' --github print each new bypass as a GitHub warning on its line',
|
|
33
|
+
' --pages each page\'s share of system classes instead (a measure only)',
|
|
34
|
+
'It reads git only. A product sets its files and system sheets in design-drift.json in its design-system folder.',
|
|
29
35
|
];
|
|
30
|
-
const FLAGS = new Set(['ref', 'base', 'weeks', 'json', 'write', 'gate', 'repo']);
|
|
31
|
-
const BOOL = new Set(['json', 'write', 'gate']);
|
|
36
|
+
const FLAGS = new Set(['ref', 'base', 'weeks', 'json', 'write', 'gate', 'repo', 'github', 'pages']);
|
|
37
|
+
const BOOL = new Set(['json', 'write', 'gate', 'github', 'pages']);
|
|
32
38
|
|
|
33
39
|
function parse(args) {
|
|
34
40
|
const pos = [], flags = {};
|
|
@@ -59,7 +65,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
|
|
|
59
65
|
for (const k of ['ref', 'base', 'weeks', 'repo']) if (k in flags && !flags[k]) { say(`✗ --${k} needs a value`); return 2; }
|
|
60
66
|
const weeks = flags.weeks === undefined ? 0 : Number(flags.weeks);
|
|
61
67
|
if (!Number.isInteger(weeks) || weeks < 0 || weeks > 12) { say('✗ --weeks is a whole number from 1 to 12'); return 2; }
|
|
62
|
-
if (flags.gate && !flags.base) { say('✗ --gate needs --base: it fails only a
|
|
68
|
+
if (flags.gate && !flags.base) { say('✗ --gate needs --base: it fails only a count that rose against an earlier commit'); return 2; }
|
|
69
|
+
if (flags.github && !flags.base) { say('✗ --github needs --base: it marks only the lines a change added'); return 2; }
|
|
63
70
|
|
|
64
71
|
const repo = repoRoot(flags.repo ? path.resolve(cwd, flags.repo) : cwd);
|
|
65
72
|
if (!repo) { say('✗ this is not a git repository. Run pmos design drift in your product\'s repository.'); return 1; }
|
|
@@ -75,6 +82,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
|
|
|
75
82
|
}
|
|
76
83
|
if (base && !D.gitOut(repo, ['rev-parse', '--verify', '--quiet', base + '^{commit}'])) { say(`✗ no commit "${base}" in this repository`); return 1; }
|
|
77
84
|
|
|
85
|
+
if (!flags.pages) return tokens({ repo, ref, base, worktree, weeks, flags, say, now });
|
|
86
|
+
|
|
78
87
|
const head = D.measure(repo, ref);
|
|
79
88
|
if (head.config.error) { say('✗ ' + head.config.error); return 1; }
|
|
80
89
|
const before = base ? D.measure(repo, base) : null;
|
|
@@ -99,7 +108,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
|
|
|
99
108
|
}
|
|
100
109
|
say(`shared code: ${head.shared.files.length} files · ${pct(head.shared.share)} from the system · ${head.shared.ownRules} own CSS rules`);
|
|
101
110
|
const q = D.queue(rows);
|
|
102
|
-
if (q.length) say('
|
|
111
|
+
if (q.length) say('Lowest system share: ' + q.map((r) => `${short(r.page)} ${pct(r.share)}`).join(', '));
|
|
103
112
|
}
|
|
104
113
|
if (trend) say('Mean share by week: ' + trend.map((t) => `${t.week} ${t.share == null ? '–' : pct(t.share)}`).join(' · '));
|
|
105
114
|
}
|
|
@@ -112,4 +121,47 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
|
|
|
112
121
|
return flags.gate && drifting.length ? 1 : 0;
|
|
113
122
|
}
|
|
114
123
|
|
|
124
|
+
const n = (x) => Number(x).toLocaleString('en-US');
|
|
125
|
+
|
|
126
|
+
/** The default view: token bypasses, and with --base the ratchet. */
|
|
127
|
+
function tokens({ repo, ref, base, worktree, weeks, flags, say, now }) {
|
|
128
|
+
const head = D.bypasses(repo, ref);
|
|
129
|
+
if (head.config.error) { say('✗ ' + head.config.error); return 1; }
|
|
130
|
+
const before = base ? D.bypasses(repo, base) : null;
|
|
131
|
+
const findings = before ? D.ratchet(repo, before, head) : null;
|
|
132
|
+
const trend = weeks ? D.tokenTrend(repo, worktree ? 'HEAD' : ref, weeks, { now: worktree ? now : Date.parse(D.gitOut(repo, ['show', '-s', '--format=%cI', ref]).trim()) }) : null;
|
|
133
|
+
const date = new Date(now).toISOString().slice(0, 10);
|
|
134
|
+
const cmd = `pmos design drift --ref ${ref}${base ? ` --base ${base}` : ''}${weeks ? ` --weeks ${weeks}` : ''} --write`;
|
|
135
|
+
const bypass = head.total - head.totals.pageClass;
|
|
136
|
+
if (flags.json) {
|
|
137
|
+
say(JSON.stringify({ ok: true, ref, commit: head.commit, base, baseCommit: before && before.commit, config: head.config.from, tokens: head.tokens, totals: head.totals, total: head.total, swaps: head.swaps,
|
|
138
|
+
files: head.files.map((f) => ({ file: f.file, counts: f.counts })), findings: findings && findings.map((g) => ({ ...g, lines: g.lines.map((x) => ({ ...x, say: D.findingSay(x) })) })), trend }));
|
|
139
|
+
} else if (!flags.github) {
|
|
140
|
+
say(`${n(bypass)} places do not read a design token, ${n(head.swaps)} of them with a same-value token; ${n(head.totals.pageClass)} page-only classes (${head.commit}; config: ${head.config.from})`);
|
|
141
|
+
say(D.KINDS.filter((k) => k !== 'pageClass').map((k) => `${D.KIND_LABEL[k]} ${n(head.totals[k])}`).join(' · '));
|
|
142
|
+
if (findings) {
|
|
143
|
+
say(findings.length ? `${findings.length} count${findings.length === 1 ? '' : 's'} rose against ${before.commit}:` : `No count rose against ${before.commit}.`);
|
|
144
|
+
for (const g of findings) {
|
|
145
|
+
say(` ${g.file} · ${D.KIND_LABEL[g.kind]} ${g.before} → ${g.after}`);
|
|
146
|
+
for (const x of g.lines.slice(0, 10)) say(` line ${x.line}: ${D.findingSay(x)}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (trend) say('By week: ' + trend.map((t) => `${t.week} ${t.total == null ? '–' : n(t.total)}`).join(' · '));
|
|
150
|
+
}
|
|
151
|
+
if (flags.github && findings) {
|
|
152
|
+
for (const g of findings) {
|
|
153
|
+
if (!g.lines.length) { say(`::warning file=${g.file},title=Design tokens::${D.KIND_LABEL[g.kind]} count ${g.before} → ${g.after}`); continue; }
|
|
154
|
+
for (const x of g.lines) say(`::warning file=${g.file},line=${x.line},title=Design tokens::${D.findingSay(x).replace(/[\r\n%]/g, ' ')}`);
|
|
155
|
+
}
|
|
156
|
+
if (!findings.length) say(`No new token bypasses against ${before.commit}.`);
|
|
157
|
+
}
|
|
158
|
+
if (flags.write) {
|
|
159
|
+
const file = path.join(repo, 'planning', 'reports', `design-drift-${date}-tokens.md`);
|
|
160
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
161
|
+
fs.writeFileSync(file, D.tokensMd({ date, ref, now: head, base, baseCommit: before && before.commit, findings, trend, cmd }));
|
|
162
|
+
if (!flags.json && !flags.github) say('Report: ' + path.relative(repo, file));
|
|
163
|
+
}
|
|
164
|
+
return flags.gate && findings && findings.length ? 1 : 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
115
167
|
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
* out of each page, so every page's number is about that page. Two pages built from one script read the same.
|
|
17
17
|
*
|
|
18
18
|
* COMPARE two commits, per page:
|
|
19
|
-
* drift own rules grew, or the share fell by more than half a point. (More restyled parts is shown, not failed: a page
|
|
19
|
+
* drift own rules grew, or the share fell by more than half a point. (More restyled parts is shown, not failed: a page moved
|
|
20
20
|
* from the parts often adds a few layout rules around them.)
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* moved the share rose 10 points or more and own rules shrank 20% or more
|
|
22
|
+
* partly moved changed, but not enough to count as moved
|
|
23
23
|
* unchanged the same numbers
|
|
24
24
|
* new · gone the page exists on one side only
|
|
25
25
|
*
|
|
@@ -43,6 +43,10 @@ const DEFAULTS = Object.freeze({
|
|
|
43
43
|
systemSheets: ['brand.css', 'charts.css', 'komorebi.css', 'documents.css', 'slides.css'],
|
|
44
44
|
// the old shared shell and the bridge from its tokens: loaded by many pages, owned by none
|
|
45
45
|
shellSheets: ['cozy.css', 'components.css', 'ds-bridge.css'],
|
|
46
|
+
// the token-bypass count (design-token-ratchet): every stylesheet, script and page here, except the system's own files and vendor code
|
|
47
|
+
scan: ['workspace/public/**/*.css', 'workspace/public/**/*.js', 'workspace/public/**/*.html'],
|
|
48
|
+
ignore: ['workspace/public/vendor/**'],
|
|
49
|
+
systemScripts: ['komorebi.js'],
|
|
46
50
|
});
|
|
47
51
|
const CONFIG_PLACES = ['pmos/design-system/design-drift.json', 'design-system/design-drift.json', 'workspace/design-system/design-drift.json'];
|
|
48
52
|
const REBUILT_SHARE = 0.10;
|
|
@@ -301,9 +305,9 @@ function compare(base, head) {
|
|
|
301
305
|
let status;
|
|
302
306
|
if (!b) status = 'new';
|
|
303
307
|
else if (h.ownRules > b.ownRules || h.share < b.share - SHARE_SLACK) status = 'drift';
|
|
304
|
-
else if (h.share - b.share >= REBUILT_SHARE && h.ownRules <= b.ownRules * REBUILT_SHRINK) status = '
|
|
308
|
+
else if (h.share - b.share >= REBUILT_SHARE && h.ownRules <= b.ownRules * REBUILT_SHRINK) status = 'moved';
|
|
305
309
|
else if (h.ownRules === b.ownRules && h.classes === b.classes && h.system === b.system && h.restyled === b.restyled) status = 'unchanged';
|
|
306
|
-
else status = '
|
|
310
|
+
else status = 'partly moved';
|
|
307
311
|
const why = [];
|
|
308
312
|
if (b && status === 'drift') {
|
|
309
313
|
if (h.ownRules > b.ownRules) why.push(`own CSS +${h.ownRules - b.ownRules} rules`);
|
|
@@ -315,7 +319,7 @@ function compare(base, head) {
|
|
|
315
319
|
return out;
|
|
316
320
|
}
|
|
317
321
|
|
|
318
|
-
/** The pages
|
|
322
|
+
/** The pages with the lowest system share first, then the most own CSS. Pages with almost no markup are left out. */
|
|
319
323
|
function queue(pages, n = 5) {
|
|
320
324
|
return pages.filter((r) => r.classes >= 20 && r.status !== 'gone').sort((a, b) => a.share - b.share || b.ownRules - a.ownRules).slice(0, n);
|
|
321
325
|
}
|
|
@@ -344,7 +348,7 @@ function summary(rows, { compared = true } = {}) {
|
|
|
344
348
|
if (!rows.length) return 'No pages found. Set "pages" in design-drift.json in your design-system folder.';
|
|
345
349
|
if (!compared) return `${rows.length} pages · mean system share ${pct(meanShare(rows))}%.`;
|
|
346
350
|
const n = (s) => rows.filter((r) => r.status === s).length;
|
|
347
|
-
const parts = [`${n('drift')} drifting`, `${n('
|
|
351
|
+
const parts = [`${n('drift')} drifting`, `${n('moved')} moved`, `${n('partly moved')} partly moved`, `${n('unchanged')} unchanged`];
|
|
348
352
|
if (n('new')) parts.push(`${n('new')} new`);
|
|
349
353
|
if (n('gone')) parts.push(`${n('gone')} gone`);
|
|
350
354
|
return `${rows.length} pages: ${parts.join(', ')}.`;
|
|
@@ -376,8 +380,8 @@ function reportMd(view) {
|
|
|
376
380
|
}
|
|
377
381
|
L.push('');
|
|
378
382
|
const q = queue(rows);
|
|
379
|
-
L.push('##
|
|
380
|
-
L.push(q.length ? '
|
|
383
|
+
L.push('## Lowest system share', '');
|
|
384
|
+
L.push(q.length ? 'A measure, not a work list: a page moves to the system by reading its tokens and blocks, never by being redrawn.' : 'No page has enough markup to rank.', '');
|
|
381
385
|
q.forEach((r, i) => L.push(`${i + 1}. **${name(r.page)}**: ${pct(r.share)}% from the system, ${r.ownRules} own CSS rules${r.parts.length ? `; restyles ${r.parts.map((p) => `\`${p.part}\` (${p.rules})`).join(', ')}` : ''}.`));
|
|
382
386
|
L.push('');
|
|
383
387
|
if (view.shared && view.shared.files && view.shared.files.length) {
|
|
@@ -392,15 +396,272 @@ function reportMd(view) {
|
|
|
392
396
|
}
|
|
393
397
|
L.push('## How to read it', '',
|
|
394
398
|
'- **drift**: own CSS grew, or the system share fell.',
|
|
395
|
-
'- **
|
|
396
|
-
'- **
|
|
397
|
-
'- The numbers count source, not the rendered page, so they differ from a pixel audit. A page can raise its share by adding system classes without deleting its own CSS; that is why "
|
|
399
|
+
'- **moved**: the system share rose 10 points or more and own CSS shrank 20% or more.',
|
|
400
|
+
'- **partly moved**: the page changed, but not enough to count as moved (for example, system classes added while its own CSS stayed).',
|
|
401
|
+
'- The numbers count source, not the rendered page, so they differ from a pixel audit. A page can raise its share by adding system classes without deleting its own CSS; that is why "moved" also needs its own CSS to shrink.', '');
|
|
398
402
|
return L.join('\n');
|
|
399
403
|
}
|
|
400
|
-
function order(s) { return ['drift', '
|
|
404
|
+
function order(s) { return ['drift', 'partly moved', 'new', 'moved', 'unchanged', 'gone'].indexOf(s); }
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
// ── token bypasses (initiative design-token-ratchet) ────────────────────────────────────────────────────────────────────────────────
|
|
408
|
+
// Wawan, 2026-11-22: a design system is reusable templates; changing one token must change every page without rewriting a page. So the
|
|
409
|
+
// guard counts every place that does not read a token, and a pull request may lower that count but never raise it.
|
|
410
|
+
|
|
411
|
+
const KINDS = ['colour', 'size', 'corner', 'spacing', 'shadow', 'tokenDef', 'inline', 'pageClass'];
|
|
412
|
+
const KIND_LABEL = { colour: 'literal colour', size: 'literal text size', corner: 'literal corner', spacing: 'literal spacing', shadow: 'literal shadow',
|
|
413
|
+
tokenDef: 'token defined outside the system', inline: 'inline style value', pageClass: 'page-only class' };
|
|
414
|
+
const COLOUR = /#[0-9a-fA-F]{3,8}\b|\b(?:rgba?|hsla?)\([^()]*\)/g;
|
|
415
|
+
const LENGTH = /(?<![\w.#/-])(-?\d*\.?\d+)(px|rem|em)\b/g;
|
|
416
|
+
const RADIUS_PROP = /^border(?:-[a-z]+)*-radius$/;
|
|
417
|
+
const SPACE_PROP = /^(?:(?:padding|margin)(?:-(?:top|right|bottom|left|inline|block)(?:-(?:start|end))?)?|(?:row-|column-)?gap)$/;
|
|
418
|
+
|
|
419
|
+
/** Text with var(...) removed, nested parentheses included: a literal inside var(--token, fallback) reads the token. */
|
|
420
|
+
function dropVars(v) {
|
|
421
|
+
let out = String(v); let guard = 0;
|
|
422
|
+
while (/var\(/.test(out) && guard++ < 50) {
|
|
423
|
+
const i = out.indexOf('var(');
|
|
424
|
+
let depth = 0; let j = i + 3;
|
|
425
|
+
for (; j < out.length; j++) { if (out[j] === '(') depth++; else if (out[j] === ')' && --depth === 0) break; }
|
|
426
|
+
out = out.slice(0, i) + out.slice(j + 1);
|
|
427
|
+
}
|
|
428
|
+
return out;
|
|
429
|
+
}
|
|
430
|
+
const normColour = (c) => {
|
|
431
|
+
let x = String(c).toLowerCase().replace(/\s+/g, '');
|
|
432
|
+
if (/^#[0-9a-f]{3}$/.test(x)) x = '#' + x.slice(1).split('').map((d) => d + d).join('');
|
|
433
|
+
return x;
|
|
434
|
+
};
|
|
435
|
+
const normSpace = (v) => String(v).replace(/\s+/g, ' ').replace(/\s*,\s*/g, ', ').trim().toLowerCase();
|
|
436
|
+
const pxOf = (n, unit) => (unit === 'px' ? Number(n) : Number(n) * 16);
|
|
437
|
+
|
|
438
|
+
/** The system's tokens from its sheets: the first value of each custom property that is a literal (not an alias). */
|
|
439
|
+
function tokensOf(sheets) {
|
|
440
|
+
const t = new Map();
|
|
441
|
+
for (const css of sheets) {
|
|
442
|
+
for (const m of String(css).replace(/\/\*[\s\S]*?\*\//g, '').matchAll(/(--[a-zA-Z0-9-]+)\s*:\s*([^;{}]+)/g)) {
|
|
443
|
+
const name = m[1]; const val = m[2].trim();
|
|
444
|
+
if (!t.has(name) && !/var\(/.test(val)) t.set(name, val);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return t;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** The token a literal should read: { token, same } — same means the token has exactly this value (a swap, no change in the light theme). */
|
|
451
|
+
function tokenFor(kind, literal, tokens) {
|
|
452
|
+
const all = [...tokens.entries()];
|
|
453
|
+
if (kind === 'colour') {
|
|
454
|
+
const hit = all.find(([, v]) => normColour(v) === normColour(literal));
|
|
455
|
+
return hit ? { token: hit[0], same: true } : { token: null, same: false };
|
|
456
|
+
}
|
|
457
|
+
if (kind === 'shadow') {
|
|
458
|
+
const hit = all.find(([n, v]) => /shadow|lift|raise|glow/.test(n) && normSpace(v) === normSpace(literal));
|
|
459
|
+
return hit ? { token: hit[0], same: true } : { token: null, same: false };
|
|
460
|
+
}
|
|
461
|
+
const family = kind === 'corner' ? /^--radius-/ : kind === 'spacing' ? /^--space-/ : kind === 'size' ? /^--(?:type|fs|font-size)-/ : null;
|
|
462
|
+
if (!family) return { token: null, same: false };
|
|
463
|
+
const px = []; for (const m of String(literal).matchAll(LENGTH)) px.push(pxOf(m[1], m[2]));
|
|
464
|
+
const cands = all.filter(([n, v]) => family.test(n) && /^-?\d*\.?\d+(px|rem)$/.test(v.trim())).map(([n, v]) => { const m = v.trim().match(/^(-?\d*\.?\d+)(px|rem)$/); return [n, pxOf(m[1], m[2])]; });
|
|
465
|
+
if (!cands.length || !px.length) return { token: null, same: false };
|
|
466
|
+
// each length on its own: a same-value token replaces it, 0 stays; `fix` is the value with every same-value length swapped
|
|
467
|
+
let same = true; const near = [];
|
|
468
|
+
const fix = String(literal).replace(LENGTH, (m, n, u) => {
|
|
469
|
+
const p = pxOf(n, u);
|
|
470
|
+
if (p === 0) return m;
|
|
471
|
+
const exact = cands.find(([, v]) => v === Math.abs(p));
|
|
472
|
+
if (exact) return p < 0 ? `calc(-1 * var(${exact[0]}))` : `var(${exact[0]})`;
|
|
473
|
+
same = false;
|
|
474
|
+
near.push(`${m} → ${cands.slice().sort((x, y) => Math.abs(x[1] - Math.abs(p)) - Math.abs(y[1] - Math.abs(p)))[0][0]}`);
|
|
475
|
+
return m;
|
|
476
|
+
}).trim();
|
|
477
|
+
return { token: same ? fix : near.join(', '), same };
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** Bypasses in one stylesheet's text: [{ kind, line, prop, value, token, same }]. PURE. */
|
|
481
|
+
function cssBypasses(css, tokens) {
|
|
482
|
+
const out = [];
|
|
483
|
+
const lines = String(css || '').replace(/\/\*[\s\S]*?\*\//g, (c) => c.replace(/[^\n]/g, ' ')).split('\n');
|
|
484
|
+
lines.forEach((text, i) => {
|
|
485
|
+
for (const m of text.matchAll(/(?:^|[{;\s])(--[a-zA-Z0-9-]+|[a-z][a-z-]*)\s*:\s*([^;{}]+)/g)) {
|
|
486
|
+
const prop = m[1]; const raw = m[2].trim();
|
|
487
|
+
if (!raw) continue; // a selector's pseudo-class (a:hover {) reads as a property no kind uses, so it never counts
|
|
488
|
+
const line = i + 1;
|
|
489
|
+
if (prop.startsWith('--')) { out.push({ kind: 'tokenDef', line, prop, value: raw, token: null, same: false }); continue; }
|
|
490
|
+
const v = dropVars(raw);
|
|
491
|
+
for (const c of v.matchAll(COLOUR)) { if (prop === 'box-shadow' || prop === 'text-shadow') break; const t = tokenFor('colour', c[0], tokens); out.push({ kind: 'colour', line, prop, value: c[0], ...t }); }
|
|
492
|
+
const hasLen = () => [...v.matchAll(LENGTH)].some((x) => Number(x[1]) !== 0);
|
|
493
|
+
if ((prop === 'font-size' || prop === 'font') && hasLen()) out.push({ kind: 'size', line, prop, value: v.trim(), ...tokenFor('size', v, tokens) });
|
|
494
|
+
else if (RADIUS_PROP.test(prop) && hasLen()) out.push({ kind: 'corner', line, prop, value: v.trim(), ...tokenFor('corner', v, tokens) });
|
|
495
|
+
else if (SPACE_PROP.test(prop) && hasLen()) out.push({ kind: 'spacing', line, prop, value: v.trim(), ...tokenFor('spacing', v, tokens) });
|
|
496
|
+
else if ((prop === 'box-shadow' || prop === 'text-shadow') && /\d/.test(v) && !/^\s*(none|0)\s*$/.test(v)) out.push({ kind: 'shadow', line, prop, value: v.trim(), ...tokenFor('shadow', raw, tokens) });
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
return out;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const INLINE = [/\bstyle\s*=\s*"([^"]*)"/g, /\bstyle\s*=\s*'([^']*)'/g, /\.style\.[a-zA-Z]+\s*=\s*["'`]([^"'`]*)["'`]/g, /\bcssText\s*[+]?=\s*["'`]([^"'`]*)["'`]/g,
|
|
503
|
+
/\bstyle\s*:\s*["'`]([^"'`]*)["'`]/g, /\.setProperty\(\s*["'][^"']+["']\s*,\s*["'`]([^"'`]*)["'`]/g];
|
|
504
|
+
/** Bypasses in one script or page: inline style values with a literal, and page-only classes. PURE. */
|
|
505
|
+
function scriptBypasses(src, systemAll) {
|
|
506
|
+
const out = [];
|
|
507
|
+
String(src || '').split('\n').forEach((text, i) => {
|
|
508
|
+
const line = i + 1;
|
|
509
|
+
for (const re of INLINE) for (const m of text.matchAll(re)) {
|
|
510
|
+
const v = dropVars(m[1].replace(/\$\{[^}]*\}/g, ''));
|
|
511
|
+
if (COLOUR.test(v) || [...v.matchAll(LENGTH)].some((x) => Number(x[1]) !== 0)) out.push({ kind: 'inline', line, prop: 'style', value: m[1].trim().slice(0, 80), token: null, same: false });
|
|
512
|
+
COLOUR.lastIndex = 0;
|
|
513
|
+
}
|
|
514
|
+
for (const c of classesOf(text)) if (!systemAll.has(c)) out.push({ kind: 'pageClass', line, prop: 'class', value: c, token: null, same: false });
|
|
515
|
+
});
|
|
516
|
+
return out;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** Every class a system sheet names anywhere (parts, states, scopes). */
|
|
520
|
+
function systemClassesAll(sheets) {
|
|
521
|
+
const all = new Set();
|
|
522
|
+
for (const css of sheets) for (const r of rulesOf(css)) for (const c of selectorClasses(r.selector)) all.add(c);
|
|
523
|
+
return all;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/** Read many files of one commit in one git call (or from disk for WORKTREE). → Map path → text */
|
|
527
|
+
function readMany(repo, ref, paths) {
|
|
528
|
+
const out = new Map();
|
|
529
|
+
if (!paths.length) return out;
|
|
530
|
+
if (isWorktree(ref)) { for (const p of paths) { try { out.set(p, fs.readFileSync(path.join(repo, p), 'utf8')); } catch { /* gone */ } } return out; }
|
|
531
|
+
const { spawnSync } = require('child_process');
|
|
532
|
+
const r = spawnSync('git', ['-C', repo, 'cat-file', '--batch'], { input: paths.map((p) => `${ref}:${p}`).join('\n') + '\n', maxBuffer: 1 << 30 });
|
|
533
|
+
const buf = r.stdout || Buffer.alloc(0);
|
|
534
|
+
let pos = 0;
|
|
535
|
+
for (const p of paths) {
|
|
536
|
+
const nl = buf.indexOf(10, pos); if (nl < 0) break;
|
|
537
|
+
const head = buf.slice(pos, nl).toString();
|
|
538
|
+
pos = nl + 1;
|
|
539
|
+
if (/ missing$/.test(head)) continue;
|
|
540
|
+
const size = Number(head.split(' ')[2]);
|
|
541
|
+
out.set(p, buf.slice(pos, pos + size).toString('utf8'));
|
|
542
|
+
pos += size + 1;
|
|
543
|
+
}
|
|
544
|
+
return out;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** Count the token bypasses of every scanned file at one commit. → { ref, commit, config, files: [{ file, counts, findings }], totals, swaps } */
|
|
548
|
+
function bypasses(repo, ref, { files: given } = {}) {
|
|
549
|
+
const R = given ? null : readerOf(repo, ref);
|
|
550
|
+
const all = given ? Object.keys(given) : R.list();
|
|
551
|
+
const read1 = given ? (p) => (p in given ? given[p] : null) : R.read;
|
|
552
|
+
const cfg = configAt(read1);
|
|
553
|
+
const isSystem = endsWithName(cfg.systemSheets);
|
|
554
|
+
const isSysJs = endsWithName(cfg.systemScripts || []);
|
|
555
|
+
const scan = (cfg.scan || []).map(globRe); const ignore = (cfg.ignore || []).map(globRe);
|
|
556
|
+
const sysPaths = all.filter((p) => /\.css$/i.test(p) && isSystem(p));
|
|
557
|
+
const targets = all.filter((p) => /\.(css|m?js|html?)$/i.test(p) && scan.some((re) => re.test(p)) && !ignore.some((re) => re.test(p)) && !isSystem(p) && !isSysJs(p)).sort();
|
|
558
|
+
const texts = given ? new Map([...sysPaths, ...targets].map((p) => [p, given[p]])) : readMany(repo, ref, [...sysPaths, ...targets]);
|
|
559
|
+
const sysTexts = sysPaths.map((p) => texts.get(p)).filter((t) => t != null);
|
|
560
|
+
const tokens = tokensOf(sysTexts);
|
|
561
|
+
const sysAll = systemClassesAll(sysTexts);
|
|
562
|
+
const files = [];
|
|
563
|
+
const totals = Object.fromEntries(KINDS.map((k) => [k, 0]));
|
|
564
|
+
let swaps = 0;
|
|
565
|
+
for (const f of targets) {
|
|
566
|
+
const text = texts.get(f);
|
|
567
|
+
if (text == null) continue;
|
|
568
|
+
let findings;
|
|
569
|
+
if (/\.css$/i.test(f)) findings = cssBypasses(text, tokens);
|
|
570
|
+
else if (/\.html?$/i.test(f)) {
|
|
571
|
+
const styles = [...text.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)];
|
|
572
|
+
findings = scriptBypasses(text.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, (b) => b.replace(/[^\n]/g, ' ')), sysAll);
|
|
573
|
+
for (const st of styles) { const off = text.slice(0, st.index).split('\n').length - 1; for (const x of cssBypasses(st[1], tokens)) findings.push({ ...x, line: x.line + off }); }
|
|
574
|
+
} else findings = scriptBypasses(text, sysAll);
|
|
575
|
+
const counts = Object.fromEntries(KINDS.map((k) => [k, 0]));
|
|
576
|
+
for (const x of findings) { counts[x.kind]++; totals[x.kind]++; if (x.same) swaps++; }
|
|
577
|
+
files.push({ file: f, counts, findings });
|
|
578
|
+
}
|
|
579
|
+
const commit = given ? null : (isWorktree(ref) ? 'WORKTREE' : (gitOut(repo, ['rev-parse', '--short', ref]) || '').trim() || null);
|
|
580
|
+
return { ref: isWorktree(ref) ? 'WORKTREE' : ref, commit, config: cfg, tokens: tokens.size, files, totals, total: Object.values(totals).reduce((a, b) => a + b, 0), swaps };
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** The lines a commit range added to one file (base → head; head WORKTREE compares with the files on disk). */
|
|
584
|
+
function addedLines(repo, base, head, file) {
|
|
585
|
+
const args = isWorktree(head) ? ['diff', '-U0', base, '--', file] : ['diff', '-U0', base, head, '--', file];
|
|
586
|
+
const out = gitOut(repo, args) || '';
|
|
587
|
+
const lines = new Set();
|
|
588
|
+
for (const m of out.matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gm)) { const a = Number(m[1]); const n = m[2] === undefined ? 1 : Number(m[2]); for (let i = 0; i < n; i++) lines.add(a + i); }
|
|
589
|
+
return lines;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/** The ratchet: every file whose count of a kind rose from base to head. → [{ file, kind, before, after, lines: [finding] }] */
|
|
593
|
+
function ratchet(repo, base, head, { addedOf = addedLines } = {}) {
|
|
594
|
+
const before = new Map(base.files.map((f) => [f.file, f.counts]));
|
|
595
|
+
const out = [];
|
|
596
|
+
for (const f of head.files) {
|
|
597
|
+
const b = before.get(f.file) || Object.fromEntries(KINDS.map((k) => [k, 0]));
|
|
598
|
+
const rose = KINDS.filter((k) => f.counts[k] > b[k]);
|
|
599
|
+
if (!rose.length) continue;
|
|
600
|
+
const added = before.has(f.file) ? addedOf(repo, base.ref, head.ref, f.file) : null;
|
|
601
|
+
for (const k of rose) out.push({ file: f.file, kind: k, before: b[k], after: f.counts[k], lines: f.findings.filter((x) => x.kind === k && (!added || added.has(x.line))) });
|
|
602
|
+
}
|
|
603
|
+
return out;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** One line for a finding: what bypasses which token. */
|
|
607
|
+
function findingSay(x) {
|
|
608
|
+
const what = `${KIND_LABEL[x.kind]} ${x.kind === 'pageClass' ? '.' + x.value : x.value}`;
|
|
609
|
+
if (x.kind === 'tokenDef') return `${what}: define tokens in the design system only`;
|
|
610
|
+
if (x.kind === 'pageClass') return `${what}: use a system part`;
|
|
611
|
+
if (x.kind === 'inline') return `${what}: use a class that reads the tokens`;
|
|
612
|
+
if (x.token && x.same) return `${what}: use ${/^--/.test(x.token) ? `var(${x.token})` : x.token} (same value)`;
|
|
613
|
+
if (x.token) return `${what}: nearest token ${x.token}`;
|
|
614
|
+
return `${what}: the system has no token for this yet`;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** The token report as markdown. view = { date, ref, commit, now: bypasses(), base, baseCommit, findings, trend, cmd } */
|
|
618
|
+
function tokensMd(view) {
|
|
619
|
+
const { date, now } = view;
|
|
620
|
+
const L = [];
|
|
621
|
+
L.push('---', 'type: Reference', `title: "Design token bypasses ${date}"`, `timestamp: ${date}`, '---', '');
|
|
622
|
+
L.push(`# Design token bypasses, ${date}`, '');
|
|
623
|
+
L.push(`**${(now.total - now.totals.pageClass).toLocaleString('en-US')} places do not read a design token. ${now.swaps.toLocaleString('en-US')} of them have a token with the same value, so swapping them changes nothing in the light theme. ${now.totals.pageClass.toLocaleString('en-US')} classes are page-only: the system does not define them.**`, '');
|
|
624
|
+
L.push(`Goal (Wawan, 2026-11-22): change one token and every page follows, with no page rewritten. Each place counted here is a place a token change does not reach. Made by \`${view.cmd}\` at \`${now.commit}\` (initiative design-token-ratchet). Config: ${now.config.from}. ${now.tokens} tokens read from the system sheets.`, '');
|
|
625
|
+
L.push('## By kind', '', '| Kind | Count | Same-value swaps |', '|---|---|---|');
|
|
626
|
+
for (const k of KINDS) L.push(`| ${KIND_LABEL[k]} | ${now.totals[k].toLocaleString('en-US')} | ${now.files.reduce((n, f) => n + f.findings.filter((x) => x.kind === k && x.same).length, 0).toLocaleString('en-US')} |`);
|
|
627
|
+
L.push('');
|
|
628
|
+
const top = now.files.map((f) => ({ f, n: KINDS.filter((k) => k !== 'pageClass').reduce((a, k) => a + f.counts[k], 0) })).filter((x) => x.n).sort((a, b) => b.n - a.n).slice(0, 15);
|
|
629
|
+
L.push('## Files with the most bypasses', '', 'Page-only classes left out of this ranking.', '', '| File | Colours | Sizes | Corners | Spacing | Shadows | Tokens defined | Inline |', '|---|---|---|---|---|---|---|---|');
|
|
630
|
+
for (const { f } of top) L.push(`| ${f.file.replace(/^workspace\/public\//, '')} | ${f.counts.colour} | ${f.counts.size} | ${f.counts.corner} | ${f.counts.spacing} | ${f.counts.shadow} | ${f.counts.tokenDef} | ${f.counts.inline} |`);
|
|
631
|
+
L.push('');
|
|
632
|
+
if (view.findings) {
|
|
633
|
+
L.push('## New bypasses against the base', '', view.findings.length ? `Compared with \`${view.baseCommit}\`:` : `None against \`${view.baseCommit}\`.`, '');
|
|
634
|
+
for (const g of view.findings) { L.push(`- \`${g.file}\` ${KIND_LABEL[g.kind]}: ${g.before} → ${g.after}`); for (const x of g.lines.slice(0, 10)) L.push(` - line ${x.line}: ${findingSay(x)}`); }
|
|
635
|
+
L.push('');
|
|
636
|
+
}
|
|
637
|
+
if (view.trend && view.trend.length) {
|
|
638
|
+
L.push('## Trend', '', 'Total bypasses at the last commit of each week (page-only classes counted separately):', '', '| Week ending | Commit | Bypasses | Page-only classes |', '|---|---|---|---|');
|
|
639
|
+
for (const t of view.trend) L.push(`| ${t.week} | ${t.commit ? '`' + t.commit + '`' : 'none'} | ${t.total == null ? '' : t.total.toLocaleString('en-US')} | ${t.pageClass == null ? '' : t.pageClass.toLocaleString('en-US')} |`);
|
|
640
|
+
L.push('');
|
|
641
|
+
}
|
|
642
|
+
L.push('## How it is used', '',
|
|
643
|
+
'- On every pull request, CI compares each file with the base. A count may fall, never rise. A rise names the line and the token it should read. CI only warns until Wawan decides to block (reminder 2026-11-29).',
|
|
644
|
+
'- The only changes this check proposes are same-value swaps: a literal replaced by the token that has that value. It never rewrites a page.',
|
|
645
|
+
'- A literal inside `var(--token, fallback)` reads the token and is not counted. A colour swap is the same in the light theme; in the dark theme the line then follows the token, as every other line does.', '');
|
|
646
|
+
return L.join('\n');
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** Totals per week from the commit at the end of each week, oldest first. */
|
|
650
|
+
function tokenTrend(repo, ref, weeks, { now = Date.now() } = {}) {
|
|
651
|
+
const out = [];
|
|
652
|
+
for (let i = weeks - 1; i >= 0; i--) {
|
|
653
|
+
const end = new Date(now - i * 7 * 86400000);
|
|
654
|
+
const sha = (gitOut(repo, ['rev-list', '-1', `--before=${end.toISOString()}`, ref]) || '').trim();
|
|
655
|
+
if (!sha) { out.push({ week: end.toISOString().slice(0, 10), commit: null, total: null, pageClass: null }); continue; }
|
|
656
|
+
const b = bypasses(repo, sha);
|
|
657
|
+
out.push({ week: end.toISOString().slice(0, 10), commit: sha.slice(0, 8), total: b.total - b.totals.pageClass, pageClass: b.totals.pageClass });
|
|
658
|
+
}
|
|
659
|
+
return out;
|
|
660
|
+
}
|
|
401
661
|
|
|
402
662
|
module.exports = {
|
|
403
663
|
DEFAULTS, CONFIG_PLACES, REBUILT_SHARE, REBUILT_SHRINK,
|
|
404
664
|
rulesOf, selectorClasses, splitSelectors, compoundsOf, systemOf, classesOf, importsOf, colourCount, globRe, resolveRef,
|
|
665
|
+
KINDS, KIND_LABEL, dropVars, tokensOf, tokenFor, cssBypasses, scriptBypasses, systemClassesAll, readMany, bypasses, addedLines, ratchet, findingSay, tokensMd, tokenTrend,
|
|
405
666
|
configAt, readerOf, measure, compare, queue, meanShare, trend, summary, reportMd, gitOut,
|
|
406
667
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.681.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.681.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "design-drift-guard: the
|
|
2
|
+
"_comment": "design-drift-guard and design-token-ratchet: every place the product's styles and scripts do not read a design token, the ratchet that lets a change lower that count but never raise it, and the older page-share measure (--pages). Read from git only (lib/design-drift.js, lib/design-cli.js), on scratch git repositories. No server, no network, no model.",
|
|
3
3
|
"modules": ["design-drift.test.js"],
|
|
4
|
-
"seconds": { "design-drift.test.js":
|
|
4
|
+
"seconds": { "design-drift.test.js": 4 }
|
|
5
5
|
}
|