create-pmos 0.685.0 → 0.687.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 +26 -14
- 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 +25 -0
- package/workspace/guide/cli.md +10 -0
- package/workspace/lib/design-drift.js +4 -0
- package/workspace/lib/page-health.js +164 -0
- package/workspace/lib/pages-cli.js +99 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/test-lists/page-fix-count-first.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.687.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": {
|
|
@@ -33,6 +33,31 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.687.0",
|
|
38
|
+
"at": "2026-11-22T09:02:57.474Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1507,
|
|
43
|
+
"t": "List pmos jira digest in the CLI guide",
|
|
44
|
+
"s": "List pmos jira digest in the CLI guide",
|
|
45
|
+
"k": "fix"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1508,
|
|
49
|
+
"t": "Design drift counts a .style.cssText assignment once",
|
|
50
|
+
"s": "Design drift counts a .style.cssText assignment once",
|
|
51
|
+
"k": "fix"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"n": 1512,
|
|
55
|
+
"t": "Pmos pages shows each page's fix count before new features",
|
|
56
|
+
"s": "Pmos pages shows each page's fix count before new features",
|
|
57
|
+
"k": "new"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
},
|
|
36
61
|
{
|
|
37
62
|
"v": "0.685.0",
|
|
38
63
|
"at": "2026-11-22T08:45:20.465Z",
|
|
@@ -375,19 +400,6 @@
|
|
|
375
400
|
"k": "new"
|
|
376
401
|
}
|
|
377
402
|
]
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
"v": "0.649.0",
|
|
381
|
-
"at": "2026-11-20T06:16:36.793Z",
|
|
382
|
-
"f": 4,
|
|
383
|
-
"prs": [
|
|
384
|
-
{
|
|
385
|
-
"n": 1431,
|
|
386
|
-
"t": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
|
|
387
|
-
"s": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
|
|
388
|
-
"k": "new"
|
|
389
|
-
}
|
|
390
|
-
]
|
|
391
403
|
}
|
|
392
404
|
]
|
|
393
405
|
}
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T09:02:53Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T09:02:53Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T09:02:53Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.687.0",
|
|
4
|
+
"at": "2026-11-22T09:02:57.474Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1507,
|
|
9
|
+
"t": "List pmos jira digest in the CLI guide",
|
|
10
|
+
"s": "List pmos jira digest in the CLI guide",
|
|
11
|
+
"k": "fix"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1508,
|
|
15
|
+
"t": "Design drift counts a .style.cssText assignment once",
|
|
16
|
+
"s": "Design drift counts a .style.cssText assignment once",
|
|
17
|
+
"k": "fix"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"n": 1512,
|
|
21
|
+
"t": "Pmos pages shows each page's fix count before new features",
|
|
22
|
+
"s": "Pmos pages shows each page's fix count before new features",
|
|
23
|
+
"k": "new"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
2
27
|
{
|
|
3
28
|
"v": "0.685.0",
|
|
4
29
|
"at": "2026-11-22T08:45:20.465Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -343,6 +343,15 @@ The aim: change one token and every page follows. Each place this command counts
|
|
|
343
343
|
- `--pages` shows the older measure instead: for each page, the share of its classes that the system defines and its own CSS rules.
|
|
344
344
|
- 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"] }`.
|
|
345
345
|
|
|
346
|
+
### pmos pages: fix a page before you add to it
|
|
347
|
+
|
|
348
|
+
A page that keeps breaking should get fixed before it gets a new feature. This command shows which pages keep breaking.
|
|
349
|
+
|
|
350
|
+
- `pmos pages` (or `pmos pages show`): each page's fixes, reverts and restores in the last 14 days, and the share of fix commits among all page commits. A page at or over the limit (3) is marked ●. A page is its HTML file, its own sheets and the scripts it loads. A file that half the pages or more load is counted once, as shared code. It reads git only.
|
|
351
|
+
- `--json` gives the same numbers as JSON. `--count` prints only the number of pages over the limit.
|
|
352
|
+
- `pmos pages check --base <ref>`: when the change since `<ref>` has a `feat` commit and touches a page over the limit, it names that page. `--feature` treats the change as a feature without a `feat` commit. `--gate` exits 1 when it names a page.
|
|
353
|
+
- The pages come from the `pages` globs in `design-drift.json`. A product sets `window_days` and `limit` in `page-health.json` in the same design-system folder, for example `{ "window_days": 14, "limit": 3 }`.
|
|
354
|
+
|
|
346
355
|
## Initiatives and the Board
|
|
347
356
|
|
|
348
357
|
### pmos initiative
|
|
@@ -652,6 +661,7 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
|
|
|
652
661
|
- `pmos jira guesses <initiative> [--from <file|->]`
|
|
653
662
|
- `pmos jira answer <initiative> <ticket> <n> --text "<answer>"` or `--keep-default`
|
|
654
663
|
- `pmos jira criteria <initiative>`: the done-test checks each ticket carries as acceptance criteria, and the checks on no ticket
|
|
664
|
+
- `pmos jira digest [--since <YYYY-MM-DD or time>]`: what moved in the tracker since the last working day, who moved it, the moved tickets with no task in PMOS, and what is worth a question (blocked, reopened, nobody assigned, stuck, not in the last read). It reads only the stored Jira reads.
|
|
655
665
|
|
|
656
666
|
Every command takes `--json` and `--root <dir>`.
|
|
657
667
|
|
|
@@ -506,7 +506,11 @@ function scriptBypasses(src, systemAll) {
|
|
|
506
506
|
const out = [];
|
|
507
507
|
String(src || '').split('\n').forEach((text, i) => {
|
|
508
508
|
const line = i + 1;
|
|
509
|
+
const seen = new Set(); // two patterns can match one value (.style.cssText = '…' is both a .style.x and a cssText): count it once
|
|
509
510
|
for (const re of INLINE) for (const m of text.matchAll(re)) {
|
|
511
|
+
const at = m.index + m[0].lastIndexOf(m[1]);
|
|
512
|
+
if (seen.has(at)) continue;
|
|
513
|
+
seen.add(at);
|
|
510
514
|
const v = dropVars(m[1].replace(/\$\{[^}]*\}/g, ''));
|
|
511
515
|
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
516
|
COLOUR.lastIndex = 0;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* page-health.js — each page's recent fix count, so a page that keeps breaking is fixed before it gets new features
|
|
3
|
+
* (initiative page-fix-count-first, bet A462). It reads git only: no checkout, no build, no browser, no model, and writes nothing.
|
|
4
|
+
* lib/pages-cli.js is `pmos pages`.
|
|
5
|
+
*
|
|
6
|
+
* PAGES. A page is an HTML file matched by the product's page globs: the `pages` of design-drift.json, the setting the design drift
|
|
7
|
+
* guard reads (PMOS-self defaults to workspace/public/*.html). Its files are the page, the sheets it links and the scripts it loads,
|
|
8
|
+
* followed through their imports. A file that half or more of the pages load (with 4 pages or more) is SHARED: a commit to it counts
|
|
9
|
+
* once, under `shared`, and on no page, so each page's number is about that page.
|
|
10
|
+
*
|
|
11
|
+
* KINDS, from the commit subject: fix / hotfix → fix · revert / Revert "…" → revert · restore, restores, restored → restore ·
|
|
12
|
+
* feat → feature · anything else → other. Restore wins over feature: "feat: restore the old row" puts something back.
|
|
13
|
+
*
|
|
14
|
+
* OVER. A page is over when fix + revert + restore in the window reach the limit. Defaults: 14 days, limit 3. A product sets
|
|
15
|
+
* { "window_days": 14, "limit": 3 } in page-health.json in its design-system folder (the same places as design-drift.json).
|
|
16
|
+
*
|
|
17
|
+
* kindOf(subject) PURE · fixCount(row) PURE · tally(pages, commits, opts) PURE · findings(rows, change) PURE
|
|
18
|
+
* pagesAt(repo, ref) → { pages: [{ page, files }], shared, config } · commitsSince(repo, ref, sinceMs) → [{ sha, at, subject, files }]
|
|
19
|
+
* measure(repo, { ref, now }) → view · check(repo, { base, ref, now, feature }) → { view, change, findings }
|
|
20
|
+
*/
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const D = require('./design-drift.js');
|
|
23
|
+
|
|
24
|
+
const TAG = '[page-health]';
|
|
25
|
+
const DEFAULTS = Object.freeze({ window_days: 14, limit: 3 });
|
|
26
|
+
const FIX_KINDS = Object.freeze(['fix', 'revert', 'restore']);
|
|
27
|
+
|
|
28
|
+
/** The kind of a commit, from its subject line. */
|
|
29
|
+
function kindOf(subject) {
|
|
30
|
+
const s = String(subject || '').trim();
|
|
31
|
+
if (/^revert\b/i.test(s)) return 'revert';
|
|
32
|
+
if (/\brestor(e|es|ed|ing)\b/i.test(s)) return 'restore';
|
|
33
|
+
if (/^(fix|hotfix|bugfix)(\([^)]*\))?!?:/i.test(s)) return 'fix';
|
|
34
|
+
if (/^feat(\([^)]*\))?!?:/i.test(s)) return 'feature';
|
|
35
|
+
return 'other';
|
|
36
|
+
}
|
|
37
|
+
const fixCount = (r) => FIX_KINDS.reduce((n, k) => n + (r[k] || 0), 0);
|
|
38
|
+
|
|
39
|
+
/** The page-health config at a commit: page-health.json over the defaults. */
|
|
40
|
+
function configAt(read) {
|
|
41
|
+
const places = D.CONFIG_PLACES.map((p) => p.replace(/design-drift\.json$/, 'page-health.json'));
|
|
42
|
+
for (const p of places) {
|
|
43
|
+
const text = read(p);
|
|
44
|
+
if (text == null) continue;
|
|
45
|
+
let own;
|
|
46
|
+
try { own = JSON.parse(text); } catch { return { ...DEFAULTS, from: p, error: `${p} is not valid JSON` }; }
|
|
47
|
+
const cfg = { ...DEFAULTS, from: p };
|
|
48
|
+
for (const k of Object.keys(DEFAULTS)) {
|
|
49
|
+
const n = Number(own[k]);
|
|
50
|
+
if (k in own && (!Number.isInteger(n) || n < 1)) return { ...cfg, error: `${p}: ${k} is a whole number of 1 or more` };
|
|
51
|
+
if (k in own) cfg[k] = n;
|
|
52
|
+
}
|
|
53
|
+
return cfg;
|
|
54
|
+
}
|
|
55
|
+
return { ...DEFAULTS, from: 'defaults' };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Every page at a commit, with the files it is built from. ref null or 'WORKTREE' reads the disk. */
|
|
59
|
+
function pagesAt(repo, ref, { files } = {}) {
|
|
60
|
+
const R = D.readerOf(repo, ref);
|
|
61
|
+
const read = files ? (p) => (p in files ? files[p] : null) : R.read;
|
|
62
|
+
const all = files ? Object.keys(files) : R.list();
|
|
63
|
+
const drift = D.configAt(read);
|
|
64
|
+
const config = configAt(read);
|
|
65
|
+
const pageRes = drift.pages.map(D.globRe);
|
|
66
|
+
const pages = all.filter((p) => /\.html?$/i.test(p) && pageRes.some((re) => re.test(p))).sort();
|
|
67
|
+
const loads = pages.map((page) => {
|
|
68
|
+
const html = read(page) || '';
|
|
69
|
+
const sheets = [...html.matchAll(/<link\b[^>]*\bhref\s*=\s*["']([^"']+\.css(?:[?#][^"']*)?)["'][^>]*>/gi)].map((m) => D.resolveRef(m[1], page, drift.assetBase)).filter(Boolean);
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
const todo = [...html.matchAll(/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi)].map((m) => D.resolveRef(m[1], page, drift.assetBase)).filter(Boolean);
|
|
72
|
+
for (const m of html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)) for (const spec of D.importsOf(m[1])) { const r = D.resolveRef(spec, page, drift.assetBase); if (r) todo.push(r); }
|
|
73
|
+
while (todo.length) {
|
|
74
|
+
const js = todo.shift();
|
|
75
|
+
if (seen.has(js)) continue;
|
|
76
|
+
seen.add(js);
|
|
77
|
+
const text = read(js);
|
|
78
|
+
if (text == null) continue;
|
|
79
|
+
for (const spec of D.importsOf(text)) { if (!/^[./]/.test(spec)) continue; const r = D.resolveRef(spec, js, drift.assetBase); if (r && !seen.has(r)) todo.push(r); }
|
|
80
|
+
}
|
|
81
|
+
return { page, files: [...new Set([...sheets, ...seen])] };
|
|
82
|
+
});
|
|
83
|
+
const used = new Map();
|
|
84
|
+
for (const l of loads) for (const f of l.files) used.set(f, (used.get(f) || 0) + 1);
|
|
85
|
+
const isShared = (f) => pages.length >= 4 && used.get(f) * 2 >= pages.length;
|
|
86
|
+
return {
|
|
87
|
+
pages: loads.map((l) => ({ page: l.page, files: [l.page, ...l.files.filter((f) => !isShared(f))] })),
|
|
88
|
+
shared: [...used.keys()].filter(isShared).sort(),
|
|
89
|
+
config: { ...config, pages: drift.pages, pagesFrom: drift.from },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The non-merge commits reachable from ref since a time, with the files each changes. */
|
|
94
|
+
function commitsSince(repo, ref, sinceMs) {
|
|
95
|
+
const out = D.gitOut(repo, ['log', '--no-merges', '--name-only', `--since=${new Date(sinceMs).toISOString()}`, '--format=%x1e%H%x1f%cI%x1f%s', ref || 'HEAD']);
|
|
96
|
+
return parseLog(out);
|
|
97
|
+
}
|
|
98
|
+
function parseLog(out) {
|
|
99
|
+
return String(out || '').split('\x1e').filter((b) => b.trim()).map((b) => {
|
|
100
|
+
const [head, ...rest] = b.split('\n');
|
|
101
|
+
const [sha, at, subject] = head.split('\x1f');
|
|
102
|
+
return { sha, at, subject, files: rest.map((l) => l.trim()).filter(Boolean) };
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Count each page's commits by kind. PURE. */
|
|
107
|
+
function tally(pages, commits, { shared = [], limit = DEFAULTS.limit, sinceMs = -Infinity } = {}) {
|
|
108
|
+
const sharedSet = new Set(shared);
|
|
109
|
+
const zero = () => ({ fix: 0, revert: 0, restore: 0, feature: 0, other: 0, commits: 0, recent: [] });
|
|
110
|
+
const byFile = new Map();
|
|
111
|
+
for (const p of pages) for (const f of p.files) { if (!byFile.has(f)) byFile.set(f, []); byFile.get(f).push(p.page); }
|
|
112
|
+
const rows = new Map(pages.map((p) => [p.page, { page: p.page, ...zero() }]));
|
|
113
|
+
const sharedRow = { page: 'shared', ...zero() };
|
|
114
|
+
let pageCommits = 0, pageFixes = 0;
|
|
115
|
+
for (const c of commits) {
|
|
116
|
+
if (Date.parse(c.at) < sinceMs) continue;
|
|
117
|
+
const kind = kindOf(c.subject);
|
|
118
|
+
const hit = new Set();
|
|
119
|
+
let touchesShared = false;
|
|
120
|
+
for (const f of c.files) { for (const p of byFile.get(f) || []) hit.add(p); if (sharedSet.has(f)) touchesShared = true; }
|
|
121
|
+
if (hit.size || touchesShared) { pageCommits++; if (FIX_KINDS.includes(kind)) pageFixes++; }
|
|
122
|
+
const add = (r) => { r[kind]++; r.commits++; if (FIX_KINDS.includes(kind) && r.recent.length < 3) r.recent.push(c.subject); };
|
|
123
|
+
for (const p of hit) add(rows.get(p));
|
|
124
|
+
if (touchesShared) add(sharedRow);
|
|
125
|
+
}
|
|
126
|
+
const list = [...rows.values()].map((r) => ({ ...r, fixes: fixCount(r), over: fixCount(r) >= limit }))
|
|
127
|
+
.sort((a, b) => b.fixes - a.fixes || a.page.localeCompare(b.page));
|
|
128
|
+
return { rows: list, shared: { ...sharedRow, fixes: fixCount(sharedRow) }, commits: pageCommits, fixes: pageFixes, share: pageCommits ? pageFixes / pageCommits : 0 };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The pages a change touches that are over the limit, when the change is a feature. PURE. */
|
|
132
|
+
function findings(rows, change) {
|
|
133
|
+
if (!change.feature) return [];
|
|
134
|
+
const files = new Set(change.files);
|
|
135
|
+
return rows.filter((r) => r.over && r.files && r.files.some((f) => files.has(f)))
|
|
136
|
+
.map((r) => ({ page: r.page, fixes: r.fixes, limit: change.limit, window_days: change.window_days, files: r.files.filter((f) => files.has(f)) }));
|
|
137
|
+
}
|
|
138
|
+
const findingSay = (x) => `${TAG} ${short(x.page)} had ${x.fixes} fixes, reverts or restores in ${x.window_days} days (limit ${x.limit}). Make it work before you add to it. This change touches ${x.files.join(', ')}.`;
|
|
139
|
+
const short = (p) => String(p).replace(/^.*\//, '').replace(/\.html?$/i, '');
|
|
140
|
+
|
|
141
|
+
/** Each page's counts at ref, for the window ending now. */
|
|
142
|
+
function measure(repo, { ref = 'HEAD', now = Date.now() } = {}) {
|
|
143
|
+
const at = pagesAt(repo, ref);
|
|
144
|
+
const { window_days, limit } = at.config;
|
|
145
|
+
const sinceMs = now - window_days * 86400000;
|
|
146
|
+
const t = tally(at.pages, commitsSince(repo, ref === 'WORKTREE' ? 'HEAD' : ref, sinceMs), { shared: at.shared, limit, sinceMs });
|
|
147
|
+
const filesOf = new Map(at.pages.map((p) => [p.page, p.files]));
|
|
148
|
+
const rows = t.rows.map((r) => ({ ...r, files: filesOf.get(r.page) }));
|
|
149
|
+
return { ref, window_days, limit, config: at.config, rows, shared: t.shared, commits: t.commits, fixes: t.fixes, share: t.share, over: rows.filter((r) => r.over).length };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** A change against a base: is it a feature, and which over pages does it touch. */
|
|
153
|
+
function check(repo, { base, ref = 'HEAD', now = Date.now(), feature = false } = {}) {
|
|
154
|
+
const view = measure(repo, { ref: base, now });
|
|
155
|
+
const worktree = ref === 'WORKTREE';
|
|
156
|
+
const diff = worktree ? D.gitOut(repo, ['diff', '--name-only', base]) : D.gitOut(repo, ['diff', '--name-only', `${base}...${ref}`]);
|
|
157
|
+
const untracked = worktree ? D.gitOut(repo, ['ls-files', '--others', '--exclude-standard']) : '';
|
|
158
|
+
const files = [...new Set(`${diff || ''}\n${untracked || ''}`.split('\n').map((s) => s.trim()).filter(Boolean))];
|
|
159
|
+
const subjects = parseLog(D.gitOut(repo, ['log', '--no-merges', '--format=%x1e%H%x1f%cI%x1f%s', `${base}..${worktree ? 'HEAD' : ref}`])).map((c) => c.subject);
|
|
160
|
+
const change = { files, subjects, feature: feature || subjects.some((s) => kindOf(s) === 'feature'), limit: view.limit, window_days: view.window_days };
|
|
161
|
+
return { view, change, findings: findings(view.rows, change) };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = { TAG, DEFAULTS, FIX_KINDS, kindOf, fixCount, configAt, pagesAt, commitsSince, parseLog, tally, findings, findingSay, short, measure, check };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* pages-cli.js — `pmos pages`: each page's fix, revert and restore count in the last days, and which feature change touches a page that
|
|
3
|
+
* keeps breaking (initiative page-fix-count-first, bet A462). lib/page-health.js does the counting; this file only reads flags and prints.
|
|
4
|
+
*
|
|
5
|
+
* pmos pages [show] [--ref <ref>] [--json] [--count]
|
|
6
|
+
* pmos pages check --base <ref> [--ref <ref>|WORKTREE] [--feature] [--gate] [--json]
|
|
7
|
+
* It reads git only and writes nothing. Exit codes: 0 done, 1 refused (or a finding with --gate), 2 usage.
|
|
8
|
+
*/
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const H = require('./page-health.js');
|
|
11
|
+
const D = require('./design-drift.js');
|
|
12
|
+
|
|
13
|
+
const COMMANDS = { pages: ['show', 'check'] };
|
|
14
|
+
const USAGE = [
|
|
15
|
+
'usage: pmos pages — each page\'s fixes, reverts and restores in the last days, so a page that keeps breaking is fixed before it gets new features',
|
|
16
|
+
' pmos pages [show] [--ref <ref>] [--json] [--count]',
|
|
17
|
+
' --count print only the number of pages over the limit',
|
|
18
|
+
' pmos pages check --base <ref> [--ref <ref>|WORKTREE] [--feature] [--gate] [--json]',
|
|
19
|
+
' --base <ref> the commit the change starts from (for example origin/main)',
|
|
20
|
+
' --feature treat the change as a feature even without a feat commit',
|
|
21
|
+
' --gate exit 1 when a feature change touches a page over the limit',
|
|
22
|
+
'It reads git only. A product sets window_days and limit in page-health.json in its design-system folder; its pages come from design-drift.json.',
|
|
23
|
+
];
|
|
24
|
+
const FLAGS = { show: ['ref', 'json', 'count', 'repo'], check: ['base', 'ref', 'feature', 'gate', 'json', 'repo'] };
|
|
25
|
+
const BOOL = new Set(['json', 'count', 'feature', 'gate']);
|
|
26
|
+
|
|
27
|
+
function parse(args) {
|
|
28
|
+
const pos = [], flags = {};
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const a = args[i];
|
|
31
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
32
|
+
const k = a.slice(2);
|
|
33
|
+
if (BOOL.has(k)) flags[k] = true;
|
|
34
|
+
else flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
35
|
+
}
|
|
36
|
+
return { pos, flags };
|
|
37
|
+
}
|
|
38
|
+
const pct = (x) => Math.round(100 * x) + '%';
|
|
39
|
+
const kinds = (r) => ['fix', 'revert', 'restore'].filter((k) => r[k]).map((k) => `${r[k]} ${k}${r[k] > 1 ? (k === 'fix' ? 'es' : 's') : ''}`).join(', ') || '–';
|
|
40
|
+
|
|
41
|
+
function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now() } = {}) {
|
|
42
|
+
let args = argv[0] === 'pages' ? argv.slice(1) : argv.slice();
|
|
43
|
+
if (['help', '--help', '-h'].includes(args[0])) { for (const l of USAGE) say(l); return 0; }
|
|
44
|
+
const sub = args[0] && !args[0].startsWith('--') ? args[0] : 'show';
|
|
45
|
+
if (args[0] === sub) args = args.slice(1);
|
|
46
|
+
if (!COMMANDS.pages.includes(sub)) { say(`unknown pages command "${sub}". Use one of: ${COMMANDS.pages.join(', ')}`); return 2; }
|
|
47
|
+
const { pos, flags } = parse(args);
|
|
48
|
+
if (pos.length) { say(`✗ pmos pages ${sub} takes no argument`); return 2; }
|
|
49
|
+
for (const k of Object.keys(flags)) if (!FLAGS[sub].includes(k)) { say(`✗ --${k} is not an option of pmos pages ${sub}`); return 2; }
|
|
50
|
+
for (const k of ['ref', 'base', 'repo']) if (k in flags && !flags[k]) { say(`✗ --${k} needs a value`); return 2; }
|
|
51
|
+
if (sub === 'check' && !flags.base) { say('✗ pmos pages check needs --base <ref>: the commit the change starts from'); return 2; }
|
|
52
|
+
|
|
53
|
+
const top = D.gitOut(flags.repo ? path.resolve(cwd, flags.repo) : cwd, ['rev-parse', '--show-toplevel']);
|
|
54
|
+
if (!top) { say('✗ this is not a git repository. Run pmos pages in your product\'s repository.'); return 1; }
|
|
55
|
+
const repo = top.trim();
|
|
56
|
+
const ref = flags.ref || 'HEAD';
|
|
57
|
+
for (const r of [ref, flags.base].filter((x) => x && x !== 'WORKTREE')) {
|
|
58
|
+
if (!D.gitOut(repo, ['rev-parse', '--verify', '--quiet', r + '^{commit}'])) { say(`✗ no commit "${r}" in this repository`); return 1; }
|
|
59
|
+
}
|
|
60
|
+
if (sub === 'show' && ref === 'WORKTREE') { say('✗ pmos pages show counts commits: give --ref a commit'); return 2; }
|
|
61
|
+
|
|
62
|
+
if (sub === 'show') {
|
|
63
|
+
const v = H.measure(repo, { ref, now });
|
|
64
|
+
if (v.config.error) { say('✗ ' + v.config.error); return 1; }
|
|
65
|
+
if (flags.count) { say(String(v.over)); return 0; }
|
|
66
|
+
if (flags.json) {
|
|
67
|
+
say(JSON.stringify({ ok: true, ref, window_days: v.window_days, limit: v.limit, config: v.config.from, pages_from: v.config.pagesFrom,
|
|
68
|
+
commits: v.commits, fixes: v.fixes, share: v.share, over: v.over,
|
|
69
|
+
pages: v.rows.map(({ files, recent, ...r }) => ({ ...r, files: files.length, recent })), shared: (({ recent, ...s }) => s)(v.shared) }));
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
if (!v.rows.length) { say(`No pages found. PMOS reads pages from the "pages" globs in design-drift.json (now: ${v.config.pages.join(', ')}).`); return 0; }
|
|
73
|
+
say(`${v.over ? `${v.over} of ${v.rows.length} pages` : 'No page'} over the limit of ${v.limit} fixes, reverts or restores in ${v.window_days} days. ${v.fixes} of ${v.commits} page commits (${pct(v.share)}) were fixes.`);
|
|
74
|
+
for (const r of v.rows) {
|
|
75
|
+
if (!r.commits) continue;
|
|
76
|
+
say(`${r.over ? '●' : ' '} ${H.short(r.page).padEnd(26)}${String(r.fixes).padStart(3)} of ${String(r.commits).padEnd(4)} ${kinds(r)}`);
|
|
77
|
+
}
|
|
78
|
+
const quiet = v.rows.filter((r) => !r.commits).length;
|
|
79
|
+
if (quiet) say(` ${quiet} page${quiet > 1 ? 's' : ''} with no commit in ${v.window_days} days.`);
|
|
80
|
+
if (v.shared.commits) say(` shared code (loaded by half the pages or more): ${v.shared.fixes} of ${v.shared.commits} commits were fixes.`);
|
|
81
|
+
if (v.over) say('A page marked ● should be fixed before it gets a new feature. pmos pages check --base <ref> names a change that adds to one.');
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const res = H.check(repo, { base: flags.base, ref, now, feature: !!flags.feature });
|
|
86
|
+
if (res.view.config.error) { say('✗ ' + res.view.config.error); return 1; }
|
|
87
|
+
if (flags.json) {
|
|
88
|
+
say(JSON.stringify({ ok: res.findings.length === 0, base: flags.base, ref, feature: res.change.feature, files: res.change.files.length, findings: res.findings }));
|
|
89
|
+
} else if (!res.change.feature) {
|
|
90
|
+
say(`Not a feature change (no feat commit since ${flags.base}), so no page waits.`);
|
|
91
|
+
} else if (!res.findings.length) {
|
|
92
|
+
say(`No page this change touches is over the limit of ${res.view.limit} in ${res.view.window_days} days.`);
|
|
93
|
+
} else {
|
|
94
|
+
for (const x of res.findings) say(H.findingSay(x));
|
|
95
|
+
}
|
|
96
|
+
return flags.gate && res.findings.length ? 1 : 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -127,6 +127,9 @@ const VERBS = Object.freeze({
|
|
|
127
127
|
// Not a pm-os-absorb verb (run: null): initiative design-drift-guard added it through the same table.
|
|
128
128
|
design: Object.freeze({ module: 'design-cli.js', run: null, guide: 'cli.md',
|
|
129
129
|
help: 'pmos design drift — which pages are built from your design system and which drift from it, read from git (pmos design help)' }),
|
|
130
|
+
// Not a pm-os-absorb verb (run: null): initiative page-fix-count-first (bet A462) added it through the same table.
|
|
131
|
+
pages: Object.freeze({ module: 'pages-cli.js', run: null, guide: 'cli.md',
|
|
132
|
+
help: 'pmos pages [show|check] — each page\'s fixes, reverts and restores in the last 14 days, and a feature change that adds to a page that keeps breaking (pmos pages help)' }),
|
|
130
133
|
// Not a pm-os-absorb verb (run: null): initiative outcome-for-every-initiative added it through the same table.
|
|
131
134
|
outcomes: Object.freeze({ module: 'outcomes-cli.js', run: null, guide: 'cli.md',
|
|
132
135
|
help: 'pmos outcomes list|propose|declare|record — every initiative\'s expected outcome and check date: Claude\'s cited drafts, the PM\'s yes, and the verdict when a check is due (pmos outcomes help)' }),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.687.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.687.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "page-fix-count-first (bet A462): each page's fix, revert and restore count in the last days, and the check that names a feature change on a page over the limit (lib/page-health.js, lib/pages-cli.js). Read from git only, on a scratch git repository. No server, no network, no model.",
|
|
3
|
+
"modules": ["page-health.test.js"],
|
|
4
|
+
"seconds": { "page-health.test.js": 2 }
|
|
5
|
+
}
|