create-pmos 0.414.0 → 0.415.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.414.0",
3
+ "version": "0.415.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -32,6 +32,18 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.415.0",
37
+ "at": "2026-10-25T15:54:44.873Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1048,
42
+ "t": "Fifth testing feedback batch",
43
+ "s": "Fifth testing feedback batch"
44
+ }
45
+ ]
46
+ },
35
47
  {
36
48
  "v": "0.414.0",
37
49
  "at": "2026-10-25T12:55:58.684Z",
@@ -264,18 +276,6 @@
264
276
  "s": "Use the width and a larger type on large screens"
265
277
  }
266
278
  ]
267
- },
268
- {
269
- "v": "0.395.0",
270
- "at": "2026-10-22T10:27:24.369Z",
271
- "f": 2,
272
- "prs": [
273
- {
274
- "n": 1009,
275
- "t": "Keep share.pm-os.app out of the workspace Access application",
276
- "s": "Keep share.pm-os.app out of the workspace Access application"
277
- }
278
- ]
279
279
  }
280
280
  ]
281
281
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@4915a4ce
1
+ kernel-source: pmos@fc4b4f72
2
2
  assembled: 2026-10-25
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-25T12:55:55Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-25T15:54:42Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-25T12:55:55Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-25T15:54:42Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-25T12:55:55Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-25T15:54:42Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -609,7 +609,7 @@ function doctor() {
609
609
  say(' pmos skill … list, read, create and edit skills');
610
610
  say(' pmos proactive … what is waiting for you, feedback, settings (pmos proactive --help)');
611
611
  say(' pmos kg … find a card, a section or a decision\'s citers without reading whole files (pmos kg --help)');
612
- say(' pmos item add|set|move|withdraw|list — an initiative\'s breakdown items (pmos item help)');
612
+ say(' pmos item add|set|move|withdraw|list — an initiative\'s breakdown items, the older task record; new tasks use pmos task add (pmos item help)');
613
613
  for (const line of require('../lib/pmos-verbs.js').helpLines()) say(line);
614
614
  say(' pmos upgrade reinstall the workspace app from the latest published create-pmos');
615
615
  code = 0;
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "v": "0.415.0",
4
+ "at": "2026-10-25T15:54:44.873Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1048,
9
+ "t": "Fifth testing feedback batch",
10
+ "s": "Fifth testing feedback batch"
11
+ }
12
+ ]
13
+ },
2
14
  {
3
15
  "v": "0.414.0",
4
16
  "at": "2026-10-25T12:55:58.684Z",
@@ -66,7 +66,10 @@ An initiative's **workflow stage** is the stage on its stage card and on the Boa
66
66
 
67
67
  ### The pmos task commands
68
68
 
69
- An agent changes a Board task's state when you ask, so you do not have to find the task on the Board yourself.
69
+ An agent adds and closes tasks when you ask, so you do not have to find the task on the Board yourself. There is one kind of task: the tasks in the initiative's Tasks section. The older breakdown items (`pmos item`) and the To finish entries of the current stage are tasks too, and these commands list and close them.
70
70
 
71
+ - `pmos task add <initiative> "<title>"` adds a task. `--due` and `--start` set its days, `--owner` its owner and `--notes` its notes. The task is the same as one added with Add a task on the page, under the agent's name.
71
72
  - `pmos task list <initiative>` lists the initiative's open tasks (To do and In progress) with their ids. `--all` adds the Done, Won't do and Archived tasks.
72
- - `pmos task state <task> [<task> …] --to <state>` sets the state of one or more tasks: To do, In progress, Done, Won't do or Archived. `--why` adds the reason. Each change writes the same line as the Board's press, under the agent's name.
73
+ - `pmos task state <task> [<task> …] --to <state>` sets the state of one or more tasks: To do, In progress, Done, Won't do or Archived. `--why` adds the reason, and for Done it is the evidence you read. Each change writes the same line as the page's press, under the agent's name. Won't do on a breakdown item withdraws it, and it cannot come back.
74
+
75
+ When an initiative reaches a stage, each entry of that stage's To finish list becomes one task, once. Closing that task, on the stage card, in the Tasks section or with `pmos task state`, marks the entry done on the stage card.
@@ -291,6 +291,14 @@ function build(f) {
291
291
  const relAt = f.nextRelease && f.nextRelease.at ? String(f.nextRelease.at).slice(0, 10) : null;
292
292
  // the Jira epic of each initiative, from the board's work items (Linked: Epic <key>)
293
293
  const epicBy = new Map(); for (const w of f.items || []) if (w && w.kind === 'Epic' && w.key && w.ini && !epicBy.has(w.ini)) epicBy.set(w.ini, w.key);
294
+ // each initiative's PMOS tasks (feedback batch 5, one list): its Board tasks, its breakdown items and its stage's To finish tasks, for the panel
295
+ const taskBy = new Map();
296
+ for (const w of f.items || []) {
297
+ if (!w || w.src !== 'pmos' || w.kind === 'Epic' || !w.ini || !w.uid || w.status === 'Archived') continue;
298
+ if (!taskBy.has(w.ini)) taskBy.set(w.ini, []);
299
+ taskBy.get(w.ini).push({ uid: w.uid, title: clip(w.title || '', 160), status: w.status || 'To do', owner: w.owner || '', end: w.end || '', ...(w.from ? { from: { stage: w.from.stage, finish: w.from.finish } } : {}) });
300
+ }
301
+ for (const r of rows.concat(stageRows, gone.cancelled, gone.archived)) if (!r.tasks) r.tasks = (taskBy.get(r.id) || []).slice(0, 60);
294
302
  for (const r of rows.concat(stageRows, gone.cancelled, gone.archived)) if (!r.track) {
295
303
  r.track = trackOf(r, tkBy.get(r.id), todayIso, relOfIni.get(r.id)); r.theme = themeOf(r.anchor);
296
304
  if (epicBy.has(r.id) && !r.epics.includes(epicBy.get(r.id))) r.epics.unshift(epicBy.get(r.id));
@@ -255,7 +255,9 @@ function fold(events) {
255
255
  } else if (e.kind === 'task' && b && typeof e.task === 'string' && typeof e.initiative === 'string' && !tasks.has(e.task)) {
256
256
  tasks.set(e.task, { id: e.task, board: b, initiative: e.initiative, kind: e.type === 'Epic' ? 'Epic' : 'Task', title: String(e.title || ''), epic: typeof e.epic === 'string' && e.epic ? e.epic : null,
257
257
  owner: typeof e.owner === 'string' && e.owner ? e.owner : null, notes: typeof e.notes === 'string' ? e.notes : '', state: taskState(e.state) || 'To do',
258
- start: typeof e.start === 'string' ? e.start : null, due: typeof e.due === 'string' ? e.due : null, at: e.at || null, by: e.by || null, history: [] });
258
+ start: typeof e.start === 'string' ? e.start : null, due: typeof e.due === 'string' ? e.due : null, at: e.at || null, by: e.by || null, history: [],
259
+ // a stage's To finish entry made a task (routes-boards stageTasks): the stage card counts it, and it is made once
260
+ from: isObj(e.from) && typeof e.from.stage === 'string' && typeof e.from.finish === 'string' ? { stage: e.from.stage, finish: e.from.finish } : null });
259
261
  } else if (e.kind === 'task-update' && typeof e.task === 'string' && tasks.has(e.task)) {
260
262
  const t = tasks.get(e.task);
261
263
  if (taskState(e.state)) t.state = taskState(e.state);
@@ -336,7 +338,7 @@ function itemStatus(status, category) {
336
338
  /** A PMOS task as a work item. */
337
339
  function taskItem(t) {
338
340
  return { uid: t.id, key: '', kind: t.kind === 'Epic' ? 'Epic' : 'Task', src: 'pmos', title: t.title, status: t.state, blocked: false, owner: t.owner || null, notes: t.notes || '',
339
- ini: t.initiative, epic: t.epic || null, start: t.start || null, end: t.due || null, ref: t.id, board: t.board };
341
+ ini: t.initiative, epic: t.epic || null, start: t.start || null, end: t.due || null, ref: t.id, board: t.board, ...(t.from ? { from: { ...t.from } } : {}) };
340
342
  }
341
343
  /** Progress per item, and an epic's status, progress, blocked flag and dates rolled up from its items. Mutates and returns items. */
342
344
  function rollupItems(items) {
@@ -68,10 +68,11 @@ const unskipMessage = (point) => MARK.unskip + ' The PM took the skip back: the
68
68
 
69
69
  function startMessage(draft) {
70
70
  return [
71
- MARK.start + ' The PM pressed Start. Work on this goal now, as you would in a terminal under the PM\'s Claude Code settings, until every done point is met:',
71
+ MARK.start + ' The PM pressed Start. Work on this goal now, on your own, until every done point is met:',
72
72
  JSON.stringify(draft),
73
- 'Merging follows the PM\'s standing rule (merge once required CI is green). Ask before anything that is sent to other people. Stop and ask when you need the PM.',
74
- 'At the end of each message about this goal, add a fenced pmos-goal block: {"step":"progress","state":"working|done|needs-you","met":["done points met"],"open":["done points still open"]}.',
73
+ 'Do whatever the goal needs, as the PM would. Do not stop to ask for approval, feedback or a choice: pick the sensible option yourself, say in one line what you chose, and go on. Merging follows the PM\'s standing rule (merge once required CI is green).',
74
+ 'Stop for the PM only when the work cannot go on without them: a sign-in or secret only they have, or a message that goes to other people. Then do every other open point first, and end with needs-you and exactly what you need.',
75
+ 'At the end of each message about this goal, add a fenced pmos-goal block: {"step":"progress","state":"working|done|needs-you","met":["done points met"],"open":["done points still open"]}. Copy each done point word for word. Report done only after you checked every point.',
75
76
  ].join('\n');
76
77
  }
77
78
  const cancelMessage = () => MARK.cancel + ' The PM cancelled this goal. Do no more work for it and say in one line what you stopped.';
@@ -141,6 +142,13 @@ function blockOf(text) {
141
142
  try { const b = JSON.parse(last[1]); return b && typeof b === 'object' ? b : null; } catch { return null; }
142
143
  }
143
144
  const strs = (a) => (Array.isArray(a) ? a.map((x) => clip(x, 200)).filter(Boolean).slice(0, 8) : null);
145
+ const norm = (x) => String(x == null ? '' : x).toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
146
+ /** The plan points Claude reports met. Claude rewords them (bug 2026-10-25: "Goal done" with 0 of 4 met), so a point counts when a
147
+ * reported string is the same after norm, or, both 12 characters or more, one holds the other. */
148
+ function matchPoints(reported, all) {
149
+ const got = (Array.isArray(reported) ? reported : []).map(norm).filter(Boolean);
150
+ return (all || []).filter((p) => { const n = norm(p); return n && got.some((r) => r === n || (r.length >= 12 && n.length >= 12 && (r.includes(n) || n.includes(r)))); });
151
+ }
144
152
  /** The chat key a session belongs to (premium-chat-sessions.jsonl, the last line that names it), or null. */
145
153
  function keyOfSession(runtimeDir, session, chatsFile) {
146
154
  let t; try { t = fs.readFileSync(path.join(runtimeDir, chatsFile), 'utf8'); } catch { return null; }
@@ -156,21 +164,33 @@ const roundsOf = (runtimeDir, id) => {
156
164
  function onStop({ runtimeDir, key, message, now = new Date() }) {
157
165
  const g = key && goalOf(runtimeDir, key);
158
166
  if (!g || g.state !== 'started' || !g.draft) return {};
159
- const d = g.draft, b = blockOf(message), all = requiredOf(g), skipped = g.skipped || [];
160
- const met = ((b && b.step === 'progress' && strs(b.met)) || g.met || []).filter((x) => !skipped.includes(x));
161
- const open = ((b && b.step === 'progress' && strs(b.open)) || all.filter((x) => !met.includes(x))).filter((x) => !skipped.includes(x));
167
+ const d = g.draft, b = blockOf(message), all = requiredOf(g);
168
+ const p = b && b.step === 'progress' ? b : null;
169
+ // the plan decides what is met and open: Claude's own open list and its "done" alone do not count
170
+ const met = p && Array.isArray(p.met) ? matchPoints(strs(p.met), all) : (g.met || []).filter((x) => all.includes(x));
171
+ const open = all.filter((x) => !met.includes(x));
162
172
  const base = { id: g.id, key, met, open, at: now.toISOString() };
163
- if (b && b.step === 'progress' && (b.state === 'done' || (open.length === 0 && met.length > 0))) { append(runtimeDir, { event: 'done', ...base }); return {}; }
164
- if (b && b.step === 'progress' && b.state === 'needs-you') { append(runtimeDir, { event: 'waiting', ...base }); return {}; }
173
+ if (all.length && !open.length) { append(runtimeDir, { event: 'done', ...base }); return {}; }
174
+ const prev = roundsOf(runtimeDir, g.id), last = prev[prev.length - 1];
175
+ const needs = !!(p && p.state === 'needs-you');
176
+ // the goal works on its own (feedback 2026-10-25): the first needs-you is sent back; a second one in a row waits on the PM
177
+ if (needs && last && last.asked && Date.parse(last.at) >= Date.parse(g.at || '')) { append(runtimeDir, { event: 'waiting', ...base }); return {}; }
165
178
  const due = Date.parse(d.by || '');
166
179
  const stop = (reason) => { append(runtimeDir, { event: 'stopped', reason, ...base }); return {}; };
167
180
  if (Number.isFinite(due) && now.getTime() > due) return stop('deadline');
168
181
  const n = (g.rounds || 0) + 1;
169
182
  if (n > (d.limit || LIMIT)) return stop('limit');
170
- const prev = roundsOf(runtimeDir, g.id);
183
+ const head = '[PMOS /goal round ' + n + '] ';
184
+ if (needs) {
185
+ append(runtimeDir, { event: 'round', n, asked: true, ...base });
186
+ return { decision: 'block', reason: head + 'Do not wait for the PM. Pick the sensible option yourself, say in one line what you chose, and go on. Only if the work truly cannot go on without the PM (a sign-in or secret only they have, or a message to other people), end again with needs-you and exactly what you need.' };
187
+ }
171
188
  if (prev.length >= NO_PROGRESS && prev.slice(-NO_PROGRESS).every((r) => (r.met || []).length >= met.length)) return stop('no-progress');
172
189
  append(runtimeDir, { event: 'round', n, ...base });
173
- return { decision: 'block', reason: '[PMOS /goal round ' + n + '] The goal is not done yet: ' + met.length + ' of ' + all.length + ' done points met. Keep working on: ' + (open.length ? open.join('; ') : 'the open points') + '. This is round ' + n + ' of ' + (d.limit || LIMIT) + '. If you need the PM, ask and end with a pmos-goal progress block whose state is needs-you. End each message with the progress block.' };
190
+ const said = p && p.state === 'done'
191
+ ? 'You reported done, but these points are not met yet: ' + open.join('; ') + '. Check each one, and work on the ones that are not true yet. Copy each point word for word in met.'
192
+ : 'The goal is not done yet: ' + met.length + ' of ' + all.length + ' done points met. Keep working on: ' + (open.length ? open.join('; ') : 'the open points') + '.';
193
+ return { decision: 'block', reason: head + said + ' This is round ' + n + ' of ' + (d.limit || LIMIT) + '. End each message with the progress block. Do not stop to ask for approval. Decide yourself and go on.' };
174
194
  }
175
195
  /** The PM wrote in the goal's conversation. A goal that waits on them is working again (U3); a finished or stopped goal is seen,
176
196
  * so its Briefing row goes (U7). A goal in any other state is left as it is. */
@@ -228,10 +248,10 @@ function withGoalRows(model, rows) {
228
248
  const count = (model.list.count || 0) + add.length;
229
249
  return { ...model, list: { ...model.list, rows: list, count }, dock: model.dock && model.dock.needs != null ? { ...model.dock, needs: count, label: count === 1 ? 'needs you' : 'need you', next: list[0].title } : model.dock };
230
250
  }
231
- /** The Claude Code --settings for a chat session: a Stop hook and an AskUserQuestion hook, each posting to this workspace with the session's token. */
251
+ /** The Claude Code --settings for a chat session: a Stop hook, an AskUserQuestion hook and a hook on every tool (goal-tool), each posting to this workspace with the session's token. */
232
252
  function hookSettings(port, host = '127.0.0.1') {
233
253
  const hook = (route) => ({ type: 'http', url: 'http://' + host + ':' + port + '/api/briefing-premium/' + route, headers: { 'x-pmos-session': '$PMOS_SESSION' }, allowedEnvVars: ['PMOS_SESSION'], timeout: 10 });
234
- return { hooks: { Stop: [{ hooks: [hook('goal-stop')] }], PreToolUse: [{ matcher: ASK_TOOL, hooks: [hook('ask-tool')] }] } };
254
+ return { hooks: { Stop: [{ hooks: [hook('goal-stop')] }], PreToolUse: [{ matcher: ASK_TOOL, hooks: [hook('ask-tool')] }, { matcher: '*', hooks: [hook('goal-tool')] }] } };
235
255
  }
236
256
  /* chat-ask-card (bug 2026-10-22): Claude Code's question tool draws a picker in the terminal, and the chat panel cannot show it. The panel
237
257
  * showed "Claude is working", the PM pressed Stop (Esc) and the question ended as "[Request interrupted by user for tool use]", again and
@@ -241,8 +261,19 @@ const ASK_TOOL = 'AskUserQuestion';
241
261
  const ASK_REASON = 'The PM is in the PMOS chat panel, not a terminal. The panel already shows these questions and their options as buttons, '
242
262
  + 'and the PM\'s answer comes as their next message. Do not ask again and do not guess the answer: end your turn now with one short line. '
243
263
  + 'If you are working on a /goal, end with a pmos-goal progress block whose state is needs-you.';
244
- function askToolReply() {
245
- return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: ASK_REASON } };
264
+ const GOAL_ASK_REASON = 'You are working on a /goal the PM started, and the PM asked you to finish it on your own. Do not ask: pick the sensible option yourself, '
265
+ + 'say in one line what you chose, and go on. Only if the work truly cannot go on without the PM (a sign-in or secret only they have, or a message to other people), '
266
+ + 'end your turn with a pmos-goal progress block whose state is needs-you.';
267
+ /** goal: the chat key's goal, or null. A started goal does not ask at all; any other chat waits for the PM's answer in the panel. */
268
+ function askToolReply(goal) {
269
+ const reason = goal && goal.state === 'started' ? GOAL_ASK_REASON : ASK_REASON;
270
+ return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: reason } };
271
+ }
272
+ /* A started goal works on its own (feedback 2026-10-25: it stopped for approval prompts): no permission prompt stops it. The PM's deny
273
+ * rules still apply. With no started goal the answer is {} and Claude Code asks as usual. */
274
+ function goalToolReply(goal, toolName) {
275
+ if (!goal || goal.state !== 'started' || toolName === ASK_TOOL) return {};
276
+ return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow', permissionDecisionReason: 'PMOS: the PM started a /goal and asked Claude to finish it on its own.' } };
246
277
  }
247
278
 
248
279
  /** chat() hands a `/goal` message here: { error } or { id, prompt } with the grilling line already on record. */
@@ -305,4 +336,4 @@ function decide({ runtimeDir, key, id, act, draft, point, session, sessions, now
305
336
  return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
306
337
  }
307
338
 
308
- module.exports = { parseCommand, grillPrompt, methodMessage, planMessage, skipMessage, unskipMessage, METHODS, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
339
+ module.exports = { parseCommand, grillPrompt, methodMessage, planMessage, skipMessage, unskipMessage, METHODS, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, goalToolReply, matchPoints, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
@@ -11,13 +11,13 @@
11
11
  * infoOf(answer) → { id, title, wf: { id, name }, stage: { key, name, n, of }, stages: [{ key, name, status }], ended } | null
12
12
  * from lib/routes-boards.js initiativeWorkflow's answer
13
13
  * rule(info, id) → the rule's lines, with the workflow and stage when info is known
14
- * isAsk(text) → whether a message is about a stage, a workflow or a move
14
+ * isAsk(text) → whether a message is about a stage, a workflow, a move or a task
15
15
  * wrap(text, info, id) → the message as PMOS types it into a live session */
16
16
 
17
17
  // The first line of every message PMOS wraps. The page reads it to show the PM's turn as typed (public/pm/goal-chat.js shownUser).
18
18
  const MARK = '[PMOS initiative]';
19
19
  const SAYS = 'The PM says: ';
20
- const ASK_RE = /\b(stages?|workflows?|move[sd]?|moving|phases?|advance|next step)\b/i;
20
+ const ASK_RE = /\b(stages?|workflows?|move[sd]?|moving|phases?|advance|next step|tasks?)\b/i; // a task ask gets the one-kind-of-task rule (feedback batch 5)
21
21
 
22
22
  const isAsk = (text) => ASK_RE.test(String(text == null ? '' : text)) && !String(text).trim().startsWith('/');
23
23
 
@@ -38,8 +38,9 @@ function rule(info, id) {
38
38
  } else out.push(`Run \`pmos workflow of ${ini}\` to see the workflow this initiative runs and its current stage.`);
39
39
  out.push(
40
40
  `The workflow stage is on the initiative: the stage card and the Board show it. \`pmos workflow of ${ini}\` reads it. When the PM asks to move the initiative, run \`pmos workflow move ${ini} --stage <key> --why "<reason>"\`. When the PM asks to change its workflow, run \`pmos workflow switch ${ini} --to <workflow id>\`. Both write what the page's press writes, under your name.`,
41
- 'A task has no workflow stage. Its only stage is its state: To do, In progress, Done, Won\'t do or Archived. When the PM asks to change a task, '
42
- + `do it yourself, never send the PM to the Board: \`pmos task list ${ini}\` names the initiative's Board tasks and \`pmos task state <task> [<task> …] --to "<state>"\` sets them (a breakdown item is \`pmos item move <item> todo|doing|done\`). Never set a task's stage, and never change tasks to move the initiative.`,
41
+ 'There is one kind of task: the ones the PM sees in the initiative\'s Tasks section. The stage card\'s To finish entries and the older breakdown items are tasks too. '
42
+ + 'A task has no workflow stage. Its only stage is its state: To do, In progress, Done, Won\'t do or Archived. When the PM asks to add, close or change a task, '
43
+ + `do it yourself, never send the PM to the Board: \`pmos task add ${ini} "<title>" [--due YYYY-MM-DD]\` adds one, \`pmos task list ${ini}\` names them all and \`pmos task state <task> [<task> …] --to "<state>" --why "<what shows it>"\` sets them. Never use \`pmos item add\` for new work. Never set a task's stage, and never change tasks to move the initiative.`,
43
44
  );
44
45
  return out;
45
46
  }
@@ -89,9 +89,11 @@ function build(f) {
89
89
  : ((sheet && sheet.stepper) || []).map((s) => ({ k: s.id, label: s.label || s.id, state: s.state === 'todo' ? 'pending' : s.state, stateLabel: STEP_STATE[s.state] || cap1(s.state), owed: s.owed ? clip(typeof s.owed === 'string' ? s.owed : s.owed.text || s.owed.what || '', 160) : '', cur: s.state === 'current' }));
90
90
  const allSteps = steps ? steps.map((s) => ({ label: s.label || s.key, stateLabel: LAD_STATE[s.status] || cap1(s.status), note: clip(s.evidence || (s.basis && s.basis.rule) || s.rule || '', 220) })) : [];
91
91
 
92
- // ── tasks: PRD requirements (no result per requirement) and the board's tracker items ──
92
+ // ── tasks: PRD requirements (no result per requirement) and the board's items: its Board tasks, the initiative's breakdown items and its
93
+ // stage's To finish tasks are one kind of task (feedback batch 5, lib/task-items.js), Jira rows are read-only ──
93
94
  const items = (f.items || []).filter((t) => t && t.ini === id).slice(0, MAX_TASKS);
94
- const tracker = items.map((t, n) => ({ key: 'task:' + (t.uid || t.key || n), uid: t.uid || '', pmos: t.src === 'pmos', ref: t.key || t.ref || '', title: clip(t.title, 160), state: t.status || 'To do', src: t.src === 'jira' ? 'Jira (read-only)' : 'PMOS task', owner: t.owner || '', start: t.start || '', end: t.end || '', blocked: !!t.blocked, kind: t.kind || 'Task', notes: t.notes || '', readAt: t.readAt || '' }));
95
+ const tracker = items.map((t, n) => ({ key: 'task:' + (t.uid || t.key || n), uid: t.uid || '', pmos: t.src === 'pmos', ref: t.key || t.ref || '', title: clip(t.title, 160), state: t.status || 'To do', src: t.src === 'jira' ? 'Jira (read-only)' : 'PMOS task', owner: t.owner || '', start: t.start || '', end: t.end || '', blocked: !!t.blocked, kind: t.kind || 'Task', notes: t.notes || '', readAt: t.readAt || '',
96
+ ...(t.from ? { from: { stage: t.from.stage, finish: t.from.finish } } : {}), ...(t.store === 'item' ? { store: 'item' } : {}) }));
95
97
  const dv = sheet && sheet.derived;
96
98
  const reqs = dv && Array.isArray(dv.items) ? dv.items.slice(0, MAX_TASKS).map((x) => ({ key: 'req:' + x.id, ref: x.ref || x.id, title: clip(x.title, 160), state: null, src: 'PRD requirement' })) : [];
97
99
  const prog = ini.progress || null;
@@ -27,7 +27,8 @@ const { parseArgs } = require('./schedule-cli');
27
27
 
28
28
  const COMMANDS = { item: ['add', 'set', 'move', 'withdraw', 'list'] };
29
29
  const USAGE = [
30
- 'usage: pmos item add|set|move|withdraw|list — an initiative\'s breakdown items',
30
+ 'usage: pmos item add|set|move|withdraw|list — an initiative\'s breakdown items, the older record of its tasks',
31
+ 'New tasks go through pmos task add, and pmos task list|state lists and closes breakdown items too. There is one kind of task.',
31
32
  ' pmos item add <initiative> "<title>" --stage <stage> [--due YYYY-MM-DD] [--start YYYY-MM-DD]',
32
33
  ' [--owner you|agent|person:<name>|tracker:<ref>] [--after <item>[,<item>]] [--milestone] [--note "<text>"]',
33
34
  ' pmos item set <item> [--title "<title>"] [--stage <stage>] [--due <date>|none] [--start <date>|none] [--owner <owner>]',
@@ -67,7 +67,7 @@ const VERBS = Object.freeze({
67
67
  help: 'pmos workflow list|show|draft|show-draft|judge|of|move|switch … — the workflows of this repository, the New workflow draft, a reading of an Only-when stage, and an initiative\'s workflow stage (pmos workflow help)' }),
68
68
  // Not a pm-os-absorb verb (run: null): feedback batch 4 (Wawan, 2026-10-25) added it through the same table.
69
69
  task: Object.freeze({ module: 'task-cli.js', run: null, guide: 'workflows.md',
70
- help: 'pmos task list|state … — an initiative\'s Board tasks, and setting their state when the PM asks (pmos task help)' }),
70
+ help: 'pmos task add|list|state … — an initiative\'s tasks: add one, list them, set their state when the PM asks (pmos task help)' }),
71
71
  // Not a pm-os-absorb verb (run: null): feedback batch 4 item 6 (Claude suggests program milestones) added it through the same table.
72
72
  program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'programs.md',
73
73
  help: 'pmos program suggest — Claude\'s milestone suggestions for a program, filed by its review run (pmos program help)' }),
@@ -24,7 +24,7 @@
24
24
  * POST /api/boards/settings { ws, board, buildDeliver?, jira?, offer?, defTpl? } → { ok, board } jira: one key or a list
25
25
  * POST /api/boards/ini-workflow { ws, board, id, template?, stages, moveTo? } → { ok, row, moved }
26
26
  * POST /api/boards/ini-epics { ws, board, id, epics: [Jira key] } → { ok, row } the Jira epics of an initiative ([] unlinks)
27
- * POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner? } → { ok, item }
27
+ * POST /api/boards/tasks/add { ws, board, initiative, title, type?, epic?, start?, due?, owner?, notes? } → { ok, item } also `pmos task add`
28
28
  * POST /api/boards/tasks/state { ws, board, task, state } → { ok, item }
29
29
  * POST /api/boards/tasks/reschedule { ws, board, task, days } → { ok, item }
30
30
  * POST /api/boards/tasks/undo-add { ws, board, task } → { ok } takes back a task added in the last 2 minutes, still To do
@@ -82,6 +82,7 @@ const { repoScript } = require('./repo-script.js');
82
82
  const B = require(repoScript('boards.js'));
83
83
  const WF = require(repoScript('workflows.js'));
84
84
  const WS = require('./workflows-store.js');
85
+ const TI = require('./task-items.js');
85
86
  const intake = require(repoScript('intake.js'));
86
87
 
87
88
  const LEDGER = 'boards.jsonl';
@@ -367,6 +368,42 @@ function rowsOfBoard(fr, board, base) {
367
368
  }
368
369
  return rows;
369
370
  }
371
+ /** A stage's To finish entries are tasks of the initiative (feedback batch 5: "Also there is workflow tasks, confusing"). Each entry of the
372
+ * current stage becomes one Board task, once: its `from` marker names the stage and the entry, so a move back and forth makes no second
373
+ * one. It runs on a move, a switch and the first read that finds none, so closing one (on the stage card, in the Tasks section or with
374
+ * `pmos task state`) is one write. Product feature's stages have no To finish list. `by` is who put the initiative on the stage.
375
+ * → the number of tasks made. */
376
+ function stageTasks(file, folded, board, row, by) {
377
+ if (!file || !row || !row.wfStage || board.self || row.ended || row.archived) return 0;
378
+ const st = (row.wfStages || []).find((s) => s.key === row.wfStage.key);
379
+ const list = st && Array.isArray(st.finish) ? st.finish.filter((f) => typeof f === 'string' && f.trim()) : [];
380
+ if (!list.length) return 0;
381
+ const have = new Set();
382
+ for (const t of folded.tasks.values()) if (t.initiative === row.id && t.from && t.from.stage === st.key) have.add(t.from.finish);
383
+ let n = 0;
384
+ for (const f of list) {
385
+ if (have.has(f)) continue;
386
+ append(file, { by: by || 'agent:unknown' }, { kind: 'task', board: board.id, task: `task-${crypto.randomBytes(5).toString('hex')}`, type: 'Task', initiative: row.id,
387
+ title: f.trim().charAt(0).toUpperCase() + f.trim().slice(1), epic: null, owner: null, state: 'To do', from: { stage: st.key, finish: f } });
388
+ have.add(f); n++;
389
+ }
390
+ return n;
391
+ }
392
+ /** Who put an initiative on its current stage: the last move or workflow switch of it on this board. */
393
+ function stagedBy(folded, boardId, id) {
394
+ const m = [...folded.moves].reverse().find((x) => x.board === boardId && x.id === id);
395
+ const own = folded.iniWf ? folded.iniWf.get(B.key(boardId, id)) : null;
396
+ return (m && m.by) || (own && own.by) || null;
397
+ }
398
+ /** The read-time pass of stageTasks over rows of one board; a fresh fold when it made any. */
399
+ function seedRows(ctx, w, fr, board, rows) {
400
+ const file = ledgerFile(ctx, w);
401
+ let n = 0;
402
+ for (const r of rows) if (r.wf && r.wf.id !== 'product-feature') n += stageTasks(file, fr.folded, board, r, stagedBy(fr.folded, board.id, r.id));
403
+ if (n) fr.folded = foldOf(ctx, w);
404
+ return n;
405
+ }
406
+
370
407
  /** The archive entry of an initiative, as a page row carries it, or null while it is not archived. */
371
408
  function archivedOf(folded, id) {
372
409
  const a = folded && folded.archives && folded.archives.get(id);
@@ -412,7 +449,7 @@ const openAsks = (folded, boardId) => [...folded.asks.values()].filter((a) => a.
412
449
  const pageAsk = (a) => ({ ...a, by: actorLib.pageName(a.by) });
413
450
  const pageMove = (m) => ({ ...m, by: actorLib.pageName(m.by) });
414
451
 
415
- /** The work items of a board: its PMOS tasks (the ledger) and, with Build and deliver on, the Jira items of its initiatives
452
+ /** The work items of a board: its PMOS tasks (the ledger and the initiatives' breakdown items) and, with Build and deliver on, the Jira items of its initiatives
416
453
  * (the ticket drafts this repository pushed, with the status of the cached readings; read-only, no dates or people). */
417
454
  function itemsOf(w, fr, board, rows) {
418
455
  const ids = new Set(rows.map((x) => x.id));
@@ -442,6 +479,7 @@ function itemsOf(w, fr, board, rows) {
442
479
  }
443
480
  }
444
481
  for (const t of fr.folded.tasks.values()) if (t.board === board.id && ids.has(t.initiative)) out.push(B.taskItem(t));
482
+ out.push(...TI.rowsOf(w.root, ids, board.id)); // one kind of task: an initiative's breakdown items show as its tasks (lib/task-items.js)
445
483
  for (const x of out) if (x.src === 'jira') x.notes = (fr.folded.ticketNotes && fr.folded.ticketNotes.get(board.id + '\u0000' + x.key)) || ''; // the PM's notes (canvas XetX1Jira)
446
484
  return B.rollupItems(out);
447
485
  }
@@ -562,6 +600,7 @@ const READS = {
562
600
  if (!base) return fail(ctx, res, 404, `no work-lane initiative ${id} in this workspace`);
563
601
  const own = r.fr.boards.find((b) => b.id === boardIdOf(base, r.fr.boards, r.fr.folded, r.w)) || r.board;
564
602
  const row = boardRow(own, base, r.fr.folded);
603
+ seedRows(ctx, r.w, r.fr, own, [row]);
565
604
  const F = r.fr.folded;
566
605
  const ownRows = own.id === r.board.id ? r.rows : rowsOfBoard(r.fr, own, r.base);
567
606
  const mine = ownRows.find((x) => x.id === id);
@@ -599,6 +638,7 @@ const READS = {
599
638
  const r = boardRead(ctx, res, url);
600
639
  if (!r) return;
601
640
  const live = r.rows.filter((x) => !x.archived); // an archived initiative leaves every list and timeline (c3-initiative-lifecycle)
641
+ seedRows(ctx, r.w, r.fr, r.board, live);
602
642
  ctx.json(res, { ok: true, ws: r.w.id, board: r.board.id, build: r.board.build, jira: r.board.jira, jiraProjects: r.board.jiraProjects, items: itemsOf(r.w, r.fr, r.board, live),
603
643
  initiatives: live.map((x) => ({ id: x.id, title: x.title, stage: x.stage, cat: x.cat, status: x.status, owner: x.owner, horizon: x.horizon, start: x.start, end: x.end, progress: x.progress, template: x.template, epics: x.epics })) });
604
644
  },
@@ -690,7 +730,31 @@ function moveOnWorkflow(ctx, res, body, g, p, own) {
690
730
  for (let i = a + 1; i < b; i++) { const sk = before.wfStages[i]; if (sk && sk.status !== 'skipped' && sk.when.mode !== 'optional') warnings.push('Skipped ' + sk.name); }
691
731
  if (!before.anchor) warnings.push('No anchor');
692
732
  append(p.file, g.actor, { kind: 'move', board: p.board.id, id: body.id, from: before.wfStage.key, to: t.key, why: body.why || '', warnings });
693
- ctx.json(res, { ok: true, row: boardRow(p.board, b0, foldOf(ctx, p.w)), warnings });
733
+ const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
734
+ const made = stageTasks(p.file, f1, p.board, row, g.actor.by); // the new stage's To finish entries, as tasks
735
+ ctx.json(res, { ok: true, row, warnings, ...(made ? { tasksMade: made } : {}) });
736
+ }
737
+
738
+ /** A breakdown item named as a task (lib/task-items.js), when its initiative is on this board; answers and returns null when not. */
739
+ function itemOnBoard(ctx, res, p, id) {
740
+ const it = TI.isItemId(id) ? TI.itemOf(p.w.root, id) : null;
741
+ if (!it) { fail(ctx, res, 404, `no PMOS task ${id} on this board`); return null; }
742
+ const base = needRows(ctx, res, p.w);
743
+ if (!base) return null;
744
+ const b0 = base.find((r) => r.id === it.initiative);
745
+ if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) { fail(ctx, res, 404, `no PMOS task ${id} on this board`); return null; }
746
+ return it;
747
+ }
748
+ /** Writes an item's lines (r: TI.stateEvents or TI.editEvents) as the task routes do and answers the item as a task. */
749
+ function itemWrite(ctx, res, p, it, r, g, extra = {}) {
750
+ if (r.error) return fail(ctx, res, 400, r.error);
751
+ if (!r.same) {
752
+ const w = TI.write(p.w.root, r.events, g.actor, g.cli || null);
753
+ if (!w.ok) return fail(ctx, res, w.status || 400, w.error);
754
+ }
755
+ const ids = new Set([it.initiative]);
756
+ const row = TI.rowsOf(p.w.root, ids, p.board.id).find((x) => x.uid === it.id) || { ...TI.rowsOf(p.w.root, ids, p.board.id)[0], uid: it.id, ref: it.id, title: it.title, status: "Won't do" };
757
+ ctx.json(res, { ok: true, item: B.rollupItems([row])[0], ...extra });
694
758
  }
695
759
 
696
760
  const WRITES = {
@@ -869,8 +933,9 @@ const WRITES = {
869
933
  if (body.to != null) { const t = WF.stageByRef(to, body.to); if (!t) return fail(ctx, res, 400, `"${body.to}" is not a stage of ${to.name}`); target = t.key; }
870
934
  const moved = { from: before.wfStage.key, to: target };
871
935
  append(p.file, g.actor, { kind: 'ini-wf', board: p.board.id, id: body.id, wf: to.id, from: from.id, moved, why: body.why ? body.why.trim() : '', ...(body.pmos === true ? { pmos: true } : {}) });
872
- const row = boardRow(p.board, b0, foldOf(ctx, p.w));
873
- ctx.json(res, { ok: true, row, moved });
936
+ const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
937
+ const made = stageTasks(p.file, f1, p.board, row, g.actor.by);
938
+ ctx.json(res, { ok: true, row, moved, ...(made ? { tasksMade: made } : {}) });
874
939
  },
875
940
  '/api/boards/wontdo': (ctx, res, body, g) => {
876
941
  const p = postFrame(ctx, res, body);
@@ -958,16 +1023,18 @@ const WRITES = {
958
1023
  for (const k of ['start', 'due']) if (body[k] != null && body[k] !== '' && !/^\d{4}-\d{2}-\d{2}$/.test(String(body[k]))) return fail(ctx, res, 400, `${k} is a day, YYYY-MM-DD`);
959
1024
  if (body.owner != null && body.owner !== '' && !ONE_LINE(body.owner, 80)) return fail(ctx, res, 400, 'owner is one line of at most 80 characters');
960
1025
  if (body.epic != null && body.epic !== '' && !ONE_LINE(body.epic, 80)) return fail(ctx, res, 400, 'epic is one line of at most 80 characters');
1026
+ if (body.notes != null && (typeof body.notes !== 'string' || body.notes.length > 4000)) return fail(ctx, res, 400, 'notes are text of at most 4000 characters');
1027
+ if (body.start && body.due && body.start > body.due) return fail(ctx, res, 400, 'the start is after the due day');
961
1028
  if (!p.file) return fail(ctx, res, 409, NO_STATE);
962
1029
  const base = needRows(ctx, res, p.w);
963
1030
  if (!base) return;
964
1031
  const b0 = base.find((r) => r.id === body.initiative);
965
1032
  if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) return fail(ctx, res, 404, `no initiative ${body.initiative} on this board`);
966
1033
  const id = `task-${crypto.randomBytes(5).toString('hex')}`;
967
- const start = body.start || B.shiftDay(today(), 1);
1034
+ const start = body.start || (body.due && body.due < B.shiftDay(today(), 1) ? body.due : B.shiftDay(today(), 1));
968
1035
  const due = body.due || B.shiftDay(start, 7);
969
1036
  append(p.file, g.actor, { kind: 'task', board: p.board.id, task: id, type: body.type || 'Task', initiative: body.initiative, title: body.title.trim(), epic: body.epic ? String(body.epic).trim() : null,
970
- owner: body.owner ? String(body.owner).trim() : actorLib.pageName(g.actor.by), state: 'To do', start, due });
1037
+ owner: body.owner ? String(body.owner).trim() : actorLib.pageName(g.actor.by), state: 'To do', start, due, ...(body.notes && body.notes.trim() ? { notes: body.notes.replace(/\s+$/, '') } : {}) });
971
1038
  const t = B.taskOf(B.fold(readLedger(ctx, p.w)), id);
972
1039
  ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t)])[0] });
