create-pmos 0.410.0 → 0.412.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 (131) hide show
  1. package/package.json +25 -30
  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/briefing-premium-adddoc-test.js +2 -2
  7. package/workspace/briefing-premium-initiative-test.js +9 -15
  8. package/workspace/briefing-premium-insights-test.js +2 -2
  9. package/workspace/briefing-premium-test.js +3 -3
  10. package/workspace/changelog.json +24 -0
  11. package/workspace/chat-asks-test.js +146 -0
  12. package/workspace/guide/board.md +1 -1
  13. package/workspace/guide/breakdown.md +6 -13
  14. package/workspace/guide/briefing-premium.md +1 -1
  15. package/workspace/guide/home.md +24 -0
  16. package/workspace/guide/index.md +1 -1
  17. package/workspace/guide/initiative-driver.md +1 -1
  18. package/workspace/guide/initiatives-screen.md +1 -1
  19. package/workspace/guide/pm-only-acts.md +23 -24
  20. package/workspace/guide/today.md +1 -1
  21. package/workspace/home-rows-test.js +149 -56
  22. package/workspace/ini-workflow-test.js +4 -4
  23. package/workspace/lib/briefing-premium-agent.js +8 -1
  24. package/workspace/lib/briefing-premium-writes.js +5 -4
  25. package/workspace/lib/coredoc-cli.js +1 -1
  26. package/workspace/lib/driver-cli.js +2 -1
  27. package/workspace/lib/driver-decide.js +3 -2
  28. package/workspace/lib/driver.js +2 -1
  29. package/workspace/lib/engine/boards.js +3 -1
  30. package/workspace/lib/goal-chat.js +94 -30
  31. package/workspace/lib/grant-mint.js +3 -2
  32. package/workspace/lib/initiative-cli.js +9 -9
  33. package/workspace/lib/issues.js +5 -4
  34. package/workspace/lib/mention-cli.js +70 -0
  35. package/workspace/lib/mention-store.js +307 -0
  36. package/workspace/lib/people-store.js +1 -1
  37. package/workspace/lib/people.js +3 -1
  38. package/workspace/lib/placements.js +13 -15
  39. package/workspace/lib/plan-items.js +17 -48
  40. package/workspace/lib/pm-guard.js +18 -5
  41. package/workspace/lib/pm-lines-needs.js +9 -5
  42. package/workspace/lib/pmos-verbs.js +3 -0
  43. package/workspace/lib/report-cli.js +2 -2
  44. package/workspace/lib/routes-board-metric-targets.js +0 -1
  45. package/workspace/lib/routes-boards.js +12 -0
  46. package/workspace/lib/routes-briefing-premium.js +5 -7
  47. package/workspace/lib/routes-core-docs.js +0 -1
  48. package/workspace/lib/routes-custom-docs.js +0 -1
  49. package/workspace/lib/routes-driver.js +0 -1
  50. package/workspace/lib/routes-home-desk.js +1 -1
  51. package/workspace/lib/routes-home-review.js +1 -1
  52. package/workspace/lib/routes-initiative-layout.js +1 -1
  53. package/workspace/lib/routes-insights-records.js +0 -1
  54. package/workspace/lib/routes-meeting-material.js +0 -1
  55. package/workspace/lib/routes-mentions.js +62 -9
  56. package/workspace/lib/routes-onboarding.js +3 -1
  57. package/workspace/lib/routes-orchestrator.js +0 -1
  58. package/workspace/lib/routes-premium-charts.js +0 -1
  59. package/workspace/lib/routes-premium-dashboards.js +0 -1
  60. package/workspace/lib/routes-programs.js +1 -1
  61. package/workspace/lib/routes-records.js +1 -1
  62. package/workspace/lib/routes-report-design.js +7 -3
  63. package/workspace/lib/routes-report-setups.js +0 -1
  64. package/workspace/lib/routes-report-structure.js +0 -1
  65. package/workspace/lib/routes-runs.js +2 -5
  66. package/workspace/lib/routes-scan.js +0 -1
  67. package/workspace/lib/routes-sources.js +1 -1
  68. package/workspace/lib/run-answers.js +14 -5
  69. package/workspace/lib/scan-cli.js +2 -1
  70. package/workspace/lib/scan.js +2 -1
  71. package/workspace/lib/session-files.js +132 -0
  72. package/workspace/lib/session-name.js +103 -0
  73. package/workspace/lib/source-reads.js +4 -1
  74. package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
  75. package/workspace/package-lock.json +2 -2
  76. package/workspace/package.json +1 -1
  77. package/workspace/premium-board-actions-test.js +10 -8
  78. package/workspace/premium-chat-goal-setup-test.js +203 -0
  79. package/workspace/premium-chat-goal-view-test.js +28 -23
  80. package/workspace/premium-chat-line-test.js +189 -0
  81. package/workspace/premium-core-doc-issue-test.js +1 -1
  82. package/workspace/premium-viewer-share-test.js +5 -2
  83. package/workspace/premium-vw-backlog-test.js +1 -1
  84. package/workspace/premium-vw-item-test.js +1 -1
  85. package/workspace/premium-vw-jira-test.js +1 -1
  86. package/workspace/public/pm/chat-ask.js +17 -9
  87. package/workspace/public/pm/cozy-home-rows.css +39 -1
  88. package/workspace/public/pm/cozy-home.css +112 -12
  89. package/workspace/public/pm/cozy-search.js +2 -1
  90. package/workspace/public/pm/cozy-steps.css +69 -0
  91. package/workspace/public/pm/cozy-steps.js +90 -0
  92. package/workspace/public/pm/goal-chat.js +141 -23
  93. package/workspace/public/pm/home-app.js +68 -35
  94. package/workspace/public/pm/home-ask.js +121 -0
  95. package/workspace/public/pm/home-chat.js +120 -68
  96. package/workspace/public/pm/home-data.js +10 -2
  97. package/workspace/public/pm/home-goal.js +159 -0
  98. package/workspace/public/pm/home-ini.css +35 -0
  99. package/workspace/public/pm/home-ini.js +50 -19
  100. package/workspace/public/pm/home-line.css +59 -0
  101. package/workspace/public/pm/home-line.js +200 -0
  102. package/workspace/public/pm/home-list.js +2 -2
  103. package/workspace/public/pm/home-mentions.js +303 -111
  104. package/workspace/public/pm/home-ses-name.js +65 -0
  105. package/workspace/public/pm/home-stage-card.js +94 -0
  106. package/workspace/public/pm/home-sweep.js +112 -0
  107. package/workspace/public/pm/home-today.js +7 -2
  108. package/workspace/public/pm/premium-initiative-head.js +8 -4
  109. package/workspace/public/pm/rename-press.js +24 -0
  110. package/workspace/public/pm/wf-page.css +3 -0
  111. package/workspace/public/pm/wf-page.js +2 -1
  112. package/workspace/public/premium-workflows.html +1 -0
  113. package/workspace/replaced-tests.json +101 -0
  114. package/workspace/server.js +133 -20
  115. package/workspace/session-names-test.js +144 -0
  116. package/workspace/skills/jira-push.skill +1 -0
  117. package/workspace/skills/morning-brief.skill +2 -1
  118. package/workspace/skills/report-daily.skill +1 -0
  119. package/workspace/skills/report-monthly.skill +1 -0
  120. package/workspace/skills/report-weekly.skill +1 -0
  121. package/workspace/skills/sources-read.skill +3 -2
  122. package/workspace/stage-card-test.js +203 -0
  123. package/workspace/test-lists/chat-asks.json +13 -0
  124. package/workspace/test-lists/chat-progress.json +13 -0
  125. package/workspace/test-lists/mentions-a-plus.json +9 -0
  126. package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
  127. package/workspace/test-lists/session-files.json +5 -0
  128. package/workspace/test-lists/session-names.json +13 -0
  129. package/workspace/test-lists/stage-card.json +6 -0
  130. package/workspace/tk-tasks-test.js +1 -1
  131. package/workspace/workflows-setup-test.js +17 -0
