create-pmos 0.669.0 → 0.671.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 (32) hide show
  1. package/package.json +20 -14
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +19 -0
  7. package/workspace/guide/agent-capabilities.md +6 -6
  8. package/workspace/guide/claude-proposes.md +1 -1
  9. package/workspace/guide/cli.md +2 -2
  10. package/workspace/guide/cloud.md +2 -2
  11. package/workspace/guide/home.md +2 -2
  12. package/workspace/guide/initiatives-and-next-steps.md +12 -2
  13. package/workspace/guide/layout.md +1 -1
  14. package/workspace/guide/settings-and-switches.md +19 -14
  15. package/workspace/lib/driver-run.js +1 -1
  16. package/workspace/lib/driver.js +4 -1
  17. package/workspace/lib/routes-boards.js +115 -4
  18. package/workspace/lib/source-heal.js +1 -1
  19. package/workspace/lib/tracker-refresh-run.js +162 -0
  20. package/workspace/package-lock.json +2 -2
  21. package/workspace/package.json +1 -1
  22. package/workspace/public/pm/cozy-ev.css +18 -4
  23. package/workspace/public/pm/cozy-evmodel.js +1 -1
  24. package/workspace/public/pm/cozy-pop-work.js +23 -3
  25. package/workspace/public/pm/cozy-settings.js +108 -89
  26. package/workspace/public/pm/next-prompt-ui.js +1 -1
  27. package/workspace/public/pm/pop-work-model.js +7 -5
  28. package/workspace/public/pm/set-ds.js +54 -0
  29. package/workspace/server.js +27 -0
  30. package/workspace/skills/tracker-refresh.skill +2 -0
  31. package/workspace/test-lists/direct-plain-actions.json +11 -0
  32. package/workspace/test-lists/settings-ds-page.json +9 -0
@@ -439,8 +439,10 @@ const whenOf = (w, t) => { const s = String(w || ''); return day(s) ? dayText(s,
439
439
 
440
440
  /* ── what PMOS suggests from the record itself (board 3, 25), next to what lib/proposals.js proposes ── */
441
441
  const andList = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
442
- /** derivedOf(r, v, o, bd, arts) → { top: [s], rows: Map(uid → s) }. Each s: { id, derived: true, say, why, ask?, move? }. ask: the words ✓ sends
443
- * to Ask PMOS, which does it in a real session; move: { uid, to, name } ✓ puts a task in a stage. o.dropped: the ids the PM said No to. */
442
+ /** derivedOf(r, v, o, bd, arts) → { top: [s], rows: Map(uid → s) }. Each s: { id, derived: true, say, why, ask?, move?, direct? }. ask: the words ✓
443
+ * sends to Ask PMOS, which does it in a real session; move: { uid, to, name } ✓ puts a task in a stage. direct: { act, to? } ✓ (or a choice)
444
+ * writes at once through POST /api/boards/ini-<act>, with Undo, and sends `ask` only when the route answers ask: true (bet 1f). o.dropped: the
445
+ * ids the PM said No to. */
444
446
  export function derivedOf(r, v, o, bd, arts) {
445
447
  const t = todayOf(o), drop = o.dropped || new Set(), top = [], rows = new Map(), title = v.title || r.title || 'this initiative';
446
448
  const live = r.status !== 'done' && !r.ended && !r.closed;
@@ -451,7 +453,7 @@ export function derivedOf(r, v, o, bd, arts) {
451
453
  const last = all.sort((a, b) => b.end.localeCompare(a.end))[0];
452
454
  if (last) top.push({ id: 'd:plan-end', derived: true, say: 'Move the plan end to ' + dayText(last.end, t) + '. It follows ' + last.title + '.',
453
455
  why: 'The plan ended on ' + dayText(r.end, t) + ', and ' + last.title + ' is due on ' + dayText(last.end, t) + '.',
454
- ask: 'Move the plan end of ' + title + ' to ' + last.end + ': it follows the task ' + last.title + '. Tell me what else moves.' });
456
+ ask: 'Move the plan end of ' + title + ' to ' + last.end + ': it follows the task ' + last.title + '. Tell me what else moves.', direct: { act: 'plan-end', to: last.end } });
455
457
  }
456
458
  // a document the gate needs is not written: PMOS drafts it from what is written, for the PM to read
457
459
  const miss = (arts || []).filter((a) => a.missing).map((a) => a.title);
@@ -466,8 +468,8 @@ export function derivedOf(r, v, o, bd, arts) {
466
468
  if ((r.closed || r.ended || r.status === 'done') && nOpen > 0) {
467
469
  const w = r.status === 'done' && !r.closed && !r.ended ? 'done' : 'closed';
468
470
  top.unshift({ id: 'd:closed-open', derived: true, say: 'It is ' + w + ', but ' + plural(nOpen, 'task is', 'tasks are') + ' open. Close them, or reopen the initiative?',
469
- why: '', choices: [{ label: 'Close them', ask: 'Close the ' + plural(nOpen, 'open task', 'open tasks') + ' of ' + title + '. It is ' + w + '. Tell me what you closed.' },
470
- { label: 'Reopen', ask: 'Reopen ' + title + ': it has ' + plural(nOpen, 'open task', 'open tasks') + '. Put it back in the stage it was in before, and tell me where.' }] });
471
+ why: '', choices: [{ label: 'Close them', ask: 'Close the ' + plural(nOpen, 'open task', 'open tasks') + ' of ' + title + '. It is ' + w + '. Tell me what you closed.', direct: { act: 'close-open' } },
472
+ { label: 'Reopen', ask: 'Reopen ' + title + ': it has ' + plural(nOpen, 'open task', 'open tasks') + '. Put it back in the stage it was in before, and tell me where.', direct: { act: 'reopen' } }] });
471
473
  }