973
1040
  },
@@ -975,8 +1042,15 @@ const WRITES = {
975
1042
  const p = postFrame(ctx, res, body);
976
1043
  if (!p) return;
977
1044
  const t = B.taskOf(p.fr.folded, body.task);
978
- if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
979
1045
  const state = B.taskState(body.state); // the five task states; an old 'In review' is In progress
1046
+ if (!t && TI.isItemId(body.task)) {
1047
+ // a breakdown item is a task too (one list, feedback batch 5): its state is written to the plan-items ledger
1048
+ if (!state) return fail(ctx, res, 400, `state is one of ${B.TASK_STATES.join(', ')}`);
1049
+ const it = itemOnBoard(ctx, res, p, body.task);
1050
+ if (!it) return;
1051
+ return itemWrite(ctx, res, p, it, TI.stateEvents(it, state, body.why), g);
1052
+ }
1053
+ if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
980
1054
  if (!state) return fail(ctx, res, 400, `state is one of ${B.TASK_STATES.join(', ')}`);
981
1055
  if (!p.file) return fail(ctx, res, 409, NO_STATE);
982
1056
  append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, state, why: typeof body.why === 'string' && body.why.trim() ? body.why.trim().slice(0, 300) : 'status move' });
@@ -999,8 +1073,13 @@ const WRITES = {
999
1073
  const p = postFrame(ctx, res, body);
1000
1074
  if (!p) return;
1001
1075
  const t = B.taskOf(p.fr.folded, body.task);
1002
- if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
1003
1076
  if (!ONE_LINE(body.title, 200)) return fail(ctx, res, 400, 'title is one line of 1 to 200 characters');
1077
+ if (!t && TI.isItemId(body.task)) {
1078
+ const it = itemOnBoard(ctx, res, p, body.task);
1079
+ if (!it) return;
1080
+ return itemWrite(ctx, res, p, it, TI.editEvents(it, { title: body.title }), g, { from: it.title });
1081
+ }
1082
+ if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
1004
1083
  if (!p.file) return fail(ctx, res, 409, NO_STATE);
1005
1084
  append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, title: body.title.trim(), why: 'renamed' });
