create-pmos 0.680.0 → 0.682.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 +12 -6
- 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 +11 -5
- package/workspace/guide/cli.md +9 -5
- package/workspace/guide/layout.md +3 -3
- 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/public/pm/bd-pop-ds.css +5 -0
- package/workspace/public/pm/bd-pop-ds.js +10 -5
- package/workspace/public/pm/cozy-pop-work.js +9 -11
- package/workspace/public/pm/pop-work-model.js +13 -14
- 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.682.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,14 +34,20 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-22T07:
|
|
37
|
+
"v": "0.682.0",
|
|
38
|
+
"at": "2026-11-22T07:57:47.146Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
41
|
{
|
|
42
|
-
"n":
|
|
43
|
-
"t": "
|
|
44
|
-
"s": "
|
|
42
|
+
"n": 1487,
|
|
43
|
+
"t": "Design drift guard counts token bypasses, with a ratchet",
|
|
44
|
+
"s": "Design drift guard counts token bypasses, with a ratchet",
|
|
45
|
+
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1478,
|
|
49
|
+
"t": "Work breakdown keeps done tasks in date order and folds a finished stage",
|
|
50
|
+
"s": "Work breakdown keeps done tasks in date order and folds a finished stage",
|
|
45
51
|
"k": "new"
|
|
46
52
|
}
|
|
47
53
|
]
|
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:57:44Z"}
|
|
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:57:44Z"}
|
|
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:57:44Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-22T07:
|
|
3
|
+
"v": "0.682.0",
|
|
4
|
+
"at": "2026-11-22T07:57:47.146Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
7
|
{
|
|
8
|
-
"n":
|
|
9
|
-
"t": "
|
|
10
|
-
"s": "
|
|
8
|
+
"n": 1487,
|
|
9
|
+
"t": "Design drift guard counts token bypasses, with a ratchet",
|
|
10
|
+
"s": "Design drift guard counts token bypasses, with a ratchet",
|
|
11
|
+
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1478,
|
|
15
|
+
"t": "Work breakdown keeps done tasks in date order and folds a finished stage",
|
|
16
|
+
"s": "Work breakdown keeps done tasks in date order and folds a finished stage",
|
|
11
17
|
"k": "new"
|
|
12
18
|
}
|
|
13
19
|
]
|
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
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Layout and first run: the places, the navigation, the Viewer, the launcher and Adler"
|
|
4
4
|
description: "The places, the navigation at the left, the Viewer, the keys and the phone; the first run; when features appear; the PMOS app; and Adler."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-22
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Layout and first run
|
|
@@ -150,7 +150,7 @@ The left column has three blocks:
|
|
|
150
150
|
|
|
151
151
|
- **Where it stands.** What is happening, in a few sentences. Then **Next**: the next three dates, a milestone as a diamond and the outcome check as a circle; press a milestone to open it. Then one suggestion from PMOS with **Why**, **PMOS will** and **Based on**. The pencil opens it so you can change it first, ✓ does it and ✕ drops it. Other suggestions are one link under it.
|
|
152
152
|
- **Stages.** Each stage of the workflow, with its dates under its name or "no dates yet", on a month scale with a red line for today. A stage's bar runs from the earliest start to the latest end of its tasks; a task with no start counts from its due date. Only a stage with no dated task uses the days the workflow moved through it. To change a stage's dates, change its tasks' dates. A stage has a bar only when it has real dates. A milestone is a diamond on its stage's row.
|
|
153
|
-
- **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". A done task stays in its
|
|
153
|
+
- **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". Press the group to fold it, and press it again to open it. A stage whose tasks are all done is folded until you open it. In a stage, the tasks are in date order, a late task first. A done task stays in its place, in grey with a check. Stages with no tasks fold into one line at the end. Press the box before a task to mark it done, with **Undo**. Press its name to rename it: Enter saves and Escape cancels. When you point at the row, four icons show: **Who** (You, the people on this initiative, or **PMOS does it**, which gives the task to PMOS), **Due date**, **Stage** (moves the task to another stage) and ⋯ (**Status**, **Make it a milestone** and **Open the task**). Each change has **Undo**. A Jira ticket keeps its owner and stage from Jira. **Gantt** is the table described below, with its bars.
|
|
154
154
|
|
|
155
155
|
Press the rest of a row, or a milestone, to open it as a full popup in place of the work side. Its top line has ←, the path (**Work › product › initiative**), the chat button, ⋯ and ×. ← or the initiative's name goes back to the initiative, where you left it. The chat button shows **Ask PMOS** beside it. × closes the popup. A task shows its status, dates, owner, notes and what changed. A milestone also shows its date and how many days are left, the done test, **Kill if**, and the suggestion from PMOS about it when there is one.
|
|
156
156
|
|
|
@@ -162,7 +162,7 @@ The right column has two blocks:
|
|
|
162
162
|
On a phone, in a shared read-only copy and in a breakdown given the whole popup, the work side keeps the three parts below. They use the full width of the popup: in a wide popup the timeline gets the extra width. A done task shows in grey text, never struck through.
|
|
163
163
|
|
|
164
164
|
- **Overview.** Three short lines from the initiative's own records: **Problem**, **Goal** (with the goal it serves, by name) and **Done when**. A line with no record says **Not written yet.** and offers a draft with ✓ and ✕. Press a line to change it; it saves when you leave the field, with **Undo**. Then one line on where it stands, **PMOS suggests** (at most three, each with ✓ and ✕), and **Details ›** for the facts: Stage, Status, Start, Target end, Next milestone, Goal, Product, Program, Workflow and Open. A fact with no value is not shown. Goal, Product, Program and Next milestone are in the link colour and open their thing; the others are plain text. An initiative that is closed or done but has open tasks shows one suggestion: **Close them** or **Reopen**.
|
|
165
|
-
- **Work breakdown.** Each stage is a row that folds and says how much is done, for example "3 of 9 done". Only the stage in progress opens by itself. In a long stage you see the late tasks, the tasks in progress and the next five, then **N more tasks**.
|
|
165
|
+
- **Work breakdown.** Each stage is a row that folds and says how much is done, for example "3 of 9 done". Only the stage in progress opens by itself, and a stage whose tasks are all done stays folded until you open it. In a stage, the tasks are in date order, a late task first; a done task stays in its place, in grey. In a long stage you see the late tasks, the tasks in progress and the next five, then **N more tasks**. The stages after the next one fold to one row. A task in no stage is not in the breakdown: it is in Work › Backlog, and one quiet line under the breakdown says how many, for example **2 tasks with no stage are in the Backlog ›**. A task with no date shows no date and is never late. The timeline is on the right, with **Today** on it. Drag the grip between the columns and the timeline to make the timeline wider or narrower; a double press puts it back. Choose its span (Quarter to Full) beside the tune icon, which shows or hides columns. The four-corners icon gives the breakdown the whole popup. Type in the last row of a stage to add a task; the **Task** choice beside it makes the next one a milestone.
|
|
166
166
|
- **Status.** Press a task's status and pick the new one. **When did this happen?** shows under the list, with **Today** chosen: press the status again, or Enter, to keep today. Press **Yesterday**, or **Pick a date**, when the work moved earlier than you noted it. A day in the future, or a day before the task's previous move, cannot be picked. The toast says both days, for example "Done on 14 Nov, noted today.", with **Undo**.
|
|
167
167
|
- **Open the task.** The ↗ on a row, or **Open the task** in its ⋯, opens a small popup on top: Task or Milestone, the name (press it to rename), status, dates, owner and notes. Its status asks **When did this happen?** too. ↑ and ↓ go to the task before or after it, and ⋯ has **Make it a milestone**, **Archive** and **Delete**, each with **Undo**. A change shows on the task's row at once. Escape, × or a press outside closes only the small popup, and the task's row lights for a moment.
|
|
168
168
|
- **Dates.** Press a task's date. **Task | Milestone** on top turns it into a milestone (one Date) or back into a task (Start and Due). Write a day as "15 Oct 2026", or press the calendar icon. The row's ⋯ also has **Make it a milestone** and **Open the task**.
|
|
@@ -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.682.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.682.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -78,3 +78,8 @@ div.pwd-art { cursor: default; }
|
|
|
78
78
|
.pwd-art.miss .t { color: var(--muted); }
|
|
79
79
|
.pwd-art .w.warn { color: var(--alert); }
|
|
80
80
|
.pwd-ai { flex: none; color: var(--muted); display: inline-flex; }
|
|
81
|
+
/* a stage head is a press that folds the stage (Wawan, 2026-11-22): the system's pm-group as a button, the chevron at the end */
|
|
82
|
+
.pwd-list .pm-group.pwd-gh { width: 100%; border: 0; font: inherit; font-size: var(--fs-label); font-weight: var(--fw-strong); text-align: left; cursor: pointer; }
|
|
83
|
+
.pwd-list .pm-group.pwd-gh svg { margin-left: auto; flex: none; }
|
|
84
|
+
.pwd-list .pm-group.pwd-gh:hover { color: var(--ink); }
|
|
85
|
+
.pwd-list .pm-group.pwd-gh:focus-visible { outline: none; box-shadow: var(--glow); }
|
|
@@ -19,7 +19,7 @@ export const I = {
|
|
|
19
19
|
star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16z', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18',
|
|
20
20
|
plus: 'M12 5v14M5 12h14', more: 'M5 12h.01M12 12h.01M19 12h.01', open: 'M14 5h5v5M19 5l-8 8M18 14v5H5V6h5', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
|
|
21
21
|
dia: 'M12 4l8 8-8 8-8-8z', doc: 'M7 3h7l4 4v14H7zM14 3v4h4M9.5 12h6M9.5 16h6', deck: 'M4 5h16v11H4zM12 16v4M8 20h8', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
|
|
22
|
-
proto: 'M4 5h16v12H4zM9 21h6M12 17v4', right: 'M10 7l5 5-5 5',
|
|
22
|
+
proto: 'M4 5h16v12H4zM9 21h6M12 17v4', right: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5',
|
|
23
23
|
who: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM5 20a7 7 0 0 1 14 0', cal: 'M5 6h14v14H5zM5 10h14M9 4v4M15 4v4', stage: 'M5 7h14M5 12h10M5 17h6',
|
|
24
24
|
};
|
|
25
25
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -131,7 +131,8 @@ export function stageKeyOf(text, st) {
|
|
|
131
131
|
const cur = L.find((x) => x.now) || L.find((x) => !x.done) || L[0];
|
|
132
132
|
return cur ? { key: cur.key, name: cur.name, title: s, guessed: true } : null;
|
|
133
133
|
}
|
|
134
|
-
/** rows: the breakdown with every stage open,
|
|
134
|
+
/** rows: the breakdown with every stage open but a finished one, done tasks in their date order and no "more" fold (pop-work-model.js
|
|
135
|
+
* breakdownOf with openAll). A stage head is a press that folds it (data-pw-fold, the Gantt's own). o: { ro, looseN, ms } */
|
|
135
136
|
export function listHtml(rows, W, o = {}) {
|
|
136
137
|
const groups = [], empty = [];
|
|
137
138
|
let g = null;
|
|
@@ -156,9 +157,13 @@ export function listHtml(rows, W, o = {}) {
|
|
|
156
157
|
return `<div class="pm-li pwd-li${x.done ? ' dn' : ''}${x.lit ? ' now' : ''}" data-pwli="${esc(x.uid)}" data-pw-row="${esc(x.uid)}">${box}<span class="txt">${title}${sub ? `<span class="w${x.late ? ' late' : ''}">${esc(sub)}</span>` : ''}</span>${acts}</div>`;
|
|
157
158
|
};
|
|
158
159
|
const body = groups.map((G) => {
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
// a stage row from breakdownOf says whether it has tasks (can) and is open; a row without them is open when tasks follow it
|
|
161
|
+
const has = G.s.can != null ? !!G.s.can : G.tasks.length > 0, open = G.s.open != null ? !!G.s.open : true;
|
|
162
|
+
if (!has) { empty.push(G.s.name); return ''; }
|
|
163
|
+
const count = G.s.count || G.tasks.filter((x) => x.done).length + ' of ' + G.tasks.length + ' done';
|
|
164
|
+
// the head folds the stage (Wawan, 2026-11-22: "completed stage can be collapsed"); its tasks keep their date order, done ones in place
|
|
165
|
+
const head = `<button type="button" class="pm-group pwd-gh${G.s.now ? ' now' : ''}" data-pw-fold="${esc(G.s.key)}" aria-expanded="${open}"><b>${esc(G.s.name)}</b> <span class="pm-meta">${esc(count)}</span>${SV(open ? I.down : I.right, 14)}</button>`;
|
|
166
|
+
return head + (open ? G.tasks.map(li).join('') : '');
|
|
162
167
|
}).join('');
|
|
163
168
|
const fold = empty.length ? `<div class="pm-fold pwd-fold">${esc(empty.length === 1 ? empty[0] + ' has no tasks yet' : empty.slice(0, -1).join(', ') + ' and ' + empty[empty.length - 1] + ' have no tasks yet')}</div>` : '';
|
|
164
169
|
const cap = o.ro ? '' : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or PMOS picks one" aria-label="Add a task. Say its stage, or PMOS picks one" maxlength="200" autocomplete="off">`;
|
|
@@ -52,10 +52,10 @@ const store = {
|
|
|
52
52
|
// 'pw-cols2': a column choice saved before round 3 (Status and Date hidden by an older tune menu) no longer hides them (round 3 point 5)
|
|
53
53
|
const COLS = 'pw-cols2', SPAN = 'pw-span', BIG = 'pw-big', TLW = 'pw-tlw';
|
|
54
54
|
const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true, ...store.get(COLS, {}) });
|
|
55
|
-
const ST = new Map(); // initiative id → { open, shut,
|
|
55
|
+
const ST = new Map(); // initiative id → { open, shut, moreOpen, farOpen, details, top }
|
|
56
56
|
const LOOSE = 'pw-loose'; // the initiatives whose Not in a stage row the PM opened (round 3 point 21), remembered on this computer
|
|
57
57
|
const stOf = (id) => {
|
|
58
|
-
if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(),
|
|
58
|
+
if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '' });
|
|
59
59
|
return ST.get(id);
|
|
60
60
|
};
|
|
61
61
|
const looseKeep = (id, on) => { const L = (store.get(LOOSE, []) || []).filter((x) => x !== id); if (on) L.push(id); store.set(LOOSE, L.slice(-200)); };
|
|
@@ -207,12 +207,11 @@ const xOf = (W) => { const a = Date.parse(W.span.a), b = Date.parse(W.span.b); r
|
|
|
207
207
|
function barHtml(x, W) {
|
|
208
208
|
const X = xOf(W);
|
|
209
209
|
if (x.kind === 'stage') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: x.tone, late: x.late, ms: x.ms, name: x.name, gaps: x.gaps, marks: x.open ? [] : x.marks }, X, { today: W.today }) : '';
|
|
210
|
-
if (x.kind === 'done') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: 'dn' }, X, { today: W.today }) : '';
|
|
211
210
|
return CB.taskBar(x, X, W.today);
|
|
212
211
|
}
|
|
213
212
|
function rowHtml(x, W, C, sugRows) {
|
|
214
213
|
if (RO) { x = { ...x, jira: true }; sugRows = new Map(); } // a copy: a task's status, date and name are text, as a Jira task's are; no ✦
|
|
215
|
-
const tl = C.tl ? `<div class="pw-tl">${(x.kind === 'stage' || x.kind === 'task'
|
|
214
|
+
const tl = C.tl ? `<div class="pw-tl">${(x.kind === 'stage' || x.kind === 'task') ? barHtml(x, W) : ''}${W.tx != null ? `<i class="pw-now" style="left:${W.tx.toFixed(2)}%"></i>` : ''}</div>` : '';
|
|
216
215
|
const stc = C.status ? `<span class="pw-st">${x.kind === 'task' && !x.jira ? `<button type="button" class="pw-cell" data-pw-status="${esc(x.uid)}" aria-haspopup="menu" aria-label="${esc('Status: ' + x.status + '. Change it')}">${esc(x.status)}</button>` : esc(x.status || '')}</span>` : '';
|
|
217
216
|
const dtc = C.date ? `<span class="pw-dt${x.late ? ' warn' : ''}">${x.kind === 'task' && !x.jira ? `<button type="button" class="pw-cell${x.date ? '' : ' empty'}" data-pw-date="${esc(x.uid)}" aria-label="${esc((x.date ? (x.ms ? 'Milestone ' : 'Due ') + x.date : 'No date') + '. Set the date, or make it a ' + (x.ms ? 'task' : 'milestone'))}">${esc(x.date || 'Set a date')}</button>` : esc(x.date || '')}</span>` : '';
|
|
218
217
|
if (x.kind === 'stage') {
|
|
@@ -223,7 +222,6 @@ function rowHtml(x, W, C, sugRows) {
|
|
|
223
222
|
}
|
|
224
223
|
if (x.kind === 'far') return `<div class="pw-tr pw-sr" role="row"><span class="pw-it"><button type="button" class="pw-stg" data-pw-far aria-expanded="false"><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b>${SVG(P.right, 14)}<small>${esc(x.count)}</small></button></span>${stc}${C.date ? '<span></span>' : ''}${tl}</div>`;
|
|
225
224
|
if (x.kind === 'more') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-more="${esc(x.key)}" aria-expanded="false">${esc(x.label)}${SVG(P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${C.tl ? '<div class="pw-tl"></div>' : ''}</div>`;
|
|
226
|
-
if (x.kind === 'done') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-done="${esc(x.key)}" aria-expanded="${x.open}">${esc(x.label)}${SVG(x.open ? P.down : P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${tl}</div>`;
|
|
227
225
|
const s = sugRows.get(x.uid);
|
|
228
226
|
const title = x.jira ? `<span class="pw-tt">${esc(x.title)}</span>` : `<button type="button" class="pw-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
|
|
229
227
|
return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
|
|
@@ -289,7 +287,7 @@ const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
|
|
|
289
287
|
function model(r, v, o) {
|
|
290
288
|
const id = keyOf(v, o), S = stOf(id), it = ITEMS.get(id);
|
|
291
289
|
const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
|
|
292
|
-
const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut,
|
|
290
|
+
const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
|
|
293
291
|
const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
|
|
294
292
|
return { W, S, id };
|
|
295
293
|
}
|
|
@@ -306,13 +304,15 @@ export function html(r, v, o = {}) {
|
|
|
306
304
|
* breakdown table with its bars and tools; List and Gantt are one remembered choice ('pw-view'). */
|
|
307
305
|
const VIEW = 'pw-view';
|
|
308
306
|
const allOpen = (v) => { const k = new Set(((v.tasks || {}).sections || []).filter((s) => s.kind === 'stage').map((s) => s.key)); return k; };
|
|
309
|
-
|
|
307
|
+
// the List (S given): every stage with tasks open but a finished one (Wawan, 2026-11-22), and the PM's own fold and unfold, shared with the
|
|
308
|
+
// Gantt. No S (a lookup: which stage holds a task, which stage a line names): every stage open, so every task is a row
|
|
309
|
+
function stagesOf(r, v, o, S) {
|
|
310
310
|
const k = allOpen(v);
|
|
311
|
-
return M.breakdownOf(r, v, { ...o, open: k, shut: new Set(),
|
|
311
|
+
return M.breakdownOf(r, v, { ...o, openAll: true, open: S ? S.open : k, shut: S ? S.shut : new Set(), moreOpen: k, farOpen: true }).rows;
|
|
312
312
|
}
|
|
313
313
|
function dsHtml(r, v, o, W, S, C, mode) {
|
|
314
314
|
const id = keyOf(v, o), view = store.get(VIEW, 'list') === 'gantt' ? 'gantt' : 'list';
|
|
315
|
-
const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus });
|
|
315
|
+
const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus }, S);
|
|
316
316
|
const wbs = view === 'gantt'
|
|
317
317
|
? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', PD.wbsHead('gantt')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
|
|
318
318
|
: `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${PD.wbsHead('list')}${PD.listHtml(st, W, { looseN: W.looseN })}</section>`;
|
|
@@ -352,7 +352,6 @@ function phoneHtml(W, S, oid, v) {
|
|
|
352
352
|
if (x.kind === 'stage' && x.loose) return '';
|
|
353
353
|
if (x.kind === 'stage') return `<li class="pw-pst${x.now ? ' now' : ''}">${dot(x)}<button type="button" class="pw-pstg" data-pw-fold="${esc(x.key)}" aria-expanded="${x.open}"${x.can ? '' : ' disabled'}><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b></button>${x.date ? `<span class="pw-pd${x.late ? ' warn' : ''}">${esc(x.date)}</span>` : x.can ? `<span class="pw-pd">${esc(x.count || '')}</span>` : ''}</li>`;
|
|
354
354
|
if (x.kind === 'far') return `<li class="pw-pst">${dot({ status: 'To do' })}<button type="button" class="pw-pstg" data-pw-far aria-expanded="false"><span class="pw-n">${esc(x.n)}</span><b>${esc(x.name)}</b></button><span class="pw-pd">${esc(x.count)}</span></li>`;
|
|
355
|
-
if (x.kind === 'done') return `<li class="pw-ptk"><button type="button" class="pw-dn" data-pw-done="${esc(x.key)}" aria-expanded="${x.open}">${esc(x.label)}</button></li>`;
|
|
356
355
|
if (x.kind === 'more') return `<li class="pw-ptk"><button type="button" class="pw-dn" data-pw-more="${esc(x.key)}" aria-expanded="false">${esc(x.label)}</button></li>`;
|
|
357
356
|
if (x.kind === 'task') return `<li class="pw-ptk${x.done ? ' done' : ''}"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i><button type="button" class="pw-tt" data-pw-open="${esc(x.uid)}">${esc(x.title)}</button>${x.date ? `<span class="pw-pd${x.late ? ' warn' : ''}">${esc(x.date)}</span>` : ''}</li>`;
|
|
358
357
|
return '';
|
|
@@ -508,7 +507,6 @@ export function wire(body, h0, x0) {
|
|
|
508
507
|
if ('pwDetails' in d) { S.details = !S.details; redraw(); return; }
|
|
509
508
|
if (d.pwFold != null) { const k = d.pwFold, open = b.getAttribute('aria-expanded') === 'true'; S.open.delete(k); S.shut.delete(k); (open ? S.shut : S.open).add(k); if (k === '') looseKeep(c.id, !open); redraw(); return; }
|
|
510
509
|
if ('pwFar' in d) { S.farOpen = true; redraw(); return; }
|
|
511
|
-
if (d.pwDone != null) { if (S.doneOpen.has(d.pwDone)) S.doneOpen.delete(d.pwDone); else S.doneOpen.add(d.pwDone); redraw(); return; }
|
|
512
510
|
if ('pwTl' in d) { store.set(COLS, { ...cols(), tl: !cols().tl }); redraw(); return; }
|
|
513
511
|
if ('pwSpan' in d) { spanMenu(b, redraw); return; }
|
|
514
512
|
if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* o { steps (Product feature's eight), today ('YYYY-MM-DD'), docs (home-ini-model.js docRows of the initiative's read), items (the
|
|
9
9
|
* Library's rows for this initiative, GET /api/library-items, when that route is there), product (its name), program ({ title } | null),
|
|
10
10
|
* goal (the goal's name, else the anchor), mode ('full' | 'quarter' | 'half' | 'year' | '2y' | '5y': the timeline's span), open (Set of
|
|
11
|
-
* stage keys the PM unfolded), shut (Set of stage keys the PM folded),
|
|
11
|
+
* stage keys the PM unfolded), shut (Set of stage keys the PM folded), openAll (the List: every stage with tasks opens by itself), farOpen (bool) }
|
|
12
12
|
* levelOf(L, o) → the same parts one level up: a program or a product (boards 26, 27). L: { kind, title, path, summary, facts, rows, docs, props }
|
|
13
13
|
* spanOf(dates, mode, today) → { a, b } ISO the window of the timeline: Full runs from the earliest start to the latest end (no bar is cut)
|
|
14
14
|
* barOf(x, span, today) → { l, w, pass, late, ms, dot } in % of the window one bar: the plan, the part that has passed, the missed date
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
* 1 Overview: the summary, then "PMOS suggests" (at most three; absent when there is none), then the facts. With many tasks the Overview
|
|
20
20
|
* folds to its summary and "Details" opens the facts (many: more than 6 rows of tasks in the open stage).
|
|
21
21
|
* 2 A suggestion about one task sits under that task (rowSuggests by uid); the same suggestion never shows twice.
|
|
22
|
-
* 3 The breakdown: a stage is a row that folds ("3 of 9 done"). Only the stage in progress opens by itself
|
|
23
|
-
*
|
|
24
|
-
* ("
|
|
22
|
+
* 3 The breakdown: a stage is a row that folds ("3 of 9 done"). Only the stage in progress opens by itself (the List: every stage with
|
|
23
|
+
* tasks). A stage whose tasks are all done stays folded until the PM opens it. In an open stage late open tasks come first, then every
|
|
24
|
+
* task by date, a done task in its place, marked done (Wawan, 2026-11-22: "it's weird to put done task on the bottom and hidden. Also
|
|
25
|
+
* completed stage can be collapsed"). The stages after the next one fold into one row ("Prioritize to Evaluate, 5 stages").
|
|
25
26
|
* 4 Bars: light grey the plan, dark grey the part that has passed, the missed date a diamond, a red line from it to today. A row with no
|
|
26
27
|
* date has no bar: PMOS does not invent a date.
|
|
27
28
|
* 5 Artefacts: one table: Artefact, Kind, Updated. A core document a gate needs that is not written is a grey row that says which gate. */
|
|
@@ -121,6 +122,8 @@ const taskSpan = (ts) => {
|
|
|
121
122
|
return [a[0] || '', b[b.length - 1] || ''];
|
|
122
123
|
};
|
|
123
124
|
const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999');
|
|
125
|
+
/** One date order for a stage's done and open tasks: a late open task first, then by date, a done task in its place. */
|
|
126
|
+
const inOrder = (a, b) => ((!b.closed && !!b.late) - (!a.closed && !!a.late)) || (a.end || a.start || '9999').localeCompare(b.end || b.start || '9999');
|
|
124
127
|
const STATUS = { done: 'Done', now: 'In progress', next: 'To do', skip: 'Skipped' };
|
|
125
128
|
const taskStatus = (x) => (x.wont ? "Won't do" : x.status || 'To do');
|
|
126
129
|
|
|
@@ -301,7 +304,7 @@ export function breakdownOf(r, v, o = {}) {
|
|
|
301
304
|
const t = todayOf(o), list = ((v.stage || {}).ladder || []).map((s, i) => ({ name: s.name, status: s.cls, ms: !!s.ms, i }));
|
|
302
305
|
const secs = (v.tasks || {}).sections || [];
|
|
303
306
|
const ran = ranOf(r, secs.filter((s) => s.kind === 'stage').map((s) => ({ key: s.key, name: s.name, status: s.status })));
|
|
304
|
-
const open = o.open || new Set(), shut = o.shut || new Set(),
|
|
307
|
+
const open = o.open || new Set(), shut = o.shut || new Set(), f = o.focus ? String(o.focus) : '';
|
|
305
308
|
const lit = (row) => (f && row.uid != null && String(row.uid) === f ? { ...row, lit: true } : row);
|
|
306
309
|
const stages = secs.filter((s) => s.kind === 'stage');
|
|
307
310
|
const cur = stages.findIndex((s) => s.status === 'now');
|
|
@@ -330,7 +333,9 @@ export function breakdownOf(r, v, o = {}) {
|
|
|
330
333
|
if (a && b && b < a) b = a;
|
|
331
334
|
const live = s.status === 'now' && r.status !== 'done' && !r.ended;
|
|
332
335
|
const dl = b && (s.status === 'now' || s.status === 'next') ? dateLate(b, t, live || ts.some((x) => !x.closed)) : { text: b && s.status === 'done' ? '' : '', late: false };
|
|
333
|
-
|
|
336
|
+
// a finished stage (every task done) folds until the PM opens it; the List opens every other stage with tasks
|
|
337
|
+
const finished = n > 0 && nDone === n;
|
|
338
|
+
const isOpen = holds(all, f) ? true : shut.has(s.key) ? false : open.has(s.key) ? true : !finished && (o.openAll || s.status === 'now');
|
|
334
339
|
// the count holds every task drawn under the stage: its own and the ones in no stage that sit under it (design check, 2026-11-19)
|
|
335
340
|
const nAll = n + lz.length;
|
|
336
341
|
const count = nAll ? (s.status === 'next' && !nDone ? plural(nAll, 'task', 'tasks') : nDone + ' of ' + nAll + ' done') : '';
|
|
@@ -341,8 +346,8 @@ export function breakdownOf(r, v, o = {}) {
|
|
|
341
346
|
rows.push({ kind: 'stage', key: s.key, n: s.n, name: s.name, ms: !!s.ms, status: STATUS[s.status] || '', count, date: dl.text, late: dl.late, start: a, end: b, gaps, marks, tone: s.status === 'done' ? 'dn' : s.status === 'now' ? 'now' : '',
|
|
342
347
|
done: s.status === 'done', open: (isOpen || lz.length > 0) && has, can: has, now: s.status === 'now', skip: s.status === 'skip' });
|
|
343
348
|
if (!((isOpen || lz.length > 0) && has)) return;
|
|
344
|
-
|
|
345
|
-
|
|
349
|
+
if (s.status === 'now' && ts.length > MANY) many = true;
|
|
350
|
+
const sorted = all.slice().sort(inOrder);
|
|
346
351
|
// a long stage (round 3 point 7): the late and in-progress tasks, then the next NEXT, then "N more"; the task a Today row opened always shows
|
|
347
352
|
const all2 = sorted.map((x) => taskRow(x, t));
|
|
348
353
|
let shown = all2;
|
|
@@ -354,12 +359,6 @@ export function breakdownOf(r, v, o = {}) {
|
|
|
354
359
|
for (const x of shown) rows.push(lit({ ...x, sec: s.key }));
|
|
355
360
|
if (shown.length < all2.length) rows.push({ kind: 'more', key: s.key, n: all2.length - shown.length, label: plural(all2.length - shown.length, 'more task', 'more tasks') });
|
|
356
361
|
for (const x of lz.slice().sort(urgent)) { rows.push(lit({ ...taskRow(x, t), sec: '', loose: s.key })); loose.push({ uid: x.uid, title: x.title, to: s.key, name: s.name }); }
|
|
357
|
-
if (nDone) {
|
|
358
|
-
const dd = s.done.map((x) => x.end).filter(Boolean).sort();
|
|
359
|
-
const dO = dOpen.has(s.key) || holds(s.done, f);
|
|
360
|
-
rows.push({ kind: 'done', key: s.key, n: nDone, label: plural(nDone, 'task', 'tasks') + ' done', open: dO, start: (s.done.map((x) => x.start).filter(Boolean).sort()[0]) || dd[0] || '', end: dd[dd.length - 1] || '' });
|
|
361
|
-
if (dO) for (const x of s.done) rows.push(lit({ ...taskRow(x, t), sec: s.key }));
|
|
362
|
-
}
|
|
363
362
|
};
|
|
364
363
|
// the stages after the next one fold into one row (board 20), unless the PM opened it
|
|
365
364
|
const farFrom = cur >= 0 ? cur + 2 : -1;
|
|
@@ -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
|
}
|