@@ -157,7 +157,7 @@ function foundOf(f) {
157
157
  const sources = Array.isArray(f.sources) ? f.sources.filter((x) => x && typeof x.ref === 'string').slice(0, 8).map((x) => ({ label: String(x.label || ''), ref: x.ref })) : [];
158
158
  return { why: typeof f.why === 'string' ? f.why : '', sources, match: typeof f.match === 'string' && f.match ? f.match : null, scan: typeof f.scan === 'string' ? f.scan : null, run: typeof f.run === 'string' ? f.run : null };
159
159
  }
160
- const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto']);
160
+ const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'task-remove', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto']);
161
161
  const TASK_STATES = Object.freeze(['To do', 'In progress', 'In review', 'Done']);
162
162
 
163
163
  const copyStages = (stages) => stages.map((s) => ({ name: s.name, cat: s.cat, hint: s.hint || '' }));
@@ -260,6 +260,8 @@ function fold(events) {
260
260
  if (typeof e.due === 'string') t.due = e.due;
261
261
  if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim(); // a rename (canvas RnATask)
262
262
  t.history.push({ at: e.at || null, by: e.by || null, state: e.state || null, start: e.start || null, due: e.due || null, why: e.why || '' });
263
+ } else if (e.kind === 'task-remove' && typeof e.task === 'string' && tasks.has(e.task)) {
264
+ tasks.delete(e.task); // the Undo of a task just added (routes-boards.js tasks/undo-add)
263
265
  } else if (e.kind === 'ini-epics' && typeof e.id === 'string' && Array.isArray(e.epics)) {
264
266
  epics.set(e.id, e.epics.filter((k) => typeof k === 'string' && JIRA_KEY_RE.test(k)).map((k) => k.toUpperCase()));
265
267
  } else if (e.kind === 'ini-archive' && typeof e.id === 'string') {
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
  /* goal-chat — `/goal` in the premium chat panel (initiative premium-chat-session, slice 2; PRD G2–G7).
3
- * `/goal <text>` turns into a PMOS grilling prompt typed into the panel's own Claude Code session: Claude reads the records, asks at most
4
- * five questions to make the goal SMART, and ends each message with a fenced `pmos-goal` JSON block the panel draws as chips or a goal card.
5
- * Start and Cancel are the PM's presses. The record is append-only: goal-runs.jsonl in the state folder (grilling, started, cancelled). */
3
+ * `/goal <text>` turns into a PMOS grilling prompt typed into the panel's own Claude Code session: Claude reads the records, picks the
4
+ * questioning method that fits the goal (METHODS; the PM can change it), asks one question at a time, and ends each message with a fenced
5
+ * `pmos-goal` JSON block the panel draws as a dots row, answer chips or the plan card. Start, Change, Cancel, a skipped point and a replaced
6
+ * goal are the PM's presses. The record is append-only: goal-runs.jsonl in the state folder. */
6
7
  const fs = require('fs');
7
8
  const path = require('path');
8
9
  const crypto = require('crypto');
@@ -11,7 +12,17 @@ const RUNS = 'goal-runs.jsonl';
11
12
  const LIMIT = 12;
12
13
  const MAX_TEXT = 1000;
13
14
  // The first line of every message PMOS types for a goal. The panel reads it to show the PM's turn as typed (public/pm/goal-chat.js).
14
- const MARK = { grill: '[PMOS /goal]', start: '[PMOS /goal start]', cancel: '[PMOS /goal cancel]' };
15
+ const MARK = { grill: '[PMOS /goal]', start: '[PMOS /goal start]', cancel: '[PMOS /goal cancel]', method: '[PMOS /goal method]', plan: '[PMOS /goal plan]', skip: '[PMOS /goal skip]', unskip: '[PMOS /goal unskip]' };
16
+ /* The questioning methods Claude picks from (Wawan, 2026-10-25: SMART is one method, not the only one). Each names the points it needs; the
17
+ * dots row over a question has one dot per point. public/pm/goal-chat.js keeps the same list for the Change menu (goal-chat.test.js M1). */
18
+ const METHODS = [
19
+ { id: 'done-criteria', name: 'Done criteria', fits: 'it ends in a deliverable, such as a document or a release', points: ['What it delivers', 'The done points', 'By when', 'What it may do'] },
20
+ { id: 'pre-mortem', name: 'Pre-mortem', fits: 'a risky launch or change', points: ['What ships', 'How it could fail', 'What prevents each failure', 'By when'] },
21
+ { id: 'outcome', name: 'Outcome and measure', fits: 'it moves a metric', points: ['The outcome', 'The measure and its target', 'The baseline', 'By when'] },
22
+ { id: 'problem', name: 'Problem statement', fits: 'discovery, while the problem is not clear yet', points: ['The problem', 'Who has it', 'The evidence', 'What we want to learn'] },
23
+ { id: 'smart', name: 'SMART', fits: 'any other goal', points: ['Specific', 'Measurable', 'Achievable', 'Relevant', 'Time-bound'] },
24
+ ];
25
+ const methodOf = (id) => METHODS.find((m) => m.id === id) || null;
15
26
 
16
27
  /** '/goal Ship X' → { text: 'Ship X' }; '/goal' → { text: '' }; anything else → null. */
17
28
  function parseCommand(s) {
@@ -23,18 +34,37 @@ function grillPrompt(text) {
23
34
  return [
24
35
  MARK.grill + ' The PM set a goal: ' + text,
25
36
  '',
26
- 'Make it a SMART goal with the PM before any work. Do not start the work: nothing runs until the PM presses Start on the page.',
27
- '1. Read the records first (this repository\'s planning/ folder, its initiatives and OKRs, open pull requests where you can) and fill what you can of S (what exactly), M (how we know it is done, as checkable points), A (achievable with what you can do in this session; if it is too big, propose the first part), R (which initiative or KR it serves) and T (by when).',
28
- '2. Ask the PM only about the points you could not fill. At most 5 questions in all, one per message, in this order: M, T, A, R, S. Each question offers 2 or 3 short answers; mark one as recommended.',
29
- '3. Stop asking when all five are filled, after 5 questions, or when the PM says "start with defaults". A point the PM did not give takes a sensible default and is listed in "assumed".',
30
- '4. If the goal needs something you cannot do here (for example sending mail that is not set up), say so and propose what you can do instead.',
37
+ 'Agree this goal with the PM before any work. Do not start the work: nothing runs until the PM presses Start on the page.',
38
+ '1. Pick the questioning method that fits this goal best, from this list. The page shows your pick in one line, and the PM can change it.',
39
+ ...METHODS.map((m) => ' - ' + m.id + ' (' + m.name + '): when ' + m.fits + '. Its points: ' + m.points.join('; ') + '.'),
40
+ '2. Read the records first (this repository\'s planning/ folder, its initiatives and OKRs, open pull requests where you can) and fill what you can of the method\'s points. Done points are always checkable.',
41
+ '3. Ask the PM only about the points you could not fill. One question per message, at most 5 questions in all. Each question offers 2 or 3 short answers; mark one as recommended. The PM can also type their own answer.',
42
+ '4. Stop asking when every point is agreed, after 5 questions, or when the PM says "start with defaults". A value the PM did not give takes a sensible default and is listed in "assumed".',
43
+ '5. If the goal needs something you cannot do here (for example sending mail that is not set up), say so and propose what you can do instead.',
44
+ '6. A message that starts with ' + MARK.method + ' changes the method: keep what is already agreed where it fits, and ask from there. A message that starts with ' + MARK.plan + ' is the plan as the PM edited it.',
31
45
  '',
32
46
  'End every message of this exchange with one fenced code block with the language tag pmos-goal, holding one JSON object. The page draws it; keep the words before it short.',
33
- '- While asking: {"step":"question","n":2,"question":"How will we know it is done?","options":[{"label":"PR green and checklist ticked","recommended":true},{"label":"PR merged"}],"draft":{...what is known so far}}',
34
- '- When ready: {"step":"ready","draft":{...}}',
35
- 'The draft: {"goal":"one sentence","done":["checkable point", "..."],"may":"what you may do","serves":"initiative or KR","by":"deadline, ISO 8601 date and time","limit":' + LIMIT + ',"assumed":["by"]}. Leave out the keys you do not know yet.',
47
+ '- While asking: {"step":"question","method":"done-criteria","why":"it ends in a document","points":[{"name":"What it delivers","agreed":true},{"name":"The done points","agreed":false}],"question":"What must be true for it to be done?","options":[{"label":"PR green and checklist ticked","recommended":true},{"label":"PR merged"}],"draft":{...what is known so far}}',
48
+ '- When ready: {"step":"ready","method":"done-criteria","points":[...every point, agreed],"draft":{...}}',
49
+ '"why" is a few words on why the method fits this goal. The draft: {"goal":"one sentence","done":["checkable point", "..."],"may":"what you may do","serves":"initiative or KR","by":"deadline, ISO 8601 date and time","limit":' + LIMIT + ',"assumed":["by"]}. Leave out the keys you do not know yet.',
36
50
  ].join('\n');
37
51
  }
52
+ /** The PM's Change on the method line: the message the panel sends. Unknown ids give null. */
53
+ function methodMessage(id) {
54
+ const m = methodOf(id); if (!m) return null;
55
+ return MARK.method + ' Use the ' + m.name + ' method for this goal instead. Its points: ' + m.points.join('; ') + '. Keep what is already agreed where it fits, and ask from there.';
56
+ }
57
+ /** The plan as the PM edited it in place. running: the goal works, so the change applies after the current step. */
58
+ function planMessage(draft, running = false) {
59
+ return [
60
+ MARK.plan + ' The PM changed the plan in place' + (running ? ' while you work. Apply it after your current step.' : '.'),
61
+ JSON.stringify(draft),
62
+ running ? 'Work to this plan from now on. Do not repeat it back.'
63
+ : 'Read it again. Write one line only if a done point has no way to check it; otherwise write nothing but the block. End with a ready pmos-goal block that holds exactly this plan.',
64
+ ].join('\n');
65
+ }
66
+ const skipMessage = (point) => MARK.skip + ' The PM skipped the done point "' + point + '". Drop it after your current step and do not work on it. It no longer counts.';
67
+ const unskipMessage = (point) => MARK.unskip + ' The PM took the skip back: the done point "' + point + '" counts again.';
38
68
 
39
69
  function startMessage(draft) {
40
70
  return [
@@ -71,10 +101,14 @@ function goalOf(runtimeDir, key) {
71
101
  if (!e || e.key !== key) continue;
72
102
  if (e.event === 'grilling') g = { id: e.id, state: 'grilling', text: e.text, at: e.at };
73
103
  else if (!g || e.id !== g.id) continue;
74
- else if (e.event === 'started') g = { ...g, state: 'started', draft: e.draft, startedAt: e.at, rounds: 0, met: [], open: (e.draft && e.draft.done) || [], at: e.at };
104
+ else if (e.event === 'started') g = { ...g, state: 'started', draft: e.draft, startedAt: e.at, roundAt: e.at, rounds: 0, met: [], open: (e.draft && e.draft.done) || [], at: e.at };
75
105
  else if (e.event === 'cancelled') g = { ...g, state: 'cancelled', at: e.at };
76
- else if (e.event === 'round') g = { ...g, rounds: e.n, met: e.met || [], open: e.open || [], at: e.at };
106
+ else if (e.event === 'round') g = { ...g, rounds: e.n, met: e.met || [], open: e.open || [], at: e.at, roundAt: e.at };
77
107
  else if (e.event === 'seen') g = { ...g, seen: true };
108
+ else if (e.event === 'planned') g = { ...g, plan: e.draft, planAt: e.at }; // the PM's in-place edit before Start
109
+ else if (e.event === 'edited') g = { ...g, draft: e.draft, open: ((e.draft && e.draft.done) || []).filter((x) => !(g.met || []).includes(x)) }; // ... and while it works
110
+ else if (e.event === 'skip') g = { ...g, skipped: [...new Set((g.skipped || []).concat(e.point))], skipAt: { ...(g.skipAt || {}), [e.point]: e.at } };
111
+ else if (e.event === 'unskip') g = { ...g, skipped: (g.skipped || []).filter((x) => x !== e.point) };
78
112
  else if (e.event === 'resumed') g = { ...g, state: 'started', reason: undefined, at: e.at };
79
113
  else if (['done', 'stopped', 'waiting'].includes(e.event)) g = { ...g, state: e.event, ...(e.reason ? { reason: e.reason } : {}), met: e.met || g.met, open: e.open || g.open, at: e.at };
80
114
  }
@@ -96,7 +130,9 @@ function statesAt(runtimeDir) {
96
130
  * goal done or needs the PM, at the deadline, after the round limit, or after NO_PROGRESS rounds that met no new point.
97
131
  * The done check is Claude's own report (a pmos-goal progress block), so the page calls it unverified. */
98
132
  const NO_PROGRESS = 3;
99
- const REASON = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.' };
133
+ /** The done points that still count: the draft's, less the ones the PM skipped. */
134
+ const requiredOf = (g) => ((g.draft && g.draft.done) || []).filter((x) => !(g.skipped || []).includes(x));
135
+ const REASON = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.', replaced: 'You replaced it with a new goal.' };
100
136
  /** The last fenced pmos-goal block in a message, parsed, or null. */
101
137
  function blockOf(text) {
102
138
  const re = /```pmos-goal[^\n]*\n([\s\S]*?)```/g;
@@ -120,9 +156,9 @@ const roundsOf = (runtimeDir, id) => {
120
156
  function onStop({ runtimeDir, key, message, now = new Date() }) {
121
157
  const g = key && goalOf(runtimeDir, key);
122
158
  if (!g || g.state !== 'started' || !g.draft) return {};
123
- const d = g.draft, b = blockOf(message), all = d.done || [];
124
- const met = (b && b.step === 'progress' && strs(b.met)) || g.met || [];
125
- const open = (b && b.step === 'progress' && strs(b.open)) || all.filter((x) => !met.includes(x));
159
+ const d = g.draft, b = blockOf(message), all = requiredOf(g), skipped = g.skipped || [];
160
+ const met = ((b && b.step === 'progress' && strs(b.met)) || g.met || []).filter((x) => !skipped.includes(x));
161
+ const open = ((b && b.step === 'progress' && strs(b.open)) || all.filter((x) => !met.includes(x))).filter((x) => !skipped.includes(x));
126
162
  const base = { id: g.id, key, met, open, at: now.toISOString() };
127
163
  if (b && b.step === 'progress' && (b.state === 'done' || (open.length === 0 && met.length > 0))) { append(runtimeDir, { event: 'done', ...base }); return {}; }
128
164
  if (b && b.step === 'progress' && b.state === 'needs-you') { append(runtimeDir, { event: 'waiting', ...base }); return {}; }
@@ -163,7 +199,7 @@ function goalRowsAt(runtimeDir, now = Date.now()) {
163
199
  if (!g || !g.draft || !ROW_TITLE[g.state] || g.seen) continue;
164
200
  const at = Date.parse(g.at || '');
165
201
  if (Number.isFinite(at) && now - at > ROW_DAYS * 86400000) continue;
166
- const all = g.draft.done || [], met = (g.met || []).length;
202
+ const all = requiredOf(g), met = (g.met || []).filter((x) => all.includes(x)).length;
167
203
  const why = g.state === 'stopped' ? (REASON[g.reason] || 'It stopped.') : g.state === 'waiting' ? 'Claude asked you something in the conversation.' : 'Claude reports every done point met. It checked its own work.';
168
204
  out.push({
169
205
  kind: 'goal', key: 'goal:' + key, chatKey: key, goalState: g.state, title: ROW_TITLE[g.state], subject: clip(g.draft.goal, 90),
@@ -175,7 +211,7 @@ function goalRowsAt(runtimeDir, now = Date.now()) {
175
211
  say: clip(g.draft.goal, 200) + ': ' + why, head: 'The goal',
176
212
  facts: [['State', ROW_TITLE[g.state]], ['Done points', met + ' of ' + all.length + ' met, unverified'], ['By', g.draft.by], ['Rounds', String(g.rounds || 0)]].filter((x) => x[1]),
177
213
  opts: [], sel: null, nodef: 'The goal card is in the conversation beside this. Write there to answer Claude or to go on.',
178
- pane: { label: 'Goal', file: 'goal-runs.jsonl', h: clip(g.draft.goal, 90), intro: why, rows: all.map((x) => [(g.met || []).includes(x) ? 'Met' : 'Open', x]), paras: [] },
214
+ pane: { label: 'Goal', file: 'goal-runs.jsonl', h: clip(g.draft.goal, 90), intro: why, rows: (g.draft.done || []).map((x) => [(g.skipped || []).includes(x) ? 'Skipped' : (g.met || []).includes(x) ? 'Met' : 'Open', x]), paras: [] },
179
215
  },
180
216
  });
181
217
  }
@@ -215,30 +251,58 @@ function begin({ runtimeDir, key, text, now = new Date() }) {
215
251
  if (!t) return { error: 'Write the goal after /goal, for example: /goal Ship the Board metrics card.' };
216
252
  if (t.length > MAX_TEXT) return { error: 'The goal is too long (' + MAX_TEXT + ' characters at most).' };
217
253
  const id = 'goal-' + crypto.randomBytes(6).toString('hex');
254
+ // one goal runs in a chat at a time: the panel asks first (In a new chat, or Here instead); a /goal that lands here replaces the working one
255
+ const cur = goalOf(runtimeDir, key);
256
+ if (cur && (cur.state === 'started' || cur.state === 'waiting')) append(runtimeDir, { event: 'stopped', reason: 'replaced', id: cur.id, key, at: now.toISOString() });
218
257
  append(runtimeDir, { event: 'grilling', id, key, text: t, at: now.toISOString() });
219
258
  return { id, prompt: grillPrompt(t) };
220
259
  }
221
260
 
222
261
  const fail = (status, error) => ({ status, body: { ok: false, error } });
223
- /** The PM's Start or Cancel on the goal card. sessions: { alive(id), type(id, text) }; session: the key's chat session id. */
224
- function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new Date() }) {
262
+ /** The PM's presses on the goal: Start or Cancel on the plan card, Stop, the plan edited in place (plan), a done point skipped or kept
263
+ * (skip, unskip), and a working goal replaced by a new /goal here (replace). sessions: { alive(id), type(id, text), keys?(id, k) };
264
+ * session: the key's chat session id. */
265
+ const ACTS = ['start', 'cancel', 'stop', 'plan', 'skip', 'unskip', 'replace'];
266
+ function decide({ runtimeDir, key, id, act, draft, point, session, sessions, now = new Date() }) {
225
267
  if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the goal in');
226
- if (!['start', 'cancel', 'stop'].includes(act)) return fail(400, 'act must be start, cancel or stop');
268
+ if (!ACTS.includes(act)) return fail(400, 'act must be one of ' + ACTS.join(', '));
227
269
  const g = goalOf(runtimeDir, key);
228
270
  if (!g || g.id !== id) return fail(404, 'That goal is not the one this conversation is on.');
229
- if (act === 'stop') { // U5: the PM's Stop on a working goal: Esc in the session, and the goal ends
230
- if (g.state !== 'started') return fail(409, 'This goal is not working.');
231
- if (session && sessions && sessions.alive(session) && sessions.keys) sessions.keys(session, '\x1b');
232
- append(runtimeDir, { event: 'stopped', reason: 'pm', id, key, at: now.toISOString() });
271
+ const at = now.toISOString(), working = g.state === 'started' || g.state === 'waiting';
272
+ const alive = !!(session && sessions && sessions.alive(session));
273
+ if (act === 'stop' || act === 'replace') { // U5: the PM's Stop on a working goal: Esc in the session, and the goal ends
274
+ if (act === 'stop' ? g.state !== 'started' : !working) return fail(409, 'This goal is not working.');
275
+ if (alive && sessions.keys) sessions.keys(session, '\x1b');
276
+ append(runtimeDir, { event: 'stopped', reason: act === 'stop' ? 'pm' : 'replaced', id, key, at });
233
277
  return { status: 200, body: { ok: true, id, state: 'stopped' } };
234
278
  }
279
+ if (act === 'skip' || act === 'unskip') {
280
+ if (!working) return fail(409, 'Only a working goal has points to skip.');
281
+ const p = clip(point, 200), all = (g.draft && g.draft.done) || [], skipped = g.skipped || [];
282
+ if (!all.includes(p)) return fail(400, 'That point is not in this goal.');
283
+ if (act === 'skip' && (skipped.includes(p) || (g.met || []).includes(p))) return fail(409, 'That point is already ' + (skipped.includes(p) ? 'skipped.' : 'met.'));
284
+ if (act === 'skip' && requiredOf(g).length <= 1) return fail(409, 'A goal keeps at least one done point. Stop it instead.');
285
+ if (act === 'unskip' && !skipped.includes(p)) return fail(409, 'That point is not skipped.');
286
+ if (act === 'unskip' && Date.parse((g.skipAt || {})[p] || '') <= Date.parse(g.roundAt || '')) return fail(409, 'Claude has already dropped that point. Tell Claude to pick it up again.');
287
+ // a queued instruction: typed while Claude works, so Claude reads it after its current step
288
+ if (!alive || !sessions.type(session, act === 'skip' ? skipMessage(p) : unskipMessage(p))) return fail(409, 'The message did not reach the session. Open it in Sessions.');
289
+ append(runtimeDir, { event: act, point: p, id, key, at });
290
+ return { status: 200, body: { ok: true, id, state: g.state } };
291
+ }
292
+ if (act === 'plan') { // the plan edited in place: before Start it is the newest plan; while it works it applies after the current step
293
+ if (g.state !== 'grilling' && !working) return fail(409, 'This goal has ended. Send /goal to set a new one.');
294
+ const d = cleanDraft(draft); if (!d) return fail(400, 'The plan needs a sentence and at least one done point.');
295
+ if (!alive || !sessions.type(session, planMessage(d, working))) return fail(409, 'The message did not reach the session. Open it in Sessions.');
296
+ append(runtimeDir, { event: working ? 'edited' : 'planned', id, key, draft: d, at });
297
+ return { status: 200, body: { ok: true, id, state: g.state } };
298
+ }
235
299
  if (g.state !== 'grilling') return fail(409, g.state === 'cancelled' ? 'This goal was cancelled.' : 'This goal has already started.');
236
- if (!session || !sessions || !sessions.alive(session)) return fail(409, 'No session is running for this conversation. Send /goal again to start one.');
300
+ if (!alive) return fail(409, 'No session is running for this conversation. Send /goal again to start one.');
237
301
  let d = null;
238
302
  if (act === 'start') { d = cleanDraft(draft); if (!d) return fail(400, 'The goal needs a sentence and at least one done point before it can start.'); }
239
303
  if (!sessions.type(session, act === 'start' ? startMessage(d) : cancelMessage())) return fail(409, 'The message did not reach the session. Open it in Sessions.');
240
- append(runtimeDir, { event: act === 'start' ? 'started' : 'cancelled', id, key, ...(d ? { draft: d } : {}), at: now.toISOString() });
304
+ append(runtimeDir, { event: act === 'start' ? 'started' : 'cancelled', id, key, ...(d ? { draft: d } : {}), at });
241
305
  return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
242
306
  }
243
307
 
244
- module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
308
+ module.exports = { parseCommand, grillPrompt, methodMessage, planMessage, skipMessage, unskipMessage, METHODS, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
@@ -82,14 +82,15 @@ function bulkTarget({ target, ids, state } = {}) {
82
82
 
83
83
  function mintFromPress(root, { scope, target, ids, state, instruction, initiative } = {}, { actor: who } = {}) {
84
84
  if (!PRESS_SCOPES.includes(scope)) return { ok: false, status: 400, error: 'a press cannot mint a grant of scope ' + JSON.stringify(scope) };
85
- if (!actor.isPm(who)) return { ok: false, status: 403, error: 'only the PM mints a grant' };
85
+ // D98: an agent session mints one too; the grant's `pm` field names the agent, so the ledger says who pressed.
86
+ if (!actor.isPm(who) && !actor.isAgent(who)) return { ok: false, status: 403, error: 'only the PM or an agent session mints a grant' };
86
87
  if (scope === 'lifecycle-bulk') target = bulkTarget({ target, ids, state }) ?? target;
87
88
  if (typeof target !== 'string' || !target.trim()) return { ok: false, status: 400, error: 'a ' + scope + ' grant names its target' };
88
89
  const repo = planTree.mainTree(path.resolve(String(root)));
89
90
  const w = writerOf(repo);
90
91
  if (!w) return { ok: false, status: 500, error: 'this repository has no grants writer (scripts/record-grant.js or pmos/scripts/pmos-log.sh)' };
91
92
  const words = typeof instruction === 'string' && instruction.trim() ? instruction.trim() : 'the PM pressed ' + scope + ' in the workspace';
92
- const argv = [...w.argv, 'grant', scope + ':' + target, who.by.slice('pm:'.length), words, TTL_MINUTES];
93
+ const argv = [...w.argv, 'grant', scope + ':' + target, actor.isPm(who) ? who.by.slice('pm:'.length) : who.by, words, TTL_MINUTES];
93
94
  if (typeof initiative === 'string' && initiative) argv.push(initiative);
94
95
  const env = { PATH: process.env.PATH || '/usr/bin:/bin', HOME: process.env.HOME || repo, LANG: 'C.UTF-8' };
95
96
  const r = spawnSync(argv[0], argv.slice(1), { cwd: repo, env, encoding: 'utf8', timeout: 20000, shell: false });
@@ -6,19 +6,19 @@
6
6
  * pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor …] [--lane …] [--title "…"]
7
7
  * pmos initiative now <id> PM only: type the id to confirm
8
8
  * pmos initiative next|later <id> [--top] to the end of that horizon, or its top
9
- * pmos initiative top|up|down <id> reorder inside its horizon (in Now: PM only)
9
+ * pmos initiative top|up|down <id> reorder inside its horizon
10
10
  * pmos initiative check-by <id> <YYYY-MM-DD|none>
11
- * pmos initiative adopt <proposal-eid> PM only: type the eid to confirm
11
+ * pmos initiative adopt <proposal-eid> the PM types the eid to confirm; an agent passes (D98)
12
12
  * pmos initiative drop <proposal-eid>
13
13
  * pmos initiative list
14
14
  * pmos initiative export <id> the breakdown as markdown on stdout; nothing is written
15
15
  * every command: [--json] [--root <dir>]
16
16
  *
17
17
  * The SAME writers the workspace page uses (lib/initiative-writer.js, lib/placements.js) — no server is needed. Who
18
- * wrote a line comes from the call path, never from an argument: a PM-only act (Move to Now, adopt, and any line into
19
- * Now) goes through lib/pm-guard.js requirePmCli — an interactive terminal with no agent session, and the PM types the
20
- * confirmation; every other command takes lib/actor.js fromCli: the PM at a terminal, the bound agent session from
21
- * PMOS_SESSION, `agent:unknown` otherwise. An agent's placement is written as a proposal (`proposed: true`).
18
+ * wrote a line comes from the call path, never from an argument: Move to Now, adopt, and any line into Now go through
19
+ * lib/pm-guard.js requirePmCli — the PM types the confirmation at a terminal, and an agent session passes with its own
20
+ * actor (D98); every other command takes lib/actor.js fromCli: the PM at a terminal, the bound agent session from
21
+ * PMOS_SESSION, `agent:unknown` otherwise. An agent's placement applies at once and its line names the agent (D98).
22
22
  * Work lanes only (D86 point 4): `list` and `export` leave document-lane initiatives out.
23
23
  * Exit codes: 0 done, 1 refused, 2 usage.
24
24
  */
@@ -43,12 +43,12 @@ const USAGE = [
43
43
  ' pmos initiative next|later <id> [--top] move it to the end of Next or Later, or to its top',
44
44
  ' pmos initiative top|up|down <id> reorder it inside its horizon',
45
45
  ' pmos initiative check-by <id> <YYYY-MM-DD|none>',
46
- ' pmos initiative adopt <proposal> keep an agent proposal (you only; type the proposal to confirm)',
47
- ' pmos initiative drop <proposal> close an agent proposal',
46
+ ' pmos initiative adopt <proposal> keep an open proposal (you type the proposal to confirm)',
47
+ ' pmos initiative drop <proposal> close an open proposal',
48
48
  ' pmos initiative list Now, Next and Later, in order',
49
49
  ' pmos initiative export <id> the breakdown as markdown on stdout',
50
50
  ' every command: [--json] [--root <dir>]',
51
- 'An agent session writes a placement as a proposal for you to keep or drop. A new initiative lands in Later.',
51
+ 'An agent session\'s placement applies at once and names the agent. A new initiative lands in Later.',
52
52
  ];
53
53
  const BOOL = new Set(['json', 'top', 'help']);
54
54
  const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root']);
@@ -99,7 +99,8 @@ function readIssues(root) {
99
99
  }
100
100
  const why = lineErr(rec);
101
101
  if (why) { out.flags.push({ kind: 'invalid', eid: rec.eid || null, why: `line ${n}: ${why}` }); continue; }
102
- if (!actorLib.isPm({ by: rec.by, via: rec.via })) { out.flags.push({ kind: 'not-pm', eid: rec.eid, why: `line ${n}: ${rec.by} issued ${rec.cadence} ${rec.slot}; only the PM issues a report (R25), so the line has no effect` }); continue; }
102
+ // D98: the PM or an agent session issues a report; the line keeps who issued it.
103
+ if (!actorLib.valid({ by: rec.by, via: rec.via })) { out.flags.push({ kind: 'not-pm', eid: rec.eid, why: `line ${n}: ${rec.by} issued ${rec.cadence} ${rec.slot}, but the line names no PM or agent session, so it has no effect` }); continue; }
103
104
  const key = `${rec.cadence}\u0000${rec.slot}`;
104
105
  if (seen.has(key)) { out.flags.push({ kind: 'duplicate-slot', eid: rec.eid, why: `line ${n}: ${rec.cadence} ${rec.slot} was issued on line ${seen.get(key)}; the later line has no effect` }); continue; }
105
106
  seen.set(key, n);
@@ -133,12 +134,12 @@ function randomChars(n) {
133
134
  }
134
135
 
135
136
  /**
136
- * One `issued` line per event. The actor is the caller's guard result (pm-guard.js), never a field; only the PM
137
- * issues, and the call path must match the actor (`ui` from the page, `cli` from a terminal). Each event names a file
137
+ * One `issued` line per event. The actor is the caller's guard result (pm-guard.js), never a field; the PM or an agent
138
+ * session issues (D98), and the call path must match the actor (`ui` from the page, `cli` from a terminal). Each event names a file
138
139
  * that exists in `root` with exactly the sha sent, so a line can never freeze bytes nobody read.
139
140
  */
140
141
  function append(root, events, actor, via, { now } = {}) {
141
- if (!actorLib.isPm(actor) || actor.via !== via) return refuse(403, `only the PM issues a report, from the ${via === 'ui' ? 'page' : 'terminal'}; nothing was written`, null);
142
+ if (!actorLib.valid(actor) || actor.via !== via) return refuse(403, `a report is issued by the PM or an agent session, from the ${via === 'ui' ? 'page' : 'terminal'}; nothing was written`, null);
142
143
  if (!Array.isArray(events) || !events.length) return refuse(400, 'send at least one line', null);
143
144
  if (events.length > MAX_LINES) return refuse(413, `send at most ${MAX_LINES} lines at once`, null);
144
145
  let read;
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+ /* mention-cli.js — `pmos mention …`: Home's Mentions from a terminal (canvas XmsDeskRefine, agreed A+).
3
+ * pmos mention list [--json] what waits on you, oldest first, then the last 7 days
4
+ * pmos mention draft <id> --text "<reply>" | --file <path|-> [--json] change the proposed reply the Mentions Viewer shows
5
+ * Claude runs `draft` from the chat where the PM changes a reply ("Reply to Arif"): the Viewer shows the new reply on its next read.
6
+ * The mark is one line in <runtime>/mentions/marks.jsonl with by: agent. This command posts nothing: the PM sends the reply where the
7
+ * mention is. */
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const stateRoot = require('./state-root');
11
+ const store = require('./mention-store.js');
12
+
13
+ const COMMANDS = { mention: ['list', 'draft'] };
14
+ const USAGE = [
15
+ 'usage: pmos mention list|draft — Home\'s Mentions',
16
+ ' pmos mention list what waits on you, oldest first, then the last 7 days',
17
+ ' pmos mention draft <id> --text "<reply>" change the proposed reply of one mention (or --file <path|->)',
18
+ ' every command: [--json]',
19
+ 'This command never posts. You send the reply where the mention is.',
20
+ ];
21
+
22
+ function parseArgs(argv) {
23
+ const out = { _: [] };
24
+ for (let i = 0; i < argv.length; i++) {
25
+ const t = argv[i];
26
+ if (!t.startsWith('--')) { out._.push(t); continue; }
27
+ const key = t.slice(2);
28
+ if (key === 'json' || key === 'help') out[key] = true;
29
+ else if (argv[i + 1] !== undefined) out[key] = argv[++i];
30
+ else out[key] = '';
31
+ }
32
+ return out;
33
+ }
34
+
35
+ function run(argv, { say = console.log, env = process.env, stateDir, cwd = process.cwd(), now = () => new Date(), stdin } = {}) {
36
+ const a = parseArgs(argv.slice(1));
37
+ const sub = a._[0];
38
+ const out = (o, line) => { if (a.json) say(JSON.stringify(o)); else say(line); };
39
+ if (!sub || a.help || sub === 'help') { USAGE.forEach((l) => say(l)); return sub || a.help ? 0 : 2; }
40
+ if (!COMMANDS.mention.includes(sub)) { say(`✗ pmos mention ${sub} is not a command`); USAGE.forEach((l) => say(l)); return 2; }
41
+ const dir = stateDir || stateRoot.defaultRoot({ env });
42
+
43
+ if (sub === 'list') {
44
+ const v = require('./routes-mentions.js').answer(dir, { now: now().getTime(), cwd });
45
+ if (a.json) { say(JSON.stringify(v)); return 0; }
46
+ if (!v.waiting.length && !v.recent.length) { say('Nobody mentioned you in the last 7 days.'); return 0; }
47
+ say(v.waiting.length ? `${v.waiting.length} wait on your reply` : 'Nothing waits on you');
48
+ for (const m of v.waiting) say(` ${m.id} ${m.who || m.source} · ${m.where || m.source} · since ${m.since || '?'}${m.count > 1 ? ' · ' + m.count + ' asks' : ''}: ${m.text}`);
49
+ if (v.recent.length) say('Last 7 days');
50
+ for (const m of v.recent) say(` ${m.id} ${m.who || m.source} · ${m.where || m.source}${m.status ? ' · ' + m.status : ''}: ${m.text}`);
51
+ return 0;
52
+ }
53
+ // draft
54
+ const id = a._[1];
55
+ if (!id || !/^[0-9a-f]{12}$/.test(id)) { out({ ok: false, error: 'the mention id is 12 hex characters (pmos mention list shows it)' }, '✗ the mention id is 12 hex characters (pmos mention list shows it)'); return 2; }
56
+ let text = a.text;
57
+ if (text === undefined && a.file !== undefined) {
58
+ try { text = a.file === '-' ? (stdin !== undefined ? stdin : fs.readFileSync(0, 'utf8')) : fs.readFileSync(path.resolve(cwd, a.file), 'utf8'); }
59
+ catch (e) { out({ ok: false, error: `could not read ${a.file}: ${e.message}` }, `✗ could not read ${a.file}`); return 1; }
60
+ }
61
+ if (typeof text !== 'string' || !text.trim()) { out({ ok: false, error: '--text "<reply>" or --file <path|-> is required' }, '✗ --text "<reply>" or --file <path|-> is required'); return 2; }
62
+ const known = JSON.parse(JSON.stringify(require('./routes-mentions.js').answer(dir, { now: now().getTime(), cwd })));
63
+ if (![...known.waiting, ...known.recent].some((m) => m.id === id)) { out({ ok: false, error: `no mention ${id}` }, `✗ no mention ${id}. pmos mention list shows them.`); return 1; }
64
+ const r = store.mark(dir, { id, act: 'draft', text }, now(), 'agent');
65
+ if (!r.ok) { out(r, `✗ refused: ${r.error}`); return 1; }
66
+ out({ ok: true, id }, `saved the proposed reply of ${id}. The Mentions Viewer shows it; you send it where the mention is.`);
67
+ return 0;
68
+ }
69
+
70
+ module.exports = { run, COMMANDS, USAGE };