1006
1085
  const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
@@ -1010,8 +1089,17 @@ const WRITES = {
1010
1089
  // the task Viewer edits in place (canvas XetX1Rest, XetX1Dates): each change saves at once; Undo sends `from` back
1011
1090
  const p = postFrame(ctx, res, body);
1012
1091
  if (!p) return;
1013
- const t = B.taskOf(p.fr.folded, body.task);
1014
- if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
1092
+ const t0 = B.taskOf(p.fr.folded, body.task);
1093
+ let t = t0;
1094
+ if (!t0 && TI.isItemId(body.task)) {
1095
+ // a breakdown item: the same checks, on the item's own fields (it stays on its initiative)
1096
+ t = itemOnBoard(ctx, res, p, body.task);
1097
+ if (!t) return;
1098
+ if (body.initiative != null && body.initiative !== t.initiative) return fail(ctx, res, 409, 'a breakdown item stays on its initiative');
1099
+ t = { ...t, owner: TI.ownerName(t.owner), notes: t.note || '', item: true };
1100
+ delete body.initiative;
1101
+ }
1102
+ if (!t || (!t.item && t.board !== p.board.id)) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
1015
1103
  const ev = {}, from = {};
1016
1104
  if (body.owner != null) { if (body.owner !== '' && !ONE_LINE(body.owner, 80)) return fail(ctx, res, 400, 'owner is one line of at most 80 characters'); ev.owner = String(body.owner).trim(); from.owner = t.owner || ''; }
1017
1105
  if (body.notes != null) { if (typeof body.notes !== 'string' || body.notes.length > 4000) return fail(ctx, res, 400, 'notes are text of at most 4000 characters'); ev.notes = body.notes.replace(/\s+$/, ''); from.notes = t.notes || ''; }
@@ -1026,6 +1114,7 @@ const WRITES = {
1026
1114
  ev.initiative = body.initiative; from.initiative = t.initiative;
1027
1115
  }
1028
1116
  if (!Object.keys(ev).length) return fail(ctx, res, 400, 'nothing to change: send owner, notes, start, due or initiative');
1117
+ if (t.item) return itemWrite(ctx, res, p, t, TI.editEvents(t, ev), g, { from });
1029
1118
  if (!p.file) return fail(ctx, res, 409, NO_STATE);
1030
1119
  append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, ...ev, why: 'edited ' + Object.keys(ev).join(', ') });
