create-pmos 0.439.0 → 0.441.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.
Files changed (66) hide show
  1. package/bin/create-pmos.js +5 -2
  2. package/package.json +25 -25
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/planning/evals/eval-calibration.md +1 -1
  5. package/payload/planning/okrs/health-budgets.md +1 -1
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +16 -13
  8. package/workspace/briefing-premium-insights-test.js +1 -1
  9. package/workspace/briefing-premium-products-test.js +4 -4
  10. package/workspace/briefing-premium-sources-test.js +2 -2
  11. package/workspace/briefing-premium-test.js +29 -23
  12. package/workspace/changelog.json +24 -0
  13. package/workspace/guide/core-documents.md +2 -2
  14. package/workspace/guide/data-freshness.md +7 -5
  15. package/workspace/guide/home.md +4 -1
  16. package/workspace/guide/horizon-scan.md +1 -1
  17. package/workspace/guide/settings.md +2 -2
  18. package/workspace/lib/agent-inbox.js +20 -2
  19. package/workspace/lib/briefing-premium-sources.js +3 -0
  20. package/workspace/lib/briefing-premium.js +37 -7
  21. package/workspace/lib/driver-cli.js +1 -1
  22. package/workspace/lib/driver-run.js +15 -1
  23. package/workspace/lib/driver.js +31 -2
  24. package/workspace/lib/goal-status.js +2 -1
  25. package/workspace/lib/headless.js +18 -1
  26. package/workspace/lib/kit-update.js +2 -2
  27. package/workspace/lib/metric-draft-runs.js +10 -4
  28. package/workspace/lib/news-for-you.js +24 -9
  29. package/workspace/lib/pm-idle.js +12 -0
  30. package/workspace/lib/refresh.js +17 -8
  31. package/workspace/lib/routes-core-docs.js +1 -1
  32. package/workspace/lib/routes-metric-drafts.js +2 -2
  33. package/workspace/lib/routes-news.js +15 -1
  34. package/workspace/lib/routes-phone-day.js +6 -4
  35. package/workspace/need-shot.js +57 -0
  36. package/workspace/news-viewers-test.js +183 -0
  37. package/workspace/package-lock.json +2 -2
  38. package/workspace/package.json +1 -1
  39. package/workspace/premium-core-doc-issue-test.js +9 -8
  40. package/workspace/premium-phone-card-test.js +9 -6
  41. package/workspace/public/pm/bd-ini-panel.js +4 -11
  42. package/workspace/public/pm/cozy-ev.css +29 -0
  43. package/workspace/public/pm/cozy-live-pill.css +6 -0
  44. package/workspace/public/pm/cozy-news.js +186 -22
  45. package/workspace/public/pm/cozy-today.css +5 -0
  46. package/workspace/public/pm/cozy-viewer.js +4 -3
  47. package/workspace/public/pm/cozy-vw-shell.css +49 -0
  48. package/workspace/public/pm/home-adddoc.js +46 -26
  49. package/workspace/public/pm/home-app.js +137 -115
  50. package/workspace/public/pm/home-day.js +15 -11
  51. package/workspace/public/pm/home-draft.js +35 -23
  52. package/workspace/public/pm/home-ini.js +2 -2
  53. package/workspace/public/pm/home-need.js +336 -0
  54. package/workspace/public/pm/home-phone-card.js +4 -2
  55. package/workspace/public/pm/home-today.js +2 -2
  56. package/workspace/public/pm/home-work.js +51 -4
  57. package/workspace/public/pm/okr-list.js +8 -4
  58. package/workspace/public/pm/premium-insights.js +6 -5
  59. package/workspace/public/pm/small-vw.js +128 -0
  60. package/workspace/public/premium-intelligence.html +1 -1
  61. package/workspace/server.js +20 -11
  62. package/workspace/skills/initiative-drive.skill +4 -1
  63. package/workspace/test-lists/batch18-asks.json +5 -0
  64. package/workspace/test-lists/news-viewers.json +13 -0
  65. package/workspace/test-lists/small-viewers.json +5 -0
  66. package/workspace/test-run.js +3 -1
