create-pmos 0.754.0 → 0.756.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.754.0",
3
+ "version": "0.756.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,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.756.0",
38
+ "at": "2026-11-24T01:12:35.636Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1704,
43
+ "t": "Line tab on Work and Today's dashed line (quiet rows slice B)",
44
+ "s": "Line tab on Work and Today's dashed line (quiet rows slice B)",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.755.0",
51
+ "at": "2026-11-24T00:55:56.769Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1699,
56
+ "t": "A new product passes a Setup station before PMOS plans its work",
57
+ "s": "A new product passes a Setup station before PMOS plans its work",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.754.0",
38
64
  "at": "2026-11-24T00:39:51.827Z",
@@ -455,129 +481,6 @@
455
481
  }
456
482
  }
457
483
  ]
458
- },
459
- {
460
- "v": "0.735.0",
461
- "at": "2026-11-23T06:26:05.595Z",
462
- "f": 4,
463
- "prs": [
464
- {
465
- "n": 1634,
466
- "t": "Approve icon in the Work popup; one jira pin line in cli.md",
467
- "s": "Approve icon in the Work popup; one jira pin line in cli.md",
468
- "k": "fix"
469
- },
470
- {
471
- "n": 1635,
472
- "t": "Goals uses the full width and opens Ask PMOS on the right",
473
- "s": "Goals uses the full width and opens Ask PMOS on the right",
474
- "k": "fix",
475
- "try": {
476
- "steps": [
477
- "Open Goals and press Ask PMOS."
478
- ],
479
- "see": "Goals fills the width; the chat opens on the right.",
480
- "open": "/premium-goals.html"
481
- }
482
- },
483
- {
484
- "n": 1612,
485
- "t": "Phone initiatives as a list with their own small line, no Gantt",
486
- "s": "Phone initiatives as a list with their own small line, no Gantt",
487
- "k": "new",
488
- "try": {
489
- "steps": [
490
- "On the phone, open Work's initiatives."
491
- ],
492
- "see": "A list where each row has its own start-to-end line. No Gantt.",
493
- "open": "/premium-board.html"
494
- }
495
- },
496
- {
497
- "n": 1624,
498
- "t": "Pmos press-release, a press release and FAQ draft for a bet (A362)",
499
- "s": "Pmos press-release, a press release and FAQ draft for a bet (A362)",
500
- "k": "new",
501
- "try": {
502
- "steps": [
503
- "In a chat, ask: draft a press release for this bet."
504
- ],
505
- "see": "A one-page press release and FAQ from the record, for you to edit."
506
- }
507
- },
508
- {
509
- "n": 1642,
510
- "t": "The case card shows a chat save at once",
511
- "s": "The case card shows a chat save at once",
512
- "k": "fix",
513
- "try": {
514
- "steps": [
515
- "Open an initiative's popup.",
516
- "In its chat, ask it to add a line to the case."
517
- ],
518
- "see": "The case card shows the line without a reload."
519
- }
520
- },
521
- {
522
- "n": 1627,
523
- "t": "The Light ground follows the time of day (A339)",
524
- "s": "The Light ground follows the time of day (A339)",
525
- "k": "new",
526
- "try": {
527
- "steps": [
528
- "Settings, General, turn on Light through the day.",
529
- "Use the Light theme."
530
- ],
531
- "see": "The ground is cool in the morning, warm in the afternoon, dusk in the evening.",
532
- "open": "/today.html?settings=general"
533
- }
534
- }
535
- ]
536
- },
537
- {
538
- "v": "0.732.0",
539
- "at": "2026-11-23T06:02:19.112Z",
540
- "f": 4,
541
- "prs": [
542
- {
543
- "n": 1632,
544
- "t": "Work always opens in the full popup; remove \"Open work beside the page\"",
545
- "s": "Work always opens in the full popup; remove \"Open work beside the page\"",
546
- "k": "fix",
547
- "try": {
548
- "steps": [
549
- "Open any work item.",
550
- "Check the chat's ⋯ menu."
551
- ],
552
- "see": "The full popup every time; Open work beside the page is gone."
553
- }
554
- },
555
- {
556
- "n": 1628,
557
- "t": "Customer signal count on each roadmap item (A157)",
558
- "s": "Customer signal count on each roadmap item (A157)",
559
- "k": "new",
560
- "try": {
561
- "steps": [
562
- "Open Work in List view."
563
- ],
564
- "see": "Items with customer signals show a count in the Next cell; pressing it lists them.",
565
- "open": "/premium-board.html"
566
- }
567
- },
568
- {
569
- "n": 1630,
570
- "t": "Draft positioning and key messages from the strategy, each citing its line (A328)",
571
- "s": "Draft positioning and key messages from the strategy, each citing its line (A328)",
572
- "k": "new",
573
- "try": {
574
- "steps": [
575
- "On a product with a five-line strategy, ask the chat to draft positioning and key messages."
576
- ],
577
- "see": "Each line of the draft cites the strategy line it came from."
578
- }
579
- }
580
- ]
581
484
  }
582
485
  ]
583
486
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@21f89ae5
1
+ kernel-source: pmos@d95d3179
2
2
  assembled: 2026-11-24
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-24T00:39:49Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T01:12:31Z"}
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-24T00:39:49Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T01:12:31Z"}
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-24T00:39:49Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T01:12:31Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.756.0",
4
+ "at": "2026-11-24T01:12:35.636Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1704,
9
+ "t": "Line tab on Work and Today's dashed line (quiet rows slice B)",
10
+ "s": "Line tab on Work and Today's dashed line (quiet rows slice B)",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.755.0",
17
+ "at": "2026-11-24T00:55:56.769Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1699,
22
+ "t": "A new product passes a Setup station before PMOS plans its work",
23
+ "s": "A new product passes a Setup station before PMOS plans its work",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.754.0",
4
30
  "at": "2026-11-24T00:39:51.827Z",
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "The Backlog"
4
4
  description: "Every open task of your products in one list, the way Jira lists them, and the tasks PMOS takes and finishes itself."
5
- timestamp: 2026-11-23
5
+ timestamp: 2026-11-24
6
6
  ---
7
7
 
8
8
  # The Backlog
@@ -12,12 +12,23 @@ The Backlog lists every open task of the products you picked, the way Jira's bac
12
12
  ## Open it
13
13
 
14
14
  1. Go to **Board**. Work shows.
15
- 2. Press **Backlog** on the switch at the top, **Initiatives | Backlog**. The number beside it is how many tasks are open.
15
+ 2. Press **Backlog** on the switch at the top, **Initiatives | Line | Backlog | This sprint**. The number beside it is how many tasks are open.
16
16
 
17
17
  On a phone the switch has its own line above the list. PMOS remembers your choice for each pick of products. A screen reader reads the switch as a set of tabs named "Work".
18
18
 