1031
1120
  const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
@@ -1046,13 +1135,17 @@ const WRITES = {
1046
1135
  '/api/boards/tasks/reschedule': (ctx, res, body, g) => {
1047
1136
  const p = postFrame(ctx, res, body);
1048
1137
  if (!p) return;
1049
- const t = B.taskOf(p.fr.folded, body.task);
1050
- if (!t || t.board !== p.board.id) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
1138
+ const t0 = B.taskOf(p.fr.folded, body.task);
1139
+ const it = !t0 && TI.isItemId(body.task) ? itemOnBoard(ctx, res, p, body.task) : null;
1140
+ if (!t0 && TI.isItemId(body.task) && !it) return;
1141
+ const t = t0 || (it ? { start: it.start, due: it.due } : null);
1142
+ if (!t || (t0 && t0.board !== p.board.id)) return fail(ctx, res, 404, `no PMOS task ${body.task} on this board`);
1051
1143
  const days = Number(body.days);
1052
1144
  if (!Number.isInteger(days) || days === 0 || Math.abs(days) > 730) return fail(ctx, res, 400, 'days is a whole number of days, not 0, at most 730 either way');
1053
- if (!p.file) return fail(ctx, res, 409, NO_STATE);
1054
1145
  const start = B.shiftDay(t.start || B.shiftDay(t.due || today(), -7), days);
1055
1146
  const due = B.shiftDay(t.due || B.shiftDay(t.start || today(), 7), days);
1147
+ if (it) return itemWrite(ctx, res, p, it, TI.editEvents(it, { start, due }), g);
1148
+ if (!p.file) return fail(ctx, res, 409, NO_STATE);
1056
1149
  append(p.file, g.actor, { kind: 'task-update', board: p.board.id, task: t.id, start, due, why: `rescheduled ${days > 0 ? '+' : ''}${days} days` });
1057
1150
  const t2 = B.taskOf(B.fold(readLedger(ctx, p.w)), t.id);
1058
1151
  ctx.json(res, { ok: true, item: B.rollupItems([B.taskItem(t2)])[0] });
@@ -1190,6 +1283,8 @@ function move(ctx, body, g) { return writeAs(ctx, '/api/boards/move', body, g);
1190
1283
  function switchWorkflow(ctx, body, g) { return writeAs(ctx, '/api/boards/ini-wf', body, g); }
1191
1284
  /** A Board task's state, by the same function POST /api/boards/tasks/state runs (`pmos task state`). body: { ws, board, task, state, why? }. */
1192
1285
  function taskState(ctx, body, g) { return writeAs(ctx, '/api/boards/tasks/state', body, g); }
1286
+ /** A new Board task, by the same function as the page's Add a task (POST /api/boards/tasks/add; `pmos task add`). body: { ws, board, initiative, title, start?, due?, owner? }. */
1287
+ function taskAdd(ctx, body, g) { return writeAs(ctx, '/api/boards/tasks/add', body, g); }
1193
1288
 
1194
1289
  /** The workflow one initiative runs and where it stands in it, as the Board's row has it (boardRow: wf, wfStage, wfStages, ended), with the
1195
1290
  * board it is on. For `pmos workflow of|move|switch` and the initiative chat's opening (bug 2026-10-25: an agent that could not see the
@@ -1205,6 +1300,14 @@ function initiativeWorkflow(ctx, w, id) {
1205
1300
  return { ok: true, board, row: boardRow(board, b0, fr.folded) };
1206
1301
  }
1207
1302
 
1303
+ /** stageTasks for one initiative outside HTTP (`pmos task list|state`): its current stage's To finish entries made tasks once. → the number made, or 0. */
1304
+ function seedInitiative(ctx, w, id) {
1305
+ const r = initiativeWorkflow(ctx, w, id);
1306
+ if (!r.ok || !r.row.wf || r.row.wf.id === 'product-feature') return 0;
1307
+ const folded = foldOf(ctx, w);
1308
+ return stageTasks(ledgerFile(ctx, w), folded, r.board, r.row, stagedBy(folded, r.board.id, id));
1309
+ }
1310
+
1208
1311
  /** The board of each initiative of a workspace, for other routes (Reports): { boards: [{ id, title }], of(id) → board id }.
1209
1312
  * Rows still being read fall back to the ledger's assignment, else the default board. */
1210
1313
  function boardIndex(ctx, w) {
@@ -1269,4 +1372,4 @@ function meetingBoards(ctx) {
1269
1372
  return { list, detail };
1270
1373
  }
1271
1374
 
1272
- module.exports = { prefixes: ['/api/boards'], handle, move, switchWorkflow, taskState, initiativeWorkflow, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
1375
+ module.exports = { prefixes: ['/api/boards'], handle, move, switchWorkflow, taskState, taskAdd, initiativeWorkflow, seedInitiative, stageTasks, itemsOf, boardIndex, appendScanAsk, scanDeclineSignal, createAndPlace, ledgerFile, append, frameFor, boardIdOf, meetingBoards, boardsOf, baseRows, boardRow, workflowRowOf, foldOf, portfolio, SELF_REFUSAL, NO_STATE };
@@ -213,7 +213,20 @@ module.exports = {
213
213
  const tok = req.headers && req.headers['x-pmos-session'];
214
214
  const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
215
215
  if (!who) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
216
- ctx.json(res, Goal.askToolReply());
216
+ const key = ctx.runtimeDir && Goal.keyOfSession(ctx.runtimeDir, who.session, Ag.CHATS);
217
+ ctx.json(res, Goal.askToolReply(key ? Goal.goalOf(ctx.runtimeDir, key) : null));
218
+ return true;
219
+ }
220
+ if (url.pathname === '/api/briefing-premium/goal-tool') {
221
+ // Claude Code's PreToolUse hook for every tool in a chat session: a started goal runs without permission prompts. Any other chat asks as usual.
222
+ if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
223
+ const got = await ctx.readJson(req);
224
+ const tok = req.headers && req.headers['x-pmos-session'];
225
+ const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
226
+ if (!who || !ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
227
+ const key = Goal.keyOfSession(ctx.runtimeDir, who.session, Ag.CHATS);
228
+ const body = got.ok && got.body && typeof got.body === 'object' ? got.body : {};
229
+ ctx.json(res, key ? Goal.goalToolReply(Goal.goalOf(ctx.runtimeDir, key), body.tool_name) : {});
217
230
  return true;
218
231
  }
219
232
  if (url.pathname === '/api/briefing-premium/seen') {
@@ -1,33 +1,43 @@
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>" [--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)
5
7
  * pmos task list <initiative> [--all] its open tasks (To do, In progress); --all adds Done, Won't do and Archived
6
8
  * 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.
9
+ * set each task's state: To do, In progress, Done, Won't do or Archived, by the same function as the Board's press
10
+ * (lib/routes-boards.js taskState, POST /api/boards/tasks/state), with the agent as the writer.
9
11
  *
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. */
12
+ * 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
13
+ * current stage's To finish entries, which become tasks the first time they are read (routes-boards stageTasks). `state` closes any of
14
+ * them. A task has no workflow stage: its only stage is its state. The initiative's workflow stage is `pmos workflow of|move`. Who wrote a
15
+ * line is the call path (lib/actor.js), never an argument. Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
13
16
  const path = require('path');
14
17
  const { execFileSync } = require('child_process');
15
18
  const actorLib = require('./actor.js');
16
19
  const driver = require('./driver.js');
17
20
  const { repoScript } = require('./repo-script.js');
18
21
  const B = require(repoScript('boards.js'));
22
+ const TI = require('./task-items.js');
23
+ const rowsLib = require('./initiative-rows.js');
19
24
 
20
- const COMMANDS = { task: ['list', 'state'] };
25
+ const COMMANDS = { task: ['add', 'list', 'state'] };
21
26
  const USAGE = [
22
- 'usage: pmos task list|state — an initiative\'s Board tasks',
27
+ 'usage: pmos task add|list|state — an initiative\'s tasks, the ones the PM sees in its Tasks section',
28
+ ' pmos task add <initiative> "<title>" [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]',
29
+ ' Add a task. Every new task goes here; pmos item add is the older breakdown record.',
23
30
  ' pmos task list <initiative> [--all] its open tasks; --all adds Done, Won\'t do and Archived',
24
31
  ' 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.',
32
+ ' 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.',
33
+ ' Give --why with Done: it is the evidence the PM reads.',
34
+ ' There is one kind of task: Board tasks, breakdown items and the current stage\'s To finish tasks all list and close here.',
35
+ ' A task has no workflow stage: its only stage is its state. Move the initiative with pmos workflow move.',
27
36
  ' every command: [--json] [--root <dir>]. Nothing is sent.',
28
37
  ];
29
38
  const BOOL = new Set(['json', 'help', 'all']);
30
- const VALUE = new Set(['to', 'why', 'root']);
39
+ const VALUE = new Set(['to', 'why', 'root', 'due', 'start', 'owner', 'notes']);
40
+ const ONLY = { add: ['due', 'start', 'owner', 'notes'], list: ['all'], state: ['to', 'why'] };
31
41
  const OPEN = new Set(['To do', 'In progress']);
32
42
  /** The PM's words for a state: any case, with or without the apostrophe or the space. */
33
43
  function stateOf(s) {
@@ -61,6 +71,12 @@ function boardsCtx(root, stateDir) {
61
71
  return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => stateDir, selfRoot: path.resolve(__dirname, '..', '..') } };
62
72
  }
63
73
  const line = (t) => `${t.id} · ${t.state} · ${t.title}${t.kind === 'Epic' ? ' (epic)' : ''}${t.due ? ' · due ' + t.due : ''}`;
74
+ /** The workflow row of an initiative, deriving the rows when they are still being read. */
75
+ function rowOf(boards, ctx, w, id) {
76
+ let r = boards.initiativeWorkflow(ctx, w, id);
77
+ if (r.pending) { try { rowsLib.deriveNow(w.root); } catch { /* answered below */ } r = boards.initiativeWorkflow(ctx, w, id); }
78
+ return r;
79
+ }
64
80
 
65
81
  async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isTTY, env } = {}) {
66
82
  const args = argv[0] === 'task' ? argv.slice(1) : argv.slice();
@@ -69,40 +85,72 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
69
85
  const json = !!flags.json;
70
86
  if (!verb || verb === 'help' || verb === '--help' || verb === '-h' || flags.help) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
71
87
  if (!COMMANDS.task.includes(verb)) { say(`unknown task command "${verb}" — one of ${COMMANDS.task.join(', ')}`); return 2; }
88
+ if (verb === 'add' && pos.length > 2) { say('usage: pmos task add <initiative> "<title>" [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]'); return 2; }
72
89
  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
90
  for (const k of Object.keys(flags)) {
74
91
  if (!BOOL.has(k) && !VALUE.has(k)) { say(`unknown option --${k}`); return 2; }
75
92
  if (VALUE.has(k) && flags[k] === '') { say(`--${k} needs a value`); return 2; }
76
93
  }
77
94
  const fail = (error, code = 1) => { if (json) say(JSON.stringify({ ok: false, error })); else say(`✗ ${error}`); return code; };
95
+ 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);
96
+ if (flags.all && verb !== 'list') return fail(`--all is not an option of ${verb}`, 2);
78
97
  const root = flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd);
79
- const stateDir = driver.stateDirOf(root, { create: verb === 'state' });
98
+ const stateDir = driver.stateDirOf(root, { create: verb !== 'list' });
80
99
  if (!stateDir) return fail('this repository has no PMOS state folder (pmos/state, state or .pmos)');
81
100
  const boards = require('./routes-boards.js');
82
101
  const { w, ctx } = boardsCtx(root, stateDir);
83
102
 
103
+ const cli = { isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env };
104
+ const g = { ok: true, actor: actorLib.fromCli(cli), cli };
105
+ /** Every task of an initiative: its Board tasks (on any board of this workspace) and its breakdown items. */
106
+ const tasksOf = (id) => {
107
+ const r = rowOf(boards, ctx, w, id);
108
+ const board = r.ok ? r.board.id : null;
109
+ const own = [...(boards.foldOf(ctx, w).tasks || new Map()).values()].filter((t) => t.initiative === id);
110
+ 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' }));
111
+ return own.concat(items);
112
+ };
113
+
114
+ if (verb === 'add') {
115
+ const [id, title] = pos;
116
+ if (!id || title === undefined) { say('usage: pmos task add <initiative> "<title>" [--due YYYY-MM-DD] [--start YYYY-MM-DD] [--owner <who>] [--notes <text>]'); return 2; }
117
+ const r = rowOf(boards, ctx, w, id);
118
+ if (!r.ok) return fail(r.error);
119
+ const body = { ws: w.id, board: r.board.id, initiative: id, title };
120
+ for (const k of ['due', 'start', 'owner', 'notes']) if (flags[k] !== undefined) body[k] = flags[k];
121
+ const a = boards.taskAdd(ctx, body, g);
122
+ if (!a.body || a.body.ok !== true) return fail((a.body && a.body.error) || 'the write was refused');
123
+ const t = a.body.item;
124
+ 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 } }));
125
+ else say(`✓ added ${t.uid} · ${t.status} · ${t.title}${t.end ? ' · due ' + t.end : ''}. The initiative's Tasks section shows it. Nothing was sent.`);
126
+ return 0;
127
+ }
128
+
84
129
  if (verb === 'list') {
85
130
  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);
