create-pmos 0.553.0 → 0.555.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 (184) hide show
  1. package/package.json +33 -27
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-board-test.js +4 -4
  8. package/workspace/briefing-premium-initiative-test.js +2 -2
  9. package/workspace/briefing-premium-test.js +1 -1
  10. package/workspace/changelog.json +32 -0
  11. package/workspace/chat-asks-test.js +5 -5
  12. package/workspace/ev-everywhere-test.js +2 -2
  13. package/workspace/goals-clear-ui-test.js +1 -1
  14. package/workspace/guide/agent-capabilities.md +33 -31
  15. package/workspace/guide/claude-proposes.md +68 -68
  16. package/workspace/guide/cli.md +23 -22
  17. package/workspace/guide/cloud.md +3 -3
  18. package/workspace/guide/home.md +38 -38
  19. package/workspace/guide/index.md +5 -5
  20. package/workspace/guide/intelligence-okr-goals.md +4 -4
  21. package/workspace/guide/layout.md +23 -23
  22. package/workspace/guide/notes.md +8 -8
  23. package/workspace/guide/programs.md +17 -17
  24. package/workspace/guide/reports.md +16 -16
  25. package/workspace/guide/settings-and-switches.md +40 -37
  26. package/workspace/guide/statuses.md +3 -3
  27. package/workspace/home-other-product-test.js +8 -8
  28. package/workspace/home-pill-test.js +3 -3
  29. package/workspace/home-rows-test.js +7 -7
  30. package/workspace/intel-report-ui-test.js +1 -1
  31. package/workspace/intelligence-gaps-ui-test.js +2 -2
  32. package/workspace/lib/agent-roles.js +1 -1
  33. package/workspace/lib/autonomy-cli.js +16 -2
  34. package/workspace/lib/autonomy.js +84 -11
  35. package/workspace/lib/bg-queue.js +1 -1
  36. package/workspace/lib/briefing-premium-agent.js +2 -2
  37. package/workspace/lib/decision-memory.js +2 -2
  38. package/workspace/lib/driver-decide.js +6 -3
  39. package/workspace/lib/driver.js +6 -2
  40. package/workspace/lib/folder-needs.js +1 -1
  41. package/workspace/lib/goal-chat.js +5 -5
  42. package/workspace/lib/goal-watch.js +1 -1
  43. package/workspace/lib/grill-runs.js +5 -5
  44. package/workspace/lib/headless.js +5 -2
  45. package/workspace/lib/idle-lab.js +5 -5
  46. package/workspace/lib/impact-runs.js +2 -2
  47. package/workspace/lib/job-graph.js +6 -3
  48. package/workspace/lib/metric-draft-runs.js +4 -4
  49. package/workspace/lib/metric-read-runs.js +5 -5
  50. package/workspace/lib/news-for-you.js +1 -1
  51. package/workspace/lib/proposal-runs.js +6 -6
  52. package/workspace/lib/refresh.js +1 -1
  53. package/workspace/lib/routes-artefacts.js +10 -4
  54. package/workspace/lib/routes-autonomy.js +1 -1
  55. package/workspace/lib/routes-board-premium.js +1 -1
  56. package/workspace/lib/routes-goal-status.js +4 -4
  57. package/workspace/lib/routes-impact.js +1 -1
  58. package/workspace/lib/routes-insight-moves.js +1 -1
  59. package/workspace/lib/routes-loose.js +2 -2
  60. package/workspace/lib/routes-mentions.js +1 -1
  61. package/workspace/lib/routes-metric-drafts.js +9 -9
  62. package/workspace/lib/routes-proposals.js +9 -9
  63. package/workspace/lib/routes-ready-reports.js +1 -1
  64. package/workspace/lib/routes-slash.js +1 -1
  65. package/workspace/lib/source-heal.js +3 -3
  66. package/workspace/lib/state-root.js +22 -1
  67. package/workspace/lib/story-seed.js +95 -0
  68. package/workspace/lib/task-items.js +1 -1
  69. package/workspace/lib/task-links.js +2 -2
  70. package/workspace/lib/team-cli.js +1 -1
  71. package/workspace/lib/today.js +2 -2
  72. package/workspace/lib/verify-runs.js +87 -3
  73. package/workspace/live-pill-round-test.js +1 -1
  74. package/workspace/metric-drafts-ui-test.js +1 -1
  75. package/workspace/milestone-suggest-test.js +5 -5
  76. package/workspace/news-viewers-test.js +3 -3
  77. package/workspace/okr-goals-ui-test.js +1 -1
  78. package/workspace/package-lock.json +2 -2
  79. package/workspace/package.json +1 -1
  80. package/workspace/premium-chat-chart-tab-test.js +1 -1
  81. package/workspace/premium-chat-context-test.js +4 -4
  82. package/workspace/premium-chat-goal-setup-test.js +3 -3
  83. package/workspace/premium-chat-goal-view-test.js +1 -1
  84. package/workspace/premium-chat-line-test.js +6 -6
  85. package/workspace/premium-chat-notes-test.js +4 -4
  86. package/workspace/premium-chat-report-tab-test.js +4 -4
  87. package/workspace/premium-rec-now-test.js +2 -2
  88. package/workspace/public/pm/batch-press.js +4 -4
  89. package/workspace/public/pm/bd-fc-card.js +1 -1
  90. package/workspace/public/pm/bd-next.js +10 -10
  91. package/workspace/public/pm/bd-prog-panel.js +5 -5
  92. package/workspace/public/pm/chat-ask.js +1 -1
  93. package/workspace/public/pm/chat-context.js +3 -3
  94. package/workspace/public/pm/cozy-evmodel.js +1 -1
  95. package/workspace/public/pm/cozy-home.css +1 -1
  96. package/workspace/public/pm/cozy-lab-ins.js +4 -4
  97. package/workspace/public/pm/cozy-lab.js +1 -1
  98. package/workspace/public/pm/cozy-news.js +2 -2
  99. package/workspace/public/pm/cozy-onboard.js +2 -2
  100. package/workspace/public/pm/cozy-rec-now.js +5 -5
  101. package/workspace/public/pm/cozy-rec-present.js +1 -1
  102. package/workspace/public/pm/cozy-reveal.js +2 -2
  103. package/workspace/public/pm/cozy-settings.js +19 -19
  104. package/workspace/public/pm/cozy-steps.js +2 -2
  105. package/workspace/public/pm/cozy-viewer.js +1 -1
  106. package/workspace/public/pm/ctx-wedge.js +1 -1
  107. package/workspace/public/pm/dash-view.js +1 -1
  108. package/workspace/public/pm/goal-chat.js +6 -6
  109. package/workspace/public/pm/good-morning.js +2 -2
  110. package/workspace/public/pm/grill-words.js +1 -1
  111. package/workspace/public/pm/home-app.js +19 -19
  112. package/workspace/public/pm/home-ask.js +1 -1
  113. package/workspace/public/pm/home-chat.js +6 -6
  114. package/workspace/public/pm/home-data.js +2 -2
  115. package/workspace/public/pm/home-day.js +3 -3
  116. package/workspace/public/pm/home-drift.js +1 -1
  117. package/workspace/public/pm/home-goal.js +1 -1
  118. package/workspace/public/pm/home-impact.js +1 -1
  119. package/workspace/public/pm/home-ini.js +1 -1
  120. package/workspace/public/pm/home-line.js +5 -5
  121. package/workspace/public/pm/home-mentions.js +4 -4
  122. package/workspace/public/pm/home-moment.js +1 -1
  123. package/workspace/public/pm/home-need.js +1 -1
  124. package/workspace/public/pm/home-phone-card.js +1 -1
  125. package/workspace/public/pm/home-stage-card.js +2 -2
  126. package/workspace/public/pm/home-sweep.js +1 -1
  127. package/workspace/public/pm/home-today.js +2 -2
  128. package/workspace/public/pm/ini-about.js +2 -2
  129. package/workspace/public/pm/ini-agent.js +5 -5
  130. package/workspace/public/pm/ini-links.js +5 -5
  131. package/workspace/public/pm/ini-props.js +11 -11
  132. package/workspace/public/pm/ini-view-model.js +1 -1
  133. package/workspace/public/pm/ini-view.js +2 -2
  134. package/workspace/public/pm/intent.js +3 -3
  135. package/workspace/public/pm/loose-props.js +5 -5
  136. package/workspace/public/pm/metric-drafts.js +1 -1
  137. package/workspace/public/pm/ms-suggest.js +3 -3
  138. package/workspace/public/pm/next-prompt-ui.js +2 -2
  139. package/workspace/public/pm/okr-list.js +1 -1
  140. package/workspace/public/pm/page-chat.js +2 -2
  141. package/workspace/public/pm/premium-attach.js +1 -1
  142. package/workspace/public/pm/premium-initiative-head.js +1 -1
  143. package/workspace/public/pm/premium-insights.js +3 -3
  144. package/workspace/public/pm/premium-meeting.js +1 -1
  145. package/workspace/public/pm/premium-mtg-replay.js +1 -1
  146. package/workspace/public/pm/premium-notes.js +2 -2
  147. package/workspace/public/pm/premium-report-read.js +6 -6
  148. package/workspace/public/pm/premium-report-tab.js +7 -7
  149. package/workspace/public/pm/premium-shell.js +18 -18
  150. package/workspace/public/pm/premium-vw-ctx.js +3 -3
  151. package/workspace/public/pm/premium-vw-jira.js +1 -1
  152. package/workspace/public/pm/premium-welcome.js +1 -1
  153. package/workspace/public/pm/prog-order.js +2 -2
  154. package/workspace/public/pm/program-charter.js +3 -3
  155. package/workspace/public/pm/program-model.js +1 -1
  156. package/workspace/public/pm/ready-lib.js +4 -4
  157. package/workspace/public/pm/report-flow.js +7 -7
  158. package/workspace/public/pm/report-orders-ui.js +2 -2
  159. package/workspace/public/pm/split-merge.js +5 -5
  160. package/workspace/public/pm/story.js +1 -1
  161. package/workspace/public/pm/task-card.js +1 -1
  162. package/workspace/public/pm/tk-draft.js +1 -1
  163. package/workspace/public/pm/tk-send.js +2 -2
  164. package/workspace/public/pm/wf-page.js +2 -2
  165. package/workspace/ready-dash-ui-test.js +1 -1
  166. package/workspace/rec-present-test.js +2 -2
  167. package/workspace/server.js +14 -8
  168. package/workspace/session-names-test.js +3 -3
  169. package/workspace/skills/doc-check.skill +2 -0
  170. package/workspace/skills/idle-lab-prototype.skill +2 -0
  171. package/workspace/skills/measure.skill +2 -0
  172. package/workspace/skills/metric-read.skill +2 -0
  173. package/workspace/skills/milestone-review.skill +2 -0
  174. package/workspace/skills/report-biweekly.skill +2 -0
  175. package/workspace/skills/report-daily.skill +2 -0
  176. package/workspace/skills/report-design.skill +2 -0
  177. package/workspace/skills/report-monthly.skill +2 -0
  178. package/workspace/skills/report-weekly.skill +2 -0
  179. package/workspace/skills/story-first.skill +23 -0
  180. package/workspace/split-merge-ui-test.js +3 -3
  181. package/workspace/stage-card-test.js +4 -4
  182. package/workspace/task-links-test.js +1 -1
  183. package/workspace/task-views-test.js +7 -7
  184. package/workspace/tk-tasks-test.js +2 -2
