create-pmos 0.686.0 → 0.688.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.686.0",
3
+ "version": "0.688.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,25 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.688.0",
38
+ "at": "2026-11-22T09:05:24.774Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1512,
43
+ "t": "Pmos pages shows each page's fix count before new features",
44
+ "s": "Pmos pages shows each page's fix count before new features",
45
+ "k": "new"
46
+ },
47
+ {
48
+ "n": 1502,
49
+ "t": "Done days and owners from the tracker, one sync number per product",
50
+ "s": "Done days and owners from the tracker, one sync number per product",
51
+ "k": "new"
52
+ }
53
+ ]
54
+ },
36
55
  {
37
56
  "v": "0.686.0",
38
57
  "at": "2026-11-22T08:54:30.609Z",
@@ -381,19 +400,6 @@
381
400
  "k": "new"
382
401
  }
383
402
  ]
384
- },
385
- {
386
- "v": "0.649.0",
387
- "at": "2026-11-20T06:16:36.793Z",
388
- "f": 4,
389
- "prs": [
390
- {
391
- "n": 1431,
392
- "t": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
393
- "s": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
394
- "k": "new"
395
- }
396
- ]
397
403
  }
398
404
  ]
399
405
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@ac5f3763
1
+ kernel-source: pmos@18bd45e3
2
2
  assembled: 2026-11-22
3
3
  mode: vendor
@@ -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-22T08:54:26Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T09:05:21Z"}
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-22T08:54:26Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T09:05:21Z"}
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-22T08:54:26Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T09:05:21Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,23 @@
1
1
  [
2
+ {
3
+ "v": "0.688.0",
4
+ "at": "2026-11-22T09:05:24.774Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1512,
9
+ "t": "Pmos pages shows each page's fix count before new features",
10
+ "s": "Pmos pages shows each page's fix count before new features",
11
+ "k": "new"
12
+ },
13
+ {
14
+ "n": 1502,
15
+ "t": "Done days and owners from the tracker, one sync number per product",
16
+ "s": "Done days and owners from the tracker, one sync number per product",
17
+ "k": "new"
18
+ }
19
+ ]
20
+ },
2
21
  {
3
22
  "v": "0.686.0",
4
23
  "at": "2026-11-22T08:54:30.609Z",
@@ -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
@@ -758,6 +767,7 @@ Before a launch date, `pmos launch` lists what is not ready in one place. It rea
758
767
 
759
768
  - `pmos tracker done [--moved N] [--left N] [--not-found N]` records the time of the read for this repository and the counts of what it found. It moves no item.
760
769
  - `pmos tracker status` says when tracker items were last read for this repository.
770
+ - `pmos tracker sync` says how much of this repository's tasks match the last Jira read, as one percent, and lists each task that differs: its state, its done day or its owner. The read already sets the state, the done day (Jira's resolution day) and the owner (Jira's assignee), so what is left is what someone set by hand. Tasks the read could not return are counted apart. `--number` prints the percent alone; `--json` prints all of it. It calls no tracker and writes nothing.
761
771
 
762
772
  ### pmos source
763
773
 
@@ -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 };
@@ -62,7 +62,7 @@ const VERBS = Object.freeze({
62
62
  help: 'pmos launch check|list — what is not ready before a launch date: tasks, tracker tickets, sign-offs, open questions (pmos launch help)' }),
63
63
  // Not a pm-os-absorb verb (run: null): tracker-read-freshness added it through the same table.
64
64
  tracker: Object.freeze({ module: 'tracker-cli.js', run: null, guide: 'cli.md',
65
- help: 'pmos tracker done|status — record when the tracker-refresh skill finished a read of this repository (pmos tracker help)' }),
65
+ help: 'pmos tracker done|status|sync — when tracker items were last read, and how much of this repository matches the last Jira read (pmos tracker help)' }),
66
66
  // Not a pm-os-absorb verb (run: null): briefing-source-flow added it through the same table.
