create-pmos 0.849.0 → 0.850.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.849.0",
3
+ "version": "0.850.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,47 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.850.0",
38
+ "at": "2026-11-25T20:45:33.395Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1950,
43
+ "t": "Compare two items side by side, the differences marked (job #1919, A421)",
44
+ "s": "Compare two items side by side, the differences marked (job #1919, A421)",
45
+ "k": "new",
46
+ "h": "Compare two items side by side, the differences marked (job #1919, A421)",
47
+ "try": {
48
+ "steps": [
49
+ "Open Work and tick exactly two tasks",
50
+ "Press the Compare icon in the bar under them",
51
+ "Read the rows that differ, press the swap icon, then fold open the rows that are the same"
52
+ ],
53
+ "see": "One compare panel opens beside the list: the two titles at the top, each field on one row, the rows that differ with a dot and a tint, and one line that says how many rows are the same. With one or…",
54
+ "open": "/premium-board.html"
55
+ },
56
+ "i": "compare-items"
57
+ },
58
+ {
59
+ "n": 1957,
60
+ "t": "Library › Drift lists specs and code that no longer match (job #1902, A495)",
61
+ "s": "Library › Drift lists specs and code that no longer match (job #1902, A495)",
62
+ "k": "new",
63
+ "h": "Library › Drift lists specs and code that no longer match (job #1902, A495)",
64
+ "try": {
65
+ "steps": [
66
+ "Open Library: the This week block sits above the list by itself, with no ask",
67
+ "Press the wrench on a row to add a task that fixes the code, or the page to add a task that updates the spec",
68
+ "Open Work, open the spec's initiative and find the new task"
69
+ ],
70
+ "see": "One row per mismatch with what the spec says, what the code does and both dates. The press adds a task to the initiative and the row says task added, with Undo. With no mismatch, there is no block",
71
+ "open": "/premium-library.html"
72
+ },
73
+ "i": "spec-code-drift"
74
+ }
75
+ ]
76
+ },
36
77
  {
37
78
  "v": "0.849.0",
38
79
  "at": "2026-11-25T18:55:50.990Z",
@@ -43,6 +84,7 @@
43
84
  "t": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
44
85
  "s": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
45
86
  "k": "new",
87
+ "i": "balance-rebalance",
46
88
  "h": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
47
89
  "try": {
48
90
  "steps": [
@@ -52,8 +94,7 @@
52
94
  ],
53
95
  "see": "When the top of the roadmap leans one way, Today proposes a target mix by itself and ✦ saves it. Then a Today row names the one rank move that closes the most gap. ✦ makes that rank move and Undo…",
54
96
  "open": "/today.html"
55
- },
56
- "i": "balance-rebalance"
97
+ }
57
98
  }
58
99
  ]
59
100
  },
@@ -978,77 +1019,6 @@
978
1019
  "i": "arch-warns"
979
1020
  }
980
1021
  ]