131
+ try { boards.seedInitiative(ctx, w, id); } catch { /* the To finish tasks are made on the next read */ }
132
+ const all = tasksOf(id);
88
133
  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; }
134
+ 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, ...(t.from ? { from: t.from } : {}) })) })); return 0; }
135
+ if (!shown.length) { say(all.length ? `No open task on ${id}. --all lists the ${all.length} closed.` : `No task on ${id}.`); return 0; }
91
136
  for (const t of shown) say(line(t));
92
137
  return 0;
93
138
  }
94
139
  // state
95
140
  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
141
  const to = stateOf(flags.to);
98
142
  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
143
  const folded = boards.foldOf(ctx, w);
102
144
  const done = [], refused = [];
103
145
  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; }
146
+ let t = B.taskOf(folded, id);
147
+ if (!t && TI.isItemId(id)) {
148
+ // a breakdown item: the Board's press writes it to the plan-items ledger (lib/task-items.js)
149
+ const it = TI.itemOf(root, id);
150
+ const r = it ? rowOf(boards, ctx, w, it.initiative) : null;
151
+ if (it && r && r.ok) t = { id, board: r.board.id, title: it.title, state: TI.STATE_OF[it.state] };
152
+ }
153
+ if (!t) { refused.push({ task: id, error: `no task ${id}; pmos task list <initiative> names them` }); continue; }
106
154
  if (t.state === to) { done.push({ task: id, title: t.title, state: to, same: true }); continue; }