@@ -41,12 +41,15 @@ const LEDGERS = Object.freeze({
41
41
  '<runtime>/run-tokens.jsonl': { concept: 'run-tokens', owner: 'lib/run-tokens.js', readers: [
42
42
  r('lib/ai-cli.js', 'run-tokens.js', '`pmos ai status`: tokens read per background run, lean and full')] },
43
43
  '<runtime>/bg-queue.jsonl': { concept: 'background-turns', owner: 'lib/bg-queue.js', readers: [
44
- r('lib/routes-lab.js', 'bgQueue.record', 'Intelligence › Lab: what Claude did in the background')] },
44
+ r('lib/routes-lab.js', 'bgQueue.record', 'Intelligence › Lab: what PMOS did in the background')] },
45
45
  '<runtime>/grill-runs.jsonl': { concept: 'grill-spend', owner: 'lib/grill.js', readers: [
46
46
  r('lib/bg-queue.js', 'grill-runs.jsonl', 'the spend limit that holds step 5'),
47
- r('lib/routes-grill.js', null, "Settings › Claude's checks: this month's spend")] },
47
+ r('lib/routes-grill.js', null, "Settings › PMOS's checks: this month's spend")] },
48
48
  '<runtime>/goal-loops.jsonl': { concept: 'goal-loops', owner: 'lib/goal-loop.js', readers: [
49
49
  r('lib/loop-cli.js', null, '`pmos loop status`: each goal, its round and its state')] },
50
+ '<state>/autonomy.jsonl': { concept: 'autonomy', owner: 'lib/autonomy.js', readers: [
51
+ r('lib/routes-autonomy.js', 'A.done', 'what PMOS did by itself on Home and in the Viewer, each with its reason and Undo'),
52
+ r('lib/loop-health.js', 'A.fold', 'the jobs back to asking, on the health line')] },
50
53
  '<state>/driver.jsonl': { concept: 'driver-runs', owner: 'lib/driver.js', readers: [
51
54
  r('lib/routes-driver.js', null, "the initiative's Agent strip"),
52
55
  r('lib/driver-needs.js', null, 'Needs you')] },
