create-pmos 0.414.0 → 0.416.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 (86) hide show
  1. package/package.json +25 -25
  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/bin/pmos.js +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +3 -3
  9. package/workspace/briefing-premium-board-test.js +72 -43
  10. package/workspace/briefing-premium-doc-edit-test.js +2 -2
  11. package/workspace/briefing-premium-initiative-test.js +19 -22
  12. package/workspace/briefing-premium-insights-test.js +28 -17
  13. package/workspace/changelog.json +24 -0
  14. package/workspace/core-docs-workflow-test.js +1 -1
  15. package/workspace/guide/workflows.md +6 -2
  16. package/workspace/ini-workflow-test.js +11 -11
  17. package/workspace/lib/board-premium.js +13 -0
  18. package/workspace/lib/board-trail.js +6 -1
  19. package/workspace/lib/engine/boards.js +12 -4
  20. package/workspace/lib/goal-chat.js +46 -15
  21. package/workspace/lib/initiative-chat.js +7 -5
  22. package/workspace/lib/initiative-premium.js +4 -2
  23. package/workspace/lib/insights-premium.js +9 -1
  24. package/workspace/lib/item-cli.js +2 -1
  25. package/workspace/lib/pmos-verbs.js +1 -1
  26. package/workspace/lib/route-modules.js +1 -0
  27. package/workspace/lib/routes-boards.js +149 -18
  28. package/workspace/lib/routes-briefing-premium.js +14 -1
  29. package/workspace/lib/routes-live.js +53 -0
  30. package/workspace/lib/task-cli.js +137 -25
  31. package/workspace/lib/task-items.js +88 -0
  32. package/workspace/lib/workflow-cli.js +1 -1
  33. package/workspace/milestone-suggest-test.js +2 -1
  34. package/workspace/package-lock.json +2 -2
  35. package/workspace/package.json +1 -1
  36. package/workspace/premium-board-actions-test.js +3 -3
  37. package/workspace/premium-chat-report-tab-test.js +13 -5
  38. package/workspace/premium-core-doc-issue-test.js +1 -1
  39. package/workspace/premium-report-read-test.js +66 -51
  40. package/workspace/premium-vw-backlog-test.js +3 -3
  41. package/workspace/premium-vw-doc-test.js +3 -3
  42. package/workspace/premium-vw-item-test.js +4 -4
  43. package/workspace/premium-vw-jira-test.js +14 -13
  44. package/workspace/premium-vw-slides-test.js +7 -5
  45. package/workspace/program-panel-test.js +1 -1
  46. package/workspace/public/pm/bd-ini-panel.js +68 -210
  47. package/workspace/public/pm/cozy-insights.css +15 -0
  48. package/workspace/public/pm/cozy-live-pill.css +48 -0
  49. package/workspace/public/pm/cozy-live-pill.js +141 -0
  50. package/workspace/public/pm/cozy-viewer.js +4 -3
  51. package/workspace/public/pm/cozy-vw-rp.css +48 -0
  52. package/workspace/public/pm/home-app.js +45 -8
  53. package/workspace/public/pm/home-chat.js +5 -2
  54. package/workspace/public/pm/home-ini.js +57 -22
  55. package/workspace/public/pm/home-stage-card.js +3 -2
  56. package/workspace/public/pm/home-task.js +16 -5
  57. package/workspace/public/pm/ini-view-model.js +277 -0
  58. package/workspace/public/pm/ini-view.css +122 -0
  59. package/workspace/public/pm/ini-view.js +180 -0
  60. package/workspace/public/pm/live-model.js +104 -0
  61. package/workspace/public/pm/ov-view.css +44 -0
  62. package/workspace/public/pm/premium-board.js +23 -15
  63. package/workspace/public/pm/premium-initiative-head.js +12 -2
  64. package/workspace/public/pm/premium-insights.js +61 -35
  65. package/workspace/public/pm/premium-report-read.js +74 -50
  66. package/workspace/public/pm/premium-report-tab.js +36 -15
  67. package/workspace/public/pm/premium-shell.js +1 -1
  68. package/workspace/public/pm/premium-vw-item-model.js +6 -3
  69. package/workspace/public/pm/premium-vw-item.js +25 -6
  70. package/workspace/public/pm/premium-vw-jira.js +17 -15
  71. package/workspace/public/pm/rp-parts.js +75 -12
  72. package/workspace/public/pm/task-card.css +24 -49
  73. package/workspace/public/pm/task-card.js +90 -64
  74. package/workspace/public/pm/tk-view.css +21 -0
  75. package/workspace/public/pm/tk-view.js +216 -0
  76. package/workspace/public/pm/wf-page.js +2 -0
  77. package/workspace/server.js +24 -1
  78. package/workspace/stage-card-test.js +49 -41
  79. package/workspace/task-card-test.js +83 -38
  80. package/workspace/test-files.json +3 -1
  81. package/workspace/test-lists/bd-ini-panel.json +3 -3
  82. package/workspace/test-lists/one-task-list.json +5 -0
  83. package/workspace/tk-tasks-test.js +3 -3
  84. package/workspace/public/pm/bd-ini-model.js +0 -81
  85. package/workspace/public/pm/cozy-rec-pill.css +0 -12
  86. package/workspace/public/pm/cozy-rec-pill.js +0 -46
@@ -1,33 +1,51 @@
1
1
  'use strict';
