create-pmos 0.536.0 → 0.538.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 +81 -33
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/board-columns-test.js +11 -10
- package/workspace/board-programs-test.js +27 -24
- package/workspace/board-publish-ui-test.js +19 -15
- package/workspace/board-shared-ui-test.js +16 -13
- package/workspace/board-workflows-test.js +26 -32
- package/workspace/briefing-premium-board-test.js +70 -50
- package/workspace/briefing-premium-insights-test.js +24 -31
- package/workspace/briefing-premium-metrics-test.js +2 -2
- package/workspace/calm-timeline-test.js +1 -1
- package/workspace/changelog.json +80 -0
- package/workspace/ev-everywhere-test.js +4 -5
- package/workspace/fixtures/board-premium-facts.js +1 -1
- package/workspace/fixtures/board-workflows-facts.js +7 -1
- package/workspace/fixtures/initiative-premium-facts.js +1 -1
- package/workspace/fixtures/insights-premium-facts.js +6 -6
- package/workspace/fixtures/program-ascent.js +1 -1
- package/workspace/guide/adler.md +2 -2
- package/workspace/guide/agent-capabilities.md +38 -6
- package/workspace/guide/board.md +20 -2
- package/workspace/guide/claude-proposes.md +1 -1
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +3 -3
- package/workspace/guide/intelligence-okr-goals.md +18 -7
- package/workspace/guide/lifecycle.md +2 -2
- package/workspace/guide/programs.md +2 -2
- package/workspace/guide/reports-needs-you.md +5 -5
- package/workspace/guide/settings.md +14 -11
- package/workspace/guide/workflows.md +3 -3
- package/workspace/guide/your-impact.md +1 -1
- package/workspace/lib/agent-team.js +262 -0
- package/workspace/lib/ai-cli.js +36 -4
- package/workspace/lib/bg-queue.js +9 -4
- package/workspace/lib/board-premium.js +6 -3
- package/workspace/lib/goal-source.js +77 -0
- package/workspace/lib/grill-runs.js +6 -3
- package/workspace/lib/headless.js +36 -4
- package/workspace/lib/idle-lab-engine.js +7 -6
- package/workspace/lib/initiative-premium.js +6 -3
- package/workspace/lib/insights-premium.js +1 -1
- package/workspace/lib/job-graph.js +191 -0
- package/workspace/lib/okr-goals.js +3 -0
- package/workspace/lib/orchestrator-keeprate.js +108 -7
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/proposal-runs.js +8 -5
- package/workspace/lib/proposals.js +32 -2
- package/workspace/lib/report-slots.js +14 -10
- package/workspace/lib/routes-boards.js +2 -2
- package/workspace/lib/routes-insights-premium.js +11 -4
- package/workspace/lib/routes-premium-dashboards.js +20 -6
- package/workspace/lib/routes-proposals.js +10 -5
- package/workspace/lib/routes-your-move.js +6 -7
- package/workspace/lib/status-proof.js +45 -0
- package/workspace/lib/status-signal.js +4 -2
- package/workspace/lib/task-links.js +3 -1
- package/workspace/lib/team-cli.js +164 -0
- package/workspace/lib/team-runs.js +244 -0
- package/workspace/lib/verify-runs.js +112 -0
- package/workspace/okr-goals-ui-test.js +10 -13
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-backlog-test.js +2 -2
- package/workspace/premium-vw-jira-test.js +2 -2
- package/workspace/public/pm/bd-acts.js +30 -45
- package/workspace/public/pm/bd-ini-panel.js +38 -27
- package/workspace/public/pm/bd-publish.js +1 -1
- package/workspace/public/pm/bd-span.js +2 -1
- package/workspace/public/pm/bd-views.js +7 -5
- package/workspace/public/pm/bd-wf.js +5 -28
- package/workspace/public/pm/c3-ini-ui.js +9 -7
- package/workspace/public/pm/cozy-board.css +75 -31
- package/workspace/public/pm/cozy-insights.css +18 -0
- package/workspace/public/pm/cozy-nav.js +2 -2
- package/workspace/public/pm/cozy-search.js +29 -7
- package/workspace/public/pm/cozy-settings.js +39 -20
- package/workspace/public/pm/home-data.js +3 -1
- package/workspace/public/pm/home-ini-model.js +15 -1
- package/workspace/public/pm/home-ini.js +9 -3
- package/workspace/public/pm/ini-tail.js +61 -0
- package/workspace/public/pm/ini-view-model.js +10 -7
- package/workspace/public/pm/premium-board.js +119 -119
- package/workspace/public/pm/premium-insights.js +95 -112
- package/workspace/public/pm/premium-report-intel.js +3 -2
- package/workspace/public/pm/readonly.js +4 -3
- package/workspace/public/pm/stage-chip.js +2 -1
- package/workspace/public/pm/status-proof.js +43 -0
- package/workspace/public/premium-board.html +14 -35
- package/workspace/public/premium-intelligence.html +7 -9
- package/workspace/server.js +35 -1
- package/workspace/sort-order-test.js +10 -8
- package/workspace/test-files.json +4 -2
- package/workspace/test-lists/agent-team.json +9 -0
- package/workspace/test-lists/job-graph.json +11 -0
- package/workspace/test-lists/status-proof.json +5 -0
- package/workspace/workflows-setup-test.js +3 -2
- package/workspace/public/premium-chat.html +0 -14
- package/workspace/public/premium-initiative.html +0 -15
- package/workspace/public/premium-work.html +0 -14
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
* end { ini, run, ok, stopped? } the run ended (stopped: the PM pressed ■)
|
|
34
34
|
* propose { ini, board, run, id, group, type, section, title, why, sources: [{ label, ref }], items: [item], data }
|
|
35
35
|
* an agent filed it (`pmos propose …`); the last line for an id wins, so a newer run replaces what it files again
|
|
36
|
-
* drop { ini, sig, facts?, why? }
|
|
36
|
+
* drop { ini, sig, id?, group?, type?, facts?, why? } id, group, type: which proposal (OS evaluation T1).
|
|
37
|
+
* why: the PM's reason, when given (the idle lab learns from it). ✕ on a proposal or on one item of it: gone until its evidence changes (a new signature) or the date
|
|
37
38
|
* passes again. `facts` (batch 24 item 6) are what the ✕ rests on, not where the work sits: a date proposal's facts are its tasks
|
|
38
39
|
* and the due dates they missed, a grill finding's are its angle and its sources. A ✕ holds while they hold, so a workflow switch
|
|
39
40
|
* (new section keys, so new ids and signatures), a reworded reason or a new day (new computed dates) does not bring it back
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
*
|
|
48
49
|
* ledgerFile(dir) · read(dir) → fold · readLines(file) · append(dir, actor, line)
|
|
49
50
|
* fold(lines) PURE → { props, drops, kept, undone, looks, t }
|
|
51
|
+
* lessonsOf(lines, { ini, match, n }) PURE → the last n reasons the PM gave one job on one initiative (✕ why, ✎ rewrites), newest first
|
|
50
52
|
* clean(group, type, input) → { prop } | { error } what `pmos propose` checks
|
|
51
53
|
* sigOf(p) · itemSig(p, x)
|
|
52
54
|
* tidyName(from, to) → '' when `to` keeps the standard (rule 5), else the reason it does not
|
|
@@ -225,6 +227,34 @@ function fold(lines) {
|
|
|
225
227
|
}
|
|
226
228
|
return { props, drops, dropWhy, kept, undone, looks, epoch, t };
|
|
227
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* PURE. What the PM taught one job on one initiative (OS evaluation T1, the learning edge): the reasons given with ✕ and the rewrites made
|
|
232
|
+
* with ✎, newest first, at most n. lines: the ledger, oldest first; match(p) → true for a proposal { group, type } of the job.
|
|
233
|
+
* → [string] each one line, ready for the job's prompt. A drop PMOS wrote itself (by `pmos:…`) teaches nothing.
|
|
234
|
+
*/
|
|
235
|
+
function lessonsOf(lines, { ini, match, n = 3 } = {}) {
|
|
236
|
+
const byId = new Map(), bySig = new Map(), out = [];
|
|
237
|
+
for (const l of lines || []) {
|
|
238
|
+
if (!isObj(l)) continue;
|
|
239
|
+
if (l.kind === 'propose' && str(l.id) && l.ini === ini) {
|
|
240
|
+
if (!match(l)) continue;
|
|
241
|
+
byId.set(l.id, l);
|
|
242
|
+
const p = { id: l.id, why: l.why, sources: Array.isArray(l.sources) ? l.sources : [], items: Array.isArray(l.items) ? l.items.filter(isObj) : [] };
|
|
243
|
+
bySig.set(sigOf(p), l); for (const x of p.items) bySig.set(itemSig(p, x), l);
|
|
244
|
+
} else if (l.kind === 'drop' && l.ini === ini && str(l.why) && !(typeof l.by === 'string' && l.by.startsWith('pmos:'))) {
|
|
245
|
+
const p = (str(l.id) && byId.get(l.id)) || bySig.get(str(l.sig)) || (str(l.group) && match(l) ? l : null);
|
|
246
|
+
if (p) out.push(`✕ on "${one(p.title || p.type || 'a proposal', 90)}": ${one(l.why, 200)}`);
|
|
247
|
+
} else if (l.kind === 'keep' && l.ini === ini) {
|
|
248
|
+
for (const w of Array.isArray(l.wrote) ? l.wrote : []) {
|
|
249
|
+
if (!isObj(w) || !isObj(w.edited)) continue;
|
|
250
|
+
const ids = Array.isArray(l.ids) ? l.ids : [];
|
|
251
|
+
if (!ids.some((id) => byId.has(String(id)))) continue;
|
|
252
|
+
out.push(`✎ you rewrote "${one(w.edited.from, 90)}" as "${one(w.edited.to, 120)}"`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return out.reverse().slice(0, n);
|
|
257
|
+
}
|
|
228
258
|
/** The kept proposal ids (a batch undone gives its proposals back). */
|
|
229
259
|
const keptIds = (F) => { const s = new Set(); for (const k of F.kept) if (!F.undone.has(k.batch)) for (const id of k.ids) s.add(id); return s; };
|
|
230
260
|
/** What was kept that has no other store: the found documents, the Linked entries and the dates past stages ran. */
|
|
@@ -413,6 +443,6 @@ function decorate(rows, F, items, o = {}) {
|
|
|
413
443
|
}
|
|
414
444
|
|
|
415
445
|
module.exports = {
|
|
416
|
-
LEDGER, GROUPS, TYPES, SOURCES, SOURCE_NAMES, RISK_DAYS, ledgerFile, read, readLines, append, fold, clean, idOf, sigOf, itemSig, factsOf, tidyName, taskOf, lateOf,
|
|
446
|
+
LEDGER, GROUPS, TYPES, SOURCES, SOURCE_NAMES, RISK_DAYS, ledgerFile, read, readLines, append, fold, lessonsOf, clean, idOf, sigOf, itemSig, factsOf, tidyName, taskOf, lateOf,
|
|
417
447
|
datesOf, viewOf, foundOf, historyOf, decorate, keptIds, newBatch, dn, isoN, md, hash, workday,
|
|
418
448
|
};
|
|
@@ -30,27 +30,31 @@ function slotError(d) {
|
|
|
30
30
|
if (!isObj(d)) return 'data is the component\'s object: { kind, ref, form }';
|
|
31
31
|
for (const k of Object.keys(d)) if (!['kind', 'ref', 'form', 'snapshot'].includes(k)) return `data.${k} is not part of a component slot; it takes kind, ref and form`;
|
|
32
32
|
if (!KINDS.includes(d.kind)) return `data.kind is one of ${KINDS.join(', ')} (the components PMOS can draw on a slide)`;
|
|
33
|
-
if (!/^[A-Za-z0-9_.:-]{1,100}$/.test(str(d.ref))) return 'data.ref
|
|
33
|
+
if (!/^[A-Za-z0-9_.:-]{1,100}$/.test(str(d.ref))) return 'data.ref names the goal the component shows: a key result (a::kr-a1, O-A.KR-A1) or a KR metric record id';
|
|
34
34
|
if (d.form != null && !FORMS.includes(d.form)) return `data.form is one of ${FORMS.join(', ')}`;
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return path.join(root, 'planning', 'records');
|
|
41
|
-
}
|
|
38
|
+
/** The records folder of a workspace (lib/goal-source.js recordsDirOf: pmos/state/records in a product repository, planning/records in PMOS). */
|
|
39
|
+
const recordsDir = (root) => require('./goal-source.js').recordsDirOf(root);
|
|
42
40
|
const stamp = (now) => { const d = new Date(now); return `${d.toISOString().slice(0, 10)} ${d.toISOString().slice(11, 16)}`; };
|
|
43
41
|
|
|
44
42
|
/** Read the record and draw the component. Async: the drawing code is the browser's own module, imported unchanged. */
|
|
45
43
|
async function snapshotOf(root, d, { now = Date.now() } = {}) {
|
|
46
44
|
const e = slotError(d); if (e) return { ok: false, error: e };
|
|
47
45
|
if (d.kind === 'kr') {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
46
|
+
// one goal source (OS evaluation T2): the ref is a goal (a::kr-a1, O-A.KR-A1) or, as before, a record id; it resolves to the record that reads it
|
|
47
|
+
const GSRC = require('./goal-source.js');
|
|
48
|
+
const goals = GSRC.source({ root, recordsDir: recordsDir(root) });
|
|
49
|
+
if (!goals.ok) return { ok: false, error: goals.error };
|
|
50
|
+
const k = GSRC.resolve(goals, d.ref);
|
|
51
|
+
if (!k) {
|
|
52
|
+
const g = GSRC.goalOf(goals, d.ref);
|
|
53
|
+
if (g) return { ok: false, error: `the key result ${g.token} (${g.title}) has no readings yet, so it has no chart` };
|
|
54
|
+
return { ok: false, error: `there is no KR metric record ${d.ref} and no key result by that name. The goals: ${goals.goals.map((x) => x.key).concat(goals.loose.map((x) => x.rid)).slice(0, 12).join(', ') || 'none'}` };
|
|
55
|
+
}
|
|
52
56
|
const today = new Date(now).toISOString().slice(0, 10);
|
|
53
|
-
const o = require('./routes-c3-strategy.js').outcomeOf(k, today);
|
|
57
|
+
const o = require('./routes-c3-strategy.js').outcomeOf(k, today); // k: the record that reads the goal
|
|
54
58
|
const c = require('./insights-premium.js').chartOf(o);
|
|
55
59
|
if (!c) return { ok: false, error: `the KR metric ${d.ref} has fewer than two readings, so it has no chart yet` };
|
|
56
60
|
// Imported as source, not by path: the file has no imports of its own, and a path import makes newer Node print a module-type warning.
|
|
@@ -563,7 +563,7 @@ function boardRow(board, base, folded, lib) {
|
|
|
563
563
|
}
|
|
564
564
|
row.closed = closedOf(row, wx);
|
|
565
565
|
// a finished initiative is never late, at risk or without a signal: its last stage is the PM's own move (batch 26 item 5)
|
|
566
|
-
if (row.closed && ['late', 'at risk', 'no signal'].includes(row.status)) { row.status = 'on track'; row.signal = { from: 'pm', why: 'In its last stage', source: 'the workflow', readAt:
|
|
566
|
+
if (row.closed && ['late', 'at risk', 'no signal'].includes(row.status)) { row.status = 'on track'; row.signal = { from: 'pm', why: 'In its last stage', source: 'the workflow', readAt: new Date().toISOString() }; }
|
|
567
567
|
const w = [];
|
|
568
568
|
if (s.source === 'move') {
|
|
569
569
|
const last = [...folded.moves].reverse().find((m) => m.board === board.id && m.id === base.id);
|
|
@@ -931,7 +931,7 @@ const READS = {
|
|
|
931
931
|
const live = r.rows.filter((x) => !x.archived); // an archived initiative leaves every list and timeline (c3-initiative-lifecycle)
|
|
932
932
|
seedRows(ctx, r.w, r.fr, r.board, live);
|
|
933
933
|
ctx.json(res, { ok: true, ws: r.w.id, board: r.board.id, build: r.board.build, jira: r.board.jira, jiraProjects: r.board.jiraProjects, items: itemsOf(r.w, r.fr, r.board, live),
|
|
934
|
-
initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, owner: x.owner, anchor: x.anchor || '', rank: x.rank, start: x.start, end: x.end, progress: x.progress, template: x.template, epics: x.epics,
|
|
934
|
+
initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, signal: x.signal || null, owner: x.owner, anchor: x.anchor || '', rank: x.rank, start: x.start, end: x.end, progress: x.progress, template: x.template, epics: x.epics,
|
|
935
935
|
stages: (x.wfStages || []).map((st) => ({ key: st.key, name: st.name, milestone: !!st.milestone })), ...(x.wfMap ? { map: x.wfMap } : {}) })) }); // the sections a task can sit in (the task Viewer's move icon)
|
|
936
936
|
},
|
|
937
937
|
'/api/boards/sprints': (ctx, res, url) => {
|
|
@@ -21,6 +21,7 @@ const { recordsDirFor } = require('./records-dir.js');
|
|
|
21
21
|
const reports = require('./routes-reports.js');
|
|
22
22
|
const setups = require('./routes-report-setups.js');
|
|
23
23
|
const PD = require('./premium-dashboards.js');
|
|
24
|
+
const GSRC = require('./goal-source.js'); // one goal source (OS evaluation T2)
|
|
24
25
|
/** The PMOS repository's own workspace: the agent measures (merges, corrections) are read only there. */
|
|
25
26
|
const isSelf = (ctx, b) => { try { return !!(ctx.selfRoot && b && require('path').resolve(ctx.getWs(b.ws).root) === require('path').resolve(ctx.selfRoot)); } catch { return false; } };
|
|
26
27
|
|
|
@@ -84,10 +85,14 @@ module.exports = {
|
|
|
84
85
|
const ws = pick ? pick.ws : wantWs;
|
|
85
86
|
const q = qs({ ws });
|
|
86
87
|
const rp = await via(reports, '/api/report' + q, req, ctx);
|
|
87
|
-
let outcomes, goalMeta = {};
|
|
88
|
+
let outcomes, goalMeta = {}, goalSrc = null;
|
|
88
89
|
try {
|
|
89
90
|
const today = new Date(), pad = (n) => String(n).padStart(2, '0'), day = today.getFullYear() + '-' + pad(today.getMonth() + 1) + '-' + pad(today.getDate());
|
|
90
|
-
|
|
91
|
+
// one goal source (OS evaluation T2): the OKR file's key results and the records that read them come from lib/goal-source.js source(), the only list
|
|
92
|
+
let wroot = null; try { const w0 = ctx.getWs(ws || null); wroot = w0 && w0.root ? require('path').resolve(w0.root) : null; } catch { wroot = null; }
|
|
93
|
+
goalSrc = GSRC.source({ root: wroot, recordsDir: recordsDirFor(ctx, ws) });
|
|
94
|
+
if (!goalSrc.ok) throw new Error(goalSrc.error);
|
|
95
|
+
const krs = goalSrc.records; // an undone ✓ on a drafted metric retires its record (source() leaves it out)
|
|
91
96
|
outcomes = krs.map((k) => strategy.outcomeOf(k, day));
|
|
92
97
|
goalMeta = Object.fromEntries(krs.map((k) => [k.rid, k])); // premium-agreed-design: the fields New goal keeps (type, direction, period, owner, …)
|
|
93
98
|
} catch (e) { return fail('the KR metric records could not be read: ' + ((e && e.message) || e)); }
|
|
@@ -124,12 +129,14 @@ module.exports = {
|
|
|
124
129
|
let okr = null, promises = null;
|
|
125
130
|
if (pick) {
|
|
126
131
|
const root = require('path').resolve(ctx.getWs(pick.ws).root);
|
|
127
|
-
|
|
132
|
+
okr = goalSrc && goalSrc.okr && goalSrc.okr.ok ? goalSrc.okr : null;
|
|
128
133
|
try { promises = promisesOf(require('./outcomes.js').scan(root)); } catch { promises = null; }
|
|
129
134
|
}
|
|
130
135
|
// premium-uncovered-features (IsMenus): the product picker says how many goals each product's workspace records; a workspace that cannot be read says none
|
|
131
136
|
const counts = new Map();
|
|
132
|
-
|
|
137
|
+
// one goal source: a product's goals are its key results plus the records no key result claims (IDPF: 10 key results and 1 record said 1 before)
|
|
138
|
+
const countOf = (w) => { if (w === ws && goalSrc) return goalSrc.count; let r = null; try { const x = ctx.getWs(w); r = x && x.root ? require('path').resolve(x.root) : null; } catch { r = null; } const s = GSRC.source({ root: r, recordsDir: recordsDirFor(ctx, w) }); return s.ok ? s.count : null; };
|
|
139
|
+
const goalsIn = (w) => { if (!counts.has(w)) { let n = null; try { n = countOf(w); } catch { n = null; } counts.set(w, n); } return counts.get(w) === null ? {} : { goals: counts.get(w) }; };
|
|
133
140
|
// batch 16 item 6 ("Claude runs the OKRs"): the reading ledger, each record's own history, and the product's open drafts
|
|
134
141
|
let watch = null, wdir = null;
|
|
135
142
|
if (pick) {
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
const guard = require('./pm-guard.js');
|
|
16
16
|
const PD = require('./premium-dashboards.js');
|
|
17
17
|
const boards = require('./routes-boards.js');
|
|
18
|
-
const { repoScript } = require('./repo-script.js');
|
|
19
18
|
const { recordsDirFor } = require('./records-dir.js');
|
|
20
19
|
|
|
21
20
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
@@ -29,9 +28,17 @@ function wsOf(ctx, id) {
|
|
|
29
28
|
function boardIds(ctx, w) {
|
|
30
29
|
try { return new Set(boards.frameFor(ctx, w).boards.map((b) => b.id)); } catch { return null; }
|
|
31
30
|
}
|
|
32
|
-
/** The
|
|
31
|
+
/** The goal source of a workspace (lib/goal-source.js source(), OS evaluation T2). null when the records cannot be read. */
|
|
32
|
+
function goalSource(ctx, ws) {
|
|
33
|
+
let root = null;
|
|
34
|
+
try { const w = ctx.getWs(ws || null); root = w && w.root ? w.root : null; } catch { root = null; }
|
|
35
|
+
const s = require('./goal-source.js').source({ root, recordsDir: recordsDirFor(ctx, ws) });
|
|
36
|
+
return s.ok ? s : null;
|
|
37
|
+
}
|
|
38
|
+
/** The KR metric ids of a workspace, from the one goal source. null when the records cannot be read. */
|
|
33
39
|
function krIds(ctx, ws) {
|
|
34
|
-
|
|
40
|
+
const s = goalSource(ctx, ws);
|
|
41
|
+
return s ? new Set(s.records.map((k) => k.rid).filter(Boolean)) : null;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
async function handle(req, res, url, ctx) {
|
|
@@ -53,6 +60,12 @@ async function handle(req, res, url, ctx) {
|
|
|
53
60
|
const r = PD.pin(w.root, body, g.actor, { now: Date.now() });
|
|
54
61
|
return send(r.ok ? { status: 200, body: { ok: true, pinned: r.pinned } } : bad(r.status, r.error));
|
|
55
62
|
}
|
|
63
|
+
// one goal source (OS evaluation T2): a chart may name a goal (a::kr-a1, O-A.KR-A1); it is kept as the id of the record that reads it, so the page
|
|
64
|
+
// draws it as before. A goal with no reader stays as named and the check below refuses it.
|
|
65
|
+
if (Array.isArray(body.charts) && body.remove !== true && body.charts.some((x) => typeof x === 'string' && /::|^(?:O[-\w]*\.)?KR/i.test(x))) {
|
|
66
|
+
const src = goalSource(ctx, w.id);
|
|
67
|
+
if (src) body.charts = body.charts.map((x) => { const r = typeof x === 'string' ? require('./goal-source.js').resolve(src, x) : null; return r ? r.rid : x; });
|
|
68
|
+
}
|
|
56
69
|
const c = PD.check(body);
|
|
57
70
|
if (!c.ok) return send(bad(c.status, c.error));
|
|
58
71
|
const ids = boardIds(ctx, w);
|
|
@@ -60,8 +73,9 @@ async function handle(req, res, url, ctx) {
|
|
|
60
73
|
if (!ids.has(c.value.board)) return send(bad(404, 'no such board in this workspace'));
|
|
61
74
|
let known = null;
|
|
62
75
|
if (!c.value.remove) {
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
76
|
+
const src = goalSource(ctx, w.id);
|
|
77
|
+
if (!src) return send(bad(503, 'The KR metric records could not be read, so the charts cannot be checked.'));
|
|
78
|
+
const ks = new Set(src.records.map((k) => k.rid).filter(Boolean));
|
|
65
79
|
for (const pc of require('./premium-charts.js').list(w.root, c.value.board)) ks.add(pc.id); // premium-studio-chart C2: a saved chart of the board
|
|
66
80
|
known = { charts: ks };
|
|
67
81
|
}
|
|
@@ -70,4 +84,4 @@ async function handle(req, res, url, ctx) {
|
|
|
70
84
|
return send({ status: 200, body: { ok: true, dashboard: r.dashboard, dashboards: r.dashboards } });
|
|
71
85
|
}
|
|
72
86
|
|
|
73
|
-
module.exports = { prefixes: ['/api/premium-dashboards'], handle, wsOf, boardIds, krIds };
|
|
87
|
+
module.exports = { prefixes: ['/api/premium-dashboards'], handle, wsOf, boardIds, krIds, goalSource };
|
|
@@ -158,7 +158,9 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
|
158
158
|
if (next) {
|
|
159
159
|
const r = RB.taskAdd(ctx, { ws: p.w.id, board: p.board.id, initiative: ini, title: String(next).slice(0, 200),
|
|
160
160
|
notes: [x.title, x.why, source ? 'From ' + source : ''].filter(Boolean).join('\n').slice(0, 1900) }, g);
|
|
161
|
-
|
|
161
|
+
// ✎: the PM's rewrite is kept beside Claude's words, so the job's next run on this initiative learns from it (PR.lessonsOf)
|
|
162
|
+
const mine = own && x.data && x.data.next && own !== x.data.next ? { edited: { from: String(x.data.next).slice(0, 200), to: own } } : {};
|
|
163
|
+
if (W.ok(r)) add({ op: 'add', task: r.body.item && (r.body.item.uid || r.body.item.id), title: next, to: { start: '', due: '' }, ...mine });
|
|
162
164
|
}
|
|
163
165
|
} else if (x.group === 'status') {
|
|
164
166
|
for (const it of items) {
|
|
@@ -278,18 +280,21 @@ const WRITES = {
|
|
|
278
280
|
if (!/^[sdi]:[0-9a-f]{10}$/.test(sig) || !ini) return fail(ctx, res, 400, 'sig names a proposal or one item of it; initiative is required');
|
|
279
281
|
// what the ✕ rests on (batch 24 item 6): a date proposal's tasks and the dates they missed, a grill finding's angle and sources, so a
|
|
280
282
|
// workflow switch, a reworded reason or a new day does not bring it back. A failure here keeps the plain signature.
|
|
281
|
-
|
|
283
|
+
// which proposal it is (OS evaluation T1): its id, group and type, so the keep rate places the ✕ on its job and the job's next run
|
|
284
|
+
// learns from the reason (lib/orchestrator-keeprate.js, PR.lessonsOf)
|
|
285
|
+
let facts = [], of = null;
|
|
282
286
|
try {
|
|
283
287
|
const v = view(ctx, p, ini, null, { grillAll: true });
|
|
284
288
|
for (const x of v ? v.groups.flatMap((gr) => gr.props) : []) {
|
|
285
|
-
if (x.sig === sig) { facts = PR.factsOf(x); break; }
|
|
289
|
+
if (x.sig === sig) { facts = PR.factsOf(x); of = x; break; }
|
|
286
290
|
const it = (x.items || []).find((y) => y && y.sig === sig);
|
|
287
|
-
if (it) { facts = PR.factsOf(x, it); break; }
|
|
291
|
+
if (it) { facts = PR.factsOf(x, it); of = x; break; }
|
|
288
292
|
}
|
|
289
293
|
} catch { facts = []; }
|
|
294
|
+
const which = of && of.group !== 'links' ? { id: String(of.id || ''), group: String(of.group || ''), type: String(of.type || '') } : {};
|
|
290
295
|
// the PM's reason, when given (the idle lab's ✕ asks for one; Claude learns from it)
|
|
291
296
|
const why = typeof body.why === 'string' ? body.why.replace(/\s+/g, ' ').trim().slice(0, 300) : '';
|
|
292
|
-
PR.append(dirOf(ctx, p.w), g.actor, { kind: 'drop', ini, sig, ...(facts.length ? { facts } : {}), ...(why ? { why } : {}) });
|
|
297
|
+
PR.append(dirOf(ctx, p.w), g.actor, { kind: 'drop', ini, sig, ...which, ...(facts.length ? { facts } : {}), ...(why ? { why } : {}) });
|
|
293
298
|
ctx.json(res, { ok: true });
|
|
294
299
|
},
|
|
295
300
|
'/api/proposals/undo': (ctx, res, body, g, p) => {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* verdicts: the outcome checks past their date with no verdict (lib/outcomes.js scan, less Intelligence's verdicts in
|
|
7
7
|
* lib/insights-records.js), each with Claude's draft from the board's Jira tickets and the board it is on (the ✓ records it there through
|
|
8
|
-
* POST /api/insights-records/verdict). kr: the first key result of the OKR file that waits on a source (lib/
|
|
8
|
+
* POST /api/insights-records/verdict). kr: the first key result of the OKR file that waits on a source (lib/goal-source.js source(), the kr-metrics records
|
|
9
9
|
* as its readers). Read only: nothing is written. A part that cannot be read is left out, never guessed. */
|
|
10
10
|
const YM = require('./your-move.js');
|
|
11
11
|
|
|
@@ -37,13 +37,12 @@ function verdicts(ctx, w, today) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function kr(ctx, w, today) {
|
|
40
|
+
// one goal source (OS evaluation T2): the key results and the records that read them come from lib/goal-source.js source()
|
|
40
41
|
const OG = require('./okr-goals.js');
|
|
41
|
-
const
|
|
42
|
-
if (!okr.ok) return null;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const goals = recs.map((k) => ({ id: k.rid, title: k.title || '', kr: k.kr || null, readings: Array.isArray(k.readings) ? k.readings.length : 0, recipe: k.recipe || null }));
|
|
46
|
-
return YM.krOf(OG.build({ okr, goals, initiatives: [], records: {}, today }));
|
|
42
|
+
const src = require('./goal-source.js').source({ root: w.root, recordsDir: require('./records-dir.js').recordsDirFor(ctx, w.id) });
|
|
43
|
+
if (!src.okr.ok) return null;
|
|
44
|
+
const goals = src.records.map((k) => ({ id: k.rid, title: k.title || '', kr: k.kr || null, goal: k.goal || null, readings: Array.isArray(k.readings) ? k.readings.length : 0, recipe: k.recipe || null }));
|
|
45
|
+
return YM.krOf(OG.build({ okr: src.okr, goals, initiatives: [], records: {}, today }));
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
module.exports = {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* status-proof.js — THE status provenance rule (OS evaluation T3, 8 Nov: "no status word, number or tile renders unless it carries a source
|
|
3
|
+
* and a read time; with none it says No signal"). Three grills found the same class of bug, a confident status from data nobody read; this
|
|
4
|
+
* turns their page fixes (W1, W2, Intelligence design A) into one invariant. lib/status-signal.js decides a status and stamps where it came
|
|
5
|
+
* from; this module is the gate every render goes through. public/pm/status-proof.js is its browser twin (status-proof.test.js holds them equal).
|
|
6
|
+
*
|
|
7
|
+
* proven(sig, now) → true when sig = { source, readAt } names a source and a parseable read time that is not in the future
|
|
8
|
+
* provenStatus(r, now) → r.status when it is a claim ('on track', 'at risk', 'late', 'done', 'on hold', 'cancelled') AND r.signal is
|
|
9
|
+
* proven; else 'no signal'
|
|
10
|
+
* provenValue(v, sig, now) → v when sig is proven, else null (a number or a tile: the caller then says "No signal")
|
|
11
|
+
* fromLine(sig) → 'From Jira · read 3 Nov' for a title or a tooltip; '' when not proven
|
|
12
|
+
* NO_SIGNAL · CLAIMS
|
|
13
|
+
* Pure: no I/O, no clock beyond `now`.
|
|
14
|
+
*/
|
|
15
|
+
const NO_SIGNAL = 'no signal';
|
|
16
|
+
const CLAIMS = Object.freeze(['on track', 'at risk', 'late', 'done', 'on hold', 'cancelled']);
|
|
17
|
+
const SKEW = 5 * 60e3; // a read stamped up to five minutes ahead (another machine's clock) still counts
|
|
18
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
|
+
/** A read time as ms: an ISO string or epoch ms; NaN for anything else. */
|
|
20
|
+
const atOf = (v) => (typeof v === 'number' ? v : typeof v === 'string' && v ? Date.parse(v) : NaN);
|
|
21
|
+
|
|
22
|
+
function proven(sig, now) {
|
|
23
|
+
if (!sig || typeof sig !== 'object') return false;
|
|
24
|
+
const src = typeof sig.source === 'string' ? sig.source.trim() : '';
|
|
25
|
+
if (!src) return false;
|
|
26
|
+
const at = atOf(sig.readAt);
|
|
27
|
+
const t = typeof now === 'number' ? now : Date.now();
|
|
28
|
+
return Number.isFinite(at) && at <= t + SKEW;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function provenStatus(r, now) {
|
|
32
|
+
const s = String((r && r.status) || '').toLowerCase();
|
|
33
|
+
if (!CLAIMS.includes(s)) return NO_SIGNAL;
|
|
34
|
+
return proven(r.signal, now) ? s : NO_SIGNAL;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function provenValue(v, sig, now) { return proven(sig, now) ? v : null; }
|
|
38
|
+
|
|
39
|
+
function fromLine(sig, now) {
|
|
40
|
+
if (!proven(sig, now)) return '';
|
|
41
|
+
const d = new Date(atOf(sig.readAt));
|
|
42
|
+
return 'From ' + String(sig.source).trim() + ' · read ' + d.getUTCDate() + ' ' + MON[d.getUTCMonth()];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { NO_SIGNAL, CLAIMS, proven, provenStatus, provenValue, fromLine };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* development, frame WgW2Status). THE ONE place a row's status is decided. Every surface (the Board's rows and header, Home's product row and
|
|
4
4
|
* card, the weekly update, the program rollups) reads the status this decides; none decides one of its own.
|
|
5
5
|
*
|
|
6
|
-
* statusOf(x) → { status, from, why, source, readAt }
|
|
6
|
+
* statusOf(x) → { status, from, why, source, readAt } source + readAt are set on every status but 'no signal' (T3, lib/status-proof.js)
|
|
7
7
|
* wordsOf(c) → '3 late · 1 at risk · 5 no signal' the pill's words from THE count (scripts/boards.js counts, whose
|
|
8
8
|
* byStatus holds 'no signal' apart: it is never counted as on track); ''
|
|
9
9
|
* when nothing is open
|
|
@@ -59,7 +59,9 @@ function jiraRead(j, now) {
|
|
|
59
59
|
function statusOf(x = {}) {
|
|
60
60
|
const now = typeof x.now === 'number' ? x.now : Date.now();
|
|
61
61
|
const day = x.day || new Date(now).toISOString().slice(0, 10);
|
|
62
|
-
|
|
62
|
+
// T3 (lib/status-proof.js): every status but No signal carries where it came from and when PMOS read it. A record or a date read for this
|
|
63
|
+
// answer is read now; a Jira reading keeps its own fetch time (older than READ_DAYS is not a read at all).
|
|
64
|
+
const out = (status, from, why, source, readAt) => ({ status, from, why: why || '', source: source || '', readAt: readAt || (status === 'no signal' ? null : new Date(now).toISOString()) });
|
|
63
65
|
const st = x.stopped && x.stopped.state;
|
|
64
66
|
const S = x.stage || null;
|
|
65
67
|
// the PM's word
|
|
@@ -333,6 +333,8 @@ function proposalsOf(ini, T, links, F, src = {}) {
|
|
|
333
333
|
}
|
|
334
334
|
return out.slice(0, 30);
|
|
335
335
|
}
|
|
336
|
+
/** The name of a linked task this board does not hold: plain words, never its record id (task-19757a8f77 showed as a row's text). */
|
|
337
|
+
const NOT_HERE = 'a task not on this board';
|
|
336
338
|
const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
|
|
337
339
|
|
|
338
340
|
/**
|
|
@@ -356,7 +358,7 @@ function viewOf(F, ini, o) {
|
|
|
356
358
|
const x = { from: l.from, to: l.to, type: l.type, lag: l.lag, source: l.source, state: 'ok' };
|
|
357
359
|
const oth = a && a.ini !== ini ? a : b && b.ini !== ini ? b : null;
|
|
358
360
|
if (oth) x.other = { ini: oth.ini, title: oth.title, tile: (oth.ini || '').slice(0, 2).toUpperCase() };
|
|
359
|
-
else if (!a || !b) x.other = { ini: '', title: (o.titles && o.titles.get(!a ? l.from : l.to)) ||
|
|
361
|
+
else if (!a || !b) x.other = { ini: '', title: (o.titles && o.titles.get(!a ? l.from : l.to)) || NOT_HERE, tile: '' }; // never the record id as words (UI grill U1)
|
|
360
362
|
if (!a || !b) return x;
|
|
361
363
|
const d = shortOf(needOf(l, a, today), b);
|
|
362
364
|
const aLate = !a.closed && a.e != null && today != null && a.e < today;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* team-cli.js — `pmos team …`: the role agents under the chief of staff (brief agent-team, GO step 3).
|
|
3
|
+
*
|
|
4
|
+
* pmos team roles [--json] every role: what it owns, what wakes it, its class and budget
|
|
5
|
+
* pmos team dispatch <initiative> [--roles a,b] [--json] the chief of staff picks the roles and runs them one after another
|
|
6
|
+
* pmos team dispatch --goal "<goal in words>" [--roles a,b]
|
|
7
|
+
* pmos team status [--json] who works on what, what waits, and the inbox entries of ended dispatches
|
|
8
|
+
* pmos team pause|resume <role|all> stop or restart a role's runs (a running run ends on its own)
|
|
9
|
+
* common: [--root <dir>]
|
|
10
|
+
*
|
|
11
|
+
* INSIDE A ROLE RUN only (the server pins PMOS_TEAM_RUN, _ROLE, _FILE, _ROOT, _INI, _MODE; nothing here takes them as arguments):
|
|
12
|
+
* pmos team wrote <path> record a write; refused outside the role's artifacts, or in propose mode
|
|
13
|
+
* pmos team done "<summary>" [--propose <path> "<what>"] the run's one-line result, and (propose mode) what it would write
|
|
14
|
+
* pmos team verdict <path> pass|fail "<why>" the Evaluator's verdict; refused on work the Evaluator itself wrote
|
|
15
|
+
* A role run cannot dispatch, pause or resume. Exit codes: 0 done, 1 refused, 2 usage.
|
|
16
|
+
*/
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const { execFileSync } = require('child_process');
|
|
20
|
+
const T = require('./agent-team.js');
|
|
21
|
+
const R = require('./team-runs.js');
|
|
22
|
+
|
|
23
|
+
const COMMANDS = { team: ['roles', 'dispatch', 'status', 'pause', 'resume', 'wrote', 'done', 'verdict'] };
|
|
24
|
+
const USAGE = [
|
|
25
|
+
'usage: pmos team roles|dispatch|status|pause|resume — the role agents under the chief of staff',
|
|
26
|
+
' pmos team roles what each role owns, what wakes it, its action class and daily budget',
|
|
27
|
+
' pmos team dispatch <initiative> [--roles spec,eval] pick the roles for an initiative and run them one after another',
|
|
28
|
+
' pmos team dispatch --goal "<goal>" [--roles …] the same for a goal in words (Strategist, Researcher, Evaluator)',
|
|
29
|
+
' pmos team status who works on what, what waits, and the inbox entries of ended dispatches',
|
|
30
|
+
' pmos team pause|resume <role|all> stop or restart a role\'s runs',
|
|
31
|
+
'Inside a role run: pmos team wrote <path> · pmos team done "<summary>" [--propose <path> "<what>"] · pmos team verdict <path> pass|fail "<why>"',
|
|
32
|
+
'every command: [--json] [--root <dir>]',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
function parse(argv) {
|
|
36
|
+
const pos = [], flags = {};
|
|
37
|
+
for (let i = 0; i < argv.length; i++) {
|
|
38
|
+
const a = argv[i];
|
|
39
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
40
|
+
const k = a.slice(2);
|
|
41
|
+
if (k === 'json') { flags.json = true; continue; }
|
|
42
|
+
if (k === 'propose') { (flags.propose = flags.propose || []).push([argv[i + 1], argv[i + 2]]); i += 2; continue; }
|
|
43
|
+
const v = argv[i + 1];
|
|
44
|
+
if (v === undefined || v.startsWith('--')) flags[k] = ''; else { flags[k] = v; i++; }
|
|
45
|
+
}
|
|
46
|
+
return { pos, flags };
|
|
47
|
+
}
|
|
48
|
+
function repoRoot(cwd) {
|
|
49
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
|
|
50
|
+
catch { return cwd; }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now() } = {}) {
|
|
54
|
+
const args = argv[0] === 'team' ? argv.slice(1) : argv.slice();
|
|
55
|
+
const verb = args[0];
|
|
56
|
+
if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
57
|
+
if (!COMMANDS.team.includes(verb)) { say(`unknown team command "${verb}" — one of ${COMMANDS.team.join(', ')}`); return 2; }
|
|
58
|
+
const { pos, flags } = parse(args.slice(1));
|
|
59
|
+
const json = !!flags.json;
|
|
60
|
+
const fail = (error, code = 1) => { say(json ? JSON.stringify({ ok: false, error }) : `✗ ${error}`); return code; };
|
|
61
|
+
const ok = (obj, text) => { say(json ? JSON.stringify({ ok: true, ...obj }) : text); return 0; };
|
|
62
|
+
|
|
63
|
+
const inRun = !!env.PMOS_TEAM_RUN;
|
|
64
|
+
const runVerb = ['wrote', 'done', 'verdict'].includes(verb);
|
|
65
|
+
if (runVerb && !inRun) return fail(`pmos team ${verb} runs only inside a role run, which PMOS starts`);
|
|
66
|
+
if (inRun && ['dispatch', 'pause', 'resume'].includes(verb)) return fail(`a role run cannot ${verb}; only you and the chief of staff can`);
|
|
67
|
+
const root = inRun ? (env.PMOS_TEAM_ROOT || repoRoot(cwd)) : (flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd));
|
|
68
|
+
const dir = inRun && env.PMOS_TEAM_FILE ? path.dirname(env.PMOS_TEAM_FILE) : require('./driver.js').stateDirOf(root, { create: ['dispatch', 'pause', 'resume'].includes(verb) });
|
|
69
|
+
|
|
70
|
+
if (verb === 'roles') {
|
|
71
|
+
const t = T.tableForPage();
|
|
72
|
+
if (json) return ok({ roles: t });
|
|
73
|
+
for (const r of t) {
|
|
74
|
+
say(`${r.initial.padEnd(2)} ${r.name} · class ${r.cls}${r.runs ? ` · up to ${r.budget} runs a day` : ' · runs no model here'}`);
|
|
75
|
+
say(` owns: ${r.what}`);
|
|
76
|
+
if (r.owns.paths.length || r.owns.verbs.length) say(` writes only: ${[...r.owns.paths, ...r.owns.verbs].join(', ')}`);
|
|
77
|
+
say(` wakes on: ${r.triggers.map((x) => (x.on === 'stage' ? `stage ${x.stage}${x.unless ? ' without ' + x.unless : ''}` : x.on === 'written' ? 'a write by another role' : 'a dispatch')).join(', ')}`);
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
if (!dir) return fail('this repository has no PMOS state folder (pmos/state, state or .pmos)');
|
|
82
|
+
|
|
83
|
+
if (verb === 'status') {
|
|
84
|
+
const S = R.status(R.fold(R.read(dir)), { now });
|
|
85
|
+
if (json) return ok(S);
|
|
86
|
+
for (const r of S.roles.filter((x) => x.runs)) {
|
|
87
|
+
const w = r.working.map((x) => x.ini || 'a goal').join(', ');
|
|
88
|
+
say(`${r.name}: ${r.paused ? 'paused' : w ? 'working on ' + w : 'free'}${r.queued ? ` · ${r.queued} waiting` : ''} · ${r.today}/${r.budget} today`);
|
|
89
|
+
}
|
|
90
|
+
for (const d of S.dispatches.slice(0, 5)) say(`dispatch ${d.id} · ${d.target} · ${d.done ? 'ended' : d.steps.map((s) => `${s.role} ${s.state}`).join(' → ')}`);
|
|
91
|
+
for (const e of S.inbox.slice(0, 5)) say(`inbox · ${e.title} · ${e.items.map((i) => `${i.role}: ${i.summary || i.state}`).join(' · ')}`);
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (verb === 'pause' || verb === 'resume') {
|
|
96
|
+
const k = String(pos[0] || '');
|
|
97
|
+
if (!k || (k !== 'all' && !T.roleOf(k))) return fail(`name a role (${Object.keys(T.TEAM).join(', ')}) or all`, 2);
|
|
98
|
+
R.append(dir, { kind: 'pause', role: k, on: verb === 'pause' }, now);
|
|
99
|
+
return ok({ role: k, paused: verb === 'pause' }, `${verb === 'pause' ? '⏸ paused' : '▶ resumed'} ${k === 'all' ? 'the whole team' : T.roleOf(k).name}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (verb === 'dispatch') {
|
|
103
|
+
const goal = typeof flags.goal === 'string' ? flags.goal : null;
|
|
104
|
+
const target = goal != null ? goal : pos[0];
|
|
105
|
+
if (!target) return fail('usage: pmos team dispatch <initiative> | --goal "<goal>"', 2);
|
|
106
|
+
const roles = typeof flags.roles === 'string' && flags.roles ? flags.roles.split(',').map((s) => s.trim()).filter(Boolean) : null;
|
|
107
|
+
if (roles) for (const k of roles) if (!T.roleOf(k)) return fail(`"${k}" is not a role (${Object.keys(T.TEAM).join(', ')})`, 2);
|
|
108
|
+
const facts = goal != null ? {} : R.factsOf(root, target);
|
|
109
|
+
const r = R.dispatch(dir, { kind: goal != null ? 'goal' : 'initiative', target, ws: require('./driver.js').wsIdOf(root), facts, roles, now });
|
|
110
|
+
if (!r.ok) return fail(r.error);
|
|
111
|
+
return ok(r, `✓ dispatched ${r.id}: ${r.roles.map((k) => T.roleOf(k).name).join(' → ')}. The workspace starts them one after another; see pmos team status.`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ── inside a role run ── */
|
|
115
|
+
const role = T.roleOf(env.PMOS_TEAM_ROLE);
|
|
116
|
+
const runId = env.PMOS_TEAM_RUN, ini = env.PMOS_TEAM_INI || null, session = env.PMOS_SESSION || null;
|
|
117
|
+
if (!role) return fail('this run has no role');
|
|
118
|
+
const mode = env.PMOS_TEAM_MODE === 'auto' ? 'auto' : 'propose';
|
|
119
|
+
|
|
120
|
+
if (verb === 'wrote') {
|
|
121
|
+
if (mode !== 'auto') return fail('this run proposes only: file it with pmos team done --propose <path> "<what>"');
|
|
122
|
+
const v = T.mayWrite(role, pos[0], { root });
|
|
123
|
+
if (!v.ok) return fail(`the ${role.name} may not write ${pos[0] || '(nothing)'}: ${v.why}`);
|
|
124
|
+
if (!fs.existsSync(path.join(root, v.rel))) return fail(`${v.rel} is not on disk; write it first`);
|
|
125
|
+
R.append(dir, { kind: 'write', run: runId, role: role.key, session, rel: v.rel, ini, mode }, now);
|
|
126
|
+
try { const A = require('./autonomy.js'); if (typeof A.recordApplied === 'function') A.recordApplied(dir, { job: 'ai:' + role.key, product: ini || null, ref: v.rel, title: `${role.name} wrote ${v.rel}`, cls: role.cls }); } catch { /* the autonomy build is not here yet */ }
|
|
127
|
+
return ok({ rel: v.rel }, `✓ recorded: the ${role.name} wrote ${v.rel}`);
|
|
128
|
+
}
|
|
129
|
+
if (verb === 'done') {
|
|
130
|
+
const summary = pos.join(' ').trim();
|
|
131
|
+
const props = flags.propose || [];
|
|
132
|
+
if (!summary && !props.length) return fail('usage: pmos team done "<summary>" [--propose <path> "<what>"]', 2);
|
|
133
|
+
const good = [];
|
|
134
|
+
for (const [p, what] of props) {
|
|
135
|
+
// a proposal names a file the role owns, or one of its `pmos` verbs (the Delivery lead's tasks, the Strategist's ranking)
|
|
136
|
+
const v = /^pmos\s/.test(String(p || '')) ? { ...T.mayRunVerb(role, p), rel: String(p).trim().replace(/\s+/g, ' ') } : T.mayWrite(role, p, { root });
|
|
137
|
+
if (!v.ok) return fail(`the ${role.name} may not propose ${p || '(nothing)'}: ${v.why}; nothing was filed`);
|
|
138
|
+
if (!String(what || '').trim()) return fail(`say what you would change in ${v.rel}`, 2);
|
|
139
|
+
good.push({ rel: v.rel, what: String(what).slice(0, 400) });
|
|
140
|
+
}
|
|
141
|
+
for (const g of good) R.append(dir, { kind: 'propose', run: runId, role: role.key, rel: g.rel, what: g.what, ini }, now);
|
|
142
|
+
if (summary) R.append(dir, { kind: 'result', run: runId, role: role.key, summary: summary.slice(0, 400) }, now);
|
|
143
|
+
return ok({ proposed: good.length }, `✓ filed${good.length ? ` ${good.length} proposal${good.length > 1 ? 's' : ''}` : ''}${summary ? ' and the result' : ''}`);
|
|
144
|
+
}
|
|
145
|
+
if (verb === 'verdict') {
|
|
146
|
+
if (role.key !== 'eval') return fail('only the Evaluator files a verdict');
|
|
147
|
+
const [p, verdict, ...why] = pos;
|
|
148
|
+
if (!p || !/^(pass|fail)$/.test(String(verdict || '')) || !why.join(' ').trim()) return fail('usage: pmos team verdict <path> pass|fail "<why>"', 2);
|
|
149
|
+
const rel = T.relOf(p, root);
|
|
150
|
+
if (!rel) return fail('the path is empty or outside the repository');
|
|
151
|
+
const F = R.fold(R.read(dir));
|
|
152
|
+
const last = R.lastWriter(F, rel);
|
|
153
|
+
// a proposal is checked too: its "writer" is the run that proposed it
|
|
154
|
+
const prop = last ? null : [...F.proposals].reverse().find((x) => x.rel === rel);
|
|
155
|
+
const writer = last || (prop ? { role: prop.role, run: prop.run, session: null } : null);
|
|
156
|
+
const m = T.mayEvaluate({ run: runId, session }, writer);
|
|
157
|
+
if (!m.ok) return fail(`no verdict on ${rel}: ${m.why}`);
|
|
158
|
+
R.append(dir, { kind: 'verdict', run: runId, rel, verdict, why: why.join(' ').slice(0, 400), of: { run: writer.run, role: writer.role } }, now);
|
|
159
|
+
return ok({ rel, verdict }, `✓ ${verdict} on ${rel}`);
|
|
160
|
+
}
|
|
161
|
+
return fail('unknown command', 2);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = { run, COMMANDS, USAGE };
|