472
474
  // one ✦ on the Not in a stage row (round 3 point 21), keyed 'stage:' (the row of no stage)
473
475
  const lz = (bd && bd.loose) || [];
@@ -0,0 +1,54 @@
1
+ /* pm/set-ds.js — the parts Settings is drawn from (initiative settings-ds-page; Exploring 3 page "pages", board SettingsDS; brief
2
+ * design-system/pages-rebuild/brief.md, Settings). Built only from PMOS Komorebi parts (workspace/design-system/ui): Settings rows (pm-set),
3
+ * Tabs as the way picker (pm-tabs, role radiogroup), the switch (pm-switch), the expanded Suggestion (pm-sug x, from bd-stands.js).
4
+ * PURE: no DOM, no fetch. pm/cozy-settings.js draws them and wires the presses by their data-ev- attributes (unchanged).
5
+ *
6
+ * SECTIONS the sections at the left, in the board's order, then Workspaces and Updates (nothing dropped)
7
+ * row(title, sub, right) one Settings row
8
+ * seg(label, key, cur, opts) Tabs that pick one value
9
+ * sw(on, attrs, label) a switch
10
+ * kindMeta(k) "31 made · 29 kept"
11
+ * sugOf(kinds, no) the one Suggestion on How PMOS decides, from what you kept and undid, or null
12
+ * sugHtml(s) its expanded form: Why, PMOS will, What changes, Based on; Change it first, Yes, No
13
+ *
14
+ * NOTHING HERE MAKES A FACT UP: a Suggestion needs at least MIN changes of one kind, and says the counts it rests on. */
15
+ import { sugHtml as sugBlock } from './bd-stands.js';
16
+
17
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
18
+ export const SECTIONS = [['general', 'General'], ['claude', 'How PMOS decides'], ['checks', 'Checks'], ['rules', 'Prototype rules'], ['connectors', 'Connectors'],
19
+ ['account', 'Your account'], ['workspaces', 'Workspaces'], ['updates', 'Updates']];
20
+ export const MIN = 5;
21
+ export const WAYS = { quiet: 'Quietly', show: 'Show me', ask: 'Ask first' };
22
+
23
+ export const row = (title, sub, right) => `<div class="ev-trow pm-set"><div class="ev-tx"><b>${esc(title)}</b>${sub ? `<p class="pm-meta">${esc(sub)}</p>` : ''}</div>${right}</div>`;
24
+ export const seg = (label, key, cur, opts) => `<span class="pm-tabs" role="radiogroup" aria-label="${esc(label)}">${opts.map(([k, w]) => {
25
+ const on = String(cur) === String(k);
26
+ return `<button type="button" class="pm-tab" role="radio" data-ev-seg="${esc(key)}" data-v="${esc(k)}" aria-checked="${on}" aria-selected="${on}">${esc(w)}</button>`;
27
+ }).join('')}</span>`;
28
+ export const sw = (on, attrs, label) => `<button type="button" class="pm-switch" role="switch" aria-checked="${!!on}" aria-label="${esc(label)}" ${attrs}></button>`;
29
+ export const kindMeta = (k) => `${k.made || 0} made · ${k.kept || 0} kept`;
30
+
31
+ const low = (s) => String(s || '').charAt(0).toLowerCase() + String(s || '').slice(1);
32
+ /** The one Suggestion. First a kind PMOS made at least MIN times that you never undid and that still shows or asks: Quietly. Else a kind you
33
+ * set to Quietly yourself and undid at least twice: Ask first. `no`: the "kind:way" pairs you said No to. → s | null */
34
+ export function sugOf(kinds, no = new Set()) {
35
+ const K = Array.isArray(kinds) ? kinds : [];
36
+ const up = K.find((k) => k.made >= MIN && !k.undone && k.kept === k.made && k.way !== 'quiet' && !no.has(k.kind + ':quiet'));
37
+ if (up) return {
38
+ kind: up.kind, to: 'quiet', title: `Let PMOS ${low(up.label)} quietly`,
39
+ why: `PMOS made ${up.made} of these by itself and you kept all ${up.made}. You undid none.`,
40
+ will: [`Set ${up.label} to Quietly`, 'Keep Undo on each one'],
41
+ changes: `These no longer wait in PMOS did; each one still has Undo.`,
42
+ basis: `The ${up.made} changes of this kind and your Undos`,
43
+ };
44
+ const down = K.find((k) => k.set === 'quiet' && k.undone >= 2 && !no.has(k.kind + ':ask'));
45
+ if (down) return {
46
+ kind: down.kind, to: 'ask', title: `Let PMOS ask first before it does ${low(down.label)}`,
47
+ why: `You set it to Quietly and then undid ${down.undone} of ${down.made}.`,
48
+ will: [`Set ${down.label} to Ask first`],
49
+ changes: 'PMOS waits for your yes before each one.',
50
+ basis: `The ${down.made} changes of this kind and your ${down.undone} Undos`,
51
+ };
52
+ return null;
53
+ }
54
+ export const sugHtml = (s) => (s ? sugBlock(s, `data-kind="${esc(s.kind)}" data-to="${esc(s.to)}"`, 'data-ev-sug') : '');
@@ -2640,9 +2640,27 @@ function endSupersededRuns(origin, now = Date.now()) {
2640
2640
  }