2
- /* task-cli.js — `pmos task …`: an initiative's Board tasks from a terminal, so an agent the PM asks can close or move them (Wawan,
3
- * 2026-10-25: "I made instruction to move, but agent still ask to move myself from Board").
2
+ /* task-cli.js — `pmos task …`: an initiative's tasks from a terminal, so an agent the PM asks can add, close or move them (Wawan,
3
+ * 2026-10-25: "I made instruction to move, but agent still ask to move myself from Board"; feedback batch 5: one kind of task).
4
4
  *
5
+ * pmos task add <initiative> "<title>" [--stage <stage>] [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]
6
+ * a new task, by the same function as the page's Add a task (lib/routes-boards.js taskAdd, POST /api/boards/tasks/add)
7
+ * pmos task set <task> [<task> …] [--stage <stage>|none] [--due YYYY-MM-DD|none] [--start …|none] [--owner <who>] [--notes <text>]
8
+ * place tasks under a workflow stage of their initiative, or change their dates, owner or notes, by the same function as the Viewer's
9
+ * edit (lib/routes-boards.js taskEdit, POST /api/boards/tasks/edit). The Tasks section groups tasks by stage (feedback batch 6:
10
+ * an agent asked to group tasks by stage had no command for it).
5
11
  * pmos task list <initiative> [--all] its open tasks (To do, In progress); --all adds Done, Won't do and Archived
6
12
  * pmos task state <task> [<task> …] --to <state> [--why <text>]
7
- * set each task's state: To do, In progress, Done, Won't do or Archived. One task-update line per task in boards.jsonl, written by
8
- * the same function as the Board's press (lib/routes-boards.js taskState, POST /api/boards/tasks/state), with the agent as the writer.
13
+ * set each task's state: To do, In progress, Done, Won't do or Archived, by the same function as the Board's press
14
+ * (lib/routes-boards.js taskState, POST /api/boards/tasks/state), with the agent as the writer.
9
15
  *
10
- * A Board task is not a breakdown item (`pmos item`) and has no workflow stage: its only stage is its state. The initiative's workflow
11
- * stage is `pmos workflow of|move`. Who wrote a line is the call path (lib/actor.js), never an argument. Exit codes: 0 done, 1 refused,
12
- * 2 usage. Nothing is sent. */
16
+ * ONE KIND OF TASK. The list holds the initiative's Board tasks, its breakdown items (the plan-items ledger, lib/task-items.js) and its
17
+ * current stage's To finish entries, which become tasks the first time they are read (routes-boards stageTasks). `state` closes any of
18
+ * them. A task's stage (--stage) is its place in the breakdown, never its state, and it never moves the initiative: the initiative's
19
+ * workflow stage is `pmos workflow of|move`. Who wrote a
20
+ * line is the call path (lib/actor.js), never an argument. Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
13
21
  const path = require('path');
14
22
  const { execFileSync } = require('child_process');
15
23
  const actorLib = require('./actor.js');
16
24
  const driver = require('./driver.js');
17
25
  const { repoScript } = require('./repo-script.js');
18
26
  const B = require(repoScript('boards.js'));
27
+ const TI = require('./task-items.js');
28
+ const rowsLib = require('./initiative-rows.js');
19
29
 
20
- const COMMANDS = { task: ['list', 'state'] };
30
+ const COMMANDS = { task: ['add', 'list', 'state', 'set'] };
21
31
  const USAGE = [
22
- 'usage: pmos task list|state — an initiative\'s Board tasks',
32
+ 'usage: pmos task add|list|state|set — an initiative\'s tasks, the ones the PM sees in its Tasks section',
33
+ ' pmos task add <initiative> "<title>" [--stage <stage>] [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]',
34
+ ' Add a task. Every new task goes here; pmos item add is the older breakdown record.',
35
+ ' pmos task set <task> [<task> …] [--stage <stage>|none] [--due YYYY-MM-DD|none] [--start YYYY-MM-DD|none] [--owner <who>] [--notes <text>]',
36
+ ' Group tasks under a stage of the initiative\'s workflow (key or name; none takes it out), or change dates, owner or notes.',
23
37
  ' pmos task list <initiative> [--all] its open tasks; --all adds Done, Won\'t do and Archived',
24
38
  ' pmos task state <task> [<task> …] --to <state> [--why <text>]',
25
- ' Set each task\'s state when the PM asks: To do, In progress, Done, Won\'t do or Archived. The Board shows it at once.',
26
- ' A Board task has no workflow stage: its only stage is its state. Move the initiative with pmos workflow move.',
39
+ ' Set each task\'s state when the PM asks: To do, In progress, Done, Won\'t do or Archived. The page shows it at once.',
40
+ ' Give --why with Done: it is the evidence the PM reads.',
41
+ ' There is one kind of task: Board tasks, breakdown items and the current stage\'s To finish tasks all list and close here.',
42
+ ' The Tasks section groups tasks by the workflow\'s stages: --stage places a task there. It never changes the task\'s state or',
43
+ ' moves the initiative. Move the initiative with pmos workflow move.',
27
44
  ' every command: [--json] [--root <dir>]. Nothing is sent.',
28
45
  ];
29
46
  const BOOL = new Set(['json', 'help', 'all']);
30
- const VALUE = new Set(['to', 'why', 'root']);
47
+ const VALUE = new Set(['to', 'why', 'root', 'due', 'start', 'owner', 'notes', 'stage']);
48
+ const ONLY = { add: ['due', 'start', 'owner', 'notes', 'stage'], list: ['all'], state: ['to', 'why'], set: ['due', 'start', 'owner', 'notes', 'stage'] };
31
49
  const OPEN = new Set(['To do', 'In progress']);
32
50
  /** The PM's words for a state: any case, with or without the apostrophe or the space. */
