create-pmos 0.360.0 → 0.362.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 +35 -25
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-sources-test.js +22 -0
- package/workspace/briefing-premium-test.js +12 -1
- package/workspace/changelog.json +34 -0
- package/workspace/guide/briefing-premium.md +6 -3
- package/workspace/lib/board-premium.js +8 -3
- package/workspace/lib/engine/boards.js +5 -3
- package/workspace/lib/first-input.js +44 -5
- package/workspace/lib/harness-health.js +95 -0
- package/workspace/lib/proactive.js +21 -3
- package/workspace/lib/refresh-run.js +20 -0
- package/workspace/lib/refresh.js +38 -4
- package/workspace/lib/routes-board-premium.js +1 -1
- package/workspace/lib/routes-boards.js +15 -1
- package/workspace/lib/routes-sources.js +4 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-jira-test.js +22 -6
- package/workspace/public/pm/premium-board.js +3 -3
- package/workspace/public/pm/premium-shell.js +24 -6
- package/workspace/public/pm/premium-vw-jira-model.js +8 -5
- package/workspace/public/pm/premium-vw-jira.css +9 -0
- package/workspace/public/pm/premium-vw-jira.js +21 -9
- package/workspace/public/pm/premium.css +6 -0
- package/workspace/server.js +69 -16
- package/workspace/test-lists/harness-health.json +5 -0
package/workspace/server.js
CHANGED
|
@@ -84,6 +84,7 @@ const scanRunLib = require('./lib/scan-run.js'); // horizon-scan — the watch
|
|
|
84
84
|
const reportFinderLib = require('./lib/report-finder.js'); // report-workspace — the weekly look for the reports the PM already sends
|
|
85
85
|
const refreshLib = require('./lib/refresh.js'); // data-refresh-settings — the sources, their schedules and the refresh log
|
|
86
86
|
const refreshRunLib = require('./lib/refresh-run.js'); // data-refresh-settings — the engine bound to this server (created by the tick below)
|
|
87
|
+
const harnessHealthLib = require('./lib/harness-health.js'); // harness-health — one line on whether the background work runs
|
|
87
88
|
let refreshRun = null;
|
|
88
89
|
const driverRunLib = require('./lib/driver-run.js'); // initiative-driver — wakes, the unblock sweep and the runs, in the 60-second tick
|
|
89
90
|
const headlessLib = require('./lib/headless.js'); // workspace-headless-jobs — which jobs run as `claude -p`, and with which tools
|
|
@@ -2773,6 +2774,36 @@ const coreDocsTick = () => {
|
|
|
2773
2774
|
proSettings, inQuiet: (now, quiet) => proactiveLib.inQuietHours(now, quiet), isLead: (w) => isPlanNeedsTree(w) }, Number.isFinite(t) ? { now: t } : {});
|
|
2774
2775
|
} catch (e) { warnWriteFail('core documents tick', e); }
|
|
2775
2776
|
};
|
|
2777
|
+
/** One needs-you item, so it shows in the bell. */
|
|
2778
|
+
function tellNeed(ws, runId, label, question) {
|
|
2779
|
+
const w = getWs(ws || '') || homeWorkspace(); const nf = w ? needsFileFor(w) : null; if (!nf) return;
|
|
2780
|
+
let needs = []; try { needs = JSON.parse(fs.readFileSync(nf, 'utf8')); } catch { needs = []; }
|
|
2781
|
+
needs.push({ run_id: runId, kind: 'refresh', initiative_id: label, question });
|
|
2782
|
+
fs.writeFileSync(nf, JSON.stringify(needs)); invalidateNeedsAgg(w.id);
|
|
2783
|
+
}
|
|
2784
|
+
// harness-health: one line on whether the background work runs (lib/harness-health.js). GET /api/sources carries it, the Sources
|
|
2785
|
+
// chip's dot takes its colour, and a stop (no brief 45 minutes after its time, a prompt typed but not sent, the tick stopped) is
|
|
2786
|
+
// told once a day in the bell.
|
|
2787
|
+
let lastBgTick = 0;
|
|
2788
|
+
const healthTold = new Set();
|
|
2789
|
+
function harnessHealth(now = Date.now()) {
|
|
2790
|
+
const set = refreshRun.settings();
|
|
2791
|
+
const d = (proSettings() || {}).dayCheck || {};
|
|
2792
|
+
let briefAt = 0; try { briefAt = fs.statSync(path.join(STATE, 'briefs', briefLib.localDate(now) + '.json')).mtimeMs; } catch { /* no brief yet today */ }
|
|
2793
|
+
const live = [...sessions.values()].filter((x) => x.state !== 'exited').map((x) => ({ id: x.id, name: x.name, origin: x.origin, state: x.state, firstInput: x.firstInput || null }));
|
|
2794
|
+
return harnessHealthLib.of({ now, settings: set, state: refreshLib.readState(STATE), log: refreshLib.foldLog(refreshLib.readLog(STATE)), briefAt, sessions: live, lastTick: lastBgTick,
|
|
2795
|
+
win: { start: d.start || '08:00', end: d.end || '18:00' } });
|
|
2796
|
+
}
|
|
2797
|
+
function healthTick(now = Date.now()) {
|
|
2798
|
+
lastBgTick = now;
|
|
2799
|
+
const h = harnessHealth(now);
|
|
2800
|
+
const day = briefLib.localDate(now);
|
|
2801
|
+
for (const i of h.issues) {
|
|
2802
|
+
if (i.level !== 'bad' || !/^(brief|unsent:|tick)/.test(i.key) || healthTold.has(day + i.key)) continue;
|
|
2803
|
+
healthTold.add(day + i.key);
|
|
2804
|
+
tellNeed(null, `health-${i.key}-${now}`, 'Background work', i.text + ' See Sources.');
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2776
2807
|
// data-refresh-settings: the refresh engine. It starts the skill sources that are due (calendar, Jira, work assigned to you, tracker,
|
|
2777
2808
|
// the morning brief), writes the refresh log, and gates the job ticks below: a job that is off, or whose input is still running, waits.
|
|
2778
2809
|
const REFRESH_BOOT = Date.now();
|
|
@@ -2791,12 +2822,7 @@ refreshRun = refreshRunLib.create({
|
|
|
2791
2822
|
if (id === 'jira' && w) { let d = null; try { d = stateDirFor(w); } catch { d = null; } return d ? [path.join(d, 'tracker', 'jira')] : []; }
|
|
2792
2823
|
return [];
|
|
2793
2824
|
},
|
|
2794
|
-
tell: ({ source, label, error, ws }) => {
|
|
2795
|
-
const w = getWs(ws || '') || homeWorkspace(); const nf = w ? needsFileFor(w) : null; if (!nf) return;
|
|
2796
|
-
let needs = []; try { needs = JSON.parse(fs.readFileSync(nf, 'utf8')); } catch { needs = []; }
|
|
2797
|
-
needs.push({ run_id: `refresh-${source}-${Date.now()}`, kind: 'refresh', initiative_id: label, question: `${label} could not refresh: ${String(error).slice(0, 300)} See Settings, Data refresh.` });
|
|
2798
|
-
fs.writeFileSync(nf, JSON.stringify(needs)); invalidateNeedsAgg(w.id);
|
|
2799
|
-
},
|
|
2825
|
+
tell: ({ source, label, error, ws }) => tellNeed(ws, `refresh-${source}-${Date.now()}`, label, `${label} could not refresh: ${String(error).slice(0, 300)} See Settings, Data refresh.`),
|
|
2800
2826
|
setDayCheckEvery: (every) => {
|
|
2801
2827
|
let raw = {}; try { raw = JSON.parse(fs.readFileSync(PRO_SETTINGS(), 'utf8')); } catch { raw = {}; }
|
|
2802
2828
|
const cur = proSettings();
|
|
@@ -2832,7 +2858,7 @@ const gated = (id, fn) => () => { let g = { ok: true }; try { g = refreshRun.job
|
|
|
2832
2858
|
// data-refresh-settings: the seed schedules move to Settings › Data refresh (refreshRun.settings(), once) BEFORE checkDueSchedules reads
|
|
2833
2859
|
// schedules.json, so a schedule that is moving never fires once more from the old list on the first tick after an upgrade.
|
|
2834
2860
|
const scheduleOwner = require('./lib/schedule-owner.js').create({ port: PORT });
|
|
2835
|
-
try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } checkDueSchedules(); proactiveTick(); try { prepareTick({ manual: false }); } catch { /* the next tick tries again */ } try { dayTick(); } catch (e) { warnWriteFail('day run tick', e); } try { refreshRun.tick(); } catch (e) { warnWriteFail('refresh tick', e); } gated('sync', () => autoSync.tick().catch(() => {}))(); dashboardScheduleTick(); orchTick(); gated('driver', driverTick)(); gated('scan', scanTick)(); gated('finder', reportFinderTick)(); gated('coredocs', coreDocsTick)(); reportDesignTick(); reportStructureTick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
|
|
2861
|
+
try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } checkDueSchedules(); proactiveTick(); try { prepareTick({ manual: false }); } catch { /* the next tick tries again */ } try { dayTick(); } catch (e) { warnWriteFail('day run tick', e); } try { refreshRun.tick(); } catch (e) { warnWriteFail('refresh tick', e); } try { healthTick(); } catch (e) { warnWriteFail('health tick', e); } gated('sync', () => autoSync.tick().catch(() => {}))(); dashboardScheduleTick(); orchTick(); gated('driver', driverTick)(); gated('scan', scanTick)(); gated('finder', reportFinderTick)(); gated('coredocs', coreDocsTick)(); reportDesignTick(); reportStructureTick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
|
|
2836
2862
|
|
|
2837
2863
|
// ── Sessions: real PTYs, owned by the server, with disk-backed scrollback + metadata. ──
|
|
2838
2864
|
/** @type {Map<string, {id,ws,name,agent,cwd,state,note,created,pty,buf,cols,rows,clients:Set}>} */
|
|
@@ -3145,6 +3171,22 @@ function paneAsk(s, now = Date.now()) {
|
|
|
3145
3171
|
s.ask = r.status === 0 && r.stdout ? transcript.permissionAsk(r.stdout, scrub) : null;
|
|
3146
3172
|
return s.ask;
|
|
3147
3173
|
}
|
|
3174
|
+
// The pane's visible screen, plain text, or '' (no tmux pane). lib/first-input.js reads Claude Code's input box from it.
|
|
3175
|
+
function paneScreen(s) {
|
|
3176
|
+
if (!s || !s.tmux || !TMUX) return '';
|
|
3177
|
+
const r = tmuxCtl(['capture-pane', '-p', '-t', s.tmux]);
|
|
3178
|
+
return r.status === 0 && r.stdout ? String(r.stdout) : '';
|
|
3179
|
+
}
|
|
3180
|
+
/** Type `input` into session `s` (lib/first-input.js). A Claude Code pane is also read: the prompt is typed once its input box is
|
|
3181
|
+
* drawn, and Enter is pressed again while the box still holds the prompt (harness-health: the 2026-10-21 morning briefs sat
|
|
3182
|
+
* unsent). A prompt that is still not sent is written on the session, so the list and the health line say so. */
|
|
3183
|
+
function deliverInput(s, input) {
|
|
3184
|
+
const screen = s && s.agent === 'claude' && s.tmux && TMUX ? () => paneScreen(s) : null;
|
|
3185
|
+
firstInput.deliver(s, input, { screen, onDone: (why) => {
|
|
3186
|
+
if (why === 'resubmitted' || why === 'unsent') { try { s.firstInput = { result: why, at: Date.now() }; } catch { /* nothing to keep */ } }
|
|
3187
|
+
if (why === 'unsent') { s.note = 'its prompt was typed but not sent'; try { pushSessions(); } catch { /* the next list shows it */ } }
|
|
3188
|
+
} });
|
|
3189
|
+
}
|
|
3148
3190
|
function transcriptHarness(s) {
|
|
3149
3191
|
if (s.state === 'exited') return { missing: { all: 'the session has exited' } };
|
|
3150
3192
|
// A `shell` session is included: the PM launches `claude` INSIDE the default shell pane, so the
|
|
@@ -3784,7 +3826,7 @@ function sendToSession(id, text) {
|
|
|
3784
3826
|
if (!s || !s.pty || s.state === 'exited' || s.agent === 'shell') return false;
|
|
3785
3827
|
const t = String(text == null ? '' : text).replace(/[\r\n]+/g, ' ').trim();
|
|
3786
3828
|
if (!t) return false;
|
|
3787
|
-
try {
|
|
3829
|
+
try { deliverInput(s, safeFirstInput(t) + '\r'); return true; } catch { return false; }
|
|
3788
3830
|
}
|
|
3789
3831
|
|
|
3790
3832
|
/* premium-chat-session: what the premium chat panel needs from the session table. `type` keeps a leading `/`, so a slash command
|
|
@@ -3797,7 +3839,7 @@ const chatSessions = {
|
|
|
3797
3839
|
if (!s || !s.pty || s.state === 'exited') return false;
|
|
3798
3840
|
const t = String(text == null ? '' : text).replace(/[\r\n]+/g, ' ').trim();
|
|
3799
3841
|
if (!t) return false;
|
|
3800
|
-
try {
|
|
3842
|
+
try { deliverInput(s, t + '\r'); return true; } catch { return false; }
|
|
3801
3843
|
},
|
|
3802
3844
|
keys: (id, data) => { const s = sessions.get(String(id || '')); if (!s || !s.pty || s.state === 'exited') return false; try { s.pty.write(String(data)); return true; } catch { return false; } },
|
|
3803
3845
|
// slice 4 (PRD L3): the live chat sessions, so a new one can end the longest idle; busy = working or a permission prompt waits
|
|
@@ -3945,7 +3987,7 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
|
|
|
3945
3987
|
// safeFirstInput: a first input that begins with `/` is read by the agent as a slash command, not as the task.
|
|
3946
3988
|
// firstInput.deliver waits until the agent is ready to read, types the prompt, then presses Enter as its own key
|
|
3947
3989
|
// (lib/first-input.js): a burst written at a fixed 700 ms was lost or left unsent while the agent was still starting.
|
|
3948
|
-
const feed = (s) => { if (initialInput && s && s.pty) { try {
|
|
3990
|
+
const feed = (s) => { if (initialInput && s && s.pty) { try { deliverInput(s, safeFirstInput(initialInput)); } catch {} } };
|
|
3949
3991
|
// shell gets a real fallback to `sh`; agent CLIs run as-is (harness untouched), NO fallback —
|
|
3950
3992
|
// falling back from `claude` to `sh` would be a lie.
|
|
3951
3993
|
const cmd = isShell ? (commandExists(SHELL) ? SHELL : 'sh') : agent;
|
|
@@ -4605,7 +4647,7 @@ function startDayTask(run, t, now) {
|
|
|
4605
4647
|
const step = t.mode === 'send' && dayRunLib.stepOf(t);
|
|
4606
4648
|
const prev = !step && t.prev_session && sessions.get(t.prev_session);
|
|
4607
4649
|
if (!sk.error && prev && prev.state !== 'exited' && prev.pty) {
|
|
4608
|
-
try {
|
|
4650
|
+
try { deliverInput(prev, line + '\r'); s = prev; } catch { s = null; }
|
|
4609
4651
|
}
|
|
4610
4652
|
if (!sk.error && !s) {
|
|
4611
4653
|
const prompt = `${sk.prompt}\n\n${line}`;
|
|
@@ -4654,7 +4696,7 @@ function startDayCheck(run, reason, now) {
|
|
|
4654
4696
|
const prev = run.checks.prev_session && sessions.get(run.checks.prev_session);
|
|
4655
4697
|
let s = null;
|
|
4656
4698
|
if (prev && prev.pty && prev.state !== 'exited' && harness.deriveState(prev.state, prev.lastOutputAt, now).state !== 'working') {
|
|
4657
|
-
try {
|
|
4699
|
+
try { deliverInput(prev, line + '\r'); s = prev; } catch { s = null; }
|
|
4658
4700
|
}
|
|
4659
4701
|
if (!s) {
|
|
4660
4702
|
s = spawnSession({ name: 'Daytime check', agent: sk.task.agent || 'claude', ws: sk.w ? sk.w.id : run.ws, origin: 'day-check', initialInput: `${sk.prompt}\n\n${line}\r`,
|
|
@@ -4872,6 +4914,17 @@ function proSettings() {
|
|
|
4872
4914
|
try { const n = proactiveLib.normalizeSettings(JSON.parse(fs.readFileSync(PRO_SETTINGS(), 'utf8'))); if (n.ok) return n.settings; } catch { /* defaults */ }
|
|
4873
4915
|
return proactiveLib.normalizeSettings({}).settings;
|
|
4874
4916
|
}
|
|
4917
|
+
/* The connectors a new Claude session starts with: those of the default profile, else those of Claude Code's own config
|
|
4918
|
+
* (~/.claude.json, or the one in CLAUDE_CONFIG_DIR). Names only (profile-discovery.connectorsIn), each with the brief source
|
|
4919
|
+
* it already backs, so premium Settings can list every connector and say which ones nothing reads yet. */
|
|
4920
|
+
function sessionConnectors() {
|
|
4921
|
+
const disc = require('./lib/profile-discovery');
|
|
4922
|
+
const id = defaultProfileFor('claude');
|
|
4923
|
+
const prof = id ? profileById(id).profile : null;
|
|
4924
|
+
const dir = prof ? (prof.env && prof.env.CLAUDE_CONFIG_DIR) || null : process.env.CLAUDE_CONFIG_DIR || os.homedir();
|
|
4925
|
+
const names = [...new Set([...(prof && Array.isArray(prof.mcp) ? prof.mcp : []), ...(dir ? disc.connectorsIn(dir) : [])])];
|
|
4926
|
+
return { profile: prof ? prof.id : null, list: names.slice(0, proactiveLib.MAX_CONNECTORS).map((name) => ({ name, label: proactiveLib.connectorLabel(name) || name, source: proactiveLib.connectorSource(name) })) };
|
|
4927
|
+
}
|
|
4875
4928
|
function proactiveCtx(now, settings) {
|
|
4876
4929
|
const repos = [];
|
|
4877
4930
|
const allSchedules = readSchedules();
|
|
@@ -8922,7 +8975,7 @@ async function handleRequest(req, res) {
|
|
|
8922
8975
|
const sk = daySkillPrompt(run, 'morning-brief');
|
|
8923
8976
|
const s = sessions.get(run.brief_session.id);
|
|
8924
8977
|
if (!sk.error) {
|
|
8925
|
-
try {
|
|
8978
|
+
try { deliverInput(s, `${sk.prompt}\n\nThis run: prepare the day again. Read every source again and submit a new brief for today.\r`); } catch { /* typed below as a new session */ }
|
|
8926
8979
|
run.brief_session = { id: s.id, started_at: new Date(pnow).toISOString(), ended_at: null };
|
|
8927
8980
|
writeDayRun(run);
|
|
8928
8981
|
return json(res, { ok: true, started: true, reused: true, session: s.id, run, goals: open.length });
|
|
@@ -9203,7 +9256,7 @@ async function handleRequest(req, res) {
|
|
|
9203
9256
|
}
|
|
9204
9257
|
}
|
|
9205
9258
|
if (p === '/api/proactive/settings') {
|
|
9206
|
-
if (req.method === 'GET') return json(res, { ok: true, settings: proSettings() });
|
|
9259
|
+
if (req.method === 'GET') return json(res, { ok: true, settings: proSettings(), connectors: sessionConnectors() });
|
|
9207
9260
|
if (req.method === 'POST') {
|
|
9208
9261
|
let body = {}; try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
|
|
9209
9262
|
const g = pmGuard.requirePagePress(req, body); // a settings write is a page press, so an agent session gets 403
|
|
@@ -9215,7 +9268,7 @@ async function handleRequest(req, res) {
|
|
|
9215
9268
|
const dayCheck = body.dayCheck && typeof body.dayCheck === 'object' && !Array.isArray(body.dayCheck) ? { ...cur.dayCheck, ...body.dayCheck } : (body.dayCheck === undefined ? cur.dayCheck : body.dayCheck);
|
|
9216
9269
|
const bpr = body.placeRepos && typeof body.placeRepos === 'object' && !Array.isArray(body.placeRepos) ? body.placeRepos : null;
|
|
9217
9270
|
const placeRepos = bpr ? { ...cur.placeRepos, ...Object.fromEntries(Object.entries(bpr).map(([k, v]) => [k, v && typeof v === 'object' && !Array.isArray(v) ? { ...((cur.placeRepos || {})[k] || {}), ...v } : v])) } : cur.placeRepos;
|
|
9218
|
-
const n = proactiveLib.normalizeSettings({ ...cur, ...body, placeRepos, triggers: { ...cur.triggers, ...(body.triggers || {}) }, briefSources: { ...cur.briefSources, ...(body.briefSources || {}) }, about: { ...(cur.about || {}), ...(body.about && typeof body.about === 'object' && !Array.isArray(body.about) ? body.about : {}) }, scopes, dayCheck });
|
|
9271
|
+
const n = proactiveLib.normalizeSettings({ ...cur, ...body, placeRepos, triggers: { ...cur.triggers, ...(body.triggers || {}) }, briefSources: { ...cur.briefSources, ...(body.briefSources || {}) }, connectors: body.connectors && typeof body.connectors === 'object' && !Array.isArray(body.connectors) ? { ...(cur.connectors || {}), ...body.connectors } : (body.connectors === undefined ? cur.connectors : body.connectors), about: { ...(cur.about || {}), ...(body.about && typeof body.about === 'object' && !Array.isArray(body.about) ? body.about : {}) }, scopes, dayCheck });
|
|
9219
9272
|
if (!n.ok) return json(res, { ok: false, error: n.error }, 400);
|
|
9220
9273
|
try { fs.mkdirSync(STATE, { recursive: true }); fs.writeFileSync(PRO_SETTINGS(), JSON.stringify(n.settings) + '\n'); }
|
|
9221
9274
|
catch (e) { warnWriteFail('proactive-settings.json', e); return json(res, { ok: false, error: 'could not save — nothing changed' }, 500); }
|
|
@@ -9643,7 +9696,7 @@ async function handleRequest(req, res) {
|
|
|
9643
9696
|
else if (x.pty) { if (x.tmux) tmuxKillSession(x.tmux); try { x.pty.kill(); } catch { /* already ended */ } }
|
|
9644
9697
|
},
|
|
9645
9698
|
// workspace-data-freshness: the source table, the facts rebuild and Refresh now's skill sessions
|
|
9646
|
-
freshness, factsRefresh: (root) => factsAsync.refresh(root, { force: true }), startSkill: startSkillSession,
|
|
9699
|
+
freshness, factsRefresh: (root) => factsAsync.refresh(root, { force: true }), startSkill: startSkillSession, health: () => harnessHealth(),
|
|
9647
9700
|
// c3-initiative-boards: the PMOS checkout this server is embedded in, whose default board keeps its derived ladder
|
|
9648
9701
|
selfRoot: EMBEDDED_SELF ? SELF_ROOT : null,
|
|
9649
9702
|
// horizon-scan-portfolio: Scan now, Stop and an approved research proposal start and end runs in the scanner; scanClock fixes its clock in the suites
|