create-pmos 0.567.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.
- package/package.json +14 -14
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/scripts/workflow-state.js +20 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +13 -0
- package/workspace/guide/initiatives-and-next-steps.md +20 -1
- package/workspace/lib/engine/workflow-state.js +20 -1
- package/workspace/lib/engine/workflows.js +71 -7
- package/workspace/lib/jira-cli.js +1 -0
- package/workspace/lib/jira-tickets.js +23 -0
- package/workspace/lib/kind-control.js +232 -0
- package/workspace/lib/rehearse-read.js +3 -1
- package/workspace/lib/rehearse.js +30 -2
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-boards.js +44 -2
- package/workspace/lib/routes-initiatives.js +3 -1
- package/workspace/lib/routes-kind-control.js +95 -0
- package/workspace/lib/vendor/scripts/workflow-state.js +20 -1
- package/workspace/lib/work-kind.js +16 -4
- package/workspace/lib/workflows-store.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ini-agent.js +16 -6
- package/workspace/public/pm/ini-kind.js +59 -0
- package/workspace/public/pm/ini-view.css +23 -0
- package/workspace/public/pm/ini-view.js +5 -2
- 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.
|
|
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,19 @@
|
|
|
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
|
+
},
|
|
36
49
|
{
|
|
37
50
|
"v": "0.567.0",
|
|
38
51
|
"at": "2026-11-12T04:54:34.259Z",
|
|
@@ -297,19 +310,6 @@
|
|
|
297
310
|
"k": "new"
|
|
298
311
|
}
|
|
299
312
|
]
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
"v": "0.548.0",
|
|
303
|
-
"at": "2026-11-10T02:35:02.323Z",
|
|
304
|
-
"f": 4,
|
|
305
|
-
"prs": [
|
|
306
|
-
{
|
|
307
|
-
"n": 1276,
|
|
308
|
-
"t": "Agent-run Your day and initiative Viewer",
|
|
309
|
-
"s": "Agent-run Your day and initiative Viewer",
|
|
310
|
-
"k": "new"
|
|
311
|
-
}
|
|
312
|
-
]
|
|
313
313
|
}
|
|
314
314
|
]
|
|
315
315
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-
|
|
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-
|
|
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
|
-
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-12T05:06:55Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
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
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"v": "0.567.0",
|
|
4
17
|
"at": "2026-11-12T04:54:34.259Z",
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
-
|
|
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
|
-
*
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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();
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* kind-control.js — what the Viewer shows for a Project and a Full SDLC initiative (launch simulation W5; main canvas boards WfA and WfB,
|
|
3
|
+
* agreed by Wawan 2026-11-12). PURE: no file, no clock, no network. lib/routes-kind-control.js reads the inputs through the pmos readers.
|
|
4
|
+
*
|
|
5
|
+
* project(input) → { kind: 'project', gate, rows, critical, ontrack, proposal, baselineAt }
|
|
6
|
+
* sdlc(input) → { kind: 'sdlc', gate }
|
|
7
|
+
* baselineOf(lines, uids, at) → Map uid → { start, due } each task's dates as they stood when the plan was set (or its first dates)
|
|
8
|
+
* dateIn(text, today) → 'YYYY-MM-DD' | '' a date a title or a KR names ("launch 15 Dec", "by Dec 15", "2026-12-15")
|
|
9
|
+
* wbsOf(tasks) → [{ milestone, tasks }] a Project's milestones with the tasks that end before each (pmos jira draft)
|
|
10
|
+
*
|
|
11
|
+
* PROJECT CONTROL. Everything here comes from task dates and task links. A status someone typed is never read: a task's colour, the critical
|
|
12
|
+
* path and the on-track answer are worked out, so they cannot drift from the plan (the design principle "honest state").
|
|
13
|
+
* baseline each task's start and due when the initiative left Plan (the ini-wf line that moved it out of `plan`), else its first dates.
|
|
14
|
+
* The outline in the Viewer is the baseline; the filled bar is now (the forecast).
|
|
15
|
+
* forecast an open task that is past its due ends today at the earliest; then the approved links (lib/task-links.js settle) push what
|
|
16
|
+
* waits on it. Go-live is the initiative's last ◇ milestone, else its last task.
|
|
17
|
+
* critical walked back from go-live through the links that hold each task tight (the predecessor that sets its start or its due).
|
|
18
|
+
* With no links into go-live there is no critical path to name, and the Viewer says nothing about it.
|
|
19
|
+
* colour done: done. Red: it ends later than its baseline, it is on the critical path and go-live misses the goal date. Amber: it ends
|
|
20
|
+
* later than its baseline otherwise, or it has not started and its start has passed. Green: on its baseline. None: no dates.
|
|
21
|
+
* on track "On track for <goal date>?" Yes when the forecast go-live is on or before the goal date; No with the slip and the first
|
|
22
|
+
* slipping task on the critical path (the cause); unknown with the reason when a date is missing.
|
|
23
|
+
* proposal on a No: a ✦ that moves the go-live milestone to its forecast. It never changes the goal, the KR or the title: those are
|
|
24
|
+
* Wawan's, and `pmos rehearse end` names each one that the new date breaks.
|
|
25
|
+
* THE GATE TO LEAVE PLAN (WfA): a dated plan (every milestone has a due day, or plan_path is set), every milestone owned by someone in People,
|
|
26
|
+
* and the go-live date matching the goal date and the date in the title. Each part says what is missing.
|
|
27
|
+
* FULL SDLC (WfB): the gate before the first pull request is the done test plus the kill condition, written in the record. Who builds is
|
|
28
|
+
* the Experiment's line (pm/ini-agent.js kindRows), the one wording the honest-copy work keeps true per repository. */
|
|
29
|
+
const TL = require('./task-links.js');
|
|
30
|
+
|
|
31
|
+
const MON = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
|
|
32
|
+
const ALL = { has: () => true };
|
|
33
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
34
|
+
const days = (n) => (Math.abs(n) === 1 ? '1 day' : Math.abs(n) + ' days');
|
|
35
|
+
const iso = TL.isoN, md = TL.md, dn = TL.dn;
|
|
36
|
+
const listOf = (a) => (a.length < 2 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
|
|
37
|
+
|
|
38
|
+
/** A date a line names, as YYYY-MM-DD; a day with no year is this year's, or next year's when this year's has passed. '' when none. */
|
|
39
|
+
function dateIn(text, today) {
|
|
40
|
+
const t = str(text), y0 = +str(today).slice(0, 4) || new Date().getUTCFullYear();
|
|
41
|
+
let m = /\b(\d{4})-(\d{2})-(\d{2})\b/.exec(t);
|
|
42
|
+
if (m) return m[0];
|
|
43
|
+
let d = 0, k = -1, y = 0;
|
|
44
|
+
m = /\b(\d{1,2})\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?(?:,?\s+(\d{4}))?/i.exec(t);
|
|
45
|
+
if (m) { d = +m[1]; k = MON.indexOf(m[2].toLowerCase()); y = m[3] ? +m[3] : 0; }
|
|
46
|
+
else {
|
|
47
|
+
m = /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})\b(?:,?\s+(\d{4}))?/i.exec(t);
|
|
48
|
+
if (m) { d = +m[2]; k = MON.indexOf(m[1].toLowerCase()); y = m[3] ? +m[3] : 0; }
|
|
49
|
+
}
|
|
50
|
+
if (!m || k < 0 || d < 1 || d > 31) return '';
|
|
51
|
+
const at = (yy) => yy + '-' + String(k + 1).padStart(2, '0') + '-' + String(d).padStart(2, '0');
|
|
52
|
+
return y ? at(y) : at(y0) >= str(today) ? at(y0) : at(y0 + 1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Each task's dates as they stood at `at` (ISO time), read from task ledger lines of either shape: a Board task ({ kind: 'task' |
|
|
56
|
+
* 'task-update', task, start?, due? }) or a breakdown item ({ ev, item, start?, due?, fields: { start?, due? } }). A task first dated after
|
|
57
|
+
* `at` keeps its first dates. No `at`: every task's first dates. → Map uid → { start, due } */
|
|
58
|
+
function baselineOf(lines, uids, at) {
|
|
59
|
+
const first = new Map(), asOf = new Map();
|
|
60
|
+
for (const e of lines || []) {
|
|
61
|
+
if (!e || typeof e !== 'object') continue;
|
|
62
|
+
const id = typeof e.task === 'string' ? e.task : typeof e.item === 'string' ? e.item : null;
|
|
63
|
+
if (!id || (uids && !uids.has(id))) continue;
|
|
64
|
+
const f = e.fields && typeof e.fields === 'object' ? e.fields : e;
|
|
65
|
+
const s = typeof f.start === 'string' ? f.start : undefined, d = typeof f.due === 'string' ? f.due : undefined;
|
|
66
|
+
if (s === undefined && d === undefined) continue;
|
|
67
|
+
const cur = { ...(first.get(id) || { start: null, due: null }) };
|
|
68
|
+
if (!first.has(id) || first.get(id).start == null || first.get(id).due == null) {
|
|
69
|
+
if (cur.start == null && s !== undefined) cur.start = s;
|
|
70
|
+
if (cur.due == null && d !== undefined) cur.due = d;
|
|
71
|
+
first.set(id, cur);
|
|
72
|
+
}
|
|
73
|
+
if (at && e.at && String(e.at) <= String(at)) {
|
|
74
|
+
const a = { ...(asOf.get(id) || { start: null, due: null }) };
|
|
75
|
+
if (s !== undefined) a.start = s;
|
|
76
|
+
if (d !== undefined) a.due = d;
|
|
77
|
+
asOf.set(id, a);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const out = new Map();
|
|
81
|
+
for (const [id, f] of first) out.set(id, asOf.get(id) || f);
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The forecast: open past-due tasks end today at the earliest, then the links push what waits on them. → Map uid → task (TL shape) */
|
|
86
|
+
function forecastOf(tasks, links, today) {
|
|
87
|
+
const T = new Map();
|
|
88
|
+
for (const x of tasks) {
|
|
89
|
+
const t = TL.taskOf(x);
|
|
90
|
+
if (!t.closed && t.e != null && today != null && t.e < today) { const len = t.s != null ? t.e - t.s : 0; t.e = today; if (t.s != null && t.status === 'To do') t.s = Math.max(t.s, today - len); }
|
|
91
|
+
T.set(t.uid, t);
|
|
92
|
+
}
|
|
93
|
+
const L = (links || []).filter((l) => l && T.has(l.from) && T.has(l.to));
|
|
94
|
+
const S = TL.settle(T, L, { today, ini: '', mode: 'quiet', allow: ALL });
|
|
95
|
+
for (const m of S.moves || []) { const t = T.get(m.uid); if (t) T.set(m.uid, { ...t, s: m.to.s, e: m.to.e }); }
|
|
96
|
+
return { T, links: L };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Walk back from `end` through the links that hold each task tight. → [uid] oldest first */
|
|
100
|
+
function criticalOf(T, links, end, today) {
|
|
101
|
+
if (!end) return [];
|
|
102
|
+
const path = [end.uid], seen = new Set(path);
|
|
103
|
+
let cur = end;
|
|
104
|
+
for (let guard = 0; guard < 200; guard++) {
|
|
105
|
+
let best = null;
|
|
106
|
+
for (const l of links) {
|
|
107
|
+
if (l.to !== cur.uid || seen.has(l.from)) continue;
|
|
108
|
+
const a = T.get(l.from); if (!a) continue;
|
|
109
|
+
const need = TL.needOf(l, a, today);
|
|
110
|
+
const tight = (need.start != null && cur.s != null && need.start >= cur.s) || (need.due != null && cur.e != null && need.due >= cur.e);
|
|
111
|
+
if (tight && (!best || (a.e || 0) > (best.e || 0))) best = a;
|
|
112
|
+
}
|
|
113
|
+
if (!best) break;
|
|
114
|
+
path.unshift(best.uid); seen.add(best.uid); cur = best;
|
|
115
|
+
}
|
|
116
|
+
return path.length > 1 ? path : [];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** People's names and handles, lower case, for "owner linked to People". */
|
|
120
|
+
function peopleSet(people) {
|
|
121
|
+
const S = new Set();
|
|
122
|
+
for (const p of people || []) {
|
|
123
|
+
if (!p) continue;
|
|
124
|
+
if (p.name) S.add(String(p.name).toLowerCase().trim());
|
|
125
|
+
for (const h of p.handles || []) S.add(String(h).toLowerCase().replace(/^person:/, '').trim());
|
|
126
|
+
}
|
|
127
|
+
return S;
|
|
128
|
+
}
|
|
129
|
+
const ownerName = (o) => str(o).replace(/^person:/, '').trim();
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* input: { today, title, goal: { id, title, byAt } | null, end (the committed end) | null, record: { plan_path? },
|
|
133
|
+
* tasks: [{ uid, title, start, end, status, milestone, owner }] (this initiative's), links, baseline: Map, baselineAt, people }
|
|
134
|
+
*/
|
|
135
|
+
function project(input) {
|
|
136
|
+
const I = input || {}, today = dn(I.today);
|
|
137
|
+
const tasks = (I.tasks || []).filter((x) => x && (x.uid || x.key) && x.kind !== 'Epic');
|
|
138
|
+
const base = I.baseline instanceof Map ? I.baseline : new Map();
|
|
139
|
+
const { T, links } = forecastOf(tasks, I.links, today);
|
|
140
|
+
const ms = [...T.values()].filter((t) => t.ms);
|
|
141
|
+
const pickEnd = (L) => L.filter((t) => t.e != null).sort((a, b) => b.e - a.e)[0] || null;
|
|
142
|
+
const goLive = pickEnd(ms) || pickEnd([...T.values()]);
|
|
143
|
+
const crit = criticalOf(T, links, goLive, today);
|
|
144
|
+
const critSet = new Set(crit);
|
|
145
|
+
// the goal date: the KR's by-date, else the committed end, else the date the title names
|
|
146
|
+
const titleDate = dateIn(I.title, I.today);
|
|
147
|
+
const goalIso = (I.goal && I.goal.byAt ? str(I.goal.byAt).slice(0, 10) : '') || (I.end ? str(I.end).slice(0, 10) : '') || titleDate;
|
|
148
|
+
const goalN = dn(goalIso), fgo = goLive ? goLive.e : null;
|
|
149
|
+
const misses = goalN != null && fgo != null && fgo > goalN;
|
|
150
|
+
|
|
151
|
+
const raw = new Map(tasks.map((x) => [x.uid || x.key, x]));
|
|
152
|
+
const rows = [];
|
|
153
|
+
for (const t of T.values()) {
|
|
154
|
+
const b = base.get(t.uid) || null, bs = b ? dn(b.start || b.due) : null, be = b ? dn(b.due || b.start) : null;
|
|
155
|
+
const slip = be != null && t.e != null ? t.e - be : 0;
|
|
156
|
+
const startLate = !t.closed && t.status === 'To do' && t.s != null && today != null && dn((raw.get(t.uid) || {}).start) != null && dn(raw.get(t.uid).start) < today;
|
|
157
|
+
let rag = 'g';
|
|
158
|
+
if (t.closed) rag = 'done';
|
|
159
|
+
else if (t.s == null && t.e == null) rag = 'n';
|
|
160
|
+
else if (slip > 0 && critSet.has(t.uid) && misses) rag = 'r';
|
|
161
|
+
else if (slip > 0 || startLate) rag = 'a';
|
|
162
|
+
const owner = ownerName((raw.get(t.uid) || {}).owner);
|
|
163
|
+
rows.push({ uid: t.uid, title: t.title, milestone: t.ms, owner: owner || null, ownerLinked: !!owner && peopleSet(I.people).has(owner.toLowerCase()),
|
|
164
|
+
rag, critical: critSet.has(t.uid), base: { start: iso(bs), due: iso(be) }, now: { start: iso(t.s), due: iso(t.e) }, slip: slip > 0 ? slip : 0,
|
|
165
|
+
words: t.closed ? 'done' : rag === 'n' ? 'no dates' : slip > 0 ? days(slip) + ' late' : startLate ? 'start passed' : 'on time' });
|
|
166
|
+
}
|
|
167
|
+
rows.sort((a, b) => (dn(a.now.start || a.now.due) || 0) - (dn(b.now.start || b.now.due) || 0) || a.title.localeCompare(b.title));
|
|
168
|
+
|
|
169
|
+
// on track for the goal date?
|
|
170
|
+
let ontrack;
|
|
171
|
+
const src = 'Read from ' + tasks.length + (tasks.length === 1 ? ' task date' : ' task dates') + (links.length ? ' and ' + links.length + (links.length === 1 ? ' link' : ' links') : '');
|
|
172
|
+
if (!goLive) ontrack = { answer: 'unknown', words: 'No task has a date yet, so PMOS cannot say.', src };
|
|
173
|
+
else if (goalN == null) ontrack = { answer: 'unknown', forecast: iso(fgo), words: 'Go-live forecasts ' + md(fgo) + '. No goal date to compare: the KR, the end and the title name none.', src };
|
|
174
|
+
else if (!misses) ontrack = { answer: 'yes', date: goalIso, forecast: iso(fgo), words: 'Yes. Go-live forecasts ' + md(fgo) + (fgo < goalN ? ', ' + days(goalN - fgo) + ' early' : '') + '.', src };
|
|
175
|
+
else {
|
|
176
|
+
const cause = crit.map((u) => rows.find((r) => r.uid === u)).find((r) => r && r.slip > 0) || rows.filter((r) => r.slip > 0).sort((a, b) => b.slip - a.slip)[0] || null;
|
|
177
|
+
const after = cause ? crit.slice(crit.indexOf(cause.uid) + 1).map((u) => (T.get(u) || {}).title).filter(Boolean) : [];
|
|
178
|
+
ontrack = { answer: 'no', date: goalIso, forecast: iso(fgo), slip: fgo - goalN,
|
|
179
|
+
words: 'No. Forecast ' + md(fgo) + ', ' + days(fgo - goalN) + ' late.', cause: cause ? { uid: cause.uid, title: cause.title, slip: cause.slip } : null,
|
|
180
|
+
why: cause ? '"' + cause.title + '" ends ' + days(cause.slip) + ' after its baseline' + (cause.critical ? ' and sits on the critical path' + (after.length ? ', so ' + listOf(after.map((x) => '"' + x + '"')) + (after.length === 1 ? ' moves' : ' move') : '') : '') + '.' : 'Open work is past its due day.', src };
|
|
181
|
+
}
|
|
182
|
+
// the ✦: move the go-live milestone to its forecast. Never the goal, the KR or the title.
|
|
183
|
+
let proposal = null;
|
|
184
|
+
if (ontrack.answer === 'no' && goLive && goLive.ms) {
|
|
185
|
+
const raw0 = raw.get(goLive.uid) || {}, was = dn(raw0.end != null ? raw0.end : raw0.due);
|
|
186
|
+
if (was != null && was < fgo) proposal = { kind: 'milestone-date', task: goLive.uid, title: goLive.title, from: iso(was), to: iso(fgo),
|
|
187
|
+
text: 'Move ◇ "' + goLive.title + '" to its forecast, ' + md(fgo) + '. Its baseline stays. ' + (I.goal && I.goal.title ? 'The goal "' + I.goal.title + '"' : 'The goal date') + ' and the title stay until you change them.' };
|
|
188
|
+
}
|
|
189
|
+
// the gate to leave Plan
|
|
190
|
+
const dated = ms.length ? ms.every((t) => t.e != null) : !!str((I.record || {}).plan_path) || tasks.some((x) => x.end || x.due);
|
|
191
|
+
const msRows = rows.filter((r) => r.milestone);
|
|
192
|
+
const owned = msRows.length > 0 && msRows.every((r) => r.ownerLinked);
|
|
193
|
+
const goIso = goLive ? iso(dn((raw.get(goLive.uid) || {}).end != null ? raw.get(goLive.uid).end : (raw.get(goLive.uid) || {}).due) || goLive.e) : '';
|
|
194
|
+
const krIso = I.goal && I.goal.byAt ? str(I.goal.byAt).slice(0, 10) : '';
|
|
195
|
+
const matches = !!goIso && (!krIso || krIso === goIso) && (!titleDate || titleDate === goIso) && !!(krIso || titleDate || I.end);
|
|
196
|
+
const unowned = msRows.filter((r) => !r.ownerLinked).map((r) => r.title);
|
|
197
|
+
const gate = { label: 'Gate to leave Plan', parts: [
|
|
198
|
+
{ text: 'dated plan', ok: dated, ...(dated ? {} : { note: ms.length ? 'A milestone has no due day' : 'No milestone and no plan_path yet' }) },
|
|
199
|
+
{ text: 'owners in People', ok: owned, ...(owned ? {} : { note: msRows.length ? 'No owner in People: ' + unowned.slice(0, 3).join(', ') + (unowned.length > 3 ? ' and ' + (unowned.length - 3) + ' more' : '') : 'No milestone yet' }) },
|
|
200
|
+
{ text: 'go-live matches the goal', ok: matches, ...(matches ? {} : { note: !goIso ? 'Go-live has no date' : [krIso && krIso !== goIso ? 'KR says ' + md(dn(krIso)) : '', titleDate && titleDate !== goIso ? 'title says ' + md(dn(titleDate)) : '', !(krIso || titleDate || I.end) ? 'no KR date, end or title date to match' : ''].filter(Boolean).join('; ') + (goIso ? ' (go-live ' + md(dn(goIso)) + ')' : '') }) },
|
|
201
|
+
] };
|
|
202
|
+
return { kind: 'project', gate, rows, critical: crit.map((u) => (T.get(u) || {}).title).filter(Boolean), goLive: goLive ? { uid: goLive.uid, title: goLive.title, due: iso(goLive.e) } : null,
|
|
203
|
+
ontrack, proposal, baselineAt: I.baselineAt || null };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Full SDLC: the gate before the first pull request reads the record's done test and kill condition (WfB). */
|
|
207
|
+
function sdlc(input) {
|
|
208
|
+
const r = (input && input.record) || {};
|
|
209
|
+
const dt = !!str(r.done_test_path).trim(), kill = !!str(r.kill).trim();
|
|
210
|
+
return { kind: 'sdlc', gate: { label: 'Gate to the first pull request', parts: [
|
|
211
|
+
{ text: 'done test', ok: dt, ...(dt ? {} : { note: 'No done test is written yet' }) },
|
|
212
|
+
{ text: 'kill condition', ok: kill, ...(kill ? {} : { note: 'No kill condition is written yet' }) },
|
|
213
|
+
] } };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** A Project as a work breakdown (pmos jira draft): each ◇ milestone in date order with the open tasks that end on or before it and after
|
|
217
|
+
* the milestone before; tasks after the last milestone go under "After the last milestone". → [{ milestone: { uid, title, due } | null, tasks }] */
|
|
218
|
+
function wbsOf(tasks) {
|
|
219
|
+
const T = (tasks || []).filter((x) => x && x.kind !== 'Epic').map((x) => ({ uid: x.uid || x.key, title: str(x.title), due: str(x.end || x.due).slice(0, 10) || null, owner: ownerName(x.owner) || null, milestone: !!x.milestone }));
|
|
220
|
+
const ms = T.filter((t) => t.milestone).sort((a, b) => String(a.due || '9').localeCompare(String(b.due || '9')));
|
|
221
|
+
const rest = T.filter((t) => !t.milestone);
|
|
222
|
+
const out = ms.map((m) => ({ milestone: m, tasks: [] }));
|
|
223
|
+
const tail = { milestone: null, tasks: [] };
|
|
224
|
+
for (const t of rest) {
|
|
225
|
+
const g = out.find((x) => t.due && x.milestone.due && t.due <= x.milestone.due) || (out.length && !t.due ? out[out.length - 1] : null);
|
|
226
|
+
(g || tail).tasks.push(t);
|
|
227
|
+
}
|
|
228
|
+
if (tail.tasks.length) out.push(tail);
|
|
229
|
+
return out;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
module.exports = { project, sdlc, baselineOf, dateIn, wbsOf, forecastOf, criticalOf };
|