107
155
  const r = boards.taskState(ctx, { ws: w.id, board: t.board, task: id, state: to, ...(flags.why ? { why: flags.why } : {}) }, g);
108
156
  if (!r.body || r.body.ok !== true) refused.push({ task: id, error: (r.body && r.body.error) || 'the write was refused' });
@@ -112,7 +160,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
112
160
  else {
113
161
  for (const d of done) say(d.same ? ` ${d.task} was already ${to}: ${d.title}` : `✓ ${d.task} is ${to}: ${d.title}`);
114
162
  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.');
163
+ if (done.some((d) => !d.same)) say(' The page shows it. Nothing was sent.');
116
164
  }
117
165
  return refused.length ? 1 : 0;
118
166
  }
@@ -0,0 +1,86 @@
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
+ }
55
+ return out;
56
+ }
57
+
58
+ /** → { events } | { same: true } | { error } */
59
+ function stateEvents(it, state, why) {
60
+ if (state === "Won't do" || state === 'Archived') return { events: [{ ev: 'withdrawn', item: it.id }] };
61
+ const to = MOVE_TO[state];
62
+ if (!to) return { error: `state is one of ${Object.keys(MOVE_TO).concat("Won't do", 'Archived').join(', ')}` };
63
+ if (STATE_OF[it.state] === state) return { same: true };
64
+ const ev = { ev: 'moved', item: it.id, to };
65
+ // 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)
66
+ if (to === 'done' && typeof why === 'string' && why.trim()) ev.evidence = { kind: 'note', ref: why.trim().replace(/\s+/g, ' ').slice(0, 200) };
67
+ return { events: [ev] };
68
+ }
69
+
70
+ /** edit: { title?, owner?, notes?, start?, due? } with '' clearing a day or the notes. → { events } | { error } */
71
+ function editEvents(it, edit) {
72
+ const fields = {};
73
+ if (edit.title != null) fields.title = String(edit.title).trim();
74
+ if (edit.owner != null) fields.owner = ownerOf(edit.owner);
75
+ if (edit.notes != null) fields.note = edit.notes === '' ? null : String(edit.notes).slice(0, 1000);
76
+ for (const k of ['start', 'due']) if (edit[k] != null) fields[k] = edit[k] === '' ? null : String(edit[k]);
77
+ if (!Object.keys(fields).length) return { error: 'nothing to change' };
78
+ return { events: [{ ev: 'set', item: it.id, fields }] };
79
+ }
80
+
81
+ function write(root, events, actor, cli) {
82
+ if (cli) return planItems.appendFromCli(root, events, cli);
83
+ return planItems.appendFromUi(root, events, { actor: actor && actor.by ? { by: actor.by, via: 'ui' } : undefined });
84
+ }
85
+
86
+ module.exports = { STATE_OF, isItemId, ownerName, ownerOf, itemOf, rowsOf, stateEvents, editEvents, write };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.414.0",
3
+ "version": "0.415.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.415.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.415.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",
@@ -5,7 +5,8 @@
5
5
  * mount(o) once, from premium-board.js. o: { M() the model, statusOf(r), fmt(iso), md(date), ago(iso), segHtml(r), barHtml(o),
6
6
  * grill(id) the open first questions, dayTitle(track) the current step's tooltip, usual(track) the usual days in it, rowOf(key), pageHref(r), askHref(r, q), refreshJira(), send(r) the Send to Jira sheet, acts(r, btn) the row
7
7
  * actions popover, grillOpen(r, btn), onShow(key, from) / onHide() so the page marks the row the item came from,
8
- * programOf(r) the program it is in or null, turnProgram(r) "Turn into a program" (POST /api/programs/turn) }
8
+ * programOf(r) the program it is in or null, turnProgram(r) "Turn into a program" (POST /api/programs/turn),
9
+ * setTask(r, uid, state) a task's state (POST /api/boards/tasks/state) }
9
10
  * openIni(r, from) the initiative (XipB, feedback batch 4 item 1): the shell's header (icon, the title once, Discuss in chat, ⋯, open