@@ -387,13 +387,13 @@ const listGoals = () => (PF ? [] : M.goals.filter((g) => isOwnKr(g) && (g.role =
387
387
  * the strip's first item; the findings and the reports Claude proposes follow it. It never says "There is no insight yet". */
388
388
  function okrLine() {
389
389
  const run = DR && DR.run;
390
- return OK.lineOf({ okr: M.okr, goals: listGoals(), budgets: M.budgets || [], drafts: drAll(), running: !!(run && run.state === 'running'), product: M.board.name });
390
+ return OK.lineOf({ okr: M.okr, goals: listGoals(), budgets: M.budgets || [], drafts: drAll(), running: !!(run && run.state === 'running'), failed: run && run.state === 'failed' ? (run.error || 'The run failed') : null, product: M.board.name });
391
391
  }
392
392
  function stripList() {
393
393
  const I0 = M.insight || { none: true, text: '' };
394
394
  // Your impact (batch 16 item 7, GmA4Moments): a key result that moved after your work, as one more ✦ line, with its source to open
395
395
  const im = PF ? null : IM.intelItem(), mine = im ? [im] : [];
396
- const ok = PF ? [] : [Object.assign({ okr: true, text: '', why: '' }, (() => { const L = okrLine(); return { text: L.head, why: L.sub, tone: L.tone, keepAll: L.keepAll, start: !!L.start }; })())];
396
+ const ok = PF ? [] : [Object.assign({ okr: true, text: '', why: '' }, (() => { const L = okrLine(); return { text: L.head, why: L.sub, tone: L.tone, keepAll: L.keepAll, start: !!L.start, retry: !!L.retry }; })())];
397
397
  if (I0.none) return ok.concat(PF ? [] : RI.stripItems(), mine);
398
398
  const finds = [{ text: I0.text, why: I0.why || '', chart: I0.chart, move: I0.move || null, calm: !!I0.calm }].concat((I0.more || []).map((x) => ({ text: x.text, why: x.why || '', chart: x.chart, move: x.move || null })));
399
399
  // a calm finding ("Nothing stands out") says what the ✦ line already says: it is left out
@@ -426,7 +426,7 @@ function drawStrip() {
426
426
  : `<button type="button" class="cz-ib sm solid" data-mv="apply" aria-label="${esc(mv.label)}" title="${esc(mv.label)}">${SV(I.chk)}</button>`;
427
427
  // the ✦ line's own press: ✓✓ keeps every draft (GsM1, GsM5); with nothing to read, ✦ asks Claude to draft the goals
428
428
  const okAct = !f.okr ? '' : f.keepAll ? `<button type="button" class="cz-ib sm solid" data-okl="keep-all" aria-label="Keep all ${f.keepAll}" title="Keep all ${f.keepAll}">${OK.SV(OK.P.checks)}</button>`
429
- : f.start && M.board.ws ? `<button type="button" class="cz-ib sm solid" data-okl="start" aria-label="Draft them" title="Draft them">${SV(I.spark)}</button>` : '';
429
+ : f.start && M.board.ws ? `<button type="button" class="cz-ib sm solid" data-okl="start" aria-label="${f.retry ? 'Try drafting again' : 'Draft them'}" title="${f.retry ? 'Try again' : 'Draft them'}">${SV(I.spark)}</button>` : '';
430
430
  if (!f.report) $('#insAct').innerHTML = mvAct + okAct;
431
431
  if (open.length > 1) {
432
432
  if (!f.report) $('#insAct').innerHTML = `<button type="button" class="cz-ib sm" id="insNo" aria-label="Not now" title="Not now">${SV(I.x)}</button>` + mvAct + okAct;
@@ -547,7 +547,8 @@ async function draftPress(k, row, b) {
547
547
  const res = await pmPost('/api/metric-drafts/' + k, Object.assign({}, base, row ? { row } : {}));
548
548
  if (!res || res.ok !== true) { if (b) b.disabled = false; toast((res && res.error) || 'It could not be done. Nothing changed.'); return; }
549
549
  const name = r0 ? r0.text : 'it';
550
- const said = k === 'start' ? 'I am drafting them. They appear under each goal.'
550
+ // batch 18 item 4: say only what the server started. The run is in Sessions; the ✦ line follows it and says when it ends, or why it failed.
551
+ const said = k === 'start' ? (res.already ? 'I am already drafting them. The drafts show here when I finish.' : 'Drafting now. Follow it in Sessions; the drafts show here when I finish.')
551
552
  : k === 'keep-all' ? 'Kept ' + (res.kept || 'them all') + '. I read them from now on.'
552
553
  : k === 'keep' ? (res.outbox ? (r0 && r0.kind === 'ticket' ? 'In the outbox for Jira.' : 'In the outbox. It goes as you.') : res.open === 'settings:connectors' ? 'Opening Connectors.' : 'Kept. I read it from now on.')
553
554
  : k === 'drop' ? 'Not now: ' + name + '.' : k === 'undo' ? 'Undone.' : 'Done.';
@@ -894,7 +895,7 @@ function openBudget(id) {
894
895
  const b = (M.budgets || []).find((x) => x.id === id); if (!b) return;
895
896
  const R = b.reading, has = R && R.share !== null;
896
897
  const sum = { line: [has ? pct(R.share) + ' now' : 'No reading yet', b.cap !== null ? 'cap ' + pct(b.cap) + ' of a quarter’s initiatives' : 'no cap declared'].join(' · '), tone: has && R.over ? 'warn' : '',
897
- text: has ? (R.over ? 'Over its cap.' : 'Within its cap.') + ' ' + R.n + ' of ' + R.total + ' open on the Board.' : 'It has no reading: ' + (b.declared ? 'no open initiative to share.' : 'it is not in the budget registry.'),
898
+ text: has ? (R.over ? 'Over its cap.' : 'Within its cap.') + ' ' + R.n + ' of ' + R.total + ' open on the Board.' : b.declared ? 'It has no reading: no open initiative to share.' : 'Initiatives use it, but no limit is set for it yet. Discuss it in Home and I set one up.',
898
899
  meta: [b.anchor, 'always on', 'judged every week'].join(' · ') };
899
900
  const text = [b.title, sum.line, sum.text].join('\n');
900
901
  vwOpen({ kind: 'Health budget', title: b.title, icon: 'goal', id: 'budget:' + id, more: [{ label: 'Copy as text', on: () => copyText(text, 'Copied as text.') }],
@@ -0,0 +1,128 @@
1
+ /* pm/small-vw.js — the small Viewers in shell A (feedback batch 18 item 2-C; canvas In development OvA8People): a stakeholder, the one
2
+ * stakeholder form Home and the Board share, and a routine. Summary first; no ids, crons or file paths in the body.
3
+ *
4
+ * openPersonVw(p, ctx) p { name, role, note, at }. Title the name, sub the initiative; the summary is the role (no tone), the note, the day
5
+ * it was added. ⋯: Change the role or note, then Remove from this initiative (danger, last; Undo adds it back).
6
+ * openPersonForm(ctx, p?) Add a stakeholder (no p) or change one (p). ✓ in the header saves, ← cancels. The fields keep their ids (hpN, hpR,
7
+ * hpT). A changed name adds the new name, then removes the old one.
8
+ * ctx { VW, pmPost, toast(text, undo?), ws, ini, iniTitle, saved() after a write, back() what ← goes to when nothing is behind }
9
+ * openRoutineVw(s, { VW, now? }) "Next run Monday 09:00", the repeat in words (never the cron) and what it runs said once, when it last ran. There is no
10
+ * primary: a schedule's run keeps no pointer to its result (the metrics review opens its own Viewer, home-app.js).
11
+ * repeatsOf(s) · nextLine(s, now) — pure, for the tests.
12
+ * Writes go to POST /api/home-desk/stakeholder only (the route the old Viewers used). */
13
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
+ const I = {
15
+ person: 'M12 4a4 4 0 1 0 0 8a4 4 0 1 0 0-8M4 21c0-4 3.6-6.5 8-6.5s8 2.5 8 6.5',
16
+ routine: 'M4 11a8 8 0 0 1 14-5.3M20 4v5h-5M20 13a8 8 0 0 1-14 5.3M4 20v-5h5',
17
+ check: 'M5 12.5l4.5 4.5L19 7.5',
18
+ pen: 'M4 20h4L19 9l-4-4L4 16zM14 6l4 4',
19
+ x: 'M6 6l12 12M18 6L6 18',
20
+ };
21
+ const DAYS = { Sun: 'Sunday', Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday' };
22
+ const WEEK = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
23
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
24
+ const hm = (d) => String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0');
25
+ const dayMon = (d) => d.getDate() + ' ' + MON[d.getMonth()];
26
+ const words = (s) => { const t = String(s || '').replace(/[-_]+/g, ' ').trim(); return t ? t.charAt(0).toUpperCase() + t.slice(1) : ''; };
27
+
28
+ /* ── the stakeholder ── */
29
+ export function openPersonVw(p, ctx, opt = {}) {
30
+ const added = p.at && !isNaN(new Date(p.at)) ? 'Added ' + dayMon(new Date(p.at)) : '';
31
+ const body = ctx.VW.open({ id: 'person:' + p.name, kind: 'Stakeholder', title: p.name, keep: !!opt.keep, sub: ctx.iniTitle || '', icon: I.person,
32
+ more: [
33
+ { label: 'Change the role or note', icon: I.pen, on: () => openPersonForm(ctx, p) },
34
+ { sep: true },
35
+ { label: 'Remove from this initiative', icon: I.x, danger: true, on: () => remove() },
36
+ ],
37
+ render: (b) => {
38
+ b.innerHTML = ctx.VW.czSummary({ line: p.role || '', text: p.note || '', meta: added })
39
+ || `<p class="czs-quiet">${esc(added || 'No role or note yet.')}</p>`;
40
+ } });
41
+ async function remove() {
42
+ const r = await ctx.pmPost('/api/home-desk/stakeholder', { ws: ctx.ws, initiative: ctx.ini, name: p.name, remove: true }).catch(() => null);
43
+ if (!(r && r.ok)) { ctx.toast((r && r.error) || 'Not removed.'); return; }
44
+ ctx.toast('Removed ' + p.name + '.', async () => { await ctx.pmPost('/api/home-desk/stakeholder', { ws: ctx.ws, initiative: ctx.ini, name: p.name, role: p.role || '', note: p.note || '' }).catch(() => null); if (ctx.saved) await ctx.saved(); });
45
+ if (ctx.back) ctx.back(); else ctx.VW.close();
46
+ if (ctx.saved) await ctx.saved();
47
+ }
48
+ return body;
49
+ }
50
+
51
+ /** One form for Add a stakeholder on Home and the Board (OvA8People): ✓ in the header saves, ← cancels. */
52
+ export function openPersonForm(ctx, p) {
53
+ const edit = !!p;
54
+ let busy = false;
55
+ const field = (id, label, val, ph, max) => `<label class="czf-l"><span>${label}</span><input id="${id}" maxlength="${max}" autocomplete="off"${ph ? ` placeholder="${esc(ph)}"` : ''} value="${esc(val || '')}"></label>`;
56
+ if (ctx.VW.drill) ctx.VW.drill(); // ← comes back to what opened the form (the stakeholder, or the initiative)
57
+ const body = ctx.VW.open({ id: 'person:' + (edit ? 'edit:' + p.name : 'new'), kind: 'Stakeholder', title: edit ? 'Change ' + p.name : 'Add a stakeholder', sub: ctx.iniTitle || '', icon: I.person, back: true,
58
+ presses: [{ act: 'save', label: edit ? 'Save the stakeholder' : 'Add the stakeholder', icon: I.check, solid: true, blue: true }],
59
+ onPress: (a) => { if (a === 'save') save(); },
60
+ render: (b) => {
61
+ b.innerHTML = `<form class="czf" data-czf-person novalidate>${field('hpN', 'Name', edit ? p.name : '', '', 80)}${field('hpR', 'Role', edit ? p.role : '', 'For example: Head of Sales', 80)}`
62
+ + `${field('hpT', 'What they care about', edit ? p.note : '', 'One line', 200)}<p class="czf-err" id="hpM" role="status"></p><button type="submit" hidden></button></form>`;
63
+ } });
64
+ const $ = (s) => body.querySelector(s);
65
+ body.addEventListener('submit', (e) => { e.preventDefault(); save(); });
66
+ setTimeout(() => { const i = $('#hpN'); if (i) i.focus(); }, 0);
67
+ async function save() {
68
+ if (busy) return;
69
+ const name = $('#hpN').value.trim(), m = $('#hpM');
70
+ if (!name) { m.textContent = 'Name the person.'; $('#hpN').focus(); return; }
71
+ busy = true;
72
+ const post = (x) => ctx.pmPost('/api/home-desk/stakeholder', { ws: ctx.ws, initiative: ctx.ini, ...x }).catch(() => null);
73
+ const role = $('#hpR').value.trim(), note = $('#hpT').value.trim();
74
+ const r = await post({ name, role, note });
75
+ if (r && r.ok && edit && name.toLowerCase() !== p.name.toLowerCase()) await post({ name: p.name, remove: true });
76
+ busy = false;
77
+ if (!(r && r.ok)) { m.textContent = (r && r.error) || (edit ? 'Not saved.' : 'Not added.'); return; }
78
+ ctx.toast(edit ? 'Saved.' : 'Added ' + name + '.');
79
+ // back to what opened the form first, then the page reads again (a read while the form shows would draw under its header)
80
+ if (edit) { ctx.VW.back(); openPersonVw({ ...p, name, role, note }, ctx, { keep: true }); } // the stakeholder again, as saved
81
+ else if (ctx.back) ctx.back(); else ctx.VW.close();
82
+ if (ctx.saved) await ctx.saved();
83
+ }
84
+ return body;
85
+ }
86
+
87
+ /* ── the routine ── */
88
+ /** The repeat in words, from the schedule's own fields (lib/schedule-logic.js); never the cron. '' when it names none. */
89
+ export function repeatsOf(s) {
90
+ const t = /^\d{1,2}:\d{2}$/.test(String(s.time || '')) ? String(s.time).padStart(5, '0') : '';
91
+ const at = t ? ' at ' + t : '';
92
+ const day = DAYS[s.day] || 'Monday';
93
+ if (s.cadence === 'daily') return 'Every day' + at;
94
+ if (s.cadence === 'weekly') return 'Every ' + day + at;
95
+ if (s.cadence === 'bi-weekly') return 'Every other ' + day + at;
96
+ if (s.cadence === 'monthly') return 'On day ' + (s.dayOfMonth || 1) + ' of each month' + at;
97
+ if (s.cadence === 'once') return 'Once' + (s.date ? ', on ' + dayMon(new Date(s.date + 'T00:00:00')) : '') + at;
98
+ const w = String(s.every || s.when || '');
99
+ return /[*/]|^\s*\d+(\s+\S+){4}\s*$/.test(w) ? '' : words(w); // a cron-like string is not words
100
+ }
101
+ /** "Next run Monday 09:00" (today, tomorrow and this week by the day's name; later by the date), "Off", or "Not scheduled". */
102
+ export function nextLine(s, now = Date.now()) {
103
+ if (s.enabled === false) return 'Off';
104
+ const n = s.next ? new Date(s.next) : null;
105
+ if (!n || isNaN(n)) return 'Not scheduled';
106
+ const a = new Date(now); a.setHours(0, 0, 0, 0);
107
+ const b = new Date(n); b.setHours(0, 0, 0, 0);
108
+ const d = Math.round((b - a) / 864e5);
109
+ return 'Next run ' + (d === 0 ? 'today' : d === 1 ? 'tomorrow' : d > 1 && d < 7 ? WEEK[n.getDay()] : WEEK[n.getDay()] + ' ' + dayMon(n)) + ' ' + hm(n);
110
+ }
111
+ const lastOf = (s) => {
112
+ if (!s.lastRun || isNaN(new Date(s.lastRun))) return '';
113
+ const d = new Date(s.lastRun), st = { ok: 'finished', fail: 'did not finish', started: 'started' }[s.lastStatus] || '';
114
+ return WEEK[d.getDay()].slice(0, 3) + ' ' + dayMon(d) + (st ? ' · ' + st : '');
115
+ };
116
+ export function openRoutineVw(s, o) {
117
+ const name = words(s.name || s.task || s.skill) || 'Routine';
118
+ const what = words(s.task || s.skill);
119
+ const rep = repeatsOf(s), line = nextLine(s, o.now), last = lastOf(s);
120
+ const text = s.enabled === false ? 'It is off: it does not run until it is turned on again.'
121
+ : (rep || 'On its schedule') + (what ? ', it runs ' + what + '.' : '.');
122
+ return o.VW.open({ id: 'routine:' + (s.id || s.name), kind: 'Routine', title: name, sub: 'Routine', icon: I.routine,
123
+ render: (b) => {
124
+ b.innerHTML = o.VW.czSummary({ line, tone: s.enabled === false || !s.next ? '' : 'ok', text })
125
+ // the repeat and what it runs are said in the summary once (say it once); the fold row keeps what the summary does not say
126
+ + o.VW.czSections([last ? { id: 'last', title: 'Last ran', count: last } : null], { key: 'routine' });
127
+ } });
128
+ }
@@ -50,7 +50,7 @@
50
50
  </div>
51
51
 
52
52
  <!-- the ✦ strip (Iq8Overview): one finding at a time, its drafted move when it has one, Ask why, Not now and the dots that page through them -->
53
- <div class="ins-strip ins-hero" id="insHero"><span class="sp" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg></span><p class="t" id="insText" aria-live="polite"><b id="insEye"></b> <span id="brief">Reading the records.</span> <span id="insWhy"></span><span class="ins-mv" id="insMv" hidden></span></p><span class="ins-hact" id="insAct"></span><a class="cz-chip gh" id="askWhy" href="/premium.html?ask=insights"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1z"/></svg>Ask why</a><span class="ins-pg" id="insPg"></span></div>
53
+ <div class="ins-strip ins-hero" id="insHero"><span class="sp" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg></span><p class="t" id="insText" aria-live="polite"><b id="insEye"></b> <span id="brief">Reading the records.</span> <span id="insWhy"></span><span class="ins-mv" id="insMv" hidden></span></p><span class="ins-hact" id="insAct"></span><a class="cz-chip gh" id="askWhy" href="/premium.html?ask=insights"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z"/></svg>Ask why</a><span class="ins-pg" id="insPg"></span></div>
54
54
  <!-- the North Star and its inputs (Iq8Overview): drawn only when a KR metric record has role north-star -->
55
55
  <section class="ins-ns" id="nsRow" aria-label="North Star" hidden></section>
56
56
  <!-- what Claude drafted for this product (Iq8Suggest, Iq9Draft): shown only while a draft is running or waits for your ✓ -->
@@ -81,6 +81,7 @@ const jevClaims = require('./lib/jev-claims.js'); // D80 — the bridge betwee
81
81
  const jevCategorize = require('./lib/jev-categorize.js'); // D82 — the bridge between the document categorizer and the one TypeSafe module
82
82
  const validateLib = require('./lib/validate.js');
83
83
  const pageAgent = require('./lib/page-agent.js'); // page-starts-agent — the fixed prompts a page press may start
84
+ const pmIdle = require('./lib/pm-idle.js'); // batch 18 item 9: how long the PM has been away, for deep work
84
85
  const scanRunLib = require('./lib/scan-run.js'); // horizon-scan — the watch list suggest run and the scheduled scans, in the 60-second tick
85
86
  const reportFinderLib = require('./lib/report-finder.js'); // report-workspace — the weekly look for the reports the PM already sends
86
87
  const refreshLib = require('./lib/refresh.js'); // data-refresh-settings — the sources, their schedules and the refresh log
@@ -2845,6 +2846,7 @@ const reportFinderTick = () => {
2845
2846
  // feedback batch 4 item 6 (canvas XmsgB): Claude reviews each program's milestones and files suggestions the PM keeps, changes or drops. ONE headless
2846
2847
  // run at a time for the machine (lib/milestone-review.js): Check now at once; new programs, joins and leaves, a moved ◆ date, a milestone's date and
2847
2848
  // Monday 09:00 inside the working hours. Its only write is `pmos program suggest`; the charter changes only on the PM's press. PMOS_MS_REVIEW=off.
2849
+ const deepOpenNow = (now) => require('./lib/driver-run.js').deepOpen(proSettings(), now, (n, q) => proactiveLib.inQuietHours(n, q));
2848
2850
  const msReviewCtx = () => ({ getWs, stateDirFor, workspaceList: () => [...workspaces.values()] });
2849
2851
  const msReviewer = require('./lib/milestone-review.js').create({
2850
2852
  programs: () => require('./lib/routes-programs.js').all(msReviewCtx()),
@@ -2889,7 +2891,7 @@ const proposalRuns = require('./lib/proposal-runs.js').create({
2889
2891
  },
2890
2892
  rowOf: (w, id) => { const r = require('./lib/routes-boards.js').initiativeWorkflow(proposalCtx(), w, id); if (!r.ok) return null;
2891
2893
  return { title: r.row.title || id, intent: r.row.intent || r.row.why || '', stage: r.row.stage || '', stages: (r.row.wfStages || []).map((s) => ({ key: s.key, name: s.name })) }; },
2892
- open: (now) => require('./lib/driver-run.js').dayCheckOpen(proSettings(), now, (n, q) => proactiveLib.inQuietHours(n, q)),
2894
+ open: deepOpenNow, // batch 18 item 9: deep work runs at night or when the PM is idle (lib/driver-run.js deepOpen)
2893
2895
  headlessOff: () => headlessLib.switchedOff(process.env),
2894
2896
  env: process.env,
2895
2897
  promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
@@ -2929,12 +2931,12 @@ const metricDraftRuns = require('./lib/metric-draft-runs.js').create({
2929
2931
  if (scope === 'initiative') { const g = metricDraftInis(w).find((x) => x.id === id); for (const a of (g && g.artifacts) || []) if (!a.shared) out.push(a.role + ': ' + a.path); }
2930
2932
  return out;
2931
2933
  },
2932
- open: (now) => require('./lib/driver-run.js').dayCheckOpen(proSettings(), now, (n, q) => proactiveLib.inQuietHours(n, q)),
2934
+ open: deepOpenNow, // batch 18 item 9: deep work runs at night or when the PM is idle (lib/driver-run.js deepOpen)
2933
2935
  headlessOff: () => headlessLib.switchedOff(process.env),
2934
2936
  env: process.env,
2935
2937
  promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
2936
2938
  spawn: (spec) => orchSpawn.spawn({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone }),
2937
- spawnNow: (spec) => spawnSession({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone }),
2939
+ spawnNow: (spec) => spawnSession({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone, byPm: spec.byPm === true }),
2938
2940
  stop: (s) => { if (s && s.child) stopHeadless(s); },
2939
2941
  warn: (what, e) => warnWriteFail(what, e),
2940
2942
  });
@@ -2953,7 +2955,7 @@ const impactRuns = require('./lib/impact-runs.js').create({
2953
2955
  out.push('Stored reads: run `pmos source status`, then `pmos source show <source>` for slack, mail, jira, calendar and wispr');
2954
2956
  return out;
2955
2957
  },
2956
- open: (now) => require('./lib/driver-run.js').dayCheckOpen(proSettings(), now, (n, q) => proactiveLib.inQuietHours(n, q)),
2958
+ open: deepOpenNow, // batch 18 item 9: deep work runs at night or when the PM is idle (lib/driver-run.js deepOpen)
2957
2959
  headlessOff: () => headlessLib.switchedOff(process.env),
2958
2960
  env: process.env,
2959
2961
  promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
@@ -2981,7 +2983,7 @@ const metricReadRuns = require('./lib/metric-read-runs.js').create({
2981
2983
  return (rids || []).map((id) => S && S.rows.get(id)).filter((r) => r && r.recipe).map((r) => ({ rid: r.id, title: (r.metric && r.metric.name) || r.text, unit: (r.metric && r.metric.unit) || '', recipe: r.recipe }));
2982
2984
  },
2983
2985
  afterRead: (w, rids, now) => require('./lib/routes-goal-status.js').afterRead({ getWs, stateDirFor, workspaceList: () => [...workspaces.values()], runtimeDir: STATE, tellGoalAlert: goalAlertTell }, w, rids, now),
2984
- open: (now) => require('./lib/driver-run.js').dayCheckOpen(proSettings(), now, (n, q) => proactiveLib.inQuietHours(n, q)),
2986
+ open: deepOpenNow, // batch 18 item 9: deep work runs at night or when the PM is idle (lib/driver-run.js deepOpen)
2985
2987
  headlessOff: () => headlessLib.switchedOff(process.env),
2986
2988
  env: process.env,
2987
2989
  promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
@@ -3000,7 +3002,7 @@ const coreDocsTick = () => {
3000
3002
  try {
3001
3003
  m.tick({ getWs, stateDirFor, workspaceList: () => [...workspaces.values()], runtimeDir: STATE, selfRoot: EMBEDDED_SELF ? SELF_ROOT : null, initiativeIndex,
3002
3004
  spawnSession: orchSpawn.spawn, stopSession: (id) => { const x = sessions.get(String(id || '')); if (x && x.child) stopHeadless(x); }, invalidateNeedsAgg,
3003
- proSettings, inQuiet: (now, quiet) => proactiveLib.inQuietHours(now, quiet), isLead: (w) => isPlanNeedsTree(w) }, Number.isFinite(t) ? { now: t } : {});
3005
+ proSettings, inQuiet: (now, quiet) => proactiveLib.inQuietHours(now, quiet), deepOpen: (st, now) => deepOpenNow(now), isLead: (w) => isPlanNeedsTree(w) }, Number.isFinite(t) ? { now: t } : {});
3004
3006
  } catch (e) { warnWriteFail('core documents tick', e); }
3005
3007
  };
3006
3008
  /** One needs-you item, so it shows in the bell. */
@@ -3129,6 +3131,7 @@ function persist(s) {
3129
3131
  state: s.state, note: s.note || '', created: s.created, tmux: s.tmux || null, origin: s.origin || null };
3130
3132
  if (s.autoDelete) meta.autoDelete = s.autoDelete;
3131
3133
  if (s.autoEnded) meta.autoEnded = true;
3134
+ if (s.byPm) meta.byPm = true;
3132
3135
  if (s.headless) meta.headless = s.headless;
3133
3136
  if (s.outcome) meta.outcome = s.outcome; // a background run's end, for its card (initiative background-run-outcome)
3134
3137
  if (s.exitedAt) meta.exitedAt = s.exitedAt;
@@ -3581,7 +3584,7 @@ function sessionList() {
3581
3584
  auto_name: s.autoName ? s.autoName.text : null, name_by: s.nameBy || null,
3582
3585
  model: 'model' in s ? s.model : null, model_line: modelLib.line('model' in s ? s.model : null),
3583
3586
  cwd: path.relative(s.root, s.cwd) || '.', note: s.note || '', origin: s.origin || null,
3584
- automatic: sessionOrigin.isAutomatic(s.origin), // the workspace started it, not the PM: the dock hides these by default
3587
+ automatic: sessionOrigin.isAutomatic(s.origin) && !s.byPm, // the workspace started it, not the PM: the dock hides these by default
3585
3588
  auto_delete: s.autoDelete || null,
3586
3589
  auto_ended: !!s.autoEnded, // PMOS ended it (idle, or room for a newer chat), not the PM: a chat's row stays on Home and resumes (batch 7)
3587
3590
  headless: s.headless || null, // workspace-headless-jobs: a background run with no terminal ('notes' or 'skill')
@@ -4369,7 +4372,7 @@ function spawnSession(opts) {
4369
4372
  return s;
4370
4373
  }
4371
4374
  function noteSessionEnd(s) { try { if (refreshRun) refreshRun.ended(s); } catch (e) { warnWriteFail('refresh log (end)', e); } }
4372
- function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile, initiative, modelAsk, planItem, workType, autoDelete, launchFlags, addDirs, onDone, scratch, extraEnv, writePaths, chatClaude }) {
4375
+ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile, initiative, modelAsk, planItem, workType, autoDelete, launchFlags, addDirs, onDone, scratch, extraEnv, writePaths, chatClaude, byPm }) {
4373
4376
  const id = nextSessionId();
4374
4377
  /* pm-os-absorb Run 1 — every AGENT session gets a token, `<id>.<8 hex>`, in its environment as PMOS_SESSION, and
4375
4378
  * PMOS_BIN, this workspace's own bin/pmos.js. `pmos item` run inside it is then attributed `agent:<token>` (the token
@@ -4426,9 +4429,10 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
4426
4429
  itemEnv.PMOS_WS_PORT = String(PORT);
4427
4430
  Object.assign(penv, itemEnv);
4428
4431
  // horizon-scan: the scan runs set PMOS_SCAN_FILE, PMOS_SCAN_ORIGIN and PMOS_SCAN_RUN for `pmos scan file`; the report-setup and report-find runs
4429
- // (report-workspace) set PMOS_REPORT_FILE and PMOS_REPORT_RUN for `pmos report propose`; nothing else is added.
4432
+ // (report-workspace) set PMOS_REPORT_FILE and PMOS_REPORT_RUN for `pmos report propose`.
4430
4433
  // core-documents: a core-doc run sets PMOS_CORE_DOC_SCOPE and PMOS_CORE_DOC_KEY, the one entry `pmos coredoc write` may write.
4431
- if (extraEnv && typeof extraEnv === 'object') for (const k of ['PMOS_SCAN_FILE', 'PMOS_SCAN_ORIGIN', 'PMOS_SCAN_RUN', 'PMOS_REPORT_FILE', 'PMOS_REPORT_RUN', 'PMOS_CORE_DOC_SCOPE', 'PMOS_CORE_DOC_KEY', 'PMOS_CORE_DOC_KEYS']) if (typeof extraEnv[k] === 'string') penv[k] = extraEnv[k];
4434
+ // A metric-draft, propose, impact, metric-read or ms-review run sets its own pins too (lib/headless.js RUN_ENV).
4435
+ Object.assign(penv, headlessLib.runEnvOf(extraEnv));
4432
4436
  const base = { id, ws: w ? w.id : wsId(SELF_ROOT), root, name: (name && String(name).trim()) || agent, agent, origin: tag,
4433
4437
  profile: pres.id, profileRefusal: pres.ok ? null : pres.error };
4434
4438
  // Hand to agent: the breakdown item this session was started for, or null. Set only by /api/plan-items/handoff/go.
@@ -4437,6 +4441,9 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
4437
4441
  if (scratch) base.scratchDir = workdir; // removed when the web run ends (startHeadless)
4438
4442
  // 'never' opts this one job out of the automatic clean-up (lib/session-origin.js); anything else is the workspace policy.
4439
4443
  if (autoDelete === 'never') base.autoDelete = 'never';
4444
+ // batch 18 item 4: a background run the PM's own press started (✦ Draft them on Intelligence) is listed with the PM's sessions while it runs,
4445
+ // not folded into "Started by PMOS", so the press shows a session at once
4446
+ if (byPm === true) base.byPm = true;
4440
4447
  const wt = workTypeOrNull(workType);
4441
4448
  if (wt) base.workType = wt;
4442
4449
  // session names A: a chat that resumes its own Claude conversation keeps the name it had (the PM's, or Claude's)
@@ -10444,6 +10451,8 @@ function writeChangeContext(dir) {
10444
10451
  // remote flag off there is no non-loopback listener, so this is transparent for local dev. Headers
10445
10452
  // and the token are never logged (D08).
10446
10453
  function httpGuard(req, res) {
10454
+ // batch 18 item 9: a page press (it carries the launch nonce, which no agent session has) is the PM at work; deep work waits for them to step away
10455
+ if (req.method !== 'GET' && req.method !== 'HEAD' && pmGuard.launchNonce() && req.headers[pmGuard.NONCE_HEADER] === pmGuard.launchNonce()) pmIdle.touch();
10447
10456
  // Origin/Host allowlist FIRST (D64 A1): reject a cross-site / DNS-rebinding request before the
10448
10457
  // token exemption for loopback can be reached. Header values are never logged (D08).
10449
10458
  if (!remoteAccess.checkHostOrigin({ origin: req.headers.origin, host: req.headers.host, binds: BIND.binds, publicHost: publicHost() })) {
@@ -10604,7 +10613,7 @@ wss.on('connection', (ws) => {
10604
10613
  } else if (m.t === 'detach') {
10605
10614
  const s = sessions.get(m.id); if (s) s.clients.delete(ws); ws.attached.delete(m.id);
10606
10615
  } else if (m.t === 'input') {
10607
- const s = sessions.get(m.id); if (s && s.pty) { s.pty.write(m.data); if (typeof m.data === 'string' && !/^\x1b/.test(m.data)) touchSession(s); } // a key the PM typed, not the terminal's own reply to a query
10616
+ const s = sessions.get(m.id); if (s && s.pty) { s.pty.write(m.data); if (typeof m.data === 'string' && !/^\x1b/.test(m.data)) { touchSession(s); pmIdle.touch(); } } // a key the PM typed, not the terminal's own reply to a query
10608
10617
  } else if (m.t === 'resize') {
10609
10618
  const s = sessions.get(m.id);
10610
10619
  if (s && s.pty) {
@@ -25,7 +25,10 @@ Rules that always hold:
25
25
 
26
26
  Procedure:
27
27
  1. Orient. Run `pmos driver status initiative <id>`. Read the initiative record (`planning/initiatives/<id>.md`, or `pmos/state/initiatives/<id>.md`) and every file it names: PRD, brief, requirement notes. Run `pmos initiative list` to see the other open initiatives.
28
- 2. Check first for a prior rejection and a duplicate. Search `planning/out-of-scope/` for the idea (Grep on its key words). Compare the title and the intent with the other open initiatives. If you find a match, file a `note` proposal first that names the file or the initiative, quotes what it says in one line, and says why this one is the same or different. Then stop unless the match is weak.
28
+ 2. Check first for a prior rejection and a duplicate. Search `planning/out-of-scope/` for the idea (Grep on its key words). Compare the title and the intent with the other open initiatives.
29
+ - A prior rejection: file a `note` proposal first that names the file, quotes what it says in one line, and says why this one is the same or different.
30
+ - Another open initiative that overlaps: file `--what overlap` with a JSON file, never a `note`: `{"with": "<the other initiative's id>", "parts": <how many parts of this plan overlap>, "of": <how many parts this plan has>, "items": ["<one part that overlaps, in plain words>"], "sure": "high|medium|low", "sureWhy": "<one line: what you read that makes you that sure>", "first": "this|other", "firstWhy": "<one line: why that one goes first>", "text": "<one sentence: what overlaps and what is separate>"}`. Give only the fields you know: leave out parts and of when the plans have no parts you can count. Never file an overlap with an initiative the prompt says the PM marked as not an overlap.
31
+ Then stop unless the match is weak.
29
32
  3. Find the stage category in the prompt. When the prompt names core documents of this stage that are due or stale, do step 8 first. For Plan, Do and Learn, go to step 5. For Discover, do step 4.
30
33
  4. Discover, in this order. Skip any step already kept.
31
34
  a. Problem statement. One paragraph: who has the problem, what it is, what it costs them. File `--what problem` with `--data "<the paragraph>"`. Give at least one source when you have one.
@@ -0,0 +1,5 @@
1
+ {
2
+ "_comment": "batch 18 item 2-A: the asks in the Viewer (start / blocked, decision, waited, source) on the one pattern, canvas In development OvA1Start, OvA1After, OvA2Decide, OvA3Waited, OvA4Source, OvA11Dark, OvA12Edges, OvA10Desk. The model in node; the presses in a browser are briefing-premium-test.js (W1-W8) and briefing-premium-sources-test.js (S2, S3).",
3
+ "modules": ["home-need.test.mjs"],
4
+ "seconds": { "home-need.test.mjs": 1 }
5
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "feedback batch 18 items 2 and 2b, slice 2-B (canvas OvA5Overlap, OvA6Given, OvA7Drafted): New for you's overlap note and task Viewers, and the Finished Viewer Your day's Drafted for you opens. news-viewers-test.js drives the real Home at 390 and 1440 px with the news, the two initiatives and the day answered in the browser.",
3
+ "modules": [
4
+ "news-viewers.test.js"
5
+ ],
6
+ "panels": [
7
+ "news-viewers-test.js"
8
+ ],
9
+ "seconds": {
10
+ "news-viewers-test.js": 30,
11
+ "news-viewers.test.js": 1
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "_comment": "batch 18 item 2-C: the small Viewers in shell A (a stakeholder and its one form on Home and the Board, a routine, Add a document, a draft to issue, your own task, a file); canvas OvA8People, OvA9Docs.",
3
+ "modules": ["small-vw.test.mjs"],
4
+ "seconds": { "small-vw.test.mjs": 1 }
5
+ }
@@ -116,7 +116,9 @@ function configure({ name = 'run', port = null } = {}) {
116
116
  PORT: chosen, HOST, BASE: `http://${HOST}:${chosen}`, STATE_DIR: stateDir,
117
117
  /** Environment for a spawned server/launcher: this run's state dir and tmux socket. */
118
118
  env(extra = {}) {
119
- return { ...process.env, PMOS_STATE_DIR: stateDir, ...extra };
119
+ // PMOS_IMPACT=off: the daily Your impact run starts on the first tick inside working hours and would take a background slot (and a
120
+ // session row) in whatever suite happens to run then; a suite about it passes PMOS_IMPACT itself (feedback batch 18, CI)
121
+ return { ...process.env, PMOS_STATE_DIR: stateDir, PMOS_IMPACT: 'off', ...extra };
120
122
  },
121
123
  /** A port nobody else holds, for a suite that needs a second server. */
122
124
  port: claimEphemeralPort,