create-pmos 0.421.0 → 0.422.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 +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/anchor-resolve.js +93 -15
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +59 -3
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/changelog.json +12 -0
- package/workspace/fixtures/report-api/draft.json +2 -1
- package/workspace/guide/briefing-premium.md +1 -0
- package/workspace/guide/home.md +5 -2
- package/workspace/guide/programs.md +4 -3
- package/workspace/home-other-product-test.js +55 -0
- package/workspace/lib/board-premium.js +18 -4
- package/workspace/lib/doc-live-root.js +37 -0
- package/workspace/lib/engine/anchor-resolve.js +93 -15
- package/workspace/lib/engine/boards.js +7 -2
- package/workspace/lib/engine/intake.js +1 -1
- package/workspace/lib/hold-spans.js +24 -10
- package/workspace/lib/kg.js +1 -1
- package/workspace/lib/report-draft.js +3 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-premium.js +6 -0
- package/workspace/lib/routes-boards.js +48 -9
- package/workspace/lib/routes-doc-sheet.js +29 -1
- package/workspace/lib/routes-programs.js +44 -5
- package/workspace/lib/routes-task-plans.js +333 -0
- package/workspace/lib/task-cli.js +16 -9
- package/workspace/lib/task-items.js +1 -1
- package/workspace/lib/task-plans.js +232 -0
- package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
- package/workspace/lib/vendor/scripts/intake.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-doc-test.js +26 -3
- package/workspace/program-leave-test.js +203 -0
- package/workspace/public/pm/bd-acts.js +5 -2
- package/workspace/public/pm/bd-ini-panel.js +20 -7
- package/workspace/public/pm/bd-prog-panel.js +22 -7
- package/workspace/public/pm/bd-span.js +175 -25
- package/workspace/public/pm/cozy-board.css +80 -0
- package/workspace/public/pm/cozy-home.css +3 -0
- package/workspace/public/pm/doc-follow.js +36 -0
- package/workspace/public/pm/home-app.js +38 -7
- package/workspace/public/pm/home-ini.js +11 -2
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-today.js +3 -1
- package/workspace/public/pm/ini-tasks.js +81 -16
- package/workspace/public/pm/ini-versions.js +343 -0
- package/workspace/public/pm/ini-view-model.js +27 -41
- package/workspace/public/pm/ini-view.css +82 -0
- package/workspace/public/pm/ini-view.js +17 -10
- package/workspace/public/pm/premium-board.js +109 -18
- package/workspace/public/pm/premium-report-read.js +20 -1
- package/workspace/public/pm/premium-shell.js +29 -4
- package/workspace/public/pm/premium-vw-doc.js +46 -11
- package/workspace/public/pm/prog-move.js +69 -0
- package/workspace/public/pm/task-card.css +3 -0
- package/workspace/public/pm/task-card.js +10 -3
- package/workspace/task-milestones-test.js +176 -0
- package/workspace/task-plans-test.js +175 -0
- package/workspace/task-views-test.js +2 -2
- package/workspace/test-lists/program-leave.json +6 -0
- package/workspace/test-lists/task-milestones.json +6 -0
- package/workspace/test-lists/task-plans.json +6 -0
- package/workspace/test-lists/viewer-live-file.json +9 -0
- package/workspace/timeline-holds-test.js +61 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* doc-live-root.js — which workspace holds the live copy of an initiative's document (feedback batch 11, item 1; PM, 2026-10-26: "When chat make update
|
|
3
|
+
* on the file that being shown on the current viewer, I should not need to refresh page. I should not need to manually commit as well").
|
|
4
|
+
* A chat about an initiative runs in that initiative's own git worktree on `initiative/<id>` (lib/start-policy.js), which spawnWithBranch registers as a
|
|
5
|
+
* workspace. Its edits are in that folder and not committed, so the Viewer reads the document there and not in the shared checkout.
|
|
6
|
+
*
|
|
7
|
+
* liveWs({ base, ini, rel, workspaces, worktreesOf, topOf, has }) -> the workspace to read, `base` when no other applies
|
|
8
|
+
* base the workspace the page asked for ({ id, root })
|
|
9
|
+
* ini the initiative id, or nothing
|
|
10
|
+
* rel the document's path inside the workspace
|
|
11
|
+
* workspaces the registered workspaces [{ id, root }]
|
|
12
|
+
* worktreesOf(top) -> [{ dir, branch }] git worktree list of the repository at `top`
|
|
13
|
+
* topOf(root) -> the repository's top folder, or null
|
|
14
|
+
* has(root, rel) -> true when the file is there
|
|
15
|
+
* Only a REGISTERED workspace is answered, so this never opens a folder the server does not already serve. A worktree that does not hold the file
|
|
16
|
+
* (the document was never on that branch) leaves the page on `base`. */
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
const INI_RX = /^[A-Za-z0-9][\w.-]{0,120}$/;
|
|
20
|
+
|
|
21
|
+
function liveWs({ base, ini, rel, workspaces = [], worktreesOf = () => [], topOf = () => null, has = () => false } = {}) {
|
|
22
|
+
if (!base || !base.root || !ini || !INI_RX.test(String(ini))) return base;
|
|
23
|
+
const top = topOf(base.root);
|
|
24
|
+
if (!top) return base;
|
|
25
|
+
let trees; try { trees = worktreesOf(top) || []; } catch { trees = []; }
|
|
26
|
+
const t = trees.find((x) => x && x.branch === 'initiative/' + ini);
|
|
27
|
+
if (!t || !t.dir) return base;
|
|
28
|
+
// a workspace registered at a subfolder of its repository lands in the same subfolder of the worktree (spawnWithBranch mirrors it)
|
|
29
|
+
const sub = path.relative(path.resolve(top), path.resolve(base.root));
|
|
30
|
+
const want = path.resolve(t.dir, sub.startsWith('..') ? '' : sub);
|
|
31
|
+
if (want === path.resolve(base.root)) return base;
|
|
32
|
+
const w = workspaces.find((x) => x && x.root && path.resolve(x.root) === want);
|
|
33
|
+
if (!w || (rel && !has(w.root, rel))) return base;
|
|
34
|
+
return w;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { liveWs };
|
|
@@ -73,20 +73,45 @@ const ACCEPTED_FORMS = [
|
|
|
73
73
|
* called `okrs` that every subsequent KR would then attach to. The shape is therefore pinned:
|
|
74
74
|
* an objective is `O` + digits, or `O-` + a word; a KR is `KR` + digits, or `KR-` + a word.
|
|
75
75
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
/*
|
|
77
|
+
* Batch 11 item 6 (2026-10-26): the OKR document as people write it. `## Objective 1 — title` is
|
|
78
|
+
* objective `o1`, the same objective as `## O1 — title`; and `KR1.2` (KR 2 of objective 1) is its own
|
|
79
|
+
* KR `kr1.2`. Before, the heading matched nothing — so no objective was read at all — and `KR1.2`
|
|
80
|
+
* matched as `KR1` with a name starting `.2`: a silent collapse of two KRs into one. The dotted part is
|
|
81
|
+
* digits only, and the token is followed by a lookahead, so `KR1.2` can never be read as `KR1`.
|
|
82
|
+
* `Objective` needs a number after it: `## Objectives` and the H1 `# OKRs — …` stay non-objectives.
|
|
83
|
+
*/
|
|
84
|
+
const OBJ_TOKEN = '(O\\d+|O-[A-Za-z][A-Za-z0-9-]*|[Oo]bjective\\s*\\d+)';
|
|
85
|
+
const KR_TOKEN = '(KR\\d+(?:\\.\\d+)*|KR-[A-Za-z][A-Za-z0-9-]*)';
|
|
86
|
+
const TOKEN_END = '(?![A-Za-z0-9]|\\.\\d)';
|
|
78
87
|
const PERIOD = '((?:q|Q)[1-4]-\\d{4})';
|
|
79
88
|
|
|
80
|
-
const RE_OBJ_HEADING = new RegExp('^#{1,3}\\s+' + OBJ_TOKEN + '
|
|
81
|
-
|
|
89
|
+
const RE_OBJ_HEADING = new RegExp('^#{1,3}\\s+(?:\\*\\*)?' + OBJ_TOKEN + TOKEN_END + '(?:\\*\\*)?\\s*(?:[—–:-]\\s*(.*))?$');
|
|
90
|
+
/* A KR bullet: `- **KR1 — name.** more`, `- **KR1.2** — name`, `- KR1.2: name`, `- KR-C — name`. The
|
|
91
|
+
* name is the bolded text when the bold wraps the id and the name, else the rest of the line. */
|
|
92
|
+
const RE_KR_BULLET = new RegExp('^\\s*[-*]\\s*(\\*\\*)?\\s*' + KR_TOKEN + TOKEN_END + '(.*)$');
|
|
93
|
+
|
|
94
|
+
function krBullet(line) {
|
|
95
|
+
const m = RE_KR_BULLET.exec(line);
|
|
96
|
+
if (!m) return null;
|
|
97
|
+
let rest = m[3];
|
|
98
|
+
const sep = /^\s*[—–:.-]?\s*/;
|
|
99
|
+
let name;
|
|
100
|
+
if (m[1] && /^\s*\*\*/.test(rest)) name = rest.replace(/^\s*\*\*/, '').replace(sep, ''); // **KR1.2** — name
|
|
101
|
+
else if (m[1]) { rest = rest.replace(sep, ''); const end = rest.indexOf('**'); name = end >= 0 ? rest.slice(0, end) : rest; }
|
|
102
|
+
else name = rest.replace(sep, '');
|
|
103
|
+
return { token: m[2], name: name.replace(/\*\*/g, '').trim() };
|
|
104
|
+
}
|
|
82
105
|
|
|
83
106
|
// Anchor forms. Order matters only in that the colon forms are tried before the looser ones.
|
|
84
107
|
const RE_HEALTH = /^health:([a-z0-9_-]+)/i; // START-anchored — rule 2
|
|
85
108
|
const RE_DOMAIN = /^domain:([a-z0-9][a-z0-9_-]*)/i; // D67 — the third anchor class
|
|
86
|
-
const RE_COLON_KR = new RegExp('^(?:okrs-)?' + PERIOD + ':([a-z0-9][a-z0-9-]*):(kr-?[a-z0-9-]+)$', 'i');
|
|
109
|
+
const RE_COLON_KR = new RegExp('^(?:okrs-)?' + PERIOD + ':([a-z0-9][a-z0-9-]*):(kr-?[a-z0-9-]+(?:\\.\\d+)*)$', 'i');
|
|
87
110
|
const RE_COLON_OBJ = new RegExp('^(?:okrs-)?' + PERIOD + ':([a-z0-9][a-z0-9-]*)$', 'i');
|
|
88
111
|
const RE_ARROW = new RegExp('^(?:okrs-)?' + PERIOD + '\\s*(?:→|->)\\s*' + OBJ_TOKEN + '(?:\\.' + KR_TOKEN + ')?$', 'i');
|
|
89
112
|
const RE_BARE = new RegExp('^' + OBJ_TOKEN + '(?:\\.' + KR_TOKEN + ')?$', 'i');
|
|
113
|
+
// A KR on its own (`KR1.2`, `KR3`): it names its objective only by being declared under exactly one.
|
|
114
|
+
const RE_BARE_KR = new RegExp('^' + KR_TOKEN + '$', 'i');
|
|
90
115
|
|
|
91
116
|
/** Strip markdown emphasis and trailing commentary. `(`, `#` and `/` never appear inside an id. */
|
|
92
117
|
function stripCommentary(raw) {
|
|
@@ -101,6 +126,8 @@ function stripCommentary(raw) {
|
|
|
101
126
|
* the heading token minus a leading `O-`, lower-cased. */
|
|
102
127
|
function objectiveId(token) {
|
|
103
128
|
const t = String(token || '').trim();
|
|
129
|
+
const n = /^objective\s*(\d+)$/i.exec(t);
|
|
130
|
+
if (n) return 'o' + n[1];
|
|
104
131
|
const m = /^O-(.+)$/i.exec(t);
|
|
105
132
|
return (m ? m[1] : t).toLowerCase();
|
|
106
133
|
}
|
|
@@ -110,6 +137,28 @@ function krId(token) {
|
|
|
110
137
|
return String(token || '').trim().toLowerCase();
|
|
111
138
|
}
|
|
112
139
|
|
|
140
|
+
/*
|
|
141
|
+
* The OKR period, in the order a reader would look for it: a `period:` line (front matter or body),
|
|
142
|
+
* then the H1 (`# OKRs — Q3 2026`), then the filename (`okrs-q3-2026.md`). Each accepts `2026-Q3`,
|
|
143
|
+
* `Q3 2026` and `q3-2026`. → `q3-2026` or null. Only the canonical form needs it; resolution does not.
|
|
144
|
+
*/
|
|
145
|
+
function periodOf(text) {
|
|
146
|
+
const s = String(text || '');
|
|
147
|
+
let m = /(\d{4})[\s_-]*(Q[1-4])(?![0-9])/i.exec(s);
|
|
148
|
+
if (m) return `${m[2].toLowerCase()}-${m[1]}`;
|
|
149
|
+
m = /(?<![A-Za-z])(Q[1-4])[\s_-]*(\d{4})(?![0-9])/i.exec(s);
|
|
150
|
+
return m ? `${m[1].toLowerCase()}-${m[2]}` : null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function filePeriod(text, file) {
|
|
154
|
+
const line = /^\s*[-*]?\s*\**period\**\s*:\s*(.+)$/im.exec(text);
|
|
155
|
+
if (line && periodOf(line[1])) return { period: periodOf(line[1]), from: 'period line' };
|
|
156
|
+
const h1 = /^#\s+(.+)$/m.exec(text);
|
|
157
|
+
if (h1 && periodOf(h1[1])) return { period: periodOf(h1[1]), from: 'title' };
|
|
158
|
+
const name = periodOf(path.basename(file, '.md'));
|
|
159
|
+
return name ? { period: name, from: 'file name' } : null;
|
|
160
|
+
}
|
|
161
|
+
|
|
113
162
|
function listOkrFiles(root) {
|
|
114
163
|
const out = [];
|
|
115
164
|
const seen = new Set();
|
|
@@ -150,41 +199,54 @@ function parseOkrIndex(root) {
|
|
|
150
199
|
const objectives = [];
|
|
151
200
|
const byId = new Map();
|
|
152
201
|
let period = null;
|
|
202
|
+
let periodFrom = null;
|
|
203
|
+
const noPeriod = [];
|
|
153
204
|
for (const file of files) {
|
|
154
205
|
let text;
|
|
155
206
|
try { text = fs.readFileSync(file, 'utf8'); }
|
|
156
207
|
catch (e) {
|
|
157
208
|
return { ok: false, objectives: [], files, error: `could not read ${file}: ${String((e && e.message) || e).slice(0, 120)}` };
|
|
158
209
|
}
|
|
210
|
+
const fp = filePeriod(text, file);
|
|
211
|
+
let declaresObjective = false;
|
|
159
212
|
let cur = null;
|
|
160
213
|
for (const line of text.split('\n')) {
|
|
161
|
-
if (!period) {
|
|
162
|
-
const p = /^\s*[-*]?\s*period\s*:\s*(\d{4})-(Q[1-4])\s*$/i.exec(line);
|
|
163
|
-
if (p) period = `${p[2].toLowerCase()}-${p[1]}`;
|
|
164
|
-
}
|
|
165
214
|
const o = RE_OBJ_HEADING.exec(line);
|
|
166
215
|
if (o) {
|
|
216
|
+
declaresObjective = true;
|
|
167
217
|
const id = objectiveId(o[1]);
|
|
168
218
|
cur = byId.get(id);
|
|
169
219
|
if (!cur) {
|
|
170
|
-
cur = { id, token: o[1], name: (o[2] || '').replace(/\*\*/g, '').trim(), krs: [], file: path.relative(root, file) };
|
|
220
|
+
cur = { id, token: o[1].replace(/\s+/g, ' '), name: (o[2] || '').replace(/\*\*/g, '').trim(), krs: [], file: path.relative(root, file), period: fp ? fp.period : null };
|
|
171
221
|
byId.set(id, cur);
|
|
172
222
|
objectives.push(cur);
|
|
173
223
|
}
|
|
174
224
|
continue;
|
|
175
225
|
}
|
|
176
|
-
const k =
|
|
226
|
+
const k = krBullet(line);
|
|
177
227
|
// A KR with no open objective stays UNATTACHED (rule 3) — never inherited from a previous one.
|
|
178
|
-
if (k && cur && !cur.krs.some((x) => x.id === krId(k
|
|
179
|
-
cur.krs.push({ id: krId(k
|
|
228
|
+
if (k && cur && !cur.krs.some((x) => x.id === krId(k.token))) {
|
|
229
|
+
cur.krs.push({ id: krId(k.token), token: k.token, name: k.name });
|
|
180
230
|
continue;
|
|
181
231
|
}
|
|
182
232
|
// the KR's own measure — its `baseline: … → target: …` sub-bullet (overhaul-r2 B4)
|
|
183
233
|
const bl = /^\s+[-*]\s*baseline\s*:\s*(.+)$/i.exec(line);
|
|
184
234
|
if (bl && cur && cur.krs.length && !cur.krs[cur.krs.length - 1].line) cur.krs[cur.krs.length - 1].line = bl[1].trim();
|
|
185
235
|
}
|
|
236
|
+
if (!declaresObjective) continue; // health-budgets.md, domains.md: not OKR documents, no period expected
|
|
237
|
+
if (fp && !period) { period = fp.period; periodFrom = `${fp.from} of ${path.relative(root, file)}`; }
|
|
238
|
+
if (!fp) noPeriod.push(path.relative(root, file));
|
|
239
|
+
}
|
|
240
|
+
const rels = files.map((f) => path.relative(root, f));
|
|
241
|
+
// What is missing, named with its fix, so a caller never has to guess why a field is empty.
|
|
242
|
+
const missing = [];
|
|
243
|
+
if (!objectives.length) {
|
|
244
|
+
missing.push(`no objective headings were read from ${rels.join(', ')} — write each objective as \`## O1 — title\` or \`## Objective 1 — title\``);
|
|
245
|
+
}
|
|
246
|
+
if (!period && objectives.length) {
|
|
247
|
+
missing.push(`no period found in ${noPeriod.join(', ') || rels.join(', ')} — add a line \`period: 2026-Q3\`, or put the quarter in the title (\`# OKRs — Q3 2026\`) or the file name (\`okrs-q3-2026.md\`)`);
|
|
186
248
|
}
|
|
187
|
-
return { ok: true, objectives, files:
|
|
249
|
+
return { ok: true, objectives, files: rels, period: period || null, period_from: periodFrom, missing, error: null };
|
|
188
250
|
}
|
|
189
251
|
|
|
190
252
|
function readBudgets(root) {
|
|
@@ -298,18 +360,34 @@ function resolveAnchor(raw, index, budgets) {
|
|
|
298
360
|
else if ((m = RE_COLON_OBJ.exec(s))) { period = m[1].toLowerCase(); objTok = m[2]; form = 'q3-2026:<objective>'; }
|
|
299
361
|
else if ((m = RE_ARROW.exec(s))) { period = m[1].toLowerCase(); objTok = m[2]; krTok = m[3] || null; form = 'legacy arrow'; }
|
|
300
362
|
else if ((m = RE_BARE.exec(s))) { objTok = m[1]; krTok = m[2] || null; form = 'legacy bare'; }
|
|
363
|
+
else if ((m = RE_BARE_KR.exec(s))) { krTok = m[1]; form = 'bare KR'; }
|
|
301
364
|
else {
|
|
302
365
|
return Object.assign(base, { kind: 'okr', status: 'unresolvable', form: 'unrecognised', reason: `'${s}' matches no accepted anchor form` });
|
|
303
366
|
}
|
|
304
367
|
|
|
305
368
|
const out = Object.assign({}, base, {
|
|
306
369
|
kind: 'okr', form, period,
|
|
307
|
-
objective: objectiveId(objTok),
|
|
370
|
+
objective: objTok ? objectiveId(objTok) : null,
|
|
308
371
|
kr: krTok ? krId(krTok) : null,
|
|
309
372
|
});
|
|
310
373
|
|
|
311
374
|
if (!index) return Object.assign(out, { status: 'unknown', reason: 'OKR index not supplied to the resolver' });
|
|
312
375
|
if (!index.ok) return Object.assign(out, { status: 'unknown', reason: index.error || 'OKR documents unreadable' });
|
|
376
|
+
if (!index.objectives.length) {
|
|
377
|
+
return Object.assign(out, { status: 'unresolvable', reason: (index.missing && index.missing[0]) || `no objectives declared in ${index.files.join(', ')}` });
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (!out.objective) {
|
|
381
|
+
// A bare KR: its objective is the one objective that declares it. Two objectives with the same KR
|
|
382
|
+
// id is ambiguous, and the reader is told how to write it — never a guess.
|
|
383
|
+
const holders = index.objectives.filter((o) => o.krs.some((k) => k.id === out.kr));
|
|
384
|
+
if (holders.length !== 1) {
|
|
385
|
+
return Object.assign(out, { status: 'unresolvable', reason: holders.length
|
|
386
|
+
? `KR '${out.kr}' is declared under ${holders.map((o) => o.id).join(' and ')} — write it with its objective, e.g. ${holders[0].token}.${krTok}`
|
|
387
|
+
: `no objective declares KR '${out.kr}' in ${index.files.join(', ')}` });
|
|
388
|
+
}
|
|
389
|
+
out.objective = holders[0].id;
|
|
390
|
+
}
|
|
313
391
|
|
|
314
392
|
const obj = index.objectives.find((o) => o.id === out.objective);
|
|
315
393
|
if (!obj) {
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
* task-section { task, section } a task's place in the breakdown (one view, feedback batch 6 item 1): the key
|
|
42
42
|
* of a stage of its initiative's workflow, '' for "Not in a stage". It is the task's place, never its state, and moving a task
|
|
43
43
|
* never moves the initiative. `task` is a Board task or a breakdown item; the last line wins.
|
|
44
|
+
* task-milestone { task, milestone } a task flagged as a milestone (feedback batch 11 item 3): its due
|
|
45
|
+
* date is the milestone's date and Done is its done. `task` is a Board task, a breakdown item or a Jira key; the last line wins.
|
|
44
46
|
* Nothing is deleted. A line that is not an object with a known kind is skipped.
|
|
45
47
|
*
|
|
46
48
|
* STAGE OF AN INITIATIVE on a team board: the last move recorded for it on that board (a workflow edit's `moved` and an
|
|
@@ -161,7 +163,7 @@ function foundOf(f) {
|
|
|
161
163
|
const sources = Array.isArray(f.sources) ? f.sources.filter((x) => x && typeof x.ref === 'string').slice(0, 8).map((x) => ({ label: String(x.label || ''), ref: x.ref })) : [];
|
|
162
164
|
return { why: typeof f.why === 'string' ? f.why : '', sources, match: typeof f.match === 'string' && f.match ? f.match : null, scan: typeof f.scan === 'string' ? f.scan : null, run: typeof f.run === 'string' ? f.run : null };
|
|
163
165
|
}
|
|
164
|
-
const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'task-remove', 'task-restore', 'ticket-note', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto', 'task-section']);
|
|
166
|
+
const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'task-remove', 'task-restore', 'ticket-note', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto', 'task-section', 'task-milestone']);
|
|
165
167
|
// A task's state is its only stage (Wawan, 2026-10-25): the same five every workflow ends in. An old 'In review' reads as In progress (taskState).
|
|
166
168
|
const TASK_STATES = Object.freeze(['To do', 'In progress', 'Done', "Won't do", 'Archived']);
|
|
167
169
|
const taskState = (s) => (s === 'In review' ? 'In progress' : TASK_STATES.includes(s) ? s : null);
|
|
@@ -191,6 +193,7 @@ function fold(events) {
|
|
|
191
193
|
const iniWorkflows = new Map(); // key(board, id) → { template, stages } (the initiative's own workflow)
|
|
192
194
|
const tasks = new Map(); // task id → { id, board, initiative, title, epic, owner, state, start, due, at, by, history }
|
|
193
195
|
const sections = new Map(); // task id → the stage key its breakdown section is ('' = Not in a stage); the last task-section line wins
|
|
196
|
+
const milestones = new Map(); // task id (or Jira key) → true | false: the PM's milestone flag; the last task-milestone line wins
|
|
194
197
|
const removed = new Map(); // task id → the task a task-remove took out, so a task-restore (Delete's Undo) puts it back
|
|
195
198
|
const ticketNotes = new Map(); // key(board, Jira key) → the PM's notes on that ticket (the last ticket-note line wins)
|
|
196
199
|
const epics = new Map(); // initiative id → the Jira epic keys the PM linked to it (the last ini-epics line wins)
|
|
@@ -275,6 +278,8 @@ function fold(events) {
|
|
|
275
278
|
t.history.push({ at: e.at || null, by: e.by || null, state: e.state || null, start: e.start || null, due: e.due || null, why: e.why || '' });
|
|
276
279
|
} else if (e.kind === 'task-section' && typeof e.task === 'string' && e.task && typeof e.section === 'string') {
|
|
277
280
|
sections.set(e.task, e.section);
|
|
281
|
+
} else if (e.kind === 'task-milestone' && typeof e.task === 'string' && e.task && typeof e.milestone === 'boolean') {
|
|
282
|
+
milestones.set(e.task, e.milestone);
|
|
278
283
|
} else if (e.kind === 'ticket-note' && b && typeof e.ref === 'string' && typeof e.notes === 'string') {
|
|
279
284
|
if (e.notes) ticketNotes.set(key(b, e.ref), e.notes); else ticketNotes.delete(key(b, e.ref));
|
|
280
285
|
} else if (e.kind === 'task-remove' && typeof e.task === 'string' && tasks.has(e.task)) {
|
|
@@ -321,7 +326,7 @@ function fold(events) {
|
|
|
321
326
|
Object.assign(a, { state: 'declined', why: e.why || '', closedAt: e.at || null });
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
|
-
return { boards, moves, assigns, asks, stages, iniWorkflows, tasks, sections, ticketNotes, epics, archives, notDup, iniWf, ends, judged, autoOver, events: list };
|
|
329
|
+
return { boards, moves, assigns, asks, stages, iniWorkflows, tasks, sections, milestones, ticketNotes, epics, archives, notDup, iniWf, ends, judged, autoOver, events: list };
|
|
325
330
|
}
|
|
326
331
|
|
|
327
332
|
/** The stages an initiative runs on a board: its own workflow when one is recorded, else the board's. */
|
|
@@ -57,7 +57,7 @@ function priorRejections(root, text) {
|
|
|
57
57
|
|
|
58
58
|
// anchor: only an explicit `health:<id>` or `KR<n>` typed in the line; the caller must still confirm it.
|
|
59
59
|
function suggestAnchor(line) {
|
|
60
|
-
const m = String(line || '').match(/\bhealth:[a-z0-9-]+\b/i) || String(line || '').match(/\bKR\d
|
|
60
|
+
const m = String(line || '').match(/\bhealth:[a-z0-9-]+\b/i) || String(line || '').match(/\bKR\d+(?:\.\d+)*\b/);
|
|
61
61
|
return m ? m[0] : null;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
//
|
|
5
5
|
// holdsOf(lines) → Map id → [{ from, to, back, reason }] every hold of every initiative, oldest first
|
|
6
6
|
// readHolds(file) → the same, read from a lifecycle.jsonl file ({} when it is missing)
|
|
7
|
-
// planGaps(spans, minDays) → [{ from, to }] the stretches of at least minDays (
|
|
7
|
+
// planGaps(spans, minDays) → [{ from, to, before?, after? }] the stretches of at least minDays (14) that no dated work covers
|
|
8
|
+
// stageSpans(spans) → [{ stage, start, due }] the first start and last due of the dated work in each stage
|
|
8
9
|
//
|
|
9
10
|
// No new record (XtiAGrill 1). A hold is the lifecycle lines PMOS already writes (D70): `on-hold` with `at` and an optional `back`
|
|
10
11
|
// (YYYY-MM-DD), and `active`, `closed` or `cancelled` after it. The latest line still decides the state (scripts/workflow-state.js
|
|
@@ -14,7 +15,8 @@
|
|
|
14
15
|
// - `active`, `closed` or `cancelled` ends the open hold on the day of its `at`. `to` stays null while the hold is open.
|
|
15
16
|
// - A line with no readable day is left out: a hold cannot be drawn without its start.
|
|
16
17
|
// planGaps reads the dated work-items and tasks as { start, due }: a gap is a stretch inside them that none covers, of minDays or more
|
|
17
|
-
// (XtiAGrill 13). It is "nothing planned", never a hold, so it carries no reason.
|
|
18
|
+
// (XtiAGrill 13). It is "nothing planned", never a hold, so it carries no reason. Batch 11 item 13 (XgapAGrill): 2 weeks, not 4, and a gap names
|
|
19
|
+
// the stage of the work on each side (`before`, `after`) when that work has one, so a skipped stage between them can be marked » on it.
|
|
18
20
|
const fs = require('fs');
|
|
19
21
|
|
|
20
22
|
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -48,17 +50,29 @@ function readHolds(file) {
|
|
|
48
50
|
return holdsOf(lines);
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
const datedOf = (spans) => (Array.isArray(spans) ? spans : []).map((s) => [dayOf(s && s.start), dayOf(s && (s.due || s.end)), (s && s.stage) || null])
|
|
54
|
+
.map(([a, b, k]) => [a || b, b || a, k]).filter(([a]) => a).sort((x, y) => (x[0] < y[0] ? -1 : x[0] > y[0] ? 1 : 0));
|
|
55
|
+
|
|
51
56
|
function planGaps(spans, minDays) {
|
|
52
|
-
const min = Number.isFinite(minDays) ? minDays :
|
|
53
|
-
const list = (Array.isArray(spans) ? spans : []).map((s) => [dayOf(s && s.start), dayOf(s && (s.due || s.end))])
|
|
54
|
-
.map(([a, b]) => [a || b, b || a]).filter(([a]) => a).sort((x, y) => (x[0] < y[0] ? -1 : x[0] > y[0] ? 1 : 0));
|
|
57
|
+
const min = Number.isFinite(minDays) ? minDays : 14;
|
|
55
58
|
const out = [];
|
|
56
|
-
let end = null;
|
|
57
|
-
for (const [a, b] of
|
|
58
|
-
if (end && dayNum(a) - dayNum(end) >= min) out.push({ from: end, to: a });
|
|
59
|
-
if (!end || b > end) end = b;
|
|
59
|
+
let end = null, endStage = null;
|
|
60
|
+
for (const [a, b, k] of datedOf(spans)) {
|
|
61
|
+
if (end && dayNum(a) - dayNum(end) >= min) out.push({ from: end, to: a, ...(endStage ? { before: endStage } : {}), ...(k ? { after: k } : {}) });
|
|
62
|
+
if (!end || b > end) { end = b; endStage = k; }
|
|
60
63
|
}
|
|
61
64
|
return out;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
function stageSpans(spans) {
|
|
68
|
+
const by = new Map();
|
|
69
|
+
for (const [a, b, k] of datedOf(spans)) {
|
|
70
|
+
if (!k) continue;
|
|
71
|
+
const x = by.get(k);
|
|
72
|
+
if (!x) by.set(k, { stage: k, start: a, due: b });
|
|
73
|
+
else if (b > x.due) x.due = b;
|
|
74
|
+
}
|
|
75
|
+
return [...by.values()];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = { holdsOf, readHolds, planGaps, stageSpans };
|
package/workspace/lib/kg.js
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
const adrFor = new Map();
|
|
105
105
|
for (const p of have) { const m = /^okf\/products\/pmos\/adr\/d(\d{2,3})-/.exec(p); if (m) adrFor.set('D' + m[1], p); }
|
|
106
106
|
const krFile = new Map();
|
|
107
|
-
for (const f of list) if (f.path.startsWith('planning/okrs/')) for (const m of f.text.matchAll(/\bO\d+\.KR\d
|
|
107
|
+
for (const f of list) if (f.path.startsWith('planning/okrs/')) for (const m of f.text.matchAll(/\bO\d+\.KR\d+(?:\.\d+)*\b/g)) if (!krFile.has(m[0])) krFile.set(m[0], f.path);
|
|
108
108
|
const budgets = have.has('planning/okrs/health-budgets.md') ? 'planning/okrs/health-budgets.md' : null;
|
|
109
109
|
|
|
110
110
|
const named = DC ? DC.namedFromRecords(list.filter((f) => /(^|\/)initiatives\//.test(f.path)).map((f) => ({ rel: f.path, fm: readFm ? readFm(f.text) : {} }))) : new Map();
|
|
@@ -372,6 +372,8 @@ function draftOf(root, { cadence, slot, now, health } = {}) {
|
|
|
372
372
|
milestones: [...new Set(spans.filter((s) => s.milestone).map((s) => s.due))].sort(),
|
|
373
373
|
holds: (() => { const all = itemSpans.initiativeSpan(spans);
|
|
374
374
|
return (holdsBy.get(b.id) || []).filter((h) => !h.to || !all || (h.to > all.start && h.from < all.due)).map((h) => ({ from: h.from, to: h.to, back: h.back, reason: h.reason })); })(),
|
|
375
|
+
// a stretch of 2 weeks or more with no dated item: "No activity" on the strip, as on the Board (batch 11 item 13); not pressable
|
|
376
|
+
gaps: holdSpans.planGaps(spans, 14).map((g) => ({ from: g.from, to: g.to })),
|
|
375
377
|
});
|
|
376
378
|
}
|
|
377
379
|
|
|
@@ -526,6 +528,7 @@ function render(draft, { notes } = {}) {
|
|
|
526
528
|
for (const r of draft.timeline.rows) {
|
|
527
529
|
r.spans.forEach((s, i) => push(`| ${i ? '' : esc(r.title)} | ${esc(s.stage || '-')} | ${s.start || '-'} | ${s.due || '-'} | ${i ? '' : (r.milestones.map(short).join(', ') || '-')} |`));
|
|
528
530
|
for (const h of r.holds || []) push(`| | On hold${h.reason ? ': ' + esc(h.reason) : ''} | ${h.from} | ${h.to || (h.back ? h.back + ' (return date)' : 'no return date')} | |`);
|
|
531
|
+
for (const g of r.gaps || []) push(`| | No activity | ${g.from} | ${g.to} | |`);
|
|
529
532
|
}
|
|
530
533
|
} else push('No initiative in this report has dated items.');
|
|
531
534
|
push('');
|
|
@@ -73,6 +73,7 @@ const MODULES = Object.freeze([
|
|
|
73
73
|
'routes-c3-reports', // console3 Reports dashboards: library, per-scope data, page-press layouts (layouts are the only write)
|
|
74
74
|
'routes-onboarding', // onboarding-scan-and-map slice 2: first run (scan read-only, structure, import into the overlay, undo, first Briefing)
|
|
75
75
|
'routes-boards', // c3-initiative-boards: Portfolio, Board, Backlog, Triage asks, workflows and moves (boards.jsonl)
|
|
76
|
+
'routes-task-plans', // batch 11 item 8: drafts of an initiative's tasks, saved plans, Make live (task-plans.jsonl; page-press POST)
|
|
76
77
|
'routes-workflows', // workflows-per-initiative (D99): the workflow library, save, copy, archive and the chat's draft (workflows.jsonl; page-press POST)
|
|
77
78
|
'routes-settings', // console3 Settings: the settings store for settings with no home of their own (GET; page-press POST)
|
|
78
79
|
'routes-hooks', // planning-flows run 7: CLI hook endpoints (session token, per-run JSONL)
|
|
@@ -16,6 +16,7 @@ const Custom = require('./custom-docs.js');
|
|
|
16
16
|
const path = require('path');
|
|
17
17
|
const fs = require('fs');
|
|
18
18
|
const Metrics = require('./board-metrics-premium.js');
|
|
19
|
+
const TaskPlans = require('./task-plans.js');
|
|
19
20
|
const { ENGINE_PATHS } = require('./console-state.js');
|
|
20
21
|
|
|
21
22
|
/** GET `pathAndQuery` from a route module's own handler, as the Work page's route does, and return { status, body }. */
|
|
@@ -90,6 +91,11 @@ module.exports = {
|
|
|
90
91
|
rows: listOf(rk, nw), columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] }, docs: d, custom,
|
|
91
92
|
items: its && its.body && its.body.ok !== false && Array.isArray(its.body.items) ? its.body.items : [], held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
|
|
92
93
|
});
|
|
94
|
+
// planned versus actual (batch 11 item 8): each row's drafts and saved plans, from task-plans.jsonl
|
|
95
|
+
try {
|
|
96
|
+
const w = ctx.getWs ? ctx.getWs(pick.ws) : null, dir = w && ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
97
|
+
if (dir) { const F = TaskPlans.read(dir); for (const L of [model.rows, ...(model.stages || []).map((x) => x.rows), model.cancelled, model.archived]) TaskPlans.decorate(L, F); }
|
|
98
|
+
} catch { missing.push('saved plans'); }
|
|
93
99
|
// a press re-derives the rows in the background; while the answer is stale the page asks again (initiative premium-board-actions)
|
|
94
100
|
let stale = false;
|
|
95
101
|
try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; const pk = w ? Rows.peek(w.root) : null; stale = !!(pk && (pk.pending || pk.stale)); } catch { stale = false; }
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
* POST /api/boards/tasks/reschedule { ws, board, task, days } → { ok, item }
|
|
30
30
|
* POST /api/boards/tasks/undo-add { ws, board, task } → { ok } takes back a task added in the last 2 minutes, still To do
|
|
31
31
|
* POST /api/boards/tasks/rename { ws, board, task, title } → { ok, from, item } only the title changes
|
|
32
|
-
* POST /api/boards/tasks/edit { ws, board, task, owner?, notes?, start?, due?, initiative?, section? } → { ok, from, item } the Viewer's edits in place
|
|
32
|
+
* POST /api/boards/tasks/edit { ws, board, task, owner?, notes?, start?, due?, initiative?, section?, milestone? } → { ok, from, item } the Viewer's edits in place
|
|
33
|
+
* (milestone: true | false, the ◇ flag of batch 11 item 3; a Jira key takes the flag only)
|
|
33
34
|
* (section: the task's place in the breakdown, a stage key of its initiative's workflow or '' — a task-section line)
|
|
34
35
|
* (canvas XetX1Rest); `from` holds the fields as they were, so Undo is the same call with `from`
|
|
35
36
|
* POST /api/boards/tickets/note { ws, board, ref, notes } → { ok, from, notes } the PM's notes on a Jira ticket
|
|
@@ -281,7 +282,7 @@ function baseRows(w) {
|
|
|
281
282
|
stopped: rec.stopped ? { reason: rec.stopped.reason || '', at: rec.stopped.at || null, back: rec.stopped.back || null } : null,
|
|
282
283
|
hasSpec, record: relRec || null, domainFolder: dm ? dm[1] : null,
|
|
283
284
|
recordEpic: jiraTickets.anchorOf(fm),
|
|
284
|
-
holds: holds.get(id) || [], workSpans: work.map((x) => ({ start: x.start, due: x.due })),
|
|
285
|
+
holds: holds.get(id) || [], workSpans: work.map((x) => ({ start: x.start, due: x.due, stage: x.stage || null })),
|
|
285
286
|
});
|
|
286
287
|
}
|
|
287
288
|
rowCache.set(w.root, { key: cacheKey, rows });
|
|
@@ -349,16 +350,19 @@ function taskSpanOf(folded, id) {
|
|
|
349
350
|
}
|
|
350
351
|
return start ? { start, end } : null;
|
|
351
352
|
}
|
|
352
|
-
/** Each dated task of an initiative as { start, due } (Won't do and Archived left out).
|
|
353
|
+
/** Each dated task of an initiative as { start, due, stage } (Won't do and Archived left out). stage: the PM's placement (a task-section line),
|
|
354
|
+
* else the stage whose To finish entry made it, else null. */
|
|
353
355
|
function taskSpansOf(folded, id) {
|
|
354
|
-
const out = [];
|
|
356
|
+
const out = [], SEC = (folded && folded.sections) || new Map();
|
|
355
357
|
for (const t of (folded && folded.tasks ? folded.tasks.values() : [])) {
|
|
356
358
|
if (!t || t.initiative !== id || t.state === "Won't do" || t.state === 'Archived') continue;
|
|
357
359
|
const a = t.start || t.due, z = t.due || t.start;
|
|
358
|
-
|
|
360
|
+
const stage = SEC.has(t.id) ? SEC.get(t.id) || null : (t.from && t.from.stage) || null;
|
|
361
|
+
if (a) out.push({ start: String(a).slice(0, 10), due: String(z).slice(0, 10), stage });
|
|
359
362
|
}
|
|
360
363
|
return out;
|
|
361
364
|
}
|
|
365
|
+
const gapFields = (spans) => ({ gaps: holdSpans.planGaps(spans, 14), stageSpans: holdSpans.stageSpans(spans) });
|
|
362
366
|
const minDay = (a, b) => (!a ? b || null : !b ? a : a < b ? a : b);
|
|
363
367
|
const maxDay = (a, b) => (!a ? b || null : !b ? a : a > b ? a : b);
|
|
364
368
|
|
|
@@ -372,8 +376,9 @@ function boardRow(board, base, folded, lib) {
|
|
|
372
376
|
horizon: base.horizon, status: base.status, start: ts ? minDay(base.start, ts.start) : base.start, end: ts ? maxDay(base.end, ts.end) : base.end, progress: base.progress, warnings: [],
|
|
373
377
|
rank: base.rank, health: B.isActive(base) ? base.health : null, updated: base.updated, reading: base.reading, stageSource: s.source, lifecycle: base.lifecycle,
|
|
374
378
|
stopped: base.stopped || null, archived: archivedOf(folded, base.id),
|
|
375
|
-
// feedback batch 9 item 8: every hold of the initiative, and the stretches of
|
|
376
|
-
|
|
379
|
+
// feedback batch 9 item 8: every hold of the initiative, and the stretches of 2 weeks or more that no dated work-item or task covers (batch 11
|
|
380
|
+
// item 13); stageSpans: where the dated work of each stage runs, so a skipped stage between two of them is marked » (XgapAGrill)
|
|
381
|
+
holds: base.holds || [], ...gapFields((base.workSpans || []).concat(taskSpansOf(folded, base.id))),
|
|
377
382
|
template: B.templateOf(board, base.id, folded), workflow: wf.map((x) => ({ name: x.name, cat: x.cat })),
|
|
378
383
|
...epicsOf(base, folded),
|
|
379
384
|
};
|
|
@@ -533,6 +538,9 @@ function itemsOf(w, fr, board, rows) {
|
|
|
533
538
|
// a task's place in the breakdown (one view): the PM's own choice, else the stage whose To finish entry made it
|
|
534
539
|
const SEC = fr.folded.sections || new Map();
|
|
535
540
|
for (const x of out) if (x.src === 'pmos' && x.kind !== 'Epic') { if (SEC.has(x.uid)) x.section = SEC.get(x.uid); else if (x.from && x.from.stage) x.section = x.from.stage; }
|
|
541
|
+
// a task flagged as a milestone (feedback batch 11 item 3): the PM's flag on the board ledger, else a breakdown item's own plan-items flag
|
|
542
|
+
const MS = fr.folded.milestones || new Map();
|
|
543
|
+
for (const x of out) if (x.kind !== 'Epic') { const on = MS.has(x.uid) ? MS.get(x.uid) : !!x.milestone; if (on) x.milestone = true; else delete x.milestone; }
|
|
536
544
|
return B.rollupItems(out);
|
|
537
545
|
}
|
|
538
546
|
|
|
@@ -1194,6 +1202,15 @@ const WRITES = {
|
|
|
1194
1202
|
// the task Viewer edits in place (canvas XetX1Rest, XetX1Dates): each change saves at once; Undo sends `from` back
|
|
1195
1203
|
const p = postFrame(ctx, res, body);
|
|
1196
1204
|
if (!p) return;
|
|
1205
|
+
if (body.milestone != null && typeof body.milestone !== 'boolean') return fail(ctx, res, 400, 'milestone is true or false');
|
|
1206
|
+
// a Jira ticket takes the milestone flag only: Jira keeps its title, status and dates (feedback batch 11 item 3)
|
|
1207
|
+
if (typeof body.task === 'string' && B.JIRA_KEY_RE.test(body.task) && !B.taskOf(p.fr.folded, body.task)) {
|
|
1208
|
+
if (body.milestone == null || ['owner', 'notes', 'start', 'due', 'initiative', 'section'].some((k) => body[k] != null)) return fail(ctx, res, 409, 'Jira owns this ticket: only its milestone flag changes here');
|
|
1209
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1210
|
+
const MS0 = p.fr.folded.milestones || new Map();
|
|
1211
|
+
append(p.file, g.actor, { kind: 'task-milestone', board: p.board.id, task: body.task, milestone: body.milestone, why: body.milestone ? 'made a milestone' : 'no longer a milestone' });
|
|
1212
|
+
return ctx.json(res, { ok: true, from: { milestone: !!MS0.get(body.task) }, item: null });
|
|
1213
|
+
}
|
|
1197
1214
|
const t0 = B.taskOf(p.fr.folded, body.task);
|
|
1198
1215
|
let t = t0;
|
|
1199
1216
|
if (!t0 && TI.isItemId(body.task)) {
|
|
@@ -1234,8 +1251,16 @@ const WRITES = {
|
|
|
1234
1251
|
sec = body.section; from.section = S0.has(t.id) ? S0.get(t.id) : (t.from && t.from.stage) || '';
|
|
1235
1252
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1236
1253
|
}
|
|
1237
|
-
|
|
1254
|
+
// the milestone flag (feedback batch 11 item 3): a board-ledger line for every kind of task, like the section
|
|
1255
|
+
let ms = null;
|
|
1256
|
+
if (body.milestone != null) {
|
|
1257
|
+
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1258
|
+
const MS0 = p.fr.folded.milestones || new Map();
|
|
1259
|
+
ms = body.milestone; from.milestone = MS0.has(t.id) ? MS0.get(t.id) : !!t.milestone;
|
|
1260
|
+
}
|
|
1261
|
+
if (!Object.keys(ev).length && sec == null && ms == null) return fail(ctx, res, 400, 'nothing to change: send owner, notes, start, due, initiative, section or milestone');
|
|
1238
1262
|
if (sec != null) append(p.file, g.actor, { kind: 'task-section', board: p.board.id, task: t.id, section: sec, why: sec ? 'placed under ' + sec : 'placed under no stage' });
|
|
1263
|
+
if (ms != null) append(p.file, g.actor, { kind: 'task-milestone', board: p.board.id, task: t.id, milestone: ms, why: ms ? 'made a milestone' : 'no longer a milestone' });
|
|
1239
1264
|
if (!Object.keys(ev).length) {
|
|
1240
1265
|
const items = itemsOf(p.w, { ...p.fr, folded: B.fold(readLedger(ctx, p.w)) }, p.board, (needRows(ctx, res, p.w) || []).filter((r) => r.id === t.initiative));
|
|
1241
1266
|
return ctx.json(res, { ok: true, from, item: items.find((x) => x.uid === t.id) || null });
|
|
@@ -1393,6 +1418,20 @@ async function handle(req, res, url, ctx) {
|
|
|
1393
1418
|
return true;
|
|
1394
1419
|
}
|
|
1395
1420
|
|
|
1421
|
+
/** Planned versus actual (batch 11 item 8): a move into Build saves the plan "Build start" once, when the initiative has none
|
|
1422
|
+
* (lib/routes-task-plans.js buildStart). It runs after the move's answer is ready, and never changes it. */
|
|
1423
|
+
for (const route of ['/api/boards/move', '/api/boards/ini-wf']) {
|
|
1424
|
+
const plain = WRITES[route];
|
|
1425
|
+
if (!plain) continue;
|
|
1426
|
+
WRITES[route] = (ctx, res, body, g) => plain({ ...ctx, json: (r, obj, code) => {
|
|
1427
|
+
if (obj && obj.ok && obj.row && obj.row.id) {
|
|
1428
|
+
const w = wsOf(ctx, typeof body.ws === 'string' ? body.ws : null), b = w && frameFor(ctx, w).boards.find((x) => x.id === body.board);
|
|
1429
|
+
if (w && b) require('./routes-task-plans.js').buildStart(ctx, w, b, obj.row, g.actor);
|
|
1430
|
+
}
|
|
1431
|
+
ctx.json(r, obj, code);
|
|
1432
|
+
} }, res, body, g);
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1396
1435
|
/** One write route run outside HTTP, by the same function the page's press runs, so its validation, warnings and ledger line are the
|
|
1397
1436
|
* route's own. `g` is { ok, actor }: who writes comes from the call path, never from the body. Answers { status, body } with the body the
|
|
1398
1437
|
* route would send. */
|
|
@@ -1503,4 +1542,4 @@ function meetingBoards(ctx) {
|
|
|
1503
1542
|
return { list, detail };
|
|
1504
1543
|
}
|
|
1505
1544
|
|
|
1506
|
-
module.exports = { prefixes: ['/api/boards'], handle, move, switchWorkflow, taskState, taskAdd, taskEdit, taskDelete, taskRestore, initiativeWorkflow, seedInitiative, stageTasks,
|
|
1545
|
+
module.exports = { prefixes: ['/api/boards'], handle, postFrame, needRows, itemsOf, 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 };
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* POST /api/doc-sheet/why { path, rev, why } page press; a reason for a revision that has none (an outside change);
|
|
20
20
|
* appended to annotations.jsonl, the revision itself is not rewritten
|
|
21
21
|
* POST /api/doc-sheet/mark-current { path, why } page press; "still current" with a reason; it counts as the last change
|
|
22
|
+
* GET /api/doc-sheet/stamp?path=&ini= → { ok, ws, hash } which workspace holds the live copy and its text's hash. With an initiative id,
|
|
23
|
+
* the initiative's own worktree when it holds the file (lib/doc-live-root.js): a chat edits there and
|
|
24
|
+
* does not commit. The page checks this every few seconds and reads again when it changed.
|
|
22
25
|
*
|
|
23
26
|
* Every revision says who wrote the text and how it came in: via 'sheet' (an edit here), 'proposal' (accepted; text_by 'agent',
|
|
24
27
|
* by 'pm', the proposal id and the sections taken) or 'outside' (the file changed outside the sheet; git's last commit of
|
|
@@ -372,11 +375,35 @@ function changeNote(root, body, runtimeDir) {
|
|
|
372
375
|
return { status: 200, body: { ok: true, note } };
|
|
373
376
|
}
|
|
374
377
|
|
|
378
|
+
// the live copy (GET /api/doc-sheet/stamp). git is asked at most every few seconds per repository: an open page asks every 2.5 s.
|
|
379
|
+
const GIT_TTL_MS = 3000;
|
|
380
|
+
const gitCache = new Map();
|
|
381
|
+
function cached(key, fn) {
|
|
382
|
+
const hit = gitCache.get(key);
|
|
383
|
+
if (hit && Date.now() - hit.at < GIT_TTL_MS) return hit.v;
|
|
384
|
+
const v = fn(); gitCache.set(key, { at: Date.now(), v });
|
|
385
|
+
if (gitCache.size > 200) gitCache.delete(gitCache.keys().next().value);
|
|
386
|
+
return v;
|
|
387
|
+
}
|
|
388
|
+
function stampRoute(q, w, ctx) {
|
|
389
|
+
const gitInfo = require('./git-info.js');
|
|
390
|
+
const base = w || { id: null, root: ctx.root || ROOT };
|
|
391
|
+
const live = require('./doc-live-root.js').liveWs({
|
|
392
|
+
base, ini: q.ini, rel: q.path,
|
|
393
|
+
workspaces: ctx.workspaceList ? ctx.workspaceList() : [],
|
|
394
|
+
topOf: (root) => cached('top|' + root, () => gitInfo.repoRoot(root)),
|
|
395
|
+
worktreesOf: (top) => cached('wt|' + top, () => gitInfo.worktrees(top)),
|
|
396
|
+
has: (root, rel) => !resolveDoc(root, rel).error,
|
|
397
|
+
});
|
|
398
|
+
const r = resolveDoc(live.root, q.path); if (r.error) return r.error;
|
|
399
|
+
return { status: 200, body: { ok: true, path: r.rel, ws: live.id || null, hash: S.hashText(r.text) } };
|
|
400
|
+
}
|
|
401
|
+
|
|
375
402
|
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
376
403
|
|
|
377
404
|
module.exports = {
|
|
378
405
|
prefixes: ['/api/doc-sheet'],
|
|
379
|
-
resolveDoc, revisionsRoute, atRoute, edit, propose, accept, changeNote, proposalsRoute, logRoute, reject, addWhy, markCurrent, lastSheetChange, ask, askState, askPrompt, parseAsk, settleAsk,
|
|
406
|
+
resolveDoc, stampRoute, revisionsRoute, atRoute, edit, propose, accept, changeNote, proposalsRoute, logRoute, reject, addWhy, markCurrent, lastSheetChange, ask, askState, askPrompt, parseAsk, settleAsk,
|
|
380
407
|
handle: async (req, res, url, ctx) => {
|
|
381
408
|
const p = url.pathname;
|
|
382
409
|
const w = (url.searchParams.get('ws') && ctx.getWs) ? ctx.getWs(url.searchParams.get('ws')) : null;
|
|
@@ -385,6 +412,7 @@ module.exports = {
|
|
|
385
412
|
if (req.method === 'GET' && p === '/api/doc-sheet/ask') return respond(ctx, res, askState(Object.fromEntries(url.searchParams), base));
|
|
386
413
|
if (req.method === 'GET' && p === '/api/doc-sheet/at') return respond(ctx, res, atRoute(base.root, Object.fromEntries(url.searchParams), base.runtimeDir));
|
|
387
414
|
if (req.method === 'GET' && p === '/api/doc-sheet/proposals') return respond(ctx, res, proposalsRoute(base.root, Object.fromEntries(url.searchParams), base.runtimeDir));
|
|
415
|
+
if (req.method === 'GET' && p === '/api/doc-sheet/stamp') return respond(ctx, res, stampRoute(Object.fromEntries(url.searchParams), w, ctx));
|
|
388
416
|
if (req.method === 'GET' && p === '/api/doc-sheet/log') return respond(ctx, res, logRoute(base.root, Object.fromEntries(url.searchParams), base.runtimeDir));
|
|
389
417
|
const fn = req.method === 'POST' && { '/api/doc-sheet/edit': edit, '/api/doc-sheet/propose': propose, '/api/doc-sheet/accept': accept,
|
|
390
418
|
'/api/doc-sheet/reject': reject, '/api/doc-sheet/why': addWhy, '/api/doc-sheet/mark-current': markCurrent, '/api/doc-sheet/ask': ask,
|