create-pmos 0.767.0 → 0.769.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 +33 -51
- package/payload/AGENTS.md +3 -1
- 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/kind-sync.js +112 -0
- package/payload/scripts/workflow-state.js +20 -2
- package/payload/scripts/workflows.js +374 -0
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +32 -0
- package/workspace/guide/breakdown.md +5 -3
- package/workspace/guide/cli.md +1 -0
- package/workspace/lib/engine/boards.js +11 -3
- package/workspace/lib/engine/workflow-state.js +20 -2
- package/workspace/lib/engine/workflows.js +27 -3
- package/workspace/lib/initiative-chat.js +1 -1
- package/workspace/lib/initiative-writer.js +12 -1
- package/workspace/lib/routes-boards.js +49 -2
- package/workspace/lib/task-cli.js +25 -2
- package/workspace/lib/task-store.js +1 -1
- package/workspace/lib/vendor/scripts/workflow-state.js +20 -2
- package/workspace/lib/vendor/scripts/workflows.js +374 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-pop-work.css +7 -0
- package/workspace/public/pm/cozy-pop-work.js +27 -12
- package/workspace/public/pm/cozy-task-pop.css +57 -17
- package/workspace/public/pm/cozy-task-pop.js +161 -20
- package/workspace/public/pm/task-card.js +113 -5
- package/workspace/public/pm/vw-ds.js +112 -38
- package/workspace/public/pm/work-select.js +27 -5
- package/workspace/test-lists/gantt-drag-nest.json +9 -0
- package/workspace/test-lists/task-detail-one-column.json +9 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* workflows.js — the workflows an initiative can run (D99, initiative workflows-per-initiative). Pure: no file, no clock.
|
|
3
|
+
* workspace/lib/routes-workflows.js does the I/O (<state dir>/workflows.jsonl) and lib/routes-boards.js reads an initiative's workflow.
|
|
4
|
+
*
|
|
5
|
+
* CATS · ENDS · OUTPUT_KINDS · WHEN_MODES · DECIDE · ICONS · PRODUCT_FEATURE_ID · PRODUCT_FEATURE
|
|
6
|
+
* kindOf(wf) → 'product' | 'sdlc' | 'project' the kind of work the workflow runs; it sets the gate (see below)
|
|
7
|
+
* check(wf, { existing }) → { ok, workflow } | { ok:false, status, error } validate and normalise one workflow
|
|
8
|
+
* 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
|
|
9
|
+
* forKind(folded, kind) · isKindDefault(folded, kind, wfId) the workflow a kind starts on; whether an initiative still runs it
|
|
10
|
+
* fold(lines) → { byId: Map, draft, defaultId } the library (the built-ins first)
|
|
11
|
+
* list(folded, counts?) → [workflow + { count, default? }] Product feature first, archived last
|
|
12
|
+
* defaultOf(folded) → the workflow a new initiative starts on (Product feature when none is set or it is archived)
|
|
13
|
+
* resolve(folded, id) → the workflow (Product feature when the id is unknown or missing)
|
|
14
|
+
* stageByRef(wf, ref) → the stage a key or a name names, or null
|
|
15
|
+
* switchTarget(from, to, stageKey) → the key an initiative lands on when it switches workflow (the bridge's stage, see mapOf)
|
|
16
|
+
* proposeBridge(from, to) → { [fromKey]: toKey } Claude's proposal of where each old stage goes (batch 20 item 3)
|
|
17
|
+
* mapOf(from, to, override?) → { [fromKey]: toKey } every old stage's new stage: the PM's override, the saved bridge, the proposal
|
|
18
|
+
* removedInUse(before, after, standing)→ [{ id, stage }] initiatives that stand in a stage the edit removes
|
|
19
|
+
* stagesOf(wf, { judged, current }) → the initiative's own stages, each with its reading and status (the ONE function every surface reads)
|
|
20
|
+
* copyOf(wf, name, taken) → a new editable copy
|
|
21
|
+
*
|
|
22
|
+
* A WORKFLOW is { id, name, icon, builtin?, decide, archived?, stages: [STAGE], bridge? }.
|
|
23
|
+
* bridge { from, map: { [fromStageKey]: stageKey } }: where each stage of the workflow it replaces lands (batch 20 item 3, canvas WmB).
|
|
24
|
+
* It is saved with the new workflow, so every later switch from `from` uses it. Many old stages may land in one new stage.
|
|
25
|
+
* A STAGE is { key, name, cat, output: { name, kind, template? }, finish: [text], milestone, auto, when: { mode, text? }, then, unless: [{ text, to }] }.
|
|
26
|
+
* cat ∈ CATS (To do, In progress, Done). Won't do and Archived (ENDS) are in every workflow and are not stages.
|
|
27
|
+
* The first stage is always `triage`, in To do. `then` null means the next stage in the list. `unless` sends the initiative elsewhere
|
|
28
|
+
* when PMOS judges its plain words true. A key is the slug of the stage's first name and survives a rename.
|
|
29
|
+
*
|
|
30
|
+
* THE LEDGER (workflows.jsonl), one line per change, the last line for an id wins; nothing is deleted:
|
|
31
|
+
* wf-save { wf } create or edit (Product feature is never saved: it is built in)
|
|
32
|
+
* wf-archive { id, archived }
|
|
33
|
+
* wf-draft { draft | null, note? } the one open draft the chat wrote (null clears it)
|
|
34
|
+
* wf-default { id } the workflow a new initiative starts on, for this workspace (batch 24 item 3, canvas DfA). The last
|
|
35
|
+
* line wins. Product feature can be the default. An unknown or archived id reads as Product feature.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const { STAGES: LIFE, LABELS, OUTPUTS, MILESTONES } = require('./nine-stages');
|
|
39
|
+
|
|
40
|
+
const CATS = Object.freeze(['todo', 'doing', 'done']);
|
|
41
|
+
const CAT_LABEL = Object.freeze({ todo: 'To do', doing: 'In progress', done: 'Done', wontdo: "Won't do", archived: 'Archived' });
|
|
42
|
+
const ENDS = Object.freeze(['wontdo', 'archived']);
|
|
43
|
+
const OUTPUT_KINDS = Object.freeze(['doc', 'jira', 'signoff', 'checklist']);
|
|
44
|
+
const WHEN_MODES = Object.freeze(['always', 'optional', 'only']);
|
|
45
|
+
const DECIDE = Object.freeze(['pmos', 'confirm']);
|
|
46
|
+
const ICONS = Object.freeze(['feature', 'doc', 'cart', 'swap', 'people', 'shield', 'box', 'flag', 'build', 'chart']);
|
|
47
|
+
const PRODUCT_FEATURE_ID = 'product-feature';
|
|
48
|
+
const NAME_MAX = 60, TEXT_MAX = 300, FINISH_MAX = 20, STAGES_MAX = 30;
|
|
49
|
+
|
|
50
|
+
const slug = (s) => String(s || '').toLowerCase().normalize('NFKD').replace(/[^\x00-\x7f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40).replace(/-+$/, '');
|
|
51
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
52
|
+
const oneLine = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
53
|
+
|
|
54
|
+
// Product feature: the eight steps of scripts/nine-stages.js, each in its category, with the output that finishes it.
|
|
55
|
+
const PF_KIND = { triage: 'doc', discover: 'doc', plan: 'doc', prioritize: 'checklist', build: 'jira', deliver: 'signoff', monitor: 'doc', evaluate: 'signoff' };
|
|
56
|
+
const PRODUCT_FEATURE = Object.freeze({
|
|
57
|
+
id: PRODUCT_FEATURE_ID, name: 'Product feature', icon: 'feature', builtin: true, decide: 'pmos',
|
|
58
|
+
stages: Object.freeze(LIFE.map((k) => Object.freeze({
|
|
59
|
+
key: k, name: LABELS[k], cat: k === 'triage' ? 'todo' : k === 'evaluate' ? 'done' : 'doing',
|
|
60
|
+
output: Object.freeze({ name: OUTPUTS[k], kind: PF_KIND[k] }), finish: Object.freeze([]), milestone: MILESTONES.has(k), auto: false,
|
|
61
|
+
when: Object.freeze({ mode: 'always' }), then: null, unless: Object.freeze([]),
|
|
62
|
+
}))),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// 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
|
|
66
|
+
// workflows are built in beside Product feature and, like it, cannot be edited (copy one to make your own). Every workflow starts with the
|
|
67
|
+
// key `triage` (the first stage, in To do); these two name it for their work: Initiate, and Done test.
|
|
68
|
+
const st = (key, name, cat, out, kind, o = {}) => Object.freeze({ key, name, cat, output: Object.freeze({ name: out, kind }), finish: Object.freeze(o.finish || []),
|
|
69
|
+
milestone: !!o.milestone, auto: false, when: Object.freeze({ mode: 'always' }), then: null, unless: Object.freeze([]) });
|
|
70
|
+
const PROJECT_ID = 'project', FULL_SDLC_ID = 'full-sdlc';
|
|
71
|
+
const PROJECT = Object.freeze({
|
|
72
|
+
id: PROJECT_ID, name: 'Project', icon: 'flag', builtin: true, decide: 'pmos', kind: 'project',
|
|
73
|
+
stages: Object.freeze([
|
|
74
|
+
st('triage', 'Initiate', 'todo', 'The charter: the goal, the date and who owns it', 'doc'),
|
|
75
|
+
st('plan', 'Plan', 'doing', 'A dated plan: milestones with owners from People, go-live matching the KR date', 'checklist', { milestone: true }),
|
|
76
|
+
st('execute', 'Execute', 'doing', 'The tasks done against the baseline', 'checklist'),
|
|
77
|
+
st('monitor', 'Monitor', 'doing', 'Go-live reached; the dates watched against the baseline', 'checklist', { milestone: true }),
|
|
78
|
+
st('close', 'Close', 'done', 'The lessons, and the outcome check', 'signoff'),
|
|
79
|
+
]),
|
|
80
|
+
});
|
|
81
|
+
const FULL_SDLC = Object.freeze({
|
|
82
|
+
id: FULL_SDLC_ID, name: 'Full SDLC', icon: 'build', builtin: true, decide: 'pmos', kind: 'sdlc',
|
|
83
|
+
stages: Object.freeze([
|
|
84
|
+
st('triage', 'Done test', 'todo', 'The done test and the kill condition, dated before the first pull request', 'doc'),
|
|
85
|
+
st('pulls', 'Pull requests', 'doing', 'The pull requests of the PR plan', 'checklist'),
|
|
86
|
+
st('ci', 'CI', 'doing', 'Green required checks on every pull request of the plan', 'checklist'),
|
|
87
|
+
st('merge', 'Merge', 'doing', 'Every pull request merged; the done test passes on the merged branch', 'checklist', { milestone: true }),
|
|
88
|
+
st('release', 'Release', 'done', 'Released; the outcome check starts', 'signoff', { milestone: true }),
|
|
89
|
+
]),
|
|
90
|
+
});
|
|
91
|
+
const BUILTIN = Object.freeze({ [PRODUCT_FEATURE_ID]: PRODUCT_FEATURE, [PROJECT_ID]: PROJECT, [FULL_SDLC_ID]: FULL_SDLC });
|
|
92
|
+
const isBuiltin = (id) => Object.prototype.hasOwnProperty.call(BUILTIN, id);
|
|
93
|
+
/** The workflow each kind of work starts on (lib/work-kind.js KINDS). Product management: the workspace's default (defaultOf). */
|
|
94
|
+
const KIND_WF = Object.freeze({ product: PRODUCT_FEATURE_ID, sdlc: FULL_SDLC_ID, project: PROJECT_ID });
|
|
95
|
+
/* Switching between the built-in workflows maps stages BY MEANING (WfC): Plan to Plan, Build to Execute, Release to Close. The proposal
|
|
96
|
+
* (proposeBridge) cannot know that Deliver is a release, so the three are mapped here and mapOf reads this before the proposal. */
|
|
97
|
+
const MEANING = Object.freeze({
|
|
98
|
+
'product-feature>project': { triage: 'triage', discover: 'triage', plan: 'plan', prioritize: 'plan', build: 'execute', deliver: 'close', monitor: 'close', evaluate: 'close' },
|
|
99
|
+
'product-feature>full-sdlc': { triage: 'triage', discover: 'triage', plan: 'triage', prioritize: 'triage', build: 'pulls', deliver: 'release', monitor: 'release', evaluate: 'release' },
|
|
100
|
+
'project>product-feature': { triage: 'triage', plan: 'plan', execute: 'build', monitor: 'deliver', close: 'evaluate' },
|
|
101
|
+
'project>full-sdlc': { triage: 'triage', plan: 'triage', execute: 'pulls', monitor: 'merge', close: 'release' },
|
|
102
|
+
'full-sdlc>product-feature': { triage: 'plan', pulls: 'build', ci: 'build', merge: 'build', release: 'deliver' },
|
|
103
|
+
'full-sdlc>project': { triage: 'plan', pulls: 'execute', ci: 'execute', merge: 'monitor', release: 'close' },
|
|
104
|
+
});
|
|
105
|
+
/** What a gate of each kind asks before work leaves planning, said once (the switch line names what the new kind adds). */
|
|
106
|
+
const KIND_GATE = Object.freeze({
|
|
107
|
+
product: 'the Build gate reads the done test and kill condition, or a PRD',
|
|
108
|
+
sdlc: 'the first pull request now needs a done test and a kill condition, dated before the build',
|
|
109
|
+
project: 'the Plan gate now needs a dated plan, milestones with owners and a go-live date that matches the KR',
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const bad = (error, status = 400) => ({ ok: false, status, error });
|
|
113
|
+
|
|
114
|
+
/** Validate and normalise one workflow. `existing` (the library's ids) only matters for a new id clashing with Product feature. */
|
|
115
|
+
function check(wf) {
|
|
116
|
+
if (!isObj(wf)) return bad('a workflow is an object { id?, name, icon?, decide?, stages }');
|
|
117
|
+
if (!oneLine(wf.name, NAME_MAX)) return bad(`a workflow needs a name of one line, at most ${NAME_MAX} characters`);
|
|
118
|
+
const name = wf.name.trim();
|
|
119
|
+
const id = typeof wf.id === 'string' && wf.id ? slug(wf.id) : slug(name);
|
|
120
|
+
if (!id) return bad('the name needs at least one letter or digit');
|
|
121
|
+
if (isBuiltin(id)) return bad(`${BUILTIN[id].name} is built in and cannot be changed. Copy it to make your own.`, 409);
|
|
122
|
+
const icon = ICONS.includes(wf.icon) ? wf.icon : 'flag';
|
|
123
|
+
const decide = wf.decide == null ? 'pmos' : wf.decide;
|
|
124
|
+
if (!DECIDE.includes(decide)) return bad(`decide is one of ${DECIDE.join(', ')}`);
|
|
125
|
+
if (!Array.isArray(wf.stages) || !wf.stages.length) return bad('a workflow needs at least one stage');
|
|
126
|
+
if (wf.stages.length > STAGES_MAX) return bad(`a workflow has at most ${STAGES_MAX} stages`);
|
|
127
|
+
const stages = [];
|
|
128
|
+
const keys = new Set();
|
|
129
|
+
for (let i = 0; i < wf.stages.length; i++) {
|
|
130
|
+
const s = wf.stages[i];
|
|
131
|
+
const at = `stage ${i + 1}`;
|
|
132
|
+
if (!isObj(s)) return bad(`${at} must be an object { name, cat, … }`);
|
|
133
|
+
if (!oneLine(s.name, NAME_MAX)) return bad(`${at} needs a name of one line, at most ${NAME_MAX} characters`);
|
|
134
|
+
const sname = s.name.trim();
|
|
135
|
+
let key = typeof s.key === 'string' && s.key ? slug(s.key) : slug(sname);
|
|
136
|
+
if (!key) return bad(`${at}: the name needs at least one letter or digit`);
|
|
137
|
+
if (keys.has(key)) { if (typeof s.key === 'string' && s.key) return bad(`two stages share the key "${key}"`); let n = 2; while (keys.has(key + '-' + n)) n++; key = key + '-' + n; }
|
|
138
|
+
if (!CATS.includes(s.cat)) return bad(`stage "${sname}": the category is one of To do (todo), In progress (doing), Done (done)`);
|
|
139
|
+
const o = isObj(s.output) ? s.output : {};
|
|
140
|
+
const kind = o.kind == null ? 'checklist' : o.kind;
|
|
141
|
+
if (!OUTPUT_KINDS.includes(kind)) return bad(`stage "${sname}": the output kind is one of ${OUTPUT_KINDS.join(', ')}`);
|
|
142
|
+
if (o.name != null && o.name !== '' && !oneLine(o.name, 120)) return bad(`stage "${sname}": the output is one line of at most 120 characters`);
|
|
143
|
+
if (o.template != null && o.template !== '' && !oneLine(o.template, 120)) return bad(`stage "${sname}": the template is one line of at most 120 characters`);
|
|
144
|
+
const finish = s.finish == null ? [] : s.finish;
|
|
145
|
+
if (!Array.isArray(finish) || finish.length > FINISH_MAX || finish.some((x) => !oneLine(x, 200))) return bad(`stage "${sname}": To finish is a list of at most ${FINISH_MAX} lines of at most 200 characters`);
|
|
146
|
+
const w = isObj(s.when) ? s.when : { mode: 'always' };
|
|
147
|
+
if (!WHEN_MODES.includes(w.mode)) return bad(`stage "${sname}": When it runs is one of ${WHEN_MODES.join(', ')}`);
|
|
148
|
+
if (w.mode === 'only' && !oneLine(w.text, TEXT_MAX)) return bad(`stage "${sname}": Only when needs the condition in your words (at most ${TEXT_MAX} characters)`);
|
|
149
|
+
const unless = s.unless == null ? [] : s.unless;
|
|
150
|
+
if (!Array.isArray(unless) || unless.length > 5 || unless.some((u) => !isObj(u) || !oneLine(u.text, TEXT_MAX) || typeof u.to !== 'string')) return bad(`stage "${sname}": each Unless is { text, to } and there are at most 5`);
|
|
151
|
+
keys.add(key);
|
|
152
|
+
stages.push({
|
|
153
|
+
key, name: sname, cat: s.cat,
|
|
154
|
+
output: { name: o.name ? o.name.trim() : '', kind, ...(o.template ? { template: o.template.trim() } : {}) },
|
|
155
|
+
finish: finish.map((x) => x.trim()), milestone: s.milestone === true, auto: s.auto === true,
|
|
156
|
+
when: w.mode === 'only' ? { mode: 'only', text: w.text.trim() } : { mode: w.mode },
|
|
157
|
+
then: typeof s.then === 'string' && s.then ? s.then : null,
|
|
158
|
+
unless: unless.map((u) => ({ text: u.text.trim(), to: u.to })),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// Triage is always first, in To do (WfAModel, wfRules).
|
|
162
|
+
if (stages[0].key !== 'triage' || stages[0].cat !== 'todo') return bad('Triage is always the first stage, in To do');
|
|
163
|
+
if (stages.slice(1).some((s) => s.key === 'triage')) return bad('only the first stage is Triage');
|
|
164
|
+
// Then and Unless name stages of this workflow (by key or by name).
|
|
165
|
+
const ref = (r) => (keys.has(r) ? r : (stages.find((s) => s.name.toLowerCase() === String(r).toLowerCase()) || {}).key || null);
|
|
166
|
+
for (const s of stages) {
|
|
167
|
+
if (s.then) { const k = ref(s.then); if (!k || k === s.key) return bad(`stage "${s.name}": Then must name another stage of this workflow`); s.then = k; }
|
|
168
|
+
for (const u of s.unless) { const k = ref(u.to); if (!k || k === s.key) return bad(`stage "${s.name}": Unless must go to another stage of this workflow`); u.to = k; }
|
|
169
|
+
}
|
|
170
|
+
let bridge = null;
|
|
171
|
+
if (wf.bridge != null) {
|
|
172
|
+
const br = wf.bridge;
|
|
173
|
+
if (!isObj(br) || typeof br.from !== 'string' || !br.from || !isObj(br.map)) return bad('a bridge is { from: the workflow id it replaces, map: { old stage key: stage of this workflow } }');
|
|
174
|
+
const ent = Object.entries(br.map);
|
|
175
|
+
if (ent.length > STAGES_MAX) return bad(`a bridge maps at most ${STAGES_MAX} stages`);
|
|
176
|
+
const map = {};
|
|
177
|
+
for (const [k, v] of ent) {
|
|
178
|
+
// a stage the bridge sends to that an edit removed drops out: that old stage falls back to Claude's proposal (mapOf), the save goes on
|
|
179
|
+
const nk = typeof v === 'string' ? ref(v) : null;
|
|
180
|
+
if (slug(k) && nk) map[slug(k)] = nk;
|
|
181
|
+
}
|
|
182
|
+
if (Object.keys(map).length && slug(br.from) !== id) bridge = { from: slug(br.from), map };
|
|
183
|
+
}
|
|
184
|
+
if (wf.kind != null && wf.kind !== '' && !WORK_KINDS.includes(wf.kind)) return bad(`the kind of work is one of ${WORK_KINDS.join(', ')}`);
|
|
185
|
+
const kind = WORK_KINDS.includes(wf.kind) ? wf.kind : null;
|
|
186
|
+
return { ok: true, workflow: { id, name, icon, decide, ...(kind ? { kind } : {}), stages, ...(bridge ? { bridge } : {}) } };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* kindOf(wf) — the kind of work a workflow runs: 'product' | 'sdlc' | 'project' (lib/work-kind.js KINDS).
|
|
191
|
+
*
|
|
192
|
+
* WHY (bug 2026-11-24, "Migration from Okta to Descope"): the gate read what an initiative must write from the record's old `type:`
|
|
193
|
+
* line, which the first records got as `feature` before workflows existed. Picking a Migration workflow later changed nothing, so the
|
|
194
|
+
* gate still asked a migration for a PRD and a rubric. The workflow is the PM's later and more specific choice, so the kind follows it.
|
|
195
|
+
* The built-ins say their kind. A saved workflow can say its own (`kind`). Else the name and the stage names decide, with the words
|
|
196
|
+
* lib/work-kind.js uses for a new initiative's name: a delivery word (migrate, cutover, decommission, rollout, tender, ...) reads as a
|
|
197
|
+
* Project; nothing reads as Product management, which keeps the lane rules, the old behaviour.
|
|
198
|
+
*/
|
|
199
|
+
const WORK_KINDS = Object.freeze(['product', 'sdlc', 'project']);
|
|
200
|
+
const PROJECT_CUES = ['migrate', 'migration', 'tender', 'rollout', 'roll out', 'vendor', 'procurement', 'rfp', 'cutover', 'decommission', 'switch off', 'hypercare', 'renewal', 'go-live', 'go live'];
|
|
201
|
+
const cueIn = (text) => PROJECT_CUES.find((w) => new RegExp('\\b' + w.replace(/[ -]/g, '[\\s-]+') + '\\b', 'i').test(text)) || '';
|
|
202
|
+
function kindOf(wf) {
|
|
203
|
+
if (!wf || typeof wf !== 'object') return 'product';
|
|
204
|
+
if (WORK_KINDS.includes(wf.kind)) return wf.kind;
|
|
205
|
+
if (wf.id === PRODUCT_FEATURE_ID) return 'product';
|
|
206
|
+
const words = [wf.name].concat((wf.stages || []).map((s) => s && s.name)).filter(Boolean).join(' · ');
|
|
207
|
+
return cueIn(words) ? 'project' : 'product';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Fold workflows.jsonl (objects or JSON strings), oldest first. */
|
|
211
|
+
function fold(lines) {
|
|
212
|
+
const byId = new Map(Object.entries(BUILTIN));
|
|
213
|
+
let draft = null, defaultId = null;
|
|
214
|
+
for (const raw of lines || []) {
|
|
215
|
+
let e = raw;
|
|
216
|
+
if (typeof raw === 'string') { try { e = JSON.parse(raw); } catch { continue; } }
|
|
217
|
+
if (!isObj(e)) continue;
|
|
218
|
+
if (e.kind === 'wf-save' && isObj(e.wf)) {
|
|
219
|
+
const c = check(e.wf);
|
|
220
|
+
if (!c.ok) continue;
|
|
221
|
+
const was = byId.get(c.workflow.id);
|
|
222
|
+
// copiedFrom: the workflow it began as a copy of (Product feature cannot be edited, so a simpler one starts as its copy): the ✦ that moves
|
|
223
|
+
// the initiatives over reads it (batch 20 item 3)
|
|
224
|
+
const cf = typeof e.copiedFrom === 'string' ? e.copiedFrom : was && was.copiedFrom ? was.copiedFrom : null;
|
|
225
|
+
byId.set(c.workflow.id, { ...c.workflow, ...(was && was.archived ? { archived: true } : {}), ...(cf ? { copiedFrom: cf } : {}), at: e.at || null });
|
|
226
|
+
} else if (e.kind === 'wf-archive' && typeof e.id === 'string' && byId.has(e.id) && !isBuiltin(e.id)) {
|
|
227
|
+
const w = { ...byId.get(e.id) };
|
|
228
|
+
if (e.archived) w.archived = true; else delete w.archived;
|
|
229
|
+
byId.set(e.id, w);
|
|
230
|
+
} else if (e.kind === 'wf-draft') {
|
|
231
|
+
draft = isObj(e.draft) ? { draft: e.draft, note: typeof e.note === 'string' ? e.note : '', at: e.at || null } : null;
|
|
232
|
+
} else if (e.kind === 'wf-default' && typeof e.id === 'string' && e.id) {
|
|
233
|
+
defaultId = e.id;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return { byId, draft, defaultId };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** The workflow a new initiative starts on: the last wf-default line's workflow, or Product feature when none is set, the id is not in the
|
|
240
|
+
* library, or that workflow is archived. */
|
|
241
|
+
function defaultOf(folded) {
|
|
242
|
+
const w = folded && folded.defaultId ? folded.byId.get(folded.defaultId) : null;
|
|
243
|
+
return w && !w.archived ? w : PRODUCT_FEATURE;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** The library as a list: Product feature first, then by name, archived last. counts: { [id]: n } initiatives on each. */
|
|
247
|
+
function list(folded, counts = {}) {
|
|
248
|
+
const def = defaultOf(folded).id;
|
|
249
|
+
const all = [...folded.byId.values()].map((w) => ({ ...w, count: counts[w.id] || 0, ...(w.id === def ? { default: true } : {}) }));
|
|
250
|
+
const order = [PRODUCT_FEATURE_ID, PROJECT_ID, FULL_SDLC_ID];
|
|
251
|
+
const rank = (w) => (isBuiltin(w.id) ? order.indexOf(w.id) : w.archived ? 4 : 3);
|
|
252
|
+
return all.sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name));
|
|
253
|
+
}
|
|
254
|
+
const resolve = (folded, id) => (id && folded && folded.byId.get(id)) || PRODUCT_FEATURE;
|
|
255
|
+
|
|
256
|
+
/** The stage a key or a name names (old lifecycle names read too: Ideate → Discover, Strategize → Prioritize). */
|
|
257
|
+
function stageByRef(wf, ref) {
|
|
258
|
+
if (ref == null || !wf) return null;
|
|
259
|
+
const r = String(ref).trim().replace(/^◆\s*/, '');
|
|
260
|
+
const low = r.toLowerCase();
|
|
261
|
+
const old = { ideate: 'discover', strategize: 'prioritize' }[low];
|
|
262
|
+
return wf.stages.find((s) => s.key === r || s.key === old) || wf.stages.find((s) => s.name.toLowerCase() === low) || null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Claude's proposal of where each stage of `from` lands in `to` (batch 20 item 3, canvas WmB). Order is kept, so no stage is guessed out of
|
|
266
|
+
* sequence. Anchors first: the same key or name, the same stem in the same category ("Discover" → "Discovery"), the stage whose output is Jira tickets, the first
|
|
267
|
+
* stage to the first and the last to the last. Between two anchors an old stage stays with the earlier one until a ◆ milestone closes it
|
|
268
|
+
* (Build, ◆ Deliver → Implementation; Monitor → Evaluation); a wider gap spreads in order. → { [fromKey]: toKey } for every stage of from. */
|
|
269
|
+
function proposeBridge(from, to) {
|
|
270
|
+
const F = (from && from.stages) || [], T = (to && to.stages) || [];
|
|
271
|
+
const out = {};
|
|
272
|
+
if (!T.length) return out;
|
|
273
|
+
const low = (x) => String(x || '').toLowerCase().trim();
|
|
274
|
+
const stem = (x) => { const v = low(x).replace(/[^a-z0-9]/g, ''); return v.length >= 6 ? v.slice(0, 6) : null; };
|
|
275
|
+
const anchor = F.map((s) => {
|
|
276
|
+
let j = T.findIndex((t) => t.key === s.key || low(t.name) === low(s.name));
|
|
277
|
+
if (j < 0 && stem(s.name)) j = T.findIndex((t) => t.cat === s.cat && stem(t.name) === stem(s.name));
|
|
278
|
+
return j;
|
|
279
|
+
});
|
|
280
|
+
const tj = T.findIndex((t) => t.output && t.output.kind === 'jira');
|
|
281
|
+
if (tj >= 0 && !anchor.includes(tj)) { const i = F.findIndex((s, n) => anchor[n] < 0 && s.output && s.output.kind === 'jira'); if (i >= 0) anchor[i] = tj; }
|
|
282
|
+
if (F.length && anchor[0] < 0) anchor[0] = 0;
|
|
283
|
+
if (F.length > 1 && anchor[F.length - 1] < 0) anchor[F.length - 1] = T.length - 1;
|
|
284
|
+
// keep the order: an anchor that would go back is dropped
|
|
285
|
+
let hi = -1;
|
|
286
|
+
for (let i = 0; i < F.length; i++) { if (anchor[i] < 0) continue; if (anchor[i] < hi) anchor[i] = -1; else hi = anchor[i]; }
|
|
287
|
+
for (let i = 0; i < F.length;) {
|
|
288
|
+
if (anchor[i] >= 0) { out[F[i].key] = T[anchor[i]].key; i++; continue; }
|
|
289
|
+
let j = i; while (j < F.length && anchor[j] < 0) j++;
|
|
290
|
+
const a = i > 0 ? anchor[i - 1] : 0, b = j < F.length ? anchor[j] : a, n = j - i;
|
|
291
|
+
let closed = false;
|
|
292
|
+
for (let k = 0; k < n; k++) {
|
|
293
|
+
let t = a;
|
|
294
|
+
if (b - a === 1) { t = closed ? b : a; if (F[i + k].milestone) closed = true; }
|
|
295
|
+
else if (b - a > 1) t = Math.min(b, a + Math.round(((k + 1) * (b - a)) / (n + 1)));
|
|
296
|
+
out[F[i + k].key] = T[t].key;
|
|
297
|
+
}
|
|
298
|
+
i = j;
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** 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. */
|
|
304
|
+
function mapOf(from, to, override) {
|
|
305
|
+
const p = proposeBridge(from, to);
|
|
306
|
+
const br = to && to.bridge && from && to.bridge.from === from.id ? to.bridge.map : (from && to && MEANING[from.id + '>' + to.id]) || {};
|
|
307
|
+
const ok = (k) => !!k && !!(to.stages || []).find((s) => s.key === k);
|
|
308
|
+
const out = {};
|
|
309
|
+
for (const s of (from && from.stages) || []) {
|
|
310
|
+
const o = override && override[s.key];
|
|
311
|
+
out[s.key] = ok(o) ? o : ok(br[s.key]) ? br[s.key] : p[s.key];
|
|
312
|
+
}
|
|
313
|
+
return out;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Switching workflow (WfAChange): the stage the bridge (or Claude's proposal) sends the current stage to; no current stage, the first stage. */
|
|
317
|
+
function switchTarget(from, to, stageRef) {
|
|
318
|
+
const cur = stageByRef(from, stageRef);
|
|
319
|
+
if (!cur) return to.stages[0].key;
|
|
320
|
+
return mapOf(from, to)[cur.key] || to.stages[0].key;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** standing: [{ id, stage }] (stage = key). The ones whose stage the edit removes (WfARemove). */
|
|
324
|
+
function removedInUse(before, after, standing) {
|
|
325
|
+
const keep = new Set(after.stages.map((s) => s.key));
|
|
326
|
+
return (standing || []).filter((x) => { const s = stageByRef(before, x.stage); return s && !keep.has(s.key); }).map((x) => ({ id: x.id, stage: stageByRef(before, x.stage).key }));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** The initiative's own stages: what the stage track, the stage card, the Viewer and the program milestones read.
|
|
330
|
+
* judged: { [stageKey]: { runs: true|false|null, why, cite } } (the agent's readings of Only-when stages, the last one per stage)
|
|
331
|
+
* current: the stage key the initiative stands in. Each stage gets n (1-based), of, status ('done' | 'current' | 'next' | 'skipped'), and
|
|
332
|
+
* for an Only-when stage its reading (null when PMOS has not read it yet). A skip is a reading of runs:false; an Optional stage is skipped
|
|
333
|
+
* only when a reading says so. */
|
|
334
|
+
function stagesOf(wf, { judged = {}, current = null } = {}) {
|
|
335
|
+
const w = wf || PRODUCT_FEATURE;
|
|
336
|
+
const at = w.stages.findIndex((s) => s.key === current);
|
|
337
|
+
return w.stages.map((s, i) => {
|
|
338
|
+
const j = judged && judged[s.key] ? judged[s.key] : null;
|
|
339
|
+
const skipped = !!j && j.runs === false;
|
|
340
|
+
const status = skipped ? 'skipped' : at < 0 ? (i === 0 ? 'current' : 'next') : i < at ? 'done' : i === at ? 'current' : 'next';
|
|
341
|
+
return { key: s.key, name: s.name, cat: s.cat, milestone: s.milestone, auto: s.auto, output: s.output, finish: s.finish, when: s.when,
|
|
342
|
+
then: s.then, unless: s.unless, n: i + 1, of: w.stages.length, status, reading: j ? { runs: j.runs, why: j.why || '', cite: j.cite || null } : null };
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** A new editable copy of a workflow ("Copy of X", a free id). */
|
|
347
|
+
function copyOf(wf, name, taken) {
|
|
348
|
+
const n = oneLine(name, NAME_MAX) ? name.trim() : 'Copy of ' + wf.name;
|
|
349
|
+
let id = slug(n) || 'workflow', k = 2;
|
|
350
|
+
while ((taken && taken.has(id)) || isBuiltin(id)) id = slug(n) + '-' + k++;
|
|
351
|
+
return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', ...(WORK_KINDS.includes(wf.kind) ? { kind: wf.kind } : {}), stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** The workflow a kind of work starts on: Project and Full SDLC their own; Product management the workspace's default (defaultOf). */
|
|
355
|
+
function forKind(folded, kind) {
|
|
356
|
+
const id = KIND_WF[kind];
|
|
357
|
+
if (!id || id === PRODUCT_FEATURE_ID) return defaultOf(folded);
|
|
358
|
+
return BUILTIN[id];
|
|
359
|
+
}
|
|
360
|
+
/** Whether an initiative on workflow `wfId` runs its kind's default: the kind's built-in, or for Product management Product feature or the
|
|
361
|
+
* workspace default. A workflow the PM picked by hand is not a kind's default, so a kind change leaves it alone. */
|
|
362
|
+
function isKindDefault(folded, kind, wfId) {
|
|
363
|
+
if (kind === 'product') return wfId === PRODUCT_FEATURE_ID || wfId === defaultOf(folded).id;
|
|
364
|
+
return wfId === KIND_WF[kind];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** The ◆ stages of a workflow: what a program milestone may wait on (D99 point 7). Product feature: Deliver first. */
|
|
368
|
+
const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.milestone).map((s) => ({ key: s.key, name: s.name }));
|
|
369
|
+
|
|
370
|
+
module.exports = {
|
|
371
|
+
CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
|
|
372
|
+
PROJECT_ID, PROJECT, FULL_SDLC_ID, FULL_SDLC, BUILTIN, KIND_WF, KIND_GATE, MEANING, isBuiltin, forKind, isKindDefault,
|
|
373
|
+
WORK_KINDS, kindOf, slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
374
|
+
};
|
|
@@ -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-24T08:04:31Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.769.0",
|
|
4
|
+
"at": "2026-11-24T08:04:34.713Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1729,
|
|
9
|
+
"t": "The task detail is one column, with its fields as chips",
|
|
10
|
+
"s": "The task detail is one column, with its fields as chips",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.768.0",
|
|
17
|
+
"at": "2026-11-24T07:49:37.442Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1731,
|
|
22
|
+
"t": "The workflow decides the kind of work, not a legacy type: feature",
|
|
23
|
+
"s": "The workflow decides the kind of work, not a legacy type: feature",
|
|
24
|
+
"k": "fix"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"n": 1730,
|
|
28
|
+
"t": "Drag to nest, take out and reorder in the Gantt, like the List",
|
|
29
|
+
"s": "Drag to nest, take out and reorder in the Gantt, like the List",
|
|
30
|
+
"k": "new"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
2
34
|
{
|
|
3
35
|
"v": "0.767.0",
|
|
4
36
|
"at": "2026-11-24T07:34:38.820Z",
|
|
@@ -17,14 +17,16 @@ If the save fails, the change goes back and a message tells you why, for example
|
|
|
17
17
|
|
|
18
18
|
## Subtasks
|
|
19
19
|
|
|
20
|
-
A task can sit under another task, at any depth. To add a subtask, type `under <parent>: <title>` in the add box of the Work breakdown, for example `under Batch 2: TM web`. To move a task, open its **More** menu and select **Make subtask of…** or **Move out of …**. With a mouse you can also drag a task in the List:
|
|
20
|
+
A task can sit under another task, at any depth. To add a subtask, type `under <parent>: <title>` in the add box of the Work breakdown, for example `under Batch 2: TM web`. To move a task, open its **More** menu and select **Make subtask of…** or **Move out of …**. With a mouse you can also drag a task, in the List or in the Gantt (hold its name):
|
|
21
21
|
|
|
22
22
|
- Drop it on another task to put it under that task.
|
|
23
|
-
- Drop it on the top or bottom edge of a row to put it
|
|
23
|
+
- Drop it on the top or bottom edge of a row to put it just before or after that row, under the same parent and in the same stage. This is also how you change the order of tasks in a stage.
|
|
24
24
|
- Drop it on a stage heading to move it to that stage, at the top level.
|
|
25
25
|
- Drag it to the left to move it out of its parent, one level up.
|
|
26
26
|
|
|
27
|
-
If you drag a selected task, all the selected tasks move. One **Undo** puts them back.
|
|
27
|
+
If you drag a selected task, all the selected tasks move. One **Undo** puts them back, and their order too.
|
|
28
|
+
|
|
29
|
+
In **Make subtask of…**, the tasks of the same stage come first. When the list is long, type in **Find a task** to narrow it.
|
|
28
30
|
|
|
29
31
|
When a stage has 8 or more tasks and several of them share a go-live date, PMOS suggests groups, for example "Group the 12 tasks of Build into 3 batches?". Select ✓ to make one parent for each date and put the tasks under it. One **Undo** removes the parents again. PMOS does not group tasks without your ✓.
|
|
30
32
|
|
package/workspace/guide/cli.md
CHANGED
|
@@ -562,6 +562,7 @@ An agent adds and closes tasks when you ask, so you do not have to find the task
|
|
|
562
562
|
- `pmos task set <task> [<task> …] --parent <task>` puts tasks under a parent task as subtasks; `--parent none` moves them back to the top level. A loop or a parent that does not exist is refused. The answer prints an `Undo:` line, one command per old parent. `pmos task add … --parent <task>` adds a new task as a subtask.
|
|
563
563
|
- `pmos task remove <task> [<task> …]` deletes a task that was added by mistake, such as a placeholder or a duplicate. The task goes from every list, and the Undo on the page brings it back. For work that stopped, use Archived or Won't do instead. A breakdown item cannot be deleted: set it to Won't do.
|
|
564
564
|
- `pmos task describe <task>` prints the task's description and its sources. `pmos task describe <task> "<text>"` writes it: what the task is, why it matters, and when it is done. `none` clears it. The task page shows it at once, with Undo. When a task has no description, PMOS writes one by itself from the initiative's record, PRD and plan documents, and names its sources. A Jira ticket keeps its description in Jira.
|
|
565
|
+
- `pmos task comment <task>` lists the task's comments. `pmos task comment <task> "<text>"` adds one. The task page shows it at once, under Activity › Comments. Comments stay in PMOS: nothing is sent to Jira.
|
|
565
566
|
- `pmos task link <from> <to>` makes `<to>` wait on `<from>`. `--type` sets how they wait: `fs` (start after it finishes, the default), `ss` (start when it starts), `ff` (finish when it finishes) or `sf` (finish when it starts). `--lag` adds days, or takes them away with a negative number. Make a link only when the PM asks for it. To suggest a link, add `--propose --why "<reason>"`: the link shows under the blue ✦ in the Tasks header, and the PM approves it or drops it. A link that loops back to a task is refused.
|
|
566
567
|
- `pmos task unlink <from> <to>` removes the link. The dates stay as they are.
|
|
567
568
|
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
* task-update { task, state?, start?, due?, title?, owner?, notes?, initiative?, why } a status move, a reschedule, a rename or an edit in the Viewer
|
|
40
40
|
* ticket-note { ref, notes } the PM's own notes on a Jira ticket (Jira keeps its fields)
|
|
41
41
|
* task-description { task, description, sources? } a task's description (task-descriptions): '' clears; sources [{ path, line, title }]
|
|
42
|
+
* task-comment { task, text } a comment on a task (task-detail-one-column): each line adds one, oldest first
|
|
42
43
|
* task-section { task, section } a task's place in the breakdown (one view, feedback batch 6 item 1): the key
|
|
43
44
|
* of a stage of its initiative's workflow, '' for "Not in a stage". It is the task's place, never its state, and moving a task
|
|
44
45
|
* never moves the initiative. `task` is a Board task or a breakdown item; the last line wins.
|
|
@@ -195,7 +196,10 @@ const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept
|
|
|
195
196
|
// a task's priority, set in the row (initiative inline-sprint-priority): P1, P2 or P3; '' takes it out
|
|
196
197
|
'task-priority',
|
|
197
198
|
// a task's description (initiative task-descriptions): what it is, why, and when it is done; '' clears it
|
|
198
|
-
'task-description'
|
|
199
|
+
'task-description',
|
|
200
|
+
// a comment on a task (initiative task-detail-one-column): the task popup's Activity › Comments and `pmos task comment`
|
|
201
|
+
'task-comment']);
|
|
202
|
+
const COMMENT_MAX = 2000; // one comment on a task (task-comment)
|
|
199
203
|
// A task's state is its only stage (Wawan, 2026-10-25): the same five every workflow ends in. An old 'In review' reads as In progress (taskState).
|
|
200
204
|
const TASK_STATES = Object.freeze(['To do', 'In progress', 'Done', "Won't do", 'Archived']);
|
|
201
205
|
const taskState = (s) => (s === 'In review' ? 'In progress' : TASK_STATES.includes(s) ? s : null);
|
|
@@ -229,6 +233,7 @@ function fold(events) {
|
|
|
229
233
|
const parents = new Map(); // task id (or Jira key) → the id of its parent task (subtasks, initiative work-subtasks); the last task-parent line wins
|
|
230
234
|
const orders = new Map(); // key(initiative, section) → the task ids in the PM's order inside that stage; the last task-order line wins
|
|
231
235
|
const pins = new Map(); // task id (or Jira key) → true | false: the PM's pin on a milestone; a null line takes it out (the rule again)
|
|
236
|
+
const comments = new Map(); // task id → [{ text, by, at }]: its comments, oldest first (task-detail-one-column)
|
|
232
237
|
const descriptions = new Map(); // task id → { text, by, at, sources }: the task's description (task-descriptions); the last line wins, '' clears
|
|
233
238
|
const priorities = new Map(); // task id → 'P1' | 'P2' | 'P3': the PM's priority (inline-sprint-priority); a '' line takes it out, the last line wins
|
|
234
239
|
const removed = new Map(); // task id → the task a task-remove took out, so a task-restore (Delete's Undo) puts it back
|
|
@@ -339,6 +344,9 @@ function fold(events) {
|
|
|
339
344
|
} else if (e.kind === 'task-description' && typeof e.task === 'string' && e.task && typeof e.description === 'string') {
|
|
340
345
|
if (e.description) descriptions.set(e.task, { text: e.description, by: e.by || null, at: e.at || null, sources: Array.isArray(e.sources) ? e.sources.filter((x) => x && typeof x.path === 'string').slice(0, 8) : [] });
|
|
341
346
|
else descriptions.delete(e.task);
|
|
347
|
+
} else if (e.kind === 'task-comment' && typeof e.task === 'string' && e.task && typeof e.text === 'string' && e.text.trim()) {
|
|
348
|
+
if (!comments.has(e.task)) comments.set(e.task, []);
|
|
349
|
+
comments.get(e.task).push({ text: e.text.slice(0, COMMENT_MAX), by: e.by || null, at: e.at || null });
|
|
342
350
|
} else if (e.kind === 'task-priority' && typeof e.task === 'string' && e.task && typeof e.priority === 'string' && /^(P[1-3])?$/.test(e.priority)) {
|
|
343
351
|
if (e.priority) priorities.set(e.task, e.priority); else priorities.delete(e.task);
|
|
344
352
|
} else if (e.kind === 'task-pin' && typeof e.task === 'string' && e.task && (typeof e.pinned === 'boolean' || e.pinned === null)) {
|
|
@@ -422,7 +430,7 @@ function fold(events) {
|
|
|
422
430
|
suggestNo.set(e.id, { kind: e.of === 'merge' ? 'merge' : 'split', fp: e.fp, at: e.at || null });
|
|
423
431
|
}
|
|
424
432
|
}
|
|
425
|
-
return { boards, moves, assigns, asks, stages, iniWorkflows, tasks, removed, sections, parents, orders, milestones, pins, priorities, descriptions, ticketNotes, ticketDates, epics, archives, deleted, notDup, iniWf, ends, judged, autoOver, ticketMoves, backlogRank, smOps, smUndone, suggestNo, events: list };
|
|
433
|
+
return { boards, moves, assigns, asks, stages, iniWorkflows, tasks, removed, sections, parents, orders, milestones, pins, priorities, descriptions, comments, ticketNotes, ticketDates, epics, archives, deleted, notDup, iniWf, ends, judged, autoOver, ticketMoves, backlogRank, smOps, smUndone, suggestNo, events: list };
|
|
426
434
|
}
|
|
427
435
|
|
|
428
436
|
/** The stages an initiative runs on a board: its own workflow when one is recorded, else the board's. */
|
|
@@ -926,5 +934,5 @@ module.exports = {
|
|
|
926
934
|
templateWorkflow, isTemplateEdited, fold, readingOf, deriveStage, stageOf, catOf, moveWarnings, cardWarnings,
|
|
927
935
|
applyWorkflowEdit, filterRows, health, counts, sprintsOf, backlogOf, key,
|
|
928
936
|
INI_TEMPLATES, TASK_STATES, taskState, isBuildStage, templateBuilds, boardSettings, jiraProjectsOf, JIRA_KEY_RE, JIRA_PROJECT_RE, workflowOf, templateOf, applyIniWorkflow, taskOf, shiftDay,
|
|
929
|
-
ITEM_PROGRESS, itemStatus, taskItem, rollupItems, wouldCycle,
|
|
937
|
+
ITEM_PROGRESS, itemStatus, taskItem, rollupItems, wouldCycle, COMMENT_MAX,
|
|
930
938
|
};
|
|
@@ -640,6 +640,24 @@ function workflowOf(root, id) {
|
|
|
640
640
|
}
|
|
641
641
|
return m.wf.get(id) || '';
|
|
642
642
|
}
|
|
643
|
+
/*
|
|
644
|
+
* workKindOf(root, id, fm) — the kind of work that sets the gate: the record's `kind:` line when it has one, else the kind of the workflow
|
|
645
|
+
* the initiative runs (scripts/workflows.js kindOf). Bug 2026-11-24: a Migration initiative kept the `type: feature` its record was born
|
|
646
|
+
* with before workflows existed, and the gate asked it for a PRD and a rubric. The workflow is the later, more specific choice, so it
|
|
647
|
+
* decides. No workflow (PMOS itself, a repository without boards) or Product feature keeps 'product', the lane rules.
|
|
648
|
+
*/
|
|
649
|
+
function workKindOf(root, id, fm) {
|
|
650
|
+
const k = String((fm && fm.kind) || '').trim().replace(/^["']|["']$/g, '');
|
|
651
|
+
if (k === 'sdlc' || k === 'project' || k === 'product') return k;
|
|
652
|
+
try {
|
|
653
|
+
const wfId = workflowOf(root, id);
|
|
654
|
+
if (wfId === null) return 'product';
|
|
655
|
+
const WF = require('./workflows');
|
|
656
|
+
const f = [['pmos', 'state'], ['state'], ['.pmos']].map((rel) => path.join(root, ...rel, 'workflows.jsonl')).find((x) => fs.existsSync(x));
|
|
657
|
+
const lib = WF.fold(f ? jsonl.readJsonl(f).rows : []);
|
|
658
|
+
return WF.kindOf(wfId ? WF.resolve(lib, wfId) : WF.defaultOf(lib));
|
|
659
|
+
} catch { return 'product'; }
|
|
660
|
+
}
|
|
643
661
|
/** The lanes a repository's initiatives may declare — what the lane picker offers and the lane write accepts. */
|
|
644
662
|
function laneNames(profile) { return laneDefs.laneNames(profile === 'pm-artifacts' ? 'pm-artifacts' : 'product-code'); }
|
|
645
663
|
function lanesFor(root) {
|
|
@@ -1019,7 +1037,7 @@ function computeWorkflowDerived(id, opts) {
|
|
|
1019
1037
|
// 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
|
|
1020
1038
|
// pull request. Project: a dated plan (plan_path), never a PRD. Product management (and a record with no kind:) keeps the rules below. A
|
|
1021
1039
|
// PRD already on the record still satisfies the spec rung after a kind change: a gate already passed stays passed.
|
|
1022
|
-
const workKind = (
|
|
1040
|
+
const workKind = workKindOf(root, id, fm);
|
|
1023
1041
|
const planPath = String(fm.plan_path || '').trim();
|
|
1024
1042
|
const agentMode = agentEvalSet.isAgent(fm);
|
|
1025
1043
|
if (agentMode && !doneTest) {
|
|
@@ -1667,7 +1685,7 @@ function pmLadder({ id, fm, lane, effLane, knownLane, legacy, steps, root, L, re
|
|
|
1667
1685
|
// W6 (launch simulation rerun, 2026-11-15): the kind of work sets this ladder too, as it sets the product-code gate (W5) and the kit gate.
|
|
1668
1686
|
// Full SDLC: a done test and a kill condition, never a brief. Project: a dated plan (plan_path), never a brief. A brief already on the
|
|
1669
1687
|
// record still passes (a gate passed stays passed). Their deliverable is not a document: the pull requests, or the plan's milestones.
|
|
1670
|
-
const workKind = (
|
|
1688
|
+
const workKind = workKindOf(root, id, fm);
|
|
1671
1689
|
const planPath = String(fm.plan_path || '').trim();
|
|
1672
1690
|
const kindSpec = !doneTest && !exists(briefPath) && !foundBrief && (workKind === 'sdlc' || (workKind === 'project'));
|
|
1673
1691
|
const tasksPlan = kindSpec && workKind === 'project' && !planPath ? taskPlanOf(root, id) : null;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* workspace/lib/routes-workflows.js does the I/O (<state dir>/workflows.jsonl) and lib/routes-boards.js reads an initiative's workflow.
|
|
4
4
|
*
|
|
5
5
|
* CATS · ENDS · OUTPUT_KINDS · WHEN_MODES · DECIDE · ICONS · PRODUCT_FEATURE_ID · PRODUCT_FEATURE
|
|
6
|
+
* kindOf(wf) → 'product' | 'sdlc' | 'project' the kind of work the workflow runs; it sets the gate (see below)
|
|
6
7
|
* check(wf, { existing }) → { ok, workflow } | { ok:false, status, error } validate and normalise one workflow
|
|
7
8
|
* 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
9
|
* forKind(folded, kind) · isKindDefault(folded, kind, wfId) the workflow a kind starts on; whether an initiative still runs it
|
|
@@ -180,7 +181,30 @@ function check(wf) {
|
|
|
180
181
|
}
|
|
181
182
|
if (Object.keys(map).length && slug(br.from) !== id) bridge = { from: slug(br.from), map };
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
+
if (wf.kind != null && wf.kind !== '' && !WORK_KINDS.includes(wf.kind)) return bad(`the kind of work is one of ${WORK_KINDS.join(', ')}`);
|
|
185
|
+
const kind = WORK_KINDS.includes(wf.kind) ? wf.kind : null;
|
|
186
|
+
return { ok: true, workflow: { id, name, icon, decide, ...(kind ? { kind } : {}), stages, ...(bridge ? { bridge } : {}) } };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* kindOf(wf) — the kind of work a workflow runs: 'product' | 'sdlc' | 'project' (lib/work-kind.js KINDS).
|
|
191
|
+
*
|
|
192
|
+
* WHY (bug 2026-11-24, "Migration from Okta to Descope"): the gate read what an initiative must write from the record's old `type:`
|
|
193
|
+
* line, which the first records got as `feature` before workflows existed. Picking a Migration workflow later changed nothing, so the
|
|
194
|
+
* gate still asked a migration for a PRD and a rubric. The workflow is the PM's later and more specific choice, so the kind follows it.
|
|
195
|
+
* The built-ins say their kind. A saved workflow can say its own (`kind`). Else the name and the stage names decide, with the words
|
|
196
|
+
* lib/work-kind.js uses for a new initiative's name: a delivery word (migrate, cutover, decommission, rollout, tender, ...) reads as a
|
|
197
|
+
* Project; nothing reads as Product management, which keeps the lane rules, the old behaviour.
|
|
198
|
+
*/
|
|
199
|
+
const WORK_KINDS = Object.freeze(['product', 'sdlc', 'project']);
|
|
200
|
+
const PROJECT_CUES = ['migrate', 'migration', 'tender', 'rollout', 'roll out', 'vendor', 'procurement', 'rfp', 'cutover', 'decommission', 'switch off', 'hypercare', 'renewal', 'go-live', 'go live'];
|
|
201
|
+
const cueIn = (text) => PROJECT_CUES.find((w) => new RegExp('\\b' + w.replace(/[ -]/g, '[\\s-]+') + '\\b', 'i').test(text)) || '';
|
|
202
|
+
function kindOf(wf) {
|
|
203
|
+
if (!wf || typeof wf !== 'object') return 'product';
|
|
204
|
+
if (WORK_KINDS.includes(wf.kind)) return wf.kind;
|
|
205
|
+
if (wf.id === PRODUCT_FEATURE_ID) return 'product';
|
|
206
|
+
const words = [wf.name].concat((wf.stages || []).map((s) => s && s.name)).filter(Boolean).join(' · ');
|
|
207
|
+
return cueIn(words) ? 'project' : 'product';
|
|
184
208
|
}
|
|
185
209
|
|
|
186
210
|
/** Fold workflows.jsonl (objects or JSON strings), oldest first. */
|
|
@@ -324,7 +348,7 @@ function copyOf(wf, name, taken) {
|
|
|
324
348
|
const n = oneLine(name, NAME_MAX) ? name.trim() : 'Copy of ' + wf.name;
|
|
325
349
|
let id = slug(n) || 'workflow', k = 2;
|
|
326
350
|
while ((taken && taken.has(id)) || isBuiltin(id)) id = slug(n) + '-' + k++;
|
|
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 })) })) };
|
|
351
|
+
return { id, name: n, icon: wf.icon, decide: wf.decide || 'pmos', ...(WORK_KINDS.includes(wf.kind) ? { kind: wf.kind } : {}), stages: wf.stages.map((s) => ({ ...s, output: { ...s.output }, finish: [...s.finish], when: { ...s.when }, unless: s.unless.map((u) => ({ ...u })) })) };
|
|
328
352
|
}
|
|
329
353
|
|
|
330
354
|
/** The workflow a kind of work starts on: Project and Full SDLC their own; Product management the workspace's default (defaultOf). */
|
|
@@ -346,5 +370,5 @@ const milestonesOf = (wf) => (wf || PRODUCT_FEATURE).stages.filter((s) => s.mile
|
|
|
346
370
|
module.exports = {
|
|
347
371
|
CATS, CAT_LABEL, ENDS, OUTPUT_KINDS, WHEN_MODES, DECIDE, ICONS, PRODUCT_FEATURE_ID, PRODUCT_FEATURE,
|
|
348
372
|
PROJECT_ID, PROJECT, FULL_SDLC_ID, FULL_SDLC, BUILTIN, KIND_WF, KIND_GATE, MEANING, isBuiltin, forKind, isKindDefault,
|
|
349
|
-
slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
373
|
+
WORK_KINDS, kindOf, slug, check, fold, list, defaultOf, resolve, stageByRef, switchTarget, proposeBridge, mapOf, removedInUse, stagesOf, copyOf, milestonesOf,
|
|
350
374
|
};
|