create-pmos 0.567.0 → 0.568.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 +14 -14
- 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/workflow-state.js +20 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +13 -0
- package/workspace/guide/initiatives-and-next-steps.md +20 -1
- package/workspace/lib/engine/workflow-state.js +20 -1
- package/workspace/lib/engine/workflows.js +71 -7
- package/workspace/lib/jira-cli.js +1 -0
- package/workspace/lib/jira-tickets.js +23 -0
- package/workspace/lib/kind-control.js +232 -0
- package/workspace/lib/rehearse-read.js +3 -1
- package/workspace/lib/rehearse.js +30 -2
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +44 -2
- package/workspace/lib/routes-initiatives.js +3 -1
- package/workspace/lib/routes-kind-control.js +95 -0
- package/workspace/lib/vendor/scripts/workflow-state.js +20 -1
- package/workspace/lib/work-kind.js +16 -4
- package/workspace/lib/workflows-store.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ini-agent.js +16 -6
- package/workspace/public/pm/ini-kind.js +59 -0
- package/workspace/public/pm/ini-view.css +23 -0
- package/workspace/public/pm/ini-view.js +5 -2
- package/workspace/test-lists/kind-workflows.json +5 -0
|
@@ -64,7 +64,7 @@ function snapshotOf(root, o = {}) {
|
|
|
64
64
|
try { const got = rowsLib.rowsFor(root); if (got && got.ok) for (const r of got.rows) recOf.set(r.id, r.record || null); } catch { /* no record paths */ }
|
|
65
65
|
if (base.ok) {
|
|
66
66
|
for (const r of base.rows) {
|
|
67
|
-
snap.rows.push({ id: r.id, title: r.title || r.id, end: r.end || null, anchor: r.anchor || null });
|
|
67
|
+
snap.rows.push({ id: r.id, title: r.title || r.id, end: r.end || null, anchor: r.anchor || null, kind: require('./work-kind.js').kindOf(r.kind) });
|
|
68
68
|
if (recOf.get(r.id)) files.records[r.id] = path.resolve(root, recOf.get(r.id));
|
|
69
69
|
}
|
|
70
70
|
} else missing.push('initiatives');
|
|
@@ -126,6 +126,8 @@ function refsOf(root, snap, files) {
|
|
|
126
126
|
if (a) R.rows[ini + ':anchor'] = a;
|
|
127
127
|
const idl = lineRef(root, file, (l) => /^id:/.test(l), ini + ' record (its end is the Board\'s, from its tasks)');
|
|
128
128
|
if (idl) R.rows[ini + ':end'] = idl;
|
|
129
|
+
const tl = lineRef(root, file, (l) => /^title:/.test(l), ini + ' title'); // W5: the date a title names
|
|
130
|
+
if (tl) R.rows[ini + ':title'] = tl;
|
|
129
131
|
}
|
|
130
132
|
for (const g of snap.goals || []) { const s = F.krs && lineRef(root, F.krs, after(jsonHas('rid', g.id)), 'goal ' + g.id); if (s) R.goals[g.id] = s; }
|
|
131
133
|
for (const p of snap.programs || []) { const s = F.programs && lineRef(root, F.programs, (line) => (line.includes('"kind":"program"') ? after(jsonHas('id', p.id))(line) : null), 'program ' + p.id); if (s) R.programs[p.id] = s; }
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* SNAPSHOT. { today: 'YYYY-MM-DD',
|
|
14
14
|
* tasks: [{ uid, title, ini, status, start, end, milestone, src }] the shape lib/task-links.js taskOf reads
|
|
15
15
|
* links: [{ from, to, type, lag }] the approved links
|
|
16
|
-
* rows: [{ id, title, end, anchor }]
|
|
16
|
+
* rows: [{ id, title, end, anchor, kind? }] the initiatives (end = the committed end; kind: lib/work-kind.js)
|
|
17
17
|
* goals: [{ id, title, byAt, moves: [initiative id], forecast: { state, likely } | null }] lib/forecast.js goalForecast
|
|
18
18
|
* programs: [{ id, title, milestones: [{ id, name, date, waits: [initiative id], done }] }]
|
|
19
19
|
* refs: { links: { 'from>to': src }, rows: { 'ini:end' | 'ini:anchor': src }, goals: { id: src }, programs: { id: src }, tasks: { uid: src } }
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
const TL = require('./task-links.js');
|
|
31
31
|
const FC = require('./forecast.js');
|
|
32
32
|
|
|
33
|
+
const KC = () => require('./kind-control.js'); // dateIn: the date a title or a KR names (W5)
|
|
33
34
|
const KINDS = Object.freeze(['move', 'end', 'cut']);
|
|
34
35
|
const MAX_LIST = 8;
|
|
35
36
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -198,6 +199,31 @@ function rehearse(snap, change) {
|
|
|
198
199
|
if (!late0 && late1) add({ tone: 'breaks', kind: 'end', ini, text: q(iniTitle(ini)) + "'s last task would end " + TL.md(f1) + ', ' + days(f1 - end1) + ' after its committed end, ' + TL.md(end1) + '.', evidence: ev });
|
|
199
200
|
else if (late0 && !late1 && f1 != null) add({ tone: 'helps', kind: 'end', ini, text: q(iniTitle(ini)) + "'s last task would end " + TL.md(f1) + ', back inside its committed end, ' + TL.md(end1) + '.', evidence: ev });
|
|
200
201
|
}
|
|
202
|
+
// W5 (board WfC): a new end is checked against the dates the plan already promises: the date the title names, the KR's date and the
|
|
203
|
+
// initiative's own ◇ milestones. Each break names what to change; nothing here estimates a number.
|
|
204
|
+
let msChecked = 0;
|
|
205
|
+
if (c.kind === 'end') {
|
|
206
|
+
const to = TL.dn(c.to), row = rows.get(c.ini) || {}, was = row.end ? TL.dn(row.end) : null;
|
|
207
|
+
const td = KC().dateIn(row.title, S.today);
|
|
208
|
+
if (td && TL.dn(td) !== to) add({ tone: 'breaks', kind: 'title', ini: c.ini, text: 'The title ' + q(row.title) + ' says ' + TL.md(TL.dn(td)) + '. Change it to ' + TL.md(to) + ', or keep the end.', evidence: [refRow(c.ini, 'title')] });
|
|
209
|
+
// the KR's date and the milestones are a Project's promises (its go-live is the end); on other kinds a later end alone moves nothing
|
|
210
|
+
// the work still meets (Wawan's Mac, 2026-11-03), so they are read only for a Project
|
|
211
|
+
const proj = row.kind === 'project';
|
|
212
|
+
for (const g of proj ? S.goals || [] : []) {
|
|
213
|
+
if (!(g.moves || []).includes(c.ini)) continue;
|
|
214
|
+
const by = TL.dn(g.byAt), gd = KC().dateIn(g.title, S.today);
|
|
215
|
+
if (by != null && to > by) add({ tone: 'breaks', kind: 'goal', ini: c.ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. The new end, ' + TL.md(to) + ', is after it. Change the goal\'s date, or keep the end.', evidence: [(R.goals || {})[g.id], refRow(c.ini, 'anchor')] });
|
|
216
|
+
else if (gd && TL.dn(gd) !== to && (by == null || TL.dn(gd) !== by)) add({ tone: 'breaks', kind: 'goal', ini: c.ini, goal: g.id, text: 'Goal ' + q(g.title) + ' says ' + TL.md(TL.dn(gd)) + '. Change it to ' + TL.md(to) + ', or keep the end.', evidence: [(R.goals || {})[g.id], refRow(c.ini, 'anchor')] });
|
|
217
|
+
}
|
|
218
|
+
const ms = proj ? [...base.T.values()].filter((t) => t.ini === c.ini && t.ms && !t.closed && t.e != null) : [];
|
|
219
|
+
msChecked = ms.length;
|
|
220
|
+
const last = ms.slice().sort((a, b) => b.e - a.e)[0];
|
|
221
|
+
for (const m of ms) {
|
|
222
|
+
if (!(m.e < to && (m === last || (was != null && m.e === was)))) continue;
|
|
223
|
+
add({ tone: 'breaks', kind: 'milestone', ini: c.ini, task: m.uid, text: '◇ ' + q(m.title) + ' is ' + TL.md(m.e) + ', before the new end. Its baseline stays; its forecast moves to ' + TL.md(to) + ' when you approve.', evidence: [refT(m.uid)] });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
201
227
|
// goals and program milestones: when each initiative's work lands, before and after
|
|
202
228
|
const land0 = new Map(), land1 = new Map();
|
|
203
229
|
for (const ini of new Set([...rows.keys(), ...inis])) { land0.set(ini, landOf(base.T, rows.get(ini), ini)); if (ini !== cutIni) land1.set(ini, landOf(TA, rowsA.get(ini), ini)); }
|
|
@@ -211,6 +237,7 @@ function rehearse(snap, change) {
|
|
|
211
237
|
const ev = [(R.goals || {})[g.id], refRow(ini, 'anchor')];
|
|
212
238
|
if (ini === cutIni) { add({ tone: 'breaks', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' loses ' + q(iniTitle(ini)) + ', ' + ((g.moves || []).length === 1 ? 'the only initiative that moves it' : 'one of the ' + g.moves.length + ' initiatives that move it') + '.' + fc, evidence: ev }); continue; }
|
|
213
239
|
const a = land0.get(ini), b = land1.get(ini); if (a == null || b == null) continue;
|
|
240
|
+
if (effects.some((e) => e.kind === 'goal' && e.goal === g.id && e.ini === ini)) continue; // said once (W5's end check above)
|
|
214
241
|
if (a <= by && b > by) add({ tone: 'breaks', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. ' + q(iniTitle(ini)) + ', which moves it, would land ' + TL.md(b) + ', after that.' + fc, evidence: ev.concat([refRow(ini, 'end'), lastRef(ini)]) });
|
|
215
242
|
else if (a > by && b <= by) add({ tone: 'helps', kind: 'goal', ini, goal: g.id, text: 'Goal ' + q(g.title) + ' is due ' + TL.md(by) + '. ' + q(iniTitle(ini)) + ', which moves it, would land ' + TL.md(b) + ', in time.' + fc, evidence: ev.concat([refRow(ini, 'end'), lastRef(ini)]) });
|
|
216
243
|
}
|
|
@@ -233,7 +260,7 @@ function rehearse(snap, change) {
|
|
|
233
260
|
const order = { breaks: 0, helps: 1, moves: 2 };
|
|
234
261
|
effects.sort((x, y) => order[x.tone] - order[y.tone]);
|
|
235
262
|
const counts = { breaks: 0, helps: 0, moves: 0 }; for (const e of effects) counts[e.tone]++;
|
|
236
|
-
return { ok: true, change: c, effects, counts, checked: { tasks: T0.size, links: links0.length, goals: (S.goals || []).length, programs: (S.programs || []).length }, missing: S.missing || [], unsourced, stale, note };
|
|
263
|
+
return { ok: true, change: c, effects, counts, checked: { tasks: T0.size, links: links0.length, goals: (S.goals || []).length, programs: (S.programs || []).length, ...(c.kind === 'end' ? { title: true, milestones: msChecked, project: (rows.get(c.ini) || {}).kind === 'project' } : {}) }, missing: S.missing || [], unsourced, stale, note };
|
|
237
264
|
}
|
|
238
265
|
|
|
239
266
|
function moveDelta(T0, T1, uid) { const a = T0.get(uid), b = T1.get(uid); return a && b && a.e != null && b.e != null ? b.e - a.e : a && b && a.s != null && b.s != null ? b.s - a.s : 0; }
|
|
@@ -263,6 +290,7 @@ function dedupe(ev) { const seen = new Set(); return ev.filter((s) => { const k
|
|
|
263
290
|
function textOf(r) {
|
|
264
291
|
if (!r.ok) return ['✗ ' + r.error];
|
|
265
292
|
const out = [];
|
|
293
|
+
if (r.checked && r.checked.title) out.push(r.checked.project ? 'Checked: the title date, the goal dates and ' + (r.checked.milestones === 1 ? '1 milestone' : (r.checked.milestones || 0) + ' milestones') + '.' : 'Checked: the date the title names.');
|
|
266
294
|
if (!r.effects.length) out.push('Nothing else moves: no other task, initiative, goal or program milestone changes.');
|
|
267
295
|
for (const e of r.effects) {
|
|
268
296
|
out.push((e.tone === 'breaks' ? '✗ Breaks: ' : e.tone === 'helps' ? '✓ Helps: ' : '· Moves: ') + e.text);
|
|
@@ -96,6 +96,7 @@ const MODULES = Object.freeze([
|
|
|
96
96
|
'routes-meeting-replay', // meeting-material-replay: the note, the Focus state and the shots joined for the Replay page (GET, read-only)
|
|
97
97
|
'routes-meeting-material', // meeting-material-replay: the material the PM links to a meeting (GET list and suggest; page-press POST add and remove; meeting-material.jsonl)
|
|
98
98
|
'routes-meeting-points', // premium-uncovered-features (meetings): the Replay's Confirm and Not right on a meeting's key points (meeting-points.jsonl)
|
|
99
|
+
'routes-kind-control', // launch simulation W5: the Viewer's Project control (gate, colours, critical path, on track) and Full SDLC gate (GET, read-only)
|
|
99
100
|
'routes-viewer', // premium-agreed-design (viewer): agenda minutes, what recording listens to, a next step made a drafted ticket, the report's Issue checks
|
|
100
101
|
'routes-report-confirm', // premium-uncovered-features (reports): the Brief tab's Confirm and Use it (report-confirms.jsonl in the runtime folder)
|
|
101
102
|
'routes-stage-tools', // stage-tools-records: the records the PM edits per stage, what PMOS holds per stage, the sprint burndown
|
|
@@ -226,11 +226,23 @@ function createAndPlace(ctx, w, boardId, input, actor, tie) {
|
|
|
226
226
|
* (Settings opens on home), and that workflow is adopted into this workspace's library first, as a switch does. PMOS still reads the BRD
|
|
227
227
|
* and proposes a switch. Never throws: a new initiative is made even when this line cannot be written.
|
|
228
228
|
* boardId: the board the initiative is on; else its domain board (products/<domain>/) or the workspace board. → the workflow id | null */
|
|
229
|
-
function startOnDefault(ctx, w, iniId, actor, { boardId = null, recordPath = null } = {}) {
|
|
229
|
+
function startOnDefault(ctx, w, iniId, actor, { boardId = null, recordPath = null, kind = null } = {}) {
|
|
230
230
|
try {
|
|
231
231
|
const file = ledgerFile(ctx, w);
|
|
232
232
|
const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
233
233
|
if (!file || !dir || isSelf(ctx, w)) return null;
|
|
234
|
+
// W5: the kind of work sets the default. Project and Full SDLC start on their own built-in workflow; Product management on the default.
|
|
235
|
+
const k = WK.valid(kind) ? kind : recordKind(w.root, recordPath);
|
|
236
|
+
if (k !== 'product') {
|
|
237
|
+
const def = WF.forKind(WS.library(dir), k);
|
|
238
|
+
const fr = frameFor(ctx, w);
|
|
239
|
+
const dm = recordPath ? /^products\/([^/]+)\//.exec(recordPath) : null;
|
|
240
|
+
const bid = boardId || (dm && fr.boards.some((b) => b.id === dm[1] && b.kind === 'domain') ? dm[1] : w.id);
|
|
241
|
+
const board = fr.boards.find((b) => b.id === bid);
|
|
242
|
+
if (!board || board.self) return null;
|
|
243
|
+
append(file, actor, { kind: 'ini-wf', board: board.id, id: iniId, wf: def.id, why: 'the ' + WK.LABEL[k] + ' workflow: the kind of work sets it', start: true });
|
|
244
|
+
return def.id;
|
|
245
|
+
}
|
|
234
246
|
let lib = WS.library(dir), from = null;
|
|
235
247
|
if (!lib.defaultId) {
|
|
236
248
|
const home = ctx.getWs ? ctx.getWs(null) : null;
|
|
@@ -251,6 +263,36 @@ function startOnDefault(ctx, w, iniId, actor, { boardId = null, recordPath = nul
|
|
|
251
263
|
} catch { return null; }
|
|
252
264
|
}
|
|
253
265
|
|
|
266
|
+
/** The `kind:` of an initiative record (lib/work-kind.js kindOf: no line or no file reads as Product management). */
|
|
267
|
+
function recordKind(root, recordPath) {
|
|
268
|
+
if (!root || !recordPath) return 'product';
|
|
269
|
+
try {
|
|
270
|
+
const text = fs.readFileSync(path.resolve(root, recordPath), 'utf8');
|
|
271
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
272
|
+
const line = m ? m[1].split(/\r?\n/).find((l) => /^kind:/.test(l)) : null;
|
|
273
|
+
return WK.kindOf(line ? line.slice(5) : '');
|
|
274
|
+
} catch { return 'product'; }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** A kind change (POST /api/initiatives/kind, `pmos initiative set … --kind`): an initiative that runs its OLD kind's default workflow moves to
|
|
278
|
+
* the new kind's, its stage mapped by meaning (scripts/workflows.js MEANING: Plan to Plan, Build to Execute, Release to Close). The switch line
|
|
279
|
+
* says what changed in one sentence. A workflow the PM picked by hand is left alone. Never throws. → { switched, wf?, line } */
|
|
280
|
+
function kindSwitch(ctx, w, id, from, to, actor) {
|
|
281
|
+
const line = WK.switchLine(from, to);
|
|
282
|
+
try {
|
|
283
|
+
if (!w || isSelf(ctx, w) || WK.kindOf(from) === WK.kindOf(to)) return { switched: false, line };
|
|
284
|
+
const r = initiativeWorkflow(ctx, w, id);
|
|
285
|
+
if (!r.ok) return { switched: false, line };
|
|
286
|
+
const lib = libOf(foldOf(ctx, w));
|
|
287
|
+
const cur = (r.row.wf && r.row.wf.id) || WF.PRODUCT_FEATURE_ID;
|
|
288
|
+
if (!WF.isKindDefault(lib, WK.kindOf(from), cur)) return { switched: false, line, kept: cur };
|
|
289
|
+
const target = WF.forKind(lib, WK.kindOf(to));
|
|
290
|
+
if (target.id === cur) return { switched: false, line };
|
|
291
|
+
const out = switchWorkflow(ctx, { ws: w.id, board: r.board.id, id, wf: target.id, why: line, pmos: true }, { ok: true, actor });
|
|
292
|
+
return out.body && out.body.ok ? { switched: true, wf: target.id, moved: out.body.moved, line } : { switched: false, line, error: out.body && out.body.error };
|
|
293
|
+
} catch (e) { return { switched: false, line, error: String((e && e.message) || e).slice(0, 200) }; }
|
|
294
|
+
}
|
|
295
|
+
|
|
254
296
|
// ── boards of a workspace ─────────────────────────────────────────────────────────────────────────
|
|
255
297
|
const isSelf = (ctx, w) => !!(ctx.selfRoot && w && path.resolve(w.root) === path.resolve(ctx.selfRoot));
|
|
256
298
|
|
|
@@ -1904,4 +1946,4 @@ function meetingBoards(ctx) {
|
|
|
1904
1946
|
return { list, detail };
|
|
1905
1947
|
}
|
|
1906
1948
|
|
|
1907
|
-
module.exports = { prefixes: ['/api/boards'], handle, tasksOfIni, 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, startOnDefault, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, taskSpanOf, workflowRowOf, closedOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
1949
|
+
module.exports = { prefixes: ['/api/boards'], handle, tasksOfIni, 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, startOnDefault, kindSwitch, recordKind, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, taskSpanOf, workflowRowOf, closedOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
|
|
@@ -655,9 +655,11 @@ async function handle(req, res, url, ctx) {
|
|
|
655
655
|
if (!g.ok) return answer(ctx, res, g), true;
|
|
656
656
|
const r = writer.setKind(w.root, body.id, body.kind, { actor: g.actor });
|
|
657
657
|
if (!r.ok) { ctx.json(res, { ok: false, status: r.status, error: r.error, field: r.field }, r.status); return true; }
|
|
658
|
+
// W5: the kind sets the default workflow, so an initiative on its old kind's default moves to the new kind's (stages mapped by meaning)
|
|
659
|
+
const sw = r.same ? null : require('./routes-boards.js').kindSwitch(ctx, w, r.id, r.from, r.kind, g.actor);
|
|
658
660
|
rowsLib.invalidate(w.root);
|
|
659
661
|
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id);
|
|
660
|
-
ctx.json(res, { ok: true, id: r.id, from: r.from, kind: r.kind, sig: sigOf(w.root) });
|
|
662
|
+
ctx.json(res, { ok: true, id: r.id, from: r.from, kind: r.kind, ...(sw ? { workflow: sw } : {}), sig: sigOf(w.root) });
|
|
661
663
|
return true;
|
|
662
664
|
}
|
|
663
665
|
// split or merge initiatives (feedback batch 11 item 14; lib/split-merge.js): the editor's button or ✓ on Claude's card, Undo, and ✕ Not now
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-kind-control.js — the Viewer's Project and Full SDLC section (launch simulation W5; boards WfA and WfB). READ ONLY.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/kind-control?ws=&ini=<id>
|
|
5
|
+
* → { ok, kind: 'product' } Product management: the Viewer shows what it shows today
|
|
6
|
+
* → { ok, kind: 'sdlc', gate, line? } lib/kind-control.js sdlc
|
|
7
|
+
* → { ok, kind: 'project', gate, rows, critical, ontrack, proposal, goLive, baselineAt, line? } lib/kind-control.js project
|
|
8
|
+
* line: the last kind change on the initiative's workflow ("Kind changed to Project …"), written by routes-boards.js kindSwitch.
|
|
9
|
+
*
|
|
10
|
+
* Every value comes through the readers the pmos verbs use (lib/rehearse-read.js snapshotOf for tasks, links, the committed end and the goals;
|
|
11
|
+
* lib/people-store.js for People; the task ledgers for the baseline), never a typed status. A reader that fails leaves its part out. */
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const KC = require('./kind-control.js');
|
|
15
|
+
const WK = require('./work-kind.js');
|
|
16
|
+
|
|
17
|
+
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
18
|
+
const okBody = (body) => ({ status: 200, body: { ok: true, ...body } });
|
|
19
|
+
const ID_RE = /^[a-z0-9][a-z0-9._-]{0,120}$/;
|
|
20
|
+
|
|
21
|
+
function readJsonl(file) {
|
|
22
|
+
let text = '';
|
|
23
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
24
|
+
const out = [];
|
|
25
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { out.push(JSON.parse(raw)); } catch { /* a torn line */ } }
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** The record's front matter keys this section reads. */
|
|
29
|
+
function recordOf(root, id) {
|
|
30
|
+
const file = path.join(root, 'planning', 'initiatives', id + '.md');
|
|
31
|
+
let text = '';
|
|
32
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch {
|
|
33
|
+
try { const got = require('./initiative-rows.js').rowsFor(root); const r = got && got.ok ? got.rows.find((x) => x.id === id) : null; if (r && r.record) text = fs.readFileSync(path.resolve(root, r.record), 'utf8'); } catch { return null; }
|
|
34
|
+
}
|
|
35
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
36
|
+
if (!m) return null;
|
|
37
|
+
const fm = {};
|
|
38
|
+
for (const l of m[1].split(/\r?\n/)) { const k = /^([a-z_]+):\s*(.*)$/.exec(l); if (k && !(k[1] in fm)) fm[k[1]] = k[2].trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1'); }
|
|
39
|
+
return fm;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One initiative's section. o: { today?, snapshot?, people? } for a test. */
|
|
43
|
+
function control(ctx, q, o = {}) {
|
|
44
|
+
const w = ctx && ctx.getWs ? ctx.getWs(q.ws || null) : null;
|
|
45
|
+
if (!w || !w.root) return fail(404, 'no such workspace');
|
|
46
|
+
const id = String(q.ini || '');
|
|
47
|
+
if (!ID_RE.test(id)) return fail(400, 'ini is an initiative id');
|
|
48
|
+
const fm = recordOf(w.root, id);
|
|
49
|
+
if (!fm) return fail(404, 'no initiative record for ' + id);
|
|
50
|
+
const kind = WK.kindOf(fm.kind);
|
|
51
|
+
if (kind === 'product') return okBody({ kind });
|
|
52
|
+
const stateDir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
53
|
+
// the last kind change on the workflow, said once
|
|
54
|
+
let line = null, baselineAt = null;
|
|
55
|
+
try {
|
|
56
|
+
const RB = require('./routes-boards.js'), f = RB.ledgerFile(ctx, w);
|
|
57
|
+
for (const e of f ? readJsonl(f) : []) {
|
|
58
|
+
if (!e || e.kind !== 'ini-wf' || e.id !== id) continue;
|
|
59
|
+
if (typeof e.why === 'string' && /^Kind changed to /.test(e.why)) line = e.why;
|
|
60
|
+
if (!baselineAt && e.moved && e.moved.from === 'plan' && e.moved.to !== 'plan') baselineAt = e.at || null;
|
|
61
|
+
}
|
|
62
|
+
} catch { /* no workflow ledger */ }
|
|
63
|
+
if (kind === 'sdlc') return okBody({ ...KC.sdlc({ record: fm }), ...(line ? { line } : {}) });
|
|
64
|
+
|
|
65
|
+
const today = o.today || new Date().toISOString().slice(0, 10);
|
|
66
|
+
let snap;
|
|
67
|
+
try { snap = o.snapshot || require('./rehearse-read.js').snapshotOf(w.root, { today, stateDir: stateDir || undefined }); } catch { snap = { tasks: [], links: [], rows: [], goals: [] }; }
|
|
68
|
+
const tasks = (snap.tasks || []).filter((x) => x && x.ini === id);
|
|
69
|
+
const row = (snap.rows || []).find((r) => r.id === id) || null;
|
|
70
|
+
const goal = (snap.goals || []).find((g) => (g.moves || []).includes(id)) || null;
|
|
71
|
+
let people = o.people;
|
|
72
|
+
if (!people) { try { const v = require('./people-store.js').view(w.root); people = v && v.ok ? v.people : []; } catch { people = []; } }
|
|
73
|
+
// the baseline: each task's dates when the initiative left Plan, read from both task ledgers
|
|
74
|
+
const lines = [];
|
|
75
|
+
try { const TS = require('./task-store.js'), s = TS.storeFor(w.root); if (s) lines.push(...readJsonl(s.file)); } catch { /* none */ }
|
|
76
|
+
try { lines.push(...readJsonl(require('./plan-ledgers.js').ledgerPath(w.root, 'plan-items'))); } catch { /* none */ }
|
|
77
|
+
try { const f = require('./routes-boards.js').ledgerFile(ctx, w); if (f) lines.push(...readJsonl(f).filter((e) => e && (e.kind === 'task' || e.kind === 'task-update'))); } catch { /* none */ }
|
|
78
|
+
lines.sort((a, b) => String(a.at || '').localeCompare(String(b.at || '')));
|
|
79
|
+
const baseline = KC.baselineOf(lines, new Set(tasks.map((x) => x.uid || x.key)), baselineAt);
|
|
80
|
+
const m = KC.project({ today, title: fm.title || (row && row.title) || id, goal: goal ? { id: goal.id, title: goal.title, byAt: goal.byAt } : null, end: row && row.end,
|
|
81
|
+
record: fm, tasks, links: snap.links || [], baseline, baselineAt, people });
|
|
82
|
+
return okBody({ ...m, ...(line ? { line } : {}) });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
prefixes: ['/api/kind-control'],
|
|
89
|
+
control, recordOf,
|
|
90
|
+
handle: async (req, res, url, ctx) => {
|
|
91
|
+
if (url.pathname !== '/api/kind-control') return false;
|
|
92
|
+
if (req.method !== 'GET') return respond(ctx, res, fail(405, 'GET only'));
|
|
93
|
+
return respond(ctx, res, control(ctx, Object.fromEntries(url.searchParams)));
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -963,7 +963,26 @@ function computeWorkflowDerived(id, opts) {
|
|
|
963
963
|
'the done test is the spec (D13 as amended by D107). Land it in an earlier commit than the build, or split this PR so it lands first',
|
|
964
964
|
{ blocking: !legacy, rule });
|
|
965
965
|
};
|
|
966
|
-
|
|
966
|
+
// W5 (boards WfA/WfB/WfC, agreed 2026-11-12): the kind of work sets the gate. Full SDLC: a done test and a kill condition before the first
|
|
967
|
+
// pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
|
|
968
|
+
// PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
|
|
969
|
+
const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
|
|
970
|
+
const planPath = String(fm.plan_path || '').trim();
|
|
971
|
+
if (!doneTest && workKind === 'sdlc' && !prd) {
|
|
972
|
+
steps.push(step('spec', 'spec', 'blocked', 'Full SDLC needs a done test and a kill condition before the first pull request — never a PRD',
|
|
973
|
+
`write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
|
|
974
|
+
} else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
|
|
975
|
+
const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
|
|
976
|
+
if (!planPath) {
|
|
977
|
+
steps.push(step('spec', 'spec', 'blocked', 'Project needs a dated plan before Execute — never a PRD',
|
|
978
|
+
`write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`, { blocking: true, rule: 'R2' }));
|
|
979
|
+
} else if (planIdx === null) {
|
|
980
|
+
steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
|
|
981
|
+
'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
|
|
982
|
+
} else {
|
|
983
|
+
steps.push(orderOf(`plan ${planPath}`, planIdx, 'O1'));
|
|
984
|
+
}
|
|
985
|
+
} else if (doneTest) {
|
|
967
986
|
const dtIdx = firstAppearance(root, range, doneTest);
|
|
968
987
|
if (dtIdx === null) {
|
|
969
988
|
steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
|
|
@@ -14,9 +14,14 @@
|
|
|
14
14
|
* (the factory, D65: propose-only, the PM merges) where a factory runs, else the team's agents (PMOS writes
|
|
15
15
|
* the done test and the pull request plan); Product and Project → the team
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* (
|
|
17
|
+
* switchLine(from, to) → string the one line a kind change writes on the workflow switch (the Viewer shows it)
|
|
18
|
+
*
|
|
19
|
+
* NOT A LANE (D107). The kind sits on the record beside the lane; it does not replace the lane. No model call: the pre-pick is the small
|
|
20
|
+
* word table below, and when it cannot tell it says so (cue '') instead of guessing.
|
|
21
|
+
* THE KIND SETS THE DEFAULT WORKFLOW AND GATE (launch simulation W5, boards WfA, WfB, WfC, agreed by Wawan 2026-11-12; this amends the
|
|
22
|
+
* batch-29 note that the kind was a hint only). Project starts on the Project workflow, Full SDLC on Full SDLC, Product management on the
|
|
23
|
+
* workspace default (scripts/workflows.js forKind). The Initiative Gate reads it too (scripts/workflow-state.js). Each initiative can still
|
|
24
|
+
* switch workflow; a kind change switches only an initiative that runs its old kind's default (routes-boards.js kindSwitch). */
|
|
20
25
|
|
|
21
26
|
const KINDS = Object.freeze(['product', 'sdlc', 'project']);
|
|
22
27
|
const LABEL = Object.freeze({ product: 'Product management', sdlc: 'Full SDLC', project: 'Project management' });
|
|
@@ -57,4 +62,11 @@ const factoryRuns = (root) => {
|
|
|
57
62
|
};
|
|
58
63
|
const executorOf = (kind, factory) => (kindOf(kind) !== 'sdlc' ? 'team' : factory ? 'factory' : 'team-agents');
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
/** The line a kind change writes: what the kind now is and what its gate adds (WfC: "Kind changed to Project, Plan gate now needs …"). */
|
|
66
|
+
function switchLine(from, to) {
|
|
67
|
+
const GATE = { product: 'the Build gate reads the done test and kill condition, or a PRD', sdlc: 'the first pull request now needs a done test and a kill condition', project: 'the Plan gate now needs milestone dates, owners and a go-live that matches the KR' };
|
|
68
|
+
const k = kindOf(to);
|
|
69
|
+
return 'Kind changed to ' + SHORT[k] + (from && kindOf(from) !== k ? ' from ' + SHORT[kindOf(from)] : '') + ': ' + GATE[k] + '.';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = { KINDS, LABEL, SHORT, DEFAULT, valid, kindOf, fromName, executorOf, factoryRuns, switchLine };
|
|
@@ -76,7 +76,7 @@ function copy(stateDir, id, name, actor) {
|
|
|
76
76
|
/** An initiative here switches to a workflow saved in another workspace's library: the same definition (same id) is saved here. */
|
|
77
77
|
function adopt(stateDir, wf, actor, fromWs) {
|
|
78
78
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
79
|
-
if (!wf || wf.id
|
|
79
|
+
if (!wf || W.isBuiltin(wf.id)) return { ok: true, workflow: wf }; // built in everywhere (W5: Project and Full SDLC too)
|
|
80
80
|
const c = W.check({ id: wf.id, name: wf.name, icon: wf.icon, decide: wf.decide, stages: wf.stages });
|
|
81
81
|
if (!c.ok) return c;
|
|
82
82
|
append(fileOf(stateDir), actor, { kind: 'wf-save', wf: c.workflow, ...(fromWs ? { adoptedFrom: fromWs } : {}) });
|
|
@@ -85,7 +85,7 @@ function adopt(stateDir, wf, actor, fromWs) {
|
|
|
85
85
|
|
|
86
86
|
function archive(stateDir, id, archived, actor, { inUse = [] } = {}) {
|
|
87
87
|
if (!stateDir) return { ok: false, status: 409, error: NO_STATE };
|
|
88
|
-
if (
|
|
88
|
+
if (W.isBuiltin(id)) return { ok: false, status: 409, error: `${W.BUILTIN[id].name} is built in and stays.` };
|
|
89
89
|
const lib = library(stateDir);
|
|
90
90
|
if (!lib.byId.has(id)) return { ok: false, status: 404, error: 'That workflow could not be found. It may have been removed.' };
|
|
91
91
|
if (archived && inUse.length) return { ok: false, status: 409, error: `${inUse.length} ${inUse.length === 1 ? 'initiative runs' : 'initiatives run'} this workflow. Move ${inUse.length === 1 ? 'it' : 'them'} to another workflow first.`, inUse };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.568.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.568.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* A check that is already due is Your move on Home, so nothing here repeats it.
|
|
25
25
|
* Icon-only presses carry their words in aria-label and title. */
|
|
26
26
|
import { pmGet, pmPost } from './http.js';
|
|
27
|
+
import { controlHtml } from './ini-kind.js'; // W5 (boards WfA, WfB): Project control and the kind's own gate, read with the experiment
|
|
27
28
|
|
|
28
29
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
29
30
|
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
@@ -113,6 +114,7 @@ export function agentModel(A, U, id, o = {}) {
|
|
|
113
114
|
/** D107: with an experiment on record, the gate to Build is its done test and its kill condition (not the PRD and the rubric). */
|
|
114
115
|
export function gateOf(M) {
|
|
115
116
|
if (!M || !M.gate) return null;
|
|
117
|
+
if (M.gate.kind) return M.gate.kind; // W5: a Project's or a Full SDLC's own gate (kindGate)
|
|
116
118
|
return { label: 'Gate to Build', parts: [{ text: 'done test', ok: M.gate.done, ...(M.gate.done ? {} : { note: 'No done test is written yet' }) }, { text: 'kill condition', ok: M.gate.kill, ...(M.gate.kill ? {} : { note: 'No kill condition is written yet' }) }] };
|
|
117
119
|
}
|
|
118
120
|
|
|
@@ -199,13 +201,18 @@ export function comingHtml(rows, o = {}) {
|
|
|
199
201
|
/** Both sections in one holder the page can swap when the reads arrive. */
|
|
200
202
|
export function sectionsHtml(M, v, id, o = {}) {
|
|
201
203
|
const k = v && v.kind ? kindOf(v.kind) : '';
|
|
202
|
-
return `<div class="ia" data-ia="${esc(id)}"${k ? ` data-ia-kind="${k}"` : ''}>${expHtml(M, k)}${workHtml(M, o)}${comingHtml(comingUp(v, M), { all: !!o.cuAll })}</div>`;
|
|
204
|
+
return `<div class="ia" data-ia="${esc(id)}"${k ? ` data-ia-kind="${k}"` : ''}>${controlHtml(cachedControl(id), { hidden: HIDDEN })}${expHtml(M, k)}${workHtml(M, o)}${comingHtml(comingUp(v, M), { all: !!o.cuAll })}</div>`;
|
|
203
205
|
}
|
|
206
|
+
/** W5: the gate a Project or a Full SDLC initiative shows on its stage card, in place of the experiment's or the PRD's. null: Product. */
|
|
207
|
+
export function kindGate(id) { const C = cachedControl(id); return C && C.gate && C.kind && C.kind !== 'product' ? C.gate : null; }
|
|
208
|
+
const HIDDEN = new Set(); // the proposals ✕ dismissed, for this session
|
|
209
|
+
export function dismiss(key) { if (key) HIDDEN.add(key); }
|
|
204
210
|
|
|
205
211
|
/* ── the reads and the presses (the page only) ── */
|
|
206
212
|
const CACHE = new Map(), WANT = new Map(), OPEN = new Set();
|
|
207
213
|
const FRESH_MS = 30e3;
|
|
208
214
|
export const cached = (id) => (CACHE.get(id) || {}).M || null;
|
|
215
|
+
export const cachedControl = (id) => (CACHE.get(id) || {}).C || null;
|
|
209
216
|
export const allOpen = (id) => OPEN.has(id);
|
|
210
217
|
/** Read the experiment and Claude's work for one initiative, at most every 30 s; done() runs when the answer changed what shows. */
|
|
211
218
|
export function want(ws, id, done, title) {
|
|
@@ -215,16 +222,19 @@ export function want(ws, id, done, title) {
|
|
|
215
222
|
if (WANT.has(k)) return;
|
|
216
223
|
const q = ws ? 'ws=' + encodeURIComponent(ws) + '&' : '';
|
|
217
224
|
const p = Promise.all([pmGet('/api/artefacts?' + q + 'scope=' + encodeURIComponent('experiment:' + id)).catch(() => null), pmGet('/api/autonomy' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null),
|
|
218
|
-
pmGet('/api/autonomy/ahead?' + q + 'ini=' + encodeURIComponent(id) + (title ? '&title=' + encodeURIComponent(title) : '')).catch(() => null)
|
|
219
|
-
.
|
|
225
|
+
pmGet('/api/autonomy/ahead?' + q + 'ini=' + encodeURIComponent(id) + (title ? '&title=' + encodeURIComponent(title) : '')).catch(() => null),
|
|
226
|
+
pmGet('/api/kind-control?' + q + 'ini=' + encodeURIComponent(id)).catch(() => null)])
|
|
227
|
+
.then(([a, u, h, k]) => {
|
|
220
228
|
const M = agentModel(a && a.ok ? a : null, u && u.ok ? u : null, id, { ahead: h && h.ok ? h : null });
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
const C = k && k.ok && k.kind !== 'product' ? k : null;
|
|
230
|
+
const was = JSON.stringify([cached(id), cachedControl(id)]);
|
|
231
|
+
CACHE.set(id, { M, C, at: Date.now() });
|
|
232
|
+
if (JSON.stringify([M, C]) !== was && done) done();
|
|
224
233
|
}).finally(() => WANT.delete(k));
|
|
225
234
|
WANT.set(k, p);
|
|
226
235
|
}
|
|
227
236
|
const forget = (id) => { const c = CACHE.get(id); if (c) c.at = 0; };
|
|
237
|
+
export { forget };
|
|
228
238
|
export function toggleMore(id) { if (OPEN.has(id)) OPEN.delete(id); else OPEN.add(id); }
|
|
229
239
|
/** Coming up's own "N more" and "Fewer", kept apart from PMOS's work. */
|
|
230
240
|
export const cuOpen = (id) => OPEN.has('cu|' + id);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* pm/ini-kind.js — the Viewer's part for a Project or a Full SDLC initiative (launch simulation W5; main canvas boards WfA and WfB, agreed by
|
|
2
|
+
* Wawan 2026-11-12). Pure: Node imports it (kind-control.test.js). pm/ini-agent.js reads GET /api/kind-control with the experiment and draws
|
|
3
|
+
* this inside the same holder, so no new pattern: the PMOS's work row shape, the one ✦ proposal with icon-only ✓ and ✕.
|
|
4
|
+
*
|
|
5
|
+
* controlHtml(C, o) → '' | the section C: the route's answer (lib/kind-control.js). o: { hidden: Set of dismissed proposal keys }
|
|
6
|
+
* proposalKey(C) → the key a ✕ hides for this session
|
|
7
|
+
*
|
|
8
|
+
* PROJECT (WfA): "On track for <date>?" first (amber on a No, with the cause), then the ✦ (move the go-live milestone to its forecast; the
|
|
9
|
+
* goal and the title stay: they are Wawan's), the critical path in one line, then each task with its colour, its owner and a bar: the
|
|
10
|
+
* outline is the baseline, the fill is now. Colour comes from dates and links, never from a status someone typed. A task that is on time
|
|
11
|
+
* and has float shows only its bar (zero is silence).
|
|
12
|
+
* FULL SDLC (WfB): nothing beyond the gate, which the stage card draws (the Experiment's Who builds line is the honest one).
|
|
13
|
+
* The kind change line ("Kind changed to Project: …") shows once, at the top. */
|
|
14
|
+
|
|
15
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
16
|
+
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
17
|
+
const P = { check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', path: 'M4 12h4l3-6 3 12 3-6h3', info: 'M12 8v.01M11 12h1v5h1M12 3.5a8.5 8.5 0 1 0 0 17a8.5 8.5 0 1 0 0-17' };
|
|
18
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
|
+
const dm = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
20
|
+
const dn = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5 : null; };
|
|
21
|
+
const RAG = { r: 'late', a: 'risk', g: 'ok', done: 'done', n: 'none' };
|
|
22
|
+
const RAG_WORDS = { r: 'Late, moves go-live', a: 'Slipping', g: 'On time', done: 'Done', n: 'No dates' };
|
|
23
|
+
|
|
24
|
+
export const proposalKey = (C) => (C && C.proposal ? C.proposal.task + '>' + C.proposal.to : '');
|
|
25
|
+
|
|
26
|
+
/** The bars: one scale for every row, from the earliest date to the latest of baseline and now. */
|
|
27
|
+
function scaleOf(rows) {
|
|
28
|
+
let lo = null, hi = null;
|
|
29
|
+
for (const r of rows) for (const x of [r.base.start, r.base.due, r.now.start, r.now.due]) { const n = dn(x); if (n == null) continue; lo = lo == null ? n : Math.min(lo, n); hi = hi == null ? n : Math.max(hi, n); }
|
|
30
|
+
return lo == null ? null : { lo, span: Math.max(1, hi - lo + 1) };
|
|
31
|
+
}
|
|
32
|
+
function barHtml(r, S) {
|
|
33
|
+
if (!S) return '';
|
|
34
|
+
const pc = (a, b) => { const s = dn(a), e = dn(b); if (s == null && e == null) return null; const x = s == null ? e : s, y = e == null ? s : e; return { l: ((x - S.lo) / S.span) * 100, w: Math.max(1.5, ((y - x + 1) / S.span) * 100) }; };
|
|
35
|
+
const b = pc(r.base.start, r.base.due), n = pc(r.now.start, r.now.due);
|
|
36
|
+
// an SVG, so the geometry is attributes, not an inline style (conformance R28-1); the colour is a class
|
|
37
|
+
const at = (g) => `x="${g.l.toFixed(2)}%" width="${g.w.toFixed(2)}%"`;
|
|
38
|
+
return `<svg class="ik-tl" aria-hidden="true" width="100%" height="16">${b ? `<rect class="bb" ${at(b)} y="1.5" height="4" rx="2"/>` : ''}${n ? `<rect class="ab ${RAG[r.rag] || 'none'}" ${at(n)} y="8" height="7" rx="3.5"/>` : ''}</svg>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function controlHtml(C, o = {}) {
|
|
42
|
+
if (!C || !C.kind || C.kind === 'product') return '';
|
|
43
|
+
const line = C.line ? `<p class="ia-note ik-line">${esc(C.line)}</p>` : '';
|
|
44
|
+
if (C.kind !== 'project') return line ? `<section class="ia-sec ik" aria-label="Kind of work">${line}</section>` : '';
|
|
45
|
+
const T = C.ontrack || {};
|
|
46
|
+
const head = T.date ? 'On track for ' + dm(T.date) + '?' : 'On track?';
|
|
47
|
+
const card = T.answer ? `<div class="ik-card${T.answer === 'no' ? ' am' : ''}"><b>${esc(head)}</b><span>${esc(T.words || '')}</span>${T.why ? `<span>${esc(T.why)}</span>` : ''}${T.src ? `<em>${esc(T.src)}</em>` : ''}</div>` : '';
|
|
48
|
+
const hidden = o.hidden instanceof Set ? o.hidden : new Set();
|
|
49
|
+
const pk = proposalKey(C);
|
|
50
|
+
const prop = C.proposal && !hidden.has(pk) ? `<div class="ik-card pr"><b><span class="you" aria-hidden="true">✦</span> PMOS proposes</b><span>${esc(C.proposal.text)}</span>`
|
|
51
|
+
+ `<span class="ia-eb"><button type="button" class="yd-ok sm" data-ik-ok="${esc(C.proposal.task)}" data-ik-to="${esc(C.proposal.to)}" aria-label="${esc('Approve: move ' + C.proposal.title + ' to ' + dm(C.proposal.to))}" title="Approve">${SVG(P.check, 16, 2.6)}</button>`
|
|
52
|
+
+ `<button type="button" class="yd-alt sm" data-ik-no="${esc(pk)}" aria-label="Dismiss" title="Dismiss">${SVG(P.x, 16, 2)}</button></span></div>` : '';
|
|
53
|
+
const crit = C.critical && C.critical.length ? `<div class="ia-dr ik-cp"><span class="ck up" aria-hidden="true">${SVG(P.path, 12, 2.2)}</span><span><b>${esc(C.critical.join(' → '))}</b><em>Critical path: ${esc(C.critical.length + ' of ' + (C.rows || []).length)} tasks. A day lost on any of them is a day lost on go-live.</em></span></div>` : '';
|
|
54
|
+
const S = scaleOf(C.rows || []);
|
|
55
|
+
const row = (r) => `<div class="ia-dr ik-r" data-rag="${esc(r.rag)}"><span class="ik-dot ${RAG[r.rag] || 'none'}" role="img" aria-label="${esc(RAG_WORDS[r.rag] || '')}"></span><span><b${r.critical ? ' class="ik-crit"' : ''}>${esc((r.milestone ? '◇ ' : '') + r.title)}</b>`
|
|
56
|
+
+ `<em>${esc([r.owner ? r.owner + (r.ownerLinked ? '' : ' (not in People)') : 'No owner', r.critical ? 'critical path' : r.rag === 'g' ? 'has float' : '', r.rag === 'g' || r.rag === 'done' ? '' : r.words].filter(Boolean).join(' · '))}</em>${barHtml(r, S)}</span></div>`;
|
|
57
|
+
const rows = (C.rows || []).length ? `<div class="iv-folds">${C.rows.map(row).join('')}<p class="ia-note">Outline is the baseline${C.baselineAt ? ', set ' + esc(dm(C.baselineAt)) : ''}; the filled bar is now. Colour comes from dates and links, never from a status someone typed.</p></div>` : '';
|
|
58
|
+
return `<section class="ia-sec ik" aria-label="Project control" data-ik><div class="ia-th"><b>Project control</b></div>${line}${card}${prop}${crit}${rows}</section>`;
|
|
59
|
+
}
|
|
@@ -1356,3 +1356,26 @@ button.ia-xr:hover { background: var(--cz-well); }
|
|
|
1356
1356
|
.ia .yd-ok { background: var(--cz-blue); color: var(--cz-onsolid); }
|
|
1357
1357
|
.ia .yd-alt { background: var(--cz-well); color: var(--cz-ink2); }
|
|
1358
1358
|
.ia .yd-alt:disabled { opacity: .5; cursor: default; }
|
|
1359
|
+
|
|
1360
|
+
/* W5 (boards WfA, WfB): Project control — on track, the ✦, the critical path, each task's colour and baseline against now (pm/ini-kind.js) */
|
|
1361
|
+
.ik-line { padding: 0 2px 4px; }
|
|
1362
|
+
.ik-card { display: flex; flex-direction: column; gap: 4px; margin: 0 0 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--cz-hair); background: var(--cz-card); font-size: var(--fs-meta); line-height: 1.45; }
|
|
1363
|
+
.ik-card > b { font-weight: var(--fw-strong); }
|
|
1364
|
+
.ik-card em { font-style: normal; font-size: var(--fs-label); color: var(--cz-ink3); }
|
|
1365
|
+
.ik-card.am { background: var(--cz-latebg); color: var(--cz-late); border-color: transparent; }
|
|
1366
|
+
.ik-card.pr .you { color: var(--cz-blue); }
|
|
1367
|
+
.ik-card .ia-eb { margin-top: 6px; }
|
|
1368
|
+
.ik-r > span:not(.ik-dot) { flex: 1; min-width: 0; }
|
|
1369
|
+
.ik-crit { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
|
|
1370
|
+
.ik-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--cz-hair); }
|
|
1371
|
+
.ik-dot.ok { background: var(--cz-ok); }
|
|
1372
|
+
.ik-dot.risk { background: var(--cz-risk); }
|
|
1373
|
+
.ik-dot.late { background: var(--cz-late); }
|
|
1374
|
+
.ik-dot.done { background: var(--cz-ink3); }
|
|
1375
|
+
.ik-tl { display: block; margin-top: 4px; overflow: visible; }
|
|
1376
|
+
.ik-tl .bb { fill: none; stroke: var(--cz-ink3); stroke-width: 1; }
|
|
1377
|
+
.ik-tl .ab { fill: var(--cz-hair); }
|
|
1378
|
+
.ik-tl .ab.ok { fill: var(--cz-ok); }
|
|
1379
|
+
.ik-tl .ab.risk { fill: var(--cz-risk); }
|
|
1380
|
+
.ik-tl .ab.late { fill: var(--cz-late); }
|
|
1381
|
+
.ik-tl .ab.done { fill: var(--cz-ink3); }
|
|
@@ -411,7 +411,7 @@ const VIEWED = new Map(); // initiative id → the view drawn last (the ✦ in
|
|
|
411
411
|
const OPTS = new Map(); // initiative id → the options it was drawn with, so About can draw alone when its description arrives
|
|
412
412
|
export function viewHtml(v, o = {}) {
|
|
413
413
|
// agent-run (AwB): with an experiment on record the gate to Build reads its done test and kill condition (D107), not PRD and rubric
|
|
414
|
-
const AM = v && v.id ? IA.cached(v.id) : null, ag = IA.gateOf(AM);
|
|
414
|
+
const AM = v && v.id ? IA.cached(v.id) : null, ag = (v && v.id && IA.kindGate(v.id)) || IA.gateOf(AM); // W5: a Project's or Full SDLC's own gate first
|
|
415
415
|
if (ag && v.stage) v = { ...v, stage: { ...v.stage, gate: ag } };
|
|
416
416
|
if (v && v.id) { VIEWED.set(v.id, v); OPTS.set(v.id, o); }
|
|
417
417
|
// a merged initiative leads with where its work went, and draws no stage or tasks (they moved; its folds stay); an open one shows Claude's split or merge card under the summary (batch 11 item 14)
|
|
@@ -433,7 +433,7 @@ export function wireView(body, h) {
|
|
|
433
433
|
const agent = (id) => { if (id && VIEWED.has(id)) IA.want(wsOf(), id, () => paintAgent(id), (VIEWED.get(id) || {}).title); };
|
|
434
434
|
const paintAgent = (id) => {
|
|
435
435
|
if (idOf() !== id || !VIEWED.has(id)) return;
|
|
436
|
-
const v0 = VIEWED.get(id), M = IA.cached(id), g = IA.gateOf(M), v = g ? { ...v0, stage: { ...v0.stage, gate: g } } : v0;
|
|
436
|
+
const v0 = VIEWED.get(id), M = IA.cached(id), g = IA.kindGate(id) || IA.gateOf(M), v = g ? { ...v0, stage: { ...v0.stage, gate: g } } : v0;
|
|
437
437
|
VIEWED.set(id, v);
|
|
438
438
|
// replace only what changed: a node another press holds (a task card's day picker) is never swapped for an identical copy
|
|
439
439
|
const swap = (n, html) => { const t = document.createElement('template'); t.innerHTML = html; const x = t.content.firstElementChild; if (!x || !x.isEqualNode(n)) n.outerHTML = html; };
|
|
@@ -487,6 +487,9 @@ export function wireView(body, h) {
|
|
|
487
487
|
if (d.iaUndo) { e.preventDefault(); IA.undo(b, wsOf(), () => paintAgent(id), H.toast); return; }
|
|
488
488
|
if ('iaMore' in d) { e.preventDefault(); IA.toggleMore(id); paintAgent(id); return; }
|
|
489
489
|
if ('iaCumore' in d) { e.preventDefault(); IA.toggleCu(id); paintAgent(id); return; }
|
|
490
|
+
// W5 (WfA): the ✦ moves the go-live milestone to its forecast, through the same quick date change as the task row (Undo in the toast)
|
|
491
|
+
if (d.ikOk) { e.preventDefault(); if (H.dates) { H.dates(d.ikOk, { due: d.ikTo }); IA.forget(id); setTimeout(() => IA.want(wsOf(), id, () => paintAgent(id)), 400); } return; }
|
|
492
|
+
if (d.ikNo) { e.preventDefault(); IA.dismiss(d.ikNo); paintAgent(id); return; }
|
|
490
493
|
if (d.ivMc) { e.preventDefault(); const M = MD.measuresOf(id); mcToggle(id, d.ivMc, { proposal: !!(M && M.mode === 'open') }); if (H.redraw) H.redraw(); later(b, (r) => r.querySelector(`[data-iv-mc="${d.ivMc}"]`), true); return; }
|
|
491
494
|
if (d.abMore && AB.pressMore(b, H.redraw)) { e.preventDefault(); return; }
|
|
492
495
|
if (d.md && MD.press(b, { redraw: H.redraw, toast: H.toast })) { e.preventDefault(); return; }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "launch simulation W5 (2026-11-12): the kind of work sets the default workflow and gate; Project control (colours, critical path, on track, the ✦), the Full SDLC gate, rehearse end on a Project, a Project's Jira draft as a work breakdown.",
|
|
3
|
+
"modules": ["kind-workflows.test.js"],
|
|
4
|
+
"seconds": { "kind-workflows.test.js": 4 }
|
|
5
|
+
}
|