create-pmos 0.751.0 → 0.753.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.
Files changed (36) hide show
  1. package/package.json +45 -77
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/changelog.json +44 -0
  8. package/workspace/guide/cli.md +28 -1
  9. package/workspace/guide/home.md +3 -1
  10. package/workspace/guide/settings-and-switches.md +2 -2
  11. package/workspace/lib/autonomy.js +2 -1
  12. package/workspace/lib/driver-decide.js +8 -0
  13. package/workspace/lib/driver-needs.js +3 -20
  14. package/workspace/lib/driver-run.js +16 -1
  15. package/workspace/lib/driver.js +23 -11
  16. package/workspace/lib/line-cli.js +99 -0
  17. package/workspace/lib/line.js +231 -0
  18. package/workspace/lib/never-wait.js +144 -0
  19. package/workspace/lib/pmos-verbs.js +4 -1
  20. package/workspace/lib/program-cli.js +165 -10
  21. package/workspace/lib/program-line.js +380 -0
  22. package/workspace/lib/routes-today-log.js +6 -3
  23. package/workspace/lib/today-log.js +21 -3
  24. package/workspace/package-lock.json +2 -2
  25. package/workspace/package.json +1 -1
  26. package/workspace/public/pm/cozy-today-app.js +17 -2
  27. package/workspace/public/pm/cozy-today-model.js +21 -3
  28. package/workspace/public/pm/cozy-today-view.js +4 -2
  29. package/workspace/public/pm/quiet-batch.js +111 -0
  30. package/workspace/public/pm/quiet-rows.js +130 -0
  31. package/workspace/public/pm/wf-page.css +2 -0
  32. package/workspace/public/pm/wf-page.js +38 -8
  33. package/workspace/test-lists/line.json +9 -0
  34. package/workspace/test-lists/never-wait-on-drafts.json +9 -0
  35. package/workspace/test-lists/program-line.json +9 -0
  36. package/workspace/test-lists/quiet-rows.json +9 -0