981
- },
982
- {
983
- "v": "0.826.0",
984
- "at": "2026-11-25T11:36:40.845Z",
985
- "f": 4,
986
- "prs": [
987
- {
988
- "n": 1973,
989
- "t": "What PMOS can do lists every pmos verb (A540)",
990
- "s": "What PMOS can do lists every pmos verb (A540)",
991
- "k": "new",
992
- "i": "directory-all-verbs"
993
- },
994
- {
995
- "n": 1944,
996
- "t": "A map of the product's code on Work, one box per main part (job #1900, A176)",
997
- "s": "A map of the product's code on Work, one box per main part (job #1900, A176)",
998
- "k": "new",
999
- "i": "code-map",
1000
- "h": "A map of the product's code on Work, one box per main part (job #1900, A176)",
1001
- "try": {
1002
- "steps": [
1003
- "Open Work and pick one product",
1004
- "Under the strategy, read the Code map: one box per main part",
1005
- "Ask the chat: say the api part is the public REST API"
1006
- ],
1007
- "see": "One box per main folder of the product's repository, each with what it is, how it is tested and who changed it last. A part with no tests or many recent fixes is tinted and says why. After the chat…",
1008
- "open": "/premium-board.html"
1009
- }
1010
- },
1011
- {
1012
- "n": 1969,
1013
- "t": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
1014
- "s": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
1015
- "k": "new",
1016
- "i": "today-order",
1017
- "h": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
1018
- "try": {
1019
- "steps": [
1020
- "Open Today on a Monday, a Friday, a day with 3 or more meetings, or the day one of your initiatives ships",
1021
- "Read the quiet line under the page head and press the lock icon beside it",
1022
- "Open Today again tomorrow and press the lock icon to unpin"
1023
- ],
1024
- "see": "The same blocks show in a different order, and one line says why (for example 'Ordered for Monday · from your calendar'). After the pin the line says the order is pinned and the order stays the same…",
1025
- "open": "/today.html"
1026
- }
1027
- },
1028
- {
1029
- "n": 1972,
1030
- "t": "Popup four learn from a full 30-day use log (A498)",
1031
- "s": "Popup four learn from a full 30-day use log (A498)",
1032
- "k": "fix",
1033
- "i": "popup-cap"
1034
- },
1035
- {
1036
- "n": 1975,
1037
- "t": "Settings opens again; features rows for code and connectors",
1038
- "s": "Settings opens again; features rows for code and connectors",
1039
- "k": "fix",
1040
- "i": "connector-data",
1041
- "h": "Settings opens again; features rows for code and connectors",
1042
- "try": {
1043
- "steps": [
1044
- "Open Today",
1045
- "Open Settings from the rail",
1046
- "Open What PMOS can do and find Code map"
1047
- ],
1048
- "see": "Settings opens, and Connectors and What PMOS does alone both show; Code map and What connectors read and write are listed"
1049
- }
1050
- }
1051
- ]
1052
1022
  }
1053
1023
  ]
1054
1024
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@92a63b229
1
+ kernel-source: pmos@63a4025cb
2
2
  assembled: 2026-11-25
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-25T18:55:46Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T20:45:29Z"}
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-25T18:55:46Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T20:45:29Z"}
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-25T18:55:46Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T20:45:29Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,45 @@
1
1
  [
2
+ {
3
+ "v": "0.850.0",
4
+ "at": "2026-11-25T20:45:33.395Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1950,
9
+ "t": "Compare two items side by side, the differences marked (job #1919, A421)",
10
+ "s": "Compare two items side by side, the differences marked (job #1919, A421)",
11
+ "k": "new",
12
+ "h": "Compare two items side by side, the differences marked (job #1919, A421)",
13
+ "try": {
14
+ "steps": [
15
+ "Open Work and tick exactly two tasks",
16
+ "Press the Compare icon in the bar under them",
17
+ "Read the rows that differ, press the swap icon, then fold open the rows that are the same"
18
+ ],
19
+ "see": "One compare panel opens beside the list: the two titles at the top, each field on one row, the rows that differ with a dot and a tint, and one line that says how many rows are the same. With one or…",
20
+ "open": "/premium-board.html"
21
+ },
22
+ "i": "compare-items"
23
+ },
24
+ {
25
+ "n": 1957,
26
+ "t": "Library › Drift lists specs and code that no longer match (job #1902, A495)",
27
+ "s": "Library › Drift lists specs and code that no longer match (job #1902, A495)",
28
+ "k": "new",
29
+ "h": "Library › Drift lists specs and code that no longer match (job #1902, A495)",
30
+ "try": {
31
+ "steps": [
32
+ "Open Library: the This week block sits above the list by itself, with no ask",
33
+ "Press the wrench on a row to add a task that fixes the code, or the page to add a task that updates the spec",
34
+ "Open Work, open the spec's initiative and find the new task"
35
+ ],
36
+ "see": "One row per mismatch with what the spec says, what the code does and both dates. The press adds a task to the initiative and the row says task added, with Undo. With no mismatch, there is no block",
37
+ "open": "/premium-library.html"
38
+ },
39
+ "i": "spec-code-drift"
40
+ }
41
+ ]
42
+ },
2
43
  {
3
44
  "v": "0.849.0",
4
45
  "at": "2026-11-25T18:55:50.990Z",
@@ -9,6 +50,7 @@
9
50
  "t": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
10
51
  "s": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
11
52
  "k": "new",
53
+ "i": "balance-rebalance",
12
54
  "h": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
13
55
  "try": {
14
56
  "steps": [
@@ -18,8 +60,7 @@
18
60
  ],
19
61
  "see": "When the top of the roadmap leans one way, Today proposes a target mix by itself and ✦ saves it. Then a Today row names the one rank move that closes the most gap. ✦ makes that rank move and Undo…",
20
62
  "open": "/today.html"
21
- },
22
- "i": "balance-rebalance"
63
+ }
23
64
  }
