create-pmos 0.446.0 → 0.448.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 +25 -25
- 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/state/discoveries.md +1 -1
- package/workspace/changelog.json +24 -0
- package/workspace/guide/claude-proposes.md +25 -2
- package/workspace/guide/forecast.md +53 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/forecast-cli.js +68 -0
- package/workspace/lib/forecast-tick.js +44 -0
- package/workspace/lib/forecast.js +209 -0
- package/workspace/lib/grill-cli.js +104 -0
- package/workspace/lib/grill-runs.js +172 -0
- package/workspace/lib/grill.js +172 -0
- package/workspace/lib/headless.js +14 -2
- package/workspace/lib/intel-report.js +4 -1
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/proposals.js +11 -4
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-premium.js +26 -1
- package/workspace/lib/routes-forecast.js +44 -0
- package/workspace/lib/routes-insights-premium.js +9 -1
- package/workspace/lib/routes-proposals.js +8 -0
- package/workspace/lib/settings-store.js +5 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-insights.css +4 -0
- package/workspace/public/pm/ini-props.js +1 -1
- package/workspace/public/pm/premium-insights.js +28 -1
- package/workspace/server.js +61 -10
- package/workspace/skills/grill.skill +40 -0
- package/workspace/test-lists/forecast.json +9 -0
- package/workspace/test-lists/grill.json +9 -0
- package/workspace/test-run.js +4 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* grill-cli.js — `pmos grill`: the one write of Claude's grill run, and Claude's checks for the PM to read and set (Grill and Forecast,
|
|
3
|
+
* part G-A; lib/grill.js, lib/grill-runs.js). What a run files waits under the initiative's blue ✦ until the PM's ✓.
|
|
4
|
+
*
|
|
5
|
+
* pmos grill find <angle> --json <file|-> one finding or a list: { "title", "why", "next", "sources": [{ "label", "ref" }], "key"?, "rank"? }
|
|
6
|
+
* pmos grill voices --sources <n> how many stored research and meeting-note sources the run found for Voices
|
|
7
|
+
* pmos grill status the open, kept and dropped findings on this initiative (in a run)
|
|
8
|
+
* pmos grill mode [full|exits|off] when Claude grills by itself (read, or set)
|
|
9
|
+
* pmos grill cap [<dollars>] the monthly credit cap (read, or set)
|
|
10
|
+
* pmos grill spend this month: spent, cap, runs, paused
|
|
11
|
+
*
|
|
12
|
+
* The run verbs need the run's environment (PMOS_GRILL_FILE, _LOG, _INI, _RUN, set by the server); outside a run they refuse. Inside a run
|
|
13
|
+
* the PM's verbs refuse: a run never changes its own mode or cap. Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const G = require('./grill.js');
|
|
16
|
+
const PR = require('./proposals.js');
|
|
17
|
+
|
|
18
|
+
const COMMANDS = { grill: ['find', 'voices', 'status', 'mode', 'cap', 'spend'] };
|
|
19
|
+
const USAGE = [
|
|
20
|
+
'usage: pmos grill find|voices|status|mode|cap|spend — Claude grills an initiative by itself; each finding waits under its ✦',
|
|
21
|
+
' pmos grill find <' + G.ANGLES.join('|') + '> --json <file|->',
|
|
22
|
+
' { "title": "<the finding, one short line>", "why": "<the evidence, one line>", "next": "<one next step>", "sources": [{ "label", "ref" }], "key"?, "rank"?: 1-9 }',
|
|
23
|
+
' voices needs ' + G.VOICES_MIN + ' sources or more and is tagged "' + G.SIMULATED.voices + '"; whatif is tagged "' + G.SIMULATED.whatif + '".',
|
|
24
|
+
' pmos grill voices --sources <n> the stored research and meeting notes you found for Voices (under ' + G.VOICES_MIN + ': no Voices)',
|
|
25
|
+
' pmos grill status',
|
|
26
|
+
' pmos grill mode [full|exits|off] when Claude grills by itself',
|
|
27
|
+
' pmos grill cap [<dollars>] the monthly credit cap; at the cap Claude pauses',
|
|
28
|
+
' pmos grill spend what this month spent',
|
|
29
|
+
'Every finding carries its source and a next step. It waits for the PM\'s ✓. Nothing is sent.',
|
|
30
|
+
];
|
|
31
|
+
const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
|
|
32
|
+
function readJson(src, stdin) {
|
|
33
|
+
let text;
|
|
34
|
+
try { text = src === '-' ? (stdin !== undefined ? String(stdin) : fs.readFileSync(0, 'utf8')) : fs.readFileSync(src, 'utf8'); } catch (e) { return { error: `could not read ${src}: ${String((e && e.message) || e).slice(0, 120)}` }; }
|
|
35
|
+
try { return { body: JSON.parse(text) }; } catch { return { error: 'the input is not JSON' }; }
|
|
36
|
+
}
|
|
37
|
+
const stateOf = (env) => require('./state-root.js').defaultRoot({ env });
|
|
38
|
+
|
|
39
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, stdin, now = Date.now() } = {}) {
|
|
40
|
+
const args = argv[0] === 'grill' ? argv.slice(1) : argv.slice();
|
|
41
|
+
const verb = args[0];
|
|
42
|
+
if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
43
|
+
if (!COMMANDS.grill.includes(verb)) { say(`unknown grill command "${verb}" — one of ${COMMANDS.grill.join(', ')}`); return 2; }
|
|
44
|
+
const inRun = !!env.PMOS_GRILL_RUN;
|
|
45
|
+
|
|
46
|
+
/* ── the PM's verbs ── */
|
|
47
|
+
if (verb === 'mode' || verb === 'cap' || verb === 'spend') {
|
|
48
|
+
const SS = require('./settings-store.js'), dir = stateOf(env);
|
|
49
|
+
if (verb === 'spend') {
|
|
50
|
+
const F = G.read(dir), month = G.monthOf(now), cap = SS.get(dir, 'grill.cap');
|
|
51
|
+
const runs = [...F.runs.values()].filter((r) => G.monthOf(Date.parse(r.at) || 0) === month);
|
|
52
|
+
say(`${month}: spent $${G.spentIn(F, month)} of the $${cap} cap · ${runs.length} ${runs.length === 1 ? 'run' : 'runs'}${F.paused.has(month) ? ' · paused at the cap' : ''}`);
|
|
53
|
+
for (const r of runs.slice(-10)) say(` ${r.at.slice(0, 10)} ${r.ini} · ${r.why} · ${r.ended ? (r.cost != null ? '$' + r.cost : 'cost unknown') : 'running'}`);
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
const key = 'grill.' + verb, val = args[1];
|
|
57
|
+
if (val === undefined) { say(`${key}: ${SS.get(dir, key)}${verb === 'mode' && G.off(env) ? ' (PMOS_GRILL=off wins: off)' : ''}`); return 0; }
|
|
58
|
+
if (inRun) { say('✗ a grill run never changes its own mode or cap'); return 1; }
|
|
59
|
+
const v = verb === 'cap' ? Number(val) : val;
|
|
60
|
+
const r = SS.set(dir, key, v);
|
|
61
|
+
if (!r.ok) { say('✗ ' + r.error); return r.status === 400 ? 2 : 1; }
|
|
62
|
+
say(`${key}: ${r.value !== undefined ? r.value : v}`);
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* ── the run's verbs ── */
|
|
67
|
+
const file = env.PMOS_GRILL_FILE, log = env.PMOS_GRILL_LOG, runId = env.PMOS_GRILL_RUN, ini = env.PMOS_GRILL_INI, board = env.PMOS_GRILL_BOARD || '';
|
|
68
|
+
if (!file || !log || !runId || !ini) { say('✗ pmos grill ' + verb + ' is for Claude\'s grill run. The PM keeps and drops findings under the initiative\'s ✦'); return 1; }
|
|
69
|
+
const L = G.fold(G.readLines(log)), me = L.runs.get(runId);
|
|
70
|
+
if (!me || me.ended) { say('✗ this run is not grilling now (it ended, or it was stopped)'); return 1; }
|
|
71
|
+
const P = PR.fold(PR.readLines(file));
|
|
72
|
+
if (verb === 'status') {
|
|
73
|
+
const kept = PR.keptIds(P), mine = [...P.props.values()].filter((p) => p.ini === ini && p.group === 'grill');
|
|
74
|
+
if (!mine.length) say('nothing filed on ' + ini);
|
|
75
|
+
for (const p of mine) say(`${kept.has(p.id) ? 'kept ' : P.drops.has(PR.sigOf(p)) ? 'dropped' : 'open '} ${p.type} ${p.id} · ${p.title}`);
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
if (verb === 'voices') {
|
|
79
|
+
const n = Number(flag(args, 'sources'));
|
|
80
|
+
if (!Number.isInteger(n) || n < 0) { say('usage: pmos grill voices --sources <n>'); return 2; }
|
|
81
|
+
fs.appendFileSync(log, JSON.stringify({ at: new Date(now).toISOString(), kind: 'voices', run: runId, n }) + '\n');
|
|
82
|
+
say(n >= G.VOICES_MIN ? `voices: ${n} sources` : `voices: ${n} sources, under ${G.VOICES_MIN}: leave Voices out`);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
const angle = args[1];
|
|
86
|
+
if (!G.ANGLES.includes(angle)) { say('✗ the angle is one of ' + G.ANGLES.join(', ')); return 2; }
|
|
87
|
+
if (angle === 'voices' && !(me.voices >= G.VOICES_MIN)) { say(`✗ Voices needs ${G.VOICES_MIN} stored sources or more: run pmos grill voices --sources <n> first, and leave Voices out under ${G.VOICES_MIN}`); return 1; }
|
|
88
|
+
const jsonAt = args.indexOf('--json'), src = jsonAt >= 0 ? args[jsonAt + 1] : null;
|
|
89
|
+
if (!src) { say(`usage: pmos grill find ${angle} --json <file|->`); return 2; }
|
|
90
|
+
const r = readJson(src, stdin); if (r.error) { say('✗ ' + r.error); return 1; }
|
|
91
|
+
let bad = 0;
|
|
92
|
+
for (const x of Array.isArray(r.body) ? r.body : [r.body]) {
|
|
93
|
+
const c = G.finding(angle, x);
|
|
94
|
+
if (c.error) { say('✗ refused: ' + c.error); bad++; continue; }
|
|
95
|
+
const id = G.idOf(ini, angle, String((x && x.key) || c.prop.title).slice(0, 120)), prop = { id, ...c.prop };
|
|
96
|
+
if (P.drops.has(PR.sigOf(prop))) { say(`dropped ${id}: the PM dropped this from the same evidence`); continue; }
|
|
97
|
+
if (PR.keptIds(P).has(id)) { say(`kept ${id}: the PM kept it already`); continue; }
|
|
98
|
+
fs.appendFileSync(file, JSON.stringify({ at: new Date(now).toISOString(), by: null, kind: 'propose', ini, board, run: runId, ...prop }) + '\n');
|
|
99
|
+
say(`filed ${id} · ${angle} · ${c.prop.title}`);
|
|
100
|
+
}
|
|
101
|
+
return bad ? 1 : 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* grill-runs.js — Claude's runs that grill an initiative by themselves (Grill and Forecast, part G-A; lib/grill.js says what and when).
|
|
3
|
+
*
|
|
4
|
+
* create(deps) → { tick(opts), start({ ws, board, ini, why, key, detail, now }), stop(run), active() }
|
|
5
|
+
* promptOf(skill, o) → the prompt of one run. o: { run, why, detail, ini, title, intent, stage, stages, today, open, dropped, budget }
|
|
6
|
+
*
|
|
7
|
+
* ONE RUN KIND (headless kind `grill`, origin `grill:<ws>:<initiative>:<run>`). The run reads the repository, the stored reads, the
|
|
8
|
+
* stored research and meeting notes, and files with `pmos grill find`, pinned by the server to this initiative and run (PMOS_GRILL_FILE,
|
|
9
|
+
* _LOG, _WS, _BOARD, _INI, _RUN). It writes no task, no document and no stage: only the PM's ✓ under the ✦ does. Nothing is sent.
|
|
10
|
+
* At most 1 run at once for the machine; each spends at most its budget (--max-budget-usd), so the monthly cap holds.
|
|
11
|
+
*
|
|
12
|
+
* deps: { workspaces() → [w], isLead(w), stateDirFor(w), runtimeDir(), rowOf(w, id) → { title, intent, stage, stages } | null,
|
|
13
|
+
* exits(w) → [{ ini, board, stage }] (stages about to end), shapes(w) → [{ ini, board, n, end }] (open tasks, latest due),
|
|
14
|
+
* goalInis(w, goalId) → [{ id, endAt, status }] (the initiatives anchored to that goal), checks(w, day) → [{ ini, board, tasks }] (late or at-risk work), turned(dir, sinceIso) → [forecast `turned` line] (lib/forecast.js),
|
|
15
|
+
* setting(key) (lib/settings-store.js get), open(now) → bool, headlessOff() → bool, env, promptFor(skillId), spawn(spec), stop(session), warn }
|
|
16
|
+
*/
|
|
17
|
+
const crypto = require('crypto');
|
|
18
|
+
const G = require('./grill.js');
|
|
19
|
+
const PR = require('./proposals.js');
|
|
20
|
+
|
|
21
|
+
const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
22
|
+
const localDay = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
23
|
+
const MAX = 1;
|
|
24
|
+
const BAD = new Set(['at-risk', 'will-miss']);
|
|
25
|
+
const WHY = {
|
|
26
|
+
exit: 'The initiative is about to leave its stage. Grill it before it does: what would make the next stage fail?',
|
|
27
|
+
forecast: 'Its forecast just turned. Grill it: why, and what would bring it back?',
|
|
28
|
+
move: 'Its scope or dates moved a lot. Grill it: is the plan still the right plan?',
|
|
29
|
+
monthly: 'The monthly look at running work that feels off (it has late work). Grill it.',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function promptOf(skill, o) {
|
|
33
|
+
const list = (a, none) => (a && a.length ? a.map((x) => '- ' + x).join('\n') : '- ' + none);
|
|
34
|
+
return `${skill}\n\nThis run:\n- Run: ${o.run}\n- Why it runs: ${WHY[o.why] || WHY.monthly} (${o.why}${o.detail ? ': ' + one(o.detail, 200) : ''})\n- Today: ${o.today}\n`
|
|
35
|
+
+ `- Initiative: ${o.ini} · ${one(o.title, 140)}${o.intent ? '\n- Its Why: ' + one(o.intent, 600) : ''}\n- Its stage now: ${o.stage || 'the first stage'}\n`
|
|
36
|
+
+ `- Its workflow's stages, in order:\n${list((o.stages || []).map((s) => s.key + ' · ' + s.name), 'not known')}\n`
|
|
37
|
+
+ `- Open findings already under its ✦ (do not file them again):\n${list(o.open, 'none')}\n`
|
|
38
|
+
+ `- Dropped by the PM (do not file these again unless the evidence is new):\n${list(o.dropped, 'none')}\n`
|
|
39
|
+
+ `- Your budget: $${o.budget}. Stop when you have your findings.\n\n`
|
|
40
|
+
+ 'File with `pmos grill find` only (the server pins this initiative and run). Send nothing.';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** PURE. Of the initiatives that move a goal, the one to grill: running (not done or stopped), the earliest end first, one with no end last.
|
|
44
|
+
* inis: [{ id, endAt, status }] → id | null */
|
|
45
|
+
function pickFor(inis) {
|
|
46
|
+
const run = (inis || []).filter((x) => x && x.id && !/^(done|stopped|archived|won't do)$/i.test(String(x.status || '')));
|
|
47
|
+
run.sort((a, b) => (a.endAt ? 0 : 1) - (b.endAt ? 0 : 1) || String(a.endAt || '').localeCompare(String(b.endAt || '')));
|
|
48
|
+
return run.length ? run[0].id : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function create(deps) {
|
|
52
|
+
const active = new Map(); // run → { session }
|
|
53
|
+
const warn = deps.warn || (() => {});
|
|
54
|
+
const lastScan = new Map(); // ws → ms
|
|
55
|
+
const runtime = () => (deps.runtimeDir ? deps.runtimeDir() : null);
|
|
56
|
+
const isOff = (env) => G.modeOf(deps.setting, env || deps.env) === 'off' || !!(deps.headlessOff && deps.headlessOff());
|
|
57
|
+
const cap = () => { let c = 10; try { c = Number(deps.setting ? deps.setting('grill.cap') : 10); } catch { c = 10; } return Number.isFinite(c) && c >= 0 ? c : 10; };
|
|
58
|
+
|
|
59
|
+
function ended(run, r, now = Date.now()) {
|
|
60
|
+
if (!active.has(run)) return;
|
|
61
|
+
active.delete(run);
|
|
62
|
+
const res = (r && r.result) || {};
|
|
63
|
+
const ok = !!(r && !r.timedOut && !r.stopped && r.code === 0 && res.ok !== false && !res.isError);
|
|
64
|
+
const cost = Number.isFinite(res.costUsd) ? Math.round(res.costUsd * 10000) / 10000 : null;
|
|
65
|
+
try { G.append(runtime(), { kind: 'end', run, ok, cost, ...(ok ? {} : { error: one((r && r.note) || res.text || 'the run failed', 200) }) }, now); } catch (e) { warn('grill run end', e); }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Start one run now. → { ok, run, budget } | { ok: false, error, paused?, held? } */
|
|
69
|
+
function start({ ws, board, ini, why = 'monthly', key = '', detail = '', now = Date.now() } = {}) {
|
|
70
|
+
if (isOff()) return { ok: false, error: 'Claude\'s grill runs are off (Settings grill.mode, PMOS_GRILL or PMOS_HEADLESS)' };
|
|
71
|
+
if (active.size >= MAX) return { ok: false, held: true, error: 'Claude is already grilling one initiative' };
|
|
72
|
+
const rt = runtime(); if (!rt) return { ok: false, error: 'no runtime state folder' };
|
|
73
|
+
const w = (deps.workspaces() || []).find((x) => x.id === ws);
|
|
74
|
+
if (!w) return { ok: false, error: 'no such workspace' };
|
|
75
|
+
const dir = deps.stateDirFor(w); if (!dir) return { ok: false, error: 'no PMOS state folder' };
|
|
76
|
+
const F = G.read(rt), b = G.budgetFor(F, { cap: cap(), now });
|
|
77
|
+
if (!b.ok) {
|
|
78
|
+
const month = G.monthOf(now);
|
|
79
|
+
// at the cap Claude pauses and says so once a month
|
|
80
|
+
if (!F.paused.has(month)) try { G.append(rt, { kind: 'paused', month, spent: b.spent, cap: cap() }, now); } catch (e) { warn('grill pause', e); }
|
|
81
|
+
return { ok: false, paused: true, error: `Claude paused grilling: this month spent $${b.spent} of the $${cap()} cap` };
|
|
82
|
+
}
|
|
83
|
+
const skill = deps.promptFor('grill');
|
|
84
|
+
if (!skill) return { ok: false, error: 'the grill skill is not installed' };
|
|
85
|
+
const run = 'gr' + now.toString(36) + crypto.randomBytes(3).toString('hex');
|
|
86
|
+
const row = (deps.rowOf && deps.rowOf(w, ini)) || {};
|
|
87
|
+
const P = PR.read(dir), kept = PR.keptIds(P);
|
|
88
|
+
const mine = [...P.props.values()].filter((p) => p.ini === ini && p.group === 'grill');
|
|
89
|
+
const dropped = mine.filter((p) => P.drops.has(PR.sigOf(p))).slice(0, 20).map((p) => one(p.title, 120));
|
|
90
|
+
const open = mine.filter((p) => !P.drops.has(PR.sigOf(p)) && !kept.has(p.id)).slice(0, 20).map((p) => one(p.title, 120));
|
|
91
|
+
const prompt = promptOf(skill, { run, why, detail, ini, title: row.title || ini, intent: row.intent || '', stage: row.stage || '', stages: row.stages || [], today: localDay(now), open, dropped, budget: b.budget });
|
|
92
|
+
active.set(run, { session: null });
|
|
93
|
+
let session = null;
|
|
94
|
+
try {
|
|
95
|
+
session = deps.spawn({ name: 'Grilling · ' + one(row.title || ini, 60), ws, origin: `grill:${ws}:${ini}:${run}`, initialInput: prompt + '\r', initiative: ini,
|
|
96
|
+
env: { PMOS_GRILL_FILE: PR.ledgerFile(dir), PMOS_GRILL_LOG: G.logFile(rt), PMOS_GRILL_WS: ws, PMOS_GRILL_BOARD: board || '', PMOS_GRILL_INI: ini, PMOS_GRILL_RUN: run, PMOS_GRILL_BUDGET: String(b.budget) },
|
|
97
|
+
onDone: (r) => ended(run, r) });
|
|
98
|
+
} catch (e) { warn('grill run', e); }
|
|
99
|
+
if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs; it grills in a minute' }; }
|
|
100
|
+
G.append(rt, { kind: 'start', run, ws, ini, board: board || '', why, key, budget: b.budget }, now);
|
|
101
|
+
if (!session || session.state === 'exited' || session.headless !== 'grill') {
|
|
102
|
+
if (session && session.headless !== 'grill' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
|
|
103
|
+
ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background', result: { costUsd: 0 } }, now);
|
|
104
|
+
return { ok: false, error: (session && session.note) || 'Claude could not start grilling' };
|
|
105
|
+
}
|
|
106
|
+
active.get(run).session = session;
|
|
107
|
+
return { ok: true, run, budget: b.budget };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function stop(run) { const a = active.get(run); if (a && a.session && deps.stop) deps.stop(a.session); }
|
|
111
|
+
|
|
112
|
+
/** What is due now, in order: stage exits, forecast turns, big moves, the monthly look. → [{ ws, board, ini, why, key, detail }] */
|
|
113
|
+
function dueOf(w, F, mode, now) {
|
|
114
|
+
const dir = deps.stateDirFor(w); if (!dir) return [];
|
|
115
|
+
const out = [];
|
|
116
|
+
const tryList = (f) => { try { return f() || []; } catch (e) { warn('grill scan', e); return []; } };
|
|
117
|
+
for (const x of tryList(() => deps.exits && deps.exits(w))) {
|
|
118
|
+
const key = `exit:${w.id}:${x.ini}:${x.stage}`;
|
|
119
|
+
if (!F.keys.has(key)) out.push({ ws: w.id, board: x.board, ini: x.ini, why: 'exit', key, detail: 'stage ' + x.stage });
|
|
120
|
+
}
|
|
121
|
+
if (mode === 'exits') return out;
|
|
122
|
+
const since = new Date(now - 7 * 864e5).toISOString();
|
|
123
|
+
for (const t of tryList(() => deps.turned && deps.turned(dir, since))) {
|
|
124
|
+
if (!t || !BAD.has(t.to) || (t.ws && t.ws !== w.id)) continue;
|
|
125
|
+
const key = `forecast:${w.id}:${t.scope}:${t.id}:${t.at}`;
|
|
126
|
+
if (F.keys.has(key)) continue;
|
|
127
|
+
// a goal that turned grills the one running initiative that moves it and is due first
|
|
128
|
+
const ini = t.scope === 'initiative' ? t.id : t.scope === 'goal' ? pickFor(tryList(() => deps.goalInis && deps.goalInis(w, t.id))) : null;
|
|
129
|
+
if (ini) out.push({ ws: w.id, board: '', ini, why: 'forecast', key, detail: `${t.scope === 'goal' ? 'its goal ' + t.id : 'its delivery'}: ${t.from || 'on-track'} → ${t.to}` });
|
|
130
|
+
}
|
|
131
|
+
for (const s of tryList(() => deps.shapes && deps.shapes(w))) {
|
|
132
|
+
const prev = F.snaps.get(w.id + '|' + s.ini), cur = { n: Number(s.n) || 0, end: s.end || '' };
|
|
133
|
+
if (!prev || prev.n !== cur.n || prev.end !== cur.end) try { G.append(deps.runtimeDir(), { kind: 'snap', ws: w.id, ini: s.ini, n: cur.n, end: cur.end }, now); } catch (e) { warn('grill snap', e); }
|
|
134
|
+
const what = G.moved(prev, cur);
|
|
135
|
+
if (what) out.push({ ws: w.id, board: s.board, ini: s.ini, why: 'move', key: `move:${w.id}:${s.ini}:${cur.n}:${cur.end}`, detail: what });
|
|
136
|
+
}
|
|
137
|
+
for (const c of tryList(() => deps.checks && deps.checks(w, localDay(now)))) {
|
|
138
|
+
const last = Date.parse(F.lastAt.get(w.id + '|' + c.ini) || '') || 0;
|
|
139
|
+
if (now - last < G.MONTHLY_DAYS * 864e5) continue;
|
|
140
|
+
out.push({ ws: w.id, board: c.board, ini: c.ini, why: 'monthly', key: `monthly:${w.id}:${c.ini}:${G.monthOf(now)}`, detail: (c.tasks || []).length + ' late or at-risk tasks' });
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function tick({ now = Date.now(), env } = {}) {
|
|
146
|
+
const mode = G.modeOf(deps.setting, env || deps.env);
|
|
147
|
+
if (mode === 'off' || (deps.headlessOff && deps.headlessOff())) return { off: true };
|
|
148
|
+
if (active.size >= MAX) return { running: active.size };
|
|
149
|
+
let open = true;
|
|
150
|
+
try { open = deps.open ? !!deps.open(now) : true; } catch { open = true; }
|
|
151
|
+
if (!open) return { started: null };
|
|
152
|
+
const rt = runtime(); if (!rt) return { started: null };
|
|
153
|
+
for (const w of deps.workspaces() || []) {
|
|
154
|
+
if (deps.isLead && !deps.isLead(w)) continue;
|
|
155
|
+
if (now - (lastScan.get(w.id) || 0) < 3600e3) continue; // one scan an hour per workspace
|
|
156
|
+
lastScan.set(w.id, now);
|
|
157
|
+
const F = G.read(rt);
|
|
158
|
+
for (const d of dueOf(w, F, mode, now)) {
|
|
159
|
+
if (F.keys.has(d.key)) continue;
|
|
160
|
+
const r = start({ ...d, now });
|
|
161
|
+
if (r.ok) return { started: d.ini, why: d.why };
|
|
162
|
+
if (r.paused) return { paused: true };
|
|
163
|
+
if (r.held) { lastScan.delete(w.id); return { held: true }; }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { started: null };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return { tick, start, stop, dueOf, active: () => [...active.keys()] };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = { create, promptOf, pickFor, WHY, MAX };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* grill.js — Claude grills an initiative by itself (Grill and Forecast, build brief 2026-10-29, part G-A). THE ONE WRITER and THE ONE FOLD of
|
|
3
|
+
* the grill run log, and the pure rules that decide when a run starts and what it may spend. lib/grill-runs.js starts the runs;
|
|
4
|
+
* lib/grill-cli.js is what a run files with and what the PM reads and sets.
|
|
5
|
+
*
|
|
6
|
+
* GRILL IS THE ✦ EXPANDED. There is no Grill button and no lens picker: the run picks its angles from the stage and the evidence, and each
|
|
7
|
+
* finding is one proposal under the initiative's blue ✦ (lib/proposals.js, group `grill`, type = the angle), with a next step. The PM keeps,
|
|
8
|
+
* drops or undoes it there. Nothing changes before the PM's ✓; the ✓ adds the next step as a task. Zero findings is silence.
|
|
9
|
+
*
|
|
10
|
+
* THE ANGLES: premortem · redteam · voices · reframe · scope · whatif. Voices are simulated from stored research and meeting notes only,
|
|
11
|
+
* and only with 3 sources or more ("Simulated, not evidence"). A what-if is "Simulated, not the plan". The angle and the tag are in the
|
|
12
|
+
* proposal's own title, so the ✦ list shows them as it is.
|
|
13
|
+
*
|
|
14
|
+
* WHEN IT RUNS (lib/grill-runs.js; Settings key grill.mode: full | exits | off, PMOS_GRILL=off wins):
|
|
15
|
+
* exit the initiative is about to leave its stage (most of the stage's tasks are closed), once per stage
|
|
16
|
+
* forecast its forecast, or the forecast of a goal it moves, turned at-risk or will-miss (lib/forecast.js `turned` lines), once per turn
|
|
17
|
+
* move its scope or dates moved a lot since the last look (tasks ±30% and 3 or more, or the end ±14 days)
|
|
18
|
+
* monthly a running initiative with late work, at most once in 30 days
|
|
19
|
+
* `exits` runs only the first. Every run counts against the monthly credit cap (grill.cap, US dollars): before a run the cap must hold
|
|
20
|
+
* the run's whole budget, which goes to the run as --max-budget-usd, so the month never goes beyond the cap. At the cap Claude pauses and
|
|
21
|
+
* says so once per month (a `paused` line).
|
|
22
|
+
*
|
|
23
|
+
* THE LOG, <runtime>/grill-runs.jsonl (machine-wide, so the cap covers every product), one line per event { at, kind, ... }:
|
|
24
|
+
* start { run, ws, ini, board, why, key, budget } key: what started it (the stage, the turn, the move), so it runs once per key
|
|
25
|
+
* voices { run, n } how many stored research and note sources the run found for Voices
|
|
26
|
+
* end { run, ok, cost, error? } cost: US dollars the run spent (lib/headless.js parseResult costUsd)
|
|
27
|
+
* snap { ws, ini, n, end } the open tasks and the latest due date the last look saw (for `move`)
|
|
28
|
+
* paused { month, spent, cap } the cap held a run back this month; written once per month
|
|
29
|
+
*
|
|
30
|
+
* logFile(dir) · readLines(file) · read(dir) → fold · append(dir, line)
|
|
31
|
+
* fold(lines) PURE → { runs: Map run → r, keys: Set, lastAt: Map ws|ini → iso, snaps: Map, paused: Set month }
|
|
32
|
+
* monthOf(ms) · spentIn(F, month) the month's spend (an open run counts its whole budget)
|
|
33
|
+
* budgetFor(F, { cap, now }) PURE → { ok, budget, spent } | { ok: false, spent, why: 'cap' }
|
|
34
|
+
* moved(prev, cur) PURE → '' | what moved, in words
|
|
35
|
+
* ready(tasks) PURE → true when a stage is about to end: 2 or more tasks, at most 1 open
|
|
36
|
+
* finding(angle, input) → { prop } | { error } what `pmos grill find` checks; the proposal for lib/proposals.js
|
|
37
|
+
* modeOf(get, env) 'full' | 'exits' | 'off'
|
|
38
|
+
*/
|
|
39
|
+
const fs = require('fs');
|
|
40
|
+
const path = require('path');
|
|
41
|
+
const crypto = require('crypto');
|
|
42
|
+
|
|
43
|
+
const LOG = 'grill-runs.jsonl';
|
|
44
|
+
const KINDS = new Set(['start', 'voices', 'end', 'snap', 'paused']);
|
|
45
|
+
const ANGLES = Object.freeze(['premortem', 'redteam', 'voices', 'reframe', 'scope', 'whatif']);
|
|
46
|
+
const LABEL = Object.freeze({ premortem: 'Premortem', redteam: 'Red team', voices: 'Voices', reframe: 'Reframe', scope: 'Scope', whatif: 'What-if' });
|
|
47
|
+
const SIMULATED = Object.freeze({ voices: 'Simulated, not evidence', whatif: 'Simulated, not the plan' });
|
|
48
|
+
const WHYS = Object.freeze(['exit', 'forecast', 'move', 'monthly']);
|
|
49
|
+
const MODES = Object.freeze(['full', 'exits', 'off']);
|
|
50
|
+
const VOICES_MIN = 3;
|
|
51
|
+
const RUN_MAX_USD = 2; // one run never spends more than this
|
|
52
|
+
const EST_USD = 0.5; // what a run costs before any has ended
|
|
53
|
+
const RUN_MIN_USD = 0.25; // under this left in the month, Claude pauses
|
|
54
|
+
const MONTHLY_DAYS = 30;
|
|
55
|
+
const MOVE_DAYS = 14;
|
|
56
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
57
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
58
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
59
|
+
const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 10);
|
|
60
|
+
const cents = (n) => Math.round(Number(n) * 100) / 100;
|
|
61
|
+
const dn = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
|
|
62
|
+
|
|
63
|
+
const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
|
|
64
|
+
const off = (env) => flagOff((env || process.env).PMOS_GRILL);
|
|
65
|
+
/** The mode: PMOS_GRILL=off wins, then Settings grill.mode. get(key) reads lib/settings-store.js. */
|
|
66
|
+
function modeOf(get, env) {
|
|
67
|
+
if (off(env)) return 'off';
|
|
68
|
+
let m = 'full';
|
|
69
|
+
try { m = get ? get('grill.mode') : 'full'; } catch { m = 'full'; }
|
|
70
|
+
return MODES.includes(m) ? m : 'full';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ── the log ── */
|
|
74
|
+
const logFile = (dir) => (dir ? path.join(dir, LOG) : null);
|
|
75
|
+
function readLines(file) {
|
|
76
|
+
if (!file) return [];
|
|
77
|
+
let text = '';
|
|
78
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
79
|
+
const out = [];
|
|
80
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && KINDS.has(l.kind)) out.push(l); } catch { /* a torn line is skipped */ } }
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
const read = (dir) => fold(readLines(logFile(dir)));
|
|
84
|
+
function append(dir, ev, at = new Date()) {
|
|
85
|
+
const line = { at: new Date(at).toISOString(), ...ev };
|
|
86
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
87
|
+
fs.appendFileSync(logFile(dir), JSON.stringify(line) + '\n');
|
|
88
|
+
return line;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function fold(lines) {
|
|
92
|
+
const runs = new Map(), keys = new Set(), lastAt = new Map(), snaps = new Map(), paused = new Set();
|
|
93
|
+
for (const l of lines || []) {
|
|
94
|
+
if (!isObj(l)) continue;
|
|
95
|
+
if (l.kind === 'start' && str(l.run)) {
|
|
96
|
+
runs.set(l.run, { run: l.run, ws: str(l.ws), ini: str(l.ini), board: str(l.board), why: str(l.why), key: str(l.key), budget: Number(l.budget) || 0, at: str(l.at), ended: false, ok: null, cost: null, voices: null });
|
|
97
|
+
if (str(l.key)) keys.add(l.key);
|
|
98
|
+
lastAt.set(l.ws + '|' + l.ini, str(l.at));
|
|
99
|
+
} else if (l.kind === 'voices') { const r = runs.get(l.run); if (r) r.voices = Number(l.n) || 0; }
|
|
100
|
+
else if (l.kind === 'end') { const r = runs.get(l.run); if (r) { r.ended = true; r.ok = !!l.ok; r.cost = Number.isFinite(Number(l.cost)) && l.cost !== null ? Number(l.cost) : null; r.endAt = str(l.at); if (l.error) r.error = str(l.error); } }
|
|
101
|
+
else if (l.kind === 'snap') snaps.set(l.ws + '|' + l.ini, { n: Number(l.n) || 0, end: str(l.end), at: str(l.at) });
|
|
102
|
+
else if (l.kind === 'paused') paused.add(str(l.month));
|
|
103
|
+
}
|
|
104
|
+
return { runs, keys, lastAt, snaps, paused };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* ── the credit cap ── */
|
|
108
|
+
const monthOf = (ms) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0'); };
|
|
109
|
+
/** What the month spent. An ended run counts its cost (its budget when the cost is unknown); an open run counts its whole budget. */
|
|
110
|
+
function spentIn(F, month) {
|
|
111
|
+
let s = 0;
|
|
112
|
+
for (const r of F.runs.values()) {
|
|
113
|
+
if (monthOf(Date.parse(r.at) || 0) !== month) continue;
|
|
114
|
+
s += r.ended ? (r.cost != null ? r.cost : r.budget) : r.budget;
|
|
115
|
+
}
|
|
116
|
+
return cents(s);
|
|
117
|
+
}
|
|
118
|
+
/** PURE. May a run start, and with what budget? The budget is 1.5 × what a run usually costs, up to RUN_MAX_USD and never more than the cap
|
|
119
|
+
* leaves; under RUN_MIN_USD left, no run starts. */
|
|
120
|
+
function budgetFor(F, { cap, now = Date.now() } = {}) {
|
|
121
|
+
const spent = spentIn(F, monthOf(now)), left = cents(Number(cap) - spent);
|
|
122
|
+
const costs = [...F.runs.values()].filter((r) => r.ended && r.cost != null).slice(-5).map((r) => r.cost);
|
|
123
|
+
const usual = costs.length ? Math.max(...costs) : EST_USD;
|
|
124
|
+
// never more than the cap leaves; too little left to do a real run is the cap too
|
|
125
|
+
const budget = cents(Math.min(RUN_MAX_USD, Math.max(usual * 1.5, EST_USD), left));
|
|
126
|
+
if (!(budget >= RUN_MIN_USD)) return { ok: false, spent, left: Math.max(0, left), why: 'cap' };
|
|
127
|
+
return { ok: true, budget, spent, left };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* ── the triggers ── */
|
|
131
|
+
/** PURE. prev, cur: { n (open tasks), end (YYYY-MM-DD) }. → '' | what moved, in words */
|
|
132
|
+
function moved(prev, cur) {
|
|
133
|
+
if (!prev || !cur) return '';
|
|
134
|
+
const out = [];
|
|
135
|
+
const dN = cur.n - prev.n;
|
|
136
|
+
if (Math.abs(dN) >= 3 && Math.abs(dN) >= 0.3 * Math.max(1, prev.n)) out.push(`scope ${dN > 0 ? 'grew' : 'shrank'} from ${prev.n} to ${cur.n} open tasks`);
|
|
137
|
+
const a = dn(prev.end), b = dn(cur.end);
|
|
138
|
+
if (a != null && b != null && Math.abs(b - a) >= MOVE_DAYS) out.push(`the end moved ${b > a ? 'out' : 'in'} ${Math.abs(b - a)} days to ${cur.end}`);
|
|
139
|
+
return out.join('; ');
|
|
140
|
+
}
|
|
141
|
+
/** PURE. A stage is about to end: it has 2 or more tasks and at most 1 is still open. tasks: [{ closed }] */
|
|
142
|
+
function ready(tasks) {
|
|
143
|
+
const t = (tasks || []).filter(Boolean);
|
|
144
|
+
return t.length >= 2 && t.filter((x) => !x.closed).length <= 1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ── what a run files ── */
|
|
148
|
+
const LIM = { title: 140, why: 300, next: 140, label: 80, ref: 500 };
|
|
149
|
+
/** → { prop } | { error }. input: { title, why, next, sources: [{ label, ref }], key?, rank? } */
|
|
150
|
+
function finding(angle, input) {
|
|
151
|
+
if (!ANGLES.includes(angle)) return { error: 'the angle is one of ' + ANGLES.join(', ') };
|
|
152
|
+
if (!isObj(input)) return { error: 'the finding is a JSON object' };
|
|
153
|
+
const title = one(input.title, LIM.title), why = one(input.why, LIM.why), next = one(input.next, LIM.next);
|
|
154
|
+
if (!title) return { error: 'title is the finding in one short line' };
|
|
155
|
+
if (!why) return { error: 'why is one line: what the evidence says' };
|
|
156
|
+
if (!next) return { error: 'next is the one next step the PM can take (it becomes a task on ✓)' };
|
|
157
|
+
if (!Array.isArray(input.sources) || !input.sources.length || input.sources.length > 8) return { error: 'every finding carries 1 to 8 sources [{ label, ref }]: a claim without a pointer is not a finding' };
|
|
158
|
+
const sources = [];
|
|
159
|
+
for (const s of input.sources) {
|
|
160
|
+
if (!isObj(s) || !str(s.label).trim()) return { error: 'each source has a label (and a ref: a link, a path or a Jira key)' };
|
|
161
|
+
sources.push({ label: one(s.label, LIM.label), ...(str(s.ref) ? { ref: one(s.ref, LIM.ref) } : {}) });
|
|
162
|
+
}
|
|
163
|
+
if (angle === 'voices' && new Set(sources.map((s) => s.ref || s.label)).size < VOICES_MIN) return { error: `Voices needs ${VOICES_MIN} sources or more (stored research or meeting notes); with fewer it is left out` };
|
|
164
|
+
const tag = SIMULATED[angle] || '';
|
|
165
|
+
const rank = Number.isInteger(input.rank) && input.rank >= 1 && input.rank <= 9 ? input.rank : 5;
|
|
166
|
+
return { prop: { group: 'grill', type: angle, section: 'check', title: one(LABEL[angle] + (tag ? ' (' + tag + ')' : '') + ': ' + title, 200), why: one(why + ' Next: ' + next, 460),
|
|
167
|
+
sources, items: [], data: { angle, next, rank, ...(tag ? { simulated: tag } : {}) } } };
|
|
168
|
+
}
|
|
169
|
+
const idOf = (ini, angle, key) => 'pr-' + hash([ini, 'grill', angle, key || ''].join('|'));
|
|
170
|
+
|
|
171
|
+
module.exports = { LOG, ANGLES, LABEL, SIMULATED, WHYS, MODES, VOICES_MIN, RUN_MAX_USD, RUN_MIN_USD, EST_USD, MONTHLY_DAYS, MOVE_DAYS,
|
|
172
|
+
off, modeOf, logFile, readLines, read, append, fold, monthOf, spentIn, budgetFor, moved, ready, finding, idOf, dn };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (initiative workspace-headless-jobs; PM decision 2026-10-11: keep Jev, no direct Claude API, background
|
|
4
4
|
* jobs that need no human run headless).
|
|
5
5
|
*
|
|
6
|
-
* kindFor({ agent, origin, skill, env }) → 'notes' | 'skill' | 'ask' | 'drive' | 'scan-web' | 'scan-repo' | 'scan-research-web' | 'scan-research-repo' | 'report-setup' | 'report-find' | 'core-doc' | 'report-design' | 'report-structure-pull' | 'report-sample-fetch' | 'report-structure' | 'report-structure-dry' | 'ms-review' | 'propose' | 'metric-draft' | 'impact' | 'metric-read' | null (null: open a pane, as before)
|
|
6
|
+
* kindFor({ agent, origin, skill, env }) → 'notes' | 'skill' | 'ask' | 'drive' | 'scan-web' | 'scan-repo' | 'scan-research-web' | 'scan-research-repo' | 'report-setup' | 'report-find' | 'core-doc' | 'report-design' | 'report-structure-pull' | 'report-sample-fetch' | 'report-structure' | 'report-structure-dry' | 'ms-review' | 'propose' | 'metric-draft' | 'grill' | 'impact' | 'metric-read' | null (null: open a pane, as before)
|
|
7
7
|
* argsFor(kind, { modelArgs, addDirs, writePaths }) → the argv after `claude` (writePaths: the one render file a report-design job may write;
|
|
8
8
|
* for the skill kind, the folders the run may write in, from skillWriteDirs)
|
|
9
9
|
* skillWriteDirs(skill, { root, scratch }) → the absolute folders a background skill run may write in: its scratch folder and the state folders its skill writes
|
|
@@ -115,6 +115,9 @@ const PROPOSE_ORIGINS = Object.freeze(['propose:']);
|
|
|
115
115
|
// batch 15 item 1: Claude drafts the metrics of a product, a program or an initiative (origin `metric-draft:<ws>:<scope>:<id>:<run>`,
|
|
116
116
|
// lib/metric-draft-runs.js). Its only write is `pmos metrics draft`, pinned by the server to that scope and run.
|
|
117
117
|
const METRIC_DRAFT_ORIGINS = Object.freeze(['metric-draft:']);
|
|
118
|
+
// Grill and Forecast (part G-A): Claude grills one initiative by itself (origin `grill:<ws>:<initiative>:<run>`, lib/grill-runs.js). Its only
|
|
119
|
+
// write is `pmos grill find` (and `pmos grill voices`), pinned by the server to that initiative and run; it spends at most its budget.
|
|
120
|
+
const GRILL_ORIGINS = Object.freeze(['grill:']);
|
|
118
121
|
// batch 16 item 7: Claude's daily impact read (origin `impact:<run>`, lib/impact-runs.js). Its only write is `pmos impact add`, pinned to that run.
|
|
119
122
|
const IMPACT_ORIGINS = Object.freeze(['impact:']);
|
|
120
123
|
// batch 16 item 6: Claude reads the goals with their recipes (origin `metric-read:<ws>:<run>`, lib/metric-read-runs.js). Its only write is
|
|
@@ -179,6 +182,10 @@ const TOOLS = Object.freeze({
|
|
|
179
182
|
// no web fetch, nothing that sends; it never writes a record (only the PM's ✓ keep does).
|
|
180
183
|
'metric-draft': Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos metrics draft *)', 'Bash(pmos initiative export *)', 'Bash(pmos initiative list *)',
|
|
181
184
|
'Bash(pmos source show *)', 'Bash(pmos source status *)', 'Bash(git log *)', 'Bash(date *)']),
|
|
185
|
+
// The grill run (lib/grill-runs.js): read and search the repository, the stored reads, research and meeting notes, and the verbs that file
|
|
186
|
+
// a finding and count the Voices sources. No Write, no Edit, no web, nothing that sends; never `pmos grill mode` or `cap` (not in the list).
|
|
187
|
+
grill: Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos grill find *)', 'Bash(pmos grill voices *)', 'Bash(pmos grill status)', 'Bash(pmos initiative export *)',
|
|
188
|
+
'Bash(pmos initiative list *)', 'Bash(pmos task list *)', 'Bash(pmos source show *)', 'Bash(pmos source status *)', 'Bash(git log *)', 'Bash(date *)']),
|
|
182
189
|
// The impact run (lib/impact-runs.js): read and search the repository and the stored reads, and the one verb that files an item. The PM's
|
|
183
190
|
// Slack, mail and Jira are read through the PM's own connectors only where the PM's settings allow it. No Write, no Edit, no web fetch,
|
|
184
191
|
// nothing that sends, posts or reacts.
|
|
@@ -225,6 +232,7 @@ function kindFor({ agent, origin, skill, env } = {}) {
|
|
|
225
232
|
if (MS_REVIEW_ORIGINS.some((p) => o.startsWith(p))) return 'ms-review';
|
|
226
233
|
if (PROPOSE_ORIGINS.some((p) => o.startsWith(p))) return 'propose';
|
|
227
234
|
if (METRIC_DRAFT_ORIGINS.some((p) => o.startsWith(p))) return 'metric-draft';
|
|
235
|
+
if (GRILL_ORIGINS.some((p) => o.startsWith(p))) return 'grill';
|
|
228
236
|
if (IMPACT_ORIGINS.some((p) => o.startsWith(p))) return 'impact';
|
|
229
237
|
if (METRIC_READ_ORIGINS.some((p) => o.startsWith(p))) return 'metric-read';
|
|
230
238
|
if (REPORT_DESIGN_ORIGINS.some((p) => o.startsWith(p))) return 'report-design';
|
|
@@ -237,7 +245,7 @@ function kindFor({ agent, origin, skill, env } = {}) {
|
|
|
237
245
|
return null;
|
|
238
246
|
}
|
|
239
247
|
|
|
240
|
-
function argsFor(kind, { modelArgs = [], addDirs = [], writePaths = [] } = {}) {
|
|
248
|
+
function argsFor(kind, { modelArgs = [], addDirs = [], writePaths = [], budgetUsd = null } = {}) {
|
|
241
249
|
if (!TOOLS[kind]) throw new Error('unknown headless kind: ' + kind);
|
|
242
250
|
const tools = TOOLS[kind].slice();
|
|
243
251
|
// A report-design run may write its render file (a report-sample-fetch run, its text copy) and nothing else: one absolute path, no wildcard, no comma.
|
|
@@ -258,6 +266,9 @@ function argsFor(kind, { modelArgs = [], addDirs = [], writePaths = [] } = {}) {
|
|
|
258
266
|
}
|
|
259
267
|
// stream-json needs --verbose in print mode; it adds the step events, and the last line is the same result object as `json`.
|
|
260
268
|
const argv = ['-p', '--output-format', 'stream-json', '--verbose', '--no-session-persistence', ...modelArgs, '--allowedTools', tools.join(',')];
|
|
269
|
+
// A run with a budget (a grill run, lib/grill.js budgetFor) stops at it, so the monthly credit cap holds
|
|
270
|
+
const b = Number(budgetUsd);
|
|
271
|
+
if (budgetUsd != null && Number.isFinite(b) && b > 0) argv.push('--max-budget-usd', String(b));
|
|
261
272
|
// A web run gets no directory at all, whatever the caller passes: it must not be able to read the repository.
|
|
262
273
|
if (!WEB_KINDS.includes(kind)) for (const d of addDirs) if (d) argv.push('--add-dir', String(d));
|
|
263
274
|
return argv;
|
|
@@ -397,6 +408,7 @@ const RUN_ENV = Object.freeze(['PMOS_SCAN_FILE', 'PMOS_SCAN_ORIGIN', 'PMOS_SCAN_
|
|
|
397
408
|
'PMOS_METRIC_DRAFT_FILE', 'PMOS_METRIC_DRAFT_WS', 'PMOS_METRIC_DRAFT_SCOPE', 'PMOS_METRIC_DRAFT_ID', 'PMOS_METRIC_DRAFT_RUN',
|
|
398
409
|
'PMOS_METRIC_READ_FILE', 'PMOS_METRIC_READ_RECORDS', 'PMOS_METRIC_READ_DRAFTS', 'PMOS_METRIC_READ_WS', 'PMOS_METRIC_READ_RUN', 'PMOS_METRIC_READ_RIDS', 'PMOS_METRIC_READ_TEST',
|
|
399
410
|
'PMOS_PROPOSE_FILE', 'PMOS_PROPOSE_WS', 'PMOS_PROPOSE_BOARD', 'PMOS_PROPOSE_INI', 'PMOS_PROPOSE_RUN',
|
|
411
|
+
'PMOS_GRILL_FILE', 'PMOS_GRILL_LOG', 'PMOS_GRILL_WS', 'PMOS_GRILL_BOARD', 'PMOS_GRILL_INI', 'PMOS_GRILL_RUN', 'PMOS_GRILL_BUDGET',
|
|
400
412
|
'PMOS_IMPACT_FILE', 'PMOS_IMPACT_RUN', 'PMOS_MS_REVIEW_FILE', 'PMOS_MS_REVIEW_RUN', 'PMOS_MS_REVIEW_PROGRAM']);
|
|
401
413
|
function runEnvOf(extra) {
|
|
402
414
|
const out = {};
|
|
@@ -113,17 +113,20 @@ function rangeOf(g) {
|
|
|
113
113
|
const last = dayMs(S[S.length - 1].at);
|
|
114
114
|
if (due <= last) return null;
|
|
115
115
|
const ends = [];
|
|
116
|
+
let likely = null; // the four-reading line, the one the Intelligence projection says in words (lib/forecast.js reads it as the likely end)
|
|
116
117
|
for (let n = 3; n <= Math.min(6, S.length); n++) {
|
|
117
118
|
const a = S[S.length - n], z = S[S.length - 1], t0 = dayMs(a.at), t1 = dayMs(z.at);
|
|
118
119
|
if (t1 <= t0) continue;
|
|
119
120
|
let v = z.v + (z.v - a.v) / (t1 - t0) * (due - t1);
|
|
120
121
|
if (pctUnit(g.unit)) v = Math.max(0, Math.min(100, v));
|
|
121
122
|
ends.push(v);
|
|
123
|
+
if (n <= 4) likely = v;
|
|
122
124
|
}
|
|
123
125
|
if (!ends.length) return null;
|
|
124
126
|
const lo = Math.min(...ends), hi = Math.max(...ends), b = better(g);
|
|
125
127
|
const reaches = b > 0 ? lo >= g.target : b < 0 ? hi <= g.target : null;
|
|
126
|
-
|
|
128
|
+
const none = b > 0 ? hi < g.target : b < 0 ? lo > g.target : null;
|
|
129
|
+
return { lo, hi, likely, by: g.byAt, reaches, none, n: ends.length };
|
|
127
130
|
}
|
|
128
131
|
const r1 = (v) => Math.round(v * 10) / 10;
|
|
129
132
|
/** A range said at one decimal, the way the design writes it: "17–19%", "≈18.2%" when the lines agree. */
|
|
@@ -78,6 +78,9 @@ const VERBS = Object.freeze({
|
|
|
78
78
|
// Not a pm-os-absorb verb (run: null): feedback batch 12 items 2, 3 and 4 (Claude proposes, the one ✦) added it through the same table.
|
|
79
79
|
propose: Object.freeze({ module: 'propose-cli.js', run: null, guide: 'claude-proposes.md',
|
|
80
80
|
help: 'pmos propose look|found|date|done|name|status … — what Claude\'s run files under an initiative\'s ✦ for the PM to keep or drop (pmos propose help)' }),
|
|
81
|
+
// Not a pm-os-absorb verb (run: null): Grill and Forecast part G-A (Claude grills an initiative by itself) added it through the same table.
|
|
82
|
+
grill: Object.freeze({ module: 'grill-cli.js', run: null, guide: 'claude-proposes.md',
|
|
83
|
+
help: 'pmos grill find|voices|status|mode|cap|spend … — what Claude\'s grill run files under an initiative\'s ✦, and when it grills and what it may spend (pmos grill help)' }),
|
|
81
84
|
// Not a pm-os-absorb verb (run: null): batch 15 item 1 (Claude drafts metrics without being asked) added it through the same table.
|
|
82
85
|
metrics: Object.freeze({ module: 'metrics-cli.js', run: null, guide: 'metric-drafts.md',
|
|
83
86
|
help: 'pmos metrics draft read|step|row|fix|end|status … — what Claude\'s metric-draft run files for the PM to keep or drop; pmos metrics reading … — what Claude\'s reading run reads (pmos metrics help)' }),
|
|
@@ -92,6 +95,9 @@ const VERBS = Object.freeze({
|
|
|
92
95
|
// Not a pm-os-absorb verb (run: null): initiative core-documents added it through the same table.
|
|
93
96
|
coredoc: Object.freeze({ module: 'coredoc-cli.js', run: null, guide: 'core-documents.md',
|
|
94
97
|
help: 'pmos coredoc write --scope <scope> --key <key> --file <path|-> — write one draft of a core document; the PM issues it on the page (pmos coredoc help)' }),
|
|
98
|
+
// Not a pm-os-absorb verb (run: null): the Grill and Forecast build (F-A) added it through the same table.
|
|
99
|
+
forecast: Object.freeze({ module: 'forecast-cli.js', run: null, guide: 'forecast.md',
|
|
100
|
+
help: 'pmos forecast baseline|baseline-off|turned … — a goal forecast\'s kept baseline, and the forecasts that turned (pmos forecast help)' }),
|
|
95
101
|
launcher: Object.freeze({ module: 'launcher-cli.js', run: null, guide: 'launcher.md',
|
|
96
102
|
help: 'pmos launcher on|off|status — a PMOS app and a login item, so the workspace starts without a terminal' }),
|
|
97
103
|
});
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* dates one proposal per stage: its late and at-risk tasks to new dates and its plan with them, plus what a moved task's links reach
|
|
16
16
|
* status "looks done": the evidence says the work happened
|
|
17
17
|
* names tidy names, before → after; the detail cut moves to the task's notes
|
|
18
|
+
* grill what Claude found when it grilled the initiative by itself (lib/grill.js): type = the angle, no items, a next step in data.next;
|
|
19
|
+
* always section 'check' (its own ✓, never Keep all). 3 show, best rank first; the group's `more` counts the rest
|
|
18
20
|
*
|
|
19
21
|
* THE LEDGER. One line per event, { at, by, kind, ... }:
|
|
20
22
|
* look { ini, board, run, why: 'populate' | 'check' } a run started looking (the live lines, PiA1)
|
|
@@ -298,7 +300,8 @@ function datesOf(ini, T, o = {}) {
|
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
/* ── what r.props carries ── */
|
|
301
|
-
const ORDER = { found: 0, dates: 1, status: 2, names: 3, links: 4 };
|
|
303
|
+
const ORDER = { found: 0, dates: 1, status: 2, names: 3, links: 4, grill: 5 };
|
|
304
|
+
const GRILL_SHOWN = 3;
|
|
302
305
|
/**
|
|
303
306
|
* One initiative's proposals, as the ✦ and the Viewer draw them, or null when there is nothing to show.
|
|
304
307
|
* o: { T (Map uid → task), today (iso), stages: [{ key, name }], links: approved task links, settle, linkProps: [task-links proposal] }
|
|
@@ -316,14 +319,18 @@ function viewOf(F, ini, o = {}) {
|
|
|
316
319
|
p.items = p.items.filter((x) => !F.drops.has(itemSig(p, x)) && (!x.task || (T.has(x.task) && !(p.group !== 'found' && T.get(x.task).closed && p.group !== 'status'))));
|
|
317
320
|
if (p.group === 'status') p.items = p.items.filter((x) => T.has(x.task) && !T.get(x.task).closed);
|
|
318
321
|
if (p.group === 'names') p.items = p.items.filter((x) => T.has(x.task) && T.get(x.task).title !== x.to).map((x) => ({ ...x, from: T.get(x.task).title, ...(T.get(x.task).jira ? { jira: true } : {}) }));
|
|
319
|
-
if (!p.items.length && p.type !== 'stage') continue;
|
|
322
|
+
if (!p.items.length && p.type !== 'stage' && p.group !== 'grill') continue;
|
|
320
323
|
props.push(p);
|
|
321
324
|
}
|
|
325
|
+
// Grill findings (lib/grill.js): 3 show, the best first (rank); the rest wait folded and come up as the PM keeps or drops one
|
|
326
|
+
const grill = props.filter((p) => p.group === 'grill').sort((a, b) => ((a.data && a.data.rank) || 5) - ((b.data && b.data.rank) || 5) || String(b.at).localeCompare(String(a.at)));
|
|
327
|
+
const grillMore = Math.max(0, grill.length - GRILL_SHOWN);
|
|
328
|
+
for (const p of grill.slice(GRILL_SHOWN)) props.splice(props.indexOf(p), 1);
|
|
322
329
|
if (today != null) for (const p of datesOf(ini, T, { today, filed: [...F.props.values()].filter((x) => x.group === 'dates' && x.ini === ini), stages: o.stages, links: o.links, settle: o.settle, drops: F.drops })) if (!kept.has(p.id + ':' + p.sig)) props.push(p);
|
|
323
330
|
for (const lp of o.linkProps || []) props.push({ id: 'lk:' + lp.id, group: 'links', type: lp.kind, section: 'sure', link: lp, title: '', why: lp.why || '', sources: [], items: [] });
|
|
324
331
|
// ✕ on one item drops that item for good: the page sends its signature
|
|
325
332
|
for (const p of props) if (p.group !== 'links') p.items = p.items.map((x) => ({ ...x, sig: itemSig(p, x) }));
|
|
326
|
-
props.sort((a, b) => ORDER[a.group] - ORDER[b.group] || (a.section === 'sure' ? 0 : a.section === 'check' ? 1 : 2) - (b.section === 'sure' ? 0 : b.section === 'check' ? 1 : 2));
|
|
333
|
+
props.sort((a, b) => ORDER[a.group] - ORDER[b.group] || (a.group === 'grill' ? ((a.data && a.data.rank) || 5) - ((b.data && b.data.rank) || 5) : 0) || (a.section === 'sure' ? 0 : a.section === 'check' ? 1 : 2) - (b.section === 'sure' ? 0 : b.section === 'check' ? 1 : 2));
|
|
327
334
|
const L = F.looks.get(ini) || null;
|
|
328
335
|
const look = L && (!L.ended || L.why === 'populate') ? { run: L.run, why: L.why, at: L.at, ended: L.ended, stopped: L.stopped, ok: L.ok,
|
|
329
336
|
// zero is silence: a source that found nothing drops off
|
|
@@ -332,7 +339,7 @@ function viewOf(F, ini, o = {}) {
|
|
|
332
339
|
const looking = look && !look.ended ? look : null;
|
|
333
340
|
if (!props.length && !looking) return null;
|
|
334
341
|
const groups = [];
|
|
335
|
-
for (const p of props) { let g = groups.find((x) => x.group === p.group); if (!g) groups.push(g = { group: p.group, props: [] }); g.props.push(p); }
|
|
342
|
+
for (const p of props) { let g = groups.find((x) => x.group === p.group); if (!g) groups.push(g = { group: p.group, props: [], ...(p.group === 'grill' && grillMore ? { more: grillMore } : {}) }); g.props.push(p); }
|
|
336
343
|
return { n: props.length, sure: props.filter((p) => p.section === 'sure').length, look: looking, groups, t: F.t };
|
|
337
344
|
}
|
|
338
345
|
|
|
@@ -52,6 +52,7 @@ const MODULES = Object.freeze([
|
|
|
52
52
|
'routes-board-docs', // premium-uncovered-features (Board): when each document of the Documents tab changed and by whom, from git (read-only)
|
|
53
53
|
'routes-board-grill', // premium-uncovered-features (Board): a new initiative's Why, material and first questions (page press; file mode)
|
|
54
54
|
'routes-insights-premium', // briefing-premium-insights: the premium Insights page's model from the KR metric records and report files (read-only)
|
|
55
|
+
'routes-forecast', // build brief Grill and Forecast F-A: a goal forecast's kept baseline, and the forecasts that turned
|
|
55
56
|
'routes-home-desk', // premium-agreed-design (Home): seen marks, queued messages, the weekly update's recipients and sends, stakeholders (page press; file mode)
|
|
56
57
|
'routes-live', // batch 6 item 2: the Live pill's sessions and the titles of their initiatives (read-only)
|
|
57
58
|
'routes-home-review', // premium-uncovered-features (Home): the weekly review's four steps and the untouched work looked at (page press; file mode)
|