@@ -0,0 +1,231 @@
1
+ 'use strict';
2
+ /* line.js — where each initiative of a product stands on its own workflow, and what moves it next (product line plan, slice 2;
3
+ * initiative pmos-line). Read-only: it never seeds a To finish task, moves an initiative or sends anything.
4
+ *
5
+ * place(input, now?) PURE → one initiative's place on the line:
6
+ * { id, title, workflow, station: { key, name, n, of } | null, live, ended, daysThere, since, quietDays, clock,
7
+ * missing: [text], next, flag: 'stuck' | 'moving' | 'waiting' | 'cant-tell', why, limit }
8
+ * input = { row, the Board's row (lib/routes-boards.js boardRow): wf, wfStage, wfStages, wfMap, oneStage, ended, end
9
+ * tasks: [{ state, from? }], the initiative's tasks (lib/stage-read.js tasksOf)
10
+ * moves: [{ at, to, via }], the Board moves and workflow switches of it (scripts/boards.js fold), oldest first
11
+ * jira: { fetchedAt, epics: [key], tickets: [{ key, category, updated? }] } | null
12
+ * activity: [ISO time] } dated lines that name it: ledger lines, ticket changes, its record's commits
13
+ * lineOf(root, { only?, now? }) → { ok, product, rows: [place answer], live, placed, ended } | { ok: false, error }
14
+ * summary(line) → { live, placed, percent }
15
+ *
16
+ * THE STATION IS THE INITIATIVE'S OWN WORKFLOW STAGE (D99), the one the Board and `pmos workflow of` show. Its exit items are the stage's
17
+ * To finish lines; a line is missing until its task is Done or Won't do. A stage with no To finish list has one exit item, its output;
18
+ * a stage whose output is Jira work lists its open tickets.
19
+ *
20
+ * RULE 1 OF THE PLAN: "can't tell" beats a guess. A station set by a Jira read older than STALE_DAYS, or an initiative with no dated
21
+ * record at all, is can't tell: never stuck. Waiting for capacity is never stuck either. Stuck limits are defaults (LIMITS), by the
22
+ * stage's key or name, else its category; a product's own limits are a later slice. */
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+ const { execFileSync } = require('child_process');
26
+
27
+ const DAY = 86400000;
28
+ const STALE_DAYS = 7;
29
+ const TICKET_QUIET_WORKDAYS = 3;
30
+ // Days a station may hold an initiative with no activity. 'tickets' = quiet Jira tickets decide; null = never stuck (waiting); 0 = closed.
31
+ const LIMITS = {
32
+ triage: 3, initiate: 3, 'done test': 3, discover: 15, discovery: 15, plan: 5, prioritize: null, prioritise: null,
33
+ build: 'tickets', implementation: 'tickets', execute: 'tickets', pulls: 'tickets', 'pull requests': 'tickets', ci: 'tickets', merge: 'tickets',
34
+ deliver: 3, release: 3, monitor: 14, evaluate: 7, evaluation: 7, close: 7, closed: 0,
35
+ };
36
+ const CAT_LIMIT = { todo: 3, doing: 15, done: 7 };
37
+ const DONE_STATES = new Set(['done', "won't do", 'wont do', 'archived']);
38
+ const CAPACITY = /\b(prioriti[sz]\w*|capacity|slot)\b/i;
39
+ const CLOSED_NAME = /^(closed|complete[d]?)$/i;
40
+
41
+ const lc = (s) => String(s || '').trim().toLowerCase();
42
+ const ms = (t) => { const v = Date.parse(t || ''); return Number.isFinite(v) ? v : null; };
43
+ const days = (from, to) => Math.max(0, Math.floor((to - from) / DAY));
44
+ function workdays(from, to) {
45
+ let n = 0;
46
+ for (let t = from + DAY; t <= to; t += DAY) { const d = new Date(t).getUTCDay(); if (d !== 0 && d !== 6) n++; }
47
+ return n;
48
+ }
49
+ function limitOf(st) {
50
+ if (!st) return 15;
51
+ for (const k of [lc(st.key), lc(st.name)]) if (Object.prototype.hasOwnProperty.call(LIMITS, k)) return LIMITS[k];
52
+ return CAT_LIMIT[st.cat] != null ? CAT_LIMIT[st.cat] : 15;
53
+ }
54
+
55
+ /** The exit items still missing on the current stage. → [text] */
56
+ function missingOf(st, row, tasks, jira) {
57
+ const finish = Array.isArray(st.finish) ? st.finish.filter((f) => typeof f === 'string' && f.trim()) : [];
58
+ if (finish.length) {
59
+ const map = row.wfMap || {};
60
+ const mine = (k) => k === st.key || map[k] === st.key;
61
+ return finish.filter((f) => !(tasks || []).some((t) => t && t.from && mine(t.from.stage) && t.from.finish === f && DONE_STATES.has(lc(t.state))));
62
+ }
63
+ const out = st.output || {};
64
+ if (out.kind === 'jira' && jira && Array.isArray(jira.tickets) && jira.tickets.length) {
65
+ const epics = new Set((jira.epics || []).map((k) => String(k).toUpperCase()));
66
+ const tk = jira.tickets.filter((t) => !epics.has(String(t.key).toUpperCase()));
67
+ const open = tk.filter((t) => t.category !== 'done');
68
+ if (!open.length) return [];
69
+ return [`${open.length} of ${tk.length} tickets open (${open.slice(0, 5).map((t) => t.key).join(', ')}${open.length > 5 ? ', …' : ''})`];
70
+ }
71
+ return [out.name ? String(out.name).trim() : `what finishes ${st.name}`];
72
+ }
73
+
74
+ function place(input, now = Date.now()) {
75
+ const { row, tasks = [], moves = [], jira = null, activity = [] } = input || {};
76
+ const one = row.oneStage || {};
77
+ const base = { id: row.id, title: row.title || row.id, workflow: row.wf ? row.wf.name : null };
78
+ const endWord = row.ended ? (row.ended.as === 'wontdo' ? "Won't do" : 'Archived') : row.archived ? 'Archived'
79
+ : one.stage === 'shipped' ? 'Shipped' : one.stage === 'cancelled' ? 'Cancelled' : null;
80
+ const st0 = row.wfStage || null;
81
+ const st = st0 ? { ...((row.wfStages || []).find((s) => s.key === st0.key) || {}), ...st0 } : null;
82
+ const station = st ? { key: st.key, name: st.name, n: st.n, of: st.of } : null;
83
+ if (endWord || (st && CLOSED_NAME.test(String(st.name || '')))) {
84
+ return { ...base, station, live: false, ended: endWord || st.name, daysThere: null, since: null, quietDays: null, clock: null, missing: [], next: null, flag: null, why: 'ended', limit: null };
85
+ }
86
+ if (!st) return { ...base, station: null, live: true, ended: null, daysThere: null, since: null, quietDays: null, clock: null, missing: [], next: null, flag: 'cant-tell', why: 'no workflow stage', limit: null };
87
+
88
+ // the clock: what put it on this station, else the last dated activity
89
+ const here = (to) => { const t = lc(to); return t === lc(st.key) || t === lc(st.name); };
90
+ const lastMove = [...moves].reverse().find((m) => m && here(m.to) && ms(m.at));
91
+ let since = null, setBy = null;
92
+ if (one.setBy === 'pm' && ms(one.readAt) && one.stage !== 'on-hold') { since = ms(one.readAt); setBy = one.source || 'your word'; }
93
+ if (lastMove && (!since || ms(lastMove.at) > since)) { since = ms(lastMove.at); setBy = lastMove.via === 'move' ? 'a Board move' : 'a workflow change'; }
94
+ const acts = activity.map(ms).filter((x) => x != null && x <= now + DAY);
95
+ const tickets = jira && Array.isArray(jira.tickets) ? jira.tickets : [];
96
+ for (const t of tickets) { const u = ms(t.updated); if (u != null) acts.push(u); }
97
+ const last = acts.length ? Math.max(...acts) : null;
98
+ const daysThere = since != null ? days(since, now) : null;
99
+ const quietDays = last != null ? days(last, now) : null;
100
+ const clock = daysThere != null ? daysThere : quietDays;
101
+
102
+ const missing = missingOf(st, row, tasks, jira);
103
+ const stages = row.wfStages || [];
104
+ const idx = stages.findIndex((s) => s.key === st.key);
105
+ const nextStage = stages.slice(idx + 1).find((s) => s.status !== 'skipped');
106
+ const limit = limitOf(st);
107
+ const capacityOnly = limit === null || (missing.length > 0 && missing.every((m) => CAPACITY.test(m)));
108
+ let next;
109
+ if (one.stage === 'on-hold') next = 'resume when the PM takes it off hold';
110
+ else if (capacityOnly && missing.length) next = `wait for a capacity slot: ${missing[0]}`;
111
+ else if (missing.length) next = `finish: ${missing[0]}`;
112
+ else next = nextStage ? `move to ${nextStage.name}` : 'close it';
113
+
114
+ const out = { ...base, station, live: true, ended: null, daysThere, since: since != null ? new Date(since).toISOString() : null, setBy,
115
+ quietDays, clock, missing, next, limit: limit === 'tickets' ? `${TICKET_QUIET_WORKDAYS} working days with no ticket change` : limit };
116
+ const flag = (f, why) => ({ ...out, flag: f, why });
117
+
118
+ if (one.stage === 'on-hold') return flag('waiting', 'on hold: the clock is stopped');
119
+ if (capacityOnly) return flag('waiting', 'waiting for capacity is never stuck');
120
+ if (one.setBy === 'jira' && jira && ms(jira.fetchedAt) != null && days(ms(jira.fetchedAt), now) > STALE_DAYS)
121
+ return flag('cant-tell', `the Jira read is ${days(ms(jira.fetchedAt), now)} days old`);
122
+ if (limit === 'tickets' && tickets.length) {
123
+ const epics = new Set((jira.epics || []).map((k) => String(k).toUpperCase()));
124
+ const open = tickets.filter((t) => !epics.has(String(t.key).toUpperCase()) && t.category !== 'done');
125
+ const upd = tickets.map((t) => ms(t.updated)).filter((x) => x != null);
126
+ const end = ms(row.end);
127
+ if (open.length && end != null && end + DAY < now) return flag('stuck', `the planned end ${row.end} passed with ${open.length} tickets open`);
128
+ if (upd.length) {
129
+ const q = workdays(Math.max(...upd), now);
130
+ if (open.length && q > TICKET_QUIET_WORKDAYS) return flag('stuck', `no ticket changed in ${q} working days`);
131
+ return flag('moving', open.length ? `a ticket changed ${q} working days ago` : 'every ticket is done');
132
+ }
133
+ }
134
+ const lim = limit === 'tickets' ? 15 : limit;
135
+ if (clock == null) return flag('cant-tell', 'no dated record says when it got here or last moved');
136
+ if (clock <= lim) return flag('moving', daysThere != null ? `${daysThere} of ${lim} days on this station` : `last activity ${quietDays} days ago`);
137
+ if (quietDays != null && quietDays <= lim) return flag('moving', `${daysThere} days here, but activity ${quietDays} days ago`);
138
+ return flag('stuck', daysThere != null ? `${daysThere} days on this station, past ${lim}, with no activity since` : `quiet ${quietDays} days, past ${lim}`);
139
+ }
140
+
141
+ /* ── reading a repository ─────────────────────────────────────────────────────────────────────────────────────────────── */
142
+ const ID_FIELDS = ['initiative', 'initiative_id', 'init', 'ini', 'id'];
143
+ // Ledgers whose lines are not progress on the work: PMOS's own proposals wait for the PM (a draft nobody kept moves nothing), the
144
+ // Driver's run log and the folder scan record that a run looked. A task, a Board move, a plan item, a run or a ticket change counts.
145
+ const NOT_PROGRESS = new Set(['proposals.jsonl', 'driver.jsonl', 'scan.jsonl', 'claims.jsonl', 'use-log.jsonl', 'initiative-layout.jsonl', 'forecast.jsonl']);
146
+ // lines that only record a read or a view are not activity on the work
147
+ const READ_KINDS = /(^|[-_])(read|reads|seen|view|views|snapshot|scan|lead|digest|open|opened|stage-judge)($|[-_])/i;
148
+ /** id → [ISO time]: every dated ledger line that names an initiative, in the state folder and planning/runs. */
149
+ function activityIndex(dirs, ids) {
150
+ const out = new Map([...ids].map((id) => [id, []]));
151
+ for (const dir of dirs) {
152
+ let files = [];
153
+ try { files = fs.readdirSync(dir).filter((f) => f.endsWith('.jsonl') && !NOT_PROGRESS.has(f)); } catch { continue; }
154
+ for (const f of files) {
155
+ let txt = '';
156
+ try { txt = fs.readFileSync(path.join(dir, f), 'utf8'); } catch { continue; }
157
+ for (const line of txt.split('\n')) {
158
+ if (!line || line[0] !== '{') continue;
159
+ let e; try { e = JSON.parse(line); } catch { continue; }
160
+ const at = e.at || e.ts || e.time || e.created_at;
161
+ if (typeof at !== 'string' || READ_KINDS.test(String(e.kind || e.type || ''))) continue;
162
+ for (const k of ID_FIELDS) { const v = e[k]; if (typeof v === 'string' && out.has(v)) { out.get(v).push(at); break; } }
163
+ }
164
+ }
165
+ }
166
+ return out;
167
+ }
168
+ /** The commit times of a file, or [] when the repository has no real history (one import commit is not history). */
169
+ function gitTimes(root, rel, real) {
170
+ if (!real || !rel) return [];
171
+ try { return execFileSync('git', ['log', '--format=%cI', '-n', '20', '--', rel], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).split('\n').filter(Boolean); }
172
+ catch { return []; }
173
+ }
174
+ function realHistory(root) {
175
+ try { return Number(execFileSync('git', ['rev-list', '--count', 'HEAD'], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()) > 1; }
176
+ catch { return false; }
177
+ }
178
+
179
+ function lineOf(root, { only = null, now = Date.now() } = {}) {
180
+ const SR = require('./stage-read.js');
181
+ const boards = require('./routes-boards.js');
182
+ const rowsLib = require('./initiative-rows.js');
183
+ const { w, ctx } = SR.cliCtx(root);
184
+ const stateDir = ctx.stateDirFor();
185
+ if (!stateDir) return { ok: false, error: 'this repository has no PMOS state folder (pmos/state, state or .pmos)' };
186
+ const was = rowsLib.setBackground(false);
187
+ try {
188
+ try { rowsLib.deriveNow(root); } catch { /* baseRows says what could not be read */ }
189
+ const pass = { ...ctx, boardsPass: new Map() };
190
+ const base = boards.baseRows(w, pass);
191
+ if (!base.ok) return { ok: false, error: base.error || 'the initiative records could not be read' };
192
+ let ids = base.rows.map((r) => r.id);
193
+ if (only) { if (!ids.includes(only)) return { ok: false, error: `no initiative ${only} on a board of this workspace` }; ids = [only]; }
194
+ const folded = boards.foldOf(pass, w);
195
+ const acts = activityIndex([stateDir, path.join(root, 'planning', 'runs')], new Set(ids));
196
+ const real = realHistory(root);
197
+ let JS = null; try { JS = require('./jira-status.js'); } catch { JS = null; }
198
+ let JT = null; try { JT = require('./jira-tickets.js'); } catch { JT = null; }
199
+ const rows = [];
200
+ for (const id of ids) {
201
+ const r = boards.initiativeWorkflow(pass, w, id);
202
+ if (!r.ok) continue;
203
+ const b0 = base.rows.find((x) => x.id === id) || {};
204
+ let tasks = []; try { tasks = SR.tasksOf(pass, w, id); } catch { tasks = []; }
205
+ const moves = (folded.moves || []).filter((m) => m.id === id && m.board === r.board.id)
206
+ .map((m) => ({ ...m, at: require('./status-when.js').realAt(m) }));
207
+ let jira = null;
208
+ if (JS) {
209
+ try {
210
+ const snap = JS.readSnapshot(root, id);
211
+ if (snap && snap.tickets && snap.tickets.size) {
212
+ jira = { fetchedAt: snap.fetchedAt || null, epics: JT ? JT.epicKeysOf(root, id) : (r.row.epics || []),
213
+ tickets: [...snap.tickets.values()].map((t) => ({ key: t.key, category: t.category || 'todo', updated: t.updated || null })) };
214
+ }
215
+ } catch { jira = null; }
216
+ }
217
+ const recRel = typeof b0.record === 'string' ? path.relative(root, path.resolve(root, b0.record)) : null;
218
+ const activity = (acts.get(id) || []).concat(gitTimes(root, recRel, real));
219
+ rows.push(place({ row: r.row, tasks, moves, jira, activity }, now));
220
+ }
221
+ const live = rows.filter((x) => x.live);
222
+ return { ok: true, product: path.basename(root), rows, live: live.length, placed: live.filter((x) => x.station && x.next).length, ended: rows.length - live.length };
223
+ } finally { rowsLib.setBackground(was); }
224
+ }
225
+
226
+ function summary(line) {
227
+ const live = line.live || 0, placed = line.placed || 0;
228
+ return { live, placed, percent: live ? Math.round((placed / live) * 1000) / 10 : 0 };
229
+ }
230
+
231
+ module.exports = { place, lineOf, summary, missingOf, limitOf, activityIndex, LIMITS, STALE_DAYS };
@@ -0,0 +1,144 @@
1
+ 'use strict';
2
+ /* never-wait.js — PMOS never waits on its own drafts (initiative never-wait-on-drafts; rule 3 of the product line plan, slice 1).
3
+ *
4
+ * An open Driver draft (lib/driver.js proposal) used to hold its target: the sweep started no new run on it until the PM decided, and the
5
+ * D106 auto apply ran only once, when the draft was filed. Now every open draft goes one of four ways, each with Undo:
6
+ *
7
+ * apply class A or B (lib/autonomy.js DRIVER_CLASS), cites a source, has an Undo writer (lib/driver-decide.js UNDOABLE): applied by
8
+ * itself through lib/driver-decide.js autoApply, also when it was filed earlier. The kill switch, the mode, a demotion, "Ask
9
+ * first" and no-source-no-auto still hold there; a draft they hold is a question (below).
10
+ * default a question: a draft PMOS may not apply by itself and that only changes PMOS's own records (no source, no Undo writer, or held
11
+ * by a rule above). After DEFAULT_DAYS PMOS takes the safe answer, "leave the record as it is": one `default` line closes the
12
+ * draft, nothing is written, and one `applied` line for `driver:default` puts it in PMOS did with Undo. Undo reopens the draft
13
+ * and it never defaults again.
14
+ * lapse class C (a stage move others read, a message to a person): it waits for the PM in the daily batch. After LAPSE_DAYS one
15
+ * `lapse` line closes it as "not sent": nothing is written or sent. Undo reopens it for another LAPSE_DAYS.
16
+ * wait younger than its deadline.
17
+ * A board in mode off or shadow is left alone. `pmos ai off` and PMOS_AUTONOMY=off stop defaults and lapses too.
18
+ *
19
+ * DEFAULT_DAYS · LAPSE_DAYS · DEFAULT_JOB · LAPSE_JOB
20
+ * classify(state, { now }) PURE → [{ id, way: apply|default|lapse|wait, cls, due }]
21
+ * heldTargets(state) PURE → [target key] targets whose agent blocker of the latest sweep day woke nothing while a
22
+ * draft was open on them (the health number; 0 is the goal)
23
+ * step({ file, stateDir, product, ctx, now, env, settingsDir, log }) → Promise of { applied, defaulted, lapsed } one ledger, once per sweep
24
+ * CLI: node lib/never-wait.js held <state folder> prints the held targets, the count on the last line
25
+ */
26
+ const D = require('./driver.js');
27
+
28
+ const DEFAULT_DAYS = 2;
29
+ const LAPSE_DAYS = 7;
30
+ const DEFAULT_JOB = 'driver:default';
31
+ const LAPSE_JOB = 'driver:lapse';
32
+ const DEFAULT_BY = 'pmos:default';
33
+ const LAPSE_BY = 'pmos:lapse';
34
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
35
+ const md = (ms) => { const d = new Date(ms); return `${d.getUTCDate()} ${MON[d.getUTCMonth()]}`; };
36
+ const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
37
+
38
+ const A = () => require('./autonomy.js');
39
+ const UNDOABLE = () => require('./driver-decide.js').UNDOABLE;
40
+ const sinceOf = (p) => Date.parse(p.reopened_at || p.at);
41
+
42
+ /** How each open draft goes now. PURE. */
43
+ function classify(state, { now = Date.now() } = {}) {
44
+ const out = [];
45
+ for (const p of D.openProposals(state)) {
46
+ const since = sinceOf(p);
47
+ const cls = A().classOfDriver(p.what);
48
+ if (cls === 'C') {
49
+ const due = Number.isFinite(since) ? since + LAPSE_DAYS * D.DAY : null;
50
+ out.push({ id: p.id, cls, way: due != null && now >= due ? 'lapse' : 'wait', due });
51
+ continue;
52
+ }
53
+ const sourced = require('./source-guard.js').citedOf(p).length > 0;
54
+ if (sourced && UNDOABLE().has(p.what)) { out.push({ id: p.id, cls, way: 'apply', due: null }); continue; }
55
+ const due = Number.isFinite(since) ? since + DEFAULT_DAYS * D.DAY : null;
56
+ out.push({ id: p.id, cls, way: !p.no_default && due != null && now >= due ? 'default' : 'wait', due });
57
+ }
58
+ return out;
59
+ }
60
+
61
+ /** The targets the old rule still holds: an agent blocker of the latest sweep day with no wake, on a target with an open draft. PURE. */
62
+ function heldTargets(state) {
63
+ const days = state.blockers.map((b) => b.day).filter(Boolean).sort();
64
+ const day = days[days.length - 1];
65
+ if (!day) return [];
66
+ const open = new Set(D.openProposals(state).map((p) => D.targetKey(p.target)));
67
+ const out = new Set();
68
+ for (const b of state.blockers) {
69
+ if (b.day !== day || b.owner !== 'agent' || !b.target) continue;
70
+ const k = D.targetKey(b.target);
71
+ if (open.has(k) && !state.wakeKeys.has(`stuck:${b.key}:${day}`)) out.add(k);
72
+ }
73
+ return [...out];
74
+ }
75
+
76
+ /** The board a draft's target is on, for its mode: Work is `work`; an initiative takes the board of its latest run. */
77
+ function boardOf(state, target) {
78
+ if (target.kind === 'work') return 'work';
79
+ const runs = [...state.runs.values()].filter((r) => D.targetKey(r.target) === D.targetKey(target) && r.board);
80
+ return runs.length ? runs[runs.length - 1].board : null;
81
+ }
82
+
83
+ const actorOf = (p) => {
84
+ const actor = require('./actor.js');
85
+ const a = { by: typeof p.by === 'string' ? p.by : 'agent:unknown', via: 'cli' };
86
+ return actor.isAgent(a) ? a : { by: 'agent:unknown', via: 'cli' };
87
+ };
88
+ const nameOf = (p) => `${String(p.what || 'draft').replace(/-/g, ' ')} on ${p.target.id}`;
89
+
90
+ /** One ledger, once per sweep. Never throws; each refusal leaves the draft as it is. */
91
+ async function step({ file, stateDir, product = null, ctx = {}, now = Date.now(), env = process.env, settingsDir = null, log = console.error } = {}) {
92
+ const out = { applied: 0, defaulted: 0, lapsed: 0 };
93
+ if (!file || !stateDir) return out;
94
+ const say = (s) => { try { log(`[never-wait] ${s}`); } catch { /* a log never stops the step */ } };
95
+ let state = D.fold(D.readLines(file));
96
+ const plan = classify(state, { now });
97
+ if (!plan.length) return out;
98
+ const killed = A().killed({ env, settingsDir });
99
+ const decideLib = require('./driver-decide.js');
100
+ for (const x of plan) {
101
+ if (x.way === 'wait') continue;
102
+ state = D.fold(D.readLines(file));
103
+ const p = state.proposals.get(x.id);
104
+ if (!p || p.state !== 'open') continue;
105
+ const mode = D.modeOf(state, boardOf(state, p.target));
106
+ if (mode === 'off' || mode === 'shadow') continue;
107
+ const ini = p.target.kind === 'initiative' ? p.target.id : null;
108
+ if (x.way === 'apply') {
109
+ const r = await decideLib.autoApply({ file, proposal: p.id, actor: actorOf(p), ctx: { ...ctx, settingsDir }, now, stateDir, product, mode });
110
+ if (r.applied) { out.applied++; say(`applied ${p.id} (${nameOf(p)}) on ${product || '*'}: class ${r.cls}, with Undo`); continue; }
111
+ // held by a rule (mode, demotion, Ask first, a PM edit): it is a question now, with the same 2-day default
112
+ const due = sinceOf(p) + DEFAULT_DAYS * D.DAY;
113
+ if (p.no_default || !(now >= due)) continue;
114
+ x.way = 'default'; x.due = due;
115
+ }
116
+ if (killed) continue;
117
+ if (x.way === 'default') {
118
+ const dec = A().decide({ stateDir, job: DEFAULT_JOB, product, cls: 'B', mode: 'auto', undoable: true, now, env, settingsDir });
119
+ if (!dec.apply) continue;
120
+ const why = `No answer by ${md(x.due)}, so PMOS left it as it was.`;
121
+ D.append(file, { ev: 'default', proposal: p.id, why, by: DEFAULT_BY }, { now });
122
+ A().recordApplied(stateDir, { job: DEFAULT_JOB, product, ref: p.id, title: `Left ${nameOf(p)} as it was: nobody answered by ${md(x.due)}`, cls: 'B', ini, why,
123
+ src: [`Unanswered draft, due ${new Date(x.due).toISOString().slice(0, 10)}`] }, { now, settingsDir });
124
+ out.defaulted++; say(`defaulted ${p.id} (${nameOf(p)}) on ${product || '*'}: left as it was`);
125
+ } else if (x.way === 'lapse') {
126
+ const why = `Nobody sent it within ${LAPSE_DAYS} days, so PMOS did not send it.`;
127
+ D.append(file, { ev: 'lapse', proposal: p.id, why, by: LAPSE_BY }, { now });
128
+ A().recordApplied(stateDir, { job: LAPSE_JOB, product, ref: p.id, title: `Not sent: ${nameOf(p)}, waited ${LAPSE_DAYS} days`, cls: 'B', ini, why,
129
+ src: [`Waited ${LAPSE_DAYS} days in the daily batch`] }, { now, settingsDir });
130
+ out.lapsed++; say(`lapsed ${p.id} (${nameOf(p)}) on ${product || '*'}: not sent`);
131
+ }
132
+ }
133
+ return out;
134
+ }
135
+
136
+ module.exports = { DEFAULT_DAYS, LAPSE_DAYS, DEFAULT_JOB, LAPSE_JOB, DEFAULT_BY, LAPSE_BY, classify, heldTargets, step };
137
+
138
+ if (require.main === module) {
139
+ const [verb, dir] = process.argv.slice(2);
140
+ if (verb !== 'held' || !dir) { console.log('usage: node lib/never-wait.js held <state folder>'); process.exit(2); }
141
+ const held = heldTargets(D.fold(D.readLines(D.ledgerFile(dir))));
142
+ for (const k of held) console.log(k);
143
+ console.log(held.length);
144
+ }
@@ -92,7 +92,7 @@ const VERBS = Object.freeze({
92
92
  blueprint: Object.freeze({ module: 'blueprint-cli.js', run: null, guide: 'cli.md',
93
93
  help: 'pmos blueprint [list|show|unplaced|check] — every feature of the product with a status worked out from its evidence (pmos blueprint help)' }),
94
94
  program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'cli.md',
95
- help: 'pmos program suggest — Claude\'s milestone suggestions for a program, filed by its review run (pmos program help)' }),
95
+ help: 'pmos program line|draft|order|capacity|decide|outcome|charter|suggest — the program line (Charter, Sequence, Track, Land) and the milestone suggestions for a program (pmos program help)' }),
96
96
  // Not a pm-os-absorb verb (run: null): c3-meet-extension added it through the same table.