33
51
  function stateOf(s) {
@@ -35,6 +53,15 @@ function stateOf(s) {
35
53
  return { todo: 'To do', inprogress: 'In progress', doing: 'In progress', done: 'Done', wontdo: "Won't do", archived: 'Archived', archive: 'Archived' }[k] || null;
36
54
  }
37
55
 
56
+ /** A stage the PM or agent names (its key or its name, any case) → its key in the initiative's workflow, '' for none, or null. */
57
+ function stageKey(stages, s) {
58
+ const k = String(s || '').trim().toLowerCase();
59
+ if (k === 'none' || k === '-') return '';
60
+ const n = (x) => String(x || '').toLowerCase().replace(/[^a-z0-9]/g, '');
61
+ const hit = (stages || []).find((x) => String(x.key).toLowerCase() === k || n(x.name) === n(k) || n(x.key) === n(k));
62
+ return hit ? hit.key : null;
63
+ }
64
+
38
65
  function parse(argv) {
39
66
  const pos = []; const flags = {};
40
67
  for (let i = 0; i < argv.length; i++) {
@@ -60,7 +87,13 @@ function boardsCtx(root, stateDir) {
60
87
  const w = { id: driver.wsIdOf(root), name: path.basename(root), root };
61
88
  return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => stateDir, selfRoot: path.resolve(__dirname, '..', '..') } };
62
89
  }
63
- const line = (t) => `${t.id} · ${t.state} · ${t.title}${t.kind === 'Epic' ? ' (epic)' : ''}${t.due ? ' · due ' + t.due : ''}`;
90
+ const line = (t) => `${t.id} · ${t.state} · ${t.title}${t.kind === 'Epic' ? ' (epic)' : ''}${t.stage ? ' · under ' + t.stage : ''}${t.due ? ' · due ' + t.due : ''}`;
91
+ /** The workflow row of an initiative, deriving the rows when they are still being read. */
92
+ function rowOf(boards, ctx, w, id) {
93
+ let r = boards.initiativeWorkflow(ctx, w, id);
94
+ if (r.pending) { try { rowsLib.deriveNow(w.root); } catch { /* answered below */ } r = boards.initiativeWorkflow(ctx, w, id); }
95
+ return r;
96
+ }
64
97
 
65
98
  async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isTTY, env } = {}) {
66
99
  const args = argv[0] === 'task' ? argv.slice(1) : argv.slice();
@@ -69,40 +102,119 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
69
102
  const json = !!flags.json;
70
103
  if (!verb || verb === 'help' || verb === '--help' || verb === '-h' || flags.help) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
71
104
  if (!COMMANDS.task.includes(verb)) { say(`unknown task command "${verb}" — one of ${COMMANDS.task.join(', ')}`); return 2; }
105
+ if (verb === 'add' && pos.length > 2) { say('usage: pmos task add <initiative> "<title>" [--stage <stage>] [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]'); return 2; }
72
106
  if ('by' in flags || 'via' in flags) { say(`attribution is set from the call path; --${'by' in flags ? 'by' : 'via'} is not accepted`); return 2; }
73
107
  for (const k of Object.keys(flags)) {
74
108
  if (!BOOL.has(k) && !VALUE.has(k)) { say(`unknown option --${k}`); return 2; }
75
109
  if (VALUE.has(k) && flags[k] === '') { say(`--${k} needs a value`); return 2; }
76
110
  }
77
111
  const fail = (error, code = 1) => { if (json) say(JSON.stringify({ ok: false, error })); else say(`✗ ${error}`); return code; };
112
+ for (const k of Object.keys(flags)) if (VALUE.has(k) && k !== 'root' && !ONLY[verb].includes(k)) return fail(`--${k} is not an option of ${verb}`, 2);
113
+ if (flags.all && verb !== 'list') return fail(`--all is not an option of ${verb}`, 2);
78
114
  const root = flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd);
79
- const stateDir = driver.stateDirOf(root, { create: verb === 'state' });
115
+ const stateDir = driver.stateDirOf(root, { create: verb !== 'list' });
80
116
  if (!stateDir) return fail('this repository has no PMOS state folder (pmos/state, state or .pmos)');
81
117
  const boards = require('./routes-boards.js');
82
118
  const { w, ctx } = boardsCtx(root, stateDir);
83
119
 
