create-pmos 0.850.0 → 0.852.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 +117 -118
- package/payload/AGENTS.md +63 -0
- package/payload/KIT-VERSION +1 -1
- package/payload/design-system/brand/README.md +5 -3
- package/payload/design-system/brand/tokens.css +2 -2
- package/payload/design-system/brand/tokens.json +31 -31
- package/payload/design-system/charts/tokens.css +2 -2
- package/payload/design-system/charts/tokens.json +6 -6
- package/payload/design-system/documents/tokens.css +2 -2
- package/payload/design-system/documents/tokens.json +6 -6
- package/payload/design-system/slides/tokens.css +2 -2
- package/payload/design-system/slides/tokens.json +2 -2
- package/payload/design-system/ui/tokens.css +2 -2
- package/payload/design-system/ui/tokens.json +6 -6
- 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/briefing-premium-insights-test.js +2 -2
- package/workspace/changelog.json +116 -4
- package/workspace/design-system/brand/README.md +5 -3
- package/workspace/design-system/brand/tokens.css +2 -2
- package/workspace/design-system/brand/tokens.json +31 -31
- package/workspace/design-system/charts/tokens.css +2 -2
- package/workspace/design-system/charts/tokens.json +6 -6
- package/workspace/design-system/documents/tokens.css +2 -2
- package/workspace/design-system/documents/tokens.json +6 -6
- package/workspace/design-system/slides/tokens.css +2 -2
- package/workspace/design-system/slides/tokens.json +2 -2
- package/workspace/design-system/ui/tokens.css +2 -2
- package/workspace/design-system/ui/tokens.json +6 -6
- package/workspace/guide/cli.md +29 -1
- package/workspace/guide/initiatives-and-next-steps.md +11 -0
- package/workspace/guide/layout.md +2 -0
- package/workspace/guide/programs.md +1 -0
- package/workspace/lib/balance-target.js +13 -6
- package/workspace/lib/design-boards.js +182 -0
- package/workspace/lib/design-cli.js +28 -5
- package/workspace/lib/design-drift.js +26 -2
- package/workspace/lib/features.json +2 -0
- package/workspace/lib/knowledge-cli.js +6 -0
- package/workspace/lib/on-item-routes.js +68 -0
- package/workspace/lib/on-item.js +272 -0
- package/workspace/lib/one-person-knows.js +403 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-capture.js +1 -1
- package/workspace/lib/routes-drift.js +2 -2
- package/workspace/lib/routes-one-person-knows.js +40 -0
- package/workspace/lib/routes-screen-map.js +47 -0
- package/workspace/lib/routes-stage-signoffs.js +4 -1
- package/workspace/lib/screen-map.js +381 -0
- package/workspace/lib/signoffs.js +4 -1
- package/workspace/lib/spec-code-drift.js +2 -2
- package/workspace/lib/{routes-spec-drift.js → spec-drift-http.js} +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-doc-test.js +1 -1
- package/workspace/public/pm/bd-prog-panel.js +25 -1
- package/workspace/public/pm/brand.css +2 -2
- package/workspace/public/pm/charts.css +2 -2
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-pop-work.js +5 -2
- package/workspace/public/pm/cozy-viewer.css +8 -8
- package/workspace/public/pm/documents.css +2 -2
- package/workspace/public/pm/ds-bridge.css +16 -0
- package/workspace/public/pm/home-app.js +5 -0
- package/workspace/public/pm/komorebi.css +2 -2
- package/workspace/public/pm/on-item.js +155 -0
- package/workspace/public/pm/one-person-knows.js +66 -0
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/screen-map.css +23 -0
- package/workspace/public/pm/screen-map.js +187 -0
- package/workspace/public/pm/slides.css +2 -2
- package/workspace/public/premium-board.html +2 -0
- package/workspace/test-lists/kit-agents-verbs.json +9 -0
- package/workspace/test-lists/one-person-knows.json +9 -0
- package/workspace/test-lists/screen-map.json +9 -0
- package/workspace/test-lists/surface-on-item.json +9 -0
- package/workspace/test-lists/text-token-guard.json +5 -0
|
@@ -163,24 +163,24 @@
|
|
|
163
163
|
{
|
|
164
164
|
"name": "raise",
|
|
165
165
|
"value": {
|
|
166
|
-
"light": "0 1px 2px rgba(
|
|
167
|
-
"dark": "0 1px 2px rgba(0,0,0,.4)
|
|
166
|
+
"light": "0 1px 2px rgba(0,0,0,.06)",
|
|
167
|
+
"dark": "0 1px 2px rgba(0,0,0,.4)"
|
|
168
168
|
},
|
|
169
169
|
"usage": "Now: cards, panels, the chosen tab, the next event."
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
"name": "lift",
|
|
173
173
|
"value": {
|
|
174
|
-
"light": "0
|
|
175
|
-
"dark": "0
|
|
174
|
+
"light": "0 1px 3px rgba(0,0,0,.08), 0 8px 24px -12px rgba(0,0,0,.12)",
|
|
175
|
+
"dark": "0 1px 3px rgba(0,0,0,.5), 0 8px 24px -12px rgba(0,0,0,.6)"
|
|
176
176
|
},
|
|
177
177
|
"usage": "Things over things: toast, sheet, menu, slide-over."
|
|
178
178
|
},
|
|
179
179
|
{
|
|
180
180
|
"name": "glow",
|
|
181
181
|
"value": {
|
|
182
|
-
"light": "0 0 0 2px #
|
|
183
|
-
"dark": "0 0 0 2px #
|
|
182
|
+
"light": "0 0 0 2px #18181B",
|
|
183
|
+
"dark": "0 0 0 2px #FAFAFA"
|
|
184
184
|
},
|
|
185
185
|
"usage": "The leaf ring: keyboard focus and the one thing that is now."
|
|
186
186
|
}
|
package/workspace/guide/cli.md
CHANGED
|
@@ -456,6 +456,26 @@ Show where the team is short before you ask for headcount. Run it in the product
|
|
|
456
456
|
- PMOS never writes over a brief. It calls no model and sends nothing. Edit the brief and share it yourself.
|
|
457
457
|
- `pmos hire count [--days 7]` prints how many briefs were drafted in the last days. Its last line is the number.
|
|
458
458
|
|
|
459
|
+
### pmos screens: the map of the product's screens
|
|
460
|
+
|
|
461
|
+
See every screen of the product and the flows between them, from its merged code. Run it in the product's repository, or pass `--root <dir>`. No running workspace is needed. Today shows the same map on the product page, under Screens.
|
|
462
|
+
|
|
463
|
+
- `pmos screens show` lists every screen with its route and file, the screens it leads to, and its marks. It reads the default branch (`origin/HEAD`, else `main` or `master`), so the map follows each merge and names the day of the last one. It writes nothing.
|
|
464
|
+
- A screen is an HTML page, or a file route of Next.js (`pages/`, `app/**/page.*`), SvelteKit (`+page.svelte`) or Nuxt (`pages/*.vue`). A flow is a link in the screen's file, or in the scripts it loads: `href`, `to=`, `location`, `router.push`, `navigate`, `goto`, `redirect` or `window.open`.
|
|
465
|
+
- The marks: a duplicate (the same name once "old", "new", "copy" or a version is taken off, or the same content), a dead end (no flow on to another screen) and a deep screen (more than 4 steps from the start). A screen with no mark is fine.
|
|
466
|
+
- `pmos screens note <screen> "<text>"` keeps a note on a screen (its file or its name) as a capture that names the screen. PMOS files it as work, and Today shows it. Nothing is sent.
|
|
467
|
+
|
|
468
|
+
### pmos knowledge: only one person knows this
|
|
469
|
+
|
|
470
|
+
Find the parts of a product that only one person knows before that person is away. Run it in the product's repository, or pass `--root <dir>`, or ask the chat. No running workspace is needed. Work shows the same list under Principles when one product is shown.
|
|
471
|
+
|
|
472
|
+
- `pmos knowledge` (or `pmos knowledge list`) lists the areas only one person touched in the last 6 months, numbered, with the person and how long. An area is a folder of the repository (up to two levels; a leading `src`, `lib`, `app` or `packages` is skipped) or an initiative's tasks, with 3 or more changes. Bots and PMOS's own agent commits are not a person. When every area has two people, or only one person works on the product at all, there is no list. `--json` prints it for a script.
|
|
473
|
+
- `pmos knowledge leave <person> <from> [<until>]` records a person's leave, with dates such as 2026-12-03. Your own `pmos away` days count too, and so does leave on the workspace calendar: an event titled leave, OOO, out of office, vacation, holiday, PTO or cuti, with the person as its one attendee or named in the title. Nothing needs to be typed for those. Leave dates stay on this computer, in the product's state folder, never in git. `pmos knowledge leave <person> --drop` forgets it.
|
|
474
|
+
- When a person's leave starts in the next 14 days, each of their areas gets a ✦: a pairing with the teammate who touched the most nearby areas, or a short write-up when nobody did. `pmos knowledge plan <n>` plans area `n`. A write-up is a draft at `planning/knowledge/<area>-<person>.md` (`pmos/planning/knowledge/` in a kit) for that person to fill in.
|
|
475
|
+
- `pmos knowledge undo <n>` takes the plan back and removes a write-up draft nobody edited.
|
|
476
|
+
- `pmos knowledge count [--days 7]` prints the plans made in the last days. Its last line is the number.
|
|
477
|
+
- PMOS sends nothing and writes nothing to Jira.
|
|
478
|
+
|
|
459
479
|
### pmos review: a built screen beside its design
|
|
460
480
|
|
|
461
481
|
Check a built screen against the design it came from by looking, not by flipping between two files. You do not need to run anything: put the design and a screenshot of the same screen in the product's repository as `screens/<initiative>/<screen>.design.png` and `<screen>.built.png` (a build or a design export can drop them there), and PMOS compares them by itself when the initiative opens on Work, and again when either file changes. The commands below do the same by hand. Run them in the product's repository, or pass `--root <dir>`. Both files must be PNG.
|
|
@@ -770,7 +790,8 @@ The aim: change one token and every page follows. Each place this command counts
|
|
|
770
790
|
|
|
771
791
|
- `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.
|
|
772
792
|
- `--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.
|
|
773
|
-
- `--gate` exits 1 when a count rose against `--base`. `--github` prints each new place as a GitHub warning on its line.
|
|
793
|
+
- `--gate` exits 1 when a count rose against `--base`. `--github` prints each new place as a GitHub warning on its line.
|
|
794
|
+
- `--block-text` exits 1 when a change adds a text colour or a text size that the design system does not own: a literal colour, a literal text size, an inline style with either, or a colour token defined outside the system sheets (a second palette, or a page that gives `--ink` its own value). CI runs `--github --block-text` on every pull request: these lines fail the check as errors, and every other kind stays a warning.
|
|
774
795
|
- `--weeks <n>` adds the total at the end of each of the last n weeks. `--write` writes the report to `planning/reports/`.
|
|
775
796
|
- `--pages` shows the older measure instead: for each page, the share of its classes that the system defines and its own CSS rules.
|
|
776
797
|
- 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"] }`.
|
|
@@ -781,6 +802,13 @@ The design system's own sheet (Komorebi, `komorebi.css`) is the only place the t
|
|
|
781
802
|
|
|
782
803
|
To change a text size on every page, change the style in `workspace/design-system/ui/tokens.json` and run `node lib/design-system.js --write`. Do not write a `--fs-*` value in a page's stylesheet.
|
|
783
804
|
|
|
805
|
+
### pmos design boards: design boards use the design system only
|
|
806
|
+
|
|
807
|
+
A design board on a canvas is not in the repository, so the CI check cannot see it. Run this on the board files before you publish them.
|
|
808
|
+
|
|
809
|
+
- `pmos design boards <board.dc.html | folder>…` checks each board. A board passes when every colour token it defines has the design system's value, it defines no colour token the system does not have, no style holds a literal colour, and every text size is on the type scale (13, 15, 18 or 26 px, or `var(--type-…)`). It names the line of each place that fails and exits 1.
|
|
810
|
+
- `--fix` puts a board back on the system: its colour tokens take the system's values, the `--type-…` tokens are added, and each text size becomes the nearest step of the scale (12 px becomes small, 14 px becomes body). It does not change a literal colour, because only a person knows whether it means ink, muted or alert.
|
|
811
|
+
|
|
784
812
|
### pmos design swap: a fixed value becomes the token with the same value
|
|
785
813
|
|
|
786
814
|
- `pmos design swap` counts, for each stylesheet, the fixed spacing (padding, margin, gap) and corner values that equal a design token. It also counts the values that sit between two tokens. It changes no file.
|
|
@@ -151,6 +151,17 @@ When PMOS drafts a document for an initiative, for example a stage's plan that y
|
|
|
151
151
|
|
|
152
152
|
Each issue offers Undo. Issuing marks the draft as the current version. Nothing is sent to anyone. When there are several drafts of one document, only the newest can be issued: it replaces the older ones.
|
|
153
153
|
|
|
154
|
+
### What PMOS can do here shows on the initiative
|
|
155
|
+
|
|
156
|
+
You do not need to know what to ask. When an initiative's own files say it is time, the initiative page shows it in the side column. When nothing applies, nothing shows.
|
|
157
|
+
|
|
158
|
+
- **Sign-offs.** Under Details, each open sign-off says who must say yes and to what. Under it, **Asked before** lists what that person asked or objected to on other work, with where it was said. When the sign-off has no source yet, PMOS shows the lines in the initiative's files that name that person with a yes. Press ✓ on the right one: it becomes the sign-off's source, and Today can then record the sign-off. Undo takes it back.
|
|
159
|
+
- **Can it conclude?** An experiment whose metric is a rate and that has a check date, but no `baseline`, `min_change` or `weekly_traffic`, shows a ✦ line under the Overview. Press ✓: PMOS drafts the three numbers from the records in the background. Press ✓ on the draft to write them into the record, with Undo. Then the Overview says whether it can conclude by the check date.
|
|
160
|
+
- **Press release.** A feature at Plan (or Discovery) with no press release shows a ✦ line. Press ✓: PMOS drafts the press release and FAQ in the background (`pmos press-release <id>`), and it lands in Artefacts. Undo stops it.
|
|
161
|
+
- **Grill.** PMOS grills an initiative that was never grilled by itself, as part of its monthly look, and again before it leaves a stage or when its PRD changes. The Overview says so while it runs, and the findings come under the ✦.
|
|
162
|
+
|
|
163
|
+
Press ✕ on a ✦ line to hide it for that initiative on this computer. The chat and the `pmos` commands do the same things.
|
|
164
|
+
|
|
154
165
|
### Now, Next and Later are retired (D105)
|
|
155
166
|
|
|
156
167
|
Earlier versions put each initiative in one of three horizons: Now, Next and Later. They are retired. Nothing you placed is lost:
|
|
@@ -19,6 +19,8 @@ PMOS has one family of design systems, agreed on 2026-11-20. Its files are in th
|
|
|
19
19
|
- `documents/`: PRDs, briefs, reports, notes and shared links, and the rules for emails, Slack messages and notifications.
|
|
20
20
|
- `slides/`: decks.
|
|
21
21
|
|
|
22
|
+
**One colour set.** Since 2026-11-25 the colours are the neutral set: a grey ground, white cards, near-black ink, grey muted text, one blue for PMOS and for actions, and red only for late, at risk or blocked. Every page and every design board takes its colours from `brand/` and nothing else. Text has four sizes: small 13 px, body 15 px, heading 18 px and title 26 px.
|
|
23
|
+
|
|
22
24
|
Read `design-system/README.md` first. Each kit gets a copy in `pmos/design-system/`, so another project or session can use it. A product may change `brand/` only. The other parts follow it.
|
|
23
25
|
|
|
24
26
|
**One icon per action.** `brand/icons.json` names one icon for each common action: dismiss (Close, No, Not now, Clear, Drop) is ✕, approve (Yes, Save, Done) is ✓, Add is +, and Undo, Back, Previous, Next, Edit, Delete, Search, Stop and Upload have one icon each. No two actions share an icon. To see each button that draws its action another way, run `node workspace/lib/icon-check.js check` in your product's repository. It names the file, the line and the label. `--gate` exits 1 when one is off. To change an icon, copy the file to `pmos/design-system/brand/icons.json` and edit it there.
|
|
@@ -125,6 +125,7 @@ PMOS suggests milestones for a program and checks them again when something chan
|
|
|
125
125
|
- Press the pencil to open the charter with the change filled in. Change it, then press **Save**.
|
|
126
126
|
- Press **✕** to drop a change. PMOS does not suggest it again unless its source changes.
|
|
127
127
|
- PMOS checks when a program is new, when an initiative joins or leaves, when a ◆ date moves, when a milestone's date comes, and every Monday from 09:00, inside your working hours. When nothing changed, nothing new shows.
|
|
128
|
+
- A program with no milestones and no suggestion yet shows a ✦ line above **Add the first milestone**: "PMOS can draft 3 first milestones from the initiatives' dates." Press ✓ and they show as suggestions with Keep and Decline, with Undo. Press ✕ to hide the line on this computer. The chat and `pmos program draft <id>` do the same.
|
|
128
129
|
- The charter says when PMOS last checked. Press the refresh icon beside it to check now.
|
|
129
130
|
- The review is a background run. It reads the initiatives' records, plan items and meeting notes, and Jira where your Claude Code settings allow it. Its only write is `pmos program suggest`, which files a suggestion for you to keep, change or drop. `PMOS_MS_REVIEW=off` turns the review off.
|
|
130
131
|
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* setTarget(runtime, root, target, { front, by }) · clearTarget(runtime, root, { by }) · undoTarget(runtime, root, { by })
|
|
8
8
|
* append-only `<runtime>/balance-targets.jsonl`; one line per write. Undo takes the last set or clear back.
|
|
9
9
|
* targetOf(runtime, root) → { target, front, at, by } | null
|
|
10
|
-
* ranked(root)
|
|
10
|
+
* ranked(root, { peek }) → [{ id, title, kind }] the live initiatives in Roadmap order (D105), finished ones left out;
|
|
11
|
+
* peek: the cached rows only (lib/initiative-rows.js peek), [] until a derivation has landed: the needs provider never derives
|
|
11
12
|
* gapOf(list, target, front) → { front: [...], mix: { kind: pct }, gap } gap = half the sum of |actual − target|, in points
|
|
12
13
|
* movesOf(list, target, front, { max }) → the best rank moves, at most `max` (2): an under-target initiative from below the front
|
|
13
14
|
* moved just above an over-target one in it. Each: { id, above, kind, pushes, gapAfter, closes, cli, undo }. Only moves that close gap.
|
|
@@ -104,10 +105,12 @@ function count(runtime, { days = 7, now = Date.now() } = {}) {
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
/** The live initiatives of a repository in Roadmap order (one ranked list, D105). Finished ones are left out. */
|
|
107
|
-
function ranked(root) {
|
|
108
|
+
function ranked(root, { peek = false } = {}) {
|
|
108
109
|
const rowsLib = require('./initiative-rows.js'), P = require('./placements.js'), PR = require('./plan-rules.js');
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
// the needs provider reads the cached rows only (peek), so the Today poll and `pmos today` never pay for a derivation
|
|
111
|
+
// (about 260 ms per record); the CLI derives now
|
|
112
|
+
const d = peek ? rowsLib.peek(root) : rowsLib.deriveSync(root);
|
|
113
|
+
if (!d || !d.ok) return [];
|
|
111
114
|
const rows = new Map(d.rows.map((r) => [r.id, r]));
|
|
112
115
|
const placed = P.readPlacements(root, { now: Date.now(), rules: PR.readRules(root), records: d.rows });
|
|
113
116
|
return placed.ranked.map((id) => rows.get(id)).filter((r) => r && !r.accepted && !r.stopped)
|
|
@@ -207,14 +210,18 @@ const runtimeNow = () => require('./state-root.js').defaultRoot({ env: process.e
|
|
|
207
210
|
function rowsFor(w, { lead } = {}) {
|
|
208
211
|
if (!lead || !w || !w.root) return [];
|
|
209
212
|
const saved = targetOf(runtimeNow(), w.root);
|
|
210
|
-
|
|
213
|
+
const list = ranked(w.root, { peek: true });
|
|
214
|
+
return saved ? rowsOf(w.id, saved, list) : proposalRowsOf(w.id, list);
|
|
211
215
|
}
|
|
212
216
|
function sig(w) {
|
|
213
217
|
let t = '-';
|
|
214
218
|
try { const st = fs.statSync(fileOf(runtimeNow())); t = st.size + ':' + st.mtimeMs; } catch { /* no target yet */ }
|
|
215
219
|
let p = '-';
|
|
216
220
|
try { p = String(require('./plan-ledgers.js').ledgerSig(w.root, 'placements')); } catch { /* no ledger */ }
|
|
217
|
-
|
|
221
|
+
// the cached rows' signature changes when a derivation lands, so Today recounts then
|
|
222
|
+
let c = '-';
|
|
223
|
+
try { c = String(require('./initiative-rows.js').cachedSig(w.root)); } catch { /* no cache yet */ }
|
|
224
|
+
return t + '|' + p + '|' + c + '|' + new Date().toISOString().slice(0, 10);
|
|
218
225
|
}
|
|
219
226
|
|
|
220
227
|
module.exports = { FILE, DEFAULT_FRONT, ROW_GAP, KIND, kinds: [KIND], fileOf, parseTarget, targetOf, setTarget, clearTarget, undoTarget, used, count,
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* design-boards.js — `pmos design boards`: the design-token check for canvas boards (*.dc.html), initiative text-token-guard.
|
|
3
|
+
*
|
|
4
|
+
* Why it exists. Wawan, 2026-11-25: "I thought we have design system which guard the design to make it consistent". The drift guard reads the
|
|
5
|
+
* repository only, so a canvas board never passed through it. The Goals boards (Exploring 3, page goalstack) wrote their own colour values
|
|
6
|
+
* into their :root block and hand-wrote text sizes off the type scale (12, 14, 22, 24, 28 px). A board can only be held to the system by a
|
|
7
|
+
* check that the design threads run on the board files before they publish, and by --fix, which puts a board back on the system.
|
|
8
|
+
*
|
|
9
|
+
* A board passes when:
|
|
10
|
+
* 1. every colour or shadow token its <style> blocks define has the design system's value for that theme (:root / [data-theme="light"]
|
|
11
|
+
* is light, [data-theme="dark"] is dark), and it defines no colour token the system does not have;
|
|
12
|
+
* 2. no style attribute and no other style rule holds a literal colour (#hex, rgb(), hsl());
|
|
13
|
+
* 3. every font-size reads a type token (var(--type-…)) or is one of the type scale's sizes (13, 15, 18, 26 px in PMOS Komorebi).
|
|
14
|
+
*
|
|
15
|
+
* check(html, sys) PURE → [{ kind, line, say }] · fix(html, sys) PURE → { html, changed } · systemFrom(dir) → sys
|
|
16
|
+
* run({ files, fix, say, dir }) → exit code (0 every board passes, 1 a board fails, 2 usage)
|
|
17
|
+
* sys = { light: { name: value }, dark: { name: value }, type: [{ name, size, line }] }. Token names have no leading --.
|
|
18
|
+
*/
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const COLOUR = /#[0-9a-fA-F]{3,8}\b|\b(?:rgba?|hsla?)\([^()]*\)/g;
|
|
23
|
+
const hasColour = (v) => { COLOUR.lastIndex = 0; const hit = COLOUR.test(String(v)); COLOUR.lastIndex = 0; return hit; };
|
|
24
|
+
const norm = (v) => String(v).toLowerCase().replace(/\s+/g, '');
|
|
25
|
+
|
|
26
|
+
/** The system's colour, shadow and type values from a design-system folder (brand/ and ui/ tokens.json). */
|
|
27
|
+
function systemFrom(dir) {
|
|
28
|
+
const read = (s) => JSON.parse(fs.readFileSync(path.join(dir, s, 'tokens.json'), 'utf8'));
|
|
29
|
+
const brand = read('brand'); const ui = read('ui');
|
|
30
|
+
const light = {}; const dark = {};
|
|
31
|
+
const put = (t) => {
|
|
32
|
+
if (t.value && typeof t.value === 'object') { light[t.name] = t.value.light; dark[t.name] = t.value.dark; } else { light[t.name] = t.value; dark[t.name] = t.value; }
|
|
33
|
+
};
|
|
34
|
+
for (const t of (brand.color && brand.color.tokens) || []) put(t);
|
|
35
|
+
for (const t of (ui.shadow && ui.shadow.tokens) || []) put(t);
|
|
36
|
+
// ground-night is the dark ground: a board's dark block uses it as --ground-night, so dark and light agree
|
|
37
|
+
const type = [];
|
|
38
|
+
for (const g of (ui.type && ui.type.groups) || []) for (const st of g.styles || []) {
|
|
39
|
+
if (st.family === 'mono') continue;
|
|
40
|
+
type.push({ name: 'type-' + st.name, size: parseFloat(st.fontSize), line: st.lineHeight });
|
|
41
|
+
}
|
|
42
|
+
type.sort((a, b) => a.size - b.size);
|
|
43
|
+
return { light, dark, type };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Which theme a token block's selector is: 'light', 'dark' or null (not a token block). */
|
|
47
|
+
function themeOf(selector) {
|
|
48
|
+
const s = String(selector);
|
|
49
|
+
if (/data-theme\s*=\s*["']?dark/.test(s)) return 'dark';
|
|
50
|
+
if (/^\s*:root\b|data-theme\s*=\s*["']?light/.test(s)) return 'light';
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const lineAt = (text, i) => text.slice(0, i).split('\n').length;
|
|
55
|
+
|
|
56
|
+
/** Every <style> block's rules: [{ selector, body, start (index of body in html) }]. Flat rules and @media are walked one level. */
|
|
57
|
+
function styleRules(html) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const m of html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)) {
|
|
60
|
+
const base = m.index + m[0].indexOf(m[1]);
|
|
61
|
+
const css = m[1];
|
|
62
|
+
const re = /([^{}]+)\{([^{}]*)\}/g;
|
|
63
|
+
let r;
|
|
64
|
+
while ((r = re.exec(css))) out.push({ selector: r[1].replace(/^[\s\S]*\{/, '').trim(), body: r[2], start: base + r.index + r[0].indexOf('{') + 1 });
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The nearest type step for a size in px: the scale is the system's, so a 12 px line becomes small (13) and 14 px becomes body (15). */
|
|
70
|
+
function stepFor(px, type) {
|
|
71
|
+
if (!type.length) return null;
|
|
72
|
+
let best = type[0];
|
|
73
|
+
for (const t of type) if (Math.abs(t.size - px) < Math.abs(best.size - px) || (Math.abs(t.size - px) === Math.abs(best.size - px) && t.size > best.size)) best = t;
|
|
74
|
+
return best;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Findings for one board. PURE. */
|
|
78
|
+
function check(html, sys) {
|
|
79
|
+
const out = [];
|
|
80
|
+
const scale = new Set(sys.type.map((t) => t.size));
|
|
81
|
+
const known = new Set(Object.keys(sys.light));
|
|
82
|
+
const tokenSpans = [];
|
|
83
|
+
for (const r of styleRules(html)) {
|
|
84
|
+
const theme = themeOf(r.selector);
|
|
85
|
+
if (theme) tokenSpans.push([r.start, r.start + r.body.length]);
|
|
86
|
+
for (const d of r.body.matchAll(/(--?[a-zA-Z][a-zA-Z0-9-]*)\s*:\s*([^;]+)/g)) {
|
|
87
|
+
const prop = d[1]; const value = d[2].trim(); const line = lineAt(html, r.start + d.index);
|
|
88
|
+
if (prop.startsWith('--')) {
|
|
89
|
+
const name = prop.slice(2);
|
|
90
|
+
if (!theme) { if (hasColour(value)) out.push({ kind: 'colour', line, say: `${prop} is defined outside the board's token block with a colour (${value})` }); continue; }
|
|
91
|
+
if (known.has(name)) {
|
|
92
|
+
const want = sys[theme][name];
|
|
93
|
+
if (want != null && norm(want) !== norm(value)) out.push({ kind: 'token', line, say: `${prop} (${theme}) is ${value}; the design system's value is ${want}` });
|
|
94
|
+
} else if (hasColour(value)) out.push({ kind: 'token', line, say: `${prop} is a colour token the design system does not have (${value})` });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (!theme && hasColour(value.replace(/var\([^()]*\)/g, ''))) out.push({ kind: 'colour', line, say: `${prop}: ${value} is a literal colour; read a token (--ink, --muted, --blue, --alert …)` });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const inToken = (i) => tokenSpans.some(([a, b]) => i >= a && i < b);
|
|
101
|
+
for (const m of html.matchAll(/\bstyle\s*=\s*"([^"]*)"/g)) {
|
|
102
|
+
const at = m.index; const v = m[1];
|
|
103
|
+
if (inToken(at)) continue;
|
|
104
|
+
const line = lineAt(html, at);
|
|
105
|
+
for (const c of v.replace(/var\([^()]*\)/g, '').matchAll(COLOUR)) out.push({ kind: 'colour', line, say: `literal colour ${c[0]} in a style attribute; read a token` });
|
|
106
|
+
}
|
|
107
|
+
for (const m of html.matchAll(/font-size\s*:\s*([^;"}]+)/g)) {
|
|
108
|
+
if (inToken(m.index)) continue;
|
|
109
|
+
const v = m[1].trim();
|
|
110
|
+
if (/^var\(--type-/.test(v) || /^(inherit|initial|unset|100%|1em)$/.test(v)) continue;
|
|
111
|
+
const px = v.match(/^(\d*\.?\d+)px$/);
|
|
112
|
+
if (px && scale.has(Number(px[1]))) continue;
|
|
113
|
+
const step = px ? stepFor(Number(px[1]), sys.type) : null;
|
|
114
|
+
out.push({ kind: 'size', line: lineAt(html, m.index), say: `font-size ${v} is not on the type scale (${[...scale].join(', ')} px)${step ? `; nearest is var(--${step.name}) ${step.size}px` : ''}` });
|
|
115
|
+
}
|
|
116
|
+
return out.sort((a, b) => a.line - b.line);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Put a board back on the system. PURE. Token blocks take the system's values (and gain the --type-* tokens); every font-size in px
|
|
120
|
+
* becomes the nearest type token, and a line-height in the same declaration list becomes that step's. Literal colours elsewhere are left
|
|
121
|
+
* for a person: their meaning (ink, muted, alert) cannot be guessed. */
|
|
122
|
+
function fix(html, sys) {
|
|
123
|
+
let out = html;
|
|
124
|
+
// 1. token blocks
|
|
125
|
+
const rules = styleRules(out).filter((r) => themeOf(r.selector)).sort((a, b) => b.start - a.start);
|
|
126
|
+
for (const r of rules) {
|
|
127
|
+
const theme = themeOf(r.selector);
|
|
128
|
+
let body = r.body.replace(/(--([a-zA-Z][a-zA-Z0-9-]*))\s*:\s*([^;]+)/g, (all, prop, name, value) => {
|
|
129
|
+
const want = sys[theme][name];
|
|
130
|
+
return want != null && norm(want) !== norm(value) ? `${prop}:${want}` : all;
|
|
131
|
+
});
|
|
132
|
+
if (theme === 'light' && /^\s*:root\b/.test(r.selector) && sys.type.length && !/--type-/.test(body) && /--font-sans|--ink/.test(body)) {
|
|
133
|
+
body = body.replace(/;?\s*$/, '') + ';' + sys.type.map((t) => `--${t.name}:${t.size}px;--${t.name}-line:${t.line}`).join(';');
|
|
134
|
+
}
|
|
135
|
+
out = out.slice(0, r.start) + body + out.slice(r.start + r.body.length);
|
|
136
|
+
}
|
|
137
|
+
// 2. font sizes, in style attributes and style rules alike
|
|
138
|
+
const decl = (list) => {
|
|
139
|
+
let lineStep = null;
|
|
140
|
+
let next = list.replace(/font-size\s*:\s*(\d*\.?\d+)px/g, (all, n) => {
|
|
141
|
+
const step = stepFor(Number(n), sys.type);
|
|
142
|
+
if (!step) return all;
|
|
143
|
+
if (Number(n) !== step.size) lineStep = step;
|
|
144
|
+
return `font-size:var(--${step.name})`;
|
|
145
|
+
});
|
|
146
|
+
if (lineStep) next = next.replace(/line-height\s*:\s*\d*\.?\d+px/g, `line-height:var(--${lineStep.name}-line)`);
|
|
147
|
+
return next;
|
|
148
|
+
};
|
|
149
|
+
out = out.replace(/\bstyle\s*=\s*"([^"]*)"/g, (all, v) => `style="${decl(v)}"`);
|
|
150
|
+
out = out.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, (block) => block.replace(/\{([^{}]*)\}/g, (all, body) => `{${decl(body)}}`));
|
|
151
|
+
return { html: out, changed: out !== html };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function listFiles(paths) {
|
|
155
|
+
const out = [];
|
|
156
|
+
for (const p of paths) {
|
|
157
|
+
if (!fs.existsSync(p)) { out.push({ missing: p }); continue; }
|
|
158
|
+
if (fs.statSync(p).isDirectory()) { for (const f of fs.readdirSync(p).sort()) if (f.endsWith('.dc.html')) out.push({ file: path.join(p, f) }); } else out.push({ file: p });
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function run({ files, write = false, say = (s) => console.log(s), dir = path.join(__dirname, '..', 'design-system') } = {}) {
|
|
164
|
+
if (!files || !files.length) { say('✗ usage: pmos design boards <board.dc.html | folder>… [--fix]'); return 2; }
|
|
165
|
+
const sys = systemFrom(dir);
|
|
166
|
+
let failed = 0; let fixed = 0;
|
|
167
|
+
for (const f of listFiles(files)) {
|
|
168
|
+
if (f.missing) { say(`✗ ${f.missing}: no such file or folder`); failed++; continue; }
|
|
169
|
+
let html = fs.readFileSync(f.file, 'utf8');
|
|
170
|
+
if (write) { const r = fix(html, sys); if (r.changed) { fs.writeFileSync(f.file, r.html); html = r.html; fixed++; } }
|
|
171
|
+
const found = check(html, sys);
|
|
172
|
+
if (!found.length) { say(`✓ ${f.file}`); continue; }
|
|
173
|
+
failed++;
|
|
174
|
+
say(`✗ ${f.file}: ${found.length} place${found.length === 1 ? '' : 's'} outside the design system`);
|
|
175
|
+
for (const x of found.slice(0, 12)) say(` line ${x.line}: ${x.say}`);
|
|
176
|
+
if (found.length > 12) say(` … ${found.length - 12} more`);
|
|
177
|
+
}
|
|
178
|
+
if (write) say(`${fixed} board${fixed === 1 ? '' : 's'} changed by --fix.`);
|
|
179
|
+
return failed ? 1 : 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = { systemFrom, themeOf, styleRules, stepFor, check, fix, run };
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* --gate exit 1 when a count rose against --base
|
|
14
14
|
* --github print each new bypass as a GitHub warning on its file and line (the CI step uses it)
|
|
15
15
|
* --pages the older view instead: each page's share of system classes and its own CSS (a measure only)
|
|
16
|
+
* --block-text exit 1 when an added line gives text a colour or size the design system does not own (CI blocks on it; the other kinds warn)
|
|
17
|
+
*
|
|
18
|
+
* pmos design boards <board.dc.html | folder>… [--fix] (initiative text-token-guard, lib/design-boards.js) a canvas board's colour tokens,
|
|
19
|
+
* literal colours and text sizes against the design system. Design threads run it on every board before they publish.
|
|
16
20
|
*
|
|
17
21
|
* pmos design swap [--write] (initiative token-swap-same-value, lib/design-swap.js) each fixed spacing or corner value in a scanned
|
|
18
22
|
* stylesheet that equals a design token: counted per file, or with --write replaced by that token. Nothing on screen moves.
|
|
@@ -23,10 +27,11 @@ const fs = require('fs');
|
|
|
23
27
|
const path = require('path');
|
|
24
28
|
const D = require('./design-drift.js');
|
|
25
29
|
|
|
26
|
-
const COMMANDS = { design: ['drift', 'swap'] };
|
|
30
|
+
const COMMANDS = { design: ['drift', 'swap', 'boards'] };
|
|
27
31
|
const USAGE = [
|
|
28
32
|
'usage: pmos design drift — every place your styles and scripts do not read a design token, and which ones a change adds',
|
|
29
|
-
' pmos design drift [--ref <ref>] [--base <ref>|week] [--weeks <n>] [--json] [--write] [--gate] [--github] [--pages]',
|
|
33
|
+
' pmos design drift [--ref <ref>] [--base <ref>|week] [--weeks <n>] [--json] [--write] [--gate] [--github] [--pages] [--block-text]',
|
|
34
|
+
' --block-text fail when a change adds a text colour or size outside the design system (literal colour or text size, or a colour token defined outside the system sheets)',
|
|
30
35
|
' --ref <ref> the commit to count (default HEAD; WORKTREE reads the files on disk)',
|
|
31
36
|
' --base <ref> compare with this commit and name each added line that bypasses a token; "week" is the last commit a week earlier',
|
|
32
37
|
' --weeks <n> the total at the end of each of the last n weeks (1 to 12)',
|
|
@@ -35,10 +40,11 @@ const USAGE = [
|
|
|
35
40
|
' --github print each new bypass as a GitHub warning on its line',
|
|
36
41
|
' --pages each page\'s share of system classes instead (a measure only)',
|
|
37
42
|
'It reads git only. A product sets its files and system sheets in design-drift.json in its design-system folder.',
|
|
43
|
+
' pmos design boards <board.dc.html | folder>… [--fix] check canvas boards: colour tokens with the system\'s values, no literal colours, text sizes on the type scale; --fix puts a board back on the system',
|
|
38
44
|
' pmos design swap [--write] each fixed spacing or corner value that equals a design token: counted, or with --write replaced by the token',
|
|
39
45
|
];
|
|
40
|
-
const FLAGS = new Set(['ref', 'base', 'weeks', 'json', 'write', 'gate', 'repo', 'github', 'pages']);
|
|
41
|
-
const BOOL = new Set(['json', 'write', 'gate', 'github', 'pages']);
|
|
46
|
+
const FLAGS = new Set(['ref', 'base', 'weeks', 'json', 'write', 'gate', 'repo', 'github', 'pages', 'block-text']);
|
|
47
|
+
const BOOL = new Set(['json', 'write', 'gate', 'github', 'pages', 'block-text', 'fix']);
|
|
42
48
|
|
|
43
49
|
function parse(args) {
|
|
44
50
|
const pos = [], flags = {};
|
|
@@ -64,6 +70,11 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
|
|
|
64
70
|
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 2; }
|
|
65
71
|
if (!COMMANDS.design.includes(sub)) { say(`unknown design command "${sub}". Use one of: ${COMMANDS.design.join(', ')}`); return 2; }
|
|
66
72
|
const { pos, flags } = parse(args.slice(1));
|
|
73
|
+
if (sub === 'boards') {
|
|
74
|
+
const bad = Object.keys(flags).filter((k) => k !== 'fix');
|
|
75
|
+
if (!pos.length || bad.length) { say('✗ usage: pmos design boards <board.dc.html | folder>… [--fix]'); return 2; }
|
|
76
|
+
return require('./design-boards.js').run({ files: pos.map((p) => path.resolve(cwd, p)), write: 'fix' in flags, say });
|
|
77
|
+
}
|
|
67
78
|
if (sub === 'swap') {
|
|
68
79
|
const bad = Object.keys(flags).filter((k) => k !== 'write' && k !== 'repo');
|
|
69
80
|
if (pos.length || bad.length) { say('✗ usage: pmos design swap [--write]'); return 2; }
|
|
@@ -79,6 +90,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
|
|
|
79
90
|
if (!Number.isInteger(weeks) || weeks < 0 || weeks > 12) { say('✗ --weeks is a whole number from 1 to 12'); return 2; }
|
|
80
91
|
if (flags.gate && !flags.base) { say('✗ --gate needs --base: it fails only a count that rose against an earlier commit'); return 2; }
|
|
81
92
|
if (flags.github && !flags.base) { say('✗ --github needs --base: it marks only the lines a change added'); return 2; }
|
|
93
|
+
if (flags['block-text'] && !flags.base) { say('✗ --block-text needs --base: it fails only the text colours and sizes a change added'); return 2; }
|
|
82
94
|
|
|
83
95
|
const repo = repoRoot(flags.repo ? path.resolve(cwd, flags.repo) : cwd);
|
|
84
96
|
if (!repo) { say('✗ this is not a git repository. Run pmos design drift in your product\'s repository.'); return 1; }
|
|
@@ -160,10 +172,16 @@ function tokens({ repo, ref, base, worktree, weeks, flags, say, now }) {
|
|
|
160
172
|
}
|
|
161
173
|
if (trend) say('By week: ' + trend.map((t) => `${t.week} ${t.total == null ? '–' : n(t.total)}`).join(' · '));
|
|
162
174
|
}
|
|
175
|
+
const blocked = flags['block-text'] && findings ? D.textBlock(findings, head.colourTokens) : [];
|
|
176
|
+
const isBlocked = (g, x) => flags['block-text'] && D.isTextFinding(x, head.colourTokens);
|
|
163
177
|
if (flags.github && findings) {
|
|
164
178
|
for (const g of findings) {
|
|
165
179
|
if (!g.lines.length) { say(`::warning file=${g.file},title=Design tokens::${D.KIND_LABEL[g.kind]} count ${g.before} → ${g.after}`); continue; }
|
|
166
|
-
for (const x of g.lines)
|
|
180
|
+
for (const x of g.lines) {
|
|
181
|
+
const level = isBlocked(g, x) ? 'error' : 'warning';
|
|
182
|
+
const why = level === 'error' ? ' (text colour or size outside the design system: this fails the check)' : '';
|
|
183
|
+
say(`::${level} file=${g.file},line=${x.line},title=Design tokens::${D.findingSay(x).replace(/[\r\n%]/g, ' ')}${why}`);
|
|
184
|
+
}
|
|
167
185
|
}
|
|
168
186
|
if (!findings.length) say(`No new token bypasses against ${before.commit}.`);
|
|
169
187
|
}
|
|
@@ -173,6 +191,11 @@ function tokens({ repo, ref, base, worktree, weeks, flags, say, now }) {
|
|
|
173
191
|
fs.writeFileSync(file, D.tokensMd({ date, ref, now: head, base, baseCommit: before && before.commit, findings, trend, cmd }));
|
|
174
192
|
if (!flags.json && !flags.github) say('Report: ' + path.relative(repo, file));
|
|
175
193
|
}
|
|
194
|
+
if (blocked.length) {
|
|
195
|
+
const n1 = blocked.reduce((a, g) => a + g.lines.length, 0);
|
|
196
|
+
say(`✗ ${n1} added line${n1 === 1 ? '' : 's'} give text a colour or size outside the design system. Read a token instead: --ink, --muted, --blue, --alert for colour; --type-small, --type-body, --type-heading, --type-title for size. A new colour or size goes into design-system/brand or design-system/ui first.`);
|
|
197
|
+
return 1;
|
|
198
|
+
}
|
|
176
199
|
return flags.gate && findings && findings.length ? 1 : 0;
|
|
177
200
|
}
|
|
178
201
|
|
|
@@ -583,7 +583,31 @@ function bypasses(repo, ref, { files: given } = {}) {
|
|
|
583
583
|
files.push({ file: f, counts, findings });
|
|
584
584
|
}
|
|
585
585
|
const commit = given ? null : (isWorktree(ref) ? 'WORKTREE' : (gitOut(repo, ['rev-parse', '--short', ref]) || '').trim() || null);
|
|
586
|
-
|
|
586
|
+
const colourTokens = [...tokens.entries()].filter(([, v]) => { COLOUR.lastIndex = 0; return COLOUR.test(v); }).map(([n]) => n);
|
|
587
|
+
COLOUR.lastIndex = 0;
|
|
588
|
+
return { ref: isWorktree(ref) ? 'WORKTREE' : ref, commit, config: cfg, tokens: tokens.size, colourTokens, files, totals, total: Object.values(totals).reduce((a, b) => a + b, 0), swaps };
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// ── the text block (Wawan 2026-11-25: "I thought we have design system which guard the design to make it consistent") ─────────────────
|
|
592
|
+
// The ratchet above only warns. These added lines fail the check, because each one gives text a colour or a size the design system does not
|
|
593
|
+
// own: a literal colour, a literal text size, an inline style with either, and a token that defines a colour outside the system sheets
|
|
594
|
+
// (a second palette, such as --nz-ink, or a page giving --ink its own value).
|
|
595
|
+
/** Is one finding a text colour or size outside the system? colourTokens = the system's colour token names (--ink …). PURE. */
|
|
596
|
+
function isTextFinding(x, colourTokens) {
|
|
597
|
+
if (x.kind === 'colour' || x.kind === 'size') return true;
|
|
598
|
+
const hasColour = (v) => { COLOUR.lastIndex = 0; const hit = COLOUR.test(String(v)); COLOUR.lastIndex = 0; return hit; };
|
|
599
|
+
if (x.kind === 'tokenDef') return hasColour(x.value) || new Set(colourTokens || []).has(x.prop);
|
|
600
|
+
if (x.kind === 'inline') return hasColour(x.value) || /font-size\s*:\s*-?\d*\.?\d+(px|rem|em)/.test(String(x.value));
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
/** The ratchet's findings that the text block fails: [{ file, kind, lines }] with only the text lines kept. PURE. */
|
|
604
|
+
function textBlock(findings, colourTokens) {
|
|
605
|
+
const out = [];
|
|
606
|
+
for (const g of findings || []) {
|
|
607
|
+
const lines = g.lines.filter((x) => isTextFinding(x, colourTokens));
|
|
608
|
+
if (lines.length) out.push({ ...g, lines });
|
|
609
|
+
}
|
|
610
|
+
return out;
|
|
587
611
|
}
|
|
588
612
|
|
|
589
613
|
/** The lines a commit range added to one file (base → head; head WORKTREE compares with the files on disk). */
|
|
@@ -668,6 +692,6 @@ function tokenTrend(repo, ref, weeks, { now = Date.now() } = {}) {
|
|
|
668
692
|
module.exports = {
|
|
669
693
|
DEFAULTS, CONFIG_PLACES, REBUILT_SHARE, REBUILT_SHRINK,
|
|
670
694
|
rulesOf, selectorClasses, splitSelectors, compoundsOf, systemOf, classesOf, importsOf, colourCount, globRe, resolveRef,
|
|
671
|
-
KINDS, KIND_LABEL, dropVars, tokensOf, tokenFor, cssBypasses, scriptBypasses, systemClassesAll, readMany, bypasses, addedLines, ratchet, findingSay, tokensMd, tokenTrend,
|
|
695
|
+
KINDS, KIND_LABEL, isTextFinding, textBlock, dropVars, tokensOf, tokenFor, cssBypasses, scriptBypasses, systemClassesAll, readMany, bypasses, addedLines, ratchet, findingSay, tokensMd, tokenTrend,
|
|
672
696
|
configAt, readerOf, measure, compare, queue, meanShare, trend, summary, reportMd, gitOut,
|
|
673
697
|
};
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
{"id": "try", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Try what shipped", "say": "The changes your recent updates brought, how to try each, and your answer.", "cmd": "/try", "verb": "try"},
|
|
62
62
|
{"id": "rules", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Rules PMOS learned", "say": "The standing rules PMOS learned from your corrections, and edit or retire one.", "cmd": "/rules", "verb": "rules"},
|
|
63
63
|
{"id": "line", "audience": "user", "status": "ga", "group": "Catch up", "name": "Where each initiative stands", "say": "Days in its stage, what is missing, the next move, and whether it is stuck.", "cmd": "/line", "verb": "line", "hint": "<initiative>", "ask": ["initiative"]},
|
|
64
|
+
{"id": "knowledge", "audience": "user", "status": "ga", "group": "Your product", "name": "Only one person knows this", "say": "The areas only one person touched in 6 months, and a pairing or write-up before their leave.", "cmd": "/knowledge", "verb": "knowledge"},
|
|
64
65
|
{"id": "hire", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The next hire", "say": "The role your open work most needs, and a one-page role brief to edit.", "cmd": "/hire", "verb": "hire"},
|
|
65
66
|
{"id": "compare", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Compare two items", "say": "Two items or two versions of one file side by side, with the differences marked.", "cmd": "/compare", "verb": "compare", "hint": "<item> <item>", "place": "board"},
|
|
66
67
|
{"id": "experiment", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Copy and layout tests", "say": "Try new words or a new layout on an initiative: PMOS drafts the test, you start it, one line says how sure the winner is.", "cmd": "/experiment", "verb": "experiment", "hint": "draft <initiative> \"<what to try>\""},
|
|
@@ -102,6 +103,7 @@
|
|
|
102
103
|
{"id": "impact", "audience": "agent", "status": "ga", "group": "Your product", "name": "Impact findings", "say": "An impact run files a finding for you to check.", "cmd": "/impact", "verb": "impact"},
|
|
103
104
|
{"id": "coredoc", "audience": "agent", "status": "ga", "group": "Plan and decide", "name": "Core document drafts", "say": "A run writes one draft of a core document; you issue it on the page.", "cmd": "/coredoc", "verb": "coredoc"},
|
|
104
105
|
{"id": "mcp", "audience": "agent", "status": "ga", "group": "Find your way", "name": "PMOS cards for other agents", "say": "PMOS cards for another agent, over MCP.", "cmd": "/mcp-cards", "verb": "mcp"},
|
|
106
|
+
{"id": "screens", "audience": "user", "status": "beta", "group": "Your product", "name": "Screen map", "say": "Every screen of your product and the flows between them, with duplicates, dead ends and deep flows marked.", "cmd": "/screens", "verb": "screens", "sub": "show"},
|
|
105
107
|
{"id": "raid", "audience": "user", "status": "beta", "group": "Catch up", "name": "RAID list", "say": "Risks, assumptions, late tasks and dependencies of one initiative, with owner, next date and what has gone stale.", "cmd": "/raid", "verb": "raid", "hint": "show <initiative>"}
|
|
106
108
|
]
|
|
107
109
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* knowledge-cli.js — `pmos knowledge`: the areas only one person knows (initiative one-person-knows, job #1899, idea A391).
|
|
3
|
+
* The verb module lib/pmos-verbs.js names; the rules, the ledger and the CLI itself are lib/one-person-knows.js. */
|
|
4
|
+
const K = require('./one-person-knows.js');
|
|
5
|
+
|
|
6
|
+
module.exports = { run: K.run, COMMANDS: K.COMMANDS, USAGE: K.USAGE };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* on-item-routes.js — what PMOS can do for the open initiative or program, shown on it with no typed ask (job #1986, surface-on-item;
|
|
3
|
+
* lib/on-item.js).
|
|
4
|
+
*
|
|
5
|
+
* GET /api/on-item?ws=<id>&ini=<id>&stage=<name> → { ok, signoffs, numbers, press } read only
|
|
6
|
+
* POST /api/on-item/evidence { ws, ini, id, ref, quote } | { ws, ini, id, undo: true, before } a picked line becomes the sign-off's source
|
|
7
|
+
* POST /api/on-item/numbers { ws, ini, baseline, min_change, weekly_traffic } | { ws, ini, undo: true, before }
|
|
8
|
+
* POST /api/on-item/press-release { ws, ini } | { ws, ini, undo: true } pmos press-release in the background, or stop it
|
|
9
|
+
* GET /api/on-item/program-drafts?program=<id> → { ok, n } n: PMOS's first milestones for a program with none and no open suggestion
|
|
10
|
+
* POST /api/on-item/program-drafts { program } | { program, undo: true } pmos program draft, or an empty review (none stays open)
|
|
11
|
+
*
|
|
12
|
+
* lib/routes-stage-signoffs.js owns the prefix and hands it here. Every POST is a page press (lib/pm-guard.js requirePagePress). Nothing is sent. */
|
|
13
|
+
const OI = require('./on-item.js');
|
|
14
|
+
|
|
15
|
+
let spawnForTest = null;
|
|
16
|
+
/** Tests stub the press release's background run. */
|
|
17
|
+
function setSpawn(fn) { spawnForTest = fn || null; }
|
|
18
|
+
|
|
19
|
+
async function handle(req, res, url, ctx) {
|
|
20
|
+
const p = url.pathname;
|
|
21
|
+
if (p !== '/api/on-item' && !p.startsWith('/api/on-item/')) return false;
|
|
22
|
+
const bad = (error, code) => { ctx.json(res, { ok: false, error }, code || 400); return true; };
|
|
23
|
+
let body = {};
|
|
24
|
+
if (req.method === 'POST') {
|
|
25
|
+
const got = await ctx.readJson(req);
|
|
26
|
+
if (!got.ok) return bad('invalid JSON body');
|
|
27
|
+
body = got.body || {};
|
|
28
|
+
const g = require('./pm-guard.js').requirePagePress(req, body);
|
|
29
|
+
if (!g.ok) return bad(g.error, g.status);
|
|
30
|
+
} else if (req.method !== 'GET') return bad('GET or POST only', 405);
|
|
31
|
+
const q = (k) => (req.method === 'POST' ? body[k] : url.searchParams.get(k));
|
|
32
|
+
|
|
33
|
+
if (p === '/api/on-item/program-drafts') {
|
|
34
|
+
const id = String(q('program') || '');
|
|
35
|
+
const prog = (require('./routes-programs.js').all(ctx) || []).find((x) => x.id === id);
|
|
36
|
+
if (!prog) return bad('no such program', 404);
|
|
37
|
+
let w = null; try { w = ctx.getWs(prog.home || null); } catch { w = null; }
|
|
38
|
+
if (!w || !w.root) return bad('the charter of this program is in a product this computer does not have', 404);
|
|
39
|
+
const empty = !(prog.milestones || []).length && !((prog.review && prog.review.open) || []).length;
|
|
40
|
+
if (req.method === 'GET') { ctx.json(res, { ok: true, n: empty ? OI.programDrafts(w.root, id).n : 0 }); return true; }
|
|
41
|
+
if (body.undo === true) { ctx.json(res, OI.undoProgramDrafts(w.root, id)); return true; }
|
|
42
|
+
if (!empty) return bad('this program has milestones or suggestions already');
|
|
43
|
+
const r = OI.fileProgramDrafts(w.root, id);
|
|
44
|
+
ctx.json(res, r, r.ok ? 200 : 400);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let w = null; try { w = ctx.getWs(q('ws') || null); } catch { w = null; }
|
|
49
|
+
if (!w || !w.root) return bad('no such workspace', 404);
|
|
50
|
+
const ini = String(q('ini') || '');
|
|
51
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(ini)) return bad('name the initiative');
|
|
52
|
+
|
|
53
|
+
if (p === '/api/on-item') {
|
|
54
|
+
if (req.method !== 'GET') return bad('GET only', 405);
|
|
55
|
+
ctx.json(res, OI.readOf(w.root, ini, { stage: url.searchParams.get('stage') || '' }));
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (req.method !== 'POST') return bad('POST only', 405);
|
|
59
|
+
let r;
|
|
60
|
+
if (p === '/api/on-item/evidence') r = body.undo === true ? OI.undoEvidence(w.root, { id: body.id, before: body.before || null }) : OI.setEvidence(w.root, { ini, id: body.id, ref: body.ref, quote: body.quote });
|
|
61
|
+
else if (p === '/api/on-item/numbers') r = body.undo === true ? OI.undoNumbers(w.root, ini, body.before || {}) : OI.setNumbers(w.root, ini, body);
|
|
62
|
+
else if (p === '/api/on-item/press-release') r = body.undo === true ? OI.stopPress(w.root, ini) : OI.startPress(w.root, ini, { spawn: spawnForTest });
|
|
63
|
+
else return bad('no such route', 404);
|
|
64
|
+
ctx.json(res, r, r.ok ? 200 : 400);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { prefixes: ['/api/on-item'], handle, setSpawn };
|