create-pmos 0.566.0 → 0.568.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 (40) hide show
  1. package/package.json +27 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/workflow-state.js +20 -1
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/changelog.json +26 -0
  8. package/workspace/guide/cli.md +3 -1
  9. package/workspace/guide/initiatives-and-next-steps.md +20 -1
  10. package/workspace/lib/autonomy.js +1 -0
  11. package/workspace/lib/board-premium.js +2 -0
  12. package/workspace/lib/engine/workflow-state.js +20 -1
  13. package/workspace/lib/engine/workflows.js +71 -7
  14. package/workspace/lib/jira-cli.js +1 -0
  15. package/workspace/lib/jira-tickets.js +23 -0
  16. package/workspace/lib/kind-control.js +232 -0
  17. package/workspace/lib/outcome-props.js +58 -4
  18. package/workspace/lib/outcomes-cli.js +7 -1
  19. package/workspace/lib/outcomes.js +188 -11
  20. package/workspace/lib/proposals.js +12 -3
  21. package/workspace/lib/rehearse-read.js +3 -1
  22. package/workspace/lib/rehearse.js +30 -2
  23. package/workspace/lib/route-modules.js +1 -0
  24. package/workspace/lib/routes-boards.js +56 -8
  25. package/workspace/lib/routes-initiatives.js +3 -1
  26. package/workspace/lib/routes-kind-control.js +95 -0
  27. package/workspace/lib/routes-proposals.js +26 -0
  28. package/workspace/lib/status-signal.js +6 -2
  29. package/workspace/lib/vendor/scripts/workflow-state.js +20 -1
  30. package/workspace/lib/work-kind.js +16 -4
  31. package/workspace/lib/workflow-cli.js +23 -1
  32. package/workspace/lib/workflows-store.js +2 -2
  33. package/workspace/package-lock.json +2 -2
  34. package/workspace/package.json +1 -1
  35. package/workspace/public/pm/bd-next.js +8 -0
  36. package/workspace/public/pm/ini-agent.js +16 -6
  37. package/workspace/public/pm/ini-kind.js +59 -0
  38. package/workspace/public/pm/ini-view.css +23 -0
  39. package/workspace/public/pm/ini-view.js +5 -2
  40. package/workspace/test-lists/kind-workflows.json +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.566.0",
3
+ "version": "0.568.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": {
@@ -33,6 +33,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.568.0",
38
+ "at": "2026-11-12T05:06:58.936Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1300,
43
+ "t": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
44
+ "s": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.567.0",
51
+ "at": "2026-11-12T04:54:34.259Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1298,
56
+ "t": "A refuted outcome reads at risk and files its next step under the ✦",
57
+ "s": "A refuted outcome reads at risk and files its next step under the ✦",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.566.0",
38
64
  "at": "2026-11-12T04:39:13.320Z",
@@ -284,32 +310,6 @@
284
310
  "k": "new"
285
311
  }
286
312
  ]
287
- },
288
- {
289
- "v": "0.548.0",
290
- "at": "2026-11-10T02:35:02.323Z",
291
- "f": 4,
292
- "prs": [
293
- {
294
- "n": 1276,
295
- "t": "Agent-run Your day and initiative Viewer",
296
- "s": "Agent-run Your day and initiative Viewer",
297
- "k": "new"
298
- }
299
- ]
300
- },
301
- {
302
- "v": "0.547.0",
303
- "at": "2026-11-09T23:58:24.564Z",
304
- "f": 4,
305
- "prs": [
306
- {
307
- "n": 1275,
308
- "t": "A Mac running PMOS keeps working unattended — minute check + Remote Control keeper",
309
- "s": "A Mac running PMOS keeps working unattended — minute check + Remote Control keeper",
310
- "k": "new"
311
- }
312
- ]
313
313
  }
314
314
  ]
315
315
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@862ddccd
1
+ kernel-source: pmos@7743111f
2
2
  assembled: 2026-11-12
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-11-12T04:39:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T05:06:55Z"}
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-11-12T04:39:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T05:06:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -963,7 +963,26 @@ function computeWorkflowDerived(id, opts) {
963
963
  'the done test is the spec (D13 as amended by D107). Land it in an earlier commit than the build, or split this PR so it lands first',
964
964
  { blocking: !legacy, rule });
965
965
  };