@@ -126,7 +129,7 @@ const JOBS = Object.freeze([
126
129
  q('grill', 'lib/grill-runs.js', [props, '<runtime>/grill-runs.jsonl'], [props, 'repo:DECISIONS.md']),
127
130
  q('metric-drafts', 'lib/metric-draft-runs.js', ['<state>/metric-drafts.jsonl'], ['<state>/metric-reads.jsonl']),
128
131
  q('impact', 'lib/impact-runs.js', ['<runtime>/impact.jsonl'], ['connectors']),
129
- q('verify', 'lib/verify-runs.js', ['repo:planning/runs/evals.jsonl', 'repo:planning/runs/verify-queue.jsonl', 'repo:planning/work-items.jsonl'], ['repo:planning/runs/verify-queue.jsonl', 'git']),
132
+ q('verify', 'lib/verify-runs.js', ['repo:planning/runs/evals.jsonl', 'repo:planning/runs/verify-queue.jsonl', 'repo:planning/work-items.jsonl', '<state>/autonomy.jsonl'], ['repo:planning/runs/verify-queue.jsonl', '<state>/autonomy.jsonl', 'git']),
130
133
  q('metric-reads', 'lib/metric-read-runs.js', ['<state>/metric-reads.jsonl'], ['connectors']),
131
134
  q('forecast', 'lib/forecast-tick.js', ['<state>/forecast.jsonl'], ['<state>/boards.jsonl']),
132
135
  q('report-design', 'lib/routes-report-design.js', ['<state>/design.jsonl']),
@@ -145,14 +145,14 @@ function create(deps) {
145
145
 
146
146
  /** Start one run now. → { ok, run } | { ok: false, error, held? } */
147
147
  function start({ ws, scope, id, why = 'press', press = true, now = Date.now(), gaps = null, sig = null } = {}) {
148
- if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'Claude\'s metric drafts are off (PMOS_METRIC_DRAFT or PMOS_HEADLESS).' };
148
+ if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'PMOS\'s metric drafts are off (PMOS_METRIC_DRAFT or PMOS_HEADLESS).' };
149
149
  if (!MD.SCOPES.includes(scope) || !id) return { ok: false, error: 'Say which product, program or initiative to draft for.' };
150
150
  const w = (deps.workspaces() || []).find((x) => x.id === ws);
151
151
  if (!w) return { ok: false, error: 'no such workspace' };
152
152
  const dir = deps.stateDirFor(w);
153
153
  if (!dir) return { ok: false, error: 'This repository has no PMOS state folder, so nothing can be drafted.' };
154
154
  for (const [r, a] of active) if (a.ws === ws && a.scope === scope && a.id === id) return { ok: true, run: r, already: true };
155
- if (active.size >= MAX) return { ok: false, held: true, error: 'Claude is drafting two others now. It drafts this one when one ends.' };
155
+ if (active.size >= MAX) return { ok: false, held: true, error: 'PMOS is drafting two others now. It drafts this one when one ends.' };
156
156
  const skill = deps.promptFor('metric-draft');
157
157
  if (!skill) return { ok: false, error: 'The metric-draft skill is not installed.' };
158
158
  const run = 'md' + now.toString(36) + crypto.randomBytes(3).toString('hex');
@@ -171,13 +171,13 @@ function create(deps) {
171
171
  session = go({ name: 'Drafting metrics · ' + one(title, 60), ws, ...(press ? { byPm: true } : {}), origin: `metric-draft:${ws}:${scope}:${id}:${run}`, initialInput: prompt + '\r', ...(scope === 'initiative' ? { initiative: id } : {}),
172
172
  env: { PMOS_METRIC_DRAFT_FILE: MD.ledgerFile(dir), PMOS_METRIC_DRAFT_WS: ws, PMOS_METRIC_DRAFT_SCOPE: scope, PMOS_METRIC_DRAFT_ID: id, PMOS_METRIC_DRAFT_RUN: run }, onDone: (r) => ended(run, r) });
173
173
  } catch (e) { warn('metric draft run', e); }
174
- if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs. It tries again in a minute.' }; }
174
+ if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'PMOS is busy with other runs. It tries again in a minute.' }; }
175
175
  // the start line lands before the run's first `pmos metrics draft` (the run starts reading after this returns), stamped with the tick's clock
176
176
  MD.append(dir, null, { kind: 'start', scope, id, run, why, title, when: MD.WHEN[why] || '', ...(sig ? { gaps: sig } : {}) }, new Date(now).toISOString());
177
177
  if (!session || session.state === 'exited' || session.headless !== 'metric-draft') {
178
178
  if (session && session.headless !== 'metric-draft' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
179
179
  ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background', result: {} }, now);
180
- return { ok: false, error: (session && session.note) || 'Claude could not start drafting.' };
180
+ return { ok: false, error: (session && session.note) || 'PMOS could not start drafting.' };
181
181
  }
182
182
  const a = active.get(run); if (a) a.session = session;
183
183
  return { ok: true, run };
@@ -65,13 +65,13 @@ function create(deps) {
65
65
 
66
66
  /** Start one run now. → { ok, run } | { ok: false, error, held? } */
67
67
  function start({ ws, rids, why = 'press', now = Date.now(), compare = null } = {}) {
68
- if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'Claude\'s goal readings are off (PMOS_METRIC_READ or PMOS_HEADLESS).' };
68
+ if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'PMOS\'s goal readings are off (PMOS_METRIC_READ or PMOS_HEADLESS).' };
69
69
  const w = (deps.workspaces() || []).find((x) => x.id === ws);
70
70
  if (!w) return { ok: false, error: 'no such workspace' };
71
71
  const dir = deps.stateDirFor(w);
72
72
  if (!dir) return { ok: false, error: 'This repository has no PMOS state folder, so nothing can be read.' };
73
- for (const [r, a] of active) if (a.ws === ws) return { ok: false, held: true, already: r, error: 'Claude is reading this product\'s goals now. It reads these when that run ends.' };
74
- if (active.size >= MAX) return { ok: false, held: true, error: 'Claude is reading two other products now. It reads these when one ends.' };
73
+ for (const [r, a] of active) if (a.ws === ws) return { ok: false, held: true, already: r, error: 'PMOS is reading this product\'s goals now. It reads these when that run ends.' };
74
+ if (active.size >= MAX) return { ok: false, held: true, error: 'PMOS is reading two other products now. It reads these when one ends.' };
75
75
  const test = why === 'test' || !!(compare && compare.draft);
76
76
  let items = [];
77
77
  if (test) { try { items = (deps.testItems && deps.testItems(w, rids)) || []; } catch { items = []; } }
@@ -95,13 +95,13 @@ function create(deps) {
95
95
  env: { PMOS_METRIC_READ_FILE: MR.ledgerFile(dir), PMOS_METRIC_READ_RECORDS: deps.recordsDir(w), PMOS_METRIC_READ_DRAFTS: (deps.draftsFile && deps.draftsFile(w)) || '',
96
96
  PMOS_METRIC_READ_WS: ws, PMOS_METRIC_READ_RUN: run, PMOS_METRIC_READ_RIDS: ids.join(','), PMOS_METRIC_READ_TEST: test ? '1' : '' }, onDone: (r) => ended(run, r) });
97
97
  } catch (e) { warn('metric read run', e); }
98
- if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs. It tries again in a minute.' }; }
98
+ if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'PMOS is busy with other runs. It tries again in a minute.' }; }
99
99
  // the start line lands before the run's first `pmos metrics reading` (the run starts reading after this returns)
100
100
  MR.append(dir, null, { kind: 'start', run, ws, rids: ids, why }, new Date(now).toISOString());
