create-pmos 0.784.0 → 0.786.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 +90 -59
- package/payload/AGENTS.md +160 -0
- package/payload/KIT-VERSION +1 -1
- package/payload/design-system/ui/components/Badge/README.md +2 -2
- package/payload/design-system/ui/components/Glyph/README.md +28 -0
- package/payload/design-system/ui/components/bundle.css +3 -0
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/bin/card-catalog-gen.js +22 -0
- package/workspace/board-columns-test.js +2 -2
- package/workspace/briefing-premium-insights-test.js +5 -4
- package/workspace/calm-timeline-test.js +4 -3
- package/workspace/changelog.json +89 -0
- package/workspace/design-system/ui/components/Badge/README.md +2 -2
- package/workspace/design-system/ui/components/Glyph/README.md +28 -0
- package/workspace/design-system/ui/components/bundle.css +3 -0
- package/workspace/guide/cli.md +19 -0
- package/workspace/guide/home.md +5 -3
- package/workspace/guide/index.md +2 -2
- package/workspace/guide/jira.md +8 -0
- package/workspace/guide/layout.md +16 -2
- package/workspace/lib/briefing-premium-agent.js +3 -0
- package/workspace/lib/card-catalog-gen.js +123 -0
- package/workspace/lib/cos-chat.js +1 -0
- package/workspace/lib/declined-asks.js +177 -0
- package/workspace/lib/declined-cli.js +87 -0
- package/workspace/lib/goal-chat.js +1 -0
- package/workspace/lib/initiative-chat.js +1 -0
- package/workspace/lib/jira-status.js +11 -2
- package/workspace/lib/live-events.js +99 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/program-chat.js +1 -0
- package/workspace/lib/quiet-cli.js +81 -0
- package/workspace/lib/quiet-sweep.js +228 -0
- package/workspace/lib/report-chat.js +1 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-backlog.js +21 -1
- package/workspace/lib/routes-live-rows.js +30 -0
- package/workspace/lib/routes-slash.js +142 -2
- package/workspace/lib/routes-your-move.js +39 -3
- package/workspace/lib/task-cli.js +5 -3
- package/workspace/lib/workflow-chat.js +1 -0
- package/workspace/okr-goals-ui-test.js +3 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-cols.js +3 -1
- package/workspace/public/pm/bd-span.js +13 -7
- package/workspace/public/pm/bd-sprint.js +29 -1
- package/workspace/public/pm/bd-views.js +6 -3
- package/workspace/public/pm/bd-work-ds.css +1 -0
- package/workspace/public/pm/bd-work.js +15 -2
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-insights.css +3 -4
- package/workspace/public/pm/ds-bridge.css +12 -0
- package/workspace/public/pm/goal-forecast.js +7 -4
- package/workspace/public/pm/home-app.js +14 -4
- package/workspace/public/pm/komorebi.css +1 -0
- package/workspace/public/pm/live-edit.js +34 -3
- package/workspace/public/pm/live-feed.js +43 -0
- package/workspace/public/pm/okr-list.js +5 -2
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/premium-insights.js +10 -4
- package/workspace/public/pm/premium-vw-doc.css +5 -0
- package/workspace/public/pm/premium-vw-doc.js +11 -31
- package/workspace/public/pm/premium-vw-file.js +13 -8
- package/workspace/public/pm/premium-vw-guide.css +9 -0
- package/workspace/public/pm/premium-vw-guide.js +20 -17
- package/workspace/public/pm/quiet-view.js +107 -0
- package/workspace/public/pm/reading-view.js +44 -0
- package/workspace/public/pm/state-glyph.js +135 -0
- package/workspace/skills/jira-sync.skill +4 -3
- package/workspace/task-milestones-test.js +2 -2
- package/workspace/test-lists/a2ui-chat-rules.json +9 -0
- package/workspace/test-lists/a2ui-live-rows.json +9 -0
- package/workspace/test-lists/declined-asks.json +9 -0
- package/workspace/test-lists/quiet-sweep.json +9 -0
- package/workspace/test-lists/state-glyph.json +5 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* declined-asks.js — saying no, kindly and on record (initiative declined-asks-reply, bet A326). A PM closes many asks without doing them
|
|
3
|
+
* (Won't Do, Declined, Duplicate…). PMOS lists them from the product's stored Jira readings, drafts a short, kind reply to the person who
|
|
4
|
+
* asked, and, when the PM records one, writes it to the product's out-of-scope list, where lib/past.js (and the "You decided this before"
|
|
5
|
+
* check, lib/past-repeat.js) finds a later repeat of the same ask.
|
|
6
|
+
*
|
|
7
|
+
* PMOS NEVER SENDS THE REPLY. It is a draft the PM copies and sends where they talk to that person. No model, no network, no Jira write.
|
|
8
|
+
*
|
|
9
|
+
* declinedOf(readings, { now, days }) → [ask] PURE: the asks closed without being done in the window, newest first
|
|
10
|
+
* reasonOf(ask) → string PURE: the default reason, from the status or the resolution
|
|
11
|
+
* replyFor(ask, { reason }) → string PURE: the reply draft, at most 3 sentences
|
|
12
|
+
* collect(root, { now, days }) → [ask] every stored Jira reading of the product (lib/jira-status.js)
|
|
13
|
+
* record(root, key, { reason, now, asks }) → { ok, ask, reply, file } | { ok: false, error }
|
|
14
|
+
* recorded(root) → [line] the recorded asks, last line per key
|
|
15
|
+
* CLI: node declined-asks.js recorded → the count on its last line (the experiment's health read)
|
|
16
|
+
*
|
|
17
|
+
* AN ASK is { key, summary, status, resolution, reporter, resolved, url }. The reading carries the reporter's display name only, never an
|
|
18
|
+
* email (lib/jira-status.js askedClosed).
|
|
19
|
+
*
|
|
20
|
+
* THE RECORD. One line per record in `declined-asks.jsonl` in the product's records folder, { at, key, summary, reporter, reason, reason_by:
|
|
21
|
+
* 'pm' | 'pmos', reply, file }, and `planning/out-of-scope/<key>.md` (type Reference, decision: declined). A later record of the same key
|
|
22
|
+
* replaces the file only while it is still the one PMOS wrote (its text matches the last line's hash); a file the PM changed is kept.
|
|
23
|
+
*/
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const crypto = require('crypto');
|
|
27
|
+
|
|
28
|
+
const FILE = 'declined-asks.jsonl';
|
|
29
|
+
const DAYS = 90;
|
|
30
|
+
const DAY_MS = 86400000;
|
|
31
|
+
const KEY_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
32
|
+
// Closed without being done, by the status's or the resolution's name (lib/task-jira.js CLOSED_NOT_DONE, the same words).
|
|
33
|
+
const CLOSED_NOT_DONE = /invalid|not an issue|won'?t|cancel|duplicate|reject|obsolete|not (?:needed|required|a bug|reproducible)|cannot reproduce|declined|abandon/i;
|
|
34
|
+
const DONE_WORD = /\b(done|closed|resolved|released|complete|shipped|deployed)\b/i;
|
|
35
|
+
const log = (s) => { try { console.log('[declined-asks] ' + s); } catch { /* no console */ } };
|
|
36
|
+
|
|
37
|
+
const one = (v, n = 200) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
38
|
+
const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 12);
|
|
39
|
+
const dayOf = (v) => { const m = /^(\d{4}-\d{2}-\d{2})/.exec(String(v || '')); return m ? m[1] : null; };
|
|
40
|
+
|
|
41
|
+
/** True when the reading was closed without being done: its status or its resolution says so. */
|
|
42
|
+
function isDeclined(r) {
|
|
43
|
+
if (!r) return false;
|
|
44
|
+
const st = String(r.status || ''), res = String(r.resolution || '');
|
|
45
|
+
if (CLOSED_NOT_DONE.test(st)) return true;
|
|
46
|
+
const closed = String(r.category || '').toLowerCase() === 'done' || DONE_WORD.test(st) || !!r.resolved;
|
|
47
|
+
return closed && !!res && CLOSED_NOT_DONE.test(res);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** PURE. The asks closed without being done, resolved in the last `days` days (a ticket with no resolution day counts by its last
|
|
51
|
+
* update), newest first, one per key. */
|
|
52
|
+
function declinedOf(readings, { now = Date.now(), days = DAYS } = {}) {
|
|
53
|
+
const since = new Date(now - days * DAY_MS).toISOString().slice(0, 10);
|
|
54
|
+
const by = new Map();
|
|
55
|
+
for (const r of readings || []) {
|
|
56
|
+
if (!r || !KEY_RE.test(String(r.key || '')) || !isDeclined(r)) continue;
|
|
57
|
+
const day = dayOf(r.resolved) || dayOf(r.updated);
|
|
58
|
+
if (!day || day < since) continue;
|
|
59
|
+
const a = { key: r.key, summary: one(r.summary, 250), status: one(r.status, 60), resolution: r.resolution ? one(r.resolution, 60) : null,
|
|
60
|
+
reporter: r.reporter ? one(r.reporter, 80) : null, resolved: day, url: r.url || null };
|
|
61
|
+
const old = by.get(a.key);
|
|
62
|
+
if (!old || a.resolved > old.resolved) by.set(a.key, a);
|
|
63
|
+
}
|
|
64
|
+
return [...by.values()].sort((x, y) => (x.resolved < y.resolved ? 1 : x.resolved > y.resolved ? -1 : x.key < y.key ? -1 : 1));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** PURE. The reason a reply gives when the PM gave none, from the words the ticket was closed with. */
|
|
68
|
+
function reasonOf(ask) {
|
|
69
|
+
const w = `${(ask && ask.resolution) || ''} ${(ask && ask.status) || ''}`;
|
|
70
|
+
if (/duplicate/i.test(w)) return 'it is already covered by another ticket, so the work happens there';
|
|
71
|
+
if (/not a bug|not an issue|cannot reproduce|not reproducible|invalid/i.test(w)) return 'we could not find a problem to fix as it was described';
|
|
72
|
+
if (/obsolete|not (?:needed|required)/i.test(w)) return 'it is no longer needed after other changes';
|
|
73
|
+
if (/cancel|abandon/i.test(w)) return 'the work it belonged to was stopped';
|
|
74
|
+
return 'it does not fit what we are working on now';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** PURE. The kind reply draft: thanks for the ask, the decision and its reason, what would bring it back. 3 sentences at most. */
|
|
78
|
+
function replyFor(ask, { reason } = {}) {
|
|
79
|
+
const first = ask && ask.reporter ? one(ask.reporter, 80).split(/\s+/)[0] : '';
|
|
80
|
+
const what = one((ask && ask.summary) || 'this', 120).replace(/[.!?…]+$/, '');
|
|
81
|
+
const why = one(reason || reasonOf(ask), 220).replace(/[.!?…]+$/, '');
|
|
82
|
+
const greet = first ? `Hi ${first}, thank you` : 'Thank you';
|
|
83
|
+
return `${greet} for asking for "${what}" (${ask.key}). We decided not to take it on for now, because ${why.charAt(0).toLowerCase() + why.slice(1)}. If something changes, for example more people need it, we will look at it again.`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ── the readings ────────────────────────────────────────────────────────────────────────────────────
|
|
87
|
+
function jiraDirOf(root) { try { return require('./jira-tickets.js').jiraDir(root); } catch { return null; } }
|
|
88
|
+
function readingsOf(root) {
|
|
89
|
+
const dir = jiraDirOf(root);
|
|
90
|
+
if (!dir) return [];
|
|
91
|
+
let names;
|
|
92
|
+
try { names = fs.readdirSync(dir); } catch { return []; }
|
|
93
|
+
const JS = require('./jira-status.js');
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const n of names.sort()) {
|
|
96
|
+
if (!n.endsWith('.md') || n.endsWith('-tickets.md') || n === '_sprint-notes.md') continue;
|
|
97
|
+
const snap = JS.readSnapshot(root, n.slice(0, -3));
|
|
98
|
+
if (snap) for (const r of snap.tickets.values()) out.push(r);
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/** Every declined ask in the product's stored Jira readings. */
|
|
103
|
+
function collect(root, opts = {}) { return declinedOf(readingsOf(root), opts); }
|
|
104
|
+
|
|
105
|
+
// ── the record ──────────────────────────────────────────────────────────────────────────────────────
|
|
106
|
+
function recordsDirOf(root) {
|
|
107
|
+
try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
|
|
108
|
+
}
|
|
109
|
+
const ledgerOf = (root) => path.join(recordsDirOf(root), FILE);
|
|
110
|
+
const outOfScopeRel = (key) => `planning/out-of-scope/${String(key).toLowerCase()}.md`;
|
|
111
|
+
|
|
112
|
+
function readLedger(root) {
|
|
113
|
+
let text;
|
|
114
|
+
try { text = fs.readFileSync(ledgerOf(root), 'utf8'); } catch { return []; }
|
|
115
|
+
const out = [];
|
|
116
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const o = JSON.parse(l); if (o && KEY_RE.test(String(o.key || ''))) out.push(o); } catch { /* a torn line is skipped */ } }
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
/** The recorded asks, the last line for each key wins, newest first. */
|
|
120
|
+
function recorded(root) {
|
|
121
|
+
const by = new Map();
|
|
122
|
+
for (const o of readLedger(root)) by.set(o.key, o);
|
|
123
|
+
return [...by.values()].sort((a, b) => (a.at < b.at ? 1 : -1));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const yq = (s) => '"' + String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
127
|
+
function fileText(ask, { reason, reply, day }) {
|
|
128
|
+
return [
|
|
129
|
+
'---', 'type: Reference', `title: ${yq(one(ask.summary, 150))}`, `timestamp: ${day}`, `ticket: ${ask.key}`, 'decision: declined', '---', '',
|
|
130
|
+
`# ${one(ask.summary, 150)}`, '',
|
|
131
|
+
'- decision: declined', `- date: ${ask.resolved || day}`, `- ticket: ${ask.key}${ask.url ? ' (' + ask.url + ')' : ''}`,
|
|
132
|
+
...(ask.reporter ? [`- asked by: ${ask.reporter}`] : []), `- closed as: ${ask.resolution || ask.status}`, '',
|
|
133
|
+
'## Reasoning', '', `Declined because ${reason}.`, '',
|
|
134
|
+
'## Reply draft', '', 'PMOS drafted this reply. It was not sent.', '', '> ' + reply, '',
|
|
135
|
+
`Recorded by \`pmos declined record ${ask.key}\`. Edit this file freely: PMOS does not write over it once you change it.`, '',
|
|
136
|
+
].join('\n');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Record one declined ask: a ledger line and the out-of-scope file. `asks` (optional) is the list to find the key in (default: collect). */
|
|
140
|
+
function record(root, key, { reason, now = Date.now(), asks } = {}) {
|
|
141
|
+
const k = String(key || '').trim().toUpperCase();
|
|
142
|
+
if (!KEY_RE.test(k)) return { ok: false, error: `"${key}" is not a ticket key such as ABC-123` };
|
|
143
|
+
const list = asks || collect(root, { now, days: 3650 });
|
|
144
|
+
const ask = list.find((a) => a.key === k);
|
|
145
|
+
if (!ask) return { ok: false, error: `${k} is not a declined ask in this product's Jira readings (pmos declined lists them)` };
|
|
146
|
+
const own = one(reason || '', 220).replace(/[.!?…]+$/, '');
|
|
147
|
+
const why = own || reasonOf(ask);
|
|
148
|
+
const reply = replyFor(ask, { reason: why });
|
|
149
|
+
const day = new Date(now).toISOString().slice(0, 10);
|
|
150
|
+
const rel = outOfScopeRel(k);
|
|
151
|
+
const abs = path.join(root, rel);
|
|
152
|
+
const text = fileText(ask, { reason: why.charAt(0).toLowerCase() + why.slice(1), reply, day });
|
|
153
|
+
const last = recorded(root).find((o) => o.key === k);
|
|
154
|
+
let kept = false;
|
|
155
|
+
if (fs.existsSync(abs)) {
|
|
156
|
+
let cur = '';
|
|
157
|
+
try { cur = fs.readFileSync(abs, 'utf8'); } catch { /* unreadable: keep it */ }
|
|
158
|
+
if (!last || hash(cur) !== last.file_hash) kept = true; // the PM wrote or changed it
|
|
159
|
+
}
|
|
160
|
+
if (!kept) { fs.mkdirSync(path.dirname(abs), { recursive: true }); fs.writeFileSync(abs, text); }
|
|
161
|
+
const lineObj = { at: new Date(now).toISOString(), key: k, summary: ask.summary, reporter: ask.reporter, reason: why, reason_by: own ? 'pm' : 'pmos', reply,
|
|
162
|
+
file: rel, file_hash: kept ? (last ? last.file_hash : null) : hash(text), kept_pm_file: kept || undefined };
|
|
163
|
+
fs.mkdirSync(path.dirname(ledgerOf(root)), { recursive: true });
|
|
164
|
+
fs.appendFileSync(ledgerOf(root), JSON.stringify(lineObj) + '\n');
|
|
165
|
+
log(`recorded ${k} (${lineObj.reason_by} reason)${kept ? '; kept the out-of-scope file the PM changed' : ''}`);
|
|
166
|
+
return { ok: true, ask, reply, reason: why, file: rel, kept };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = { FILE, DAYS, isDeclined, declinedOf, reasonOf, replyFor, collect, record, recorded, outOfScopeRel };
|
|
170
|
+
|
|
171
|
+
if (require.main === module) {
|
|
172
|
+
const [cmd, root] = process.argv.slice(2);
|
|
173
|
+
if (cmd === 'recorded') {
|
|
174
|
+
const r = path.resolve(root || process.cwd());
|
|
175
|
+
process.stdout.write(String(recorded(r).length) + '\n');
|
|
176
|
+
} else { process.stdout.write('usage: node declined-asks.js recorded [<product root>]\n'); process.exitCode = 2; }
|
|
177
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* declined-cli.js — `pmos declined`: the asks closed without being done, each with a kind reply draft, and recording one in the product's
|
|
3
|
+
* out-of-scope list (initiative declined-asks-reply, bet A326; lib/declined-asks.js).
|
|
4
|
+
*
|
|
5
|
+
* pmos declined list [--days N] [--json] the asks closed as Won't Do, Declined, Duplicate… in the last N days (90), each with its reply draft
|
|
6
|
+
* pmos declined draft <KEY> [--reason "<why>"] [--json] the reply draft for one ask, with the PM's reason when given
|
|
7
|
+
* pmos declined record <KEY> [--reason "<why>"] [--json] record it: a line in declined-asks.jsonl and planning/out-of-scope/<key>.md
|
|
8
|
+
* every command: [--root <dir>] (default: this repository)
|
|
9
|
+
*
|
|
10
|
+
* PMOS never sends the reply: the PM copies it and sends it where they talk to that person. Exit codes: 0 done, 1 refused, 2 usage. */
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { execFileSync } = require('child_process');
|
|
13
|
+
const D = require('./declined-asks.js');
|
|
14
|
+
|
|
15
|
+
const COMMANDS = { declined: ['list', 'draft', 'record'] };
|
|
16
|
+
const USAGE = [
|
|
17
|
+
'usage: pmos declined list|draft|record — asks closed without being done, each with a kind reply draft PMOS never sends',
|
|
18
|
+
' pmos declined list [--days 90] [--json] the asks closed as Won\'t Do, Declined, Duplicate and the like, newest first, each with its reply draft',
|
|
19
|
+
' pmos declined draft <KEY> [--reason "<why>"] the reply draft for one ask; your reason replaces the one PMOS reads from the ticket',
|
|
20
|
+
' pmos declined record <KEY> [--reason "<why>"] record it in the product\'s out-of-scope list, so a repeat of the ask is raised later',
|
|
21
|
+
'Run it in the product\'s repository, or pass --root <dir>. The reply is a draft: copy it and send it yourself.',
|
|
22
|
+
];
|
|
23
|
+
const ALLOWED = { list: ['json', 'root', 'days'], draft: ['json', 'root', 'reason'], record: ['json', 'root', 'reason'] };
|
|
24
|
+
const BOOL = new Set(['json']);
|
|
25
|
+
|
|
26
|
+
function parse(args) {
|
|
27
|
+
const pos = [], flags = {};
|
|
28
|
+
for (let i = 0; i < args.length; i++) {
|
|
29
|
+
const a = args[i];
|
|
30
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
31
|
+
const k = a.slice(2);
|
|
32
|
+
if (BOOL.has(k)) { flags[k] = true; continue; }
|
|
33
|
+
flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
34
|
+
}
|
|
35
|
+
return { pos, flags };
|
|
36
|
+
}
|
|
37
|
+
function repoRoot(cwd) {
|
|
38
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
39
|
+
}
|
|
40
|
+
const who = (a) => (a.reporter ? `asked by ${a.reporter}` : 'who asked is not known');
|
|
41
|
+
|
|
42
|
+
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now() } = {}) {
|
|
43
|
+
const args = argv[0] === 'declined' ? argv.slice(1) : argv.slice();
|
|
44
|
+
let sub = args[0];
|
|
45
|
+
if (['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return 0; }
|
|
46
|
+
if (!sub || sub.startsWith('--')) { sub = 'list'; args.unshift('list'); }
|
|
47
|
+
if (!COMMANDS.declined.includes(sub)) { say(`unknown declined command "${sub}". Use one of: ${COMMANDS.declined.join(', ')}`); return 2; }
|
|
48
|
+
const { pos, flags } = parse(args.slice(1));
|
|
49
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos declined ${sub}`); return 2; }
|
|
50
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
51
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
52
|
+
|
|
53
|
+
if (sub === 'list') {
|
|
54
|
+
if (pos.length) return fail('pmos declined list takes options, not an argument', 2);
|
|
55
|
+
const days = flags.days === undefined ? D.DAYS : Number(flags.days);
|
|
56
|
+
if (!Number.isInteger(days) || days < 1 || days > 3650) return fail('--days is a whole number from 1 to 3650', 2);
|
|
57
|
+
const done = new Set(D.recorded(root).map((o) => o.key));
|
|
58
|
+
const asks = D.collect(root, { now, days }).map((a) => ({ ...a, recorded: done.has(a.key), reply: D.replyFor(a) }));
|
|
59
|
+
if (flags.json) { say(JSON.stringify({ ok: true, days, asks })); return 0; }
|
|
60
|
+
if (!asks.length) { say(`No ask was closed without being done in the last ${days} days in this product's Jira readings.`); return 0; }
|
|
61
|
+
say(`${asks.length} ask${asks.length === 1 ? ' was' : 's were'} closed without being done in the last ${days} days. Each reply is a draft: PMOS does not send it.`);
|
|
62
|
+
for (const a of asks) {
|
|
63
|
+
say('');
|
|
64
|
+
say(`${a.recorded ? '✓' : '•'} ${a.key} ${a.summary} (closed as ${a.resolution || a.status} on ${a.resolved}, ${who(a)})${a.recorded ? ' — recorded' : ''}`);
|
|
65
|
+
say(` Reply: ${a.reply}`);
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
const key = String(pos[0] || '').toUpperCase();
|
|
70
|
+
if (!key || pos.length > 1) return fail(`pmos declined ${sub} takes one ticket key, such as ABC-123`, 2);
|
|
71
|
+
if (sub === 'draft') {
|
|
72
|
+
const a = D.collect(root, { now, days: 3650 }).find((x) => x.key === key);
|
|
73
|
+
if (!a) return fail(`${key} is not a declined ask in this product's Jira readings (pmos declined lists them)`);
|
|
74
|
+
const reply = D.replyFor(a, { reason: flags.reason || undefined });
|
|
75
|
+
say(flags.json ? JSON.stringify({ ok: true, ask: a, reply }) : reply);
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
// record
|
|
79
|
+
const r = D.record(root, key, { reason: flags.reason || undefined, now });
|
|
80
|
+
if (!r.ok) return fail(r.error);
|
|
81
|
+
if (flags.json) { say(JSON.stringify({ ok: true, key, file: r.file, kept: r.kept, reply: r.reply })); return 0; }
|
|
82
|
+
say(`recorded ${key} in ${r.file}${r.kept ? ' (your own edits to that file are kept)' : ''}`);
|
|
83
|
+
say(`Reply (a draft, not sent): ${r.reply}`);
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -76,6 +76,7 @@ function startMessage(draft) {
|
|
|
76
76
|
'At the end of each message about this goal, add a fenced pmos-goal block: {"step":"progress","state":"working|done|needs-you","met":["done points met"],"open":["done points still open"]}. Copy each done point word for word. Report done only after you checked every point.',
|
|
77
77
|
// batch 22 item 13 (Wawan, 2026-11-01): "6 of 6 met" while the report the goal asked for was only proposed
|
|
78
78
|
'A done point that names a thing to make (a report, slides, a deck, a document) is met only when that thing exists where the PM reads it, opened and checked by you. A proposal, a plan or a draft waiting for a PM press does not meet it: that point stays open, and you end with needs-you and the one press.',
|
|
79
|
+
/* card-catalog:begin, generated by bin/card-catalog-gen.js: edit lib/card-catalog.json, not this block */"The card buttons run these pmos commands (the card catalog; who acts: you = one press with Undo, agent = PMOS starts a run, waits = only after the PM says yes). Run the one that fits the PM's ask, and tell the PM the Undo line it prints: pmos proactive goals add <text> --initiative <id> (Add, Done, Drop, Reopen; you); pmos measure add <anchor> <value> --source <source> (Add a reading; you); pmos outcomes declare <id> --metric <text> (Declare the metric; you); pmos outcomes test <id> --test <text> (Set the smallest test; you); pmos outcomes record <id> worked|didnt-work|cant-tell --evidence <text> (Record the result; you); pmos forecast baseline (Set baseline; you); pmos forecast baseline-off (Clear baseline; you)."/* card-catalog:end */,
|
|
79
80
|
].join('\n');
|
|
80
81
|
}
|
|
81
82
|
const cancelMessage = () => MARK.cancel + ' The PM cancelled this goal. Do no more work for it and say in one line what you stopped.';
|
|
@@ -62,6 +62,7 @@ function rule(info, id) {
|
|
|
62
62
|
'The Work timeline draws one bar per initiative, from the earliest start to the latest due of its tasks. An initiative with no dated task has no bar. Every stage shows there, Monitor and Evaluate included. Use these rules when the PM asks why an initiative is not on the timeline.',
|
|
63
63
|
`A stage's document fills its card only through \`pmos coredoc write --scope initiative:${ini} --key wf-<stage key> --file <path>\` (the stage keys are in \`pmos workflow of ${ini}\`). It is a draft the PM issues on the page. A file written under planning/ is not linked to a card.`,
|
|
64
64
|
);
|
|
65
|
+
out.push(/* card-catalog:begin, generated by bin/card-catalog-gen.js: edit lib/card-catalog.json, not this block */"The card buttons run these pmos commands (the card catalog; who acts: you = one press with Undo, agent = PMOS starts a run, waits = only after the PM says yes). Run the one that fits the PM's ask, and tell the PM the Undo line it prints: pmos task set <id> --due <date> [--start <date>] [--owner <who>] [--notes <text>] [--milestone] [--pin] [--no-milestone] (Move the date, Set start and due, Change owner, Add a note, Make it a milestone, Pin, Back to a task; you); pmos task state <id> --to <state> --why <text> (Change status, Mark done; you); pmos task comment <id> <text> (Comment; you); pmos task describe <id> (Write the description; agent); pmos task remove <id> --why <text> (Remove; you); pmos task add <initiative> \"<title>\" --parent <task> [--due <date>] [--owner <who>] (Add a subtask, Add a task; you); pmos rehearse move <id> --due <date> [--by <days>] (What slips if it moves, Move a task; you); pmos task link <from> <to> --type fs|ss|ff|sf --lag <days> (Link two tasks; you); pmos task unlink <from> <to> (Unlink; you); pmos item move <item> <todo|doing|review|done> --evidence <ref> (Move on the board; you); pmos item set <item> --due <date> --owner <who> (Change date or owner; you); pmos item withdraw <item> (Withdraw; you); pmos initiative up|down <id> (Move up / down; you); pmos initiative top|bottom <id> (Move to top / bottom; you); pmos initiative after <id> <other> (Rank after another; you); pmos initiative check-by <id> <date> (Set check date; you); pmos initiative kind <id> product|project|sdlc (Change kind; you); pmos workflow switch <id> --to <workflow> --stage <stage> --why <text> (Change workflow; you); pmos workflow move <id> --stage <stage> --why <text> (Move to stage; you); pmos initiative describe <id> (Write the description; agent); pmos parked hold <id> --why <text> (Park it, Change the reason; you); pmos initiative export <id> (Export the breakdown; you); pmos initiative adopt <proposal> (Keep; you); pmos initiative drop <proposal> (Drop; you); pmos parked back <id> (Bring back; you); pmos launch check <initiative> --date <date> (Check what is not ready; you); pmos launch tier <initiative> (Set the launch tier; you); pmos ready check <initiative> (Run the check; you); pmos artefacts set <scope> <artefact> --text <text> (Write it; you); pmos artefacts undo <a-id> (Undo; you); pmos signoff ask <initiative> --who <who> (Ask; waits); pmos signoff answer <id> --answer <text> (Record the answer; you); pmos signoff drop <id> --why <text> (Drop; you); pmos rehearse end <initiative> --to <date> (Move the end; you); pmos rehearse cut <task|initiative> (Cut it; you)."/* card-catalog:end */);
|
|
65
66
|
return out;
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
* reading saved before they were carried has none of them, and the burndown says it cannot be drawn. A ticket the search did not return keeps its last reading, marked
|
|
30
30
|
* stale. Titles and statuses only: never a description or a comment. The one person a reading carries is the assignee's display name, with
|
|
31
31
|
* the time of the last update (`assignee`, `updated`): Waiting on others names who a stale ticket waits on (home-your-move-waiting).
|
|
32
|
+
* It may also carry the reporter's display name and the resolution's name (`reporter`, `resolution`), when the read gave them:
|
|
33
|
+
* lib/declined-asks.js drafts a reply to the person who asked when the ticket was closed without being done (bet A326).
|
|
32
34
|
*
|
|
33
35
|
* A task that names a key follows its reading: lib/task-jira.js trackerLines sets its state in memory when the read is newer (no
|
|
34
36
|
* plan item or ledger line is written, D88 still holds).
|
|
@@ -241,6 +243,13 @@ function whoWhen(a, up) {
|
|
|
241
243
|
const t = Date.parse(isStr(up) ? up : '');
|
|
242
244
|
return { ...(name ? { assignee: name } : {}), ...(Number.isFinite(t) ? { updated: new Date(t).toISOString() } : {}) };
|
|
243
245
|
}
|
|
246
|
+
/** Who asked (the reporter's display name only, never an email) and how the ticket was closed (the resolution's name, e.g. "Won't Do"):
|
|
247
|
+
* lib/declined-asks.js drafts the reply to the person who asked when an ask is closed without being done (bet A326). */
|
|
248
|
+
function askedClosed(rep, res) {
|
|
249
|
+
const nm = (v) => clip(oneLine(typeof v === 'string' ? v : v && typeof v === 'object' ? v.displayName || v.name || '' : ''), 80);
|
|
250
|
+
const reporter = nm(rep), resolution = nm(res);
|
|
251
|
+
return { ...(reporter ? { reporter } : {}), ...(resolution ? { resolution } : {}) };
|
|
252
|
+
}
|
|
244
253
|
/** The official Atlassian MCP connector returns custom fields under `fields.customFields`, keyed by name: { Sprint: { id: 'customfield_10004',
|
|
245
254
|
* value: [...] } }. They are put back at the top level under their id and their name, as the REST shape has them, so the sprint, points
|
|
246
255
|
* and flag rules read them. A field already at the top level wins. */
|
|
@@ -271,7 +280,7 @@ function normalizeIssue(x) {
|
|
|
271
280
|
return { key, summary, status, category: categoryOf(status, st.statusCategory), sprint: sprintIn(f), ...sprintsAll(sprintField(f)), subtasks: subtasksOf(f.subtasks), ...subsOf(f.subtasks), fixVersion: fixVersionsOf(f.fixVersions),
|
|
272
281
|
points: pointsIn(f), resolved: dayOf(f.resolutiondate || f.resolved),
|
|
273
282
|
flagged, reason: flagged ? (flaggedIn(f) ? 'Flagged in Jira' : `Status: ${status}`) : null, url: urlOf(x, key),
|
|
274
|
-
...typeParent(f.issuetype, f.parent), ...whoWhen(f.assignee, f.updated) };
|
|
283
|
+
...typeParent(f.issuetype, f.parent), ...whoWhen(f.assignee, f.updated), ...askedClosed(f.reporter, f.resolution) };
|
|
275
284
|
}
|
|
276
285
|
// The flat shape: what the skill tells the agent to write when it is unsure of the connector's shape.
|
|
277
286
|
const summary = clip(oneLine(x.summary || x.title), 250);
|
|
@@ -281,7 +290,7 @@ function normalizeIssue(x) {
|
|
|
281
290
|
return { key, summary, status, category: categoryOf(status, x.category), sprint: sprintOf(x.sprint), ...sprintsAll(x.sprints != null ? x.sprints : x.sprint), subtasks: subtasksOf(x.subtasks), ...subsOf(x.subtasks), fixVersion: fixVersionsOf(x.fixVersions != null ? x.fixVersions : x.fixVersion),
|
|
282
291
|
points: pointsIn(x), resolved: dayOf(x.resolved || x.resolutiondate),
|
|
283
292
|
flagged, reason: flagged ? clip(oneLine(x.reason || x.flag_reason || (x.flagged === true ? 'Flagged in Jira' : `Status: ${status}`)), 160) : null,
|
|
284
|
-
url: urlOf(x, key), ...typeParent(x.type != null ? x.type : x.issuetype, x.parent), ...whoWhen(x.assignee, x.updated) };
|
|
293
|
+
url: urlOf(x, key), ...typeParent(x.type != null ? x.type : x.issuetype, x.parent), ...whoWhen(x.assignee, x.updated), ...askedClosed(x.reporter, x.resolution) };
|
|
285
294
|
}
|
|
286
295
|
function normalize(raw) {
|
|
287
296
|
const list = issuesList(raw);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* live-events.js — a write made from the chat shows on every open page at once (bet A458, path-level live updates; job #1750).
|
|
3
|
+
*
|
|
4
|
+
* Before: a page drew a chat-made change only when the chat turn ended (cz:chat-turn), and then it read its whole lists again. A
|
|
5
|
+
* change that `pmos task …` made in the PM's terminal reached no open page until that read.
|
|
6
|
+
*
|
|
7
|
+
* Now `pmos task add|set|state|remove` appends one line per changed field to <state dir>/live-events.jsonl:
|
|
8
|
+
* { at, kind: 'task', id, field, value, undo } field is a live-edit field (state, due, start, owner, notes, section, parent,
|
|
9
|
+
* milestone), 'removed' for a deleted task, or 'added' for a new one
|
|
10
|
+
* (value: { initiative, title, status, owner, start, end, section?, parent? })
|
|
11
|
+
* The server streams new lines to every open page (lib/routes-live-rows.js, GET /api/live-rows), and the page puts each one on the rows it holds
|
|
12
|
+
* (public/pm/live-feed.js → live-edit.js remote()): one row changes, no list is read again.
|
|
13
|
+
*
|
|
14
|
+
* emit(stateDir, ev) append one event (several when ev is a list); never throws, a failed append only loses the live draw
|
|
15
|
+
* fieldEvents(id, body) the events of one task edit body ({ due, start, owner, notes, section, parent, milestone })
|
|
16
|
+
* read(file, from) { events, size } the events after byte offset from
|
|
17
|
+
* hub(dirsOf) { on(fn) → off, poll() } one shared watcher over the state dirs dirsOf() names, for every open page
|
|
18
|
+
*
|
|
19
|
+
* The file is local runtime state (pmos/state is not tracked), kept short: past MAX bytes the writer keeps the last KEEP lines that fit in half of MAX. */
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
const FILE = 'live-events.jsonl';
|
|
24
|
+
const MAX = 256 * 1024;
|
|
25
|
+
const KEEP = 200;
|
|
26
|
+
const EDIT_FIELDS = ['state', 'due', 'start', 'owner', 'notes', 'section', 'parent', 'milestone'];
|
|
27
|
+
|
|
28
|
+
function emit(stateDir, ev) {
|
|
29
|
+
if (!stateDir) return 0;
|
|
30
|
+
const list = (Array.isArray(ev) ? ev : [ev]).filter((e) => e && typeof e.id === 'string' && e.id && typeof e.field === 'string' && e.field);
|
|
31
|
+
if (!list.length) return 0;
|
|
32
|
+
const f = path.join(stateDir, FILE), at = new Date().toISOString();
|
|
33
|
+
try {
|
|
34
|
+
fs.appendFileSync(f, list.map((e) => JSON.stringify({ at, kind: e.kind || 'task', id: e.id, field: e.field, value: e.value === undefined ? null : e.value, undo: !!e.undo })).join('\n') + '\n');
|
|
35
|
+
const size = fs.statSync(f).size;
|
|
36
|
+
if (size > MAX) {
|
|
37
|
+
// the last KEEP lines, and no more than half of MAX, so the next cut is a while away
|
|
38
|
+
const all = fs.readFileSync(f, 'utf8').split('\n').filter(Boolean).slice(-KEEP), keep = [];
|
|
39
|
+
let bytes = 0;
|
|
40
|
+
for (let i = all.length - 1; i >= 0 && bytes + all[i].length + 1 <= MAX / 2; i--) { keep.unshift(all[i]); bytes += all[i].length + 1; }
|
|
41
|
+
fs.writeFileSync(f, keep.join('\n') + (keep.length ? '\n' : ''));
|
|
42
|
+
}
|
|
43
|
+
return list.length;
|
|
44
|
+
} catch { return 0; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function fieldEvents(id, body) {
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const k of EDIT_FIELDS) if (body && body[k] !== undefined && body[k] !== null) out.push({ kind: 'task', id, field: k, value: k === 'milestone' ? !!body[k] : body[k] });
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function read(file, from = 0) {
|
|
54
|
+
let size = 0;
|
|
55
|
+
try { size = fs.statSync(file).size; } catch { return { events: [], size: 0 }; }
|
|
56
|
+
// the writer cut the file short: read it from the start again
|
|
57
|
+
const start = size < from ? 0 : from;
|
|
58
|
+
if (size === start) return { events: [], size };
|
|
59
|
+
let text = '';
|
|
60
|
+
try {
|
|
61
|
+
const fd = fs.openSync(file, 'r');
|
|
62
|
+
try { const buf = Buffer.alloc(size - start); fs.readSync(fd, buf, 0, buf.length, start); text = buf.toString('utf8'); } finally { fs.closeSync(fd); }
|
|
63
|
+
} catch { return { events: [], size: from }; }
|
|
64
|
+
// a line still being written waits for the next poll
|
|
65
|
+
const end = text.lastIndexOf('\n');
|
|
66
|
+
if (end < 0) return { events: [], size: start };
|
|
67
|
+
const events = [];
|
|
68
|
+
for (const line of text.slice(0, end).split('\n')) { if (!line.trim()) continue; try { events.push(JSON.parse(line)); } catch { /* a torn line is skipped */ } }
|
|
69
|
+
return { events, size: start + Buffer.byteLength(text.slice(0, end + 1)) };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** One watcher for every open page: it starts at the files' current ends (a page that opens now reads its lists itself), polls every
|
|
73
|
+
* ms while a page listens, and stops when none does. */
|
|
74
|
+
function hub(dirsOf, { ms = 200 } = {}) {
|
|
75
|
+
const fns = new Set(), at = new Map();
|
|
76
|
+
let timer = null;
|
|
77
|
+
const files = () => { let d = []; try { d = dirsOf() || []; } catch { d = []; } return [...new Set(d.filter(Boolean))].map((x) => path.join(x, FILE)); };
|
|
78
|
+
const mark = () => { for (const f of files()) if (!at.has(f)) { let s = 0; try { s = fs.statSync(f).size; } catch { s = 0; } at.set(f, s); } };
|
|
79
|
+
function poll() {
|
|
80
|
+
for (const f of files()) {
|
|
81
|
+
// a workspace added while pages listen starts at its file's current end, like the others did
|
|
82
|
+
if (!at.has(f)) { let s = 0; try { s = fs.statSync(f).size; } catch { s = 0; } at.set(f, s); continue; }
|
|
83
|
+
const r = read(f, at.get(f));
|
|
84
|
+
at.set(f, r.size);
|
|
85
|
+
for (const e of r.events) for (const fn of fns) { try { fn(e); } catch { /* one page's failed send never stops the others */ } }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
on(fn) {
|
|
90
|
+
if (!fns.size) { at.clear(); mark(); timer = setInterval(poll, ms); if (timer.unref) timer.unref(); }
|
|
91
|
+
fns.add(fn);
|
|
92
|
+
return () => { fns.delete(fn); if (!fns.size && timer) { clearInterval(timer); timer = null; } };
|
|
93
|
+
},
|
|
94
|
+
poll,
|
|
95
|
+
listeners: () => fns.size,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { FILE, MAX, KEEP, EDIT_FIELDS, emit, fieldEvents, read, hub };
|
|
@@ -169,12 +169,18 @@ const VERBS = Object.freeze({
|
|
|
169
169
|
// Not a pm-os-absorb verb (run: null): initiative strategy-draft (Wawan 2026-11-24) added it through the same table.
|
|
170
170
|
strategy: Object.freeze({ module: 'strategy-cli.js', run: null, guide: 'cli.md',
|
|
171
171
|
help: 'pmos strategy show|sources|draft|set|undo — the product\'s five-line strategy; PMOS drafts blank lines from the product\'s files, each citing them (pmos strategy help)' }),
|
|
172
|
+
// Not a pm-os-absorb verb (run: null): initiative declined-asks-reply (bet A326) added it through the same table.
|
|
173
|
+
declined: Object.freeze({ module: 'declined-cli.js', run: null, guide: 'cli.md',
|
|
174
|
+
help: 'pmos declined list|draft|record — asks closed without being done, each with a kind reply draft PMOS never sends; record one in the out-of-scope list (pmos declined help)' }),
|
|
172
175
|
// Not a pm-os-absorb verb (run: null): initiative sprint-retro-one-change (bet A76) added it through the same table.
|
|
173
176
|
sprint: Object.freeze({ module: 'sprint-cli.js', run: null, guide: 'cli.md',
|
|
174
177
|
help: 'pmos sprint retro|change — a closed sprint\'s retro from PMOS\'s own close numbers, and its one tracked change (pmos sprint help)' }),
|
|
175
178
|
// Not a pm-os-absorb verb (run: null): initiative parked-reason-way-back (bet A446) added it through the same table.
|
|
176
179
|
parked: Object.freeze({ module: 'parked-cli.js', run: null, guide: 'cli.md',
|
|
177
180
|
help: 'pmos parked list|hold|back|coverage — parked initiatives: why each is parked, what brings it back, and bringing it back (pmos parked help)' }),
|
|
181
|
+
// Not a pm-os-absorb verb (run: null): initiative quiet-work-sweep (bet A503) added it through the same table.
|
|
182
|
+
quiet: Object.freeze({ module: 'quiet-cli.js', run: null, guide: 'cli.md',
|
|
183
|
+
help: 'pmos quiet list|keep|park|close|undo — the weekly sweep of initiatives quiet 30 days or more: keep, park or close each (pmos quiet help)' }),
|
|
178
184
|
// Not a pm-os-absorb verb (run: null): chief-unit-owners (Wawan 2026-11-18) added both through the same table.
|
|
179
185
|
units: Object.freeze({ module: 'units-cli.js', run: null, guide: 'cli.md',
|
|
180
186
|
help: 'pmos units [list|show <unit>] — the programs, products and projects, who owns each initiative, and each owner\'s brief (pmos units help)' }),
|
|
@@ -29,6 +29,7 @@ const RULE = [
|
|
|
29
29
|
'Run `pmos program help` when unsure. If a command refuses, say what it printed and what would let it through; never send the PM to Work for a change a command makes.',
|
|
30
30
|
'To see a program: press its name on Work, or open /premium-board.html?program=<id>.',
|
|
31
31
|
'You can read programs.jsonl to answer a question about a program. If the PM asks you to sort a turned program\'s tasks into program, initiative or epic, propose a level for each task in a list and let the PM decide.',
|
|
32
|
+
/* card-catalog:begin, generated by bin/card-catalog-gen.js: edit lib/card-catalog.json, not this block */"The card buttons run these pmos commands (the card catalog; who acts: you = one press with Undo, agent = PMOS starts a run, waits = only after the PM says yes). Run the one that fits the PM's ask, and tell the PM the Undo line it prints: pmos program check <id> <milestone> (Check a milestone; you); pmos program milestone <id> move <m> --date <date> (Move a milestone, Add a milestone, Rename a milestone, Drop a milestone; you); pmos program join <id> <initiative> (Add an initiative; you); pmos program leave <id> <initiative> (Take one out; you); pmos program charter <id> --goal <text> --why <text> (Set goal and why; you); pmos program capacity <team> <n> (Set team capacity; you); pmos program decide --team <team> --first <initiative> (Decide what goes first; you); pmos program order <id> <id,id,…> (Order its initiatives; you); pmos program archive <id> (Archive; you); pmos program task <id> \"<title>\" --key <key> (Add; you); pmos program task-done <id> <key> (Done; you); pmos units show <unit> (Open; you)."/* card-catalog:end */,
|
|
32
33
|
].join('\n');
|
|
33
34
|
|
|
34
35
|
/** The message as PMOS types it into the session: the rule, then the PM's words. */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* quiet-cli.js — `pmos quiet`: the weekly sweep of quiet work (initiative quiet-work-sweep, bet A503; lib/quiet-sweep.js).
|
|
3
|
+
*
|
|
4
|
+
* pmos quiet list [--json] the initiatives quiet 30 days or more, most quiet first, each with what PMOS suggests
|
|
5
|
+
* pmos quiet keep <id> still on: the sweep leaves it alone for 30 days
|
|
6
|
+
* pmos quiet park <id> [--why "<reason>"] park it (one on-hold line; the reason says how long it was quiet unless you give one)
|
|
7
|
+
* pmos quiet close <id> [--why "<reason>"] close it (one closed line)
|
|
8
|
+
* pmos quiet undo <id> undo the newest sweep answer of that initiative
|
|
9
|
+
* every command: [--root <dir>] (default: this repository)
|
|
10
|
+
*
|
|
11
|
+
* The chat's way to answer the same list Today shows; the agent runs keep, park and close only after the PM said so in the chat.
|
|
12
|
+
* Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { execFileSync } = require('child_process');
|
|
15
|
+
const Q = require('./quiet-sweep.js');
|
|
16
|
+
|
|
17
|
+
const COMMANDS = { quiet: ['list', 'keep', 'park', 'close', 'undo'] };
|
|
18
|
+
const USAGE = [
|
|
19
|
+
'usage: pmos quiet list|keep|park|close|undo — the weekly sweep of initiatives quiet 30 days or more',
|
|
20
|
+
' pmos quiet list [--json] the quiet initiatives, most quiet first, with what PMOS suggests',
|
|
21
|
+
' pmos quiet keep <id> still on: the sweep leaves it alone for 30 days',
|
|
22
|
+
' pmos quiet park <id> [--why "<reason>"] park it with a reason',
|
|
23
|
+
' pmos quiet close <id> [--why "<reason>"] close it',
|
|
24
|
+
' pmos quiet undo <id> undo the newest sweep answer of that initiative',
|
|
25
|
+
'Today shows the same list once a week. Run it in the product\'s repository, or pass --root <dir>.',
|
|
26
|
+
];
|
|
27
|
+
const ALLOWED = { list: ['json', 'root'], keep: ['json', 'root'], park: ['json', 'root', 'why'], close: ['json', 'root', 'why'], undo: ['json', 'root'] };
|
|
28
|
+
const BOOL = new Set(['json']);
|
|
29
|
+
const SAID = { keep: 'kept: the sweep leaves it alone for 30 days', park: 'parked', close: 'closed', undo: 'undone' };
|
|
30
|
+
|
|
31
|
+
function parse(args) {
|
|
32
|
+
const pos = [], flags = {};
|
|
33
|
+
for (let i = 0; i < args.length; i++) {
|
|
34
|
+
const a = args[i];
|
|
35
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
36
|
+
const k = a.slice(2);
|
|
37
|
+
if (BOOL.has(k)) flags[k] = true;
|
|
38
|
+
else flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
39
|
+
}
|
|
40
|
+
return { pos, flags };
|
|
41
|
+
}
|
|
42
|
+
function repoRoot(cwd) {
|
|
43
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now(), isTTY, sweep } = {}) {
|
|
47
|
+
const args = argv[0] === 'quiet' ? argv.slice(1) : argv.slice();
|
|
48
|
+
const sub = args[0];
|
|
49
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
50
|
+
if (!COMMANDS.quiet.includes(sub)) { say(`unknown quiet command "${sub}". Use one of: ${COMMANDS.quiet.join(', ')}`); return 2; }
|
|
51
|
+
const { pos, flags } = parse(args.slice(1));
|
|
52
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos quiet ${sub}`); return 2; }
|
|
53
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
54
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
55
|
+
|
|
56
|
+
if (sub === 'list') {
|
|
57
|
+
if (pos.length) return fail('pmos quiet list takes no argument', 2);
|
|
58
|
+
const s = (sweep || Q.sweepRoot)(root, { now });
|
|
59
|
+
if (!s.ok) return fail(s.error);
|
|
60
|
+
if (flags.json) { say(JSON.stringify(s)); return 0; }
|
|
61
|
+
if (!s.total) { say('Nothing is quiet 30 days or more.'); return 0; }
|
|
62
|
+
say(`${s.total} of ${s.live} live initiatives quiet ${Q.QUIET_DAYS} days or more`);
|
|
63
|
+
for (const it of s.items.slice(0, 50)) say(` ✦ ${it.suggest === 'close' ? 'Close' : 'Park'} · ${it.id} — ${it.title}\n ${it.why}`);
|
|
64
|
+
if (s.total > 50) say(` … ${s.total - 50} more`);
|
|
65
|
+
say('\nAnswer one: pmos quiet keep|park|close <id>');
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (pos.length !== 1) return fail(`usage: pmos quiet ${sub} <id>${sub === 'park' || sub === 'close' ? ' [--why "<reason>"]' : ''}`, 2);
|
|
70
|
+
const id = pos[0];
|
|
71
|
+
const a = require('./actor.js').fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env });
|
|
72
|
+
const opts = { now, by: a.by, via: a.via };
|
|
73
|
+
const r = sub === 'keep' ? Q.keep(root, { id }, opts) : sub === 'park' ? Q.park(root, { id, why: flags.why }, opts)
|
|
74
|
+
: sub === 'close' ? Q.close(root, { id, why: flags.why }, opts) : Q.undo(root, { id }, opts);
|
|
75
|
+
if (!r.ok) return fail(r.error);
|
|
76
|
+
if (flags.json) { say(JSON.stringify({ ok: true, file: r.file, line: r.line })); return 0; }
|
|
77
|
+
say(`${Q.TAG} ✓ ${id} ${SAID[sub]} (${r.file}). Undo: pmos quiet undo ${id}. Commit it to keep it.`);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = { run, COMMANDS, USAGE };
|