120
+ const cli = { isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env };
121
+ const g = { ok: true, actor: actorLib.fromCli(cli), cli };
122
+ /** Every task of an initiative: its Board tasks (on any board of this workspace) and its breakdown items. */
123
+ const tasksOf = (id) => {
124
+ const r = rowOf(boards, ctx, w, id);
125
+ const board = r.ok ? r.board.id : null;
126
+ const F = boards.foldOf(ctx, w), S = F.sections || new Map();
127
+ const stageOf = (tid, from) => (S.has(tid) ? S.get(tid) : (from && from.stage) || ''); // the group the Tasks section shows it under
128
+ const own = [...(F.tasks || new Map()).values()].filter((t) => t.initiative === id).map((t) => ({ ...t, stage: stageOf(t.id, t.from) }));
129
+ const items = TI.rowsOf(root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, due: x.end, store: 'item', stage: stageOf(x.uid) }));
130
+ return own.concat(items);
131
+ };
132
+
133
+ if (verb === 'add') {
134
+ const [id, title] = pos;
135
+ if (!id || title === undefined) { say('usage: pmos task add <initiative> "<title>" [--stage <stage>] [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]'); return 2; }
136
+ const r = rowOf(boards, ctx, w, id);
137
+ if (!r.ok) return fail(r.error);
138
+ const stages = r.row.wfStages || [];
139
+ const sec = flags.stage !== undefined ? stageKey(stages, flags.stage) : null;
140
+ if (flags.stage !== undefined && sec == null) return fail(`"${flags.stage}" is not a stage of ${id}'s workflow: one of ${stages.map((x) => x.key).join(', ')}, or none`, 2);
141
+ const body = { ws: w.id, board: r.board.id, initiative: id, title };
142
+ for (const k of ['due', 'start', 'owner', 'notes']) if (flags[k] !== undefined) body[k] = flags[k];
143
+ const a = boards.taskAdd(ctx, body, g);
144
+ if (!a.body || a.body.ok !== true) return fail((a.body && a.body.error) || 'the write was refused');
145
+ const t = a.body.item;
146
+ if (sec) {
147
+ const e = boards.taskEdit(ctx, { ws: w.id, board: r.board.id, task: t.uid, section: sec }, g);
148
+ if (!e.body || e.body.ok !== true) return fail(`added ${t.uid}, but it was not placed under ${sec}: ${(e.body && e.body.error) || 'the write was refused'}`);
149
+ }
150
+ if (json) say(JSON.stringify({ ok: true, task: { id: t.uid, board: t.board, title: t.title, state: t.status, owner: t.owner, start: t.start, due: t.end, ...(sec ? { stage: sec } : {}) } }));
151
+ else say(`✓ added ${t.uid} · ${t.status} · ${t.title}${sec ? ' · under ' + sec : ''}${t.end ? ' · due ' + t.end : ''}. The initiative's Tasks section shows it. Nothing was sent.`);
152
+ return 0;
153
+ }
154
+
84
155
  if (verb === 'list') {
85
156
  const id = pos[0]; if (!id || pos.length > 1) { say('usage: pmos task list <initiative> [--all]'); return 2; }
86
- for (const k of ['to', 'why']) if (k in flags) return fail(`--${k} is not an option of list`, 2);
87
- const all = [...(boards.foldOf(ctx, w).tasks || new Map()).values()].filter((t) => t.initiative === id);
157
+ try { boards.seedInitiative(ctx, w, id); } catch { /* the To finish tasks are made on the next read */ }
158
+ const all = tasksOf(id);
88
159
  const shown = flags.all ? all : all.filter((t) => OPEN.has(t.state));
89
- if (json) { say(JSON.stringify({ ok: true, tasks: shown.map((t) => ({ id: t.id, board: t.board, kind: t.kind, title: t.title, state: t.state, owner: t.owner, due: t.due })) })); return 0; }
90
- if (!shown.length) { say(all.length ? `No open task on ${id}. --all lists the ${all.length} closed.` : `No Board task on ${id}.`); return 0; }
160
+ if (json) { say(JSON.stringify({ ok: true, tasks: shown.map((t) => ({ id: t.id, board: t.board, kind: t.kind, title: t.title, state: t.state, owner: t.owner, due: t.due, stage: t.stage || '', ...(t.from ? { from: t.from } : {}) })) })); return 0; }
161
+ if (!shown.length) { say(all.length ? `No open task on ${id}. --all lists the ${all.length} closed.` : `No task on ${id}.`); return 0; }
91
162
  for (const t of shown) say(line(t));
92
163
  return 0;
93
164
  }
165
+ /** A task by its id: a Board task, or a breakdown item with the board its initiative is on. */
166
+ const findTask = (folded, id) => {
167
+ let t = B.taskOf(folded, id);
168
+ if (!t && TI.isItemId(id)) {
169
+ // a breakdown item: the Board's press writes it to the plan-items ledger (lib/task-items.js)
170
+ const it = TI.itemOf(root, id);
171
+ const r = it ? rowOf(boards, ctx, w, it.initiative) : null;
172
+ if (it && r && r.ok) t = { id, board: r.board.id, initiative: it.initiative, title: it.title, state: TI.STATE_OF[it.state] };
173
+ }
174
+ return t;
175
+ };
176
+
177
+ if (verb === 'set') {
178
+ const keys = ['stage', 'due', 'start', 'owner', 'notes'].filter((k) => flags[k] !== undefined);
179
+ if (!pos.length || !keys.length) { say('usage: pmos task set <task> [<task> …] [--stage <stage>|none] [--due YYYY-MM-DD|none] [--start YYYY-MM-DD|none] [--owner <who>] [--notes <text>]'); return 2; }
180
+ const folded = boards.foldOf(ctx, w);
181
+ const done = [], refused = [];
182
+ for (const id of pos) {
183
+ const t = findTask(folded, id);
184
+ if (!t) { refused.push({ task: id, error: `no task ${id}; pmos task list <initiative> names them` }); continue; }
185
+ const body = { ws: w.id, board: t.board, task: id };
186
+ if (flags.stage !== undefined) {
187
+ const r = rowOf(boards, ctx, w, t.initiative);
188
+ const stages = r.ok ? r.row.wfStages || [] : [];
189
+ const sec = stageKey(stages, flags.stage);
190
+ if (sec == null) { refused.push({ task: id, error: `"${flags.stage}" is not a stage of ${t.initiative}'s workflow: one of ${stages.map((x) => x.key).join(', ')}, or none` }); continue; }
191
+ body.section = sec;
192
+ }
193
+ for (const k of ['due', 'start']) if (flags[k] !== undefined) body[k] = String(flags[k]).toLowerCase() === 'none' ? '' : flags[k];
194
+ for (const k of ['owner', 'notes']) if (flags[k] !== undefined) body[k] = flags[k];
195
+ const e = boards.taskEdit(ctx, body, g);
196
+ if (!e.body || e.body.ok !== true) refused.push({ task: id, error: (e.body && e.body.error) || 'the write was refused' });
197
+ else done.push({ task: id, title: t.title, set: Object.fromEntries(keys.map((k) => [k, k === 'stage' ? body.section : body[k]])) });
198
+ }
199
+ const what = (x) => Object.entries(x).map(([k, v]) => (k === 'stage' ? (v ? 'under ' + v : 'under no stage') : v === '' ? 'no ' + k : k + ' ' + v)).join(', ');
200
+ if (json) say(JSON.stringify({ ok: !refused.length, done, refused }));
201
+ else {
202
+ for (const d of done) say(`✓ ${d.task} ${what(d.set)}: ${d.title}`);
203
+ for (const x of refused) say(`✗ ${x.task}: ${x.error}`);
204
+ if (done.length) say(' The page shows it. Nothing was sent.');
205
+ }
206
+ return refused.length ? 1 : 0;
207
+ }
208
+
94
209
  // state