2641
2641
  return ended;
2642
2642
  }
2643
+ /* A skill done by code, not an agent session (bet 1f): the tracker refresh reads local files and moves items by a fixed procedure, so it
2644
+ * needs no model (lib/tracker-refresh-run.js). → { ok, got?, error? } */
2645
+ function isCodeSkill(skill) { return skill === 'tracker-refresh'; }
2646
+ function codeSkillRun(skill, wsId) {
2647
+ if (!isCodeSkill(skill)) return { ok: false, error: `${skill} is not done by code` };
2648
+ const w = (wsId && workspaces.get(wsId)) || homeWorkspace();
2649
+ if (!w) return { ok: false, error: 'no workspace' };
2650
+ const TRR = require('./lib/tracker-refresh-run.js');
2651
+ const r = TRR.refresh(w.root, { runtimeDir: STATE });
2652
+ try { if (r.ok && r.moved.length) boardCache.invalidate(w.root); } catch { /* the next read rebuilds */ }
2653
+ return r.ok ? { ok: true, got: TRR.summary(r), result: r } : { ok: false, error: r.error };
2654
+ }
2643
2655
  function fireSchedule(sched, opts = {}) {
2644
2656
  const w = workspaces.get(sched.ws) || homeWorkspace();
2645
2657
  const root = w ? w.root : SELF_ROOT;
2658
+ if (isCodeSkill(sched.skill) || isCodeSkill(sched.task)) {
2659
+ const r = codeSkillRun(isCodeSkill(sched.skill) ? sched.skill : sched.task, sched.ws);
2660
+ const list = readSchedules(); const cur = list.find((x) => x.id === sched.id);
2661
+ if (cur) { cur.lastRun = nowISO(); cur.lastStatus = r.ok ? 'ok' : 'fail'; if (!opts.release) { cur.nextRun = scheduleLogic.nextRun(cur); if (cur.cadence === 'once') cur.enabled = false; countRun(cur); } writeSchedules(list); }
2662
+ return { ok: r.ok, kind: 'code', sessionId: null, reason: r.ok ? r.got : r.error };
2663
+ }
2646
2664
  // One corpus load probing both keys — taskById would re-read every .skill file per probe.
2647
2665
  const tasks = loadTasks(root);
2648
2666
  const byId = (id) => tasks.find((t) => t.id === id || t.skill === id) || null;
@@ -5702,6 +5720,15 @@ function myWorkRead(wsId) {
5702
5720
  /** Refresh now (workspace-data-freshness R7): start skill `skillId` in a session of repository `wsId`, as myWorkRead does. */
5703
5721
  function startSkillSession(wsId, skillId, name, origin, opts) {
5704
5722
  if (Array.isArray(skillId)) return startSharedRefreshSession(wsId, skillId, name, origin, opts); // smart refresh step 2: several due sources, one session
5723
+ // a skill done by code (bet 1f: the tracker refresh): no session; the refresh engine writes its run lines from the answer (code: true)
5724
+ // the refresh log records it as a run with no session: started, then ended with the script's answer (lib/refresh-run.js started, ended)
5725
+ if (isCodeSkill(skillId)) {
5726
+ const s = { id: 'code-' + crypto.randomBytes(4).toString('hex'), ws: wsId || null, origin: origin || 'refresh:' + (refreshLib.SKILL_OF.get(skillId) || skillId), state: 'running' };
5727
+ try { refreshRun.started(s); } catch (e) { warnWriteFail('refresh log (code run)', e); }
5728
+ const r = codeSkillRun(skillId, wsId);
5729
+ try { refreshRun.ended(s, { result: r.ok ? 'done' : 'failed', got: r.got || null, error: r.ok ? null : r.error }); } catch (e) { warnWriteFail('refresh log (code run)', e); }
5730
+ return { ...r, code: true, session: null };
5731
+ }
5705
5732
  const w = getWs(wsId);
5706
5733
  if (!w) return { ok: false, status: 400, error: 'no workspace' };
5707
5734
  const task = taskById(skillId, w.root);
@@ -13,6 +13,8 @@ output:
13
13
 
14
14
  /tracker-refresh — bring the plan items that a tracker owns up to date for THIS repository. A tracker-owned item has an owner that starts with `tracker:`. You read files that are already here and you append evidence lines. You call no tracker.
15
15
 
16
+ The weekly schedule and the Refresh press do this procedure by code, with no agent session (lib/tracker-refresh-run.js, bet 1f). You run it only when the PM asks an agent for it.
17
+
16
18
  This skill runs before the bi-weekly report (`report-biweekly`). The report script reads only the ledgers. It cannot call a tracker (R30, D71), so the evidence lines you write are the only way a tracker item reaches the report.
17
19
 
18
20
  Rules that always hold (D71):
@@ -0,0 +1,11 @@
1
+ {
2
+ "_comment": "Plain ✓ actions write directly (initiative direct-plain-actions, done test C1-C10): the popup's plan end, close-open and reopen presses write through board routes with Undo; a move the PM pressed wakes no Driver run; the tracker refresh is a script. Scratch server and pure checks. No connector, model or network.",
3
+ "modules": [
4
+ "direct-acts.test.js",
5
+ "tracker-refresh-run.test.js"
6
+ ],
7
+ "seconds": {
8
+ "direct-acts.test.js": 40,
9
+ "tracker-refresh-run.test.js": 10
10
+ }
11
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Settings rebuilt from design system blocks (initiative settings-ds-page, done test C1-C6): pm/set-ds.js, pm/cozy-settings.js sections and rows. Pure, node.",
3
+ "modules": [
4
+ "set-ds.test.js"
5
+ ],
6
+ "seconds": {
7
+ "set-ds.test.js": 2
8
+ }
9
+ }