24
65
  ]
25
66
  },
@@ -396,6 +396,14 @@ Write the press release before the build ("working backwards"). Run it in the pr
396
396
  - The draft uses one agent run with no tools. `--no-ai`, `pmos ai off press-release` or `PMOS_AI=off` makes a draft from the record's own lines only. A failed run does the same and says why.
397
397
  - `pmos press-release count [--days 7]` prints how many drafts were written in the last days. Its last line is the number.
398
398
 
399
+ ### pmos compare: two items side by side
400
+
401
+ See what changed between two items before you choose. Run it in the product's repository, or pass `--root <dir>`, or ask the chat to "compare the brief with its last version". No running workspace is needed. In Work, tick exactly two tasks and press Compare in the bar under them: the same rows open in one panel beside the list.
402
+
403
+ - `pmos compare <a> <b>` (or `pmos compare show <a> <b>`) compares two initiatives by id, or two files. Add `@<git revision>` to read a version: `pmos compare planning/prd/otp.md@HEAD~1 planning/prd/otp.md`.
404
+ - Fields (the record's frontmatter) line up row by row, and each `## ` section is a part compared in words: removed words show in `[-…-]`, added words in `{+…+}`. The rows that are the same are named in one line.
405
+ - `--json` gives every row. PMOS changes neither item and sends nothing.
406
+
399
407
  ### pmos story-map: the user's journey and the Release 1 line
400
408
 
401
409
  A story map for a new bet: the steps of the user's journey left to right, the tasks of each step top to bottom, and a dashed line under the thinnest release that still works end to end. The initiative popup on Work shows it, and the chat reads and writes the same map. Run it in the product's repository, or pass `--root <dir>`. No running workspace is needed.
@@ -743,6 +751,19 @@ Only PMOS's impact run uses these. The server pins each run to your ledger. Outs
743
751
  - `pmos drift replay`: the replay of the last four weeks of this repository.
744
752
  - `pmos drift status`: the last weekly result and the replays on record.
745
753
 
754
+ #### pmos drift spec: specs and code that no longer match
755
+
756
+ Once a week PMOS compares each merged spec (an initiative's done test) with the code as it is now. Library shows the result in the "This week" block, one row per mismatch: what the spec says, what the code does now, and both dates. With no mismatch, there is no block.
757
+
758
+ A row comes from git only. No model reads the code. A spec row names the test that proves it. The check reads that test twice: when the spec landed, and now. A row shows when the test file is gone, when the test no longer names the row, or when a line that proved the row was rewritten. A test that never named its row, a moved test that still proves it, a line added beside the proof and a changed comment do not give a row.
759
+
760
+ - `pmos drift spec`: this week's rows for this repository, each with its row id. When this week has no result, it runs the check first. `--now` runs it again.
761
+ - `pmos drift spec fix <row>`: adds the task "Fix the code to match the spec" to the spec's initiative.
762
+ - `pmos drift spec update <row>`: adds the task "Update the spec" instead.
763
+ - `pmos drift spec undo <row>`: removes that task again. The row is open again.
764
+
765
+ The page writes the same record, in your runtime folder (`spec-drift/spec-drift.jsonl`), so a change from the chat shows in Library at once. `PMOS_SPEC_DRIFT=off` turns the check off. Nothing is sent.
766
+
746
767
  ### pmos design drift: places that do not read a design token
747
768
 
748
769
  The aim: change one token and every page follows. Each place this command counts is a place a token change does not reach.
@@ -144,6 +144,7 @@ An "off" switch accepts `off`, `0`, `false` or `no` unless the row says a differ
144
144
  | `PMOS_DESCRIPTIONS` | `off` stops the daily [initiative descriptions](claude-proposes.md). | on | `pmos ai off descriptions` |
145
145
  | `PMOS_OUTCOMES` | `off` stops the daily read for [expected outcomes](claude-proposes.md). | on | `pmos ai off outcomes` |
146
146
  | `PMOS_DRIFT` | `off` stops [what you might have missed](claude-proposes.md). | on | `pmos ai off drift` |
147
+ | `PMOS_SPEC_DRIFT` | `off` stops the weekly check of specs and code in Library (`pmos drift spec`). | on | — |
147
148
  | `PMOS_IMPACT` | `off` stops the daily read for [your impact](claude-proposes.md). | on | General › Your impact |
148
149
  | `PMOS_METRIC_DRAFT` | `off` stops the [metric drafts](claude-proposes.md). | on | — |
149
150
  | `PMOS_METRIC_READ` | `off` stops the goal reading runs. | on | — |
@@ -280,6 +281,7 @@ Do not set these on your own computer. The suites set them to make a run short o
280
281
  | `PMOS_CORE_DOCS_NOW` | A fixed clock for the core document drafts. | the real clock | — |
281
282
  | `PMOS_REFRESH_NOW` | A fixed clock for the refresh runs. | the real clock | — |
282
283
  | `PMOS_DRIFT_NOW` | A fixed clock for what you might have missed. | the real clock | — |
284
+ | `PMOS_SPEC_DRIFT_NOW` | A fixed clock for the weekly check of specs and code. | the real clock | — |
283
285
  | `PMOS_IMPACT_NOW` | A fixed clock for your impact. | the real clock | — |
284
286
  | `PMOS_MOMENTS_NOW` | A fixed clock for moments. | the real clock | — |
285
287
  | `PMOS_PACK_KEYS_RECORD` | A file path. A shared board's pack then keeps every key and writes each key path to that file, to grow the key list. For development only: never set it where you publish. | not set | — |
@@ -0,0 +1,140 @@
1
+ 'use strict';
2
+ /* compare-cli.js — `pmos compare <a> <b>`: two items side by side, the differences marked (idea A421, initiative compare-items; done test
3
+ * planning/done-tests/compare-items.md). The chat's way to the compare panel Work opens (public/pm/compare-items.js).
4
+ *
5
+ * pmos compare <a> <b> [--json] [--root <dir>] (pmos compare show <a> <b> is the same)
6
+ * <a>, <b>: an initiative id (its record, kit or PMOS-self layout) or a file path, each with an optional @<git revision>:
7
+ * pmos compare checkout-redesign wechat-login two initiatives: their fields and their `## ` sections
8
+ * pmos compare planning/prd/otp.md@HEAD~1 planning/prd/otp.md two versions of one brief
9
+ * Prints the rows that differ (removed words in [-…-], added words in {+…+}) and the rows that are the same in one line.
10
+ *
11
+ * sideOf(root, ref) → { ok: true, side } | { ok: false, error } side: { title, sub, fields: [[name, value]], parts: [[name, text]] }
12
+ * splitOf(text) → { front: [[key, value]], parts: [[heading, text]] } PURE
13
+ *
14
+ * The rows come from the page's own pure model (public/pm/compare-items.js compareOf), so the chat and the panel never disagree.
15
+ * READ ONLY: it reads files and `git show`, writes nothing to the product and sends nothing. Each run counts the use-log control
16
+ * compareOpen (this computer's runtime folder, the health number) and prints one [compare-items] line on stderr.
17
+ * Exit codes: 0 done, 1 an item was not found, 2 usage. */
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+ const { execFileSync } = require('child_process');
21
+ const why = require('./item-why.js');
22
+
23
+ const TAG = '[compare-items]';
24
+ const COMMANDS = { compare: ['show'] };
25
+ const USAGE = [
26
+ 'usage: pmos compare <a> <b> — two items side by side, the differences marked',
27
+ ' <a>, <b> an initiative id or a file path, each with an optional @<git revision> (a version: brief.md@HEAD~1)',
28
+ ' pmos compare show <a> <b> the same',
29
+ ' every command: [--json] [--root <dir>]',
30
+ 'Removed words show in [-…-], added words in {+…+}. Nothing is written or sent.',
31
+ ];
32
+ const FIELD_WORD = { parent_kr: 'Goal it moves', status: 'Status', lane: 'Lane', kind: 'Kind', owner: 'Owner', stage: 'Stage', state: 'State',
33
+ expected_outcome: 'Expected outcome', outcome_horizon: 'Check date', kill: 'Kill if', start: 'Start', due: 'Due', target_date: 'Due' };
34
+ const SKIP = new Set(['title', 'type', 'timestamp', 'id', 'done_test_path', 'health_read', 'health_log', 'try_open']);
35
+ const nameOf = (k) => FIELD_WORD[k] || (k.charAt(0).toUpperCase() + k.slice(1)).replace(/_/g, ' ');
36
+
37
+ function repoRoot(cwd) {
38
+ try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
39
+ catch { return cwd; }
40
+ }
41
+
42
+ /** The frontmatter as named fields and the body as its `## ` parts (the text before the first heading is "Opening"). PURE. */
43
+ function splitOf(text) {
44
+ const t = String(text || '').replace(/\r\n?/g, '\n');
45
+ const fm = why.frontOf(t);
46
+ const front = Object.entries(fm).filter(([k, v]) => !SKIP.has(k) && String(v == null ? '' : v).trim() !== '').map(([k, v]) => [nameOf(k), String(v)]);
47
+ const body = t.replace(/^---\n[\s\S]*?\n---\n?/, '');
48
+ const parts = []; let cur = 'Opening', buf = [];
49
+ const flush = () => { const x = buf.join('\n').trim(); if (x) parts.push([cur, x]); buf = []; };
50
+ for (const line of body.split('\n')) {
51
+ const m = /^##\s+(.+?)\s*#*\s*$/.exec(line);
52
+ if (m) { flush(); cur = m[1]; } else if (!/^#\s/.test(line)) buf.push(line);
53
+ }
54
+ flush();
55
+ // a heading used twice keeps both, numbered, so no part hides another
56
+ const seen = new Map();
57
+ return { front, parts: parts.map(([k, v]) => { const n = (seen.get(k) || 0) + 1; seen.set(k, n); return [n > 1 ? `${k} (${n})` : k, v]; }) };
58
+ }
59
+
60
+ const inside = (root, f) => { const a = path.resolve(f); return a === root || a.startsWith(root + path.sep); };
61
+ /** One item read from disk or from git. */
62
+ function sideOf(root, ref) {
63
+ const raw = String(ref || '').trim();
64
+ if (!raw) return { ok: false, error: 'an item is missing' };
65
+ const at = raw.lastIndexOf('@');
66
+ const base = at > 0 ? raw.slice(0, at) : raw, rev = at > 0 ? raw.slice(at + 1) : '';
67
+ if (rev && !/^[A-Za-z0-9._~^/-]{1,80}$/.test(rev)) return { ok: false, error: `"${rev}" is not a git revision` };
68
+ let file = null;
69
+ const asPath = path.resolve(root, base);
70
+ if (inside(root, asPath) && (fs.existsSync(asPath) || rev) && /[./\\]/.test(base)) file = asPath;
71
+ else { const rec = why.recordPathOf(root, base); if (rec) file = rec; }
72
+ if (!file || !inside(root, file)) return { ok: false, error: `no initiative or file "${base}" here` };
73
+ const relp = path.relative(root, file).split(path.sep).join('/');
74
+ let text = null, when = '';
75
+ if (rev) {
76
+ try {
77
+ text = execFileSync('git', ['show', `${rev}:${relp}`], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 8 << 20 });
78
+ when = execFileSync('git', ['log', '-1', '--format=%cs', rev, '--', relp], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
79
+ } catch { return { ok: false, error: `${relp} has no version at ${rev}` }; }
80
+ } else {
81
+ try { text = fs.readFileSync(file, 'utf8'); } catch { return { ok: false, error: `${relp} cannot be read` }; }
82
+ }
83
+ const fm = why.frontOf(text), s = splitOf(text);
84
+ const title = String(fm.title || path.basename(relp, path.extname(relp))) + (rev ? ` @ ${rev}` : '');
85
+ return { ok: true, side: { title, sub: [relp, when].filter(Boolean).join(' · '), fields: s.front, parts: s.parts } };
86
+ }
87
+
88
+ function parse(argv) {
89
+ const pos = [], flags = {};
90
+ for (let i = 0; i < argv.length; i++) {
91
+ const a = argv[i];
92
+ if (a === '--root') flags.root = argv[++i];
93
+ else if (a.startsWith('--root=')) flags.root = a.slice(7);
94
+ else if (a === '-h' || a === '--help') flags.help = true;
95
+ else if (a.startsWith('--')) flags[a.slice(2)] = true;
96
+ else pos.push(a);
97
+ }
98
+ return { pos, flags };
99
+ }
100
+
101
+ const pieceText = (p) => (p.op === 'del' ? `[-${p.t.trim()}-]${/\s$/.test(p.t) ? ' ' : ''}` : p.op === 'add' ? `{+${p.t.trim()}+}${/\s$/.test(p.t) ? ' ' : ''}` : p.t);
102
+ const oneLine = (s, n = 160) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
103
+ function used(o) {
104
+ try {
105
+ const dir = o.stateDir || require('./state-root.js').defaultRoot({ env: o.env || process.env });
106
+ require('./use-log.js').record(dir, [{ kind: 'use', page: 'today', control: 'compareOpen', device: 'desk' }], o.now || Date.now());
107
+ } catch { /* a count, never a reason to fail */ }
108
+ }
109
+
110
+ async function run(argv, o = {}) {
111
+ const say = o.say || ((s) => console.log(s));
112
+ const args = argv[0] === 'compare' ? argv.slice(1) : argv.slice();
113
+ const { pos, flags } = parse(args);
114
+ if (pos[0] === 'show') pos.shift();
115
+ if (flags.help || pos[0] === 'help') { for (const l of USAGE) say(l); return 0; }
116
+ if (pos.length !== 2) { for (const l of USAGE) say(l); return 2; }
117
+ const root = path.resolve(flags.root || repoRoot(o.cwd || process.cwd()));
118
+ const A = sideOf(root, pos[0]), B = sideOf(root, pos[1]);
119
+ for (const x of [A, B]) if (!x.ok) { if (flags.json) say(JSON.stringify({ ok: false, error: x.error })); else say(`✗ ${x.error}`); return 1; }
120
+ const C = await import(require('url').pathToFileURL(path.join(__dirname, '..', 'public', 'pm', 'compare-items.js')).href);
121
+ const m = C.compareOf(A.side, B.side);
122
+ used(o);
123
+ try { console.error(TAG, 'compare', m.differ, 'of', m.total); } catch { /* no stderr */ }
124
+ if (flags.json) {
125
+ say(JSON.stringify({ ok: true, left: { title: m.left.title, sub: m.left.sub }, right: { title: m.right.title, sub: m.right.sub }, unit: m.unit, differ: m.differ, same: m.same, total: m.total, rows: m.rows }));
126
+ return 0;
127
+ }
128
+ say(`${m.left.title} and ${m.right.title}: ${C.sumText(m) || 'nothing to compare'}.`);
129
+ for (const r of m.rows.filter((x) => !x.same)) {
130
+ say(`• ${r.name}`);
131
+ if (r.diff) { say(` - ${oneLine(r.diff.a.map(pieceText).join(''), 400) || 'None'}`); say(` + ${oneLine(r.diff.b.map(pieceText).join(''), 400) || 'None'}`); }
132
+ else { say(` - ${oneLine(r.a) || 'None'}`); say(` + ${oneLine(r.b) || 'None'}`); }
133
+ }
134
+ const same = m.rows.filter((x) => x.same);
135
+ if (same.length) say(`${same.length} the same: ${oneLine(same.map((x) => x.name).join(', '), 300)}.`);
136
+ say('Nothing was changed or sent.');
137
+ return 0;
138
+ }
139
+
140
+ module.exports = { TAG, COMMANDS, USAGE, splitOf, sideOf, run };
@@ -8,6 +8,7 @@
8
8
  * replay (lib/ai-guard.js), and writes one replay line to your own ledger. This product's items show
9
9
  * on Home only after a replay that passed.
10
10
  * pmos drift status [--json] the last weekly result and the replays on record.
11
+ * pmos drift spec … Library › Drift: specs and code that no longer match (lib/spec-drift-cli.js).
11
12
  *
12
13
  * Run it in the product's repository. The weekly run itself needs no command: the server runs it each Monday. Nothing here changes a task,
13
14
  * an initiative or a ticket, and nothing is sent. Exit codes: 0 done, 1 refused or the replay failed, 2 usage. */
@@ -17,12 +18,13 @@ const D = require('./drift.js');
17
18
  const R = require('./drift-runs.js');
18
19
  const Facts = require('./drift-facts.js');
19
20
 
20
- const COMMANDS = { drift: ['show', 'replay', 'status'] };
21
+ const COMMANDS = { drift: ['show', 'replay', 'status', 'spec'] };
21
22
  const USAGE = [
22
23
  'usage: pmos drift show|replay|status — the weekly check for quiet drift (What would I have missed)',
23
24
  ' pmos drift show [--weeks <n>] [--json] what each of the last n weeks (default 4) would have shown for this repository; writes nothing',
24
25
  ' pmos drift replay [--json] replay the last 4 weeks of this repository on its real records; its items show on Today only after this passes',
25
26
  ' pmos drift status [--json] the last weekly result and the replays on record',
27
+ ' pmos drift spec [fix|update|undo <row>] specs and code that no longer match (Library › Drift; pmos drift spec help)',
26
28
  'The weekly run starts by itself each Monday. Nothing is changed in a task, an initiative or Jira, and nothing is sent.',
27
29
  ];
28
30
 
@@ -47,6 +49,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
47
49
  const sub = args[0];
48
50
  if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
49
51
  if (!COMMANDS.drift.includes(sub)) { say(`unknown drift command "${sub}". Use one of: ${COMMANDS.drift.join(', ')}`); return 2; }
52
+ if (sub === 'spec') return require('./spec-drift-cli.js').run(args.slice(1), { say, env, cwd, now, runtime });
50
53
  const { pos, flags } = parse(args.slice(1));
51
54
  if (pos.length) { say(`✗ pmos drift ${sub} takes no argument`); return 2; }
52
55
  for (const k of Object.keys(flags)) if (k !== 'json' && !(k === 'weeks' && sub === 'show')) { say(`✗ --${k} is not an option of pmos drift ${sub}`); return 2; }
@@ -62,6 +62,7 @@
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
64
  {"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
+ {"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"},
65
66
  {"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>\""},
66
67
  {"id": "review", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Built beside its design", "say": "The built screen beside its design, each difference circled and numbered. Accept it, or send a difference back as a fix.", "cmd": "/built-vs-design", "verb": "review", "sub": "list", "hint": "<initiative>", "place": "board"},
67
68
  {"id": "story-map", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Story map", "say": "A new bet's user journey left to right, with the Release 1 line to move tasks across.", "cmd": "/story-map", "verb": "story-map", "hint": "<initiative>"},
@@ -159,6 +159,9 @@ const VERBS = Object.freeze({
159
159
  // Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
160
160
  why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
161
161
  help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
162
+ // Not a pm-os-absorb verb (run: null): initiative compare-items (job #1919, A421) added it through the same table.
163
+ compare: Object.freeze({ module: 'compare-cli.js', run: null, guide: 'cli.md',
164
+ help: 'pmos compare <a> <b> — two initiatives, or two versions of a document (<file>@<revision>), side by side with the differences marked (pmos compare help)' }),
162
165
  // Not a pm-os-absorb verb (run: null): initiative copy-tests (job #1905, A351) added it through the same table.
163
166
  experiment: Object.freeze({ module: 'copy-tests.js', run: null, guide: 'cli.md',
164
167
  help: 'pmos experiment draft|list|show|flag|start|result|keep|undo|count — copy and layout tests on an initiative: drafted from plain words, started by you, one table and one ✦ line with how sure (pmos experiment help)' }),
@@ -13,6 +13,7 @@
13
13
  * GET /api/drift/slip?ws=<id> → { ok, ws, name, notRead, today, initiatives, tasks, days, unsourced_days } open tasks behind
14
14
  * their first plan (initiative slip-baseline-contradictions, lib/plan-baseline.js); read-only
15
15
  * GET /api/drift/contradictions?ws=<id> → { ok, ws, name, notRead, items, total } records that disagree (lib/contradictions.js); read-only
16
+ * /api/spec-drift[/act|/undo] Library › Drift: specs and code that no longer match (lib/routes-spec-drift.js, which says what each does)
16
17
  *
17
18
  * THE SWITCH. PMOS_DRIFT=off, or the shared guard's switch (lib/ai-guard.js off: PMOS_AI, the ai settings): every GET answers { ok, on: false }
18
19
  * and every POST 409. WHO WRITES: a POST that carries an agent session header is refused (403); pm-guard requirePagePress checks the page. */
@@ -30,6 +31,8 @@ function isOn(ctx) {
30
31
  }
31
32
 
32
33
  async function handle(req, res, url, ctx) {
34
+ // Library › Drift, spec and code (initiative spec-code-drift): its own module, under this module's place in the route table
35
+ if (url.pathname === '/api/spec-drift' || url.pathname.startsWith('/api/spec-drift/')) return require('./routes-spec-drift.js').handle(req, res, url, ctx);
33
36
  const send = (r) => { ctx.json(res, r.body, r.status); return true; };
34
37
  const what = url.pathname.replace(/^\/api\/drift\/?/, '');
35
38
  const dir = D.dirOf(ctx.runtimeDir);
@@ -115,4 +118,4 @@ async function handle(req, res, url, ctx) {
115
118
  return send({ status: 200, body: { ok: true } });
116
119
  }
117
120
 
118
- module.exports = { prefixes: ['/api/drift'], handle };
121
+ module.exports = { prefixes: ['/api/drift', '/api/spec-drift'], handle };