95
210
  if (!pos.length || !flags.to) { say('usage: pmos task state <task> [<task> …] --to <state> [--why <text>]'); return 2; }
96
- if (flags.all) return fail('--all is not an option of state', 2);
97
211
  const to = stateOf(flags.to);
98
212
  if (!to) return fail(`--to is one of ${B.TASK_STATES.join(', ')}`, 2);
99
- const actor = actorLib.fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env });
100
- const g = { ok: true, actor };
101
213
  const folded = boards.foldOf(ctx, w);
102
214
  const done = [], refused = [];
103
215
  for (const id of pos) {
104
- const t = B.taskOf(folded, id);
105
- if (!t) { refused.push({ task: id, error: `no Board task ${id}; pmos task list <initiative> names them` }); continue; }
216
+ const t = findTask(folded, id);
217
+ if (!t) { refused.push({ task: id, error: `no task ${id}; pmos task list <initiative> names them` }); continue; }
106
218
  if (t.state === to) { done.push({ task: id, title: t.title, state: to, same: true }); continue; }
107
219
  const r = boards.taskState(ctx, { ws: w.id, board: t.board, task: id, state: to, ...(flags.why ? { why: flags.why } : {}) }, g);
108
220
  if (!r.body || r.body.ok !== true) refused.push({ task: id, error: (r.body && r.body.error) || 'the write was refused' });
@@ -112,9 +224,9 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
112
224
  else {
113
225
  for (const d of done) say(d.same ? ` ${d.task} was already ${to}: ${d.title}` : `✓ ${d.task} is ${to}: ${d.title}`);
114
226
  for (const x of refused) say(`✗ ${x.task}: ${x.error}`);
115
- if (done.some((d) => !d.same)) say(' The Board shows it. Nothing was sent.');
227
+ if (done.some((d) => !d.same)) say(' The page shows it. Nothing was sent.');
116
228
  }
117
229
  return refused.length ? 1 : 0;
118
230
  }
119
231
 
