create-pmos 0.557.0 → 0.559.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 +27 -81
- 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/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +8 -6
- package/workspace/changelog.json +26 -0
- package/workspace/fixtures/board-premium-facts.js +2 -12
- package/workspace/guide/initiatives-and-next-steps.md +18 -2
- package/workspace/guide/programs.md +2 -2
- package/workspace/lib/board-premium.js +5 -23
- package/workspace/lib/core-docs-needs.js +12 -16
- package/workspace/lib/core-docs.js +27 -214
- package/workspace/lib/coredoc-cli.js +6 -6
- package/workspace/lib/custom-docs.js +3 -1
- package/workspace/lib/initiative-cli.js +4 -4
- package/workspace/lib/initiative-premium.js +1 -1
- package/workspace/lib/initiative-writer.js +28 -4
- package/workspace/lib/job-graph.js +2 -2
- package/workspace/lib/refresh.js +2 -2
- package/workspace/lib/route-modules.js +0 -1
- package/workspace/lib/routes-board-premium.js +5 -11
- package/workspace/lib/routes-boards.js +5 -4
- package/workspace/lib/routes-core-docs.js +23 -113
- package/workspace/lib/routes-custom-docs.js +8 -6
- package/workspace/lib/routes-initiatives.js +12 -0
- package/workspace/lib/routes-intake.js +6 -2
- package/workspace/lib/work-kind.js +48 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-core-doc-issue-test.js +11 -18
- package/workspace/public/pm/bd-acts.js +5 -77
- package/workspace/public/pm/bd-asks.js +16 -10
- package/workspace/public/pm/bd-ini-panel.js +11 -1
- package/workspace/public/pm/bd-next.js +14 -4
- package/workspace/public/pm/bd-prog.js +4 -5
- package/workspace/public/pm/bd-views.js +7 -58
- package/workspace/public/pm/cozy-board.css +12 -24
- package/workspace/public/pm/cozy-viewer.js +11 -5
- package/workspace/public/pm/home-app.js +2 -3
- package/workspace/public/pm/home-ini.js +10 -1
- package/workspace/public/pm/ini-agent.js +40 -8
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/premium-board.js +9 -26
- package/workspace/public/pm/premium-shell.js +3 -33
- package/workspace/public/pm/prog-page.js +1 -1
- package/workspace/public/pm/work-kind.js +82 -0
- package/workspace/ready-dash-ui-test.js +1 -1
- package/workspace/server.js +3 -12
- package/workspace/test-files.json +1 -1
- package/workspace/test-lists/uncovered-board.json +1 -1
- package/workspace/lib/routes-board-docs.js +0 -46
|
@@ -55,7 +55,7 @@ const LEDGERS = Object.freeze({
|
|
|
55
55
|
r('lib/driver-needs.js', null, 'Needs you')] },
|
|
56
56
|
'<state>/core-docs.jsonl': { concept: 'core-doc-drafts', owner: 'lib/core-docs.js', readers: [
|
|
57
57
|
r('lib/routes-core-docs.js', null, 'the core documents of an initiative'),
|
|
58
|
-
r('lib/core-docs-needs.js', null, 'Needs you')] },
|
|
58
|
+
r('lib/core-docs-needs.js', null, 'Needs you (initiative drafts only)')] },
|
|
59
59
|
'<state>/metric-drafts.jsonl': { concept: 'metric-drafts', owner: 'lib/metric-drafts.js', readers: [
|
|
60
60
|
r('lib/routes-metric-drafts.js', null, 'the metric ✦ on a product, program or initiative page')] },
|
|
61
61
|
'<state>/metric-reads.jsonl': { concept: 'metric-readings', owner: 'lib/metric-reads.js', readers: [
|
|
@@ -123,7 +123,7 @@ const JOBS = Object.freeze([
|
|
|
123
123
|
q('driver', 'lib/driver.js', ['<state>/driver.jsonl'], ['initiative records', 'jira']),
|
|
124
124
|
q('goal-loops', 'lib/goal-loop.js', ['<runtime>/goal-loops.jsonl'], ['<runtime>/goal-loops.jsonl'], 'D106: each round is a run started through the capacity governor; the run writes its own records'),
|
|
125
125
|
q('finder', 'lib/report-finder.js', ['<state>/report-setups.jsonl'], ['connectors']),
|
|
126
|
-
q('coredocs', 'lib/core-docs.js', [
|
|
126
|
+
q('coredocs', 'lib/routes-core-docs.js', [], [], 'retired (batch 29 item 8): it drafted portfolio and board documents and now drafts nothing; an initiative document is drafted by Draft it or the driver'),
|
|
127
127
|
q('milestones', 'lib/milestone-review.js', ['<state>/milestone-reviews.jsonl'], ['program charters']),
|
|
128
128
|
q('propose', 'lib/proposal-runs.js', [props], ['connectors', props]),
|
|
129
129
|
q('grill', 'lib/grill-runs.js', [props, '<runtime>/grill-runs.jsonl'], [props, 'repo:DECISIONS.md']),
|
package/workspace/lib/refresh.js
CHANGED
|
@@ -74,8 +74,8 @@ const SOURCES = Object.freeze([
|
|
|
74
74
|
{ id: 'scan', label: 'Horizon scan', group: 'pmos', ic: 'search', run: 'job', how: 'bg', setIn: 'Initiatives, Horizon scan',
|
|
75
75
|
what: 'Reads the web and your repositories for changes that matter to your initiatives.', uses: ['repo'],
|
|
76
76
|
impact: 'Core documents cite the older scan.' },
|
|
77
|
-
{ id: 'coredocs', label: 'Core documents', group: 'pmos', ic: 'doc', run: 'job', how: 'bg', fixed: '
|
|
78
|
-
what: 'Drafts the
|
|
77
|
+
{ id: 'coredocs', label: 'Core documents', group: 'pmos', ic: 'doc', run: 'job', how: 'bg', fixed: 'When you press Draft it on an initiative, or the driver asks for a document',
|
|
78
|
+
what: 'Drafts the initiative documents that are due, old or missing. Portfolio and board documents are retired.', uses: ['repo', 'jira', 'scan'],
|
|
79
79
|
impact: 'The initiative driver no longer sees documents that are due or old.' },
|
|
80
80
|
{ id: 'driver', label: 'Initiative driver', group: 'pmos', ic: 'bolt', run: 'job', how: 'bg', fixed: 'Every 30 min in working hours, and when an initiative moves',
|
|
81
81
|
what: 'Checks each driven initiative for its next step and unblocks what it can.', uses: ['repo', 'jira', 'coredocs'],
|
|
@@ -54,7 +54,6 @@ const MODULES = Object.freeze([
|
|
|
54
54
|
'routes-my-work-premium', // briefing-premium-work: the premium My work page's model from the Work page's own list (read-only)
|
|
55
55
|
'routes-board-premium', // briefing-premium-board: the premium Board page's model from the Initiatives page's own routes (read-only)
|
|
56
56
|
'routes-board-trail', // premium-agreed-design: what the Agreed Board draws beside each initiative, derived from the repository (read-only)
|
|
57
|
-
'routes-board-docs', // premium-uncovered-features (Board): when each document of the Documents tab changed and by whom, from git (read-only)
|
|
58
57
|
'routes-board-grill', // premium-uncovered-features (Board): a new initiative's Why, material and first questions (page press; file mode)
|
|
59
58
|
'routes-insights-premium', // briefing-premium-insights: the premium Insights page's model from the KR metric records and report files (read-only)
|
|
60
59
|
'routes-forecast', // build brief Grill and Forecast F-A: a goal forecast's kept baseline, and the forecasts that turned
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 200 { ok, state: 'ready', model, as_of } | 202 { ok, state: 'reading' } | 500 { ok: false, state: 'error', error }
|
|
5
5
|
* model is lib/board-premium.js build(), made from the answers of the routes the production Initiatives page reads: /api/boards, /api/boards/board,
|
|
6
|
-
* /backlog, /columns
|
|
6
|
+
* /backlog, /columns and /sprints. Those routes derive the initiatives in the background and answer 202 while they do, so
|
|
7
7
|
* this route answers 202 too and the page asks again: no request waits for the read. Read-only: the page's presses go from the page to the
|
|
8
|
-
* console's own routes (POST /api/
|
|
8
|
+
* console's own routes (POST /api/boards/asks/*, /api/boards/move, /api/lifecycle, /api/boards/archive).
|
|
9
9
|
* initiative premium-board-actions adds the open asks (/api/boards/asks), the on-hold rows and the cancelled and archived rows (/backlog).
|
|
10
10
|
* Build brief F-A adds each open row's delivery forecast (r.forecast), the programs' milestones at risk (model.programForecasts) and writes a
|
|
11
11
|
* changed forecast state to <state>/forecast.jsonl (lib/forecast.js). */
|
|
@@ -13,8 +13,6 @@ const BoardPremium = require('./board-premium.js');
|
|
|
13
13
|
const BoardP = BoardPremium;
|
|
14
14
|
const Rows = require('./initiative-rows.js');
|
|
15
15
|
const boards = require('./routes-boards.js');
|
|
16
|
-
const coreDocs = require('./routes-core-docs.js');
|
|
17
|
-
const Custom = require('./custom-docs.js');
|
|
18
16
|
const path = require('path');
|
|
19
17
|
const fs = require('fs');
|
|
20
18
|
const Metrics = require('./board-metrics-premium.js');
|
|
@@ -83,12 +81,11 @@ module.exports = {
|
|
|
83
81
|
const missing = [];
|
|
84
82
|
// the late and at-risk initiatives first (the board's own `risk` view, late before at risk), then its `now` view, each initiative once
|
|
85
83
|
const listOf = (a, n) => { const seen = new Set(), out = []; const rank = (r) => (r.status === 'late' ? 0 : 1); for (const r of [...((a && a.rows) || [])].sort((x, y) => rank(x) - rank(y))) { if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } } for (const r of (n && n.rows) || []) if (!seen.has(r.id)) { seen.add(r.id); out.push(r); } return out.slice(0, 100); };
|
|
86
|
-
const [risk, now, cols, spr,
|
|
84
|
+
const [risk, now, cols, spr, held, can, arc, asks, its] = await Promise.all([
|
|
87
85
|
via(boards, '/api/boards/backlog' + q + '&view=risk&limit=100', req, ctx),
|
|
88
86
|
via(boards, '/api/boards/backlog' + q + '&view=now&limit=100', req, ctx),
|
|
89
87
|
via(boards, '/api/boards/columns' + q, req, ctx),
|
|
90
88
|
via(boards, '/api/boards/sprints' + q, req, ctx),
|
|
91
|
-
via(coreDocs, '/api/core-docs' + qs({ level: 'board', ws: pick.ws, board: pick.id }), req, ctx),
|
|
92
89
|
via(boards, '/api/boards/backlog' + q + '&view=all&status=' + encodeURIComponent('on hold') + '&limit=100', req, ctx),
|
|
93
90
|
via(boards, '/api/boards/backlog' + q + '&view=all&status=cancelled&limit=100', req, ctx),
|
|
94
91
|
via(boards, '/api/boards/backlog' + q + '&archived=1&limit=100', req, ctx),
|
|
@@ -96,11 +93,8 @@ module.exports = {
|
|
|
96
93
|
via(boards, '/api/boards/items' + q, req, ctx), // the Jira tickets of each initiative, for the stage track (premium-agreed-design B1)
|
|
97
94
|
]);
|
|
98
95
|
const ok = (r, name) => { if (r.status === 202 || !r.body || r.body.ok === false || r.body.pending) { missing.push(name); return null; } return r.body; };
|
|
99
|
-
const rk = ok(risk, 'initiatives'), nw = ok(now, 'initiatives'), c = ok(cols, 'stages'), s = ok(spr, 'sprints')
|
|
96
|
+
const rk = ok(risk, 'initiatives'), nw = ok(now, 'initiatives'), c = ok(cols, 'stages'), s = ok(spr, 'sprints');
|
|
100
97
|
const hd = ok(held, 'on-hold initiatives'), cn = ok(can, 'cancelled initiatives'), ar = ok(arc, 'archived initiatives'), ak = ok(asks, 'new asks');
|
|
101
|
-
// the documents the PM added (lib/custom-docs.js): one file read, no route
|
|
102
|
-
let custom = [];
|
|
103
|
-
try { const w = ctx.getWs ? ctx.getWs(pick.ws) : null; custom = w ? Custom.list(w.root, 'board:' + pick.id) : []; } catch { custom = []; missing.push('added documents'); }
|
|
104
98
|
// the initiatives of this workspace that a program holds (GET /api/programs): the list above is the `now` and `risk` views, so a member
|
|
105
99
|
// on a later horizon is not in it, and the program page would call it unread. Their rows come from the board's own `all` view.
|
|
106
100
|
const rowsNow = listOf(rk, nw);
|
|
@@ -116,7 +110,7 @@ module.exports = {
|
|
|
116
110
|
const model = BoardPremium.build({
|
|
117
111
|
now: Date.now(), pending: false, missing: missing.filter((m) => m !== 'core documents'), boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
|
|
118
112
|
board: head.body.board, counts: head.body.counts, nextRelease: head.body.nextRelease || null, pastReleases: head.body.pastReleases || [],
|
|
119
|
-
rows: rowsNow, members, columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] },
|
|
113
|
+
rows: rowsNow, members, columns: c ? c.columns : [], sprints: s || { source: 'none', sprints: [] },
|
|
120
114
|
items: its && its.body && its.body.ok !== false && Array.isArray(its.body.items) ? its.body.items : [], held: hd ? hd.rows : [], cancelled: cn ? cn.rows : [], archived: ar ? ar.rows : [], asks: ak ? ak.asks || [] : null,
|
|
121
115
|
});
|
|
122
116
|
// workspace grill W2: a row nothing read for says No signal (grey), with where its status came from (r.signal: from, why, source,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* POST /api/boards/move { ws, board, id, to, why? } → { ok, row, warnings }
|
|
21
21
|
* POST /api/boards/assign { ws, id, to } → { ok }
|
|
22
22
|
* POST /api/boards/asks/add { ws, board, line, source? } → { ok, ask, draft }
|
|
23
|
-
* POST /api/boards/asks/accept { ws, board, ask, title, lane, anchor, intent?, id? } → { ok, initiative, stage }
|
|
23
|
+
* POST /api/boards/asks/accept { ws, board, ask, title, lane, anchor, intent?, id?, kind? } → { ok, initiative, stage } (kind: product | sdlc | project, default product)
|
|
24
24
|
* POST /api/boards/asks/decline { ws, board, ask, why } → { ok }
|
|
25
25
|
* POST /api/boards/asks/more { ws, board, ask, note? } → { ok }
|
|
26
26
|
* POST /api/boards/settings { ws, board, buildDeliver?, jira?, offer?, defTpl? } → { ok, board } jira: one key or a list
|
|
@@ -103,6 +103,7 @@ const TS = require('./task-store.js');
|
|
|
103
103
|
const holdSpans = require('./hold-spans.js');
|
|
104
104
|
const ledgers = require('./plan-ledgers.js');
|
|
105
105
|
const intake = require(repoScript('intake.js'));
|
|
106
|
+
const WK = require('./work-kind.js');
|
|
106
107
|
const OS = require('./one-stage.js');
|
|
107
108
|
|
|
108
109
|
const LEDGER = 'boards.jsonl';
|
|
@@ -363,7 +364,7 @@ function baseRowsRead(w) {
|
|
|
363
364
|
const relRec = String(rec.record || '').split(path.sep).join('/');
|
|
364
365
|
const dm = /^products\/([^/]+)\//.exec(relRec);
|
|
365
366
|
rows.push({
|
|
366
|
-
id, title: r.title, lane: r.lane || null,
|
|
367
|
+
id, title: r.title, lane: r.lane || null, kind: WK.kindOf(fm.kind), // batch 29 item 11: no line reads as Product management
|
|
367
368
|
owner: fm.owner ? String(fm.owner) : null,
|
|
368
369
|
anchor: r.anchor || null, rank: Number.isInteger(r.rank) ? r.rank : null, dormant: !!r.dormant,
|
|
369
370
|
status: statusOf(rec, r.health, end, day, jiraOf(w.root, id)),
|
|
@@ -534,7 +535,7 @@ function boardRow(board, base, folded, lib) {
|
|
|
534
535
|
const wf = B.workflowOf(board, base.id, folded);
|
|
535
536
|
const cat = B.catOf({ workflow: wf }, s.stage);
|
|
536
537
|
const row = {
|
|
537
|
-
id: base.id, title: base.title, lane: base.lane, stage: s.stage, cat, owner: base.owner, anchor: base.anchor,
|
|
538
|
+
id: base.id, title: base.title, lane: base.lane, kind: WK.kindOf(base.kind), stage: s.stage, cat, owner: base.owner, anchor: base.anchor,
|
|
538
539
|
status: base.status, start: ts ? minDay(base.start, ts.start) : base.start, end: ts ? maxDay(base.end, ts.end) : base.end, progress: base.progress, warnings: [],
|
|
539
540
|
rank: base.rank, health: B.isActive(base) ? base.health : null, updated: base.updated, reading: base.reading, stageSource: s.source, lifecycle: base.lifecycle,
|
|
540
541
|
stopped: base.stopped || null, archived: archivedOf(folded, base.id),
|
|
@@ -1181,7 +1182,7 @@ const WRITES = {
|
|
|
1181
1182
|
if (a.state !== 'open') return fail(ctx, res, 409, `ask ${a.id} is ${a.state} already`);
|
|
1182
1183
|
if (!p.file) return fail(ctx, res, 409, NO_STATE);
|
|
1183
1184
|
const input = { title: body.title, lane: body.lane, anchor: body.anchor };
|
|
1184
|
-
for (const k of ['intent', 'id']) if (body[k] != null && body[k] !== '') input[k] = body[k];
|
|
1185
|
+
for (const k of ['intent', 'id', 'kind']) if (body[k] != null && body[k] !== '') input[k] = body[k];
|
|
1185
1186
|
const made = createAndPlace(ctx, p.w, p.board.id, input, g.actor,
|
|
1186
1187
|
({ file, initiative, stage }) => append(file, g.actor, { kind: 'ask-accept', board: p.board.id, ask: a.id, initiative, stage }));
|
|
1187
1188
|
if (!made.ok) return fail(ctx, res, made.status || 400, made.error, { field: made.field || null });
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-core-docs.js — the core documents of each level (initiative core-documents, PRD sections 3 to 5).
|
|
3
3
|
*
|
|
4
|
-
* GET /api/core-docs?ws&level=portfolio|board
|
|
4
|
+
* GET /api/core-docs?ws&level=initiative&id (level=portfolio|board: 410, retired)
|
|
5
5
|
* → { ok, level, scope, question, reader, rhythm, build, wfTpl, stage, cat, summary: { draft, due, missing, stale }, docs: [entry + state] }
|
|
6
6
|
* 202 { ok: true, pending: true } while the initiatives are still being read (level=initiative only)
|
|
7
7
|
* POST /api/core-docs/draft { ws, scope, key } → { ok, run } starts a core-doc run; 409 when one runs for that entry
|
|
8
|
+
* Every route answers 410 for a portfolio or board scope (retired, below).
|
|
8
9
|
* POST /api/core-docs/issue { ws, scope, key, slot } → { ok } `state: issued` in the file and one `issue` line
|
|
9
10
|
* POST /api/core-docs/drop { ws, scope, key, slot } → { ok } one `drop` line
|
|
10
11
|
*
|
|
11
12
|
* WHO WRITES. Every POST refuses a request that carries an agent session header (403), as routes-scan.js does. Draft it passes pm-guard
|
|
12
13
|
* requirePagePress; Issue it and Drop pass requirePmPress (act `issue`): only the PM issues or drops a core document. A draft is never sent.
|
|
13
14
|
*
|
|
14
|
-
* THE RUN. A press on Draft it (
|
|
15
|
+
* THE RUN. A press on Draft it (an initiative document) starts ONE headless run, kind `core-doc` (lib/headless.js), origin
|
|
15
16
|
* `core-doc:<scope>:<key>`. Its tools are Read, Glob, Grep and `pmos coredoc write`; the server pins the entry it may write with
|
|
16
17
|
* PMOS_CORE_DOC_SCOPE and PMOS_CORE_DOC_KEY. There is no cap on how many run at once (PM, 2026-10-13: no run limit).
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* run: the refresh log says so and Needs you tells the PM (lib/refresh-run.js). The schedule does not try those documents again until the next
|
|
24
|
-
* day. A batch that wrote some drafts is progress: the documents still missing are tried on the next tick.
|
|
19
|
+
* PORTFOLIO AND BOARD DOCUMENTS ARE RETIRED (feedback batch 29 item 8; Wawan picked option A on 2026-11-10). Under D107 each of them has
|
|
20
|
+
* a home in the seven artefacts (the Narrative is the weekly update, Lessons keep the retro, Intent and Goal keep the charter and the
|
|
21
|
+
* metrics), and on the 3 Nov backup PMOS had drafted 80 of them with none issued. So nothing drafts them any more: every route answers 410
|
|
22
|
+
* for a portfolio or board scope, and the tick drafts nothing. The documents already written stay on disk, untouched, with their ledger
|
|
23
|
+
* lines (lib/core-docs.js; `pmos artefacts` still reads them). Initiative documents are unchanged (Draft it here, the Initiative Driver's doc-due).
|
|
25
24
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
25
|
+
* A FAILURE IS NOT RETRIED IN A LOOP. A run that ends having written no draft (the command could not run, the run was refused) is a failed
|
|
26
|
+
* run: the refresh log says so (lib/refresh-run.js).
|
|
27
|
+
*
|
|
28
|
+
* THERE IS NO TICK. It drafted the due portfolio and board documents (opt-in with PMOS_CORE_DOCS=on since D107); it is gone, and that switch
|
|
29
|
+
* does nothing. The background queue's `coredocs` step (server.js) is a no-op, so the queue and the Sources row keep their shape.
|
|
30
30
|
*/
|
|
31
31
|
const guard = require('./pm-guard.js');
|
|
32
32
|
const CD = require('./core-docs.js');
|
|
@@ -35,11 +35,8 @@ const headless = require('./headless.js');
|
|
|
35
35
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
36
36
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
37
37
|
const POSTS = ['draft', 'issue', 'drop'];
|
|
38
|
-
const TICK_EVERY_MS = 30 * 60 * 1000;
|
|
39
38
|
|
|
40
39
|
const runs = new Map(); // `${ws}|${scope}|${key}` → session id, for the core-doc runs this server started
|
|
41
|
-
const missed = new Map(); // `${ws}|${scope}|${key}` → the local day a scheduled run for it ended with no draft at all: not tried again that day
|
|
42
|
-
let lastTick = null;
|
|
43
40
|
|
|
44
41
|
const runKey = (ws, scope, key) => `${ws}|${scope}|${key}`;
|
|
45
42
|
function wsOf(ctx, id) {
|
|
@@ -51,19 +48,20 @@ const isRunning = (ws) => (scope, key) => runs.has(runKey(ws, scope, key));
|
|
|
51
48
|
/** The entry of a scope in this workspace: the level's facts must find the board or the initiative. → { ok, entry, facts } | refusal */
|
|
52
49
|
function resolve(ctx, w, scope, key, now) {
|
|
53
50
|
const p = CD.parseScope(scope);
|
|
54
|
-
if (!p) return { ok: false, status: 400, error: 'scope must be
|
|
51
|
+
if (!p) return { ok: false, status: 400, error: 'scope must be initiative:<id>' };
|
|
52
|
+
if (CD.RETIRED_LEVELS.includes(p.level)) return { ok: false, status: 410, error: CD.RETIRED };
|
|
55
53
|
let entry = CD.entryOf(p.level, key);
|
|
56
54
|
if (!entry) return { ok: false, status: 400, error: `no core document ${String(key).slice(0, 40)} at the ${p.level} level` };
|
|
57
|
-
const g = CD.gather(ctx, w, { level: p.level,
|
|
55
|
+
const g = CD.gather(ctx, w, { level: p.level, id: p.id, now });
|
|
58
56
|
if (g.pending) return { ok: false, status: 202, error: 'The initiatives are being read. Ask again in a few seconds.' };
|
|
59
57
|
if (!g.ok) return g;
|
|
60
58
|
// D99: the initiative's own set holds the full entry (a workflow stage's document carries its name, stage and template)
|
|
61
|
-
|
|
59
|
+
{ const hit = g.facts.list.find((x) => x.entry.key === key); if (hit) entry = hit.entry; }
|
|
62
60
|
return { ok: true, entry, facts: g.facts, level: p.level, id: p.id };
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
/** Start the run that drafts one entry. → { ok, run } | { ok: false, status, error } */
|
|
66
|
-
function startRun(ctx, w, scope, entry, { label, now
|
|
64
|
+
function startRun(ctx, w, scope, entry, { label, now } = {}) {
|
|
67
65
|
if (typeof ctx.spawnSession !== 'function') return { ok: false, status: 409, error: 'this workspace cannot start sessions' };
|
|
68
66
|
const origin = `core-doc:${scope}:${entry.key}`;
|
|
69
67
|
if (headless.kindFor({ agent: 'claude', origin }) !== 'core-doc') return { ok: false, status: 409, error: 'Background runs are switched off here (PMOS_HEADLESS=off), so PMOS cannot draft this document.' };
|
|
@@ -77,8 +75,7 @@ function startRun(ctx, w, scope, entry, { label, now, scheduled = false } = {})
|
|
|
77
75
|
onDone: () => {
|
|
78
76
|
runs.delete(k); try { if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id); } catch { /* the next poll recounts */ }
|
|
79
77
|
if (!unwritten(w, scope, [entry.key], t0).length) return undefined;
|
|
80
|
-
|
|
81
|
-
return { failed: `the run wrote no draft of the ${entry.title.toLowerCase()}.` + (scheduled ? ' The schedule tries it again tomorrow; Draft it tries now.' : '') };
|
|
78
|
+
return { failed: `the run wrote no draft of the ${entry.title.toLowerCase()}.` };
|
|
82
79
|
} });
|
|
83
80
|
if (!s || s.state === 'exited' || s.headless !== 'core-doc') {
|
|
84
81
|
if (s && s.headless !== 'core-doc' && s.state !== 'exited' && typeof ctx.stopSession === 'function') { try { ctx.stopSession(s.id); } catch { /* best effort */ } }
|
|
@@ -94,93 +91,7 @@ function unwritten(w, scope, keys, t0) {
|
|
|
94
91
|
return keys.filter((key) => { const x = store.get(`${scope}|${key}`); return !(x && x.drafts.some((d) => Date.parse(d.at) >= t0 - 1000)); });
|
|
95
92
|
}
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
function startBatch(ctx, w, scope, entries, { label, now } = {}) {
|
|
99
|
-
if (typeof ctx.spawnSession !== 'function') return { ok: false, status: 409, error: 'this workspace cannot start sessions' };
|
|
100
|
-
const origin = `core-doc:${scope}:batch`;
|
|
101
|
-
if (headless.kindFor({ agent: 'claude', origin }) !== 'core-doc') return { ok: false, status: 409, error: 'Background runs are switched off here (PMOS_HEADLESS=off), so PMOS cannot draft these documents.' };
|
|
102
|
-
const todo = entries.filter((e) => !runs.has(runKey(w.id, scope, e.key)));
|
|
103
|
-
if (!todo.length) return { ok: false, status: 409, error: 'PMOS is drafting these documents already' };
|
|
104
|
-
const t0 = now == null ? Date.now() : now;
|
|
105
|
-
const keys = todo.map((e) => e.key);
|
|
106
|
-
const prompt = CD.batchPrompt(todo, scope, { today: CD.localDay(t0), label });
|
|
107
|
-
let sid = null;
|
|
108
|
-
const s = ctx.spawnSession({ name: `Core documents · ${todo.length} drafts`, agent: 'claude', ws: w.id, origin, initialInput: prompt + '\r',
|
|
109
|
-
extraEnv: { PMOS_CORE_DOC_SCOPE: scope, PMOS_CORE_DOC_KEYS: keys.join(',') },
|
|
110
|
-
onDone: () => {
|
|
111
|
-
for (const key of keys) if (runs.get(runKey(w.id, scope, key)) === sid) runs.delete(runKey(w.id, scope, key));
|
|
112
|
-
try { if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id); } catch { /* the next poll recounts */ }
|
|
113
|
-
const left = unwritten(w, scope, keys, t0);
|
|
114
|
-
if (left.length < keys.length) return undefined; // some drafts came: the rest are tried on the next tick
|
|
115
|
-
const day = CD.localDay(t0); // the day the run started (the tick's clock)
|
|
116
|
-
for (const key of keys) missed.set(runKey(w.id, scope, key), day);
|
|
117
|
-
return { failed: `the run wrote none of its ${keys.length} drafts. The schedule tries them again tomorrow; Draft it tries one now.` };
|
|
118
|
-
} });
|
|
119
|
-
if (!s || s.state === 'exited' || s.headless !== 'core-doc') {
|
|
120
|
-
if (s && s.headless !== 'core-doc' && s.state !== 'exited' && typeof ctx.stopSession === 'function') { try { ctx.stopSession(s.id); } catch { /* best effort */ } }
|
|
121
|
-
return { ok: false, status: 409, error: 'The drafts could not start: ' + ((s && s.note) || 'no background run') };
|
|
122
|
-
}
|
|
123
|
-
sid = s.id;
|
|
124
|
-
for (const key of keys) runs.set(runKey(w.id, scope, key), s.id);
|
|
125
|
-
return { ok: true, run: s.id, keys };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const labelOf = (facts) => (facts.level === 'board' && facts.board ? facts.board.name : facts.level === 'initiative' && facts.row ? `${facts.row.id} ${facts.row.title || ''}`.trim() : null);
|
|
129
|
-
|
|
130
|
-
// ── the tick ─────────────────────────────────────────────────────────────────────────────────────────
|
|
131
|
-
/** Draft the doc entries of the portfolio and the boards that are due, out of date or not started (due first). → [{ ws, scope, key, ok, error? }] */
|
|
132
|
-
function tick(ctx, { now = Date.now(), force = false } = {}) {
|
|
133
|
-
if (!ctx || typeof ctx.getWs !== 'function') return [];
|
|
134
|
-
if (!force && lastTick != null && now - lastTick < TICK_EVERY_MS) return [];
|
|
135
|
-
const settings = (() => { try { return ctx.proSettings ? ctx.proSettings() : null; } catch { return null; } })();
|
|
136
|
-
const open = ctx.deepOpen ? ctx.deepOpen(settings || {}, now) : require('./driver-run.js').dayCheckOpen(settings || {}, now, ctx.inQuiet || (() => false)); // batch 18 item 9: at night or when idle
|
|
137
|
-
if (!open) return [];
|
|
138
|
-
lastTick = now;
|
|
139
|
-
// D107 (seven artefacts): the schedule drafts no portfolio or board document by default; the Narrative is the only report and the
|
|
140
|
-
// Lessons keep what a retro or a review held. PMOS_CORE_DOCS=on brings the old schedule back. Draft it on a card still works.
|
|
141
|
-
if (headless.switchedOff(process.env) || !/^(on|1|true|yes)$/i.test(String(process.env.PMOS_CORE_DOCS || ''))) return [];
|
|
142
|
-
const day = CD.localDay(now);
|
|
143
|
-
const out = [];
|
|
144
|
-
const list = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : [ctx.getWs(null)].filter(Boolean);
|
|
145
|
-
// Every candidate first, then the most pressing: due (issued, cadence passed), out of date, then not started (the first draft, and the
|
|
146
|
-
// proposed OKRs while no OKR files exist). No cap: every candidate starts; a failed run is tried again on the next tick.
|
|
147
|
-
const RANK = { due: 0, stale: 1, missing: 2 };
|
|
148
|
-
const todo = [];
|
|
149
|
-
for (const w of list) {
|
|
150
|
-
if (!w || !w.root) continue;
|
|
151
|
-
if (typeof ctx.isLead === 'function' && !ctx.isLead(w)) continue;
|
|
152
|
-
const levels = [{ level: 'portfolio' }];
|
|
153
|
-
try { for (const b of require('./routes-boards.js').frameFor(ctx, w).boards) levels.push({ level: 'board', board: b.id }); } catch { /* the portfolio still drafts */ }
|
|
154
|
-
for (const [li, lv] of levels.entries()) {
|
|
155
|
-
let g;
|
|
156
|
-
try { g = CD.gather(ctx, w, { ...lv, now }); } catch { continue; }
|
|
157
|
-
if (!g.ok) continue;
|
|
158
|
-
for (const [ei, entry] of g.facts.entries.entries()) {
|
|
159
|
-
if (!CD.draftable(entry) && !(entry.store && entry.by !== 'you')) continue;
|
|
160
|
-
const st = CD.stateOf(entry, g.facts);
|
|
161
|
-
if (!(st.st in RANK) || st.draft) continue;
|
|
162
|
-
const k = runKey(w.id, g.facts.scope, entry.key);
|
|
163
|
-
if (runs.has(k) || missed.get(k) === day) continue; // a run for it is going, or today's run for it wrote nothing
|
|
164
|
-
const x = g.facts.store.get(`${g.facts.scope}|${entry.key}`);
|
|
165
|
-
if (x && x.drafts.some((d) => x.drops.has(d.slot) && CD.localDay(Date.parse(d.at)) === day)) continue; // the PM dropped today's draft: not again until tomorrow
|
|
166
|
-
todo.push({ w, g, entry, k, order: [RANK[st.st], li, ei] });
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
todo.sort((a, b) => a.order[0] - b.order[0] || a.order[1] - b.order[1] || a.order[2] - b.order[2]);
|
|
171
|
-
// One run per scope: the most pressing scope first, its entries in rank order.
|
|
172
|
-
const groups = new Map();
|
|
173
|
-
for (const t of todo) { const gk = `${t.w.id}|${t.g.facts.scope}`; if (!groups.has(gk)) groups.set(gk, []); groups.get(gk).push(t); }
|
|
174
|
-
for (const list of groups.values()) {
|
|
175
|
-
const { w, g } = list[0];
|
|
176
|
-
const scope = g.facts.scope;
|
|
177
|
-
const r = list.length === 1
|
|
178
|
-
? startRun(ctx, w, scope, list[0].entry, { label: labelOf(g.facts), now, scheduled: true })
|
|
179
|
-
: startBatch(ctx, w, scope, list.map((t) => t.entry), { label: labelOf(g.facts), now });
|
|
180
|
-
for (const t of list) out.push({ ws: w.id, scope, key: t.entry.key, ok: r.ok, ...(r.ok ? { run: r.run } : { error: r.error }) });
|
|
181
|
-
}
|
|
182
|
-
return out;
|
|
183
|
-
}
|
|
94
|
+
const labelOf = (facts) => (facts.row ? `${facts.row.id} ${facts.row.title || ''}`.trim() : null);
|
|
184
95
|
|
|
185
96
|
// ── the handler ──────────────────────────────────────────────────────────────────────────────────────
|
|
186
97
|
async function handle(req, res, url, ctx) {
|
|
@@ -192,7 +103,7 @@ async function handle(req, res, url, ctx) {
|
|
|
192
103
|
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
193
104
|
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
194
105
|
if (!w) return send(bad(404, 'no such workspace'));
|
|
195
|
-
const level = text(url.searchParams.get('level')) || '
|
|
106
|
+
const level = text(url.searchParams.get('level')) || 'initiative';
|
|
196
107
|
const g = CD.gather(ctx, w, { level, board: url.searchParams.get('board') || null, id: url.searchParams.get('id') || null, now: Date.now() });
|
|
197
108
|
if (g.pending) return send({ status: 202, body: { ok: true, pending: true } });
|
|
198
109
|
if (!g.ok) return send(bad(g.status || 400, g.error));
|
|
@@ -217,8 +128,7 @@ async function handle(req, res, url, ctx) {
|
|
|
217
128
|
if (!r.ok) return send(bad(r.status || 400, r.error));
|
|
218
129
|
if (!CD.storable(r.entry)) return send(bad(400, `${r.entry.title} is read from its own source; there is nothing to draft here`));
|
|
219
130
|
if (r.entry.by === 'you') return send(bad(400, `You write the ${r.entry.title.toLowerCase()}. PMOS only checks it`));
|
|
220
|
-
if (r.
|
|
221
|
-
if (r.level === 'initiative' && !r.facts.list.some((x) => x.entry.key === key)) return send(bad(400, `${r.entry.title} is not in this initiative's set`));
|
|
131
|
+
if (!r.facts.list.some((x) => x.entry.key === key)) return send(bad(400, `${r.entry.title} is not in this initiative's set`));
|
|
222
132
|
const s = startRun(ctx, w, scope, r.entry, { label: labelOf(r.facts), now });
|
|
223
133
|
if (!s.ok) return send(bad(s.status, s.error));
|
|
224
134
|
return send({ status: 200, body: { ok: true, run: s.run } });
|
|
@@ -232,4 +142,4 @@ async function handle(req, res, url, ctx) {
|
|
|
232
142
|
return send({ status: 200, body: { ok: true } });
|
|
233
143
|
}
|
|
234
144
|
|
|
235
|
-
module.exports = { prefixes: ['/api/core-docs'], handle,
|
|
145
|
+
module.exports = { prefixes: ['/api/core-docs'], handle, startRun, _runs: runs, _reset: () => { runs.clear(); } };
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* POST /api/custom-docs/add { ws, scope, title, writer, phase, kind, url } → { ok, doc } one `add` line in custom-docs.jsonl
|
|
6
6
|
*
|
|
7
7
|
* WHO WRITES. The POST refuses a request that carries an agent session header (403), as routes-core-docs.js does, and passes pm-guard
|
|
8
|
-
* requirePagePress: the launch nonce and the page's origin. The scope must be
|
|
9
|
-
*
|
|
8
|
+
* requirePagePress: the launch nonce and the page's origin. The scope must be an initiative the workspace knows (lib/core-docs.js gather).
|
|
9
|
+
* A board scope is 410: board documents are retired (feedback batch 29 item 8); the GET still lists the ones added before. The route stores
|
|
10
|
+
* what the PM typed and nothing else: it never reads a linked page. */
|
|
10
11
|
const guard = require('./pm-guard.js');
|
|
11
12
|
const CD = require('./core-docs.js');
|
|
12
13
|
const Custom = require('./custom-docs.js');
|
|
@@ -18,13 +19,14 @@ function wsOf(ctx, id) {
|
|
|
18
19
|
const w = ctx.getWs(id || null);
|
|
19
20
|
return w && (!id || w.id === id) ? w : null;
|
|
20
21
|
}
|
|
21
|
-
/** The scope must name
|
|
22
|
+
/** The scope must name an initiative this workspace holds; a board scope is retired (410). → null | refusal */
|
|
22
23
|
function known(ctx, w, scope) {
|
|
23
24
|
const p = CD.parseScope(scope);
|
|
24
|
-
if (!p
|
|
25
|
-
|
|
25
|
+
if (!p) return bad(400, 'scope must be initiative:<id>');
|
|
26
|
+
if (CD.RETIRED_LEVELS.includes(p.level)) return bad(410, CD.RETIRED);
|
|
27
|
+
const g = CD.gather(ctx, w, { level: p.level, id: p.id, now: Date.now() });
|
|
26
28
|
if (g.pending) return bad(202, 'The initiatives are being read. Ask again in a few seconds.');
|
|
27
|
-
if (!g.ok) return bad(g.status || 404, g.error || 'no such
|
|
29
|
+
if (!g.ok) return bad(g.status || 404, g.error || 'no such initiative');
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* POST /api/initiatives { ws, title, lane, anchor, intent?, id?, from?, specimen_test?, surface_check? }
|
|
10
10
|
* → { ok, id, path, written, sig } New initiative (requirePagePress)
|
|
11
11
|
* POST /api/initiatives/rename { ws, id, title } → { ok, id, from, title, path, sig } rename: the record's title only (requirePagePress)
|
|
12
|
+
* POST /api/initiatives/kind { ws, id, kind } → { ok, id, from, kind, sig } the kind of work: product | sdlc | project (requirePagePress)
|
|
12
13
|
* POST /api/initiatives/rescan { ws } → { ok, started, running } read the repository again now (requirePagePress);
|
|
13
14
|
* nothing is written: the cached rows go stale and one derivation starts
|
|
14
15
|
* POST /api/initiatives/duplicates { ws } → { ok, profile, archive, groups } documents that share an initiative and a
|
|
@@ -648,6 +649,17 @@ async function handle(req, res, url, ctx) {
|
|
|
648
649
|
ctx.json(res, { ok: true, id: r.id, from: r.from, title: r.title, path: r.path, sig: sigOf(w.root) });
|
|
649
650
|
return true;
|
|
650
651
|
}
|
|
652
|
+
if (p === '/api/initiatives/kind') {
|
|
653
|
+
// the kind of work (batch 29 item 11, Viewer KdV1-3): only the record's `kind:` line changes; product | sdlc | project
|
|
654
|
+
const g = guard.requirePagePress(req, body);
|
|
655
|
+
if (!g.ok) return answer(ctx, res, g), true;
|
|
656
|
+
const r = writer.setKind(w.root, body.id, body.kind, { actor: g.actor });
|
|
657
|
+
if (!r.ok) { ctx.json(res, { ok: false, status: r.status, error: r.error, field: r.field }, r.status); return true; }
|
|
658
|
+
rowsLib.invalidate(w.root);
|
|
659
|
+
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id);
|
|
660
|
+
ctx.json(res, { ok: true, id: r.id, from: r.from, kind: r.kind, sig: sigOf(w.root) });
|
|
661
|
+
return true;
|
|
662
|
+
}
|
|
651
663
|
// split or merge initiatives (feedback batch 11 item 14; lib/split-merge.js): the editor's button or ✓ on Claude's card, Undo, and ✕ Not now
|
|
652
664
|
const SM_ROUTES = { '/api/initiatives/split': 'split', '/api/initiatives/merge': 'merge', '/api/initiatives/sm-undo': 'undo', '/api/initiatives/suggest': 'dismiss' };
|
|
653
665
|
if (SM_ROUTES[p]) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-intake.js — planning-flows run 4: the one-line intake draft.
|
|
3
|
-
* POST /api/intake/draft { line, acknowledged? } → { ok, draft }
|
|
3
|
+
* POST /api/intake/draft { line, acknowledged? } → { ok, draft } draft.kind and draft.kind_cue: the kind of work the name reads as
|
|
4
|
+
* (lib/work-kind.js fromName; kind_cue '' when the name tells nothing)
|
|
4
5
|
* Drafts only. Creating the initiative stays with createInitiative, which refuses an unanchored create. */
|
|
5
6
|
const path = require('path');
|
|
6
7
|
const guard = require('./pm-guard.js');
|
|
7
8
|
const { repoScript } = require('./repo-script.js');
|
|
8
9
|
const intake = require(repoScript('intake.js'));
|
|
10
|
+
const WK = require('./work-kind.js');
|
|
9
11
|
|
|
10
12
|
const ROOT = path.resolve(__dirname, '..', '..');
|
|
11
13
|
|
|
@@ -19,7 +21,9 @@ module.exports = {
|
|
|
19
21
|
const g = guard.requirePagePress(req, body);
|
|
20
22
|
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
21
23
|
if (typeof body.line !== 'string' || !body.line.trim()) { ctx.json(res, { ok: false, error: 'line is required' }, 400); return true; }
|
|
22
|
-
|
|
24
|
+
const draft = intake.intakeDraft({ line: body.line, root: ctx.root || ROOT, acknowledged: body.acknowledged === true });
|
|
25
|
+
const k = WK.fromName(body.line, draft && draft.lane);
|
|
26
|
+
ctx.json(res, { ok: true, draft: { ...draft, kind: k.kind, kind_cue: k.cue } });
|
|
23
27
|
return true;
|
|
24
28
|
},
|
|
25
29
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* work-kind.js — the kind of work of an initiative (batch 29 item 11; main canvas boards KdA, KdAP, KdV1-3, KdBd, agreed by the PM
|
|
3
|
+
* 2026-11-11, option A). The PM picks one kind when the initiative is made; PMOS works out the rest from it.
|
|
4
|
+
*
|
|
5
|
+
* KINDS ['product', 'sdlc', 'project']
|
|
6
|
+
* LABEL[kind] · SHORT[kind] 'Product management' · 'Product' (the switch's word)
|
|
7
|
+
* kindOf(value) → kind a record's `kind:` value, read; anything else (no line, an old record) is 'product'
|
|
8
|
+
* valid(value) → bool one of the three, exactly
|
|
9
|
+
* fromName(name, lane) → { kind, cue } the pre-pick from the name and the intake draft's lane; cue is the word that decided it,
|
|
10
|
+
* or '' when nothing did (then the kind is 'product' and the page shows no ✦ line)
|
|
11
|
+
* executorOf(kind) → 'factory' | 'team' who builds by default (lib/artefacts.js EXECUTORS): Full SDLC → PMOS (the factory, D65:
|
|
12
|
+
* propose-only, the PM merges); Product and Project → the team
|
|
13
|
+
*
|
|
14
|
+
* A HINT, NOT A LANE (D107). The kind sits on the record beside the lane; it does not replace the lane. The Initiative Gate, the stages
|
|
15
|
+
* and the default workflow do not read it. No model call: the pre-pick is the small word table below, and when it cannot tell it says so
|
|
16
|
+
* (cue '') instead of guessing. */
|
|
17
|
+
|
|
18
|
+
const KINDS = Object.freeze(['product', 'sdlc', 'project']);
|
|
19
|
+
const LABEL = Object.freeze({ product: 'Product management', sdlc: 'Full SDLC', project: 'Project management' });
|
|
20
|
+
const SHORT = Object.freeze({ product: 'Product', sdlc: 'Full SDLC', project: 'Project' });
|
|
21
|
+
const DEFAULT = 'product';
|
|
22
|
+
|
|
23
|
+
const valid = (v) => typeof v === 'string' && KINDS.includes(v);
|
|
24
|
+
/** The kind a record's value reads as: one of the three, else Product management (an old record has no line). */
|
|
25
|
+
const kindOf = (v) => { const s = typeof v === 'string' ? v.trim().replace(/^["']|["']$/g, '') : ''; return valid(s) ? s : DEFAULT; };
|
|
26
|
+
|
|
27
|
+
// the cues, as whole words. Full SDLC only on an explicit build word (never from a lane alone); Project on a delivery word.
|
|
28
|
+
const SDLC = ['build', 'implement', 'api', 'endpoint', 'refactor', 'fix bug', 'bug fix', 'bugfix', 'sdk'];
|
|
29
|
+
const PROJECT = ['migrate', 'migration', 'tender', 'rollout', 'roll out', 'vendor', 'procurement', 'rfp', 'cutover', 'decommission', 'renewal', 'contract', 'deadline', 'by q1', 'by q2', 'by q3', 'by q4'];
|
|
30
|
+
const DATE = /\b(by|before|until|due)\s+(\d{1,2}\s+)?(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\b|\b20\d\d-\d\d-\d\d\b/i;
|
|
31
|
+
const hit = (text, words) => words.find((w) => new RegExp('\\b' + w.replace(/ /g, '\\s+') + '\\b', 'i').test(text)) || '';
|
|
32
|
+
|
|
33
|
+
/** The pre-pick. A build word gives Full SDLC; a delivery word or a date gives Project; nothing gives Product with no cue. */
|
|
34
|
+
function fromName(name, lane) {
|
|
35
|
+
const t = String(name || '');
|
|
36
|
+
if (!t.trim()) return { kind: DEFAULT, cue: '' };
|
|
37
|
+
const b = hit(t, SDLC);
|
|
38
|
+
if (b) return { kind: 'sdlc', cue: b };
|
|
39
|
+
const p = hit(t, PROJECT) || ((DATE.exec(t) || [])[0] || '');
|
|
40
|
+
if (p) return { kind: 'project', cue: p.trim() };
|
|
41
|
+
// feature, discovery, prototype and content are product work; a chore or an incident with no delivery cue stays product too
|
|
42
|
+
void lane;
|
|
43
|
+
return { kind: DEFAULT, cue: '' };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const executorOf = (kind) => (kindOf(kind) === 'sdlc' ? 'factory' : 'team');
|
|
47
|
+
|
|
48
|
+
module.exports = { KINDS, LABEL, SHORT, DEFAULT, valid, kindOf, fromName, executorOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.559.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.559.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* premium-core-doc-issue-test.js — Issue it on a core document draft, on the premium Board and the premium initiative page (initiative premium-core-doc-issue;
|
|
4
4
|
* planning/prd/premium-core-doc-issue-prd.md I1 to I7). A real server on a scratch `team` repository, never the PMOS checkout. The drafts are written by the
|
|
5
5
|
* core-docs writer (lib/core-docs.js writeDraft), so the pages read what the agent's run would leave. The real pages press the real route:
|
|
6
|
-
* R reading (slot and path) · B
|
|
6
|
+
* R reading (slot and path) · B a board scope is refused (board documents are retired, batch 29 item 8) · I the initiative (a layout in Home since premium-agreed-design: its Overview, the draft
|
|
7
7
|
* reader in the Viewer), unsaved edits and a refusal · P the POST allow-list · F floors */
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
@@ -47,10 +47,10 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
47
47
|
await T.waitForServer(BASE);
|
|
48
48
|
const ready = await until(async () => { const r = await fetch(BASE + '/api/board-premium'); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' && j.model.initiatives.list.rows.length ? j : null; }, 90000, 400);
|
|
49
49
|
if (!ready) { ok('setup the real route reads the scratch board', false); return finish(1); }
|
|
50
|
-
const B = ready.model.board, bscope =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const B = ready.model.board, bscope = 'board:' + B.id;
|
|
51
|
+
// batch 29 item 8: board documents are retired. The board model carries none, and the writer refuses a board scope
|
|
52
|
+
const d1 = CD.writeDraft(team, { scope: bscope, key: 'charter', markdown: BODY, by: 'agent:test', now: Date.now() });
|
|
53
|
+
ok('setup the board model has no documents, and the writer refuses a board scope (410)', !('docs' in ready.model) && d1.status === 410, JSON.stringify(d1));
|
|
54
54
|
const iq = '?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id);
|
|
55
55
|
const ini = await until(async () => { const r = await fetch(BASE + '/api/initiative-premium' + iq); const j = await r.json().catch(() => null); return r.status === 200 && j && j.ok && j.state === 'ready' ? j : null; }, 90000, 400);
|
|
56
56
|
/* the initiative documents PMOS keeps itself are Risks and Outcome review (lib/core-docs.js storable); the others are read from their own source */
|
|
@@ -61,12 +61,9 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
61
61
|
if (!ikey) return finish(1);
|
|
62
62
|
const d2 = CD.writeDraft(team, { scope: iscope, key: ikey, markdown: BODY, by: 'agent:test', now: Date.now() });
|
|
63
63
|
const d3 = CD.writeDraft(team, { scope: iscope, key: free[1], markdown: BODY, by: 'agent:test', now: Date.now() });
|
|
64
|
-
ok('setup the writer left
|
|
64
|
+
ok('setup the writer left two drafts', d2.ok && d3.ok, JSON.stringify([d2, d3]));
|
|
65
65
|
|
|
66
66
|
/* R reading */
|
|
67
|
-
const board2 = await (await fetch(BASE + '/api/board-premium')).json();
|
|
68
|
-
const br = board2.model.docs.rows.find((d) => d.key === bkey);
|
|
69
|
-
ok('R1 the board model carries the draft\'s slot and path from the core-docs answer', br.st === 'draft' && br.slot === d1.slot && br.path === d1.path, JSON.stringify(br));
|
|
70
67
|
const ini2 = await (await fetch(BASE + '/api/initiative-premium' + iq)).json();
|
|
71
68
|
const ir = ini2.model.docs.rows.find((d) => d.key === ikey);
|
|
72
69
|
ok('R2 the initiative model carries the draft\'s slot and path', ir.st === 'draft' && ir.slot === d2.slot && ir.path === d2.path, JSON.stringify(ir));
|
|
@@ -87,14 +84,10 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
87
84
|
const H = await T.pressHeaders(BASE);
|
|
88
85
|
const nonce = H['x-pmos-nonce'];
|
|
89
86
|
|
|
90
|
-
/* B a board's own core document
|
|
91
|
-
issues it; the issue route still takes a board scope */
|
|
87
|
+
/* B a board's own core document: retired (batch 29 item 8). The issue route refuses a board scope */
|
|
92
88
|
const n0 = ledger().filter((l) => l.ev === 'issue').length;
|
|
93
|
-
const bres = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: H, body: JSON.stringify({ ws: B.ws, scope: bscope, key:
|
|
94
|
-
ok('B4 the issue route
|
|
95
|
-
const il = ledger().filter((l) => l.ev === 'issue');
|
|
96
|
-
ok('B5 the ledger has one new issue line for that draft', il.length === n0 + 1 && il[il.length - 1].slot === d1.slot && il[il.length - 1].scope === bscope, JSON.stringify(il));
|
|
97
|
-
ok('B5 the file now says state: issued', /^state: issued$/m.test(fs.readFileSync(path.join(team, d1.path), 'utf8')));
|
|
89
|
+
const bres = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: H, body: JSON.stringify({ ws: B.ws, scope: bscope, key: 'charter', slot: '2026-01-01' }) });
|
|
90
|
+
ok('B4 the issue route refuses a board scope (410) and writes no line', bres.status === 410 && ledger().filter((l) => l.ev === 'issue').length === n0, String(bres.status));
|
|
98
91
|
|
|
99
92
|
/* I the initiative: a layout inside Home (premium-agreed-design). The Board's expand link lands there; the card's Overview lists the core documents (its Documents view),
|
|
100
93
|
and a draft opens a minimal reader in the Viewer (Waiting for design) with the Issue it bar, Read and Edit */
|
|
@@ -154,9 +147,9 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
|
|
|
154
147
|
ok('P1 the pages post only to the issue route (and the conversation note)', all.length >= 2 && !other.length, JSON.stringify(other));
|
|
155
148
|
const sentAll = all.filter((x) => x.path === '/api/core-docs/issue');
|
|
156
149
|
ok('P2 every issue press carried the nonce and no writer field', sentAll.length >= 2 && sentAll.every((x) => x.headers['x-pmos-nonce'] === nonce && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)));
|
|
157
|
-
const bare = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: BASE }, body: JSON.stringify({ ws: B.ws, scope:
|
|
150
|
+
const bare = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: BASE }, body: JSON.stringify({ ws: B.ws, scope: iscope, key: ikey, slot: d2.slot }) });
|
|
158
151
|
ok('P3 a press without the launch nonce is refused', bare.status === 403);
|
|
159
|
-
const agent = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body: JSON.stringify({ ws: B.ws, scope:
|
|
152
|
+
const agent = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body: JSON.stringify({ ws: B.ws, scope: iscope, key: free[1], slot: d3.slot }) });
|
|
160
153
|
ok('P4 D98: an agent session is not refused as an agent (the press is checked like the PM\'s)', agent.status !== 403, String(agent.status));
|
|
161
154
|
ok('P5 no script error on any page', !I.errors.length && !J.errors.length, I.errors.concat(J.errors).join(' | '));
|
|
162
155
|
await J.ctx.close();
|