97
97
  extension: Object.freeze({ module: 'extension-cli.js', run: null, guide: 'cli.md',
98
98
  help: 'pmos extension — the folder of the Chrome extension for Google Meet, and the three steps to load it' }),
@@ -145,6 +145,9 @@ const VERBS = Object.freeze({
145
145
  // Not a pm-os-absorb verb (run: null): initiative standing-rules-list (bet A470) added it through the same table.
146
146
  rules: Object.freeze({ module: 'rules-cli.js', run: null, guide: 'cli.md',
147
147
  help: 'pmos rules [edit|retire|restore|count] — the standing rules PMOS learned from your corrections: where each came from, times fired, last fired (pmos rules help)' }),
148
+ // Not a pm-os-absorb verb (run: null): initiative pmos-line (product line plan, slice 2) added it through the same table.
149
+ line: Object.freeze({ module: 'line-cli.js', run: null, guide: 'cli.md',
150
+ help: 'pmos line [<initiative>|count] — where each initiative stands on its own workflow: days there, what is missing, the next move, stuck or not (pmos line help)' }),
148
151
  // Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
149
152
  why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
150
153
  help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
@@ -15,7 +15,7 @@ const fs = require('fs');
15
15
  const pmItems = require('./pm-items.js');
16
16
  const MS = require('./milestone-suggest.js');
17
17
 
18
- const COMMANDS = { program: ['suggest', 'charter'] };
18
+ const COMMANDS = { program: ['suggest', 'charter', 'line', 'draft', 'order', 'capacity', 'decide', 'outcome'] };
19
19
  const USAGE = [
20
20
  'usage: pmos program suggest — PMOS\'s milestone suggestions for a program',
21
21
  ' pmos program suggest --json <file|->',
@@ -23,8 +23,22 @@ const USAGE = [
23
23
  ' { "op": "add|move|rename|drop|risk", "milestone": "<id, not for add>", "name": "<add, rename>", "date": "YYYY-MM-DD (add, move)",',
24
24
  ' "waits": ["<initiative id>", … (add)], "why": "<one line>", "src": { "kind": "deliver|jira|meeting|task|target|member|charter", "label": "Steering, Oct 22" } }',
25
25
  ' It answers filed, duplicate or declined for each. The PM keeps, changes or drops it on the page. Nothing is sent.',
26
- ' pmos program charter <id> [--goal "<text>"] [--why "<text>"]',
27
- ' The program card\'s Goal and For lines, after the PM said yes in the chat. Run it in the repository where the program was made.',
26
+ ' pmos program charter <id> [--goal "<text>"] [--why "<text>"] [--target YYYY-MM-DD] [--owner "<name>"]',
27
+ ' The program card\'s Goal, For, target date and owner, after the user said yes in the chat. Run it in the repository where the program was made.',
28
+ ' pmos program line [<id>] [--json] [--root <dir>]',
29
+ ' Where each program stands: Charter, Sequence, Track or Land, what is missing, the next move, the forecast against the target,',
30
+ ' and one decision row for each team two products need in Build beyond its capacity. Reads every product on this computer, or only',
31
+ ' the --root folders given. Writes nothing.',
32
+ ' pmos program draft <id>',
33
+ ' File PMOS\'s milestone drafts (from the initiatives\' dates) as suggestions the program shows with Keep and Decline.',
34
+ ' pmos program order <id> [<id>,<id>,… | --clear]',
35
+ ' Save the order of the program\'s initiatives; with no list, the order PMOS proposes. Prints the Undo.',
36
+ ' pmos program capacity <team> <n>',
37
+ ' How many initiatives a team builds at once (default 2). The program line holds the rest before Implementation. Prints the Undo.',
38
+ ' pmos program decide <id> --keep-target | pmos program decide --team <team> --first <initiative>',
39
+ ' Record the user\'s decision on a forecast past the target, or which initiative a shared team builds first.',
40
+ ' pmos program outcome <id> "<what the outcome read says>"',
41
+ ' Record the outcome read against the program\'s goal (the last exit of Land).',
28
42
  ];
29
43
  const MAX_PER_RUN = 8;
30
44
 
@@ -34,6 +48,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
34
48
  if (!verb || verb === 'help' || verb === '--help' || verb === '-h') { for (const l of USAGE) say(l); return verb ? 0 : 1; }
35
49
  if (!COMMANDS.program.includes(verb)) { say(`unknown program command "${verb}" — one of ${COMMANDS.program.join(', ')}`); return 2; }
36
50
  if (verb === 'charter') return charter(args.slice(1), { say, cwd: process.cwd() });
51
+ if (LINE_VERBS.includes(verb)) return lineVerb(verb, args.slice(1), { say, cwd: process.cwd(), env });
37
52
  const i = args.indexOf('--json'), src = i >= 0 ? args[i + 1] : null;
38
53
  if (!src) { say('usage: pmos program suggest --json <file|->'); return 2; }
39
54
  const file = env.PMOS_MS_REVIEW_FILE, runId = env.PMOS_MS_REVIEW_RUN, program = env.PMOS_MS_REVIEW_PROGRAM;
@@ -66,9 +81,10 @@ function charter(args, { say, cwd }) {
66
81
  const path = require('path');
67
82
  const P = require('./programs.js');
68
83
  const pos = [], flags = {};
69
- for (let k = 0; k < args.length; k++) { const a = args[k]; if (/^--(goal|why|root)$/.test(a)) flags[a.slice(2)] = args[++k]; else if (a.startsWith('--')) { say(`✗ unknown flag ${a}`); return 2; } else pos.push(a); }
84
+ for (let k = 0; k < args.length; k++) { const a = args[k]; if (/^--(goal|why|root|target|owner)$/.test(a)) flags[a.slice(2)] = args[++k]; else if (a.startsWith('--')) { say(`✗ unknown flag ${a}`); return 2; } else pos.push(a); }
70
85
  const id = pos[0];
71
- if (!id || (flags.goal === undefined && flags.why === undefined)) { say(USAGE[USAGE.length - 2]); return 2; }
86
+ const keys = ['goal', 'why', 'target', 'owner'].filter((k) => flags[k] !== undefined);
87
+ if (!id || !keys.length) { say(USAGE.find((l) => l.includes('pmos program charter'))); return 2; }
72
88
  if (!P.ID_RE.test(id)) { say('✗ the program id is lower-case letters, numbers and dashes'); return 2; }
73
89
  const root = path.resolve(cwd, flags.root || '.');
74
90
  const files = [['pmos', 'state'], ['state'], ['.pmos'], ['planning', 'runs']].map((r) => path.join(root, ...r, 'programs.jsonl')).filter((f) => fs.existsSync(f));
@@ -76,15 +92,154 @@ function charter(args, { say, cwd }) {
76
92
  for (const f of files) { const p = P.fold(pmItems.readLines(f).filter(Boolean))[id]; if (p && p.charter) { file = f; prog = p; break; } }
77
93
  if (!prog) { say(`✗ no charter of ${id} in this repository. Run it in the product where the program was made`); return 1; }
78
94
  const next = { ...prog, id };
79
- if (flags.goal !== undefined) next.goal = String(flags.goal || '');
80
- if (flags.why !== undefined) next.why = String(flags.why || '');
95
+ for (const k of keys) next[k] = String(flags[k] || '');
81
96
  const v = P.validProgram(next);
82
97
  if (v.error) { say('✗ ' + v.error); return 1; }
83
98
  if (flags.goal !== undefined && String(flags.goal).trim().length > 160) say(' ! the goal was cut to 160 characters');
84
99
  pmItems.appendEvent(file, { ...v, from: prog.from || undefined });
85
- const undo = ['pmos program charter', id].concat(flags.goal !== undefined ? ['--goal', JSON.stringify(prog.goal || '')] : [], flags.why !== undefined ? ['--why', JSON.stringify(prog.why || '')] : []).join(' ');
86
- say(`✓ ${id}: ${[flags.goal !== undefined ? 'goal' : '', flags.why !== undefined ? 'why' : ''].filter(Boolean).join(' and ')} saved to ${path.relative(root, file)}. The program card shows it. Undo: ${undo}`);
100
+ const undo = ['pmos program charter', id].concat(...keys.map((k) => ['--' + k, JSON.stringify(prog[k] || '')])).join(' ');
101
+ say(`✓ ${id}: ${keys.map((k) => (k === 'target' ? 'target date' : k)).join(' and ')} saved to ${path.relative(root, file)}. The program card shows it. Undo: ${undo}`);
87
102
  return 0;
88
103
  }
89
104
 
90
- module.exports = { run, COMMANDS, USAGE, charter };
105
+ const LINE_VERBS = ['line', 'draft', 'order', 'capacity', 'decide', 'outcome'];
106
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
107
+ const short = (d) => (d ? MON[+d.slice(5, 7) - 1] + ' ' + (+d.slice(8, 10)) + ' ' + d.slice(0, 4) : '');
108
+
109
+ /** The program line verbs (lib/program-line.js). `line` reads; the rest write one line each, to the file that holds what they change:
110
+ * draft → the charter workspace's milestone-reviews.jsonl (suggestions the program page shows with Keep and Decline);
111
+ * order, decide <id>, outcome → the charter workspace's programs.jsonl; capacity and decide --team → this repository's programs.jsonl
112
+ * (a team spans products: extrasOf reads the lines of every product). Exit 0 done, 1 refused, 2 usage. */
113
+ function lineVerb(verb, args, { say, cwd, env, now = Date.now(), read: readFn } = {}) {
114
+ const path = require('path');
115
+ const PL = require('./program-line.js');
116
+ const driver = require('./driver.js');
117
+ const pos = [], flags = {};
118
+ for (let k = 0; k < args.length; k++) {
119
+ const a = args[k];
120
+ if (a === '--json' || a === '--keep-target' || a === '--clear') flags[a.slice(2)] = true;
121
+ else if (/^--(root|team|first)$/.test(a)) { const v = args[++k]; if (a === '--root') (flags.root = flags.root || []).push(v); else flags[a.slice(2)] = v; }
122
+ else if (a.startsWith('--')) { say(`✗ unknown flag ${a}`); return 2; }
123
+ else pos.push(a);
124
+ }
125
+ const here = (flags.root && flags.root[0]) ? path.resolve(cwd, flags.root[0]) : gitTop(cwd);
126
+ const roots = flags.root ? PL.rootsOf(flags.root.map((r) => path.resolve(cwd, r)), env, false) : PL.rootsOf([here], env, true);
127
+ const R = () => (readFn || PL.read)(roots, { now, only: verb === 'line' ? pos[0] || null : null, env });
128
+ const rootOfWs = (r, ws) => (r.products.find((x) => x.ws === ws) || {}).root || null;
129
+ const progFile = (root) => { const d = driver.stateDirOf(root); return d ? path.join(d, 'programs.jsonl') : null; };
130
+
131
+ if (verb === 'line') {
132
+ const r = R();
133
+ if (flags.json) { say(JSON.stringify({ ok: true, ...r })); return 0; }
134
+ if (!r.programs.length) { say(pos[0] ? `No open program ${pos[0]} in the products this computer has.` : 'No open program in the products this computer has.'); return 0; }
135
+ for (const L of r.programs) {
136
+ const where = L.station ? `${L.station.name} (${L.station.n} of ${L.station.of})` : 'Landed';
137
+ const fc = L.forecast.state === 'past' ? `forecast ${short(L.forecast.date)}, past the target ${short(L.target)}` : L.forecast.state === 'inside' ? `forecast ${short(L.forecast.date)}, inside the target ${short(L.target)}`
138
+ : L.forecast.state === 'cant-tell' ? "forecast: can't tell" : L.forecast.state === 'no-target' ? `forecast ${short(L.forecast.date)}, no target` : '';
139
+ say(`${L.title} · ${where}${L.products.length > 1 ? ' · ' + L.products.join(' + ') : ''}${fc ? ' · ' + fc : ''}`);
140
+ const miss = L.station ? L.stations[L.station.n - 1].missing : [];
141
+ if (miss.length) say(` missing: ${miss.join('; ')}`);
142
+ say(` next: ${L.next}`);
143
+ }
144
+ for (const c of r.clashes) {
145
+ say(`Decide · ${c.text}`);
146
+ say(` PMOS recommends: ${c.recommend.why}${c.recommend.wait.length ? ' ' + c.recommend.wait.join(', ') + ' wait.' : ''} Keep it: pmos program decide --team ${JSON.stringify(c.team)} --first ${c.recommend.first}`);
147
+ }
148
+ for (const p of r.products.filter((x) => !x.ok)) say(` ! ${p.product}: ${p.error}`);
149
+ return 0;
150
+ }
151
+
152
+ if (verb === 'capacity') {
153
+ const team = pos[0], n = Number(pos[1]);
154
+ if (!team || !Number.isInteger(n) || n < 1 || n > 50) { say('usage: pmos program capacity <team> <n> (n from 1 to 50)'); return 2; }
155
+ const file = progFile(here);
156
+ if (!file) { say('✗ this repository has no PMOS state folder'); return 1; }
157
+ const was = PL.extrasOf(pmItems.readLines(file).filter(Boolean)).capacity[team] || PL.DEFAULT_CAPACITY;
158
+ pmItems.appendEvent(file, { kind: 'team-capacity', team: String(team).slice(0, 80), n }, new Date(now));
159
+ say(`[program-line] ✓ ${team} builds ${n} at once (was ${was}). Undo: pmos program capacity ${JSON.stringify(team)} ${was}`);
160
+ return 0;
161
+ }
162
+
163
+ if (verb === 'decide' && flags.team) {
164
+ if (!flags.first || !P_INI.test(flags.first)) { say('usage: pmos program decide --team <team> --first <initiative>'); return 2; }
165
+ const file = progFile(here);
166
+ if (!file) { say('✗ this repository has no PMOS state folder'); return 1; }
167
+ pmItems.appendEvent(file, { kind: 'decision', team: String(flags.team).slice(0, 80), first: flags.first }, new Date(now));
168
+ say(`[program-line] ✓ ${flags.team} builds ${flags.first} first. The program line follows it.`);
169
+ return 0;
170
+ }
171
+
172
+ const id = pos[0];
173
+ if (!id) { say(USAGE.find((l) => l.includes('pmos program ' + verb))); return 2; }
174
+ const r = R();
175
+ const L = r.programs.find((x) => x.id === id);
176
+ if (!L) { say(`✗ no open program ${id} in the products this computer has`); return 1; }
177
+ const home = rootOfWs(r, L.home);
178
+ if (!home) { say(`✗ the charter of ${id} is in a product this computer does not have`); return 1; }
179
+
180
+ if (verb === 'order') {
181
+ const P = require('./programs.js');
182
+ const list = flags.clear ? [] : pos[1] ? String(pos[1]).split(',').map((x) => x.trim()).filter(Boolean) : L.order.proposed;
183
+ const v = P.validOrder(list);
184
+ if (v.error) { say('✗ ' + v.error); return 1; }
185
+ const known = new Set(L.members.map((m) => m.id));
186
+ const bad = v.find((x) => !known.has(x));
187
+ if (bad) { say(`✗ ${bad} is not an initiative of ${id}`); return 1; }
188
+ const lines = pmItems.readLines(progFile(home)).filter(Boolean);
189
+ const was = (P.fold(lines)[id] || {}).order || [];
190
+ pmItems.appendEvent(progFile(home), { kind: 'order', program: id, order: v }, new Date(now));
191
+ say(`[program-line] ✓ ${id} order: ${v.length ? v.join(' → ') : 'A to Z'}. Undo: pmos program order ${id} ${was.length ? was.join(',') : '--clear'}`);
192
+ return 0;
193
+ }
194
+
195
+ if (verb === 'decide') {
196
+ if (!flags['keep-target']) { say('usage: pmos program decide <id> --keep-target'); return 2; }
197
+ if (L.forecast.state !== 'past' && L.forecast.state !== 'cant-tell') { say(`${id}: the forecast is not past the target; nothing to decide.`); return 0; }
198
+ pmItems.appendEvent(progFile(home), { kind: 'decision', program: id, choice: 'keep-target', forecast: L.forecast.date, target: L.target }, new Date(now));
199
+ say(`[program-line] ✓ ${id}: target ${short(L.target)} kept against the forecast ${short(L.forecast.date) || "can't tell"}. A new slip asks again.`);
200
+ return 0;
201
+ }
202
+
203
+ if (verb === 'outcome') {
204
+ const text = String(pos.slice(1).join(' ') || '').replace(/\s+/g, ' ').trim().slice(0, 400);
205
+ if (!text) { say('usage: pmos program outcome <id> "<what the outcome read says>"'); return 2; }
206
+ pmItems.appendEvent(progFile(home), { kind: 'outcome', program: id, text }, new Date(now));
207
+ say(`[program-line] ✓ ${id}: outcome read saved.`);
208
+ return 0;
209
+ }
210
+
211
+ // draft: file the milestone drafts as one finished review run, so the program page shows them open with Keep and Decline. The open
212
+ // suggestions of the last review are filed again in the same run, so nothing a review said is withdrawn by this one.
213
+ const items = PL.draftsOf(L);
214
+ if (!items.length) { say(!(L.stations[1].missing || []).includes('milestones') ? `${id} already has milestones; PMOS drafts only a program's first ones.` : `${id}: no milestone to draft${L.drafts.cantTell.length ? `; can't tell for ${L.drafts.cantTell.join(', ')} (no date)` : ''}.`); return 0; }
215
+ const d = driver.stateDirOf(home);
216
+ const file = MS.fileOf(d);
217
+ const st = MS.fold(pmItems.readLines(file))[id] || null;
218
+ const prog = { milestones: [] };
219
+ const carry = st ? MS.openOf(st, prog) : [];
220
+ const run = 'line' + now.toString(36);
221
+ const at = new Date(now);
222
+ pmItems.appendEvent(file, { kind: 'review-start', program: id, run, why: 'line', members: L.members.map((m) => (m.ws || '') + ':' + m.id).sort().join(',') }, at);
223
+ let filed = 0, skipped = 0;
224
+ const keys = new Set();
225
+ for (const raw of items.concat(carry.map(({ key, run: _r, at: _a, ...it }) => it))) {
226
+ const v = MS.validItem(raw);
227
+ if (v.error) { skipped++; continue; }
228
+ const key = MS.keyOf(id, v.item);
229
+ if (keys.has(key) || (st && st.declined.has(MS.sigOf(v.item)))) { skipped++; continue; }
230
+ keys.add(key);
231
+ pmItems.appendEvent(file, { kind: 'suggest', program: id, run, key, item: v.item }, at);
232
+ filed++;
233
+ }
234
+ pmItems.appendEvent(file, { kind: 'review-end', program: id, run, ok: true }, at);
235
+ say(`[program-line] ✓ ${id}: ${filed} milestone suggestion${filed === 1 ? '' : 's'} filed${skipped ? ` (${skipped} declined before or repeated)` : ''}. The program shows them with Keep and Decline.`);
236
+ for (const it of items) say(` ${short(it.date)} · ${it.name} · waits on ${it.waits.join(', ')}`);
237
+ if (L.drafts.cantTell.length) say(` can't tell: ${L.drafts.cantTell.join(', ')} (no date)`);
238
+ return 0;
239
+ }
240
+ const P_INI = /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/;
241
+ function gitTop(cwd) {
242
+ try { return require('child_process').execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
243
+ }
244
+
245
+ module.exports = { run, COMMANDS, USAGE, charter, lineVerb };