120
- module.exports = { run, COMMANDS, USAGE, stateOf };
232
+ module.exports = { run, COMMANDS, USAGE, stateOf, stageKey };
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+ /* task-items.js — one kind of task (feedback batch 5, items 2 and 3; Wawan picked "One list", 2026-10-25).
3
+ * An initiative had two task stores: Board tasks (boards.jsonl, the Tasks section, `pmos task`) and breakdown items (the plan-items ledger,
4
+ * `pmos item`), which showed nowhere but the timeline. Claude added 19 work packages as breakdown items and the PM found none of them; a
5
+ * chat could not close three "workflow tasks" because `pmos task` did not see them. Here a breakdown item reads and writes as a task:
6
+ *
7
+ * isItemId(id) → whether id names a breakdown item (<initiative>.<10 characters>), not a Board task (task-…)
8
+ * STATE_OF[item.state] → its task state: todo To do · doing, review In progress · done Done
9
+ * rowsOf(root, ids, board) → the items of those initiatives as work items (routes-boards itemsOf's shape, src 'pmos', store 'item')
10
+ * itemOf(root, id) → the folded item, or null (a withdrawn item is gone: it was Won't do)
11
+ * stateEvents(it, state, why) → the plan-items lines that set a task state: a move, or a withdraw for Won't do and Archived
12
+ * editEvents(it, edit) → the lines of a rename, a reschedule or the Viewer's edits (title, owner, notes, start, due)
13
+ * write(root, events, actor, cli) → the plan-items writer's answer: appendFromCli for a `pmos` call (cli: { isTTY, env }), else appendFromUi
14
+ *
15
+ * The item keeps its store: its start and due still feed the timeline exactly as before (lib/board-fold.js, lib/item-spans.js), and
16
+ * `pmos item list` reads the same fold. Won't do is a withdraw, which the ledger cannot undo, so a closed item leaves the list. */
17
+ const planItems = require('./plan-items.js');
18
+ const actorLib = require('./actor.js');
19
+
20
+ const STATE_OF = Object.freeze({ todo: 'To do', doing: 'In progress', review: 'In progress', done: 'Done' });
21
+ const MOVE_TO = Object.freeze({ 'To do': 'todo', 'In progress': 'doing', Done: 'done' });
22
+
23
+ const isItemId = (id) => typeof id === 'string' && !/^task-/.test(id) && planItems.ID_RE.test(id) && !!planItems.initiativeOf(id);
24
+
25
+ /** An item's owner in the words the Board uses for a task's owner. */
26
+ function ownerName(o) {
27
+ if (o === 'you') return 'pm:' + actorLib.PM_SLUG;
28
+ if (o === 'agent') return 'Claude';
29
+ const m = /^(?:person|tracker):(.+)$/s.exec(String(o || ''));
30
+ return m ? m[1] : null;
31
+ }
32
+ /** A task owner typed on the page or the CLI, as an item owner. */
33
+ function ownerOf(text) {
34
+ const t = String(text || '').trim();
35
+ if (!t || /^pm:/.test(t) || t.toLowerCase() === 'you') return 'you';
36
+ if (/^(claude|agent)\b/i.test(t)) return 'agent';
37
+ return 'person:' + t.slice(0, 60);
38
+ }
39
+
40
+ function itemOf(root, id) {
41
+ try { return planItems.readFold(root).items[id] || null; } catch { return null; }
42
+ }
43
+
44
+ /** The breakdown items of the initiatives in `ids` (a Set), as work items. A proposed item is not a task yet. */
45
+ function rowsOf(root, ids, board) {
46
+ let f;
47
+ try { f = planItems.readFold(root); } catch { return []; }
48
+ const out = [];
49
+ for (const id of f.order) {
50
+ const it = f.items[id];
51
+ if (!it || it.proposed || !ids.has(it.initiative)) continue;
52
+ out.push({ uid: it.id, key: '', kind: 'Task', src: 'pmos', store: 'item', title: it.title, status: STATE_OF[it.state] || 'To do', blocked: !!it.blocked, owner: ownerName(it.owner),
53
+ notes: it.note || '', ini: it.initiative, epic: null, start: it.start || null, end: it.due || null, ref: it.id, board,
54
+ // the breakdown's own stage (plan-tree) and order: the one view places the item in the workflow stage of the same name
55
+ ...(it.stage ? { itemStage: it.stage } : {}), ...(Number.isFinite(it.order) ? { order: it.order } : {}) });
56
+ }
57
+ return out;
58
+ }
59
+
60
+ /** → { events } | { same: true } | { error } */
61
+ function stateEvents(it, state, why) {
62
+ if (state === "Won't do" || state === 'Archived') return { events: [{ ev: 'withdrawn', item: it.id }] };
63
+ const to = MOVE_TO[state];
64
+ if (!to) return { error: `state is one of ${Object.keys(MOVE_TO).concat("Won't do", 'Archived').join(', ')}` };
65
+ if (STATE_OF[it.state] === state) return { same: true };
66
+ const ev = { ev: 'moved', item: it.id, to };
67
+ // the reason a person gave is the Done's evidence: an agent Done with none goes to the PM to check (lib/plan-items.js noEvidence)
68
+ if (to === 'done' && typeof why === 'string' && why.trim()) ev.evidence = { kind: 'note', ref: why.trim().replace(/\s+/g, ' ').slice(0, 200) };
69
+ return { events: [ev] };
70
+ }
71
+
72
+ /** edit: { title?, owner?, notes?, start?, due? } with '' clearing a day or the notes. → { events } | { error } */
73
+ function editEvents(it, edit) {
74
+ const fields = {};
75
+ if (edit.title != null) fields.title = String(edit.title).trim();
76
+ if (edit.owner != null) fields.owner = ownerOf(edit.owner);
77
+ if (edit.notes != null) fields.note = edit.notes === '' ? null : String(edit.notes).slice(0, 1000);
78
+ for (const k of ['start', 'due']) if (edit[k] != null) fields[k] = edit[k] === '' ? null : String(edit[k]);
79
+ if (!Object.keys(fields).length) return { error: 'nothing to change' };
80
+ return { events: [{ ev: 'set', item: it.id, fields }] };
81
+ }
82
+
83
+ function write(root, events, actor, cli) {
84
+ if (cli) return planItems.appendFromCli(root, events, cli);
85
+ return planItems.appendFromUi(root, events, { actor: actor && actor.by ? { by: actor.by, via: 'ui' } : undefined });
86
+ }
87
+
88
+ module.exports = { STATE_OF, isItemId, ownerName, ownerOf, itemOf, rowsOf, stateEvents, editEvents, write };
@@ -179,7 +179,7 @@ function ofLines(r) {
179
179
  const out = [`${row.title} (${row.id}) runs ${row.wf.name} (${row.wf.id}) on the board ${r.board.name}.`];
180
180
  out.push(row.ended ? `It ended: ${row.ended.as === 'wontdo' ? "Won't do" : 'Archived'}.` : `Stage ${st.n} of ${st.of}: ${st.name} [${st.key}]`);
181
181
  (row.wfStages || []).forEach((s, i) => out.push(` ${MARK[s.status] || ' '} ${String(i + 1).padStart(2)}. ${s.milestone ? '◆ ' : ''}${s.name} [${s.key}]${s.status === 'current' ? ' · current' : s.status === 'skipped' ? ' · skipped' : ''}`));
182
- out.push(`Move it: pmos workflow move ${row.id} --stage <key>. A task has no workflow stage; moving the initiative changes no task.`);
182
+ out.push(`Move it: pmos workflow move ${row.id} --stage <key>. Moving the initiative changes no task; a task's group (pmos task set --stage) is its place in the breakdown, not its state.`);
183
183
  return out;
184
184
  }
185
185
  const ofJson = (r) => ({ initiative: { id: r.row.id, title: r.row.title }, board: { id: r.board.id, name: r.board.name }, wf: r.row.wf, stage: r.row.wfStage, stages: r.row.wfStages, ended: r.row.ended });
@@ -33,7 +33,8 @@ const finish = async (code) => {
33
33
  };
34
34
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
35
35
 