10
11
  * wide, close); the summary card: the status, ONE sentence that says why (whyOf), where the progress number comes from,
11
12
  * the owner and the workflow; the stage card: the current stage of the initiative's OWN workflow, its ladder, the
@@ -102,13 +103,29 @@ function exitSteps(r, L) {
102
103
  const t = r.track || {};
103
104
  if (L.own) {
104
105
  const st = L.stage || {}, out = [];
105
- for (const f of Array.isArray(st.finish) ? st.finish : []) if (f) out.push({ state: 'wait', label: f.charAt(0).toUpperCase() + f.slice(1) });
106
+ // each To finish entry is a task of the initiative (feedback batch 5): done when that task is closed, and ✓ closes it here
107
+ for (const f of Array.isArray(st.finish) ? st.finish : []) {
108
+ if (!f) continue;
109
+ const k = (r.tasks || []).find((x) => x.from && x.from.stage === st.key && x.from.finish === f);
110
+ const label = k ? k.title : f.charAt(0).toUpperCase() + f.slice(1);
111
+ out.push(k && CLOSED.has(k.status) ? { state: 'done', label } : { state: 'wait', label, ...(k ? { act: doneAct(k) } : {}) });
112
+ }
106
113
  const o = st.output || {};
107
114
  if (o.name && !out.some((x) => x.label.toLowerCase() === String(o.name).toLowerCase())) out.push(o.kind === 'signoff' ? { state: 'you', label: 'Your sign-off: ' + o.name } : { state: 'wait', label: o.name.charAt(0).toUpperCase() + o.name.slice(1) });
108
115
  return out;
109
116
  }
110
117
  return (t.segs || []).filter((s) => s.name).map((s) => (s.cls === 'dn' ? { state: 'done', label: s.name } : s.cls === 'yo' ? { state: 'you', label: s.name, note: s.st || '' } : { state: 'wait', label: s.name, note: s.st && s.st !== 'to do' ? s.st : '' }));
111
118
  }
119
+ const CLOSED = new Set(['Done', "Won't do", 'Archived']);
120
+ const doneAct = (k) => ({ attr: `data-xb="tkdone:${esc(k.uid)}"`, icon: 'check', label: 'Mark done: ' + k.title });
121
+ /** The initiative's tasks (feedback batch 5, one list): its Board tasks, its breakdown items and its stage's To finish tasks, the open ones
122
+ * each with ✓, then how many are done. The Tasks section of the initiative page lists and edits them all. */
123
+ function tasksHtml(r) {
124
+ const T = r.tasks || [], open = T.filter((k) => !CLOSED.has(k.status)), done = T.length - open.length;
125
+ const note = (k) => [k.status === 'In progress' ? 'In progress' : '', k.end ? 'due ' + O.fmt(k.end) : '', k.owner && !/^pm:/.test(k.owner) ? k.owner : ''].filter(Boolean).join(' · ');
126
+ return stepsHtml(open.map((k) => ({ state: 'wait', label: k.title, note: note(k), act: doneAct(k) })), { cls: 'xv-sl', label: 'Tasks' })
127
+ + (done ? lr({ mk: 'done', title: esc(done + ' done') }) : '');
128
+ }
112
129
  const PLUS = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M5 12h14"/></svg>';