966
- if (doneTest) {
966
+ // W5 (boards WfA/WfB/WfC, agreed 2026-11-12): the kind of work sets the gate. Full SDLC: a done test and a kill condition before the first
967
+ // pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
968
+ // PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
969
+ const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
970
+ const planPath = String(fm.plan_path || '').trim();
971
+ if (!doneTest && workKind === 'sdlc' && !prd) {
972
+ steps.push(step('spec', 'spec', 'blocked', 'Full SDLC needs a done test and a kill condition before the first pull request — never a PRD',
973
+ `write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
974
+ } else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
975
+ const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
976
+ if (!planPath) {
977
+ steps.push(step('spec', 'spec', 'blocked', 'Project needs a dated plan before Execute — never a PRD',
978
+ `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`, { blocking: true, rule: 'R2' }));
979
+ } else if (planIdx === null) {
980
+ steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
981
+ 'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
982
+ } else {
983
+ steps.push(orderOf(`plan ${planPath}`, planIdx, 'O1'));
984
+ }
985
+ } else if (doneTest) {
967
986
  const dtIdx = firstAppearance(root, range, doneTest);
968
987
  if (dtIdx === null) {
969
988
  steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
@@ -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-11-12T04:39:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-12T05:06:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.568.0",
4
+ "at": "2026-11-12T05:06:58.936Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1300,
9
+ "t": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
10
+ "s": "Project and Full SDLC get their own workflows and gates (launch simulation W5)",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.567.0",
17
+ "at": "2026-11-12T04:54:34.259Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1298,
22
+ "t": "A refuted outcome reads at risk and files its next step under the ✦",
23
+ "s": "A refuted outcome reads at risk and files its next step under the ✦",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.566.0",
4
30
  "at": "2026-11-12T04:39:13.320Z",
@@ -231,6 +231,8 @@ Run them in the product's repository, or pass `--root <dir>`.
231
231
  - `pmos outcomes propose [<id>]` shows PMOS's drafts, each with the lines it cites. Before the first draft of a repository it replays them on that repository's records, and shows nothing unless the replay passes.
232
232
  - `pmos outcomes declare <id> --metric "<text>" --horizon <YYYY-MM-DD>` writes the outcome and its check date, after you said yes.
233
233
  - `pmos outcomes record <id> <worked|didnt-work|cant-tell> --evidence "<text>"` records your verdict on a due check.
234
+ - When you record `didnt-work`, the initiative shows **At risk** on every page, with the check as the reason. PMOS compares the evidence with the kill condition and files one next step under the initiative's ✦. If the evidence meets the kill condition, PMOS suggests that you stop the initiative. If this is the second check that did not work, it suggests a new experiment. Otherwise it suggests one more round with a new check date. The Board's Next column asks you the same question. Nothing happens until you press ✓. Undo reverses the step.
235
+ - `pmos outcomes propose` also reads the experiment's hypothesis. When the hypothesis names a different KR from the initiative's anchor, the draft tells you.
234
236
 
235
237
  ### pmos rehearse: rehearse a change
236
238
 
@@ -351,7 +353,7 @@ An agent writes a draft or a reading with these commands, and moves an initiativ
351
353
  - `pmos workflow show-draft` shows the draft that is open.
352
354
  - `pmos workflow judge --board <id> --id <initiative> --stage <key> --runs yes|no|unsure --why <reason> --cite <where>` records PMOS's reading of an Only when stage. **unsure** makes PMOS ask you. `--undo` takes a reading back.
353
355
  - `pmos workflow of <initiative>` shows the workflow the initiative runs, its current stage, and each stage numbered as done, current or skipped. It reads the same row as the Board.
354
- - `pmos workflow move <initiative> --stage <key|name|number>` moves the initiative to a stage of its own workflow. A number counts from 1 in the workflow's order, so `--stage 5` is the fifth stage. `--why` adds the reason. The move writes the same line as a move on the Board, under the agent's name. On a board whose columns join two stages, such as **Build & Deliver**, the initiative still goes to the stage you name, and the joined column name means its first stage.
356
+ - `pmos workflow move <initiative> --stage <key|name|number>` moves the initiative to a stage of its own workflow. A number counts from 1 in the workflow's order, so `--stage 5` is the fifth stage. `--why` adds the reason. When the initiative passes stages that still have open tasks, the move lists those tasks. It does not close them. The move writes the same line as a move on the Board, under the agent's name. On a board whose columns join two stages, such as **Build & Deliver**, the initiative still goes to the stage you name, and the joined column name means its first stage.
355
357
  - `pmos workflow switch <initiative> --to <workflow id>` puts the initiative on another workflow. `--stage` picks the stage it lands in; without it, the stage is the one the Board's switch picks.
356
358
  - `pmos workflow check [<initiative>]` compares the stage that each surface shows: the Board, the Viewer and `pmos workflow of`, `pmos initiative list`, and the notes and report slides. It exits 1 and names the surfaces when two of them show different stages for one initiative. `scripts/workflow-state.js` shows the CI gate rung (`gate`), not the stage.
357
359
 
@@ -140,7 +140,26 @@ The writer makes the record in `planning/initiatives/<id>.md` with its type, tit
140
140
 
141
141
  PMOS picks a kind from the name as you type, and a blue line says so. Tap another kind to change it. After you tap a kind, PMOS does not change it. When the name gives no hint, the kind is Product.
142
142
 
143
- The kind is saved as `kind:` in the record (`product`, `sdlc` or `project`). An older record with no `kind:` line reads as Product. Use `pmos initiative new --kind <kind>` to set it from a terminal. The kind is not a lane: the Initiative Gate and the stages do not read it.
143
+ The kind is saved as `kind:` in the record (`product`, `sdlc` or `project`). An older record with no `kind:` line reads as Product. Use `pmos initiative new --kind <kind>` to set it from a terminal. The kind is not a lane, but it sets the workflow and the gate that the initiative starts on:
144
+
145
+ | Kind | Workflow | Gate |
146
+ |---|---|---|
147
+ | Product | The workspace default (Product feature unless you set another) | A done test and a kill condition, or a PRD |
148
+ | Full SDLC | Done test, Pull requests, CI, Merge, Release | A done test and a kill condition, dated before the first pull request. Never a PRD. |
149
+ | Project | Initiate, Plan, Execute, Monitor, Close | A dated plan (`plan_path`, or milestones with due days), every milestone owned by someone in People, and a go-live date that matches the KR date and the title. Never a PRD. |
150
+
151
+ Project and Full SDLC are built in, beside Product feature, under **Settings › Workflows**. You cannot edit them; copy one to make your own. Each initiative can still switch to another workflow.
152
+
153
+ When you change the kind, an initiative that runs its old kind's workflow moves to the new kind's. Its stage maps by meaning: Plan to Plan, Build to Execute, Deliver or Release to Close. A gate that it passed stays passed. One line in the initiative says what changed, for example "Kind changed to Project from Product: the Plan gate now needs milestone dates, owners and a go-live that matches the KR." An initiative on a workflow that you picked yourself stays on it.
154
+
155
+ **Project control.** A Project initiative shows **Project control** at the top of the initiative:
156
+
157
+ - **On track for <date>?** The answer comes from the task dates and the task links. The date is the KR's date, else the end, else the date in the title. On a No, it names the forecast, the slip and the task that causes it.
158
+ - **PMOS proposes** moving the go-live milestone to its forecast. Approve or dismiss it with the icons. It never changes the KR, the goal or the title: change those yourself. `pmos rehearse end <initiative> --to <date>` names each one that a new date breaks.
159
+ - **The critical path**: the tasks that hold go-live, walked back through the task links. With no links, PMOS names none.
160
+ - **Each task** with its colour, its owner and a bar. The outline is the baseline (the dates when the initiative left Plan, else the first dates). The filled bar is now. Red: late, on the critical path, and go-live misses the date. Amber: later than its baseline, or its start has passed. Green: on its baseline. The colour never reads a status that someone typed.
161
+
162
+ `pmos jira draft <initiative>` on a Project with no PRD drafts its milestones and tasks as a work breakdown: each milestone is an epic, with the tasks that end before it. Nothing is sent until you approve it.
144
163
 
145
164
  - **On the Board.** A small icon before each initiative's name shows its kind. The **Next** column follows the kind. For example, Full SDLC says "PMOS builds the first pull request" where a factory runs, and "PMOS writes the pull request plan for the team's agents" where none runs. Project says "PMOS writes the status line".
146
165
  - **In the initiative.** The same icon is in the header, before **Discuss in chat**. Tap it to change the kind. The toast has **Undo**. The Experiment names the kind once. Until someone writes **Who builds**, it comes from the kind: PMOS for Full SDLC where a factory runs, else the team's agents; the team for Product and Project. Project says **Who does it** and needs no specimens. A line that you or PMOS wrote stays as written.
@@ -119,6 +119,7 @@ function classOfProposal(p) {
119
119
  if (!isObj(p)) return 'C';
120
120
  const c = PROPOSAL_CLASS[p.group] || 'C';
121
121
  if (p.group === 'status' && (p.items || []).some((x) => x && x.jira)) return 'C';
122
+ if (p.group === 'outcome' && p.type === 'refuted') return 'C'; // stopping or replacing an experiment is the PM's call (launch simulation W2)
122
123
  // a maybe, or a duplicate already in another initiative (type link, or an item with `other`), is a question for the PM, not a change
123
124
  // found type stage moves the initiative's stage: a stage move is C (as the Driver's `move`)
124
125
  if (p.group === 'found' && (p.type === 'stage' || p.type === 'maybe' || p.type === 'link' || (p.items || []).some((x) => x && x.other))) return 'C';
@@ -287,6 +287,8 @@ function rowOf(r0, wf, today) {
287
287
  finish: r.end ? shortDate(r.end) : 'Not planned', over: !!over, start: r.start || null, end: r.end || null,
288
288
  owner: r.owner || null, lane: r.lane || null, kind: KINDS.includes(r.kind) ? r.kind : 'product', anchor: r.anchor || null, kr: krShort(r.anchor), rank: Number.isInteger(r.rank) ? r.rank : null, warnings: (r.warnings || []).filter((w) => typeof w === 'string').slice(0, 12), epics: Array.isArray(r.epics) ? r.epics.filter((e) => typeof e === 'string').slice(0, 6) : [], updated: r.updated || null, reading: r.reading || null, overDays: over ? days(r.end, today) : 0,
289
289
  acts: actsOf(r, names),
290
+ // the PM's standing verdict on the outcome (launch simulation W2): the Next cell stops asking "did it work?" once it is answered
291
+ outcome: r.outcome && r.outcome.verdict ? { verdict: r.outcome.verdict, current: !!r.outcome.current, ...(r.outcome.next ? { next: r.outcome.next } : {}) } : null,
290
292
  holds: holdsOf(r), gaps: gapsOf(r), stageSpans: stageSpansOf(r),
291
293
  // D99: the workflow it runs and where it stands in it (lib/routes-boards.js workflowRowOf); Product feature when the server sends none
292
294
  ...wfFields(r),
@@ -963,7 +963,26 @@ function computeWorkflowDerived(id, opts) {
963
963
  'the done test is the spec (D13 as amended by D107). Land it in an earlier commit than the build, or split this PR so it lands first',
964
964
  { blocking: !legacy, rule });
965
965
  };
966
- if (doneTest) {
966
+ // W5 (boards WfA/WfB/WfC, agreed 2026-11-12): the kind of work sets the gate. Full SDLC: a done test and a kill condition before the first
967
+ // pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
968
+ // PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
969
+ const workKind = (() => { const k = String(fm.kind || '').trim().replace(/^["']|["']$/g, ''); return k === 'sdlc' || k === 'project' ? k : 'product'; })();
970
+ const planPath = String(fm.plan_path || '').trim();
971
+ if (!doneTest && workKind === 'sdlc' && !prd) {
972
+ steps.push(step('spec', 'spec', 'blocked', 'Full SDLC needs a done test and a kill condition before the first pull request — never a PRD',
973
+ `write the done test (okf/core/templates/done-test-template.md), set done_test_path and kill: in ${recRel}`, { blocking: true, rule: 'R2' }));
974
+ } else if (!doneTest && workKind === 'project' && (planPath || !prd)) {
975
+ const planIdx = planPath ? firstAppearance(root, range, planPath) : null;
976
+ if (!planPath) {
977
+ steps.push(step('spec', 'spec', 'blocked', 'Project needs a dated plan before Execute — never a PRD',
978
+ `write the plan (milestones with dates and owners, go-live matching the KR date) and set plan_path in ${recRel}, or a done test`, { blocking: true, rule: 'R2' }));
979
+ } else if (planIdx === null) {
980
+ steps.push(step('spec', 'spec', 'blocked', `plan_path '${planPath}' does not exist in the repo`,
981
+ 'create the plan the record points at, or correct plan_path', { blocking: true, rule: 'R2' }));
982
+ } else {
983
+ steps.push(orderOf(`plan ${planPath}`, planIdx, 'O1'));
984
+ }
985
+ } else if (doneTest) {
967
986
  const dtIdx = firstAppearance(root, range, doneTest);
968
987
  if (dtIdx === null) {
969
988
  steps.push(step('spec', 'spec', 'blocked', `done_test_path '${doneTest}' does not exist in the repo`,
@@ -4,7 +4,9 @@
4
4
  *
5
5
  * CATS · ENDS · OUTPUT_KINDS · WHEN_MODES · DECIDE · ICONS · PRODUCT_FEATURE_ID · PRODUCT_FEATURE
6
6
  * check(wf, { existing }) → { ok, workflow } | { ok:false, status, error } validate and normalise one workflow
7
- * fold(lines) → { byId: Map, draft, defaultId } the library (Product feature first)
7
+ * PROJECT · FULL_SDLC · BUILTIN · KIND_WF the two workflows the kind of work starts on (W5, boards WfA/WfB/WfC), built in like Product feature
8
+ * forKind(folded, kind) · isKindDefault(folded, kind, wfId) the workflow a kind starts on; whether an initiative still runs it
9
+ * fold(lines) → { byId: Map, draft, defaultId } the library (the built-ins first)
8
10
  * list(folded, counts?) → [workflow + { count, default? }] Product feature first, archived last
9
11
  * defaultOf(folded) → the workflow a new initiative starts on (Product feature when none is set or it is archived)
10
12
  * resolve(folded, id) → the workflow (Product feature when the id is unknown or missing)
@@ -59,6 +61,53 @@ const PRODUCT_FEATURE = Object.freeze({
59
61
  }))),
60
62
  });
61
63
 
64
+ // The kind of work sets the default workflow (launch simulation W5, main canvas boards WfA, WfB, WfC; agreed by Wawan 2026-11-12). Two more
65
+ // workflows are built in beside Product feature and, like it, cannot be edited (copy one to make your own). Every workflow starts with the
66
+ // key `triage` (the first stage, in To do); these two name it for their work: Initiate, and Done test.
67
+ const st = (key, name, cat, out, kind, o = {}) => Object.freeze({ key, name, cat, output: Object.freeze({ name: out, kind }), finish: Object.freeze(o.finish || []),
68
+ milestone: !!o.milestone, auto: false, when: Object.freeze({ mode: 'always' }), then: null, unless: Object.freeze([]) });
69
+ const PROJECT_ID = 'project', FULL_SDLC_ID = 'full-sdlc';
70
+ const PROJECT = Object.freeze({
71
+ id: PROJECT_ID, name: 'Project', icon: 'flag', builtin: true, decide: 'pmos', kind: 'project',
72
+ stages: Object.freeze([
73
+ st('triage', 'Initiate', 'todo', 'The charter: the goal, the date and who owns it', 'doc'),
74
+ st('plan', 'Plan', 'doing', 'A dated plan: milestones with owners from People, go-live matching the KR date', 'checklist', { milestone: true }),
75
+ st('execute', 'Execute', 'doing', 'The tasks done against the baseline', 'checklist'),
76
+ st('monitor', 'Monitor', 'doing', 'Go-live reached; the dates watched against the baseline', 'checklist', { milestone: true }),
77
+ st('close', 'Close', 'done', 'The lessons, and the outcome check', 'signoff'),
78
+ ]),
79
+ });
80
+ const FULL_SDLC = Object.freeze({
81
+ id: FULL_SDLC_ID, name: 'Full SDLC', icon: 'build', builtin: true, decide: 'pmos', kind: 'sdlc',
82
+ stages: Object.freeze([
83
+ st('triage', 'Done test', 'todo', 'The done test and the kill condition, dated before the first pull request', 'doc'),
84
+ st('pulls', 'Pull requests', 'doing', 'The pull requests of the PR plan', 'checklist'),
85
+ st('ci', 'CI', 'doing', 'Green required checks on every pull request of the plan', 'checklist'),
86
+ st('merge', 'Merge', 'doing', 'Every pull request merged; the done test passes on the merged branch', 'checklist', { milestone: true }),
87
+ st('release', 'Release', 'done', 'Released; the outcome check starts', 'signoff', { milestone: true }),
88
+ ]),
89
+ });
90
+ const BUILTIN = Object.freeze({ [PRODUCT_FEATURE_ID]: PRODUCT_FEATURE, [PROJECT_ID]: PROJECT, [FULL_SDLC_ID]: FULL_SDLC });
91
+ const isBuiltin = (id) => Object.prototype.hasOwnProperty.call(BUILTIN, id);
92
+ /** The workflow each kind of work starts on (lib/work-kind.js KINDS). Product management: the workspace's default (defaultOf). */
93
+ const KIND_WF = Object.freeze({ product: PRODUCT_FEATURE_ID, sdlc: FULL_SDLC_ID, project: PROJECT_ID });
94
+ /* Switching between the built-in workflows maps stages BY MEANING (WfC): Plan to Plan, Build to Execute, Release to Close. The proposal
95
+ * (proposeBridge) cannot know that Deliver is a release, so the three are mapped here and mapOf reads this before the proposal. */
96
+ const MEANING = Object.freeze({
97
+ 'product-feature>project': { triage: 'triage', discover: 'triage', plan: 'plan', prioritize: 'plan', build: 'execute', deliver: 'close', monitor: 'close', evaluate: 'close' },
98
+ 'product-feature>full-sdlc': { triage: 'triage', discover: 'triage', plan: 'triage', prioritize: 'triage', build: 'pulls', deliver: 'release', monitor: 'release', evaluate: 'release' },
99
+ 'project>product-feature': { triage: 'triage', plan: 'plan', execute: 'build', monitor: 'deliver', close: 'evaluate' },
100
+ 'project>full-sdlc': { triage: 'triage', plan: 'triage', execute: 'pulls', monitor: 'merge', close: 'release' },
101
+ 'full-sdlc>product-feature': { triage: 'plan', pulls: 'build', ci: 'build', merge: 'build', release: 'deliver' },
102
+ 'full-sdlc>project': { triage: 'plan', pulls: 'execute', ci: 'execute', merge: 'monitor', release: 'close' },
103
+ });
104
+ /** What a gate of each kind asks before work leaves planning, said once (the switch line names what the new kind adds). */
105
+ const KIND_GATE = Object.freeze({
106
+ product: 'the Build gate reads the done test and kill condition, or a PRD',
107
+ sdlc: 'the first pull request now needs a done test and a kill condition, dated before the build',
108
+ project: 'the Plan gate now needs a dated plan, milestones with owners and a go-live date that matches the KR',
109
+ });
110
+
62
111
  const bad = (error, status = 400) => ({ ok: false, status, error });
63
112
 
64
113
  /** Validate and normalise one workflow. `existing` (the library's ids) only matters for a new id clashing with Product feature. */
@@ -68,7 +117,7 @@ function check(wf) {
68
117
  const name = wf.name.trim();
69
118
  const id = typeof wf.id === 'string' && wf.id ? slug(wf.id) : slug(name);
70
119
  if (!id) return bad('the name needs at least one letter or digit');
71
- if (id === PRODUCT_FEATURE_ID) return bad('Product feature is built in and cannot be changed. Copy it to make your own.', 409);
120
+ if (isBuiltin(id)) return bad(`${BUILTIN[id].name} is built in and cannot be changed. Copy it to make your own.`, 409);
72
121
  const icon = ICONS.includes(wf.icon) ? wf.icon : 'flag';
73
122
  const decide = wf.decide == null ? 'pmos' : wf.decide;
74
123
  if (!DECIDE.includes(decide)) return bad(`decide is one of ${DECIDE.join(', ')}`);
@@ -136,7 +185,7 @@ function check(wf) {
136
185
 
137
186
  /** Fold workflows.jsonl (objects or JSON strings), oldest first. */
138
187
  function fold(lines) {
139
- const byId = new Map([[PRODUCT_FEATURE_ID, PRODUCT_FEATURE]]);
188
+ const byId = new Map(Object.entries(BUILTIN));
140
189
  let draft = null, defaultId = null;
141
190
  for (const raw of lines || []) {
142
191
  let e = raw;
@@ -150,7 +199,7 @@ function fold(lines) {
150
199
  // the initiatives over reads it (batch 20 item 3)
151
200
  const cf = typeof e.copiedFrom === 'string' ? e.copiedFrom : was && was.copiedFrom ? was.copiedFrom : null;
152
201
  byId.set(c.workflow.id, { ...c.workflow, ...(was && was.archived ? { archived: true } : {}), ...(cf ? { copiedFrom: cf } : {}), at: e.at || null });
153
- } else if (e.kind === 'wf-archive' && typeof e.id === 'string' && byId.has(e.id) && e.id !== PRODUCT_FEATURE_ID) {
202
+ } else if (e.kind === 'wf-archive' && typeof e.id === 'string' && byId.has(e.id) && !isBuiltin(e.id)) {
154
203
  const w = { ...byId.get(e.id) };
155
204
  if (e.archived) w.archived = true; else delete w.archived;
156
205
  byId.set(e.id, w);
@@ -174,7 +223,8 @@ function defaultOf(folded) {
174
223
  function list(folded, counts = {}) {
175
224
  const def = defaultOf(folded).id;
176
225
  const all = [...folded.byId.values()].map((w) => ({ ...w, count: counts[w.id] || 0, ...(w.id === def ? { default: true } : {}) }));
177
- const rank = (w) => (w.id === PRODUCT_FEATURE_ID ? 0 : w.archived ? 2 : 1);
226
+ const order = [PRODUCT_FEATURE_ID, PROJECT_ID, FULL_SDLC_ID];
227
+ const rank = (w) => (isBuiltin(w.id) ? order.indexOf(w.id) : w.archived ? 4 : 3);
178
228
  return all.sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name));
179
229
  }
180
230
  const resolve = (folded, id) => (id && folded && folded.byId.get(id)) || PRODUCT_FEATURE;
@@ -229,7 +279,7 @@ function proposeBridge(from, to) {
229
279
  /** Every stage of `from` and where it lands in `to`: the PM's own pick (override), the bridge saved with `to`, else Claude's proposal. */
230
280
  function mapOf(from, to, override) {
231
281
  const p = proposeBridge(from, to);
232
- const br = to && to.bridge && from && to.bridge.from === from.id ? to.bridge.map : {};
282
+ const br = to && to.bridge && from && to.bridge.from === from.id ? to.bridge.map : (from && to && MEANING[from.id + '>' + to.id]) || {};
233
283
  const ok = (k) => !!k && !!(to.stages || []).find((s) => s.key === k);
234
284
  const out = {};
235
285
  for (const s of (from && from.stages) || []) {
@@ -273,14 +323,28 @@ function stagesOf(wf, { judged = {}, current = null } = {}) {
273
323
  function copyOf(wf, name, taken) {
274
324
  const n = oneLine(name, NAME_MAX) ? name.trim() : 'Copy of ' + wf.name;
275
325
  let id = slug(n) || 'workflow', k = 2;
276
- while ((taken && taken.has(id)) || id === PRODUCT_FEATURE_ID) id = slug(n) + '-' + k++;
326
+ while ((taken && taken.has(id)) || isBuiltin(id)) id = slug(n) + '-' + k++;
277
327
  return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
278
328
  }
279
329
 
330
+ /** The workflow a kind of work starts on: Project and Full SDLC their own; Product management the workspace's default (defaultOf). */
331
+ function forKind(folded, kind) {
332
+ const id = KIND_WF[kind];
333
+ if (!id || id === PRODUCT_FEATURE_ID) return defaultOf(folded);
334
+ return BUILTIN[id];
335
+ }
336
+ /** Whether an initiative on workflow `wfId` runs its kind's default: the kind's built-in, or for Product management Product feature or the
337
+ * workspace default. A workflow the PM picked by hand is not a kind's default, so a kind change leaves it alone. */
338
+ function isKindDefault(folded, kind, wfId) {
339
+ if (kind === 'product') return wfId === PRODUCT_FEATURE_ID || wfId === defaultOf(folded).id;
340
+ return wfId === KIND_WF[kind];
341
+ }
342
+
280
343
  /** The ◆ stages of a workflow: what a program milestone may wait on (D99 point 7). Product feature: Deliver first. */
281
344
  const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.milestone).map((s) => ({ key: s.key, name: s.name }));
282
345
 
283
346
  module.exports = {
284
347
  CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
348
+ PROJECT_ID, PROJECT, FULL_SDLC_ID, FULL_SDLC, BUILTIN, KIND_WF, KIND_GATE, MEANING, isBuiltin, forKind, isKindDefault,
285
349
  slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
286
350
  };
@@ -190,6 +190,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
190
190
  if (!r.ok) return fail(r.error);
191
191
  const lines = [`${initiative} · ${r.tickets} ${r.tickets === 1 ? 'ticket' : 'tickets'} in ${r.draft}${r.changed ? '' : ' · no change'}${flags['dry-run'] ? ' · dry run, nothing written' : ''}`];
192
192
  if (r.from === 'done-test' || r.from === 'tasks') lines.push(` From ${r.from === 'done-test' ? 'the done test\'s checks' : 'the open tasks'} (${r.sources.join(', ')}): the PRD has no stories section.`);
193
+ else if (r.from === 'plan') lines.push(' From the plan: each milestone is an epic, with the tasks that end before it. A Project has no PRD.');
193
194
  for (const c of r.changes) lines.push(` ${c.what.padEnd(9)} ${c.ticket} · ${c.summary}${c.why ? ` (${c.why})` : ''}`);
194
195
  lines.push('Read them on the Jira tickets tab, or with pmos jira show. Select the ready ones there, or with pmos jira approve.');
195
196
  return out(r, lines);
@@ -306,6 +306,12 @@ function items(root, initiative) {
306
306
  const s = dt ? itemsFromDoneTest(dt, title) : [];
307
307
  if (s.length) { found.push(...s); sources.push(dt.path); from = 'done-test'; }
308
308
  }
309
+ // W5 (board WfA): a Project has no PRD. With no done test either, its plan is the draft: each ◇ milestone an epic, and under it the
310
+ // tasks that end on or before it (lib/kind-control.js wbsOf), a work breakdown. Nothing is sent: the draft waits for the PM as any other.
311
+ if (!found.length && String(fm.kind || '').replace(/["']/g, '').trim() === 'project') {
312
+ const w = wbsItems(root, initiative);
313
+ if (w.length) { found.push(...w); sources.push('the plan: milestones and tasks'); from = 'plan'; }
314
+ }
309
315
  if (!found.length) {
310
316
  const s = itemsFromTasks(root, initiative, title);
311
317
  if (s.length) { found.push(...s); sources.push(s[0].source); from = 'tasks'; }
@@ -324,6 +330,23 @@ function items(root, initiative) {
324
330
  return { ok: true, initiative, items: found, sources, prd: prd || null, from };
325
331
  }
326
332
 
333
+ /** A Project's milestones and tasks as ticket items (W5): the milestone is the epic; each task a Task with its due day and owner. */
334
+ function wbsItems(root, initiative) {
335
+ let tasks = [];
336
+ try {
337
+ const SR = require('./stage-read.js'), { w, ctx } = SR.cliCtx(root);
338
+ tasks = (SR.tasksOf(ctx, w, initiative) || []).map((t) => ({ uid: t.id, title: t.title, end: t.due || null, owner: t.owner || null, milestone: !!t.milestone, kind: t.kind, status: t.state }));
339
+ } catch { return []; }
340
+ const done = /^(done|won't do|archived)$/i;
341
+ const out = [];
342
+ for (const g of require('./kind-control.js').wbsOf(tasks.filter((t) => !done.test(String(t.status || ''))))) {
343
+ const epic = g.milestone ? clip(oneLine('◇ ' + g.milestone.title + (g.milestone.due ? ' · ' + g.milestone.due : '')), MAX_EPIC) : 'After the last milestone';
344
+ for (const t of g.tasks) out.push({ id: null, title: t.title, epic, source: 'plan', body: ['Due ' + (t.due || 'not set') + '.', t.owner ? 'Owner ' + t.owner + '.' : 'No owner yet.'].join(' ') });
345
+ if (g.milestone) out.push({ id: null, title: g.milestone.title, epic, source: 'plan', body: 'Milestone, due ' + (g.milestone.due || 'not set') + '.' + (g.milestone.owner ? ' Owner ' + g.milestone.owner + '.' : '') });
346
+ }
347
+ return out;
348
+ }
349
+
327
350
  // ── J2 · one item in the PM's template ─────────────────────────────────────────────────────────────
328
351
  const sectionKey = (line) => {
329
352
  const t = String(line).replace(/^#{1,6}\s+/, '').replace(/\*\*/g, '').replace(/:\s*$/, '').trim().toLowerCase();