36
- const CHECKED = new Date(Date.now() - 3 * 3600e3).toISOString();
36
+ /* three hours ago, but never before today's midnight: the line says "today" at any hour */
37
+ const CHECKED = new Date(Math.max(Date.now() - 3 * 3600e3, new Date().setHours(0, 0, 0, 0))).toISOString();
37
38
  const CHANGES = [
38
39
  { key: 'k-move', op: 'move', milestone: 'pilot-live', date: '2026-12-02', why: 'Was Nov 18. Jira moved epic DSC-41 to sprint 24, which ends Dec 1.', src: { kind: 'jira', label: 'Jira, read 2h ago' } },
39
40
  { key: 'k-add', op: 'add', name: 'Partner SSO cut-over', date: '2027-03-15', waits: ['microsite-signin'], why: 'Partner SSO joined the program yesterday. Its ◆ Deliver is Mar 15, 2027.', src: { kind: 'member', label: 'Partner SSO' } },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.414.0",
3
+ "version": "0.416.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.414.0",
9
+ "version": "0.416.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.414.0",
3
+ "version": "0.416.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -188,9 +188,9 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
188
188
  const I = await open('/premium-initiative.html?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id));
189
189
  const ip = I.page;
190
190
  const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
191
- const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('.hm-card .cz-sl'); }), 60000);
191
+ const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('#czViewer .iv-sc'); }), 60000);
192
192
  ok('I0 the expand link lands on Home with the initiative selected, ws and board kept', !!landed, await ip.evaluate(() => location.href));
193
- await ip.click('#czViewer .hi-pgh [data-hi-addtask]'); // the initiative's page (canvas HbC): its + drills into Tasks
193
+ await ip.click('#czViewer [data-cz-vw="more"]').then(() => ip.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); // the initiative's page (canvas HbC): its + drills into Tasks
194
194
  await until(() => ip.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 60000);
195
195
  await (async (pg) => { if (await pg.$('#czViewer [data-hi-view="stage"]')) await pg.click('#czViewer [data-hi-view="stage"]'); else await viaMore(pg, 'Stage'); })(ip);
196
196
  const bar = await until(() => ip.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); if (!v || !v.querySelector('[data-ov-move]')) return null; const cur = v.querySelector('[data-ov-move][aria-pressed="true"]'); return { moves: [...v.querySelectorAll('[data-ov-move]')].map((x) => x.dataset.ovMove), cur: cur ? cur.dataset.ovMove : '', life: [...v.querySelectorAll('[data-ov-life]')].map((x) => x.dataset.ovLife) }; }), 60000);
@@ -208,7 +208,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
208
208
  await ip.click('#czViewer [data-cz-vw="back"]'); // ← from Stage: the initiative's page again (canvas HbCDrill)
209
209
  // the card (stage card D): its last node, the next stage, opens the move popover with Move now and Back; Back always asks for a reason,
210
210
  // and the move line carries it (InStage)
211
- const openNext = async () => { await until(() => ip.evaluate(() => !!document.querySelector('.hm-card [data-hi-next]')), 30000); await ip.click('.hm-card [data-hi-next]'); return until(() => ip.evaluate(() => !!document.querySelector('.hi-pop [data-hi-goback]'))); };
211
+ const openNext = async () => { await until(() => ip.evaluate(() => !!document.querySelector('.iv-sc [data-iv-next]')), 30000); await ip.click('.iv-sc [data-iv-next]'); return until(() => ip.evaluate(() => !!document.querySelector('.hi-pop [data-hi-goback]'))); };
212
212
  const back = await openNext();
213
213
  ok('I4 the card\'s next stage opens Move to the next stage now and Back', back && await ip.evaluate(() => /^Move to .+ now$/.test(((document.querySelector('.hi-pop [data-hi-go]') || {}).textContent || '').trim())));
214
214
  if (back) {
@@ -48,7 +48,8 @@ const look = () => {
48
48
  tabs: pane ? [(vw.querySelector('.cz-vw-kind') || {}).textContent || ''] : [], pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
49
49
  secs: pane ? (pane.querySelector('.vz-dkt') ? pane.querySelectorAll('.vz-dkt button').length - 1 : pane.querySelectorAll('.vz-secs li').length) : 0,
50
50
  slide: pane && pane.querySelector('.vz-dkn > span') ? pane.querySelector('.vz-dkn > span').textContent : null,
51
- sched: pane && pane.querySelector('[data-rt="sched"] b') ? pane.querySelector('[data-rt="sched"] b').textContent : null,
51
+ sched: pane && pane.querySelector('[data-rt="sched"] b') ? pane.querySelector('[data-rt="sched"] b').textContent : pane && pane.querySelector('.rp-mc[data-rt="sched"]') ? pane.querySelector('.rp-mc[data-rt="sched"]').textContent : null,
52
+ sum: pane && pane.querySelector('.rp-sum') ? { line: pane.querySelector('.rp-sum .czs-line').textContent, chips: [...pane.querySelectorAll('.rp-sum .rp-mc')].map((c) => c.textContent).join(), pri: (pane.querySelector('.rp-sum .rp-pri') || {}).getAttribute?.('aria-label') || '', seg: [...pane.querySelectorAll('.rp-seg button')].map((b) => b.textContent).join(), folds: [...pane.querySelectorAll('.czs-row')].map((r) => r.textContent).join('|') } : null,
52
53
  wide: document.documentElement.scrollWidth > innerWidth + 1 };
53
54
  };
54
55
 