113
130
  /** The stage card (XipB; the Home stage card D look): the current stage of the initiative's own workflow, where it stands ("5 of 7 · day 0
114
131
  * of ~14"), its ladder, then what finishes it: the tickets on Build and Deliver, else the exit steps, else "No exit steps on record" with
@@ -180,6 +197,8 @@ function planHtml(r) {
180
197
  }
181
198
  function iniSections(r) {
182
199
  const it = TI(r), S = [];
200
+ const T = r.tasks || [], open = T.filter((k) => !CLOSED.has(k.status)).length;
201
+ if (T.length) S.push({ id: 'tasks', title: 'Tasks', count: open ? open + ' open' : T.length + ' done', open: open > 0, render: () => tasksHtml(r) });
183
202
  const d = ((it && it.drafted) || []).filter((x) => !x.key);
184
203
  if (d.length) S.push({ id: 'drafted', title: 'Drafted in PMOS', count: d.length, render: () => draftedHtml(d, (it && it.gate) || {}) });
185
204
  const dr = (it && it.drift) || [];
@@ -222,6 +241,7 @@ function wire(body, key) {
222
241
  if (act === 'grill') O.grillOpen(r, a);
223
242
  else if (act === 'commit') O.send(r); // the Commit of drafted tickets opens the Send sheet (tk-send.js), the one path to Jira
224
243
  else if (act === 'drift') location.assign(O.askHref(r, a.dataset.q || ''));
244
+ else if (act.startsWith('tkdone:') && O.setTask) O.setTask(r, act.slice(7), 'Done');
225
245
  else if (act.startsWith('doc:')) O.viewDoc(act.slice(4));
226
246
  };
227
247
  }
@@ -33,7 +33,8 @@ export function stepRows(h, o = {}) {
33
33
  for (const x of (h && h.rest) || []) {
34
34
  if (x.kind === 'you') { you.push({ state: 'you', label: x.label, note: x.note, go: first ? { attr: 'data-hm-go', label: x.label + '. Open it' } : null, attr: first ? '' : 'data-hm-go', aria: x.label + '. Open it' }); first = false; }
35
35
  else if (x.kind === 'agent' && o.run && !ran) { ran = true; run.push({ state: 'run', label: x.label, note: runNote(), owner: { kind: 'claude', live: true } }); }
36
- else if (x.kind === 'agent') wait.push({ state: 'wait', label: x.label, note: x.note, owner: { kind: 'claude' } });
36
+ else if (x.kind === 'agent') wait.push({ state: 'wait', label: x.label, note: x.note, owner: { kind: 'claude' },
37
+ ...(x.task ? { act: { attr: `data-hi-chk="${esc(x.task)}"`, icon: 'check', label: 'Mark done: ' + x.label } } : {}) }); // a stage task closes here (home-ini.js hiChk)
37
38
  else if (x.kind === 'risk') risk.push({ state: 'risk', label: x.label, note: x.note, noteWarn: true });
38
39
  else if (x.kind === 'jira') wait.push({ state: 'wait', label: x.label, owner: { kind: 'jira' }, jira: x.jt ? { done: x.jd, total: x.jt } : null });
39
40
  else wait.push({ state: 'wait', label: x.label, note: x.note });
@@ -87,7 +88,7 @@ export function stageCardHtml(h, o = {}) {
87
88
  const fold = R.done.length ? { n: R.done.length, names: o.doneOpen ? '' : R.done.map((x) => x.label).join(', '), open: !!o.doneOpen, attr: 'data-hm-done' } : null;
88
89
  const steps = (o.doneOpen ? R.done : []).concat(R.shown);
89
90
  const list = stepsHtml(steps, { label: h.checkTitle, cls: 'hm-scl', fold, more: R.more > 0 ? { n: R.more, attr: 'data-hm-more' } : null, tail: o.tail || '' });
90
- const none = !R.done.length && !R.open.length ? '<p class="hm-none">No exit step is on record for this stage.</p>' : '';
91
+ const none = !R.done.length && !R.open.length ? '<p class="hm-none">No task is on record for this stage.</p>' : '';
91
92
  const turn = R.open.some((x) => x.state === 'you') ? 'you' : h.turn;
92
93
  return `<section class="hm-card hm-pcard hm-sc" aria-label="${esc(o.title || '')}">`
93
94
  + `<div class="hm-box hm-scb ${esc(turn)}"><div class="hm-sch"><b>${esc(h.cur || 'No stage')}</b>${R.done.length + R.open.length ? `<span class="of">${esc(h.doneOf)}</span>` : ''}`
@@ -784,6 +784,15 @@ async function loadWorkflows() {
784
784
  let r = null; try { r = await (await fetch('/api/workflows' + (M.board.ws ? '?ws=' + encodeURIComponent(M.board.ws) : ''), { credentials: 'same-origin' })).json(); } catch { r = null; }
785
785
  if (r && r.ok && Array.isArray(r.workflows)) { WF.setDefs(r.workflows); drawInit(); }
786
786
  }
787
+ /** A task's state from the initiative panel (✓ on its Tasks or its stage card); Undo puts the old state back. */
788
+ async function setTask(r, uid, state) {
789
+ const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid };
790
+ const res = await pmPost('/api/boards/tasks/state', { ...body, state }).catch(() => null);
791
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
792
+ // a breakdown item closed as Won't do is withdrawn, which the ledger cannot undo; Done can go back
793
+ say(state + ': ' + (k ? k.title : uid) + '.', k && state === 'Done' ? async () => { const u = await pmPost('/api/boards/tasks/state', { ...body, state: k.status }).catch(() => null); say(u && u.ok ? 'Back to ' + k.status + '.' : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
794
+ load();
795
+ }
787
796
  const viewDoc = (path) => { const a = document.createElement('button'); a.dataset.doc = path; a.hidden = true; document.body.appendChild(a); a.click(); a.remove(); };
788
797
  const anchors = async (ws, board) => { try { const r = await (await fetch('/api/boards/anchors?ws=' + encodeURIComponent(ws || M.board.ws || '') + '&board=' + encodeURIComponent(board || M.board.id || ''), { credentials: 'same-origin' })).json(); return r && r.ok ? r.anchors || [] : []; } catch { return []; } };
789
798
  const openIniAny = (r) => openIni(r, $('#bdBell'), 'track');
@@ -797,7 +806,7 @@ Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePa
797
806
  BI.mount({ M: () => M, statusOf, dayTitle, usual: usualOf, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
798
807
  send: (r) => import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say })),
799
808
  acts: (r, b) => Acts.open.row(r, b), grillOpen: (r, b) => Asks.openGrill(r.id, r.title, (r.track && r.track.label) || 'Triage', false, b), onShow: iniShown, onHide: iniHidden,
800
- programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), rename: renameIni, turnProgram });
809
+ programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), rename: renameIni, setTask, turnProgram });
801
810
  /** Tap the title to rename (canvas RnAIni): the list, the Timeline and the panel show the new name at once; Undo is the same press.
802
811
  * The Jira box opens Home's chat about it with the request typed, for the PM to send (PMOS holds no Jira credential, D53). */
803
812
  // a name the PM just saved holds over a read that predates it (the board derives off the request path) until a read says it too
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * THE RULE (as lib/initiative-premium.js): every item comes from a field of a record. On Product feature the workflow engine's checks give
10
10
  * the done and waiting items; on another workflow (D99) the current stage's To finish list and its output give them (scripts/workflows.js
11
- * STAGE.finish, STAGE.output), and the engine's lane checks never show; the board's Jira tickets give the build item ("N of M tickets Done in Jira"); the engineers build in Jira, so the card
11
+ * STAGE.finish, STAGE.output; each To finish entry is a task of the initiative, done when that task is closed), and the engine's lane checks never show; the board's Jira tickets give the build item ("N of M tickets Done in Jira"); the engineers build in Jira, so the card
12
12
  * never names a PMOS builder agent, a pull request or CI as the build story. A time in the stage shows only when a record holds one;
13
13
  * otherwise the line gives the planned finish, or says the time is not recorded. */
14
14
 
@@ -37,6 +37,7 @@ const PAYOFF = {
37
37
  evaluate: 'You decide to keep it, iterate on it or stop it.',
38
38
  };
39
39
  const YOU_STEPS = /^(contract|review|accept|commit|signoff|sign-off)$/;
40
+ const CLOSED = new Set(['Done', "Won't do", 'Archived']);
40
41
  // a failed review: the engine reports a FAIL verdict as a pending review whose evidence names it (scripts/workflow-state.js R3), or blocks on it
41
42
  const failedReview = (c) => c.k === 'review' && c.state !== 'done' && c.state !== 'na' && (c.state === 'blocked' || /\bFAIL/i.test(c.owed || ''));
42
43
  const isFailedReview = (m) => (m.checks || []).some(failedReview);
@@ -73,7 +74,16 @@ export function headModel(M, now = Date.now()) {
73
74
  // another workflow (D99): what finishes its current stage is that stage's own To finish list and its output, in the PM's words. The
74
75
  // workflow engine's lane checks (spec, contract, Review Gate) belong to Product feature and never show here (bug 2026-10-25).
75
76
  const st = (m.wfStages || []).find((s) => m.wfStage && s.key === m.wfStage.key) || {};
76
- for (const f of Array.isArray(st.finish) ? st.finish : []) if (f) items.push({ kind: 'agent', label: cap1(f) });
77
+ // each To finish entry is a task of the initiative (feedback batch 5: routes-boards stageTasks makes it once, with a `from` marker):
78
+ // done when that task is closed, so closing it on this card, in the Tasks section or with `pmos task state` is one write
79
+ const rows = (m.tasks && m.tasks.rows) || [];
80
+ for (const f of Array.isArray(st.finish) ? st.finish : []) {
81
+ if (!f) continue;
82
+ const t = rows.find((r) => r.from && r.from.stage === st.key && r.from.finish === f);
83
+ const label = t && t.title ? t.title : cap1(f);
84
+ if (t && CLOSED.has(t.state)) items.push({ kind: 'done', label });
85
+ else items.push({ kind: 'agent', label, ...(t && t.pmos && t.uid ? { task: t.key } : {}) });
86
+ }
77
87
  const o = st.output || {};
78
88
  if (o.name && !items.some((x) => x.label.toLowerCase() === String(o.name).toLowerCase())) items.push({ kind: o.kind === 'signoff' ? 'you' : 'agent', label: o.kind === 'signoff' ? 'Your sign-off: ' + o.name : cap1(o.name) });
79
89
  } else {
@@ -0,0 +1,5 @@
1
+ {
2
+ "_comment": "feedback batch 5, items 2 and 3 (Wawan: One list): pmos task add, breakdown items as tasks (list, close, edit), a stage's To finish entries made tasks once, the stage card counts them.",
3
+ "modules": ["one-task-list.test.js"],
4
+ "seconds": { "one-task-list.test.js": 3 }
5
+ }