67
67
  source: Object.freeze({ module: 'source-cli.js', run: null, guide: 'cli.md',
68
68
  help: 'pmos source save|status|show — the stored read of each tool the Briefing uses: Mail, Slack, Confluence and the rest (pmos source help)' }),
@@ -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)' }),
@@ -15,11 +15,21 @@
15
15
  * trackerLines(lines, snapOf) PURE → [task-update line] the state changes the last Jira read makes (see THE RULE). They are
16
16
  * added to the folded lines in memory (lib/routes-boards.js readLedger) and never written to a file
17
17
  * staleOf(keys, snap, now) PURE → { stale, since, keys } whether the read these keys rest on is older than STALE_MS
18
+ * syncOf(lines, snapOf) PURE → { read, inSync, unread, pct, quiet, rows } how much of PMOS matches the last read (A439)
19
+ * readLines(root) → the task ledger lines of the repository, parsed
18
20
  *
19
21
  * THE RULE. The read sets the state of a task nobody changed since it was made or imported. When someone changed the state in PMOS, the
20
22
  * read wins only when it is newer and Jira moved the ticket after that change (its last update or its resolution day); a read with
21
23
  * neither time may only close the task. So a task the PM reopened stays open until Jira moves. A reading the search did not return
22
24
  * (marked stale) changes nothing.
25
+ * DONE DAY (A438, initiative tracker-dates-owners-sync). A task done in PMOS whose ticket Jira closed takes Jira's resolution day as
26
+ * the day it finished, also when it was already done before the read (imported as Done, so its done day was the import day). A day
27
+ * the PM gave by hand (`happened` on their own line) stays. A ticket that is not closed gives no day.
28
+ * OWNER (A440). Jira's assignee becomes the owner when PMOS has none, an agent id, or the owner the task was made or imported with.
29
+ * An owner someone set later by hand stays: syncOf names the difference. An unassigned ticket clears nothing, and an assignee that is
30
+ * a bot or an agent is never taken. "Dana" and "Dana Lee" are the same person.
31
+ * SYNC (A439). After the read is applied, a task the read returned is in sync when its state, done day and owner match the reading.
32
+ * pct = in sync ÷ read; the tasks the read did not return are counted apart (unread). quiet at 95% or more (zero is silence).
23
33
  * STALE. The Jira read is due every day: a read older than 26 hours (lib/freshness.js, jira stale_after_ms) is stale, and so is a task
24
34
  * key no read has covered yet. A forecast never rests on a stale read (lib/forecast.js, lib/kind-control.js).
25
35
  *