@@ -80,15 +81,22 @@ const look = () => {
80
81
  ok('R1 opening the chat opens no tab by itself', s0.tabs.length === 0, JSON.stringify(s0));
81
82
  await p.click('#hmLog [data-report-open]');
82
83
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
83
- ok('R3 the new report is the design\'s slide deck: name, audience, format, a title slide and seven section slides, Schedule Off', /Slide deck/.test(s1.tabs.join(' ')) && /Social login weekly/.test(s1.pane || '') && /Read byGrowth leads/.test(s1.pane || '') && /FormatGoogle Slides/.test(s1.pane || '') && !/Waiting for design/.test(s1.pane || '')
84
- && s1.secs === 7 && s1.slide === 'Slide 1 of 8' && s1.sched === 'Off · runs once' && /Set it up/.test(s1.pane || '') && !(await p.$('#czViewer .rt, #czViewer .obody, #dlg:not([hidden])')), JSON.stringify(s1));
84
+ ok('R3 the new report opens the one report Viewer in its first state (OvReport): New · from your chat, Not set up yet, Set it up as an icon, the chips Once and the format, Slides | Document, a title slide and seven section slides, the folds At a glance and Structure and look', /Report · Growth leads/.test(s1.tabs.join(' ')) && /Social login weekly/.test(s1.pane || '') && !/Waiting for design/.test(s1.pane || '')
85
+ && s1.sum && s1.sum.line === 'New · from your chatNot set up yet' && s1.sum.pri === 'Set it up' && s1.sum.chips === 'Once,Google Slides' && s1.sum.seg === 'Slides,Document' && s1.sum.folds === 'At a glanceFor, read by, goes out|Structure and looknew'
86
+ && /One slide per section: Headline, Timeline/.test(s1.pane || '') && s1.secs === 7 && s1.slide === 'Slide 1 of 8' && s1.sched === 'Once' && !(await p.$('#czViewer .rt, #czViewer .obody, #dlg:not([hidden])')), JSON.stringify(s1));
87
+ await p.click('#czViewer .czs-row[data-czs-fold="glance"]');
88
+ ok('R3 At a glance opens with For, Read by, Goes out and Format', await until(() => p.evaluate(() => /Read byGrowth leads/.test(document.querySelector('#czViewer .czs-sec.on').textContent) && /FormatGoogle Slides/.test(document.querySelector('#czViewer .czs-sec.on').textContent) && /Goes outOff · runs once/.test(document.querySelector('#czViewer .czs-sec.on').textContent))));
89
+ await p.click('#czViewer .czs-row[data-czs-fold="glance"]');
90
+ await p.click('#czViewer [data-rt="view|doc"]');
91
+ ok('R3 Document shows the outline as a page, and Slides brings the deck back', await until(() => p.evaluate(() => document.querySelectorAll('#czViewer .vz-dkp .vz-secs li').length === 7 && !document.querySelector('#czViewer .vz-dks'))));
92
+ await p.click('#czViewer [data-rt="view|deck"]');
85
93
  await p.click('#czViewer [data-rt="sl|1"]');
86
94
  ok('R3 next shows the second slide, a section of the report', /Slide 2 of 8/.test((await p.evaluate(look)).slide || '') && /Headline/.test(await p.textContent('#czViewer .vz-dks')));
87
95
  if (shots) await p.screenshot({ path: `${shots}/new-1280-light.png` });
88
96
  await p.click('#czViewer [data-rt="sched"]');
89
97
  await p.click('#czViewer [data-rt="pick|2"]');
90
- const s2 = await until(async () => { const v = await p.evaluate(look); return v.sched && /Weekly/.test(v.sched) ? v : null; }) || await p.evaluate(look);
91
- ok('R3 a pick changes the chip only: nothing is written', /Weekly, Mondays at 09:00/.test(s2.sched || '') && !ledger().some((l) => l.ev === 'setup'), JSON.stringify(s2));
98
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.sched && /Every week/.test(v.sched) ? v : null; }) || await p.evaluate(look);
99
+ ok('R3 a pick changes the chip only: nothing is written', s2.sched === 'Every week' && !ledger().some((l) => l.ev === 'setup'), JSON.stringify(s2));
92
100
  await p.click('#czViewer [data-rt="sched"]'); await p.click('#czViewer [data-rt="pick|0"]');
93
101
  await p.click('#czViewer [data-rt="setup"]');
94
102
  const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Report template/.test(v.tabs.join()) && /Draft/.test(v.pane) ? v : null; }, 15000) || await p.evaluate(look);
@@ -118,7 +118,7 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
118
118
  // the initiative's page (canvas HbC): its list row opens it again when the Viewer shows something else
119
119
  const ovOpen = async (p) => { await until(() => p.evaluate(() => !!document.querySelector('#hmList [data-hm-sel^="i:"][aria-current="true"]')), 60000);
120
120
  if (!(await p.$('#czViewer:not([hidden]) [data-hi-v="page"]'))) await p.click('#hmList [data-hm-sel^="i:"][aria-current="true"]');
121
- await until(() => p.evaluate(() => !!document.querySelector('#czViewer .hi-pgh [data-hi-addtask]')), 60000); await p.click('#czViewer .hi-pgh [data-hi-addtask]'); // the initiative's page (canvas HbC): its + drills into Tasks
121
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-hi-v="page"] .iv')), 60000); await p.click('#czViewer [data-cz-vw="more"]').then(() => p.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); // the initiative's page (canvas HbC): its + drills into Tasks
122
122
  // the Overview opens on Tasks; the core documents are its Documents view (premium-uncovered-features, canvas InDocs)
123
123
  if (await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 30000)) await (async (pg) => { if (await pg.$('#czViewer [data-hi-view="docs"]')) await pg.click('#czViewer [data-hi-view="docs"]'); else await viaMore(pg, 'Documents'); })(p); };
124
124
  const I = await open('/premium-initiative.html' + iq), ip = I.page;