19
19
  The Work page uses the PMOS design system (see [Layout](layout.md#the-design-system)): the switch is its Tabs, the toolbar buttons its Buttons, and the timeline its chart colours. Done is leaf green, now is blue, planned is grey, and late and the today line are the alert colour.
20
20
 
21
+ ## The Line
22
+
23
+ Press **Line** on the switch to see every live initiative of your pick in one table, in groups by workflow station (for example Discovery, then Implementation). The address `/premium-board.html?work=line` opens it directly.
24
+
25
+ - The sentence above the table says where the line stands, for example "9 initiatives on the line. 7 move by themselves. 1 stuck."
26
+ - The columns are **Initiative**, **Days here** ("day 6", or "4 of 15" when the station has a limit), **Still missing to finish**, **Next move** and **State**.
27
+ - The tabs **All**, **Stuck**, **Can't tell** and **Your move** filter the table. A tab with nothing in it is not shown.
28
+ - A row that waits on you reads "your move". You answer it on Today, so it is marked here and not repeated there.
29
+ - Waiting for a free builder is not stuck: it reads "moving". "Can't tell" means PMOS could not place the initiative, so it leaves it alone.
30
+ - Press an initiative's name to open it.
31
+
21
32
  ## The columns
22
33
 
23
34
  | Column | What it shows |
@@ -51,6 +51,15 @@ Some computers have no global git name and email, so each repository keeps its o
51
51
 
52
52
  Type `pmos git-identity` in the repository to see the identity it commits as and the GitHub login it pushes with. When one is missing, the result lists the ones your other repositories use. To save your choice for this repository only, type `pmos git-identity set --name "Your Name" --email you@example.com --login your-github-login`. To save only the login, type `pmos git-identity set --login your-github-login`. After that, `git push` in the repository uses that login, whichever login `gh` has active. Your global git settings do not change.
53
53
 
54
+ ### pmos setup: the Setup station of a new product
55
+
56
+ A new product passes Setup when three things are recorded: its tracker was read, at least one goal is agreed, and it has an owner. Until then, PMOS runs only Triage and the documents part of Discovery on it. A product with work already past Discovery is not held.
57
+
58
+ - `pmos setup` (or `pmos setup check`) shows the three items, each with the record it rests on, and the next proposal. The number of items met is on the last line.
59
+ - `pmos setup agree goal` keeps the goal PMOS drafted. The goal loses its PROPOSED mark.
60
+ - `pmos setup owner "<name>"` writes the owner in project-context.md.
61
+ - `pmos setup undo` takes the last of these two back. It does nothing when the file was changed since.
62
+
54
63
  ## Your day
55
64
 
56
65
  ### pmos today
@@ -49,6 +49,7 @@ Home, the Board, Insights and the Viewer use one typeface, Plus Jakarta Sans, wi
49
49
  - **At most 5 show.** The rest are under **Can wait**, in the same order. Nothing is dropped.
50
50
  - **At most 3 rows a day for each product.** A row from a product's own records counts toward the 3: an open question, a check, a grill finding, a date change from a meeting, a key result, or a change PMOS proposes on an initiative. A reply someone waits for, your own task and a draft never count. The rows are fixed the first time Today shows them that day. When you finish a row, nothing takes its place until tomorrow. A new row that holds up a ship date takes the place of that product's lowest row and never makes a fourth. Rows over the 3 wait under **Later** with "Waits for tomorrow". A product with nothing for you has no row.
51
51
  - **Today's batch.** Everything other people will see (a review request, Jira tickets, a follow-up, a closed ask) is one row: "Today's batch: 5 to send". Press it to open the batch full size. **Back** returns to Today. The drafts are in groups by kind, and each one says who will see it. ✎ **Change it first** opens the draft, ✕ **Skip** drops it (with Undo), and ✓ **Approve** sends it. When more than one draft waits, PMOS suggests **Approve and send all**. Nothing is sent until you press. If no channel is connected yet, the draft stays in the batch and says so. A draft you leave for 7 days lapses and is not sent. On a phone the batch shows one draft at a time, full text first: swipe right to approve, left to skip.
52
+ - **The dashed line.** Your move ends with one dashed line, for example "9 more move in the line by themselves · none stuck" (or "· 1 stuck"). It counts the live initiatives of your products that do not wait on you. Press it to open the Line on Work. With nothing on the line there is no dashed line.
52
53
  - **One press per initiative.** An initiative's proposals are one row, for example "Checkout: 6 changes to keep" with "3 dates, 2 names, 1 link" under it. Press it to see them grouped as Dates, Names, Done and Links. ✓ keeps all of them, with one Undo for the batch. ✕ drops them, then offers three reasons and **Say why**. A proposal that needs your own check keeps its own ✓ and ✕. **See every change** opens the full list on the initiative.
53
54
  - **An ask expires after 14 days with no answer.** PMOS leaves it as it was and writes why in the initiative's History. Your move says it once: "2 asks expired after 14 days with no answer." Dates computed from your tasks never expire: PMOS reads them again each time.
54
55
  - **Done** lists what PMOS finished by itself in the last 14 days, one line each with Undo.
@@ -33,6 +33,7 @@ const D = require('./driver.js');
33
33
  const decideLib = require('./driver-decide.js');
34
34
  const stageTools = require('./stage-tools.js');
35
35
  const stateRoot = require('./state-root.js');
36
+ const setupLib = require('./setup-station.js');
36
37
 
37
38
  const COMMANDS = { driver: ['propose', 'status', 'exits', 'keep', 'return', 'drop', 'undo', 'pause', 'resume', 'mode'] };
38
39
  const USAGE = [
@@ -147,6 +148,12 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
147
148
  if (flags.effort !== undefined) asked.effort = String(flags.effort).toUpperCase();
148
149
  const c = D.checkProposal({ ...target(), what: flags.what, data: d.data, why: flags.why, sources: s.sources, ...asked });
149
150
  if (!c.ok) return fail(c.error);
151
+ // setup-station: until a new product passes Setup, only Triage and the documents part of Discovery run (lib/setup-station.js gate)
152
+ if (c.proposal.target.kind === 'initiative' && !setupLib.DOC_WHATS.includes(c.proposal.what)) {
153
+ const sr = setupLib.check(setupLib.read(root, { runtimeDir: stateRoot.defaultRoot() }));
154
+ const g = setupLib.gate(sr, sr.passed ? [] : setupLib.stepsOf(root), { what: c.proposal.what, data: c.proposal.data });
155
+ if (!g.ok) { console.error(`[setup] held ${c.proposal.what} on ${c.proposal.target.id}: missing ${sr.missing.join(', ')}`); return fail(g.error); }
156
+ }
150
157
  const actor = actorLib.fromCli(who);
151
158
  const state = D.fold(D.readLines(file));
152
159
  const same = JSON.stringify(c.proposal.data);
@@ -41,6 +41,7 @@ const PROVIDERS = Object.freeze([
41
41
  'decision-journal-needs', // decision-journal-outcome-checks: a journal decision whose check date came, with no verdict (kind 1)
42
42
  'parked-reasons', // parked-reason-way-back (bet A446): a parked initiative whose way back is met, to bring back (kind 7)
43
43
  'product-health', // product-health-score: a product's health score fell 10 points or more against its past week (kind 8)
44
+ 'setup-station', // setup-station: a product that has not passed Setup (tracker read, agreed goal, owner), with the next ✦ (kind 7)
44
45
  ]);
45
46
  /** Kinds that already mean something in the needs queue. A provider may not reuse one. */
46
47
  const RESERVED_KINDS = Object.freeze(['question', 'accept', 'outcome', 'keep', 'evidence', 'plan-flag', 'provider-error']);
@@ -179,6 +179,9 @@ const VERBS = Object.freeze({
179
179
  // one-change-record-no-source-no-auto: everything PMOS changed by itself, in one record (lib/change-record.js)
180
180
  health: Object.freeze({ module: 'product-health-cli.js', run: null, guide: 'cli.md',
181
181
  help: 'pmos health [score|trend|drops] — this product\'s health score (0 to 100), its trend this month and its past drops (pmos health help)' }),
182
+ // Not a pm-os-absorb verb (run: null): initiative setup-station (product line slice 5) added it through the same table.
183
+ setup: Object.freeze({ module: 'setup-cli.js', run: null, guide: 'cli.md',
184
+ help: 'pmos setup [agree goal|owner "<name>"|undo] — the Setup station of a new product: tracker read, an agreed goal and an owner (pmos setup help)' }),
182
185
  factory: Object.freeze({ module: 'factory-cli.js', run: null, guide: 'cli.md',
183
186
  help: 'pmos factory today [--days N] — everything PMOS changed by itself, per line and station, with what cites no source (pmos factory help)' }),
184
187
  // D106 (Full autonomy now): what agents do by themselves, and the goals they work on until done
@@ -20,7 +20,11 @@
20
20
  * each smallest test that was named and has no result yet.
21
21
  * DEFAULTS (default-decisions-with-a-deadline, lib/default-decisions.js): each question carries `default` ({ choice, due, n, say } | null),
22
22
  * `waits` (why it has no default | null), `waiting` (days on the list) and `cost` (A27: what the wait holds up | null). The read takes the
23
- * defaults due today (one batch each, with Undo in "PMOS did"), and `taken` lists them. A dry-run gap or a sign-off never defaults. */
23
+ * defaults due today (one batch each, with Undo in "PMOS did"), and `taken` lists them. A dry-run gap or a sign-off never defaults.
24
+ *
25
+ * GET /api/line?ws=<id> → { ok, ws, rows: [lib/line.js lineOf row + ws], you: [initiative id] } (quiet-rows slice B: Work's Line
26
+ * tab and Today's dashed line). lineOf reads every row of the repository, so it runs in a child process and its answer is kept LINE_MS per
27
+ * product. you: the initiatives with a question to the PM or a check due today (they are in Your move). */
24
28
  const YM = require('./your-move.js');
25
29
 
26
30
  const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
@@ -115,10 +119,53 @@ function asksOf(root, now = Date.now()) {
115
119
  return out;
116
120
  }
117
121
 
122
+ const LINE_MS = 5 * 60e3;
123
+ const LINES = new Map(); // ws → { at, rows, p? }
124
+ /** lineOf in a child process: it reads every record and the git history of the repository, which must not hold the server's event loop. */
125
+ function lineChild(root, now) {
126
+ const { execFile } = require('child_process');
127
+ const src = "const L=require(" + JSON.stringify(require.resolve('./line.js')) + ");const r=L.lineOf(process.argv[1],{now:+process.argv[2]});process.stdout.write(JSON.stringify(r))";
128
+ return new Promise((resolve) => execFile(process.execPath, ['-e', src, root, String(now)], { cwd: root, maxBuffer: 64 * 1024 * 1024, timeout: 120000 }, (err, out) => {
129
+ if (err) { resolve(null); return; }
130
+ try { resolve(JSON.parse(out)); } catch { resolve(null); }
131
+ }));
132
+ }
133
+ /** The product's line (lib/line.js lineOf), kept LINE_MS. A stale answer is served at once while a new read runs; the first read waits. */
134
+ async function lineRows(w, now = Date.now()) {
135
+ const c = LINES.get(w.id);
136
+ if (c && now - c.at < LINE_MS) return c.rows;
137
+ if (c && c.p) return c.rows || c.p;
138
+ const p = lineChild(w.root, now).then((L) => {
139
+ const rows = L && L.ok ? (L.rows || []).map((r) => ({ ...r, ws: w.id })) : [];
140
+ LINES.set(w.id, { at: Date.now(), rows });
141
+ console.info('[quiet-rows-line] line read ws=' + w.id + ' rows=' + rows.length);
142
+ return rows;
143
+ });
144
+ LINES.set(w.id, { at: c ? c.at : 0, rows: c ? c.rows : null, p });
145
+ return c && c.rows ? c.rows : p;
146
+ }
147
+ /** The initiatives of a product that are in Your move: a question to the PM, or a check due today. */
148
+ function youOf(ctx, w, today) {
149
+ const out = new Set();
150
+ try { for (const q of questions(ctx, w, today, { take: false }).questions || []) if (q.toPm && q.ini) out.add(String(q.ini)); } catch { /* none read */ }
151
+ try { for (const v of verdicts(ctx, w, today)) if (v.ini) out.add(String(v.ini)); } catch { /* none read */ }
152
+ return [...out];
153
+ }
154
+
118
155
  module.exports = {
119
- expire, questions, asksOf,
120
- prefixes: ['/api/your-move'],
156
+ expire, questions, asksOf, lineRows,
157
+ prefixes: ['/api/your-move', '/api/line'],
121
158
  handle: async (req, res, url, ctx) => {
159
+ if (url.pathname === '/api/line') {
160
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
161
+ let w = null;
162
+ try { w = ctx.getWs(url.searchParams.get('ws') || null); } catch { w = null; }
163
+ if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
164
+ let rows = [];
165
+ try { rows = await lineRows(w); } catch (e) { ctx.json(res, { ok: false, error: 'the line could not be read: ' + (e && e.message) }, 500); return true; }
166
+ ctx.json(res, { ok: true, ws: w.id, rows, you: youOf(ctx, w, localDay()) });
167
+ return true;
168
+ }
122
169
  if (url.pathname !== '/api/your-move') return false;
123
170
  if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
124
171
  let w = null;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+ /* setup-cli.js — `pmos setup`: the Setup station of this product (initiative setup-station). The work is in lib/setup-station.js; this file
3
+ * is the verb's entry in lib/pmos-verbs.js. Reads, except the two approvals (agree goal, owner) and their undo. */
4
+ const S = require('./setup-station.js');
5
+
6
+ const COMMANDS = S.COMMANDS;
7
+ const USAGE = S.USAGE;
8
+ function run(argv, { say = (s) => console.log(s) } = {}) {
9
+ const args = argv[0] === 'setup' ? argv.slice(1) : argv.slice();
10
+ return S.cli(args, { say });
11
+ }
12
+
13
+ module.exports = { COMMANDS, USAGE, run };
@@ -0,0 +1,400 @@
1
+ 'use strict';
2
+ /* setup-station.js — the Setup station of the product line: a new product passes it before PMOS plans its work (initiative setup-station;
3
+ * product line plan, doc Ejs4HXyqpenvaiqiRMtzoF tab Plan, slice 5, agreed by the PM 2026-11-24).
4
+ *
5
+ * read(root, { runtimeDir }) → facts the three exit items as the records state them. Reads only; never writes
6
+ * check(facts) → result PURE. { passed, met, of: 3, items: [item], missing: [label], next: proposal | null }
7
+ * holds(result, steps) → bool PURE. Is the gate shut? Only while Setup has not passed AND the product is new
8
+ * gate(result, steps, { what, data }) → { ok } | { ok: false, error } PURE. May the Driver file this proposal now?
9
+ * stepsOf(root) → [step] | null the lifecycle step of each initiative (lib/stage-read.js), null when unreadable
10
+ * agreeGoal(root, { now, by }) · setOwner(root, name, { now, by }) · undo(root, { now, by }) the PM's approvals, with Undo
11
+ * kinds · rowsFor(w, { lead }) · sig(w) the Today row (lib/needs-providers.js)
12
+ * cli(argv, { say, cwd }) `pmos setup [check|agree goal|owner "<name>"|undo]`
13
+ *
14
+ * THE EXIT TEST (Connect station). A product passes when its records show all three:
15
+ * tracker the tracker was read: a Jira status snapshot (<state>/tracker/jira/<initiative>.md, lib/jira-status.js) or the tracker read stamp
16
+ * (lib/tracker-read.js, `pmos tracker done`). Connecting the tracker is the person's: PMOS cannot do it for them.
17
+ * goal at least one AGREED goal: a key result of the OKR files (lib/okr-goals.js) not marked PROPOSED. A PROPOSED one is a draft PMOS
18
+ * offers for one approval (`pmos setup agree goal`).
19
+ * owner the Owner line of project-context.md (lib/project-onboard.js readContext). With none, PMOS offers the person who committed most
20
+ * in the last 90 days, from git, for one approval (`pmos setup owner "<name>"`).
21
+ * A record that cannot be read is "can't tell", never a pass (the plan's rule 1).
22
+ *
23
+ * THE GATE. Until Setup passes, only Triage and the documents part of Discovery run: the Driver may file problem, evidence, assumption, note,
24
+ * doc, artefact and overlap proposals and a move into a Triage or Discovery stage; sizing, stakeholders and any later move wait. It holds only
25
+ * while the product is NEW: when one of its initiatives already stands past Discovery (its records put it there, by the person or the tracker),
26
+ * the product is running and the gate stays open (the plan's rule 2, the outside wins). A product that cannot be read holds.
27
+ *
28
+ * THE LEDGER is <state>/setup.jsonl, one line per approval: { v: 1, ev: 'agree' | 'owner' | 'undo', file, before, after, at, by }. Undo puts
29
+ * the file back only while nobody changed it since. Nothing here sends anything or calls a model. Works on any product built with PMOS.
30
+ */
31
+ const fs = require('fs');
32
+ const path = require('path');
33
+ const { spawnSync } = require('child_process');
34
+
35
+ const TAG = '[setup]';
36
+ const NAME = 'setup-station';
37
+ const KIND = 'setup-station';
38
+ const LEDGER = 'setup.jsonl';
39
+ const OF = 3;
40
+ const DOC_WHATS = Object.freeze(['problem', 'evidence', 'assumption', 'note', 'doc', 'artefact', 'overlap']);
41
+ const OPEN_STEPS = Object.freeze(['triage', 'discover']);
42
+ const DISCOVER_STAGE = /\b(triage|discover|discovery|intake)\b/i;
43
+ const BOT = /\[bot\]|\bbot\b|^claude$|^github-actions|^dependabot|noreply@anthropic\.com|^noreply@github\.com$|^actions@github/i;
44
+ const LABEL = { tracker: 'tracker read', goal: 'an agreed goal', owner: 'an owner' };
45
+
46
+ const clip = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
47
+ const mtime = (f) => { try { return fs.statSync(f).mtimeMs; } catch { return 0; } };
48
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
49
+ const day = (ms) => new Date(ms).toISOString().slice(0, 10);
50
+
51
+ function stateDirOf(root) { try { return require('./driver.js').stateDirOf(root); } catch { return null; } }
52
+ function planningOf(root) {
53
+ try { const pm = require('./project-onboard.js').pmosIn(root); if (pm) return pm.planning; } catch { /* below */ }
54
+ return fs.existsSync(path.join(root, 'pmos', 'planning')) ? path.join(root, 'pmos', 'planning') : path.join(root, 'planning');
55
+ }
56
+ const okrDirOf = (root) => [path.join(root, 'pmos', 'planning', 'okrs'), path.join(root, 'planning', 'okrs')].find((d) => fs.existsSync(d)) || null;
57
+
58
+ // ── reading the records ──────────────────────────────────────────────────────────────────────────────────
59
+
60
+ function trackerOf(root, runtimeDir) {
61
+ const out = { at: 0, via: null };
62
+ try {
63
+ const sd = stateDirOf(root);
64
+ const j = sd ? require('./freshness.js').jiraAsOf(sd) : 0;
65
+ if (j > out.at) { out.at = j; out.via = 'Jira status read'; }
66
+ } catch { /* the other read answers */ }
67
+ try {
68
+ const t = runtimeDir ? require('./tracker-read.js').readAtMs(runtimeDir, root) : 0;
69
+ if (t > out.at) { out.at = t; out.via = 'tracker items read'; }
70
+ } catch { /* none */ }
71
+ return out;
72
+ }
73
+
74
+ function goalsOf(root) {
75
+ let okr;
76
+ try { okr = require('./okr-goals.js').read(root); } catch (e) { return { error: 'the OKR files could not be read' }; }
77
+ if (!okr.ok) return { agreed: [], proposed: [], files: [] };
78
+ const krs = okr.objectives.flatMap((o) => o.krs.map((k) => ({ token: `${o.token}.${k.token}`, kr: k.token, title: k.title, proposed: !!k.proposed })));
79
+ return { agreed: krs.filter((k) => !k.proposed), proposed: krs.filter((k) => k.proposed), files: okr.files };
80
+ }
81
+
82
+ function contextOf(root) {
83
+ const file = path.join(planningOf(root), 'project-context.md');
84
+ const text = readText(file);
85
+ if (text == null) return { file, exists: false, ctx: null };
86
+ try { return { file, exists: true, ctx: require('./project-onboard.js').readContext(text) }; } catch { return { file, exists: true, ctx: null, error: true }; }
87
+ }
88
+
89
+ /** The person who committed most in the last 90 days: a draft owner, with its source. null with no git or no commits. */
90
+ function ownerDraftOf(root) {
91
+ const r = spawnSync('git', ['shortlog', '-sne', '--no-merges', '--since=90.days', 'HEAD'], { cwd: root, encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
92
+ if (r.status !== 0) return null;
93
+ for (const line of String(r.stdout || '').split('\n')) {
94
+ const m = /^\s*(\d+)\s+(.+?)\s+<([^>]*)>\s*$/.exec(line);
95
+ if (!m || BOT.test(m[2]) || BOT.test(m[3])) continue; // an agent or a bot commits; it does not own the product
96
+ return { name: clip(m[2], 80), source: `git: ${m[1]} commit${m[1] === '1' ? '' : 's'} in the last 90 days, the most of any person` };
97
+ }
98
+ return null;
99
+ }
100
+
101
+ function read(root, { runtimeDir = null, ownerDraft = ownerDraftOf } = {}) {
102
+ const ctx = contextOf(root);
103
+ const owner = ctx.ctx && ctx.ctx.fields && ctx.ctx.fields.owner ? ctx.ctx.fields.owner : null;
104
+ const g = goalsOf(root);
105
+ return {
106
+ name: (ctx.ctx && ctx.ctx.name) || path.basename(path.resolve(root)),
107
+ tracker: trackerOf(root, runtimeDir),
108
+ goals: g.error ? { error: g.error } : g,
109
+ owner: ctx.error ? { error: 'project-context.md could not be read' } : owner ? { value: owner.value, source: owner.source, file: path.relative(root, ctx.file) } : null,
110
+ ownerDraft: owner || ctx.error ? null : (ownerDraft ? ownerDraft(root) : null),
111
+ goalDraft: ctx.ctx && ctx.ctx.goal ? ctx.ctx.goal : null,
112
+ };
113
+ }
114
+
115
+ // ── the exit test ────────────────────────────────────────────────────────────────────────────────────────
116
+
117
+ /** facts (read() or a test's) → { passed, met, of, items: [{ key, label, status: 'ok'|'missing'|"can't tell", quote }], missing, next }. PURE. */
118
+ function check(facts) {
119
+ const f = facts || {};
120
+ const items = [];
121
+ const t = f.tracker || {};
122
+ items.push(t.at > 0 ? { key: 'tracker', label: LABEL.tracker, status: 'ok', quote: `${t.via || 'tracker read'} on ${day(t.at)}` }
123
+ : { key: 'tracker', label: LABEL.tracker, status: 'missing', quote: 'no Jira status snapshot and no tracker read recorded' });
124
+ const g = f.goals || {};
125
+ if (g.error) items.push({ key: 'goal', label: LABEL.goal, status: "can't tell", quote: g.error });
126
+ else if ((g.agreed || []).length) items.push({ key: 'goal', label: LABEL.goal, status: 'ok', quote: `${g.agreed[0].token}: ${g.agreed[0].title}` + (g.agreed.length > 1 ? ` and ${g.agreed.length - 1} more` : '') });
127
+ else items.push({ key: 'goal', label: LABEL.goal, status: 'missing', quote: (g.proposed || []).length ? `${g.proposed.length} drafted, none agreed yet` : 'no goal in the OKR files' });
128
+ const o = f.owner;
129
+ if (o && o.error) items.push({ key: 'owner', label: LABEL.owner, status: "can't tell", quote: o.error });
130
+ else if (o && o.value) items.push({ key: 'owner', label: LABEL.owner, status: 'ok', quote: `${o.value} (${o.file || 'project-context.md'})` });
131
+ else items.push({ key: 'owner', label: LABEL.owner, status: 'missing', quote: 'no Owner line in project-context.md' });
132
+ const met = items.filter((i) => i.status === 'ok').length;
133
+ const missing = items.filter((i) => i.status !== 'ok').map((i) => i.label);
134
+ return { passed: met === OF, met, of: OF, items, missing, next: nextOf(items, f) };
135
+ }
136
+
137
+ /** The one ✦ proposal for what is still missing, in the order the person can act on it fastest: a drafted goal or owner first (one approval),
138
+ * then the tracker (the person connects it). null when nothing is missing. PURE. */
139
+ function nextOf(items, f) {
140
+ const miss = (k) => items.some((i) => i.key === k && i.status === 'missing');
141
+ const g = f.goals || {};
142
+ if (miss('goal') && (g.proposed || []).length) {
143
+ const p = g.proposed[0];
144
+ return { key: 'goal', label: 'Agree goal', text: `Agree the drafted goal ${p.token}: ${p.title}`, cli: 'pmos setup agree goal', source: (g.files || [])[0] || 'the OKR file' };
145
+ }
146
+ if (miss('goal') && f.goalDraft && f.goalDraft.kr) {
147
+ return { key: 'goal', label: 'Agree goal', text: `Agree the drafted goal: ${clip(f.goalDraft.kr, 120)}`, cli: 'pmos setup agree goal', source: 'project-context.md (Goal draft)' };
148
+ }
149
+ if (miss('owner') && f.ownerDraft && f.ownerDraft.name) {
150
+ return { key: 'owner', label: 'Keep owner', text: `Make ${f.ownerDraft.name} the owner`, cli: `pmos setup owner "${f.ownerDraft.name.replace(/"/g, '')}"`, source: f.ownerDraft.source };
151
+ }
152
+ if (miss('tracker')) return { key: 'tracker', label: 'Connect tracker', text: 'Connect the tracker in Settings › Sources; PMOS reads it on the next refresh', cli: 'pmos setup', source: null };
153
+ if (miss('goal')) return { key: 'goal', label: 'Add a goal', text: 'Add one goal: tell the chat what this product must achieve', cli: 'pmos setup', source: null };
154
+ if (miss('owner')) return { key: 'owner', label: 'Name owner', text: 'Name the owner: pmos setup owner "<name>"', cli: 'pmos setup', source: null };
155
+ return null;
156
+ }
157
+
158
+ // ── the gate ─────────────────────────────────────────────────────────────────────────────────────────────
159
+
160
+ /** Is the gate shut? steps: the lifecycle step of each initiative (lib/one-stage.js keys), or null when unreadable. PURE. */
161
+ function holds(result, steps) {
162
+ if (!result || result.passed) return false;
163
+ if (!Array.isArray(steps)) return true; // can't tell: hold
164
+ return !steps.some((s) => s && !OPEN_STEPS.includes(s));
165
+ }
166
+
167
+ /** May the Driver file this proposal now? PURE. */
168
+ function gate(result, steps, { what, data } = {}) {
169
+ if (!holds(result, steps)) return { ok: true };
170
+ if (DOC_WHATS.includes(what)) return { ok: true };
171
+ if (what === 'move' && data && DISCOVER_STAGE.test(String(data.to || ''))) return { ok: true };
172
+ return { ok: false, error: `this product has not passed Setup yet (missing: ${result.missing.join(', ')}), so only Triage and the documents part of Discovery run: a ${what} proposal waits. See pmos setup` };
173
+ }
174
+
175
+ /** The lifecycle step of every initiative of the product, as the Board reads it. null when the records cannot be read. */
176
+ const RUNNING_FILE = 'setup-running.json';
177
+ const RUNNING_FOR_MS = 24 * 3600 * 1000;
178
+ function stepsOf(root, { now = Date.now(), derive = true } = {}) {
179
+ // reading every stage derives the Board's rows (seconds on a big product); a product seen running stays running for a day
180
+ // the cache is runtime state, never a repository file: <runtime>/setup/<hash of the repository path>.json
181
+ const rd = runtimeDirOf();
182
+ const cache = rd ? path.join(rd, 'setup', require('crypto').createHash('sha1').update(path.resolve(root)).digest('hex').slice(0, 16) + '-' + RUNNING_FILE) : null;
183
+ try { const c = JSON.parse(readText(cache) || 'null'); if (c && c.step && now - Date.parse(c.at) < RUNNING_FOR_MS) return [c.step]; } catch { /* read again */ }
184
+ const steps = readSteps(root, derive);
185
+ const past = (steps || []).find((x) => x && !OPEN_STEPS.includes(x));
186
+ if (past && cache) { try { writeFile(cache, JSON.stringify({ step: past, at: new Date(now).toISOString() }) + '\n'); } catch { /* read again next time */ } }
187
+ return steps;
188
+ }
189
+ function readSteps(root, derive) {
190
+ try {
191
+ const SR = require('./stage-read.js');
192
+ const boards = require('./routes-boards.js');
193
+ const rowsLib = require('./initiative-rows.js');
194
+ const { w, ctx } = SR.cliCtx(root);
195
+ if (!ctx.stateDirFor()) return null;
196
+ // derive: true (a terminal) reads the records now; false (the server's Today row) takes the rows the server already read, and a read
197
+ // still running answers null, "can't tell"
198
+ const was = derive ? rowsLib.setBackground(false) : null;
199
+ try {
200
+ if (derive) { try { rowsLib.deriveNow(root); } catch { /* baseRows says */ } }
201
+ const base = boards.baseRows(w, { ...ctx, boardsPass: new Map() });
202
+ if (!base.ok) return null;
203
+ // one fold of the Board for the whole list; it stops at the first initiative past Discovery, since one is enough to open the gate
204
+ const pass = { ...ctx, boardsPass: new Map() };
205
+ const out = [];
206
+ for (const r of base.rows) {
207
+ let a = null; try { a = SR.stageOf(pass, w, r.id); } catch { a = null; }
208
+ const step = a ? (a.stage === 'shipped' ? 'monitor' : a.step || null) : null;
209
+ out.push(step);
210
+ if (step && !OPEN_STEPS.includes(step)) break;
211
+ }
212
+ return out;
213
+ } finally { if (derive) rowsLib.setBackground(was); }
214
+ } catch { return null; }
215
+ }
216
+
217
+ // ── the person's approvals, with Undo ───────────────────────────────────────────────────────────────────
218
+
219
+ function ledgerFile(root) { const sd = stateDirOf(root); return sd ? path.join(sd, LEDGER) : null; }
220
+ function readLedger(root) {
221
+ const f = ledgerFile(root);
222
+ const t = f ? readText(f) : null;
223
+ if (!t) return [];
224
+ return t.split('\n').map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
225
+ }
226
+ function append(root, line, now) {
227
+ const f = ledgerFile(root);
228
+ if (!f) throw new Error('this repository has no PMOS state folder (pmos/state, state or .pmos)');
229
+ const rec = { v: 1, ...line, at: new Date(now).toISOString() };
230
+ fs.appendFileSync(f, JSON.stringify(rec) + '\n');
231
+ return rec;
232
+ }
233
+ function writeFile(file, text) {
234
+ fs.mkdirSync(path.dirname(file), { recursive: true });
235
+ const tmp = `${file}.${process.pid}.tmp`;
236
+ fs.writeFileSync(tmp, text);
237
+ fs.renameSync(tmp, file);
238
+ }
239
+
240
+ /** Keep the drafted goal: the first PROPOSED key result of the OKR files loses its PROPOSED mark. With no OKR file and a Goal draft in
241
+ * project-context.md, the draft file is written as agreed. → { ok, file, goal } | { ok: false, error } */
242
+ function agreeGoal(root, { now = Date.now(), by = 'pm' } = {}) {
243
+ const dir = okrDirOf(root);
244
+ const g = goalsOf(root);
245
+ if (g.error) return { ok: false, error: g.error };
246
+ if (dir && g.proposed.length) {
247
+ for (const name of g.files) {
248
+ const file = path.join(dir, name);
249
+ const before = readText(file);
250
+ if (before == null) continue;
251
+ const lines = before.split('\n');
252
+ const i = lines.findIndex((l) => /\bPROPOSED\b/.test(l) && /\*\*\s*KR/i.test(l));
253
+ if (i < 0) continue;
254
+ lines[i] = lines[i].replace(/\s*\bPROPOSED\b:?\s*/, ' ').replace(/\*\* +/, '** ');
255
+ const after = lines.join('\n');
256
+ writeFile(file, after);
257
+ append(root, { ev: 'agree', file: path.relative(root, file), before, after, by }, now);
258
+ return { ok: true, file: path.relative(root, file), goal: clip(lines[i].replace(/^\s*-\s*/, ''), 160) };
259
+ }
260
+ }
261
+ const ctx = contextOf(root);
262
+ const draft = ctx.ctx && ctx.ctx.goal;
263
+ if (!draft || !draft.kr) return { ok: false, error: g.agreed.length ? 'a goal is agreed already' : 'there is no drafted goal to agree: tell the chat what this product must achieve' };
264
+ const file = path.join(planningOf(root), 'okrs', 'okrs-draft.md');
265
+ if (fs.existsSync(file)) return { ok: false, error: `${path.relative(root, file)} holds no drafted key result to agree` };
266
+ const OF_ = require('./onboard-fundamentals.js');
267
+ const after = OF_.goalFile(ctx.ctx.name || path.basename(root), draft, ctx.ctx.fields && ctx.ctx.fields.purpose && ctx.ctx.fields.purpose.value, day(now))
268
+ .replace(/\s*\bPROPOSED\b:?\s*/, ' ').replace(/\*\* +/, '** ').replace(' (draft)"', '"').replace(/^# Goals: (.+) \(draft\)$/m, '# Goals: $1')
269
+ .replace(/It is a draft: nothing reads it, and no number is claimed\./, 'The PM agreed it; no number is claimed yet.');
270
+ writeFile(file, after);
271
+ append(root, { ev: 'agree', file: path.relative(root, file), before: null, after, by }, now);
272
+ return { ok: true, file: path.relative(root, file), goal: clip(draft.kr, 160) };
273
+ }
274
+
275
+ /** Name the owner: the Owner line of project-context.md, said by the PM. The file is made when there is none. */
276
+ function setOwner(root, name, { now = Date.now(), by = 'pm' } = {}) {
277
+ const who = clip(name, 80).replace(/[()]/g, '');
278
+ if (!who) return { ok: false, error: 'give the owner\'s name: pmos setup owner "<name>"' };
279
+ const { file } = contextOf(root);
280
+ const before = readText(file);
281
+ const line = `- **Owner:** ${who} (source: the PM)`;
282
+ let after;
283
+ if (before == null) {
284
+ const title = path.basename(path.resolve(root));
285
+ after = ['---', 'type: Reference', `title: "Project context: ${title.replace(/"/g, "'")}"`, `timestamp: ${day(now)}`, '---', '', `# ${title}`, '', line, ''].join('\n');
286
+ } else if (/^- \*\*Owner:\*\*.*$/m.test(before)) after = before.replace(/^- \*\*Owner:\*\*.*$/m, line);
287
+ else after = before.replace(/\n*$/, '\n') + line + '\n';
288
+ writeFile(file, after);
289
+ append(root, { ev: 'owner', file: path.relative(root, file), before, after, by }, now);
290
+ return { ok: true, file: path.relative(root, file), owner: who };
291
+ }
292
+
293
+ /** Undo the newest approval not undone yet, while its file still holds what it wrote. */
294
+ function undo(root, { now = Date.now(), by = 'pm' } = {}) {
295
+ const lines = readLedger(root);
296
+ const undone = new Set(lines.filter((l) => l.ev === 'undo').map((l) => l.of));
297
+ const last = [...lines].reverse().find((l) => (l.ev === 'agree' || l.ev === 'owner') && !undone.has(l.at + '|' + l.file));
298
+ if (!last) return { ok: false, error: 'nothing to undo' };
299
+ const file = path.join(root, last.file);
300
+ if (readText(file) !== last.after) return { ok: false, error: `${last.file} changed since, so it is left as it is` };
301
+ if (last.before == null) fs.unlinkSync(file); else writeFile(file, last.before);
302
+ append(root, { ev: 'undo', of: last.at + '|' + last.file, file: last.file, by }, now);
303
+ return { ok: true, file: last.file, what: last.ev };
304
+ }
305
+
306
+ // ── the Today row (lib/needs-providers.js) ──────────────────────────────────────────────────────────────
307
+
308
+ function runtimeDirOf() { try { return require('./state-root.js').defaultRoot(); } catch { return null; } }
309
+
310
+ function rowsFor(w, { lead, runtimeDir = runtimeDirOf(), facts, steps } = {}) {
311
+ if (!lead || !w || !w.root) return [];
312
+ const f = facts || read(w.root, { runtimeDir });
313
+ const r = check(f);
314
+ if (r.passed) return [];
315
+ // no row (zero is silence) for: a product with no initiative yet (nothing to hold), a running product (an initiative past Discovery),
316
+ // and a product whose stages cannot be read yet ("can't tell")
317
+ const st = steps !== undefined ? steps : stepsOf(w.root, { derive: false });
318
+ if (!Array.isArray(st) || !st.length || !holds(r, st)) return [];
319
+ const name = w.name || f.name;
320
+ const cause = `Set up ${name}: ${r.met} of ${r.of} done, ${r.missing.join(' and ')} still missing`;
321
+ const evidence = [r.next ? `✦ ${r.next.text}` + (r.next.source ? ` (from ${r.next.source})` : '') : '', 'Until then PMOS runs only Triage and the documents part of Discovery here']
322
+ .filter(Boolean).join(' · ');
323
+ return [{
324
+ run_id: `${NAME}:${w.id}`, kind: KIND, initiative_id: null, question: cause, doc: null, ws: w.id,
325
+ today: { kind: 7, source: NAME, cause, evidence, act: { label: r.next ? r.next.label : 'See setup', cli: r.next ? r.next.cli : 'pmos setup' } },
326
+ }];
327
+ }
328
+
329
+ function sig(w) {
330
+ if (!w || !w.root) return '';
331
+ const sd = stateDirOf(w.root);
332
+ const okr = okrDirOf(w.root);
333
+ let okrSig = '-';
334
+ try { okrSig = okr ? fs.readdirSync(okr).map((n) => n + ':' + mtime(path.join(okr, n))).join(',') : '-'; } catch { /* - */ }
335
+ let jira = 0; try { jira = sd ? require('./freshness.js').jiraAsOf(sd) : 0; } catch { /* 0 */ }
336
+ let tr = 0; try { const rd = runtimeDirOf(); tr = rd ? require('./tracker-read.js').readAtMs(rd, w.root) : 0; } catch { /* 0 */ }
337
+ return [okrSig, mtime(path.join(planningOf(w.root), 'project-context.md')), jira, tr, sd ? mtime(path.join(sd, LEDGER)) : 0].join('|');
338
+ }
339
+
340
+ // ── the command line ─────────────────────────────────────────────────────────────────────────────────────
341
+
342
+ const USAGE = [
343
+ 'usage: pmos setup [check|agree goal|owner "<name>"|undo] [--json] [--root <dir>] — the Setup station of this product',
344
+ ' pmos setup what Setup still needs: a tracker read, an agreed goal and an owner; the number met on the last line',
345
+ ' pmos setup agree goal keep the goal PMOS drafted (it loses its PROPOSED mark)',
346
+ ' pmos setup owner "<n>" name the owner in project-context.md',
347
+ ' pmos setup undo take the last of these two back, while nobody changed the file since',
348
+ ];
349
+ const COMMANDS = { setup: ['check', 'agree', 'owner', 'undo'] };
350
+
351
+ function cli(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now(), runtimeDir = runtimeDirOf(), ownerDraft } = {}) {
352
+ const args = argv.slice();
353
+ const json = args.includes('--json');
354
+ const ri = args.indexOf('--root');
355
+ let root = null;
356
+ if (ri >= 0) { root = args[ri + 1]; args.splice(ri, 2); }
357
+ const pos = args.filter((a) => !a.startsWith('--'));
358
+ const verb = pos[0] || 'check';
359
+ if (['help', '-h'].includes(verb) || args.includes('--help')) { for (const l of USAGE) say(l); return 0; }
360
+ const top = () => { const r = spawnSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }); return r.status === 0 && r.stdout.trim() ? r.stdout.trim() : cwd; };
361
+ root = path.resolve(cwd, root || (verb === 'check' && pos[1]) || top());
362
+ const out = (o, text) => { if (json) say(JSON.stringify(o)); else for (const l of [].concat(text)) say(l); };
363
+ if (verb === 'check') {
364
+ const f = read(root, { runtimeDir, ...(ownerDraft !== undefined ? { ownerDraft } : {}) });
365
+ const r = check(f);
366
+ const steps = r.passed ? [] : stepsOf(root);
367
+ const held = holds(r, steps);
368
+ out({ ok: true, ...r, holds: held }, [
369
+ `${TAG} ${f.name}: ${r.passed ? 'Setup passed' : `${r.met} of ${r.of} exit items met`}`,
370
+ ...r.items.map((i) => `${TAG} ${i.status === 'ok' ? '✓' : i.status === 'missing' ? '○' : '?'} ${i.label}: ${i.quote}`),
371
+ ...(r.next ? [`${TAG} ✦ ${r.next.text}${r.next.source ? ` (from ${r.next.source})` : ''}. Say yes and run: ${r.next.cli}`] : []),
372
+ ...(r.passed ? [] : [held ? `${TAG} Until then PMOS runs only Triage and the documents part of Discovery here.` : `${TAG} Work here is already past Discovery, so nothing waits on Setup.`]),
373
+ String(r.met),
374
+ ]);
375
+ return 0;
376
+ }
377
+ let res;
378
+ if (verb === 'agree') {
379
+ if (pos[1] !== 'goal') { say('usage: pmos setup agree goal'); return 2; }
380
+ res = agreeGoal(root, { now });
381
+ if (res.ok) out(res, `✓ goal agreed in ${res.file}: ${res.goal}. Undo: pmos setup undo`);
382
+ } else if (verb === 'owner') {
383
+ res = setOwner(root, pos.slice(1).join(' '), { now });
384
+ if (res.ok) out(res, `✓ owner is ${res.owner} (${res.file}). Undo: pmos setup undo`);
385
+ } else if (verb === 'undo') {
386
+ res = undo(root, { now });
387
+ if (res.ok) out(res, `✓ undone: the ${res.what === 'agree' ? 'agreed goal' : 'owner'} in ${res.file} is back as it was`);
388
+ } else { say(`unknown setup command "${verb}"`); for (const l of USAGE) say(l); return 2; }
389
+ if (!res.ok) { out(res, `✗ ${res.error}`); return 1; }
390
+ console.error(`${TAG} ${verb} ${path.basename(root)}: ${res.file}`);
391
+ return 0;
392
+ }
393
+
394
+ module.exports = {
395
+ NAME, KIND, LEDGER, DOC_WHATS, USAGE, COMMANDS,
396
+ read, check, holds, gate, stepsOf, agreeGoal, setOwner, undo, readLedger, cli,
397
+ kinds: [KIND], rowsFor, sig,
398
+ };
399
+
400
+ if (require.main === module) process.exitCode = cli(process.argv.slice(2));
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.754.0",
3
+ "version": "0.756.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.754.0",
9
+ "version": "0.756.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.754.0",
3
+ "version": "0.756.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",
@@ -21,6 +21,7 @@ import * as WS from './work-select.js'; // the bulk move with one Undo, shared
21
21
  import * as IF from './inline-fields.js'; // a task's sprint and priority, set in the row (initiative inline-sprint-priority)
22
22
  import * as LE from './live-edit.js'; // a task's status or days show at once in the list, before it is read again; a failed save is put back
23
23
  import { noteUse } from './use-log.js'; // the sprint draft's presses, counted on this computer only (sprint-draft-capacity)
24
+ import * as LV from './line-view.js'; // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
24
25
  import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
25
26
 
26
27
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
@@ -65,12 +66,15 @@ export function tabOf() {
65
66
  const q = new URLSearchParams(location.search).get('work');
66
67
  if (q === 'backlog') return 'bk';
67
68
  if (q === 'sprint') return 'sp';
69
+ if (q === 'line') return 'ln';
68
70
  if (q === 'initiatives') return 'ini';
69
71
  const v = (get(KEY, {}) || {})[scopeKey()];
70
- return v === 'bk' || v === 'sp' ? v : 'ini';
72
+ return v === 'bk' || v === 'sp' || v === 'ln' ? v : 'ini';
71
73
  }
72
74
  /** Is a task tab (Backlog or This sprint) the view now? */
73
- export const on = () => tabOf() !== 'ini';
75
+ export const on = () => tabOf() === 'bk' || tabOf() === 'sp';
76
+ /** Is the Line tab the view now? (quiet-rows slice B) */
77
+ export const lineOn = () => tabOf() === 'ln';
74
78
  function setOn(v) {
75
79
  v = v === true ? 'bk' : v === false ? 'ini' : v;
76
80
  const m = get(KEY, {}) || {}; m[scopeKey()] = v; put(KEY, m);
@@ -119,7 +123,8 @@ export async function load() {
119
123
  /* ── the switch in Work's header ──────────────────────────────────────────────────────────────────────────────── */
120
124
  /** Work's three tab names: a desk says "This sprint" and no count; a phone says "Backlog 14" and "Sprint" (PhoneWorkDS, job 1540).
121
125
  * Zero is silence: no count when the Backlog is empty or not read yet. */
122
- export const tabNames = (phone, n) => [['ini', 'Initiatives'], ['bk', 'Backlog' + (phone && n > 0 ? ` <span class="bk-swn">${Number(n)}</span>` : '')], ['sp', phone ? 'Sprint' : 'This sprint']];
126
+ // the Line (quiet-rows-line) is a five-column table for a desk; a phone keeps its three tabs (Today's dashed line is desk-only too)
127
+ export const tabNames = (phone, n) => [['ini', 'Initiatives'], ...(phone ? [] : [['ln', 'Line']]), ['bk', 'Backlog' + (phone && n > 0 ? ` <span class="bk-swn">${Number(n)}</span>` : '')], ['sp', phone ? 'Sprint' : 'This sprint']];
123
128
  const phoneNow = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
124
129
  function drawSwitch() {
125
130
  if (!sw) return;
@@ -130,16 +135,49 @@ function drawSwitch() {
130
135
  sw.innerHTML = tabNames(ph, ph && DATA ? backlogOf().length : 0).map(([k, n]) => tb(k, n)).join('');
131
136
  }
132
137
  function apply() {
133
- const bk = on();
138
+ const bk = on(), ln = lineOn();
134
139
  if (tabOf() === 'sp') CHIPS.add('sprint');
135
140
  document.body.classList.toggle('sp-on', tabOf() === 'sp');
136
- document.body.classList.toggle('bk-on', bk);
137
- if (host) host.hidden = !bk;
141
+ document.body.classList.toggle('bk-on', bk || ln);
142
+ if (host) host.hidden = !(bk || ln);
138
143
  drawSwitch();
144
+ if (ln) { closeAll(); drawLine(); return; }
139
145
  if (bk) { if (!DATA || scopeKey() !== lastScope) { lastScope = scopeKey(); host.innerHTML = '<p class="bk-wait">Reading the tasks…</p>'; load(); } else draw(); }
140
146
  else closeAll();
141
147
  }
142
148
 
149
+ /* ── the Line tab (quiet-rows slice B, board QuietLine) ── every live initiative of the pick by station, from GET /api/line ── */
150
+ const LN = { tab: '', got: null, key: '', used: false };
151
+ async function readLine() {
152
+ const ws = [...new Set(A.scope().map((s) => s.ws || ''))];
153
+ const got = await Promise.all(ws.map((w) => fetch('/api/line' + (w ? '?ws=' + encodeURIComponent(w) : ''), { credentials: 'same-origin' }).then((r) => r.json()).catch(() => null)));
154
+ return got.filter((r) => r && r.ok).map((r) => ({ ws: r.ws, rows: r.rows || [], you: r.you || [] }));
155
+ }
156
+ function drawLine() {
157
+ if (!host) return;
158
+ const k = scopeKey();
159
+ if (!LN.used) { LN.used = true; noteUse('qr-line'); console.info('[quiet-rows-line] line tab opened'); } // the health number: one open per page load
160
+ if (!LN.got || LN.key !== k) {
161
+ LN.key = k; host.innerHTML = '<p class="bk-wait">Reading the line…</p>';
162
+ readLine().then((g) => { LN.got = g; if (lineOn()) drawLine(); });
163
+ return;
164
+ }
165
+ const rows = LN.got.flatMap((L) => L.rows.map((r) => ({ ...r, ws: L.ws })));
166
+ const you = new Set(LN.got.flatMap((L) => L.you.map((id) => L.ws + '|' + id)));
167
+ const M = LV.lineModel(rows, { you, tab: LN.tab });
168
+ const one = A.scope().length === 1 ? A.scope()[0].name || '' : '';
169
+ host.innerHTML = LV.lineHtml(M, { name: one, say: LV.sayOf(M) });
170
+ }
171
+ /** A press in the Line tab: a tab, or a row's name (opens the initiative). true when it was one. */
172
+ function linePress(e) {
173
+ if (!lineOn()) return false;
174
+ const tb = e.target.closest('[data-line-tab]');
175
+ if (tb) { LN.tab = tb.dataset.lineTab; drawLine(); return true; }
176
+ const b = e.target.closest('[data-line-ini]');
177
+ if (b) { if (A && A.openIni) A.openIni(b.dataset.lineIni, b.dataset.lineWs || ''); return true; }
178
+ return false;
179
+ }
180
+
143
181
  /* ── the list ─────────────────────────────────────────────────────────────────────────────────────────────────── */
144
182
  const partB = () => true;
145
183
  function draw() {
@@ -746,7 +784,7 @@ export function sync(api) {
746
784
  sw.addEventListener('click', (e) => { const b = e.target.closest('[data-bksw]'); if (b) setOn(b.dataset.bksw); });
747
785
  host = document.createElement('div'); host.id = 'bkBody'; host.className = 'bk-host'; host.hidden = true;
748
786
  ib.insertAdjacentElement('afterend', host);
749
- host.addEventListener('click', (e) => { press(e); });
787
+ host.addEventListener('click', (e) => { if (linePress(e)) return; press(e); });
750
788
  host.addEventListener('change', (e) => { if (e.target.closest('[data-bkck]')) press(e); });
751
789
  host.addEventListener('keydown', (e) => { const c = e.target.closest('[data-bkcap]'); if (c && e.key === 'Enter') { e.preventDefault(); capture(c); } });
752
790
  dragWire();
@@ -40,6 +40,7 @@ export function mountToday(ctx) {
40
40
  draw();
41
41
  readReports();
42
42
  readQuestions();
43
+ readLine();
43
44
  }
44
45
  /* open-questions-today (A420, board QuestionsA): every product's register (GET /api/open-questions), one list for the Decide tab. A product
45
46
  * that does not answer is left out; nothing is guessed. Read-only: taking a default and putting it off a week are slice 2. */
@@ -55,6 +56,16 @@ export function mountToday(ctx) {
55
56
  X.questions = lines;
56
57
  draw();
57
58
  }
59
+ /* quiet-rows-line (board QuietLine): each product's line (GET /api/line), for the dashed line at the end of Your move. A product that does not
60
+ * answer is left out; with nothing on the line there is no dashed line (zero is silence). */
61
+ async function readLine() {
62
+ const P = ((ctx.S.M && ctx.S.M.products) || []).filter((p) => p && p.model);
63
+ const W = [...new Set((P.length ? P.map((p) => p.ws || ctx.boardWs() || '') : [ctx.boardWs() || '']))];
64
+ const got = await Promise.all(W.map((ws) => ctx.pmGet('/api/line' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
65
+ const lines = got.filter((r) => r && r.ok && Array.isArray(r.rows)).map((r) => ({ ws: r.ws || '', rows: r.rows, you: r.you || [] }));
66
+ if (JSON.stringify(lines) === JSON.stringify(X.lines || [])) return;
67
+ X.lines = lines; draw();
68
+ }
58
69
  // the reports that go out today, at their time (GET /api/events-place; 202 while a Board is read: ask again in a moment, three times)
59
70
  async function readReports(n = 0) {
60
71
  const r = await ctx.pmGet('/api/events-place').catch(() => null);
@@ -129,7 +140,7 @@ export function mountToday(ctx) {
129
140
  return;
130
141
  }
131
142
  el.classList.remove('tdp');
132
- const html = TP.pageHtml(L, A, { draft, overview: O, job: X.job, open: X.open || !!X.job, ymOpen: X.ymOpen, handled: X.job && X.job !== 'Reply' ? [] : handled(), hopen: X.hopen, sopen: [...X.sopen], filed: filedLine() });
143
+ const html = TP.pageHtml(L, A, { draft, overview: O, job: X.job, open: X.open || !!X.job, ymOpen: X.ymOpen, handled: X.job && X.job !== 'Reply' ? [] : handled(), hopen: X.hopen, sopen: [...X.sopen], filed: filedLine(), lines: X.lines || null });
133
144
  if (html === X.html && el.firstChild) return;
134
145
  X.html = html;
135
146
  const st = el.parentNode ? el.parentNode.scrollTop : 0;
@@ -398,6 +409,7 @@ export function mountToday(ctx) {
398
409
  wireSwipe(el, { on: phone, act: (row, way) => { const act = row.dataset[way === 'right' ? 'swRight' : 'swLeft']; if (act) run(act, row.dataset.key || '', { dataset: {}, disabled: false, isConnected: false }); } });
399
410
  }
400
411
  async function run(act, key, b) {
412
+ if (act === 'line') { console.info('[quiet-rows-line] dashed line opened'); return; } // the link opens Work › Line, which counts the open (qr-line)
401
413
  if (act === 'cal') { ctx.openCalendar(); return; }
402
414
  // the phone (Ph2_today): Record on the next event starts its recording; with no event, a recording of its own (PMOS names it after)
403
415
  if (act === 'rec' || act === 'rec-ev') {
@@ -58,6 +58,7 @@ button.td-t:focus-visible, .td-ln:focus-visible, .td-evl:focus-visible { outline
58
58
  .ym-n { flex: none; min-width: var(--space-16); text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
59
59
  .td-li .ym-why { display: flex; align-items: center; gap: var(--space-4); }
60
60
  .ym-why .pm-star { flex: none; color: var(--blue); }
61
+ .ym-line { display: block; border: 1px dashed var(--muted); text-decoration: none; color: var(--muted); } /* quiet-rows slice B: the rest of the line, one dashed line */
61
62
 
62
63
  /* the agenda: each event at its time, the now line where it falls */
63
64
  .td-evl { font-size: var(--fs-meta); color: var(--blue); }
@@ -16,6 +16,7 @@
16
16
  * a Summary block for the meeting PMOS recorded and filed, with one Suggestion (keep it filed, or take it out).
17
17
  * Every icon-only button has an aria-label. The UI says PMOS. Text from records goes through esc(). */
18
18
 
19
+ import { dashModel as lineDash, dashHtml as lineDashHtml } from './line-view.js'; // quiet-rows-line: Your move ends with the line's dashed line
19
20
  import { groupsHtml as questionGroups, phoneGroupsHtml as phoneQuestionGroups } from './open-questions-view.js'; // open-questions-today (A420)
20
21
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
21
22
  const svg = (d, w = 15, sw = 1.9) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
@@ -138,7 +139,7 @@ export function moveRowHtml(r, n, o = {}) {
138
139
  /** "4 more, in the same order · the next one: <title>, <age>". */
139
140
  const nextWord = (r) => r.title + (ageOf(r) ? ', ' + plural(ageOf(r), 'day', 'days') : '');
140
141
  /** The Your move group: the heading, five rows, the fold line (open: the rest, in the same order). '' when nothing waits (zero is
141
- * silence). rows: the ranked rows (logModel().move, filtered by the tab). o: { ymOpen, sopen } */
142
+ * silence). rows: the ranked rows (logModel().move, filtered by the tab). o: { ymOpen, sopen, lines } */
142
143
  export function moveHtml(rows, o = {}) {
143
144
  if (!rows || !rows.length) return '';
144
145
  const so = new Set(o.sopen || []), shown = rows.slice(0, YM_SHOW), rest = rows.slice(YM_SHOW);
@@ -150,6 +151,8 @@ export function moveHtml(rows, o = {}) {
150
151
  if (rest.length && o.ymOpen) h += rest.map((r, i) => moveRowHtml(r, YM_SHOW + i + 1, { sopen: so.has(r.key) })).join('');
151
152
  h += '</div>';
152
153
  if (rest.length) h += `<button type="button" class="td-fold pm-fold ym-fold" data-td="ym-fold" aria-expanded="${!!o.ymOpen}">${esc(rest.length + ' more, in the same order')} <span class="td-n">${esc('· the next one: ' + nextWord(rest[0]))}</span>${ic(I.more, 14)}</button>`;
154
+ // quiet-rows-line (board QuietLine): the last line, dashed: what moves in the line by itself, which opens Work › Line. o.lines: GET /api/line
155
+ h += lineDashHtml(lineDash(o.lines));
153
156
  return h;
154
157
  }
155
158
  /** The jobs the log's Tabs filter by, in order. */
@@ -172,7 +175,7 @@ export function logHtml(L, o = {}) {
172
175
  const one = (r, lit) => (r.members ? rowHtml(r, { sopen: so.has(r.key), lit }) + (so.has(r.key) ? r.members.map((m) => rowHtml(m)).join('') : '') : rowHtml(r, { lit }));
173
176
  const today = pick(L.todayRows), wait = pick(L.wait);
174
177
  let body = job === 'Decide' ? questionGroups(L.questions) : '';
175
- body += moveHtml(pick(L.move || L.first), o);
178
+ body += moveHtml(pick(L.move || L.first), job ? { ...o, lines: null } : o);
176
179
  if (today.length) body += `<div class="td-gr pm-group">Today</div><div class="rows">${today.map((r) => one(r)).join('')}</div>`;
177
180
  if (wait.length) {
178
181
  const oldest = Math.max(0, ...wait.map((r) => r.carried || 0));
@@ -0,0 +1,85 @@
1
+ /* pm/line-view.js — the Line tab on Work and Today's dashed line (initiative quiet-rows-line, quiet rows slice B; board QuietLine on the
2
+ * main canvas, In development). Pure: Node imports it (quiet-rows-line.test.js).
3
+ *
4
+ * lineModel(rows, { you, tab }) → { groups: [{ key, name, n, rows }], counts: { all, stuck, cant, you }, tab, live }
5
+ * lineHtml(M, o) → the Line block: Tabs (All, Stuck, Can't tell, Your move) and one table grouped by station
6
+ * dashModel(lines) → { n, stuck, text } | null Today's dashed line under Your move ("9 more move in the line by themselves · 1 stuck")
7
+ * dashHtml(D) → the dashed line, a link to /premium-board.html?work=line
8
+ *
9
+ * rows: lib/line.js lineOf rows (GET /api/line), each with its product (ws). you: Set of '<ws>|<initiative>' that have a Your move row (a question
10
+ * to the PM, a check due). A row in Your move is marked "your move" here and not repeated on Today. Waiting for capacity is never stuck: it
11
+ * reads moving. "Can't tell" never moves an item and never raises a row. The UI says PMOS. Text from records goes through esc(). */
12
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
13
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
14
+ const cap1 = (s) => String(s || '').replace(/^[a-z]/, (c) => c.toUpperCase());
15
+
16
+ export const TABS = [['', 'All', 'all'], ['stuck', 'Stuck', 'stuck'], ['cant', 'Can’t tell', 'cant'], ['you', 'Your move', 'you']];
17
+ const STATE_WORD = { you: 'your move', stuck: 'stuck', cant: 'can’t tell', moving: 'moving' };
18
+
19
+ /** One row's state: your move first, then the line's flag. */
20
+ export function stateOf(r, you) {
21
+ if (you && you.has((r.ws || '') + '|' + r.id)) return 'you';
22
+ if (r.flag === 'stuck') return 'stuck';
23
+ if (r.flag === 'cant-tell') return 'cant';
24
+ return 'moving';
25
+ }
26
+ /** Days here: "day 6" with no number limit, "4 of 15" against one; '' when no record says. */
27
+ export function daysWord(r) {
28
+ if (r.daysThere == null) return r.quietDays != null ? 'quiet ' + plural(r.quietDays, 'day', 'days') : '';
29
+ return typeof r.limit === 'number' && r.limit > 0 ? r.daysThere + ' of ' + r.limit : 'day ' + r.daysThere;
30
+ }
31
+ export function lineModel(rows, o = {}) {
32
+ const you = o.you instanceof Set ? o.you : new Set(o.you || []);
33
+ const live = (rows || []).filter((r) => r && r.id && r.live);
34
+ const all = live.map((r) => ({ ...r, state: stateOf(r, you) }));
35
+ const counts = { all: all.length, stuck: all.filter((r) => r.state === 'stuck').length, cant: all.filter((r) => r.state === 'cant').length, you: all.filter((r) => r.state === 'you').length };
36
+ const tab = TABS.some(([k]) => k === o.tab) && (o.tab === '' || counts[o.tab]) ? o.tab : '';
37
+ const shown = tab ? all.filter((r) => r.state === tab) : all;
38
+ const by = new Map();
39
+ for (const r of shown) {
40
+ const st = r.station || { key: '', name: 'No station', n: 999 };
41
+ const k = (st.n == null ? 999 : st.n) + '|' + String(st.name || '').toLowerCase();
42
+ if (!by.has(k)) by.set(k, { key: k, name: st.name || 'No station', n: st.n == null ? 999 : st.n, rows: [] });
43
+ by.get(k).rows.push(r);
44
+ }
45
+ const groups = [...by.values()].sort((a, b) => a.n - b.n || a.name.localeCompare(b.name));
46
+ for (const g of groups) g.rows.sort((a, b) => String(a.title).localeCompare(String(b.title)));
47
+ return { groups, counts, tab, live: all.length };
48
+ }
49
+ /** The Line block. M: lineModel(). o: { name: the product's name, say: a line above the table (Where it stands) } */
50
+ export function lineHtml(M, o = {}) {
51
+ if (!M || !M.live) return `<section class="pm-block ln" aria-label="The line"><p class="pm-meta">No initiative is on a workflow yet, so the line is empty.</p></section>`;
52
+ const tabs = TABS.filter(([k, , c]) => k === '' || M.counts[c]).map(([k, n, c]) => `<button type="button" class="pm-tab${M.tab === k ? ' on' : ''}" role="tab" aria-selected="${M.tab === k}" data-line-tab="${k}">${esc(n)} <span class="pm-meta">${M.counts[c]}</span></button>`).join('');
53
+ const head = `<div class="ln-row ln-head" role="row"><span role="columnheader">Initiative</span><span role="columnheader">Days here</span><span role="columnheader">Still missing to finish</span><span role="columnheader">Next move</span><span role="columnheader">State</span></div>`;
54
+ const body = M.groups.map((g) => `<div class="ln-row pm-group" role="row"><span role="cell">${esc(g.name)} <span class="pm-meta">${g.rows.length}</span></span></div>`
55
+ + g.rows.map((r) => `<div class="ln-row pm-li ln-${r.state}" role="row"><span role="cell"><button type="button" class="t" data-line-ini="${esc(r.id)}" data-line-ws="${esc(r.ws || '')}">${esc(r.title || r.id)}</button></span>`
56
+ + `<span role="cell" class="pm-meta">${esc(daysWord(r))}</span><span role="cell">${esc((r.missing || []).join('; '))}</span><span role="cell">${esc(cap1(r.next || ''))}</span>`
57
+ + `<span role="cell"><span class="pm-badge${r.state === 'stuck' ? ' alert' : ''}" title="${esc(r.why || '')}">${esc(STATE_WORD[r.state])}</span></span></div>`).join('')).join('');
58
+ return `<section class="pm-block list ln" aria-label="The line">${o.say ? `<p class="ln-say">${esc(o.say)}</p>` : ''}<div class="pm-tabs" role="tablist" aria-label="Show">${tabs}</div>`
59
+ + `<div class="ln-t" role="table" aria-label="${esc((o.name ? o.name + ': ' : '') + 'initiatives by station')}">${head}${body}</div></section>`;
60
+ }
61
+ /** Where it stands, one sentence over the table. */
62
+ export function sayOf(M) {
63
+ if (!M || !M.live) return '';
64
+ const moving = M.live - M.counts.you - M.counts.stuck - M.counts.cant;
65
+ return [plural(M.live, 'initiative', 'initiatives') + ' on the line.', moving ? moving + (moving === 1 ? ' moves by itself.' : ' move by themselves.') : '',
66
+ M.counts.you ? M.counts.you + ' wait' + (M.counts.you === 1 ? 's' : '') + ' on you, already in Your move.' : '',
67
+ M.counts.stuck ? M.counts.stuck + ' stuck.' : '', M.counts.cant ? M.counts.cant + ' can’t be placed, so PMOS leaves ' + (M.counts.cant === 1 ? 'it' : 'them') + ' alone.' : ''].filter(Boolean).join(' ');
68
+ }
69
+ /** Today's dashed line. lines: [{ ws, rows, you: [initiative id] }]. null when nothing is on the line (zero is silence). */
70
+ export function dashModel(lines) {
71
+ let n = 0, stuck = 0, live = 0;
72
+ for (const L of lines || []) {
73
+ const you = new Set((L.you || []).map(String));
74
+ for (const r of L.rows || []) {
75
+ if (!r || !r.live) continue;
76
+ live++;
77
+ if (you.has(String(r.id))) continue;
78
+ n++; if (r.flag === 'stuck') stuck++;
79
+ }
80
+ }
81
+ if (!live) return null;
82
+ return { n, stuck, text: n + ' more move in the line by themselves · ' + (stuck ? stuck + ' stuck' : 'none stuck') };
83
+ }
84
+ export const LINE_HREF = '/premium-board.html?work=line';
85
+ export const dashHtml = (D) => (D ? `<a class="td-fold pm-fold ym-line" href="${LINE_HREF}" data-td="line">${esc(D.text)}</a>` : '');
@@ -1563,6 +1563,8 @@ const bkApi = () => ({
1563
1563
  scope: () => (M.board.all ? (M.board.products || []).map((p) => ({ ws: p.ws, board: p.id || '', name: p.name })) : [{ ws: M.board.ws || '', board: M.board.id || '', name: M.board.product || M.board.name || '' }]),
1564
1564
  // CLASSIC (lib/classic-board.js) is the test seam of the four Board views: Work and its Backlog switch are not there
1565
1565
  post: pmPost, say, reload: () => load(), readonly: !!window.PMOS_READONLY || CLASSIC,
1566
+ // the Line tab (quiet-rows slice B): a row opens its initiative, as a row of Initiatives does
1567
+ openIni: (id, ws) => { const r = (M.rows || []).find((x) => x.id === id && x.track && (!ws || (x.ws || M.board.ws) === ws)); if (r) openIni(r); else say('Open ' + id + ' from Initiatives.'); },
1566
1568
  // the sprint band (pm/bd-sprint.js): Read Jira again is the Board's own; "Make a home" opens New initiative with the theme's name
1567
1569
  readJira: () => refreshJira(null),
1568
1570
  newInitiative: async (name, from) => {
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Work's Line tab and Today's dashed line (initiative quiet-rows-line, done test L1-L6). Pure; no browser, no server.",
3
+ "modules": [
4
+ "quiet-rows-line.test.js"
5
+ ],
6
+ "seconds": {
7
+ "quiet-rows-line.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "setup-station: a new product passes a Setup station (tracker read, agreed goal, owner) before PMOS plans its work; the Driver gate, the Today row and pmos setup (lib/setup-station.js, lib/setup-cli.js). Temp product folders only.",
3
+ "modules": [
4
+ "setup-station.test.js"
5
+ ],
6
+ "seconds": {
7
+ "setup-station.test.js": 2
8
+ }
9
+ }