@@ -49,12 +59,19 @@ function keyedTasks(lines) {
49
59
  if (e.kind === 'task') {
50
60
  if (all.has(e.task) || typeof e.initiative !== 'string') continue;
51
61
  // stateAt is the time someone CHANGED the state: the state a task was created (or imported) with is no decision
52
- all.set(e.task, { task: e.task, initiative: e.initiative, title: String(e.title || ''), state: e.state || 'To do', stateAt: null });
62
+ all.set(e.task, { task: e.task, initiative: e.initiative, title: String(e.title || ''), state: e.state || 'To do', stateAt: null,
63
+ owner: typeof e.owner === 'string' && e.owner.trim() ? e.owner.trim() : null, ownerAt: null, since: null, dayByHand: false });
53
64
  } else if (e.kind === 'task-update') {
54
65
  const t = all.get(e.task); if (!t) continue;
55
66
  if (typeof e.initiative === 'string' && e.initiative) t.initiative = e.initiative;
56
67
  if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim();
57
- if (typeof e.state === 'string' && e.state) { t.state = e.state === 'In review' ? 'In progress' : e.state; t.stateAt = e.at || t.stateAt; }
68
+ if (typeof e.state === 'string' && e.state) {
69
+ t.state = e.state === 'In review' ? 'In progress' : e.state; t.stateAt = e.at || t.stateAt;
70
+ // the done day, as scripts/boards.js folds `since`: the line's `happened`, else the day it was written
71
+ t.since = typeof e.happened === 'string' ? e.happened : String(e.at || '').slice(0, 10) || null;
72
+ t.dayByHand = typeof e.happened === 'string' && e.by !== BY;
73
+ }
74
+ if (typeof e.owner === 'string') { t.owner = e.owner.trim() || null; if (e.by !== BY) t.ownerAt = e.at || t.ownerAt || 'by-hand'; }
58
75
  } else if (e.kind === 'task-remove') {
59
76
  if (all.has(e.task)) { removed.set(e.task, all.get(e.task)); all.delete(e.task); }
60
77
  } else if (e.kind === 'task-restore') {
@@ -78,11 +95,7 @@ function keysByInitiative(lines) {
78
95
  }
79
96
  /** keysByInitiative from the repository's own task ledger; an empty Map when it cannot be read. */
80
97
  function readKeys(root) {
81
- let raw = null;
82
- try { raw = require('./task-store.js').readStore(root); } catch { raw = null; }
83
- const lines = [];
84
- for (const x of raw || []) { if (typeof x !== 'string') { lines.push(x); continue; } try { lines.push(JSON.parse(x)); } catch { /* a torn line */ } }
85
- return keysByInitiative(lines);
98
+ return keysByInitiative(readLines(root));
86
99
  }
87
100
 
88
101
  /** A Jira reading as a task state. */
@@ -100,33 +113,104 @@ function stateOf(rd) {
100
113
  * readSnapshot). Each line is { at: the read's time, by: 'tracker:jira', kind: 'task-update', task, state, why, tracker: true }.
101
114
  */
102
115
  function trackerLines(lines, snapOf) {
103
- const out = []; const snaps = new Map();
104
- const snap = (ini) => { if (!snaps.has(ini)) { let s = null; try { s = snapOf(ini) || null; } catch { s = null; } snaps.set(ini, s); } return snaps.get(ini); };
116
+ const out = [];
117
+ const snap = snapMemo(snapOf);
105
118
  for (const t of keyedTasks(lines).values()) {
106
119
  if (t.state === 'Archived') continue;
107
120
  const s = snap(t.initiative);
108
121
  if (!s || !s.fetchedAt || !s.tickets || !s.tickets.get) continue;
109
122
  const rd = s.tickets.get(t.key);
110
123
  if (!rd || rd.stale) continue;
124
+ const readAt = ms(s.fetchedAt);
125
+ if (!readAt) continue;
126
+ const line = {}; const why = [];
127
+ // STATE (read-tracker-daily)
111
128
  const want = stateOf(rd);
112
- if (!want || want === t.state) continue;
113
- const readAt = ms(s.fetchedAt), changed = ms(t.stateAt);
114
- if (!readAt || readAt <= changed) continue; // the PM (or an agent) changed the task after the read
115
- if (changed) {
116
- // someone changed the state in PMOS: Jira wins only when it moved after that (its last update or resolution), or, when the read
117
- // carries neither time, only to close the task
118
- const jiraAt = Math.max(ms(rd.updated), ms(rd.resolved));
119
- const closes = want === 'Done' || want === "Won't do";
120
- if (jiraAt ? jiraAt <= changed : !closes) continue;
129
+ let state = t.state;
130
+ if (want && want !== t.state && readAt > ms(t.stateAt)) {
131
+ const changed = ms(t.stateAt);
132
+ let take = true;
133
+ if (changed) {
134
+ // someone changed the state in PMOS: Jira wins only when it moved after that (its last update or resolution), or, when the read
135
+ // carries neither time, only to close the task
136
+ const jiraAt = Math.max(ms(rd.updated), ms(rd.resolved));
137
+ const closes = want === 'Done' || want === "Won't do";
138
+ if (jiraAt ? jiraAt <= changed : !closes) take = false;
139
+ }
140
+ if (take) { line.state = want; state = want; why.push(`Jira says ${String(rd.status || want).slice(0, 40)}`); }
141
+ }
142
+ // DONE DAY (A438): Jira's resolution day when the task is done and the ticket closed, unless the PM gave the day by hand
143
+ const closed = want === 'Done' || want === "Won't do";
144
+ const day = /^\d{4}-\d{2}-\d{2}$/.test(String(rd.resolved || '')) ? rd.resolved : null;
145
+ if (closed && day && state === want && (line.state || (!t.dayByHand && t.since !== day))) {
146
+ line.happened = day;
147
+ if (!line.state) { line.state = state; why.push(`Jira closed it on ${day}`); }
121
148
  }
122
- // happened: Jira's resolution day when it closed the ticket, so a done task carries its real finish day, not the read's (A67)
123
- const happened = (want === 'Done' || want === "Won't do") && /^\d{4}-\d{2}-\d{2}$/.test(String(rd.resolved || '')) ? { happened: rd.resolved } : {};
124
- out.push({ at: s.fetchedAt, by: BY, kind: 'task-update', task: t.task, state: want, tracker: true, ...happened,
125
- why: `Jira says ${String(rd.status || want).slice(0, 40)} (${t.key}, read ${String(s.fetchedAt).slice(0, 16).replace('T', ' ')} UTC)` });
149
+ // OWNER (A440): Jira's assignee, unless someone set the owner by hand
150
+ const who = humanAssignee(rd.assignee);
151
+ if (who && !samePerson(who, t.owner) && (!t.ownerAt || isAgent(t.owner))) { line.owner = who; why.push(`Jira assignee ${who}`); }
152
+ if (!Object.keys(line).length) continue;
153
+ out.push({ at: s.fetchedAt, by: BY, kind: 'task-update', task: t.task, ...line, tracker: true,
154
+ why: `${why.join('; ')} (${t.key}, read ${String(s.fetchedAt).slice(0, 16).replace('T', ' ')} UTC)` });
126
155
  }
127
156
  return out.sort((a, b) => String(a.at).localeCompare(String(b.at)));
128
157
  }
129
158
 
159
+ function snapMemo(snapOf) {
160
+ const snaps = new Map();
161
+ return (ini) => { if (!snaps.has(ini)) { let s = null; try { s = snapOf(ini) || null; } catch { s = null; } snaps.set(ini, s); } return snaps.get(ini); };
162
+ }
163
+ // an owner or assignee that is an agent, a bot or an automation, never a person
164
+ const AGENT = /^(agent|bot|ai|tracker|system)[:/]|^(claude|pmos|agent|bot|system|automation)$|\[bot\]$|\bbot\b|automation for|^jira automation/i;
165
+ const isAgent = (name) => !!name && AGENT.test(String(name).trim());
166
+ const humanAssignee = (a) => { const n = typeof a === 'string' ? a.trim() : ''; return n && !isAgent(n) ? n : null; };
167
+ const words = (n) => String(n || '').toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
168
+ /** Whether two names are the same person: equal ignoring case and marks, or one's words are all in the other ("Dana", "Dana Lee"). */
169
+ function samePerson(a, b) {
170
+ const x = words(a), y = words(b);
171
+ if (!x.length || !y.length) return false;
172
+ const [short, long] = x.length <= y.length ? [x, y] : [y, x];
173
+ return short.every((w) => long.includes(w));
174
+ }
175
+
176
+ /**
177
+ * How much of PMOS matches the last Jira read (A439). The read is applied first (trackerLines), so what is left is what PMOS keeps on
178
+ * purpose: a state changed after Jira's last move, a done day or an owner set by hand. Each row is
179
+ * { task, key, title, initiative, field: 'state' | 'done day' | 'owner', pmos, tracker }.
180
+ */
181
+ function syncOf(lines, snapOf) {
182
+ const snap = snapMemo(snapOf);
183
+ const all = (lines || []).concat(trackerLines(lines, snap));
184
+ let read = 0, inSync = 0, unread = 0; const rows = [];
185
+ for (const t of keyedTasks(all).values()) {
186
+ if (t.state === 'Archived') continue;
187
+ const s = snap(t.initiative);
188
+ const rd = s && s.fetchedAt && s.tickets && s.tickets.get ? s.tickets.get(t.key) : null;
189
+ if (!rd || rd.stale) { unread++; continue; }
190
+ read++;
191
+ const diff = [];
192
+ const want = stateOf(rd);
193
+ if (want && want !== t.state) diff.push(['state', t.state, want]);
194
+ const day = /^\d{4}-\d{2}-\d{2}$/.test(String(rd.resolved || '')) ? rd.resolved : null;
195
+ if (day && (want === 'Done' || want === "Won't do") && t.state === want && t.since !== day) diff.push(['done day', t.since, day]);
196
+ const who = humanAssignee(rd.assignee);
197
+ if (who && !samePerson(who, t.owner)) diff.push(['owner', t.owner, who]);
198
+ if (!diff.length) { inSync++; continue; }
199
+ for (const [field, pmos, tracker] of diff) rows.push({ task: t.task, key: t.key, title: t.title, initiative: t.initiative, field, pmos: pmos || null, tracker });
200
+ }
201
+ const pct = read ? Math.floor((inSync / read) * 100) : null;
202
+ return { read, inSync, unread, pct, quiet: pct === null || pct >= 95, rows };
203
+ }
204
+
205
+ /** The task ledger lines of the repository (lib/task-store.js), parsed; [] when it cannot be read. */
206
+ function readLines(root) {
207
+ let raw = null;
208
+ try { raw = require('./task-store.js').readStore(root); } catch { raw = null; }
209
+ const lines = [];
210
+ for (const x of raw || []) { if (typeof x !== 'string') { lines.push(x); continue; } try { lines.push(JSON.parse(x)); } catch { /* a torn line */ } }
211
+ return lines;
212
+ }
213
+
130
214
  /** Whether the read `keys` rest on is stale: no read, a read older than STALE_MS, or keys the read did not return. */
131
215
  function staleOf(keys, snap, now = Date.now()) {
132
216
  const list = [...new Set((keys || []).filter(Boolean))];
@@ -137,4 +221,4 @@ function staleOf(keys, snap, now = Date.now()) {
137
221
  return { stale: old || missing.length > 0, since: snap.fetchedAt, keys: old ? list : missing };
138
222
  }
139
223
 
140
- module.exports = { STALE_MS, BY, keyOf, keyedTasks, keysByInitiative, readKeys, stateOf, trackerLines, staleOf };
224
+ module.exports = { STALE_MS, BY, keyOf, keyedTasks, keysByInitiative, readKeys, readLines, stateOf, trackerLines, staleOf, syncOf, samePerson, isAgent };
@@ -3,6 +3,7 @@
3
3
  * tracker-read-freshness).
4
4
  * pmos tracker done [--moved N] [--left N] [--not-found N] [--json]
5
5
  * pmos tracker status [--json]
6
+ * pmos tracker sync [--json | --number] how much of PMOS matches the last Jira read here (initiative tracker-dates-owners-sync, A439)
6
7
  * The repository is the one this terminal is in. The record is kept in the per-user runtime folder (lib/tracker-read.js),
7
8
  * never in a repository. This command calls no tracker and moves no item.
8
9
  */
@@ -10,11 +11,12 @@ const { execFileSync } = require('child_process');
10
11
  const stateRoot = require('./state-root');
11
12
  const TR = require('./tracker-read.js');
12
13
 
13
- const COMMANDS = { tracker: ['done', 'status'] };
14
+ const COMMANDS = { tracker: ['done', 'status', 'sync'] };
14
15
  const USAGE = [
15
16
  'usage: pmos tracker done|status — when tracker items were last read for this repository',
16
17
  ' pmos tracker done [--moved N] [--left N] [--not-found N] the tracker-refresh skill runs this as its last step',
17
18
  ' pmos tracker status when the last read finished, and what it found',
19
+ ' pmos tracker sync [--number] how much of PMOS matches the last Jira read: state, done day, owner',
18
20
  ' every command: [--json]',
19
21
  'This command never calls a tracker and moves no item.',
20
22
  ];
@@ -26,7 +28,7 @@ function parseArgs(argv) {
26
28
  if (!t.startsWith('--')) { out._.push(t); continue; }
27
29
  const eq = t.indexOf('=');
28
30
  const key = eq > 0 ? t.slice(2, eq) : t.slice(2);
29
- if (key === 'json' || key === 'help') out[key] = true;
31
+ if (key === 'json' || key === 'help' || key === 'number') out[key] = true;
30
32
  else if (eq > 0) out[key] = t.slice(eq + 1);
31
33
  else if (argv[i + 1] !== undefined) out[key] = argv[++i];
32
34
  else out[key] = '';
@@ -60,9 +62,26 @@ function run(argv, { say = console.log, env = process.env, stateDir, cwd = proce
60
62
  out({ ok: true, ...rec }, `tracker items read at ${rec.read_at} for ${rec.root}. The freshness line shows it.`);
61
63
  return 0;
62
64
  }
65
+ if (sub === 'sync') return sync(root, a, say);
63
66
  const rec = TR.read(dir, root);
64
67
  out({ ok: true, record: rec }, rec ? `tracker items last read at ${rec.read_at} (moved ${rec.moved ?? '?'}, left ${rec.left ?? '?'}, not found ${rec.not_found ?? '?'})` : 'tracker items not read yet for this repository');
65
68
  return 0;
66
69
  }
67
70
 
71
+ /** `pmos tracker sync`: the sync number of this repository (lib/task-jira.js syncOf). Reads the task ledger and the Jira snapshots
72
+ * the last read saved; calls no tracker and writes nothing. --number prints the number alone on the last line (the health read). */
73
+ function sync(root, a, say) {
74
+ const TJ = require('./task-jira.js');
75
+ const JS = require('./jira-status.js');
76
+ const s = TJ.syncOf(TJ.readLines(root), (ini) => JS.readSnapshot(root, ini));
77
+ console.log(`[tracker-sync] root=${root} read=${s.read} in_sync=${s.inSync} unread=${s.unread} pct=${s.pct === null ? 'none' : s.pct}`);
78
+ if (a.json) { say(JSON.stringify({ ok: true, root, ...s })); return 0; }
79
+ if (a.number) { say(s.pct === null ? 'none' : String(s.pct)); return 0; }
80
+ if (s.pct === null) { say(s.unread ? `No task here has a Jira reading yet (${s.unread} can't be read).` : 'No task here names a Jira ticket.'); return 0; }
81
+ const differ = s.read - s.inSync;
82
+ say(`${s.pct}% in sync with Jira (${differ} of ${s.read} differ${s.unread ? `, ${s.unread} can't be read` : ''}).`);
83
+ for (const r of s.rows) say(` ${r.key} ${r.field}: PMOS ${r.pmos || 'none'}, Jira ${r.tracker} · ${r.title.slice(0, 60)}`);
84
+ return 0;
85
+ }
86
+
68
87
  module.exports = { run, COMMANDS, USAGE };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.686.0",
3
+ "version": "0.688.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.686.0",
9
+ "version": "0.688.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.686.0",
3
+ "version": "0.688.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -131,7 +131,8 @@
131
131
  "setup-routes.test.js",
132
132
  "project-onboard.test.js",
133
133
  "loop-telemetry.test.js",
134
- "signals.test.js"
134
+ "signals.test.js",
135
+ "task-jira-sync.test.js"
135
136
  ],
136
137
  "panels": [
137
138
  "pm-r7-test.js",
@@ -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
+ }