101
101
  if (!session || session.state === 'exited' || session.headless !== 'metric-read') {
102
102
  if (session && session.headless !== 'metric-read' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
103
103
  ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background' }, now);
104
- return { ok: false, error: (session && session.note) || 'Claude could not start reading.' };
104
+ return { ok: false, error: (session && session.note) || 'PMOS could not start reading.' };
105
105
  }
106
106
  const a = active.get(run); if (a) a.session = session;
107
107
  return { ok: true, run, rids: ids };
@@ -63,7 +63,7 @@ function build({ inbox = null, work = null, seen = new Set(), name = () => '', b
63
63
  const by = (a, b) => (b.at || 0) - (a.at || 0);
64
64
  const ib = inbox && inbox.ok !== false && Array.isArray(inbox.items) ? inbox.items : [];
65
65
  const groups = [
66
- { key: 'propose', label: 'Claude proposes', items: ib.filter((x) => x && x.id && x.overlap && x.overlap.with && !seen.has(x.id)).map((x) => overlapItem(x, name))
66
+ { key: 'propose', label: 'PMOS proposes', items: ib.filter((x) => x && x.id && x.overlap && x.overlap.with && !seen.has(x.id)).map((x) => overlapItem(x, name))
67
67
  .concat((bridges || []).filter((x) => x && x.id && x.kind === 'wf-bridge' && !seen.has(x.id))).sort(by) },
68
68
  { key: 'given', label: 'Given to you', items: givenItems(work, seen, name).sort(by) },
69
69
  { key: 'finished', label: 'Finished while you were away', items: finishedItems(inbox, seen).sort(by) },
@@ -95,7 +95,7 @@ function create(deps) {
95
95
 
96
96
  /** Start one run now. → { ok, run } | { ok: false, error } */
97
97
  function start({ ws, board, ini, why = 'populate', press = true, now = Date.now() } = {}) {
98
- if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'Claude\'s background runs are off (PMOS_PROPOSE or PMOS_HEADLESS)' };
98
+ if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'PMOS\'s background runs are off (PMOS_PROPOSE or PMOS_HEADLESS)' };
99
99
  const w = (deps.workspaces() || []).find((x) => x.id === ws);
100
100
  if (!w) return { ok: false, error: 'no such workspace' };
101
101
  const dir = deps.stateDirFor(w);
@@ -119,14 +119,14 @@ function create(deps) {
119
119
  session = go({ name: (why === 'check' ? 'Task check · ' : 'Looking for · ') + one(row.title || ini, 60), ws, origin: `propose:${ws}:${ini}:${run}`, initialInput: prompt + '\r', initiative: ini,
120
120
  env: { PMOS_PROPOSE_FILE: PR.ledgerFile(dir), PMOS_PROPOSE_WS: ws, PMOS_PROPOSE_BOARD: board || '', PMOS_PROPOSE_INI: ini, PMOS_PROPOSE_RUN: run }, onDone: (r) => ended(run, r) });
121
121
  } catch (e) { warn('proposal run', e); }
122
- if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs; it looks again in a minute' }; }
122
+ if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'PMOS is busy with other runs; it looks again in a minute' }; }
123
123
  // the look line lands before the run's first `pmos propose look` (the run starts reading after this returns)
124
124
  // stamped with the tick's clock, so "once a day" compares the same clock the tick reads (a test or a tick near midnight)
125
125
  PR.append(dir, null, { kind: 'look', ini, board: board || (deps.boardOf && deps.boardOf(w, ini)) || '', run, why, at: new Date(now).toISOString() });
126
126
  if (!session || session.state === 'exited' || session.headless !== 'propose') {
127
127
  if (session && session.headless !== 'propose' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
128
128
  ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background', result: {} }, now);
129
- return { ok: false, error: (session && session.note) || 'Claude could not start looking' };
129
+ return { ok: false, error: (session && session.note) || 'PMOS could not start looking' };
130
130
  }
131
131
  const a = active.get(run); if (a) a.session = session;
132
132
  return { ok: true, run };
@@ -134,7 +134,7 @@ function create(deps) {
134
134
 
135
135
  /** Home's clean-up: one run over the rows Home last showed loose. → { ok, run } | { ok: false, error, held? } */
136
136
  function startLoose({ why = 'check', press = true, now = Date.now() } = {}) {
137
- if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'Claude\'s background runs are off (PMOS_PROPOSE or PMOS_HEADLESS)' };
137
+ if (off(deps.env) || (deps.headlessOff && deps.headlessOff())) return { ok: false, error: 'PMOS\'s background runs are off (PMOS_PROPOSE or PMOS_HEADLESS)' };
138
138
  const dir = deps.looseDir ? deps.looseDir() : null, w = deps.homeWs ? deps.homeWs() : null;
139
139
  if (!dir || !w) return { ok: false, error: 'no place to keep the clean-up' };
140
140
  for (const [r, a] of active) if (a.ini === LOOSE) return { ok: true, run: r, already: true };
@@ -153,12 +153,12 @@ function create(deps) {
153
153
  session = go({ name: 'Tidy loose work', ws: w.id, origin: `propose:${w.id}:${LOOSE}:${run}`, initialInput: prompt + '\r',
154
154
  env: { PMOS_PROPOSE_FILE: LP.ledgerFile(dir), PMOS_PROPOSE_WS: w.id, PMOS_PROPOSE_BOARD: '', PMOS_PROPOSE_INI: LOOSE, PMOS_PROPOSE_RUN: run }, onDone: (r) => ended(run, r) });
155
155
  } catch (e) { warn('clean-up run', e); }
156
- if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'Claude is busy with other runs; it looks again in a minute' }; }
156
+ if (session && session.held) { active.delete(run); return { ok: false, held: true, error: 'PMOS is busy with other runs; it looks again in a minute' }; }
157
157
  LP.append(dir, null, { kind: 'look', run, why, at: new Date(now).toISOString() });
158
158
  if (!session || session.state === 'exited' || session.headless !== 'propose') {
159
159
  if (session && session.headless !== 'propose' && session.state !== 'exited' && deps.stop) { try { deps.stop(session); } catch { /* best effort */ } }
160
160
  ended(run, { code: 1, note: (session && session.note) || 'the run could not start in the background', result: {} }, now);
161
- return { ok: false, error: (session && session.note) || 'Claude could not start looking' };
161
+ return { ok: false, error: (session && session.note) || 'PMOS could not start looking' };
162
162
  }
163
163
  const a = active.get(run); if (a) a.session = session;
164
164
  return { ok: true, run };
@@ -65,7 +65,7 @@ const SOURCES = Object.freeze([
65
65
  def: { kind: 'daily', times: ['06:45'] } },
66
66
  // popup context slice 3b (PM pick, 2026-10-21): one leads session after the reads, for the popups the PM opened; it reads no tool
67
67
  { id: 'leads', label: 'Popup leads', group: 'pmos', ic: 'notes', run: 'skill', skill: 'popup-leads', how: 'bg',
68
- what: 'Claude\'s short lead for each popup you opened in the last 14 days, written from the stored reads after they are refreshed. It reads no tool.', uses: ['calendar', 'jira', 'mywork', 'tools'],
68
+ what: 'PMOS\'s short lead for each popup you opened in the last 14 days, written from the stored reads after they are refreshed. It reads no tool.', uses: ['calendar', 'jira', 'mywork', 'tools'],
69
69
  impact: 'Popups show their last lead, or none, until you press Refresh in the popup.',
70
70
  def: { kind: 'manual' } },
71
71
  { id: 'daycheck', label: 'Day check', group: 'pmos', ic: 'clock', run: 'job', how: 'bg',
@@ -3,9 +3,10 @@
3
3
  *
4
4
  * GET /api/artefacts?ws&scope → { ok, ws, scope, kind, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
5
5
  * scope: portfolio (default), board:<id>, goal:<id>, experiment:<id> (initiative:<id> is an alias)
6
- * GET /api/artefacts/story?ws → { ok, ws, story: { scope, at, lines: [{ text, sources }] } | null } "The story so far" on the product
7
- * page (board AwE): the Narrative of board:<ws>, else of the portfolio (lib/artefacts.js storyOf). A shared
8
- * Board carries it without the sources (lib/board-pack.js).
6
+ * GET /api/artefacts/story?ws → { ok, ws, story: { scope, at, lines: [{ text, sources }] } | null, seeding? } "The story so far" on the
7
+ * product page (board AwE): the Narrative of board:<ws>, else of the portfolio (lib/artefacts.js storyOf). A
8
+ * shared Board carries it without the sources (lib/board-pack.js). seeding: there is no story yet and PMOS is
9
+ * writing the first one (lib/story-seed.js, batch 29 item 5).
9
10
  * GET /api/artefacts/lessons → { ok, lessons: [{ ws, product, scope, text, at }] } every product's Lessons, newest first, at most 20
10
11
  * (Settings › Claude, board AwG2)
11
12
  * GET /api/artefacts/map → { ok, artefacts, rows: [{ from, name, artefact, field, note }] } what every older shape became
@@ -99,7 +100,12 @@ async function handle(req, res, url, ctx) {
99
100
  let dir;
100
101
  try { dir = A.dirOf(w.root); } catch (e) { return send(409, { ok: false, error: String((e && e.message) || e) }); }
101
102
  const scopes = (A.parseScope('board:' + w.id) ? ['board:' + w.id] : []).concat('portfolio');
102
- return send(200, { ok: true, ws: w.id, story: A.storyOf(A.fold(A.readLines(A.file(dir))), scopes) });
103
+ const story = A.storyOf(A.fold(A.readLines(A.file(dir))), scopes);
104
+ // batch 29 item 5: no story yet, so PMOS writes the first one itself (lib/story-seed.js: one lean run, at most once a day per product)
105
+ let seeding = false;
106
+ const seeder = ctx.storySeed || require('./story-seed.js').forCtx(ctx);
107
+ if (!story && seeder) { try { const r = seeder.seed(w); seeding = !!r.started || r.why === 'running'; } catch { seeding = false; } }
108
+ return send(200, { ok: true, ws: w.id, story, ...(seeding ? { seeding: true } : {}) });
103
109
  }
104
110
  if (sub) return send(404, { ok: false, error: 'no such artefacts route' });
105
111
  const q = url.searchParams;
@@ -149,4 +149,4 @@ async function handle(req, res, url, ctx) {
149
149
  return send({ status: 200, body: { ok: true } });
150
150
  }
151
151
 
152
- module.exports = { prefixes: ['/api/autonomy'], handle, undoRef, failedOf, sayOf };
152
+ module.exports = { prefixes: ['/api/autonomy'], handle, undoRef, failedOf, sayOf, dirsOf };
@@ -172,7 +172,7 @@ module.exports = {
172
172
  const F = PR.read(dir), today = model.today || new Date().toISOString().slice(0, 10);
173
173
  for (const L of [model.rows, ...(model.stages || []).map((x) => x.rows)]) PR.decorate(L, F, items.filter((x) => x && x.kind !== 'Epic'), { today, links: () => approved, settle: TL.settle });
174
174
  }
175
- } catch { missing.push('Claude\'s proposals'); }
175
+ } catch { missing.push('PMOS\'s proposals'); }
176
176
  // Claude's suggestion to split an initiative or merge two (batch 11 item 14): made from the tasks and tickets on every read, never a timer;
177
177
  // the PM's ✕ hides one while its facts hold (the same group, the same partner). A failure here only leaves the suggestions out.
178
178
  try {
@@ -67,7 +67,7 @@ function heldOrCompare(ctx, w, what, body, { root, id, rec }) {
67
67
  const reading = { at: h.day, value: h.value, source: h.source || 'held reading', via: 'held', read_at: h.at };
68
68
  for (const k of ['num', 'den']) if (Number.isFinite(h[k])) reading[k] = h[k];
69
69
  if (h.period) reading.period = h.period;
70
- const r = records().addReading(root, rec.rid, reading, UI(), 'The PM filed a reading Claude held');
70
+ const r = records().addReading(root, rec.rid, reading, UI(), 'The PM filed a reading PMOS held');
71
71
  if (!r.ok) return bad(400, (r.reasons || []).join('; '));
72
72
  MR.append(dir, UI(), { kind: 'filed', rid: rec.rid, held: h.at }, now);
73
73
  if (h.ticket) { try { MD.append(dir, UI(), { kind: 'clear', scope: 'product', id: w.id, row: h.ticket }, now); } catch { /* the ticket stays a draft */ } }
@@ -159,12 +159,12 @@ async function handle(req, res, url, ctx) {
159
159
  }
160
160
  if (body.close_band !== undefined) { const b = Number(body.close_band); if (!Number.isFinite(b) || b < 0) return send(bad(400, 'close_band is a number, 0 or more')); set.close_band = b; }
161
161
  if (!Object.keys(set).length) return send(bad(400, 'Say the recipe, the rhythm or the close band.'));
162
- const out = edit(set, body.recipe === undefined && body.rhythm !== undefined ? 'How often Claude reads this goal' : 'How Claude reads this goal');
162
+ const out = edit(set, body.recipe === undefined && body.rhythm !== undefined ? 'How often PMOS reads this goal' : 'How PMOS reads this goal');
163
163
  if (out.status === 200 && set.recipe) out.body.rhythm = MR.rhythmOf(set.recipe);
164
164
  return send(out);
165
165
  }
166
166
  if (what === 'read' || what === 'test') {
167
- if (!ctx.metricReadRuns) return send(bad(503, 'Claude\'s runs are off on this server.'));
167
+ if (!ctx.metricReadRuns) return send(bad(503, 'PMOS\'s runs are off on this server.'));
168
168
  let rids;
169
169
  if (what === 'test') {
170
170
  rids = Array.isArray(body.rows) ? body.rows.filter((x) => typeof x === 'string').slice(0, 8) : [];
@@ -172,7 +172,7 @@ async function handle(req, res, url, ctx) {
172
172
  } else rids = rec ? [rec.rid] : id ? [] : liveRecords(ctx, w).filter((r) => r.recipe && r.recipe.connector).map((r) => r.rid);
173
173
  if (!rids.length) return send(bad(id ? 404 : 409, id ? 'There is no such goal.' : 'No goal has a way to be read yet.'));
174
174
  const r = ctx.metricReadRuns.start({ ws: w.id, rids, why: what === 'test' ? 'test' : 'press' });
175
- return send(r && r.ok ? { status: 200, body: { ok: true, run: r.run, rids: r.rids } } : bad(409, (r && r.error) || 'Claude could not start reading.'));
175
+ return send(r && r.ok ? { status: 200, body: { ok: true, run: r.run, rids: r.rids } } : bad(409, (r && r.error) || 'PMOS could not start reading.'));
176
176
  }
177
177
  if (what === 'file-held' || what === 'compare' || what === 'compare-pick') return send(heldOrCompare(ctx, w, what, body, { root, id, rec }));
178
178
  // csv: the fallback when no connector reads it
@@ -53,7 +53,7 @@ async function handle(req, res, url, ctx) {
53
53
  }
54
54
  if (!['verdict', 'verdict-all', 'undo', 'seen', 'looked'].includes(what)) return send(bad(404, 'no such impact route'));
55
55
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
56
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'Only you check your impact, from the page. Claude\'s run files items with pmos impact.'));
56
+ if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'Only you check your impact, from the page. PMOS\'s run files items with pmos impact.'));
57
57
  const rd = await ctx.readJson(req);
58
58
  if (!rd.ok) return send(bad(400, 'the body is not JSON'));
59
59
  const body = rd.body || {};
@@ -37,7 +37,7 @@ const movesIn = (m) => { const I = (m && m.insight) || {}; return [I.move].conca
37
37
  function write(ctx, w, mv, actor) {
38
38
  if (mv.kind === 'date') {
39
39
  let e;
40
- try { e = records().edit(recordsDirFor(ctx, w.id), 'kr-metrics', mv.goal, { by: mv.to }, UI(), 'Moved the target date Claude drafted on Intelligence'); } catch (x) { e = { ok: false, reasons: [String((x && x.message) || x).slice(0, 160)] }; }
40
+ try { e = records().edit(recordsDirFor(ctx, w.id), 'kr-metrics', mv.goal, { by: mv.to }, UI(), 'Moved the target date PMOS drafted on Intelligence'); } catch (x) { e = { ok: false, reasons: [String((x && x.message) || x).slice(0, 160)] }; }
41
41
  return e.ok ? { undo: { by: mv.from } } : { error: 'The date could not be moved: ' + (e.reasons || []).join('; ') };
42
42
  }
43
43
  if (mv.kind === 'anchor') {
@@ -171,9 +171,9 @@ const WRITES = {
171
171
  ctx.json(res, { ok: true, back, kept, ...viewNow(ctx, dir, dayOf(body)) });
172
172
  },
173
173
  '/api/loose-props/look': (ctx, res, body, g) => {
174
- if (!ctx.proposalRuns || !ctx.proposalRuns.startLoose) return fail(ctx, res, 503, 'Claude\'s runs are off on this server');
174
+ if (!ctx.proposalRuns || !ctx.proposalRuns.startLoose) return fail(ctx, res, 503, 'PMOS\'s runs are off on this server');
175
175
  const r = ctx.proposalRuns.startLoose({ why: 'check', press: true });
176
- if (!r || !r.ok) return fail(ctx, res, 409, (r && r.error) || 'Claude could not start looking');
176
+ if (!r || !r.ok) return fail(ctx, res, 409, (r && r.error) || 'PMOS could not start looking');
177
177
  ctx.json(res, { ok: true, started: r.run });
178
178
  },
179
179
  };
@@ -81,7 +81,7 @@ module.exports = {
81
81
  if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
82
82
  if (!ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'no runtime folder' }, 500); return true; }
83
83
  if (p === '/api/mentions/act') {
84
- if (store.AGENT_ACTS.has(b.act)) { ctx.json(res, { ok: false, error: b.act + ' is what Claude writes: pmos mention ' + (b.act === 'offer' ? 'watch' : b.act) }, 400); return true; }
84
+ if (store.AGENT_ACTS.has(b.act)) { ctx.json(res, { ok: false, error: b.act + ' is what PMOS writes: pmos mention ' + (b.act === 'offer' ? 'watch' : b.act) }, 400); return true; }
85
85
  const r = store.mark(ctx.runtimeDir, b, new Date(), 'pm');
86
86
  ctx.json(res, r, r.ok ? 200 : 400);
87
87
  return true;
@@ -108,14 +108,14 @@ async function handle(req, res, url, ctx) {
108
108
  const S = () => MD.read(dir).scopes.get(MD.keyOf(scope, id));
109
109
 
110
110
  if (what === 'start') {
111
- if (!ctx.metricDraftRuns) return send(bad(503, 'Claude\'s runs are off on this server.'));
111
+ if (!ctx.metricDraftRuns) return send(bad(503, 'PMOS\'s runs are off on this server.'));
112
112
  const r = ctx.metricDraftRuns.start({ ws: w.id, scope, id, why: 'press' });
113
- if (!r || !r.ok) return send(bad(409, (r && r.error) || 'Claude could not start drafting.'));
113
+ if (!r || !r.ok) return send(bad(409, (r && r.error) || 'PMOS could not start drafting.'));
114
114
  return send({ status: 200, body: { ok: true, run: r.run, ...(r.already ? { already: true } : {}) } });
115
115
  }
116
116
  if (what === 'stop') {
117
117
  const s = S();
118
- if (!s || !s.run || s.run.ended) return send(bad(409, 'Claude is not drafting now.'));
118
+ if (!s || !s.run || s.run.ended) return send(bad(409, 'PMOS is not drafting now.'));
119
119
  try { if (ctx.metricDraftRuns) ctx.metricDraftRuns.stop(s.run.run); } catch { /* the end line below says it stopped */ }
120
120
  MD.append(dir, g.actor, { kind: 'end', scope, id, run: s.run.run, ok: true, stopped: true }, at());
121
121
  return send({ status: 200, body: { ok: true } });
@@ -143,19 +143,19 @@ async function handle(req, res, url, ctx) {
143
143
  if (k === 'outcome') Object.assign(kf.fields, { kr: row.goal, was: row.old || '' });
144
144
  if (row.recipe) kf.fields.recipe = row.recipe;
145
145
  kf.fields.draft = row.id;
146
- let r; try { r = records().add(root, 'kr-metrics', kf.fields, UI(), k === 'outcome' ? 'Kept the outcome Claude drafted for a project-shaped goal' : 'Kept next quarter\'s goal Claude drafted'); } catch (e) { return { error: 'The record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
146
+ let r; try { r = records().add(root, 'kr-metrics', kf.fields, UI(), k === 'outcome' ? 'Kept the outcome PMOS drafted for a project-shaped goal' : 'Kept next quarter\'s goal PMOS drafted'); } catch (e) { return { error: 'The record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
147
147
  if (!r.ok) return { error: r.reasons.join('; ') };
148
148
  // the test read (lib/metric-reads.js), else the reading it was drafted from, is the first reading, with its source
149
149
  let test = null; try { const x = require('./metric-reads.js').read(dir).rids.get(row.id); test = x && x.test && x.test.ok && !x.test.held ? x.test : null; } catch { test = null; }
150
150
  const first = test ? { at: test.day, value: test.value, source: test.source, via: 'run', read_at: test.at } : kf.reading;
151
- if (first) { try { records().addReading(root, r.rid, first, UI(), test ? 'The test read before you kept it' : 'The reading Claude drafted it from'); } catch { /* the record stands */ } }
151
+ if (first) { try { records().addReading(root, r.rid, first, UI(), test ? 'The test read before you kept it' : 'The reading PMOS drafted it from'); } catch { /* the record stands */ } }
152
152
  return done({ rid: r.rid });
153
153
  }
154
154
  if (k === 'connect') return done({ open: 'settings:connectors', connector: row.connector });
155
155
  const editKeep = (fields, why) => { if (!cur(row.goal)) return { error: 'The goal this fix repairs is not recorded any more.' }; const before = beforeOf(row.goal, Object.keys(fields)); const e = editRec(row.goal, fields, why); return e ? { error: e } : done({ rid: row.goal, before }); };
156
- if (k === 'recipe') return editKeep({ recipe: row.recipe }, 'Kept how Claude reads this goal');
156
+ if (k === 'recipe') return editKeep({ recipe: row.recipe }, 'Kept how PMOS reads this goal');
157
157
  if (k === 'carry') return editKeep({ by: row.by, ...(typeof row.target === 'number' ? { target: row.target } : {}) }, 'Carried on to next quarter');
158
- if (k === 'owner') return editKeep({ owner: row.owner.name, owner_from: row.owner.from }, 'Kept the owner Claude proposed');
158
+ if (k === 'owner') return editKeep({ owner: row.owner.name, owner_from: row.owner.from }, 'Kept the owner PMOS proposed');
159
159
  if (k === 'chase') { const o = row.channel === 'jira-write' ? toOutbox('jira-write', row.epic, 'About ' + row.goal, row.body) : toOutbox('team-note', row.to, 'A note on ' + row.goal, row.body); return o.error ? o : done({ rid: row.goal, outbox: o.id }); }
160
160
  if (k === 'ticket') { const o = toOutbox('jira-write', (row.ticket && row.ticket.project) || null, row.ticket.title, row.ticket.text); return o.error ? o : done({ rid: row.goal, outbox: o.id }); }
161
161
  return { error: 'This draft cannot be kept.' };
@@ -165,12 +165,12 @@ async function handle(req, res, url, ctx) {
165
165
  const k = MD.keepFields(scope, id, row, { today });
166
166
  if (k.error) return { error: k.error };
167
167
  let r;
168
- try { r = records().add(root, 'kr-metrics', k.fields, UI(), 'Kept a metric Claude drafted'); } catch (e) { return { error: 'The record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
168
+ try { r = records().add(root, 'kr-metrics', k.fields, UI(), 'Kept a metric PMOS drafted'); } catch (e) { return { error: 'The record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
169
169
  if (!r.ok) return { error: r.reasons.join('; ') };
170
170
  // batch 18 item 11: a good live read (not held) is the first reading, with its counts; else the reading it was drafted from
171
171
  let live = null; try { const x = require('./metric-reads.js').read(dir).rids.get(row.id); live = x && x.test && x.test.ok && !x.test.held ? x.test : null; } catch { live = null; }
172
172
  const first = live ? { at: live.day, value: live.value, source: live.source, via: 'run', read_at: live.at, ...(Number.isFinite(live.num) ? { num: live.num } : {}), ...(Number.isFinite(live.den) ? { den: live.den } : {}), ...(live.period ? { period: live.period } : {}) } : k.reading;
173
- if (first) { try { records().addReading(root, r.rid, first, UI(), live ? 'The live read before you kept it' : 'The reading Claude drafted it from'); } catch { /* the record stands; the next reading fills it */ } }
173
+ if (first) { try { records().addReading(root, r.rid, first, UI(), live ? 'The live read before you kept it' : 'The reading PMOS drafted it from'); } catch { /* the record stands; the next reading fills it */ } }
174
174
  MD.append(dir, g.actor, { kind: 'keep', scope, id, row: row.id, rid: r.rid }, at());
175
175
  return { rid: r.rid };
176
176
  };
@@ -100,13 +100,13 @@ function undoCore(ctx, p, g, id) {
100
100
  for (const w of k.wrote.slice().reverse()) {
101
101
  const xi = w.task ? f.byUid.get(w.task) : null, t = w.task ? f.T.get(w.task) : null;
102
102
  let r = null;
103
- if (w.op === 'add') { if (xi && (xi.status || 'To do') === 'To do') r = RB.taskDelete(ctx, { ws: p.w.id, board: p.board.id, task: w.task, why: 'Undo: Claude ✦ added it' }, g); }
103
+ if (w.op === 'add') { if (xi && (xi.status || 'To do') === 'To do') r = RB.taskDelete(ctx, { ws: p.w.id, board: p.board.id, task: w.task, why: 'Undo: PMOS ✦ added it' }, g); }
104
104
  // a task changed since keeps its change: Undo never overwrites a later edit
105
105
  else if (w.op === 'dates') { if (xi && (xi.end || '') === (w.to.due || xi.end || '')) r = W.dates(ctx, p, g, w.task, xi, { start: w.from.start, due: w.from.due }); }
106
106
  else if (w.op === 'state') { if (t && t.status === w.to) r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: w.task, state: w.from || 'To do', why: 'Undo' }, g); }
107
107
  else if (w.op === 'rename') { if (t && t.title === w.to) r = RB.writeAs(ctx, '/api/boards/tasks/rename', { ws: p.w.id, board: p.board.id, task: w.task, title: w.from }, g); }
108
108
  else if (w.op === 'notes') { if (xi && (xi.notes || '') === w.to) r = RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: w.task, notes: w.from || '' }, g); }
109
- else if (w.op === 'stage') { const row = rowOf(f, k.ini); if (row && row.stage === w.to && w.from) r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: k.ini, to: w.from, why: 'Undo: Claude ✦ moved it' }, g); }
109
+ else if (w.op === 'stage') { const row = rowOf(f, k.ini); if (row && row.stage === w.to && w.from) r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: k.ini, to: w.from, why: 'Undo: PMOS ✦ moved it' }, g); }
110
110
  else if (w.op === 'epics') r = RB.writeAs(ctx, '/api/boards/ini-epics', { ws: p.w.id, board: p.board.id, id: k.ini, epics: w.from }, g);
111
111
  else if (w.op === 'unlink') { TL.append(dir, g.actor, { kind: 'link', board: p.board.id, ini: k.ini, from: w.from, to: w.to, type: w.link.type, lag: w.link.lag, source: w.link.source }); back++; continue; }
112
112
  else if (w.op === 'link') { TL.append(dir, g.actor, { kind: 'unlink', from: w.from, to: w.to }); back++; continue; }
@@ -154,7 +154,7 @@ function autoKeep(ctx, w, { modeOf = () => 'auto', now } = {}) {
154
154
  if (!d.apply) { out.held++; continue; }
155
155
  try {
156
156
  const r = keepCore(ctx, p, g, f, ini, [x], {}, { auto: true, group: x.group });
157
- A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls, ini, why: x.title && x.why && x.why !== x.title ? x.why : '' }, { now });
157
+ A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls, ini, why: x.title && x.why && x.why !== x.title ? x.why : '' }, { now, settingsDir: ctx.runtimeDir || null });
158
158
  out.applied.push({ ini, batch: r.batch, group: x.group, title: x.title || x.why || '' });
159
159
  } catch { out.held++; }
160
160
  }
@@ -172,7 +172,7 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
172
172
  if (x.type === 'stage') {
173
173
  const row = rowOf(f, ini), stage = x.data && x.data.stage;
174
174
  if (stage && row && row.stage !== stage) {
175
- const r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: ini, to: stage, why: 'Claude found it there: ' + why }, g);
175
+ const r = RB.move(ctx, { ws: p.w.id, board: p.board.id, id: ini, to: stage, why: 'PMOS found it there: ' + why }, g);
176
176
  if (W.ok(r)) add({ op: 'stage', from: row.stage || '', to: stage });
177
177
  }
178
178
  for (const it of items) add({ op: 'ran', stage: it.stage, from: it.start || null, to: it.due || null, source: it.source || source });
@@ -241,7 +241,7 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
241
241
  // the idle lab (lib/idle-lab.js): ✓ keeps it as the initiative's own document. A prototype is each specimen of round 1, or the new
242
242
  // round; a scan finding is evidence. The specimen stays in the runtime folder; the document links it (GET /api/lab/specimen)
243
243
  const LAB = require('./idle-lab.js'), d = x.data || {}, name = (sp) => 'Prototype ' + sp.key + ' · ' + sp.title;
244
- const docOf = (title, ref, kind) => add({ op: 'doc', id: 'fd-' + PR.hash(ini + '|' + x.id + '|' + (ref || title)), title: String(title).slice(0, 140), source: 'Claude, while you were away', at: x.at || '', ref, kind, claude: true });
244
+ const docOf = (title, ref, kind) => add({ op: 'doc', id: 'fd-' + PR.hash(ini + '|' + x.id + '|' + (ref || title)), title: String(title).slice(0, 140), source: 'PMOS, while you were away', at: x.at || '', ref, kind, claude: true });
245
245
  if (x.group === 'prototyped') for (const sp of d.specimens || []) docOf(name(sp), LAB.specimenUrl(sp.file), 'prototype');
246
246
  else if (x.group === 'improved') docOf('Prototype ' + (d.base || '') + ' · round ' + d.round + ': ' + (d.changed || ''), LAB.specimenUrl(d.file), 'prototype');
247
247
  else docOf(x.why, ((x.sources || [])[0] || {}).ref || '', 'evidence');
@@ -261,7 +261,7 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
261
261
  for (const it of items) {
262
262
  const t = f.T.get(it.task); if (!t || t.closed) continue;
263
263
  if (t.jira) { outbox.push({ task: it.task, text: 'It looks done: ' + why + ' Could you close ' + it.task + '?' }); continue; }
264
- const r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: it.task, state: 'Done', why: 'Claude ✦: ' + why }, g);
264
+ const r = RB.taskState(ctx, { ws: p.w.id, board: p.board.id, task: it.task, state: 'Done', why: 'PMOS ✦: ' + why }, g);
265
265
  if (W.ok(r)) add({ op: 'state', task: it.task, title: t.title, from: t.status, to: 'Done' });
266
266
  }
267
267
  } else if (x.group === 'names') {
@@ -388,7 +388,7 @@ const WRITES = {
388
388
  const ini = String(body.initiative || '');
389
389
  if (!ini) return fail(ctx, res, 400, 'initiative is required');
390
390
  const dir = dirOf(ctx, p.w), L = PR.read(dir).looks.get(ini);
391
- if (!L || L.ended) return fail(ctx, res, 409, 'Claude is not looking now');
391
+ if (!L || L.ended) return fail(ctx, res, 409, 'PMOS is not looking now');
392
392
  try { if (ctx.proposalRuns) ctx.proposalRuns.stop(L.run); } catch { /* the end line below says it stopped */ }
393
393
  PR.append(dir, g.actor, { kind: 'end', ini, run: L.run, ok: true, stopped: true });
394
394
  ctx.json(res, { ok: true });
@@ -396,9 +396,9 @@ const WRITES = {
396
396
  '/api/proposals/look': (ctx, res, body, g, p) => {
397
397
  const ini = String(body.initiative || ''), why = body.why === 'check' ? 'check' : 'populate';
398
398
  if (!ini) return fail(ctx, res, 400, 'initiative is required');
399
- if (!ctx.proposalRuns) return fail(ctx, res, 503, 'Claude\'s runs are off on this server');
399
+ if (!ctx.proposalRuns) return fail(ctx, res, 503, 'PMOS\'s runs are off on this server');
400
400
  const r = ctx.proposalRuns.start({ ws: p.w.id, board: p.board.id, ini, why });
401
- if (!r || !r.ok) return fail(ctx, res, 409, (r && r.error) || 'Claude could not start looking');
401
+ if (!r || !r.ok) return fail(ctx, res, 409, (r && r.error) || 'PMOS could not start looking');
402
402
  ctx.json(res, { ok: true, started: r.run });
403
403
  },
404
404
  };
@@ -94,7 +94,7 @@ function needsOf(ctx, w, boardId, ids) {
94
94
  const ps = v.groups.flatMap((g) => g.props || []).sort((a, b) => (a.group === 'dates' ? -1 : 0) - (b.group === 'dates' ? -1 : 0));
95
95
  const p = ps[0]; if (!p) continue;
96
96
  const first = (p.items || [])[0] || null;
97
- out.push({ id: p.id, q: String(p.title || (first && first.title) || 'A change Claude proposes').slice(0, 160), sub: String(p.why || '').slice(0, 200), pick: pickOf(first), from: ini, ini, board: boardId, group: p.group,
97
+ out.push({ id: p.id, q: String(p.title || (first && first.title) || 'A change PMOS proposes').slice(0, 160), sub: String(p.why || '').slice(0, 200), pick: pickOf(first), from: ini, ini, board: boardId, group: p.group,
98
98
  keep: { ids: [p.id] }, drop: { sig: p.sig } });
99
99
  }
100
100
  return out.sort((a, b) => (a.group === 'dates' ? -1 : 0) - (b.group === 'dates' ? -1 : 0));
@@ -13,7 +13,7 @@ const fs = require('fs');
13
13
  const os = require('os');
14
14
  const path = require('path');
15
15
 
16
- const PMOS = [{ cmd: '/goal', name: 'Give Claude a goal', say: 'It asks a few questions to make the goal SMART, then works on it after you press Start.' }];
16
+ const PMOS = [{ cmd: '/goal', name: 'Give PMOS a goal', say: 'It asks a few questions to make the goal SMART, then works on it after you press Start.' }];
17
17
  const CLAUDE = [
18
18
  ['/compact', 'Compact the conversation', 'Claude Code summarises the conversation so far to free room.'],
19
19
  ['/clear', 'Clear the conversation', 'Claude Code starts again with an empty context in the same session.'],
@@ -35,7 +35,7 @@ const CAUSES = Object.freeze({
35
35
  'claude-signin': { why: 'Claude is signed out on this computer', user: true, after: 2 },
36
36
  'connector-missing': { why: 'its connector is not connected', user: true, after: 1 },
37
37
  'sign-in': { why: 'its sign-in has expired', user: true, after: 2 },
38
- 'rate-limit': { why: 'it asked Claude to slow down', user: false },
38
+ 'rate-limit': { why: 'it asked PMOS to slow down', user: false },
39
39
  network: { why: 'the network or the proxy did not answer', user: false },
40
40
  'connector-failed': { why: 'its connector did not start', user: false },
41
41
  interrupted: { why: 'the read was stopped before it ended', user: false },
@@ -116,13 +116,13 @@ function view(h, name = 'It') {
116
116
  if (!h) return null;
117
117
  const c = h.cause ? CAUSES[h.cause] : null;
118
118
  const n = (h.attempts || []).length;
119
- const tried = n ? `Claude read it again ${n === 1 ? 'once' : n + ' times'} since ${hm(h.attempts[0].at)}${c ? `, and ${c.why}` : ''}.` : '';
119
+ const tried = n ? `PMOS read it again ${n === 1 ? 'once' : n + ' times'} since ${hm(h.attempts[0].at)}${c ? `, and ${c.why}` : ''}.` : '';
120
120
  let action = null;
121
121
  if (h.state === 'needs-you') {
122
122
  if (h.cause === 'claude-signin') action = { label: 'Sign in to Claude', how: require('./claude-signin.js').how(), sec: 'claude' };
123
123
  else if (h.cause === 'connector-missing') action = { label: 'Connect ' + name, how: 'Turn on its connector in your Claude connectors.', href: CONNECTORS };
124
124
  else if (h.cause === 'sign-in') action = { label: 'Reconnect ' + name, how: 'Sign in to its connector again in your Claude connectors.', href: CONNECTORS };
125
- else action = { label: 'Read ' + name + ' again', how: h.cause === 'manual' ? 'You chose to read it only when you press ↻.' : 'Claude stopped after ' + n + ' tries.', read: true };
125
+ else action = { label: 'Read ' + name + ' again', how: h.cause === 'manual' ? 'You chose to read it only when you press ↻.' : 'PMOS stopped after ' + n + ' tries.', read: true };
126
126
  }
127
127
  return { state: h.state, cause: h.cause || null, why: c ? c.why : '', tried, action, attempts: n, next_at: h.next_at ? new Date(h.next_at).toISOString() : null,
128
128
  ...(h.repaired_at ? { repaired_at: new Date(h.repaired_at).toISOString() } : {}) };
@@ -581,7 +581,28 @@ function stateHealth({ migration, fellBack = [], rootError = null } = {}) {
581
581
  });
582
582
  }
583
583
 
584
- module.exports = { APP, NOTE_NAME, NOT_STATE, SETTLED_ACTIONS,
584
+ /* ── PMOS-SELF'S FILE-MODE RECORDS WHEN THE CHECKOUT HAS NO pmos/state/ ───────────────────────
585
+ *
586
+ * A PMOS checkout run from source (a cloud session, CI, a dev clone) with no pmos/state/ used to
587
+ * write its file-mode records (tasks.jsonl, proposals.jsonl, driver.jsonl, needs.json) into
588
+ * workspace/state/ — inside the application directory, and two of those files were tracked, so
589
+ * every cloud or CI run that touched them committed machine events with the next PR.
590
+ *
591
+ * So the fallback goes to the per-user root, like the runtime state: <root>/self-records. One
592
+ * exception keeps a running machine from forking its records: when workspace/state/ already holds
593
+ * a record (any *.jsonl, or needs.json), that copy stays in use. A fresh clone holds none, so it
594
+ * never writes into the checkout again. driver.js, today.js and server.js all ask here, so the
595
+ * reader and the writer always agree. */
596
+ const SELF_RECORDS = 'self-records';
597
+ function holdsRecords(dir) {
598
+ try { return fs.readdirSync(dir).some((n) => n.endsWith('.jsonl') || n === 'needs.json'); } catch { return false; }
599
+ }
600
+ function selfRecordsDir({ legacy = null, env = process.env, platform = process.platform, home = os.homedir() } = {}) {
601
+ if (legacy && holdsRecords(legacy)) return legacy;
602
+ return path.join(defaultRoot({ env, platform, home }), SELF_RECORDS);
603
+ }
604
+
605
+ module.exports = { SELF_RECORDS, selfRecordsDir, holdsRecords, APP, NOTE_NAME, NOT_STATE, SETTLED_ACTIONS,
585
606
  WHY_REFUSED, whyRefused, WHY_UNREADABLE, whyUnreadable, isSettled,
586
607
  overrideDir, defaultRoot, readState, presence, migrateLegacy, resolveStateRoot, resolveStore,
587
608
  stateHealth };