create-pmos 0.423.0 → 0.424.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 +13 -13
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/briefing-premium-products-test.js +16 -3
- package/workspace/changelog.json +12 -0
- package/workspace/guide/claude-proposes.md +37 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/home-pill-test.js +138 -0
- package/workspace/lib/headless.js +14 -1
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/proposal-runs.js +148 -0
- package/workspace/lib/proposals.js +370 -0
- package/workspace/lib/propose-cli.js +96 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-premium.js +11 -0
- package/workspace/lib/routes-boards.js +1 -1
- package/workspace/lib/routes-proposals.js +325 -0
- package/workspace/lib/routes-task-links.js +35 -28
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/public/pm/bd-asks.js +3 -0
- package/workspace/public/pm/cozy-today.css +23 -0
- package/workspace/public/pm/cozy-viewer.js +14 -3
- package/workspace/public/pm/cozy-vw-shell.css +8 -0
- package/workspace/public/pm/home-app.js +20 -6
- package/workspace/public/pm/home-task.js +2 -1
- package/workspace/public/pm/home-today.js +66 -16
- package/workspace/public/pm/ini-groups.js +30 -5
- package/workspace/public/pm/ini-links.js +6 -48
- package/workspace/public/pm/ini-props.js +218 -0
- package/workspace/public/pm/ini-view-model.js +6 -1
- package/workspace/public/pm/ini-view.css +47 -0
- package/workspace/public/pm/ini-view.js +23 -6
- package/workspace/public/pm/premium-vw-item.js +2 -1
- package/workspace/public/pm/task-card.css +13 -0
- package/workspace/public/pm/task-card.js +37 -2
- package/workspace/server.js +37 -2
- package/workspace/skills/initiative-propose.skill +45 -0
- package/workspace/stage-card-test.js +1 -1
- package/workspace/task-links-test.js +26 -14
- package/workspace/test-lists/claude-proposes.json +5 -0
- package/workspace/test-lists/home-sessions-pill.json +6 -0
- package/workspace/tk-tasks-test.js +13 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* proposals.js — everything Claude proposes on one initiative, under its one blue ✦ (feedback batch 12 items 2, 3 and 4; canvas In
|
|
3
|
+
* development, rows "Populate initiative" PiA1–PiA6 + devPiRules and "Task proposals" TpA1–TpA6 + devTpRules). THE ONE WRITER and THE ONE
|
|
4
|
+
* FOLD of <state>/proposals.jsonl, beside boards.jsonl and task-links.jsonl, and the pure engines that turn the tasks into proposals.
|
|
5
|
+
* lib/routes-proposals.js does the I/O; pm/ini-props.js draws the ✦ and the Viewer "Claude proposes N".
|
|
6
|
+
*
|
|
7
|
+
* ONE ✦ PER INITIATIVE (rule 13). Its count is every open proposal: what Claude found elsewhere when the initiative was added (item 4),
|
|
8
|
+
* new dates for late and at-risk tasks, "looks done" and tidy names (items 2+3), and the link proposals of lib/task-links.js (they keep their
|
|
9
|
+
* own store; the Viewer lists them as one more group). Nothing lands on the initiative before the PM's ✓.
|
|
10
|
+
*
|
|
11
|
+
* THE GROUPS, in the Viewer's order:
|
|
12
|
+
* found Found elsewhere: type stage (the stage the work is really in, with the dates past stages really ended), docs, tasks; then
|
|
13
|
+
* section 'check' (Check these: a maybe, with its reason; a duplicate already in another initiative, LINKED, never copied: they
|
|
14
|
+
* need their own ✓ and never ride on Keep all) and section 'unplaced' (Not placed: kept under Linked)
|
|
15
|
+
* dates one proposal per stage: its late and at-risk tasks to new dates and its plan with them, plus what a moved task's links reach
|
|
16
|
+
* status "looks done": the evidence says the work happened
|
|
17
|
+
* names tidy names, before → after; the detail cut moves to the task's notes
|
|
18
|
+
*
|
|
19
|
+
* THE LEDGER. One line per event, { at, by, kind, ... }:
|
|
20
|
+
* look { ini, board, run, why: 'populate' | 'check' } a run started looking (the live lines, PiA1)
|
|
21
|
+
* src { ini, run, source, state: 'reading' | 'done', n, what } one source's progress: "5 documents" or Reading…
|
|
22
|
+
* end { ini, run, ok, stopped? } the run ended (stopped: the PM pressed ■)
|
|
23
|
+
* propose { ini, board, run, id, group, type, section, title, why, sources: [{ label, ref }], items: [item], data }
|
|
24
|
+
* an agent filed it (`pmos propose …`); the last line for an id wins, so a newer run replaces what it files again
|
|
25
|
+
* drop { ini, sig } ✕ on a proposal or on one item of it: gone until its evidence changes (a new signature) or the date passes again
|
|
26
|
+
* keep { ini, board, batch, ids, wrote: [write] } ✓: what was written, each write with what it was before, for Undo and History
|
|
27
|
+
* undo { batch }
|
|
28
|
+
* epoch { } the first scan of lib/proposal-runs.js: only initiatives made after it are looked for
|
|
29
|
+
*
|
|
30
|
+
* A WRITE (in keep.wrote): { op, task?, title?, from?, to?, why, source?, ... } op ∈ add · dates · state · rename · notes · stage · ran ·
|
|
31
|
+
* doc · linked · epics · unlink · outbox · prd. The fold reads the kept doc, linked and ran writes as the initiative's own (they have no
|
|
32
|
+
* other store); every other op went through the board's own writer and is here for Undo and the task's History.
|
|
33
|
+
*
|
|
34
|
+
* ledgerFile(dir) · read(dir) → fold · readLines(file) · append(dir, actor, line)
|
|
35
|
+
* fold(lines) PURE → { props, drops, kept, undone, looks, t }
|
|
36
|
+
* clean(group, type, input) → { prop } | { error } what `pmos propose` checks
|
|
37
|
+
* sigOf(p) · itemSig(p, x)
|
|
38
|
+
* tidyName(from, to) → '' when `to` keeps the standard (rule 5), else the reason it does not
|
|
39
|
+
* datesOf(ini, T, o) PURE → the date proposals for one initiative (rule 1: late, or due within 3 days and not started)
|
|
40
|
+
* viewOf(F, ini, o) → what r.props carries (null: nothing to show)
|
|
41
|
+
* foundOf(F, ini) → { docs, linked, ran } the kept found items, as the initiative's own
|
|
42
|
+
* historyOf(F, uid) → [entry] Claude's approved changes to one task, newest first, each with its reason and source
|
|
43
|
+
* decorate(rows, F, items, o) puts r.props and r.found on each Board row that has something
|
|
44
|
+
*/
|
|
45
|
+
const fs = require('fs');
|
|
46
|
+
const path = require('path');
|
|
47
|
+
const crypto = require('crypto');
|
|
48
|
+
|
|
49
|
+
const LEDGER = 'proposals.jsonl';
|
|
50
|
+
const KINDS = new Set(['epoch', 'look', 'src', 'end', 'propose', 'drop', 'keep', 'undo']);
|
|
51
|
+
const GROUPS = ['found', 'dates', 'status', 'names'];
|
|
52
|
+
const TYPES = { found: ['stage', 'docs', 'tasks', 'link', 'maybe', 'unplaced'], dates: ['stage', 'task'], status: ['done'], names: ['tidy'] };
|
|
53
|
+
const SOURCES = ['drive', 'docs', 'sheets', 'slides', 'jira', 'calendar', 'notes', 'mail', 'slack', 'confluence', 'chat', 'repo'];
|
|
54
|
+
const SOURCE_NAMES = { drive: 'Drive and Slides', docs: 'Docs', sheets: 'Sheets', slides: 'Slides', jira: 'Jira', calendar: 'Calendar and meeting notes', notes: 'Meeting notes',
|
|
55
|
+
mail: 'Gmail', slack: 'Slack', confluence: 'Confluence', chat: 'Chat', repo: 'This repository' };
|
|
56
|
+
const CLOSED = new Set(['Done', "Won't do", 'Archived']);
|
|
57
|
+
const RISK_DAYS = 3;
|
|
58
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
59
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
60
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
61
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
62
|
+
const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 10);
|
|
63
|
+
const DAY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
64
|
+
const dn = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
65
|
+
const isoN = (n) => (n == null ? '' : new Date(n * 864e5).toISOString().slice(0, 10));
|
|
66
|
+
const md = (n) => { if (n == null) return ''; const d = new Date(n * 864e5); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); };
|
|
67
|
+
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
68
|
+
const newBatch = () => 'pk-' + crypto.randomBytes(5).toString('hex');
|
|
69
|
+
/** The next working day on or after n (a Saturday or Sunday moves to Monday). */
|
|
70
|
+
const workday = (n) => { const w = new Date(n * 864e5).getUTCDay(); return w === 6 ? n + 2 : w === 0 ? n + 1 : n; };
|
|
71
|
+
|
|
72
|
+
/* ── the ledger ── */
|
|
73
|
+
function ledgerFile(dir) { return dir ? path.join(dir, LEDGER) : null; }
|
|
74
|
+
function readLines(file) {
|
|
75
|
+
if (!file) return [];
|
|
76
|
+
let text = '';
|
|
77
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && KINDS.has(l.kind)) out.push(l); } catch { /* a torn line is skipped */ } }
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function read(dir) { return fold(readLines(ledgerFile(dir))); }
|
|
83
|
+
function append(dir, actor, ev) {
|
|
84
|
+
const line = { at: new Date().toISOString(), by: (actor && actor.by) || null, ...ev };
|
|
85
|
+
fs.appendFileSync(ledgerFile(dir), JSON.stringify(line) + '\n');
|
|
86
|
+
return line;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ── what an agent may file (`pmos propose`): every field short, every claim with its pointer ── */
|
|
90
|
+
const LIM = { title: 140, why: 300, label: 80, ref: 500, items: 120, notes: 400 };
|
|
91
|
+
function srcList(v) {
|
|
92
|
+
if (v == null) return { v: [] };
|
|
93
|
+
if (!Array.isArray(v) || v.length > 8) return { error: 'sources is a list of at most 8 { label, ref }' };
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const s of v) {
|
|
96
|
+
if (!isObj(s) || !str(s.label).trim()) return { error: 'each source has a label (and a ref: a link, a path or a Jira key)' };
|
|
97
|
+
out.push({ label: one(s.label, LIM.label), ...(str(s.ref) ? { ref: one(s.ref, LIM.ref) } : {}) });
|
|
98
|
+
}
|
|
99
|
+
return { v: out };
|
|
100
|
+
}
|
|
101
|
+
const dateOk = (v) => v == null || v === '' || DAY_RE.test(String(v));
|
|
102
|
+
function itemOf(group, type, x, i) {
|
|
103
|
+
if (!isObj(x)) return { error: `item ${i + 1} is an object` };
|
|
104
|
+
const o = { id: one(x.id || x.task || x.ref || x.title || String(i), 120) };
|
|
105
|
+
const t = (k, n) => { if (x[k] != null && x[k] !== '') o[k] = one(x[k], n); };
|
|
106
|
+
t('title', LIM.title); t('source', LIM.label); t('ref', LIM.ref); t('owner', 60); t('stage', 60); t('wbs', 20); t('why', LIM.why); t('notes', LIM.notes); t('kind', 20); t('jira', 40);
|
|
107
|
+
for (const k of ['at', 'start', 'due']) { if (x[k] == null || x[k] === '') continue; if (!dateOk(x[k])) return { error: `item ${i + 1}: ${k} is YYYY-MM-DD` }; o[k] = String(x[k]); }
|
|
108
|
+
if (x.other != null) { if (!isObj(x.other) || !str(x.other.ini)) return { error: `item ${i + 1}: other is { ini, title }` }; o.other = { ini: one(x.other.ini, 120), title: one(x.other.title || x.other.ini, LIM.title) }; }
|
|
109
|
+
if (group === 'dates' || group === 'status' || group === 'names') {
|
|
110
|
+
if (!str(x.task)) return { error: `item ${i + 1}: task names the task (its id or Jira key)` };
|
|
111
|
+
o.task = one(x.task, 120); o.id = o.task;
|
|
112
|
+
}
|
|
113
|
+
if (group === 'dates' && !(x.due || x.start)) return { error: `item ${i + 1}: a new date is start and/or due` };
|
|
114
|
+
if (group === 'names') { if (!str(x.to)) return { error: `item ${i + 1}: to is the new name` }; o.to = one(x.to, LIM.title); }
|
|
115
|
+
if (type === 'stage' && group === 'found') { if (!str(x.stage)) return { error: `item ${i + 1}: a past stage names its stage` }; }
|
|
116
|
+
if (type === 'tasks' && !o.title) return { error: `item ${i + 1}: a task has a title` };
|
|
117
|
+
if (type === 'docs' && !o.title) return { error: `item ${i + 1}: a document has a title` };
|
|
118
|
+
return { item: o };
|
|
119
|
+
}
|
|
120
|
+
/** → { prop } | { error }. input: { title, why, sources, items, section?, data? } */
|
|
121
|
+
function clean(group, type, input) {
|
|
122
|
+
if (!GROUPS.includes(group)) return { error: 'group is one of ' + GROUPS.join(', ') };
|
|
123
|
+
if (!(TYPES[group] || []).includes(type)) return { error: `type of ${group} is one of ${TYPES[group].join(', ')}` };
|
|
124
|
+
if (!isObj(input)) return { error: 'the proposal is a JSON object' };
|
|
125
|
+
const why = one(input.why, LIM.why);
|
|
126
|
+
if (!why) return { error: 'why is one line: what the evidence says' };
|
|
127
|
+
const s = srcList(input.sources); if (s.error) return s;
|
|
128
|
+
if (!s.v.length && !(group === 'dates' && input.noReason)) return { error: 'every proposal carries its source (sources: [{ label, ref }]): a claim without a pointer is not a proposal' };
|
|
129
|
+
const raw = Array.isArray(input.items) ? input.items : [];
|
|
130
|
+
if (raw.length > LIM.items) return { error: `at most ${LIM.items} items` };
|
|
131
|
+
const items = [];
|
|
132
|
+
for (const [i, x] of raw.entries()) { const r = itemOf(group, type, x, i); if (r.error) return r; items.push(r.item); }
|
|
133
|
+
if (!items.length && type !== 'stage') return { error: 'items is the list of what it proposes' };
|
|
134
|
+
if (group === 'names') for (const x of items) { const bad = tidyName(x.from || '', x.to); if (bad) return { error: `"${x.to}": ${bad}` }; }
|
|
135
|
+
const section = type === 'link' || type === 'maybe' ? 'check' : type === 'unplaced' ? 'unplaced' : 'sure';
|
|
136
|
+
const data = {};
|
|
137
|
+
if (group === 'found' && type === 'stage') {
|
|
138
|
+
if (!str(input.stage)) return { error: 'stage names the stage the work is in now' };
|
|
139
|
+
data.stage = one(input.stage, 60);
|
|
140
|
+
if (input.since != null) { if (!DAY_RE.test(String(input.since))) return { error: 'since is YYYY-MM-DD' }; data.since = String(input.since); }
|
|
141
|
+
}
|
|
142
|
+
if (group === 'dates' && str(input.stage)) data.stage = one(input.stage, 60);
|
|
143
|
+
return { prop: { group, type, section, title: one(input.title, LIM.title) || null, why, sources: s.v, items, data } };
|
|
144
|
+
}
|
|
145
|
+
/** The proposal's own id: one per initiative, group, type and key, so a newer run files over the older one. */
|
|
146
|
+
const idOf = (ini, group, type, key) => 'pr-' + hash([ini, group, type, key || ''].join('|'));
|
|
147
|
+
/** A proposal's signature: what it says and what it rests on. ✕ drops this; new evidence (a new signature) is proposed again. */
|
|
148
|
+
function sigOf(p) { return 's:' + hash([p.id, p.why, JSON.stringify((p.sources || []).map((s) => s.ref || s.label)), JSON.stringify((p.items || []).map((x) => [x.id, x.due, x.start, x.to]))].join('|')); }
|
|
149
|
+
function itemSig(p, x) { return 'i:' + hash([p.id, x.id || x.task || x.ref || x.title || '', x.due || '', x.start || '', JSON.stringify(x.to == null ? '' : x.to)].join('|')); }
|
|
150
|
+
|
|
151
|
+
/* ── rule 5: one standard for a task's name ── */
|
|
152
|
+
const WBS_RE = /^(\d+(?:\.\d+)*)\s+/;
|
|
153
|
+
/** '' when `to` keeps the standard, else the reason it does not. */
|
|
154
|
+
function tidyName(from, to) {
|
|
155
|
+
const s = String(to || '').trim();
|
|
156
|
+
if (!s) return 'a name is not empty';
|
|
157
|
+
if (/[+()[\]{}]/.test(s)) return 'no "+" and no brackets: the detail goes to the notes';
|
|
158
|
+
const w = WBS_RE.exec(from || ''), w2 = WBS_RE.exec(s);
|
|
159
|
+
if (w && (!w2 || w2[1] !== w[1])) return `keep the WBS number ${w[1]} first`;
|
|
160
|
+
const words = s.replace(WBS_RE, '').split(/\s+/).filter(Boolean);
|
|
161
|
+
if (words.length > 9) return 'at most about 7 words';
|
|
162
|
+
if (!/^[A-Z]/.test(words[0] || '')) return 'sentence case, verb first';
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* ── the fold ── */
|
|
167
|
+
function fold(lines) {
|
|
168
|
+
const props = new Map(); // id → the newest propose line
|
|
169
|
+
const drops = new Set(); // signatures
|
|
170
|
+
const kept = []; // keep lines, oldest first
|
|
171
|
+
const undone = new Set();
|
|
172
|
+
const looks = new Map(); // ini → { run, why, at, ended, ok, stopped, sources: Map source → { state, n, what } }
|
|
173
|
+
let t = '', epoch = '';
|
|
174
|
+
for (const l of lines || []) {
|
|
175
|
+
if (!isObj(l) || !KINDS.has(l.kind)) continue;
|
|
176
|
+
if (l.at && String(l.at) > t) t = String(l.at);
|
|
177
|
+
const ini = str(l.ini);
|
|
178
|
+
if (l.kind === 'epoch') { if (!epoch) epoch = str(l.at); }
|
|
179
|
+
else if (l.kind === 'look' && ini && str(l.run)) looks.set(ini, { run: l.run, why: str(l.why) || 'populate', at: l.at || '', board: str(l.board), ended: false, ok: null, stopped: false, sources: new Map() });
|
|
180
|
+
else if (l.kind === 'src' && ini) { const L = looks.get(ini); if (L && L.run === l.run && str(l.source)) L.sources.set(l.source, { state: l.state === 'done' ? 'done' : 'reading', n: Number(l.n) || 0, what: str(l.what) }); }
|
|
181
|
+
else if (l.kind === 'end' && ini) { const L = looks.get(ini); if (L && L.run === l.run) { L.ended = true; L.ok = !!l.ok; L.stopped = !!l.stopped; L.endAt = l.at || ''; } }
|
|
182
|
+
else if (l.kind === 'propose' && ini && str(l.id)) props.set(l.id, { id: l.id, ini, board: str(l.board), run: str(l.run), group: l.group, type: l.type, section: str(l.section) || 'sure', title: str(l.title), why: str(l.why), sources: Array.isArray(l.sources) ? l.sources : [], items: Array.isArray(l.items) ? l.items.filter(isObj) : [], data: isObj(l.data) ? l.data : {}, at: l.at || '', by: l.by || null });
|
|
183
|
+
else if (l.kind === 'drop' && str(l.sig)) drops.add(l.sig);
|
|
184
|
+
else if (l.kind === 'keep' && str(l.batch)) kept.push({ batch: l.batch, ini, board: str(l.board), ids: Array.isArray(l.ids) ? l.ids : [], wrote: Array.isArray(l.wrote) ? l.wrote.filter(isObj) : [], at: l.at || '', by: l.by || null });
|
|
185
|
+
else if (l.kind === 'undo' && str(l.batch)) undone.add(l.batch);
|
|
186
|
+
}
|
|
187
|
+
return { props, drops, kept, undone, looks, epoch, t };
|
|
188
|
+
}
|
|
189
|
+
/** The kept proposal ids (a batch undone gives its proposals back). */
|
|
190
|
+
const keptIds = (F) => { const s = new Set(); for (const k of F.kept) if (!F.undone.has(k.batch)) for (const id of k.ids) s.add(id); return s; };
|
|
191
|
+
/** What was kept that has no other store: the found documents, the Linked entries and the dates past stages ran. */
|
|
192
|
+
function foundOf(F, ini) {
|
|
193
|
+
const docs = [], linked = [], ran = {};
|
|
194
|
+
for (const k of F.kept) {
|
|
195
|
+
if (k.ini !== ini || F.undone.has(k.batch)) continue;
|
|
196
|
+
for (const w of k.wrote) {
|
|
197
|
+
if (w.op === 'doc') docs.push({ id: w.id, title: w.title, source: w.source || '', at: w.at || '', ref: w.ref || '', kind: w.kind || 'doc', ...(w.claude ? { claude: true } : {}) });
|
|
198
|
+
else if (w.op === 'linked') linked.push({ id: w.id, label: w.title, ref: w.ref || '', title: w.why || '' });
|
|
199
|
+
else if (w.op === 'ran' && str(w.stage)) ran[w.stage] = { from: w.from || null, to: w.to || null, source: w.source || '' };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
docs.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
203
|
+
return docs.length || linked.length || Object.keys(ran).length ? { docs, linked, ran } : null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* ── rule 1: late, or at risk (due within 3 days and not started) ── */
|
|
207
|
+
/** A task as the engines read it, from a work item (routes-boards itemsOf). */
|
|
208
|
+
function taskOf(x) {
|
|
209
|
+
const s = dn(x.start), e = dn(x.end != null ? x.end : x.due);
|
|
210
|
+
return { uid: x.uid || x.key, title: str(x.title), ini: str(x.ini), status: str(x.status) || 'To do', s: s == null ? e : s, e: e == null ? s : e, hasStart: s != null,
|
|
211
|
+
jira: x.src === 'jira' || !!x.jira, ms: !!x.milestone, closed: CLOSED.has(x.status), sec: str(x.section) || str(x.itemStage) || '', owner: str(x.owner), notes: str(x.notes), kind: str(x.kind) };
|
|
212
|
+
}
|
|
213
|
+
function lateOf(t, today) {
|
|
214
|
+
if (t.closed || t.e == null || t.kind === 'Epic') return '';
|
|
215
|
+
if (t.e < today) return 'late';
|
|
216
|
+
if (t.e - today <= RISK_DAYS && t.status === 'To do') return 'risk';
|
|
217
|
+
return '';
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* PURE. The date proposals for one initiative: one per stage, from the agent's reasons where it filed them, else Claude's own fallback
|
|
221
|
+
* ("No reason found", with the owner to ask). A Jira ticket is never moved: its proposal is a drafted comment.
|
|
222
|
+
* T Map uid → task (taskOf), this board's tasks
|
|
223
|
+
* o { today (day number), filed: [propose line of group dates], stages: [{ key, name }] (the initiative's workflow), links: approved
|
|
224
|
+
* task links [{ from, to, type, lag, source, why }], settle(T, links, opts) (lib/task-links.js), drops: Set }
|
|
225
|
+
* → [proposal] each { id, sig, group: 'dates', type: 'stage' | 'task', title, why, sources, noReason, items: [{ id, task, title, from, to,
|
|
226
|
+
* jira?, ms? }], plan?: { from, to, ms? }, links: [{ key, from, to, title, toTitle, type, rec, why, moves, clash? }], ask?: { owner } }
|
|
227
|
+
*/
|
|
228
|
+
function datesOf(ini, T, o = {}) {
|
|
229
|
+
const today = o.today, mine = [...T.values()].filter((t) => t.ini === ini);
|
|
230
|
+
// a ◇ milestone is a promise: Claude never proposes moving it (the plan says it stays); a task that waits on it asks instead
|
|
231
|
+
const due = mine.filter((t) => !t.ms && lateOf(t, today));
|
|
232
|
+
if (!due.length) return [];
|
|
233
|
+
const filed = (o.filed || []).filter((p) => p.ini === ini && p.group === 'dates');
|
|
234
|
+
const byTask = new Map();
|
|
235
|
+
for (const p of filed) for (const x of p.items) if (T.has(x.task)) byTask.set(x.task, { p, x });
|
|
236
|
+
const stName = (k) => { const s = (o.stages || []).find((x) => x.key === k || x.name === k); return s ? s.name : k || ''; };
|
|
237
|
+
const groups = new Map(); // stage key → [task]
|
|
238
|
+
for (const t of due) { const k = t.sec || ''; if (!groups.has(k)) groups.set(k, []); groups.get(k).push(t); }
|
|
239
|
+
const out = [];
|
|
240
|
+
for (const [k, ts] of groups) {
|
|
241
|
+
// the agent's proposal for these tasks leads: its reason and its dates; the rest get Claude's own
|
|
242
|
+
const lead = ts.map((t) => byTask.get(t.uid)).find(Boolean);
|
|
243
|
+
const items = [];
|
|
244
|
+
for (const t of ts) {
|
|
245
|
+
const f = byTask.get(t.uid);
|
|
246
|
+
let to;
|
|
247
|
+
if (f) to = { start: f.x.start || (t.hasStart ? isoN(t.s) : ''), due: f.x.due || isoN(t.e) };
|
|
248
|
+
else {
|
|
249
|
+
// no reason found: the length the task had, from today (the next working day), never earlier than tomorrow
|
|
250
|
+
const len = t.s != null && t.e != null ? Math.max(1, t.e - t.s) : 5;
|
|
251
|
+
const s1 = t.hasStart ? workday(today + 1) : null, e1 = s1 != null ? workday(s1 + len) : workday(today + Math.max(RISK_DAYS, len));
|
|
252
|
+
to = { start: s1 == null ? '' : isoN(s1), due: isoN(e1) };
|
|
253
|
+
}
|
|
254
|
+
items.push({ id: t.uid, task: t.uid, title: t.title, from: { start: t.hasStart ? isoN(t.s) : '', due: isoN(t.e) }, to, late: lateOf(t, today), ...(t.jira ? { jira: true } : {}), ...(t.ms ? { ms: true } : {}), ...(t.owner ? { owner: t.owner } : {}) });
|
|
255
|
+
}
|
|
256
|
+
const name = stName(k), newDue = items.map((x) => dn(x.to.due)).filter((n) => n != null), maxNew = newDue.length ? Math.max(...newDue) : null;
|
|
257
|
+
const span = (() => { const ns = [...new Set(newDue)].sort((a, b) => a - b); if (!ns.length) return ''; if (ns.length === 1) return md(ns[0]); const a = md(ns[0]), b = md(ns[ns.length - 1]); return a.split(' ')[0] === b.split(' ')[0] ? a + '–' + b.split(' ')[1] : a + ' – ' + b; })();
|
|
258
|
+
// the stage's plan is its latest due date; a ◇ milestone in the section is a promise, kept or left on its own
|
|
259
|
+
const sec = mine.filter((t) => (t.sec || '') === k && t.e != null), oldPlan = sec.length ? Math.max(...sec.map((t) => t.e)) : null;
|
|
260
|
+
const others = sec.filter((t) => !items.some((x) => x.task === t.uid)).map((t) => t.e);
|
|
261
|
+
const newPlan = maxNew == null ? null : Math.max(maxNew, ...(others.length ? others : [maxNew]));
|
|
262
|
+
const plan = oldPlan != null && newPlan != null && newPlan !== oldPlan ? { from: isoN(oldPlan), to: isoN(newPlan), ms: sec.some((t) => t.ms) } : null;
|
|
263
|
+
// rule 11: every new date checks the task links
|
|
264
|
+
const links = [];
|
|
265
|
+
if (o.settle && (o.links || []).length) {
|
|
266
|
+
const T2 = new Map(T);
|
|
267
|
+
for (const x of items) { if (x.jira) continue; const t = T.get(x.task); T2.set(x.task, { ...t, s: dn(x.to.start) != null ? dn(x.to.start) : t.s, e: dn(x.to.due) }); }
|
|
268
|
+
for (const l of o.links) {
|
|
269
|
+
if (!items.some((x) => x.task === l.from && !x.jira) || items.some((x) => x.task === l.to)) continue;
|
|
270
|
+
const b = T.get(l.to); if (!b || b.closed) continue;
|
|
271
|
+
const S = o.settle(T2, [l], { seeds: [l.from], today, ini, mode: 'own' });
|
|
272
|
+
const key = l.from + '>' + l.to, a = T.get(l.from);
|
|
273
|
+
if (S.moves.length) {
|
|
274
|
+
const m = S.moves[0];
|
|
275
|
+
links.push({ key, from: l.from, to: l.to, type: l.type, title: a.title, toTitle: b.title, rec: 'keep',
|
|
276
|
+
why: l.why ? l.why : 'it waits on ' + a.title.replace(WBS_RE, '') + (l.type === 'fs' ? ' finishing' : ''),
|
|
277
|
+
moves: [{ task: m.uid, title: b.title, from: { start: isoN(m.from.s), due: isoN(m.from.e) }, to: { start: isoN(m.to.s), due: isoN(m.to.e) } }] });
|
|
278
|
+
} else if (S.asks.length || S.clashes.length) {
|
|
279
|
+
const c = S.asks[0] || S.clashes[0], what = c.kind === 'jira' ? 'a Jira ticket' : c.why === 'milestone' ? 'a ◇ milestone' : c.why === 'other' ? 'in another initiative' : c.why === 'end' ? 'past the committed end' : 'done';
|
|
280
|
+
links.push({ key, from: l.from, to: l.to, type: l.type, title: a.title, toTitle: b.title, clash: true, rec: 'ignore', why: b.title + ' is ' + what + ' and is never moved: it will start before ' + a.title.replace(WBS_RE, '') + ' ends', moves: [] });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const id = idOf(ini, 'dates', 'stage', k || '(none)');
|
|
285
|
+
const noReason = !lead;
|
|
286
|
+
const owners = [...new Set(items.map((x) => x.owner).filter(Boolean))];
|
|
287
|
+
const p = { id, ini, group: 'dates', type: 'stage', section: 'sure', stage: k, items, plan, links, noReason,
|
|
288
|
+
title: (name ? name + ': ' : '') + plural(items.length, 'task', 'tasks') + ' to ' + span,
|
|
289
|
+
why: lead ? lead.p.why : 'No reason found: no notes, chat or Jira about ' + (items.length === 1 ? 'it' : 'them') + ' since ' + md(Math.min(...items.map((x) => dn(x.from.due)))) + '. ' + (span ? span + ' gives ' + (items.length === 1 ? 'it' : 'them') + ' the time ' + (items.length === 1 ? 'it' : 'they') + ' had.' : ''),
|
|
290
|
+
sources: lead ? lead.p.sources : [], ...(noReason && owners.length ? { ask: { owner: owners[0] } } : {}) };
|
|
291
|
+
p.sig = 'd:' + hash([id, ...items.map((x) => x.task + x.from.due)].join('|')); // rule 7: the date passing again is a new signature
|
|
292
|
+
if (o.drops && o.drops.has(p.sig)) continue;
|
|
293
|
+
p.items = p.items.filter((x) => !(o.drops && o.drops.has(itemSig(p, x))));
|
|
294
|
+
if (!p.items.length) continue;
|
|
295
|
+
out.push(p);
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* ── what r.props carries ── */
|
|
301
|
+
const ORDER = { found: 0, dates: 1, status: 2, names: 3, links: 4 };
|
|
302
|
+
/**
|
|
303
|
+
* One initiative's proposals, as the ✦ and the Viewer draw them, or null when there is nothing to show.
|
|
304
|
+
* o: { T (Map uid → task), today (iso), stages: [{ key, name }], links: approved task links, settle, linkProps: [task-links proposal] }
|
|
305
|
+
* → { n, sure, look: { run, why, at, ended, stopped, sources: [{ source, name, state, n, what }] } | null, groups: [{ group, props: [p] }], t }
|
|
306
|
+
*/
|
|
307
|
+
function viewOf(F, ini, o = {}) {
|
|
308
|
+
const today = dn(o.today), kept = keptIds(F), T = o.T || new Map();
|
|
309
|
+
const live = (p) => p.ini === ini && !kept.has(p.id) && !F.drops.has(p.sig);
|
|
310
|
+
const props = [];
|
|
311
|
+
for (const p0 of F.props.values()) {
|
|
312
|
+
if (p0.ini !== ini || p0.group === 'dates') continue;
|
|
313
|
+
const p = { ...p0, sig: sigOf(p0) };
|
|
314
|
+
if (!live(p)) continue;
|
|
315
|
+
// a task proposal for a task that is gone, closed, or (names, status) a Jira ticket is not drawn; an item dropped is left out
|
|
316
|
+
p.items = p.items.filter((x) => !F.drops.has(itemSig(p, x)) && (!x.task || (T.has(x.task) && !(p.group !== 'found' && T.get(x.task).closed && p.group !== 'status'))));
|
|
317
|
+
if (p.group === 'status') p.items = p.items.filter((x) => T.has(x.task) && !T.get(x.task).closed);
|
|
318
|
+
if (p.group === 'names') p.items = p.items.filter((x) => T.has(x.task) && T.get(x.task).title !== x.to).map((x) => ({ ...x, from: T.get(x.task).title, ...(T.get(x.task).jira ? { jira: true } : {}) }));
|
|
319
|
+
if (!p.items.length && p.type !== 'stage') continue;
|
|
320
|
+
props.push(p);
|
|
321
|
+
}
|
|
322
|
+
if (today != null) for (const p of datesOf(ini, T, { today, filed: [...F.props.values()].filter((x) => x.group === 'dates' && x.ini === ini), stages: o.stages, links: o.links, settle: o.settle, drops: F.drops })) if (!kept.has(p.id + ':' + p.sig)) props.push(p);
|
|
323
|
+
for (const lp of o.linkProps || []) props.push({ id: 'lk:' + lp.id, group: 'links', type: lp.kind, section: 'sure', link: lp, title: '', why: lp.why || '', sources: [], items: [] });
|
|
324
|
+
// ✕ on one item drops that item for good: the page sends its signature
|
|
325
|
+
for (const p of props) if (p.group !== 'links') p.items = p.items.map((x) => ({ ...x, sig: itemSig(p, x) }));
|
|
326
|
+
props.sort((a, b) => ORDER[a.group] - ORDER[b.group] || (a.section === 'sure' ? 0 : a.section === 'check' ? 1 : 2) - (b.section === 'sure' ? 0 : b.section === 'check' ? 1 : 2));
|
|
327
|
+
const L = F.looks.get(ini) || null;
|
|
328
|
+
const look = L && (!L.ended || L.why === 'populate') ? { run: L.run, why: L.why, at: L.at, ended: L.ended, stopped: L.stopped, ok: L.ok,
|
|
329
|
+
// zero is silence: a source that found nothing drops off
|
|
330
|
+
sources: [...L.sources].filter(([, s]) => s.state === 'reading' || s.n > 0).map(([k, s]) => ({ source: k, name: SOURCE_NAMES[k] || k, state: s.state, n: s.n, what: s.what })) } : null;
|
|
331
|
+
// the live look matters while it runs; once it ended it says nothing more (its finds are the proposals)
|
|
332
|
+
const looking = look && !look.ended ? look : null;
|
|
333
|
+
if (!props.length && !looking) return null;
|
|
334
|
+
const groups = [];
|
|
335
|
+
for (const p of props) { let g = groups.find((x) => x.group === p.group); if (!g) groups.push(g = { group: p.group, props: [] }); g.props.push(p); }
|
|
336
|
+
return { n: props.length, sure: props.filter((p) => p.section === 'sure').length, look: looking, groups, t: F.t };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Claude's approved changes to one task, newest first: { at, by: 'claude', field, from, to, why, source, batch, undone } (rule 10). */
|
|
340
|
+
function historyOf(F, uid) {
|
|
341
|
+
const out = [];
|
|
342
|
+
for (const k of F.kept) for (const w of k.wrote) {
|
|
343
|
+
if (w.task !== uid || !['add', 'dates', 'state', 'rename', 'notes'].includes(w.op)) continue;
|
|
344
|
+
out.push({ at: k.at, by: 'claude', approvedBy: k.by, field: w.op === 'dates' ? 'due' : w.op === 'state' ? 'status' : w.op === 'rename' ? 'name' : w.op, from: w.from == null ? null : w.from, to: w.to == null ? null : w.to, why: w.why || '', source: w.source || '', batch: k.batch, undone: F.undone.has(k.batch) });
|
|
345
|
+
}
|
|
346
|
+
return out.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** Each Board row's r.props and r.found. items: the board's work items. o: { today, links(ini) → approved links, linkProps(r) → [proposal], settle, stages(r) } */
|
|
350
|
+
function decorate(rows, F, items, o = {}) {
|
|
351
|
+
if (!F) return rows;
|
|
352
|
+
const T = new Map();
|
|
353
|
+
for (const w of items || []) { if (!w || !(w.uid || w.key)) continue; const t = taskOf(w); T.set(t.uid, t); }
|
|
354
|
+
for (const r of rows || []) {
|
|
355
|
+
if (!r || !r.id || r.props !== undefined) continue;
|
|
356
|
+
let v = null;
|
|
357
|
+
try {
|
|
358
|
+
v = viewOf(F, r.id, { T, today: o.today, stages: (r.wfStages || []).map((s) => ({ key: s.key, name: s.name })), links: o.links ? o.links(r.id) : [], settle: o.settle,
|
|
359
|
+
linkProps: r.links && Array.isArray(r.links.proposals) ? r.links.proposals : [] });
|
|
360
|
+
} catch { v = null; }
|
|
361
|
+
if (v) r.props = v;
|
|
362
|
+
const f = foundOf(F, r.id); if (f) r.found = f;
|
|
363
|
+
}
|
|
364
|
+
return rows;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
module.exports = {
|
|
368
|
+
LEDGER, GROUPS, TYPES, SOURCES, SOURCE_NAMES, RISK_DAYS, ledgerFile, read, readLines, append, fold, clean, idOf, sigOf, itemSig, tidyName, taskOf, lateOf,
|
|
369
|
+
datesOf, viewOf, foundOf, historyOf, decorate, keptIds, newBatch, dn, isoN, md, hash, workday,
|
|
370
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* propose-cli.js — `pmos propose`: the one write of Claude's proposal run (feedback batch 12 items 2, 3 and 4; lib/proposals.js,
|
|
3
|
+
* lib/proposal-runs.js). What it files waits under the initiative's blue ✦ until the PM's ✓.
|
|
4
|
+
*
|
|
5
|
+
* pmos propose look <source> --reading | --found <n> --what "<5 documents>" | --none
|
|
6
|
+
* one source's live line in the Viewer (PiA1): Reading…, then what it found; --none drops the line (zero is silence)
|
|
7
|
+
* pmos propose found <stage|docs|tasks|link|maybe|unplaced> --json <file|-> Found elsewhere
|
|
8
|
+
* pmos propose date --json <file|-> new dates for late or at-risk tasks, with the reason (one per stage)
|
|
9
|
+
* pmos propose done --json <file|-> "looks done": the evidence says the work happened
|
|
10
|
+
* pmos propose name --json <file|-> tidy names, before → after; the detail cut goes to the notes
|
|
11
|
+
* pmos propose status what is open, kept and dropped on this initiative (read)
|
|
12
|
+
*
|
|
13
|
+
* The server pins the initiative, the board, the run and the ledger in the run's environment (PMOS_PROPOSE_INI, _BOARD, _RUN, _FILE);
|
|
14
|
+
* outside such a run the verb refuses: the PM keeps and drops on the page. It writes `src` and `propose` lines only. A proposal the PM
|
|
15
|
+
* dropped from the same evidence answers `dropped`. Exit codes: 0 filed, 1 refused, 2 usage. Nothing is sent. */
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const PR = require('./proposals.js');
|
|
18
|
+
|
|
19
|
+
const COMMANDS = { propose: ['look', 'found', 'date', 'done', 'name', 'status'] };
|
|
20
|
+
const USAGE = [
|
|
21
|
+
'usage: pmos propose look|found|date|done|name|status — what Claude proposes on an initiative, under its ✦',
|
|
22
|
+
' pmos propose look <source> --reading | --found <n> --what "<5 documents>" | --none',
|
|
23
|
+
' source: ' + PR.SOURCES.join(', ') + '. Say --reading when you start a source and --found or --none when you finish it.',
|
|
24
|
+
' pmos propose found <stage|docs|tasks|link|maybe|unplaced> --json <file|->',
|
|
25
|
+
' { "key"?, "title", "why": "<one line>", "sources": [{ "label", "ref" }], "items": [...], "stage"? (stage), "since"? (stage) }',
|
|
26
|
+
' stage: the stage the work is in now, from evidence; items are the past stages { stage, start, due, source }. Never a made-up plan.',
|
|
27
|
+
' docs: { title, source, at, ref, kind }. tasks: { title, wbs?, stage, start?, due?, owner?, ref?, jira? (an epic key) }.',
|
|
28
|
+
' link: already in another initiative { title, ref, other: { ini, title } } (linked, never copied). maybe: { title, ref, why }.',
|
|
29
|
+
' unplaced: { title, ref } (kept under Linked).',
|
|
30
|
+
' pmos propose date --json <file|-> { "stage", "why", "sources", "items": [{ "task", "start"?, "due" }] }',
|
|
31
|
+
' pmos propose done --json <file|-> { "why", "sources", "items": [{ "task" }] }',
|
|
32
|
+
' pmos propose name --json <file|-> { "why", "sources", "items": [{ "task", "to", "notes"? }] } verb first, sentence case, about 7 words,',
|
|
33
|
+
' the WBS number kept, no "+" and no brackets; the cut detail goes in notes',
|
|
34
|
+
' pmos propose status',
|
|
35
|
+
'Every proposal carries its source. It waits for the PM\'s ✓ on the page. Nothing is sent.',
|
|
36
|
+
];
|
|
37
|
+
const GROUP = { found: 'found', date: 'dates', done: 'status', name: 'names' };
|
|
38
|
+
|
|
39
|
+
function readJson(src, stdin) {
|
|
40
|
+
let text;
|
|
41
|
+
try { text = src === '-' ? (stdin !== undefined ? String(stdin) : fs.readFileSync(0, 'utf8')) : fs.readFileSync(src, 'utf8'); } catch (e) { return { error: `could not read ${src}: ${String((e && e.message) || e).slice(0, 120)}` }; }
|
|
42
|
+
try { return { body: JSON.parse(text) }; } catch { return { error: 'the input is not JSON' }; }
|
|
43
|
+
}
|
|
44
|
+
const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
|
|
45
|
+
|
|
46
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, stdin } = {}) {
|
|
47
|
+
const args = argv[0] === 'propose' ? argv.slice(1) : argv.slice();
|
|
48
|
+
const verb = args[0];
|
|
49
|
+
if (!verb || verb === 'help' || verb === '--help' || verb === '-h') { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
50
|
+
if (!COMMANDS.propose.includes(verb)) { say(`unknown propose command "${verb}" — one of ${COMMANDS.propose.join(', ')}`); return 2; }
|
|
51
|
+
const file = env.PMOS_PROPOSE_FILE, runId = env.PMOS_PROPOSE_RUN, ini = env.PMOS_PROPOSE_INI, board = env.PMOS_PROPOSE_BOARD || '';
|
|
52
|
+
if (!file || !runId || !ini) { say('✗ pmos propose is for Claude\'s proposal run. The PM keeps and drops proposals on the page, under the initiative\'s ✦'); return 1; }
|
|
53
|
+
const F = PR.fold(PR.readLines(file));
|
|
54
|
+
const line = (ev) => { fs.appendFileSync(file, JSON.stringify({ at: new Date().toISOString(), by: null, ...ev }) + '\n'); };
|
|
55
|
+
|
|
56
|
+
if (verb === 'status') {
|
|
57
|
+
const mine = [...F.props.values()].filter((p) => p.ini === ini), kept = PR.keptIds(F);
|
|
58
|
+
if (!mine.length) say('nothing filed on ' + ini);
|
|
59
|
+
for (const p of mine) say(`${kept.has(p.id) ? 'kept ' : F.drops.has(PR.sigOf(p)) ? 'dropped' : 'open '} ${p.group}/${p.type} ${p.id} · ${p.title || ''} · ${p.why}`);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (verb === 'look') {
|
|
63
|
+
const source = args[1];
|
|
64
|
+
if (!PR.SOURCES.includes(source)) { say('✗ source is one of ' + PR.SOURCES.join(', ')); return 2; }
|
|
65
|
+
const L = F.looks.get(ini);
|
|
66
|
+
if (!L || L.run !== runId || L.ended) { say('✗ this run is not looking now (it ended, or the PM pressed Stop)'); return 1; }
|
|
67
|
+
if (flag(args, 'reading')) { line({ kind: 'src', ini, run: runId, source, state: 'reading', n: 0, what: '' }); say(`reading ${source}`); return 0; }
|
|
68
|
+
if (flag(args, 'none')) { line({ kind: 'src', ini, run: runId, source, state: 'done', n: 0, what: '' }); say(`${source}: nothing`); return 0; }
|
|
69
|
+
const n = Number(flag(args, 'found')), what = String(flag(args, 'what') || '').replace(/\s+/g, ' ').trim().slice(0, 60);
|
|
70
|
+
if (!Number.isInteger(n) || n < 0 || !what) { say('usage: pmos propose look <source> --found <n> --what "<5 documents>"'); return 2; }
|
|
71
|
+
line({ kind: 'src', ini, run: runId, source, state: 'done', n, what }); say(`${source}: ${what}`);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
const L = F.looks.get(ini);
|
|
75
|
+
if (L && L.run === runId && L.stopped) { say('✗ the PM pressed Stop: file nothing more'); return 1; }
|
|
76
|
+
const type = verb === 'found' ? args[1] : verb === 'date' ? 'stage' : verb === 'done' ? 'done' : 'tidy';
|
|
77
|
+
const jsonAt = args.indexOf('--json'), src = jsonAt >= 0 ? args[jsonAt + 1] : null;
|
|
78
|
+
if (!src) { say(`usage: pmos propose ${verb}${verb === 'found' ? ' <type>' : ''} --json <file|->`); return 2; }
|
|
79
|
+
const r = readJson(src, stdin); if (r.error) { say('✗ ' + r.error); return 1; }
|
|
80
|
+
const list = Array.isArray(r.body) ? r.body : [r.body];
|
|
81
|
+
let bad = 0;
|
|
82
|
+
for (const x of list) {
|
|
83
|
+
const c = PR.clean(GROUP[verb], type, x);
|
|
84
|
+
if (c.error) { say(`✗ refused: ${c.error}`); bad++; continue; }
|
|
85
|
+
const key = String((x && x.key) || (c.prop.group === 'dates' ? c.prop.data.stage || c.prop.items.map((i) => i.task).join(',') : c.prop.group === 'status' ? c.prop.items.map((i) => i.task).join(',') : c.prop.group === 'names' ? 'names' : type)).slice(0, 120);
|
|
86
|
+
const id = PR.idOf(ini, c.prop.group, type, key);
|
|
87
|
+
const prop = { id, ...c.prop };
|
|
88
|
+
if (F.drops.has(PR.sigOf(prop))) { say(`dropped ${id}: the PM dropped this from the same evidence`); continue; }
|
|
89
|
+
if (PR.keptIds(F).has(id)) { say(`kept ${id}: the PM kept it already; file new finds under a new key`); continue; }
|
|
90
|
+
line({ kind: 'propose', ini, board, run: runId, ...prop });
|
|
91
|
+
say(`filed ${id} · ${c.prop.group}/${type} · ${c.prop.items.length} ${c.prop.items.length === 1 ? 'item' : 'items'}`);
|
|
92
|
+
}
|
|
93
|
+
return bad ? 1 : 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -75,6 +75,7 @@ const MODULES = Object.freeze([
|
|
|
75
75
|
'routes-boards', // c3-initiative-boards: Portfolio, Board, Backlog, Triage asks, workflows and moves (boards.jsonl)
|
|
76
76
|
'routes-task-plans', // batch 11 item 8: drafts of an initiative's tasks, saved plans, Make live (task-plans.jsonl; page-press POST)
|
|
77
77
|
'routes-task-links', // batch 11 item 15: links between tasks, Claude's proposals, the quiet moves (task-links.jsonl; page-press POST)
|
|
78
|
+
'routes-proposals', // batch 12 items 2, 3 and 4: everything Claude proposes on an initiative, under its one ✦ (proposals.jsonl; page-press POST)
|
|
78
79
|
'routes-workflows', // workflows-per-initiative (D99): the workflow library, save, copy, archive and the chat's draft (workflows.jsonl; page-press POST)
|
|
79
80
|
'routes-settings', // console3 Settings: the settings store for settings with no home of their own (GET; page-press POST)
|
|
80
81
|
'routes-hooks', // planning-flows run 7: CLI hook endpoints (session token, per-run JSONL)
|
|
@@ -107,6 +107,17 @@ module.exports = {
|
|
|
107
107
|
for (const L of [model.rows, ...(model.stages || []).map((x) => x.rows)]) TaskLinks.decorate(L, F, items, { today: model.today || new Date().toISOString().slice(0, 10), src });
|
|
108
108
|
}
|
|
109
109
|
} catch { missing.push('task links'); }
|
|
110
|
+
// what Claude proposes (batch 12 items 2, 3 and 4): each row's one ✦ and what its ✓ kept from elsewhere (proposals.jsonl). After the links:
|
|
111
|
+
// the link proposals move into the same Viewer.
|
|
112
|
+
try {
|
|
113
|
+
const w = ctx.getWs ? ctx.getWs(pick.ws) : null, dir = w && ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
114
|
+
if (dir) {
|
|
115
|
+
const items = its && its.body && Array.isArray(its.body.items) ? its.body.items : [], TL = require('./task-links.js'), PR = require('./proposals.js');
|
|
116
|
+
const T = new Set(items.map((x) => x && x.uid).filter(Boolean)), approved = TL.linksOf(TL.read(dir)).filter((l) => T.has(l.from) && T.has(l.to));
|
|
117
|
+
const F = PR.read(dir), today = model.today || new Date().toISOString().slice(0, 10);
|
|
118
|
+
for (const L of [model.rows, ...(model.stages || []).map((x) => x.rows)]) PR.decorate(L, F, items.filter((x) => x && x.kind !== 'Epic'), { today, links: () => approved, settle: TL.settle });
|
|
119
|
+
}
|
|
120
|
+
} catch { missing.push('Claude\'s proposals'); }
|
|
110
121
|
// Claude's suggestion to split an initiative or merge two (batch 11 item 14): made from the tasks and tickets on every read, never a timer;
|
|
111
122
|
// the PM's ✕ Not now hides one until its tasks change. A failure here only leaves the suggestions out.
|
|
112
123
|
try {
|
|
@@ -1582,4 +1582,4 @@ function meetingBoards(ctx) {
|
|
|
1582
1582
|
return { list, detail };
|
|
1583
1583
|
}
|
|
1584
1584
|
|
|
1585
|
-
module.exports = { prefixes: ['/api/boards'], handle, postFrame, needRows, itemsOf, readLedger, foldOf, epicsOf, rowsOfBoard, invalidateRows: (w) => { rowsLib.invalidate(w.root); rowCache.delete(w.root); }, move, switchWorkflow, taskState, taskAdd, taskEdit, taskDelete, taskRestore, initiativeWorkflow, seedInitiative, stageTasks, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, taskSpanOf, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
1585
|
+
module.exports = { prefixes: ['/api/boards'], handle, postFrame, needRows, itemsOf, readLedger, foldOf, epicsOf, rowsOfBoard, invalidateRows: (w) => { rowsLib.invalidate(w.root); rowCache.delete(w.root); }, move, switchWorkflow, taskState, taskAdd, taskEdit, writeAs, taskDelete, taskRestore, initiativeWorkflow, seedInitiative, stageTasks, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, taskSpanOf, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|